import { RichIteratorResult, Bounds, Cursor, Nullable, SimpleElement, SimpleNode, InternalComponentCapabilities, InternalComponentManager, CapturedArguments, CurriedType, Owner, GlimmerTreeChanges, SimpleDocument, SimpleComment, SimpleText, AttrNamespace, ElementNamespace, GlimmerTreeConstruction, ClassicResolver, ComponentInstanceWithCreate, Environment, EnvironmentOptions, ModifierInstance, RuntimeArtifacts, RuntimeOptions, Transaction, TransactionSymbol, CapturedRenderNode, DebugRenderTree, RenderNode, Arguments, CompilableProgram, ComponentDefinitionState, DynamicScope, EvaluationContext, RenderResult, TemplateIterator, TreeBuilder, Dict, Scope, ScopeBlock, ScopeSlot, CompilableTemplate, DebugVmSnapshot, DebugVmTrace, Destroyable, Program, ProgramConstants, UpdatingOpcode, RuntimeOp, BlockArguments, BlockValue, CapturedBlockArguments, CapturedNamedArguments, CapturedPositionalArguments, NamedArguments, PositionalArguments, VMArguments, AppendingBlock, ExceptionHandler, ResettableBlock, ElementOperations, Maybe, SimpleDocumentFragment, AttributeCursor, AttributeOperation } from '@glimmer/interfaces'; import { UpdatingVM as IUpdatingVM } from "@glimmer/interfaces"; import { Reference, OpaqueIterationItem, OpaqueIterator } from "@glimmer/reference"; import { Cache, Tag } from "@glimmer/validator"; import { MachineRegister, Register, SyscallRegister } from "@glimmer/vm"; import { Stack } from "@glimmer/util"; declare class CursorImpl implements Cursor { element: SimpleElement; nextSibling: Nullable; constructor(element: SimpleElement, nextSibling: Nullable); } declare class ConcreteBounds implements Bounds { parentNode: SimpleElement; private first; private last; constructor(parentNode: SimpleElement, first: SimpleNode, last: SimpleNode); parentElement(): SimpleElement; firstNode(): SimpleNode; lastNode(): SimpleNode; } declare function clear(bounds: Bounds): Nullable; type DebugGet = (path: string) => unknown; type DebugCallback = (context: unknown, get: DebugGet) => void; // For testing purposes declare function setDebuggerCallback(cb: DebugCallback): void; declare function resetDebuggerCallback(): void; declare class TemplateOnlyComponentManager implements InternalComponentManager { getCapabilities(): InternalComponentCapabilities; getDebugName({ name }: TemplateOnlyComponentDefinition): string; getSelf(): Reference; getDestroyable(): null; } declare const TEMPLATE_ONLY_COMPONENT_MANAGER: TemplateOnlyComponentManager; // This is only exported for types, don't use this class directly declare class TemplateOnlyComponentDefinition { moduleName: string; name: string; constructor(moduleName?: string, name?: string); toString(): string; } /** This utility function is used to declare a given component has no backing class. When the rendering engine detects this it is able to perform a number of optimizations. Templates that are associated with `templateOnly()` will be rendered _as is_ without adding a wrapping `
` (or any of the other element customization behaviors of [@ember/component](/ember/release/classes/Component)). Specifically, this means that the template will be rendered as "outer HTML". In general, this method will be used by build time tooling and would not be directly written in an application. However, at times it may be useful to use directly to leverage the "outer HTML" semantics mentioned above. For example, if an addon would like to use these semantics for its templates but cannot be certain it will only be consumed by applications that have enabled the `template-only-glimmer-components` optional feature. @example ```js import { templateOnlyComponent } from '@glimmer/runtime'; export default templateOnlyComponent(); ``` @public @method templateOnly @param {String} moduleName the module name that the template only component represents, this will be used for debugging purposes @category EMBER_GLIMMER_SET_COMPONENT_TEMPLATE */ declare function templateOnlyComponent(moduleName?: string, name?: string): TemplateOnlyComponentDefinition; declare const TYPE: unique symbol; declare const INNER: unique symbol; declare const OWNER: unique symbol; declare const ARGS: unique symbol; declare const RESOLVED: unique symbol; declare class CurriedValue { [TYPE]: T; [INNER]: object | string | CurriedValue; [OWNER]: Owner; [ARGS]: CapturedArguments | null; [RESOLVED]: boolean; /** @internal */ constructor(type: T, inner: object | string | CurriedValue, owner: Owner, args: CapturedArguments | null, resolved?: boolean); } declare function curry(type: T, spec: object | string | CurriedValue, owner: Owner, args: CapturedArguments | null, resolved?: boolean): CurriedValue; declare class DOMOperations { protected document: SimpleDocument; protected uselessElement: SimpleElement; // Set by this.setupUselessElement() in constructor constructor(document: SimpleDocument); // split into separate method so that NodeDOMTreeConstruction // can override it. protected setupUselessElement(): void; createElement(tag: string, context?: SimpleElement): SimpleElement; insertBefore(parent: SimpleElement, node: SimpleNode, reference: Nullable): void; insertHTMLBefore(parent: SimpleElement, nextSibling: Nullable, html: string): Bounds; createTextNode(text: string): SimpleText; createComment(data: string): SimpleComment; } declare function isWhitespace(string: string): boolean; declare class DOMChangesImpl extends DOMOperations implements GlimmerTreeChanges { protected document: SimpleDocument; protected namespace: Nullable; constructor(document: SimpleDocument); setAttribute(element: SimpleElement, name: string, value: string): void; removeAttribute(element: SimpleElement, name: string): void; insertAfter(element: SimpleElement, node: SimpleNode, reference: SimpleNode): void; } declare const DOMChanges: typeof DOMChangesImpl; declare class TreeConstruction extends DOMOperations implements GlimmerTreeConstruction { createElementNS(namespace: ElementNamespace, tag: string): SimpleElement; setAttribute(element: SimpleElement, name: string, value: string, namespace?: Nullable): void; } declare const DOMTreeConstruction: typeof TreeConstruction; type DOMTreeConstruction = TreeConstruction; /* * @method normalizeProperty * @param element {HTMLElement} * @param slotName {String} * @returns {Object} { name, type } */ declare function normalizeProperty(element: SimpleElement, slotName: string): { normalized: any; type: any; }; declare class DebugRenderTreeImpl implements DebugRenderTree { private stack; private refs; private roots; private nodes; begin(): void; create(state: TBucket, node: RenderNode): void; update(state: TBucket): void; didRender(state: TBucket, bounds: Bounds): void; willDestroy(state: TBucket): void; commit(): void; capture(): CapturedRenderNode[]; private reset; private enter; private exit; private nodeFor; private appendChild; private captureRefs; private captureNode; private captureTemplate; private captureBounds; } declare module DebugRenderTreeImplWrapper { export { DebugRenderTreeImpl }; } import DebugRenderTree$0 = DebugRenderTreeImplWrapper.DebugRenderTreeImpl; declare const TRANSACTION: TransactionSymbol; declare class TransactionImpl implements Transaction { scheduledInstallModifiers: ModifierInstance[]; scheduledUpdateModifiers: ModifierInstance[]; createdComponents: ComponentInstanceWithCreate[]; updatedComponents: ComponentInstanceWithCreate[]; didCreate(component: ComponentInstanceWithCreate): void; didUpdate(component: ComponentInstanceWithCreate): void; scheduleInstallModifier(modifier: ModifierInstance): void; scheduleUpdateModifier(modifier: ModifierInstance): void; commit(): void; } declare class EnvironmentImpl implements Environment { private delegate; [TRANSACTION]: Nullable; protected appendOperations: GlimmerTreeConstruction; protected updateOperations?: GlimmerTreeChanges | undefined; // Delegate methods and values isInteractive: boolean; // eslint-disable-next-line @typescript-eslint/no-explicit-any isArgumentCaptureError: ((error: any) => boolean) | undefined; debugRenderTree: DebugRenderTree$0 | undefined; constructor(options: EnvironmentOptions, delegate: EnvironmentDelegate); getAppendOperations(): GlimmerTreeConstruction; getDOM(): GlimmerTreeChanges; begin(): void; private get transaction(); didCreate(component: ComponentInstanceWithCreate): void; didUpdate(component: ComponentInstanceWithCreate): void; scheduleInstallModifier(modifier: ModifierInstance): void; scheduleUpdateModifier(modifier: ModifierInstance): void; commit(): void; } interface EnvironmentDelegate { /** * Used to determine the the environment is interactive (e.g. SSR is not * interactive). Interactive environments schedule modifiers, among other things. */ isInteractive: boolean; /** * Used to enable debug tooling */ enableDebugTooling: boolean; /** * Callback to be called when an environment transaction commits */ onTransactionCommit: () => void; } declare function runtimeOptions(options: EnvironmentOptions, delegate: EnvironmentDelegate, artifacts: RuntimeArtifacts, resolver: Nullable): RuntimeOptions; declare function inTransaction(env: Environment, block: () => void): void; /** Use the `{{array}}` helper to create an array to pass as an option to your components. ```handlebars ``` or ```handlebars {{my-component people=(array 'Tom Dale' 'Yehuda Katz' this.myOtherPerson) }} ``` Would result in an object such as: ```js ['Tom Dale', 'Yehuda Katz', this.get('myOtherPerson')] ``` Where the 3rd item in the array is bound to updates of the `myOtherPerson` property. @method array @param {Array} options @return {Array} Array @public */ declare const array: object; /** Concatenates the given arguments into a string. Example: ```handlebars {{some-component name=(concat firstName " " lastName)}} {{! would pass name=" " to the component}} ``` or for angle bracket invocation, you actually don't need concat at all. ```handlebars ``` @public @method concat */ declare const concat: object; /** The `fn` helper allows you to ensure a function that you are passing off to another component, helper, or modifier has access to arguments that are available in the template. For example, if you have an `each` helper looping over a number of items, you may need to pass a function that expects to receive the item as an argument to a component invoked within the loop. Here's how you could use the `fn` helper to pass both the function and its arguments together: ```app/templates/components/items-listing.hbs {{#each @items as |item|}} {{/each}} ``` ```app/components/items-list.js import Component from '@glimmer/component'; import { action } from '@ember/object'; export default class ItemsList extends Component { handleSelected = (item) => { // ...snip... } } ``` In this case the `display-item` component will receive a normal function that it can invoke. When it invokes the function, the `handleSelected` function will receive the `item` and any arguments passed, thanks to the `fn` helper. Let's take look at what that means in a couple circumstances: - When invoked as `this.args.select()` the `handleSelected` function will receive the `item` from the loop as its first and only argument. - When invoked as `this.args.select('foo')` the `handleSelected` function will receive the `item` from the loop as its first argument and the string `'foo'` as its second argument. In the example above, we used an arrow function to ensure that `handleSelected` is properly bound to the `items-list`, but let's explore what happens if we left out the arrow function: ```app/components/items-list.js import Component from '@glimmer/component'; export default class ItemsList extends Component { handleSelected(item) { // ...snip... } } ``` In this example, when `handleSelected` is invoked inside the `display-item` component, it will **not** have access to the component instance. In other words, it will have no `this` context, so please make sure your functions are bound (via an arrow function or other means) before passing into `fn`! See also [partial application](https://en.wikipedia.org/wiki/Partial_application). @method fn @public */ declare const fn: object; /** Dynamically look up a property on an object. The second argument to `{{get}}` should have a string value, although it can be bound. For example, these two usages are equivalent: ```app/components/developer-detail.js import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; export default class extends Component { @tracked developer = { name: "Sandi Metz", language: "Ruby" } } ``` ```handlebars {{this.developer.name}} {{get this.developer "name"}} ``` If there were several facts about a person, the `{{get}}` helper can dynamically pick one: ```app/templates/application.hbs ``` ```handlebars {{get this.developer @factName}} ``` For a more complex example, this template would allow the user to switch between showing the user's height and weight with a click: ```app/components/developer-detail.js import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; export default class extends Component { @tracked developer = { name: "Sandi Metz", language: "Ruby" } @tracked currentFact = 'name' showFact = (fact) => { this.currentFact = fact; } } ``` ```app/components/developer-detail.js {{get this.developer this.currentFact}} ``` The `{{get}}` helper can also respect mutable values itself. For example: ```app/components/developer-detail.js ``` Would allow the user to swap what fact is being displayed, and also edit that fact via a two-way mutable binding. @public @method get */ declare const get: object; /** Use the `{{hash}}` helper to create a hash to pass as an option to your components. This is specially useful for contextual components where you can just yield a hash: ```handlebars {{yield (hash name='Sarah' title=office )}} ``` Would result in an object such as: ```js { name: 'Sarah', title: this.get('office') } ``` Where the `title` is bound to updates of the `office` property. Note that the hash is an empty object with no prototype chain, therefore common methods like `toString` are not available in the resulting hash. If you need to use such a method, you can use the `call` or `apply` approach: ```js function toString(obj) { return Object.prototype.toString.apply(obj); } ``` @method hash @param {Object} options @return {Object} Hash @public */ declare const hash: object; //////////// declare function invokeHelper(context: object, definition: object, computeArgs?: (context: object) => Partial): Cache; declare const on: {}; declare function renderSync(env: Environment, iterator: TemplateIterator): RenderResult; declare function renderMain(context: EvaluationContext, owner: Owner, self: Reference, tree: TreeBuilder, layout: CompilableProgram, dynamicScope?: DynamicScope): TemplateIterator; declare function renderComponent(context: EvaluationContext, tree: TreeBuilder, owner: Owner, definition: ComponentDefinitionState, args?: Record, dynamicScope?: DynamicScope): TemplateIterator; declare class DynamicScopeImpl implements DynamicScope { private bucket; constructor(bucket?: Dict); get(key: string): Reference; set(key: string, reference: Reference): Reference; child(): DynamicScopeImpl; } interface ScopeOptions { /** @default {UNDEFINED_REFERENCE} */ self: Reference; /** @default {0} */ size?: number | undefined; } declare class ScopeImpl implements Scope { static root(owner: Owner, { self, size }: ScopeOptions): Scope; static sized(owner: Owner, size?: number): Scope; readonly owner: Owner; private slots; private callerScope; constructor(owner: Owner, // the 0th slot is `self` slots: Array, // a single program can mix owners via curried components, and the state lives on root scopes callerScope: Nullable); init({ self }: { self: Reference; }): this; /** * @debug */ snapshot(): ScopeSlot[]; getSelf(): Reference; getSymbol(symbol: number): Reference; getBlock(symbol: number): Nullable; bind(symbol: number, value: ScopeSlot): void; bindSelf(self: Reference): void; bindSymbol(symbol: number, value: Reference): void; bindBlock(symbol: number, value: Nullable): void; bindCallerScope(scope: Nullable): void; getCallerScope(): Nullable; child(): Scope; private get; private set; } interface SafeString { toHTML(): string; } type LowLevelRegisters = [ $pc: number, $ra: number, $sp: number, $fp: number ]; interface VmStack { readonly registers: LowLevelRegisters; push(value: unknown): void; get(position: number): number; pop(): T; snapshot?(): unknown[]; } interface Externs { debugBefore(opcode: RuntimeOp): unknown; debugAfter(state: unknown): void; } declare class LowLevelVM { stack: VmStack; externs: Externs | undefined; currentOpSize: number; readonly registers: LowLevelRegisters; readonly context: EvaluationContext; constructor(stack: VmStack, context: EvaluationContext, externs: Externs | undefined, registers: LowLevelRegisters); fetchRegister(register: MachineRegister): number; loadRegister(register: MachineRegister, value: number): void; setPc(pc: number): void; // Start a new frame and save $ra and $fp on the stack pushFrame(): void; // Restore $ra, $sp and $fp popFrame(): void; pushSmallFrame(): void; popSmallFrame(): void; // Jump to an address in `program` goto(offset: number): void; target(offset: number): number; // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS) call(handle: number): void; // Put a specific `program` address in $ra returnTo(offset: number): void; // Return to the `program` address stored in $ra return(): void; nextStatement(): Nullable; evaluateOuter(opcode: RuntimeOp, vm: VM): void; evaluateInner(opcode: RuntimeOp, vm: VM): void; evaluateMachine(opcode: RuntimeOp, vm: VM): void; evaluateSyscall(opcode: RuntimeOp, vm: VM): void; } interface EvaluationStack { readonly registers: LowLevelRegisters; push(value: unknown): void; dup(position?: number): void; copy(from: number, to: number): void; pop(n?: number): T; peek(offset?: number): T; get(offset: number, base?: number): T; set(value: unknown, offset: number, base?: number): void; slice(start: number, end: number): T[]; capture(items: number): unknown[]; reset(): void; snapshot?(): unknown[]; } /* The calling convention is: * 0-N block arguments at the bottom * 0-N positional arguments next (left-to-right) * 0-N named arguments next */ declare class VMArgumentsImpl implements VMArguments { private stack; positional: PositionalArgumentsImpl; named: NamedArgumentsImpl; blocks: BlockArgumentsImpl; constructor(); empty(stack: EvaluationStack): this; setup(stack: EvaluationStack, names: readonly string[], blockNames: readonly string[], positionalCount: number, atNames: boolean): void; get base(): number; get length(): number; at(pos: number): Reference; realloc(offset: number): void; capture(): CapturedArguments; clear(): void; } declare class PositionalArgumentsImpl implements PositionalArguments { base: number; length: number; // eslint-disable-next-line @typescript-eslint/no-explicit-any private stack; private _references; constructor(); empty(stack: EvaluationStack, base: number): void; setup(stack: EvaluationStack, base: number, length: number): void; at(position: number): Reference; capture(): CapturedPositionalArguments; prepend(other: Reference[]): void; private get references(); } declare class NamedArgumentsImpl implements NamedArguments { base: number; length: number; private stack; private _references; private _names; private _atNames; constructor(); empty(stack: EvaluationStack, base: number): void; setup(stack: EvaluationStack, base: number, length: number, names: readonly string[], atNames: boolean): void; get names(): readonly string[]; get atNames(): readonly string[]; has(name: string): boolean; get(name: string, atNames?: boolean): Reference; capture(): CapturedNamedArguments; merge(other: Record): void; private get references(); private toSyntheticName; private toAtName; } declare class BlockArgumentsImpl implements BlockArguments { private stack; private internalValues; private _symbolNames; internalTag: Nullable; names: readonly string[]; length: number; base: number; constructor(); empty(stack: EvaluationStack, base: number): void; setup(stack: EvaluationStack, base: number, length: number, names: readonly string[]): void; get values(): readonly BlockValue[]; has(name: string): boolean; get(name: string): Nullable; capture(): CapturedBlockArguments; get symbolNames(): readonly string[]; } declare function createCapturedArgs(named: Dict, positional: Reference[]): CapturedArguments; declare function reifyNamed(named: CapturedNamedArguments): Dict; declare function reifyPositional(positional: CapturedPositionalArguments): unknown[]; declare function reifyArgs(args: CapturedArguments): { named: Dict; positional: unknown[]; }; declare const EMPTY_NAMED: CapturedNamedArguments; declare const EMPTY_POSITIONAL: CapturedPositionalArguments; declare const EMPTY_ARGS: CapturedArguments; declare function dynamicAttribute(element: SimpleElement, attr: string, namespace: Nullable, isTrusting?: boolean): DynamicAttribute; declare abstract class DynamicAttribute implements AttributeOperation { attribute: AttributeCursor; constructor(attribute: AttributeCursor); abstract set(dom: TreeBuilder, value: unknown, env: Environment): void; abstract update(value: unknown, env: Environment): void; } declare class SimpleDynamicAttribute extends DynamicAttribute { set(dom: TreeBuilder, value: unknown, _env: Environment): void; update(value: unknown, _env: Environment): void; } interface FirstNode { debug?: { first: () => Nullable; }; firstNode(): SimpleNode; } interface LastNode { debug?: { last: () => Nullable; }; lastNode(): SimpleNode; } declare class NewTreeBuilder implements TreeBuilder { debug?: () => { blocks: AppendingBlock[]; constructing: Nullable; cursors: Cursor[]; }; dom: GlimmerTreeConstruction; updateOperations: GlimmerTreeChanges; constructing: Nullable; operations: Nullable; private env; readonly cursors: Stack; private modifierStack; private blockStack; static forInitialRender(env: Environment, cursor: CursorImpl): NewTreeBuilder; static resume(env: Environment, block: ResettableBlock): NewTreeBuilder; constructor(env: Environment, parentNode: SimpleElement, nextSibling: Nullable); protected initialize(): this; debugBlocks(): AppendingBlock[]; get element(): SimpleElement; get nextSibling(): Nullable; get hasBlocks(): boolean; protected block(): AppendingBlock; popElement(): void; pushAppendingBlock(): AppendingBlock; pushResettableBlock(): ResettableBlockImpl; pushBlockList(list: AppendingBlock[]): AppendingBlockList; protected pushBlock(block: T, isRemote?: boolean): T; popBlock(): AppendingBlock; __openBlock(): void; __closeBlock(): void; // todo return seems unused openElement(tag: string): SimpleElement; __openElement(tag: string): SimpleElement; flushElement(modifiers: Nullable): void; __flushElement(parent: SimpleElement, constructing: SimpleElement): void; closeElement(): Nullable; pushRemoteElement(element: SimpleElement, guid: string, insertBefore: Maybe): RemoteBlock; __pushRemoteElement(element: SimpleElement, _guid: string, insertBefore: Maybe): RemoteBlock; popRemoteElement(): RemoteBlock; protected pushElement(element: SimpleElement, nextSibling?: Maybe): void; private pushModifiers; private popModifiers; didAppendBounds(bounds: Bounds): Bounds; didAppendNode(node: T): T; didOpenElement(element: SimpleElement): SimpleElement; willCloseElement(): void; appendText(string: string): SimpleText; __appendText(text: string): SimpleText; __appendNode(node: SimpleNode): SimpleNode; __appendFragment(fragment: SimpleDocumentFragment): Bounds; __appendHTML(html: string): Bounds; appendDynamicHTML(value: string): void; appendDynamicText(value: string): SimpleText; appendDynamicFragment(value: SimpleDocumentFragment): void; appendDynamicNode(value: SimpleNode): void; private trustedContent; private untrustedContent; appendComment(string: string): SimpleComment; __appendComment(string: string): SimpleComment; __setAttribute(name: string, value: string, namespace: Nullable): void; __setProperty(name: string, value: unknown): void; setStaticAttribute(name: string, value: string, namespace: Nullable): void; setDynamicAttribute(name: string, value: unknown, trusting: boolean, namespace: Nullable): DynamicAttribute; } declare class AppendingBlockImpl implements AppendingBlock { private parent; debug?: { first: () => Nullable; last: () => Nullable; }; protected first: Nullable; protected last: Nullable; protected nesting: number; constructor(parent: SimpleElement); parentElement(): SimpleElement; firstNode(): SimpleNode; lastNode(): SimpleNode; openElement(element: SimpleElement): void; closeElement(): void; didAppendNode(node: SimpleNode): void; didAppendBounds(bounds: Bounds): void; finalize(stack: TreeBuilder): void; } declare class RemoteBlock extends AppendingBlockImpl { constructor(parent: SimpleElement); } declare class ResettableBlockImpl extends AppendingBlockImpl implements ResettableBlock { constructor(parent: SimpleElement); reset(): Nullable; } // FIXME: All the noops in here indicate a modelling problem declare class AppendingBlockList implements AppendingBlock { private readonly parent; boundList: AppendingBlock[]; constructor(parent: SimpleElement, boundList: AppendingBlock[]); parentElement(): SimpleElement; firstNode(): SimpleNode; lastNode(): SimpleNode; openElement(_element: SimpleElement): void; closeElement(): void; didAppendNode(_node: SimpleNode): void; didAppendBounds(_bounds: Bounds): void; finalize(_stack: TreeBuilder): void; } declare function clientBuilder(env: Environment, cursor: CursorImpl): TreeBuilder; declare class UpdatingVM implements IUpdatingVM { env: Environment; dom: GlimmerTreeChanges; alwaysRevalidate: boolean; private frameStack; constructor(env: Environment, { alwaysRevalidate }: { alwaysRevalidate?: boolean; }); execute(opcodes: UpdatingOpcode[], handler: ExceptionHandler): void; private _execute; private get frame(); goto(index: number): void; try(ops: UpdatingOpcode[], handler: Nullable): void; throw(): void; } declare abstract class BlockOpcode implements UpdatingOpcode, Bounds { protected state: Closure; protected context: EvaluationContext; children: UpdatingOpcode[]; protected readonly bounds: AppendingBlock; constructor(state: Closure, context: EvaluationContext, bounds: AppendingBlock, children: UpdatingOpcode[]); parentElement(): import("@glimmer/interfaces").SimpleElement; firstNode(): import("@glimmer/interfaces").SimpleNode; lastNode(): import("@glimmer/interfaces").SimpleNode; evaluate(vm: UpdatingVM): void; } declare class TryOpcode extends BlockOpcode implements ExceptionHandler { type: string; protected bounds: ResettableBlock; // Shadows property on base class evaluate(vm: UpdatingVM): void; handleException(): void; } declare class ListItemOpcode extends TryOpcode { key: unknown; memo: Reference; value: Reference; retained: boolean; index: number; constructor(state: Closure, context: EvaluationContext, bounds: ResettableBlock, key: unknown, memo: Reference, value: Reference); shouldRemove(): boolean; reset(): void; } declare class VM { #private; readonly args: VMArgumentsImpl; readonly lowlevel: LowLevelVM; readonly debug?: () => DebugVmSnapshot; readonly trace?: () => DebugVmTrace; get stack(): EvaluationStack; /* Registers */ get pc(): number; /** * Fetch a value from a syscall register onto the stack. * * ## Opcodes * * - Append: `Fetch` * * ## State changes * * [!] push Eval Stack <- $register */ fetch(register: SyscallRegister): void; /** * Load a value from the stack into a syscall register. * * ## Opcodes * * - Append: `Load` * * ## State changes * * [!] pop Eval Stack -> `value` * [$] $register <- `value` */ load(register: SyscallRegister): void; /** * Load a value into a syscall register. * * ## State changes * * [$] $register <- `value` * * @utility */ loadValue(register: SyscallRegister, value: T): void; /** * Fetch a value from a register (machine or syscall). * * ## State changes * * [ ] get $register * * @utility */ fetchValue(register: MachineRegister): number; fetchValue(register: Register): T; // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS) call(handle: number | null): void; // Return to the `program` address stored in $ra return(): void; readonly context: EvaluationContext; constructor({ scope, dynamicScope, stack, pc }: ClosureState, context: EvaluationContext, tree: TreeBuilder); static initial(context: EvaluationContext, options: InitialVmState): VM; compile(block: CompilableTemplate): number; get constants(): ProgramConstants; get program(): Program; get env(): Environment; private captureClosure; capture(args: number, pc?: number): Closure; /** * ## Opcodes * * - Append: `BeginComponentTransaction` * * ## State Changes * * [ ] create `guard` (`JumpIfNotModifiedOpcode`) * [ ] create `tracker` (`BeginTrackFrameOpcode`) * [!] push Updating Stack <- `guard` * [!] push Updating Stack <- `tracker` * [!] push Cache Stack <- `guard` * [!] push Tracking Stack */ beginCacheGroup(name?: string): void; /** * ## Opcodes * * - Append: `CommitComponentTransaction` * * ## State Changes * * Create a new `EndTrackFrameOpcode` (`end`) * * [!] pop CacheStack -> `guard` * [!] pop Tracking Stack -> `tag` * [ ] create `end` (`EndTrackFrameOpcode`) with `guard` * [-] consume `tag` */ commitCacheGroup(): void; /** * ## Opcodes * * - Append: `Enter` * * ## State changes * * [!] push Element Stack as `block` * [ ] create `try` (`TryOpcode`) with `block`, capturing `args` from the Eval Stack * * Did Enter (`try`): * [-] associate destroyable `try` * [!] push Destroyable Stack <- `try` * [!] push Updating List <- `try` * [!] push Updating Stack <- `try.children` */ enter(args: number): void; /** * ## Opcodes * * - Append: `Iterate` * - Update: `ListBlock` * * ## State changes * * Create a new ref for the iterator item (`value`). * Create a new ref for the iterator key (`key`). * * [ ] create `valueRef` (`Reference`) from `value` * [ ] create `keyRef` (`Reference`) from `key` * [!] push Eval Stack <- `valueRef` * [!] push Eval Stack <- `keyRef` * [!] push Element Stack <- `UpdatableBlock` as `block` * [ ] capture `closure` with *2* items from the Eval Stack * [ ] create `iteration` (`ListItemOpcode`) with `closure`, `block`, `key`, `keyRef` and `valueRef` * * Did Enter (`iteration`): * [-] associate destroyable `iteration` * [!] push Destroyable Stack <- `iteration` * [!] push Updating List <- `iteration` * [!] push Updating Stack <- `iteration.children` */ enterItem({ key, value, memo }: OpaqueIterationItem): ListItemOpcode; registerItem(opcode: ListItemOpcode): void; /** * ## Opcodes * * - Append: `EnterList` * * ## State changes * * [ ] capture `closure` with *0* items from the Eval Stack, and `$pc` from `offset` * [ ] create `updating` (empty `Array`) * [!] push Element Stack <- `list` (`BlockList`) with `updating` * [ ] create `list` (`ListBlockOpcode`) with `closure`, `list`, `updating` and `iterableRef` * [!] push List Stack <- `list` * * Did Enter (`list`): * [-] associate destroyable `list` * [!] push Destroyable Stack <- `list` * [!] push Updating List <- `list` * [!] push Updating Stack <- `list.children` */ enterList(iterableRef: Reference, offset: number): void; /** * ## Opcodes * * - Append: `Enter` * - Append: `Iterate` * - Append: `EnterList` * - Update: `ListBlock` * * ## State changes * * [-] associate destroyable `opcode` * [!] push Destroyable Stack <- `opcode` * [!] push Updating List <- `opcode` * [!] push Updating Stack <- `opcode.children` * */ private didEnter; /** * ## Opcodes * * - Append: `Exit` * - Append: `ExitList` * * ## State changes * * [!] pop Destroyable Stack * [!] pop Element Stack * [!] pop Updating Stack */ exit(): void; /** * ## Opcodes * * - Append: `ExitList` * * ## State changes * * Pop List: * [!] pop Destroyable Stack * [!] pop Element Stack * [!] pop Updating Stack * * [!] pop List Stack */ exitList(): void; /** * ## Opcodes * * - Append: `RootScope` * - Append: `VirtualRootScope` * * ## State changes * * [!] push Scope Stack */ pushRootScope(size: number, owner: Owner): Scope; /** * ## Opcodes * * - Append: `ChildScope` * * ## State changes * * [!] push Scope Stack <- `child` of current Scope */ pushChildScope(): void; /** * ## Opcodes * * - Append: `Yield` * * ## State changes * * [!] push Scope Stack <- `scope` */ pushScope(scope: Scope): void; /** * ## Opcodes * * - Append: `PopScope` * * ## State changes * * [!] pop Scope Stack */ popScope(): void; /** * ## Opcodes * * - Append: `PushDynamicScope` * * ## State changes: * * [!] push Dynamic Scope Stack <- child of current Dynamic Scope */ pushDynamicScope(): DynamicScope; /** * ## Opcodes * * - Append: `BindDynamicScope` * * ## State changes: * * [!] pop Dynamic Scope Stack `names.length` times */ bindDynamicScope(names: string[]): void; /** * ## State changes * * - [!] push Updating Stack * * @utility */ pushUpdating(list?: UpdatingOpcode[]): void; /** * ## State changes * * [!] pop Updating Stack * * @utility */ popUpdating(): UpdatingOpcode[]; /** * ## State changes * * [!] push Updating List * * @utility */ updateWith(opcode: UpdatingOpcode): void; private listBlock; /** * ## State changes * * [-] associate destroyable `child` * * @utility */ associateDestroyable(child: Destroyable): void; private updating; /** * Get Tree Builder */ tree(): TreeBuilder; /** * Get current Scope */ scope(): Scope; /** * Get current Dynamic Scope */ dynamicScope(): DynamicScope; popDynamicScope(): void; /// SCOPE HELPERS getOwner(): Owner; // eslint-disable-next-line @typescript-eslint/no-explicit-any getSelf(): Reference; referenceForSymbol(symbol: number): Reference; /// EXECUTION execute(initialize?: (vm: this) => void): RenderResult; private _execute; next(): RichIteratorResult; } interface InitialVmState { /** * The address of the compiled template. This is converted into a * pc when the VM is created. */ handle: number; /** * Optionally, specify the root scope for the VM. If not specified, * the VM will use a root scope with no `this` reference and no * symbols. */ scope?: ScopeOptions; /** * */ tree: TreeBuilder; dynamicScope: DynamicScope; owner: Owner; } interface ClosureState { /** * The program counter that subsequent evaluations should start from. */ readonly pc: number; /** * The current value of the VM's scope (which changes whenever a component is invoked or a block * with block params is entered). */ readonly scope: Scope; /** * The current value of the VM's dynamic scope */ readonly dynamicScope: DynamicScope; /** * A number of stack elements captured during the initial evaluation, and which should be restored * to the stack when the block is re-evaluated. */ readonly stack: unknown[]; } /** * A closure captures the state of the VM for a particular block of code that is necessary to * re-invoke the block in the future. * * In practice, this allows us to clear the previous render and "replay" the block's execution, * rendering content in the same position as the first render. */ declare class Closure { private state; private context; constructor(state: ClosureState, context: EvaluationContext); evaluate(tree: TreeBuilder): VM; } declare const SERIALIZATION_FIRST_NODE_STRING = "%+b:0%"; declare function isSerializationFirstNode(node: SimpleNode): boolean; declare class RehydratingCursor extends CursorImpl { readonly startingBlockDepth: number; candidate: Nullable; openBlockDepth: number; injectedOmittedNode: boolean; constructor(element: SimpleElement, nextSibling: Nullable, startingBlockDepth: number); } declare class RehydrateTree extends NewTreeBuilder implements TreeBuilder { private unmatchedAttributes; cursors: Stack; // Hides property on base class blockDepth: number; startingBlockOffset: number; constructor(env: Environment, parentNode: SimpleElement, nextSibling: Nullable); get currentCursor(): Nullable; get candidate(): Nullable; set candidate(node: Nullable); disableRehydration(nextSibling: Nullable): void; enableRehydration(candidate: Nullable): void; pushElement(/** called from parent constructor before we initialize this */ this: RehydrateTree | (NewTreeBuilder & Partial>), element: SimpleElement, nextSibling?: Maybe): void; // clears until the end of the current container // either the current open block or higher private clearMismatch; __openBlock(): void; __closeBlock(): void; __appendNode(node: SimpleNode): SimpleNode; __appendHTML(html: string): Bounds; protected remove(node: SimpleNode): Nullable; private markerBounds; __appendText(string: string): SimpleText; __appendComment(string: string): SimpleComment; __openElement(tag: string): SimpleElement; __setAttribute(name: string, value: string, namespace: Nullable): void; __setProperty(name: string, value: string): void; __flushElement(parent: SimpleElement, constructing: SimpleElement): void; willCloseElement(): void; getMarker(element: HTMLElement, guid: string): Nullable; __pushRemoteElement(element: SimpleElement, cursorId: string, insertBefore: Maybe): RemoteBlock; didAppendBounds(bounds: Bounds): Bounds; } declare function rehydrationBuilder(env: Environment, cursor: CursorImpl): TreeBuilder; type IteratorResult = RichIteratorResult; export { clear, ConcreteBounds, CursorImpl, DebugCallback, resetDebuggerCallback, setDebuggerCallback, TEMPLATE_ONLY_COMPONENT_MANAGER, TemplateOnlyComponentDefinition as TemplateOnlyComponent, templateOnlyComponent, TemplateOnlyComponentManager, CurriedValue, curry, DOMChanges, DOMTreeConstruction, DOMChangesImpl as IDOMChanges, isWhitespace, normalizeProperty, EnvironmentDelegate, EnvironmentImpl, inTransaction, runtimeOptions, array, concat, fn, get, hash, invokeHelper, on, renderComponent, renderMain, renderSync, DynamicScopeImpl, ScopeImpl, UpdatingVM, VM, createCapturedArgs, EMPTY_ARGS, EMPTY_NAMED, EMPTY_POSITIONAL, reifyArgs, reifyNamed, reifyPositional, DynamicAttribute, dynamicAttribute, SimpleDynamicAttribute, clientBuilder, NewTreeBuilder, RemoteBlock, ResettableBlockImpl, LowLevelVM, isSerializationFirstNode, RehydrateTree, rehydrationBuilder, SERIALIZATION_FIRST_NODE_STRING, IteratorResult }; export type { SafeString }; export { destroy, isDestroyed, isDestroying, registerDestructor } from "@glimmer/destroyable"; //# sourceMappingURL=index.d.ts.map