import { ASTPluginBuilder } from '@glimmer/syntax'; import { ProgramSymbolTable, ModuleLocator, CompilableProgram, CompilableTemplate, SerializedHeap, ConstantPool, SerializedTemplateBlock, CompileMode, WholeProgramCompilationContext, STDLib, CompileTimeHeap, SyntaxCompilationContext, CompileTimeConstants, Macros, Option, HandleResult } from '@glimmer/interfaces'; import ModuleLocatorMap from './module-locator-map'; import ExternalModuleTable from './external-module-table'; import BundleCompilerDelegate from './delegate'; import BundleCompilerLookup from './lookup'; export interface BundleCompileOptions { plugins: ASTPluginBuilder[]; } export interface BundleCompilerOptions { macros?: Macros; constants?: CompileTimeConstants; plugins?: ASTPluginBuilder[]; } /** * ModuleLocatorepresents the results of a bundle compilation. */ export interface BundleCompilationResult { /** * The VM handle corresponding to the program entry point. This is the heap * offset where execution will begin when the program starts. */ main: number; /** * The final result of program compilation, including the binary bytecode. */ heap: SerializedHeap; /** * A JSON-ready data structure containing constant values generated during * compilation. */ pool: ConstantPool; /** * A table mapping modules locators to their associated handles, and vice * versa. */ table: ExternalModuleTable; /** * A mapping of module locators to compiled template symbol tables. */ symbolTables: ModuleLocatorMap; } export interface PartialTemplateLocator extends ModuleLocator { meta: M; kind?: 'template'; } export { CompilableTemplate }; export declare class BundleCompilerCompilationContext implements WholeProgramCompilationContext { readonly delegate: BundleCompilerDelegate; readonly compilableTemplates: ModuleLocatorMap; readonly compiledBlocks: ModuleLocatorMap; readonly meta: ModuleLocatorMap; readonly constants: CompileTimeConstants; readonly resolverDelegate: BundleCompilerLookup; readonly heap: CompileTimeHeap; readonly mode = CompileMode.aot; readonly stdlib: STDLib; constructor(delegate: BundleCompilerDelegate, options: BundleCompilerOptions); } /** * The BundleCompiler is used to compile all of the component templates in a * Glimmer program into binary bytecode. * * First, you must call `add()` to push each component's template into the * bundle. Once every template in the program has been registered, the last step * is to call `compile()`, which begins eager compilation of the entire program * into the heap. * * At the end of compilation, the heap plus additional metadata is produced, * which is suitable for serialization into bytecode and JavaScript assets that * can be loaded and run in the browser. */ export default class BundleCompiler { protected macros: Macros; protected plugins: ASTPluginBuilder[]; private context; constructor(delegate: BundleCompilerDelegate, options?: BundleCompilerOptions); get syntaxContext(): SyntaxCompilationContext; /** * Adds the template source code for a component to the bundle. */ addTemplateSource(_locator: ModuleLocator, templateSource: string): SerializedTemplateBlock; /** * Adds a custom CompilableTemplate instance to the bundle. */ addCompilableTemplate(locator: ModuleLocator, template: CompilableProgram): void; getTemplate(locator: ModuleLocator): Option; /** * Compiles all of the templates added to the bundle. Once compilation * completes, the results of the compilation are returned, which includes * everything needed to serialize the Glimmer program into binary bytecode and * data segment. */ compile(): BundleCompilationResult; preprocess(locator: ModuleLocator, input: string): SerializedTemplateBlock; compilerModuleLocatorResolver(): BundleCompilerLookup; /** * Performs the actual compilation of the template identified by the passed * locator into the Program. ModuleLocatoreturns the VM handle for the compiled template. */ protected compileTemplate(locator: ModuleLocator): HandleResult; } /** * For developer convenience, we allow users to pass partially populated * TemplateLocator objects as identifiers for a given template. Because it is * always a TemplateLocator added to a bundle, we can populate missing fields * like the `kind` with the appropriate value and avoid boilerplate on the part * of API consumers. */ export declare function normalizeLocator(l: ModuleLocator): ModuleLocator; //# sourceMappingURL=bundle-compiler.d.ts.map