UNPKG

3.81 kBTypeScriptView Raw
1import { Loader, TemplateRegistryEntry, LoaderPlugin } from 'aurelia-loader';
2export declare type LoaderPlugin = {
3 fetch: (address: string) => Promise<TemplateRegistryEntry> | TemplateRegistryEntry;
4};
5/**
6* An implementation of the TemplateLoader interface implemented with text-based loading.
7*/
8export declare class TextTemplateLoader {
9 /**
10 * Loads a template.
11 * @param loader The loader that is requesting the template load.
12 * @param entry The TemplateRegistryEntry to load and populate with a template.
13 * @return A promise which resolves when the TemplateRegistryEntry is loaded with a template.
14 */
15 loadTemplate(loader: Loader, entry: TemplateRegistryEntry): Promise<void>;
16}
17export declare function ensureOriginOnExports(moduleExports: any, moduleId: string): any;
18/**
19* A default implementation of the Loader abstraction which works with webpack (extended common-js style).
20*/
21export declare class WebpackLoader extends Loader {
22 moduleRegistry: any;
23 loaderPlugins: {
24 [name: string]: LoaderPlugin & {
25 hot?: ((moduleId: string) => void) | undefined;
26 };
27 };
28 modulesBeingLoaded: Map<string, Promise<any>>;
29 templateLoader: TextTemplateLoader;
30 hmrContext: {
31 handleModuleChange(moduleId: string, hot: Webpack.WebpackHotModule): Promise<void>;
32 handleViewChange(moduleId: string): Promise<void>;
33 };
34 constructor();
35 _import(address: string, defaultHMR?: boolean): Promise<any>;
36 /**
37 * Maps a module id to a source.
38 * @param id The module id.
39 * @param source The source to map the module to.
40 */
41 map(id: string, source: any): void;
42 /**
43 * Normalizes a module id.
44 * @param moduleId The module id to normalize.
45 * @param relativeTo What the module id should be normalized relative to.
46 * @return The normalized module id.
47 */
48 normalizeSync(moduleId: string, relativeTo: string): string;
49 /**
50 * Normalizes a module id.
51 * @param moduleId The module id to normalize.
52 * @param relativeTo What the module id should be normalized relative to.
53 * @return The normalized module id.
54 */
55 normalize(moduleId: string, relativeTo: string): Promise<string>;
56 /**
57 * Instructs the loader to use a specific TemplateLoader instance for loading templates
58 * @param templateLoader The instance of TemplateLoader to use for loading templates.
59 */
60 useTemplateLoader(templateLoader: TextTemplateLoader): void;
61 /**
62 * Loads a collection of modules.
63 * @param ids The set of module ids to load.
64 * @return A Promise for an array of loaded modules.
65 */
66 loadAllModules(ids: Array<string>): Promise<any[]>;
67 /**
68 * Loads a module.
69 * @param moduleId The module ID to load.
70 * @return A Promise for the loaded module.
71 */
72 loadModule(moduleId: string, defaultHMR?: boolean): Promise<any>;
73 /**
74 * Loads a template.
75 * @param url The url of the template to load.
76 * @return A Promise for a TemplateRegistryEntry containing the template.
77 */
78 loadTemplate(url: string): Promise<any>;
79 /**
80 * Loads a text-based resource.
81 * @param url The url of the text file to load.
82 * @return A Promise for text content.
83 */
84 loadText(url: string): Promise<any>;
85 /**
86 * Alters a module id so that it includes a plugin loader.
87 * @param url The url of the module to load.
88 * @param pluginName The plugin to apply to the module id.
89 * @return The plugin-based module id.
90 */
91 applyPluginToUrl(url: string, pluginName: string): string;
92 /**
93 * Registers a plugin with the loader.
94 * @param pluginName The name of the plugin.
95 * @param implementation The plugin implementation.
96 */
97 addPlugin(pluginName: string, implementation: LoaderPlugin): void;
98}
99
\No newline at end of file