/** * edge * * (c) EdgeJS * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import type { ComponentsTree, LoaderContract, LoaderTemplate } from './types.js'; /** * The job of a loader is to load the template from a given path. * The base loader (shipped with edge) looks for files on the * file-system and reads them synchronously. * * You are free to define your own loaders that implements the [[LoaderContract]] interface. */ export declare class Loader implements LoaderContract { #private; /** * Returns an object of mounted directories with their public * names. * * ```js * loader.mounted * // output * * { * default: '/users/virk/code/app/views', * foo: '/users/virk/code/app/foo', * } * ``` */ get mounted(): { [key: string]: string; }; /** * Returns an object of templates registered as a raw string * * ```js * loader.templates * // output * * { * 'form.label': { template: 'Template contents' } * } * ``` */ get templates(): { [templatePath: string]: LoaderTemplate; }; /** * Mount a directory with a name for resolving views. If name is set * to `default`, then you can resolve views without prefixing the * disk name. * * ```js * loader.mount('default', join(__dirname, 'views')) * * // mount a named disk * loader.mount('admin', join(__dirname, 'admin/views')) * ``` */ mount(diskName: string, dirPath: string | URL): void; /** * Remove the previously mounted dir. * * ```js * loader.unmount('default') * ``` */ unmount(diskName: string): void; /** * Make path to a given template. The paths are resolved from the root * of the mounted directory. * * ```js * loader.makePath('welcome') // returns {diskRootPath}/welcome.edge * loader.makePath('admin::welcome') // returns {adminRootPath}/welcome.edge * loader.makePath('users.list') // returns {diskRootPath}/users/list.edge * ``` * * @throws Error if disk is not mounted and attempting to make path for it. */ makePath(templatePath: string): string; /** * Resolves the template by reading its contents from the disk * * ```js * loader.resolve('welcome', true) * * // output * { * template: `