UNPKG

41.2 kBTypeScriptView Raw
1import { RichIteratorResult, Bounds, Cursor, Nullable, SimpleElement, SimpleNode, InternalComponentCapabilities, InternalComponentManager, CapturedArguments, CurriedType, Owner, GlimmerTreeChanges, SimpleDocument, SimpleComment, SimpleText, AttrNamespace, ElementNamespace, GlimmerTreeConstruction, ComponentInstanceWithCreate, Environment, EnvironmentOptions, ModifierInstance, RuntimeArtifacts, RuntimeContext, RuntimeResolver, Transaction, TransactionSymbol, CapturedRenderNode, DebugRenderTree, RenderNode, Arguments, CompilableProgram, CompileTimeCompilationContext, ComponentDefinitionState, DynamicScope, ElementBuilder, RenderResult, TemplateIterator, Dict, PartialScope, Scope, ScopeBlock, ScopeSlot, CompilableTemplate, Destroyable, ResolutionTimeConstants, RuntimeConstants, RuntimeProgram, UpdatingOpcode, RuntimeHeap, RuntimeOp, ExceptionHandler, LiveBlock, UpdatableBlock, CursorStackSymbol, ElementOperations, Maybe, SimpleDocumentFragment, AttributeCursor, AttributeOperation, BlockArguments, BlockValue, CapturedBlockArguments, CapturedNamedArguments, CapturedPositionalArguments, NamedArguments, PositionalArguments, VMArguments } from '@glimmer/interfaces';
2import { VM as PublicVM } from "@glimmer/interfaces";
3import { UpdatingVM as IUpdatingVM } from "@glimmer/interfaces";
4import { Reference, OpaqueIterationItem, OpaqueIterator } from "@glimmer/reference";
5import { Cache, Tag } from "@glimmer/validator";
6import { MachineRegister, Register, SyscallRegister } from "@glimmer/vm";
7import { Stack as Stack$0 } from "@glimmer/util";
8declare class CursorImpl implements Cursor {
9 element: SimpleElement;
10 nextSibling: Nullable<SimpleNode>;
11 constructor(element: SimpleElement, nextSibling: Nullable<SimpleNode>);
12}
13declare class ConcreteBounds implements Bounds {
14 parentNode: SimpleElement;
15 private first;
16 private last;
17 constructor(parentNode: SimpleElement, first: SimpleNode, last: SimpleNode);
18 parentElement(): SimpleElement;
19 firstNode(): SimpleNode;
20 lastNode(): SimpleNode;
21}
22declare function clear(bounds: Bounds): Nullable<SimpleNode>;
23type DebugGet = (path: string) => unknown;
24type DebugCallback = (context: unknown, get: DebugGet) => void;
25// For testing purposes
26declare function setDebuggerCallback(cb: DebugCallback): void;
27declare function resetDebuggerCallback(): void;
28declare class TemplateOnlyComponentManager implements InternalComponentManager {
29 getCapabilities(): InternalComponentCapabilities;
30 getDebugName({ name }: TemplateOnlyComponentDefinition): string;
31 getSelf(): Reference;
32 getDestroyable(): null;
33}
34declare const TEMPLATE_ONLY_COMPONENT_MANAGER: TemplateOnlyComponentManager;
35// This is only exported for types, don't use this class directly
36declare class TemplateOnlyComponentDefinition {
37 moduleName: string;
38 name: string;
39 constructor(moduleName?: string, name?: string);
40 toString(): string;
41}
42/**
43 This utility function is used to declare a given component has no backing class. When the rendering engine detects this it
44 is able to perform a number of optimizations. Templates that are associated with `templateOnly()` will be rendered _as is_
45 without adding a wrapping `<div>` (or any of the other element customization behaviors of [@ember/component](/ember/release/classes/Component)).
46 Specifically, this means that the template will be rendered as "outer HTML".
47
48 In general, this method will be used by build time tooling and would not be directly written in an application. However,
49 at times it may be useful to use directly to leverage the "outer HTML" semantics mentioned above. For example, if an addon would like
50 to use these semantics for its templates but cannot be certain it will only be consumed by applications that have enabled the
51 `template-only-glimmer-components` optional feature.
52
53 @example
54
55 ```js
56 import { templateOnlyComponent } from '@glimmer/runtime';
57
58 export default templateOnlyComponent();
59 ```
60
61 @public
62 @method templateOnly
63 @param {String} moduleName the module name that the template only component represents, this will be used for debugging purposes
64 @category EMBER_GLIMMER_SET_COMPONENT_TEMPLATE
65 */
66declare function templateOnlyComponent(moduleName?: string, name?: string): TemplateOnlyComponentDefinition;
67declare const TYPE: unique symbol;
68declare const INNER: unique symbol;
69declare const OWNER: unique symbol;
70declare const ARGS: unique symbol;
71declare const RESOLVED: unique symbol;
72declare class CurriedValue<T extends CurriedType = CurriedType> {
73 [TYPE]: T;
74 [INNER]: object | string | CurriedValue<T>;
75 [OWNER]: Owner;
76 [ARGS]: CapturedArguments | null;
77 [RESOLVED]: boolean;
78 /** @internal */
79 constructor(type: T, inner: object | string | CurriedValue<T>, owner: Owner, args: CapturedArguments | null, resolved?: boolean);
80}
81declare function curry<T extends CurriedType>(type: T, spec: object | string | CurriedValue<T>, owner: Owner, args: CapturedArguments | null, resolved?: boolean): CurriedValue<T>;
82declare class DOMOperations {
83 protected document: SimpleDocument;
84 protected uselessElement: SimpleElement; // Set by this.setupUselessElement() in constructor
85 constructor(document: SimpleDocument);
86 // split into separate method so that NodeDOMTreeConstruction
87 // can override it.
88 protected setupUselessElement(): void;
89 createElement(tag: string, context?: SimpleElement): SimpleElement;
90 insertBefore(parent: SimpleElement, node: SimpleNode, reference: Nullable<SimpleNode>): void;
91 insertHTMLBefore(parent: SimpleElement, nextSibling: Nullable<SimpleNode>, html: string): Bounds;
92 createTextNode(text: string): SimpleText;
93 createComment(data: string): SimpleComment;
94}
95declare function isWhitespace(string: string): boolean;
96declare class DOMChangesImpl extends DOMOperations implements GlimmerTreeChanges {
97 protected document: SimpleDocument;
98 protected namespace: Nullable<string>;
99 constructor(document: SimpleDocument);
100 setAttribute(element: SimpleElement, name: string, value: string): void;
101 removeAttribute(element: SimpleElement, name: string): void;
102 insertAfter(element: SimpleElement, node: SimpleNode, reference: SimpleNode): void;
103}
104declare const DOMChanges: typeof DOMChangesImpl;
105declare class TreeConstruction extends DOMOperations implements GlimmerTreeConstruction {
106 createElementNS(namespace: ElementNamespace, tag: string): SimpleElement;
107 setAttribute(element: SimpleElement, name: string, value: string, namespace?: Nullable<AttrNamespace>): void;
108}
109declare const DOMTreeConstruction: typeof TreeConstruction;
110type DOMTreeConstruction = TreeConstruction;
111/*
112* @method normalizeProperty
113* @param element {HTMLElement}
114* @param slotName {String}
115* @returns {Object} { name, type }
116*/
117declare function normalizeProperty(element: SimpleElement, slotName: string): {
118 normalized: any;
119 type: any;
120};
121declare class DebugRenderTreeImpl<TBucket extends object> implements DebugRenderTree<TBucket> {
122 private stack;
123 private refs;
124 private roots;
125 private nodes;
126 begin(): void;
127 create(state: TBucket, node: RenderNode): void;
128 update(state: TBucket): void;
129 didRender(state: TBucket, bounds: Bounds): void;
130 willDestroy(state: TBucket): void;
131 commit(): void;
132 capture(): CapturedRenderNode[];
133 private reset;
134 private enter;
135 private exit;
136 private nodeFor;
137 private appendChild;
138 private captureRefs;
139 private captureNode;
140 private captureTemplate;
141 private captureBounds;
142}
143declare module DebugRenderTreeImplWrapper {
144 export { DebugRenderTreeImpl };
145}
146import DebugRenderTree$0 = DebugRenderTreeImplWrapper.DebugRenderTreeImpl;
147declare const TRANSACTION: TransactionSymbol;
148declare class TransactionImpl implements Transaction {
149 scheduledInstallModifiers: ModifierInstance[];
150 scheduledUpdateModifiers: ModifierInstance[];
151 createdComponents: ComponentInstanceWithCreate[];
152 updatedComponents: ComponentInstanceWithCreate[];
153 didCreate(component: ComponentInstanceWithCreate): void;
154 didUpdate(component: ComponentInstanceWithCreate): void;
155 scheduleInstallModifier(modifier: ModifierInstance): void;
156 scheduleUpdateModifier(modifier: ModifierInstance): void;
157 commit(): void;
158}
159declare class EnvironmentImpl implements Environment {
160 private delegate;
161 [TRANSACTION]: Nullable<TransactionImpl>;
162 protected appendOperations: GlimmerTreeConstruction;
163 protected updateOperations?: GlimmerTreeChanges | undefined;
164 // Delegate methods and values
165 isInteractive: boolean;
166 isArgumentCaptureError: ((error: any) => boolean) | undefined;
167 debugRenderTree: DebugRenderTree$0<object> | undefined;
168 constructor(options: EnvironmentOptions, delegate: EnvironmentDelegate);
169 getAppendOperations(): GlimmerTreeConstruction;
170 getDOM(): GlimmerTreeChanges;
171 begin(): void;
172 private get transaction();
173 didCreate(component: ComponentInstanceWithCreate): void;
174 didUpdate(component: ComponentInstanceWithCreate): void;
175 scheduleInstallModifier(modifier: ModifierInstance): void;
176 scheduleUpdateModifier(modifier: ModifierInstance): void;
177 commit(): void;
178}
179interface EnvironmentDelegate {
180 /**
181 * Used to determine the the environment is interactive (e.g. SSR is not
182 * interactive). Interactive environments schedule modifiers, among other things.
183 */
184 isInteractive: boolean;
185 /**
186 * Used to enable debug tooling
187 */
188 enableDebugTooling: boolean;
189 /**
190 * Callback to be called when an environment transaction commits
191 */
192 onTransactionCommit: () => void;
193}
194declare function runtimeContext(options: EnvironmentOptions, delegate: EnvironmentDelegate, artifacts: RuntimeArtifacts, resolver: RuntimeResolver): RuntimeContext;
195declare function inTransaction(env: Environment, block: () => void): void;
196/**
197 Use the `{{array}}` helper to create an array to pass as an option to your
198 components.
199
200 ```handlebars
201 <MyComponent @people={{array
202 'Tom Dale'
203 'Yehuda Katz'
204 this.myOtherPerson}}
205 />
206 ```
207 or
208 ```handlebars
209 {{my-component people=(array
210 'Tom Dale'
211 'Yehuda Katz'
212 this.myOtherPerson)
213 }}
214 ```
215
216 Would result in an object such as:
217
218 ```js
219 ['Tom Dale', 'Yehuda Katz', this.get('myOtherPerson')]
220 ```
221
222 Where the 3rd item in the array is bound to updates of the `myOtherPerson` property.
223
224 @method array
225 @param {Array} options
226 @return {Array} Array
227 @public
228 */
229declare const array: object;
230/**
231 Concatenates the given arguments into a string.
232
233 Example:
234
235 ```handlebars
236 {{some-component name=(concat firstName " " lastName)}}
237
238 {{! would pass name="<first name value> <last name value>" to the component}}
239 ```
240
241 or for angle bracket invocation, you actually don't need concat at all.
242
243 ```handlebars
244 <SomeComponent @name="{{firstName}} {{lastName}}" />
245 ```
246
247 @public
248 @method concat
249 */
250declare const concat: object;
251/**
252 The `fn` helper allows you to ensure a function that you are passing off
253 to another component, helper, or modifier has access to arguments that are
254 available in the template.
255
256 For example, if you have an `each` helper looping over a number of items, you
257 may need to pass a function that expects to receive the item as an argument
258 to a component invoked within the loop. Here's how you could use the `fn`
259 helper to pass both the function and its arguments together:
260
261 ```app/templates/components/items-listing.hbs
262 {{#each @items as |item|}}
263 <DisplayItem @item=item @select={{fn this.handleSelected item}} />
264 {{/each}}
265 ```
266
267 ```app/components/items-list.js
268 import Component from '@glimmer/component';
269 import { action } from '@ember/object';
270
271 export default class ItemsList extends Component {
272 handleSelected = (item) => {
273 // ...snip...
274 }
275 }
276 ```
277
278 In this case the `display-item` component will receive a normal function
279 that it can invoke. When it invokes the function, the `handleSelected`
280 function will receive the `item` and any arguments passed, thanks to the
281 `fn` helper.
282
283 Let's take look at what that means in a couple circumstances:
284
285 - When invoked as `this.args.select()` the `handleSelected` function will
286 receive the `item` from the loop as its first and only argument.
287 - When invoked as `this.args.select('foo')` the `handleSelected` function
288 will receive the `item` from the loop as its first argument and the
289 string `'foo'` as its second argument.
290
291 In the example above, we used an arrow function to ensure that
292 `handleSelected` is properly bound to the `items-list`, but let's explore what
293 happens if we left out the arrow function:
294
295 ```app/components/items-list.js
296 import Component from '@glimmer/component';
297
298 export default class ItemsList extends Component {
299 handleSelected(item) {
300 // ...snip...
301 }
302 }
303 ```
304
305 In this example, when `handleSelected` is invoked inside the `display-item`
306 component, it will **not** have access to the component instance. In other
307 words, it will have no `this` context, so please make sure your functions
308 are bound (via an arrow function or other means) before passing into `fn`!
309
310 See also [partial application](https://en.wikipedia.org/wiki/Partial_application).
311
312 @method fn
313 @public
314 */
315declare const fn: object;
316/**
317 Dynamically look up a property on an object. The second argument to `{{get}}`
318 should have a string value, although it can be bound.
319
320 For example, these two usages are equivalent:
321
322 ```app/components/developer-detail.js
323 import Component from '@glimmer/component';
324 import { tracked } from '@glimmer/tracking';
325
326 export default class extends Component {
327 @tracked developer = {
328 name: "Sandi Metz",
329 language: "Ruby"
330 }
331 }
332 ```
333
334 ```handlebars
335 {{this.developer.name}}
336 {{get this.developer "name"}}
337 ```
338
339 If there were several facts about a person, the `{{get}}` helper can dynamically
340 pick one:
341
342 ```app/templates/application.hbs
343 <DeveloperDetail @factName="language" />
344 ```
345
346 ```handlebars
347 {{get this.developer @factName}}
348 ```
349
350 For a more complex example, this template would allow the user to switch
351 between showing the user's height and weight with a click:
352
353 ```app/components/developer-detail.js
354 import Component from '@glimmer/component';
355 import { tracked } from '@glimmer/tracking';
356
357 export default class extends Component {
358 @tracked developer = {
359 name: "Sandi Metz",
360 language: "Ruby"
361 }
362
363 @tracked currentFact = 'name'
364
365 showFact = (fact) => {
366 this.currentFact = fact;
367 }
368 }
369 ```
370
371 ```app/components/developer-detail.js
372 {{get this.developer this.currentFact}}
373
374 <button {{on 'click' (fn this.showFact "name")}}>Show name</button>
375 <button {{on 'click' (fn this.showFact "language")}}>Show language</button>
376 ```
377
378 The `{{get}}` helper can also respect mutable values itself. For example:
379
380 ```app/components/developer-detail.js
381 <Input @value={{mut (get this.person this.currentFact)}} />
382
383 <button {{on 'click' (fn this.showFact "name")}}>Show name</button>
384 <button {{on 'click' (fn this.showFact "language")}}>Show language</button>
385 ```
386
387 Would allow the user to swap what fact is being displayed, and also edit
388 that fact via a two-way mutable binding.
389
390 @public
391 @method get
392 */
393declare const get: object;
394/**
395 Use the `{{hash}}` helper to create a hash to pass as an option to your
396 components. This is specially useful for contextual components where you can
397 just yield a hash:
398
399 ```handlebars
400 {{yield (hash
401 name='Sarah'
402 title=office
403 )}}
404 ```
405
406 Would result in an object such as:
407
408 ```js
409 { name: 'Sarah', title: this.get('office') }
410 ```
411
412 Where the `title` is bound to updates of the `office` property.
413
414 Note that the hash is an empty object with no prototype chain, therefore
415 common methods like `toString` are not available in the resulting hash.
416 If you need to use such a method, you can use the `call` or `apply`
417 approach:
418
419 ```js
420 function toString(obj) {
421 return Object.prototype.toString.apply(obj);
422 }
423 ```
424
425 @method hash
426 @param {Object} options
427 @return {Object} Hash
428 @public
429 */
430declare const hash: object;
431////////////
432declare function invokeHelper(context: object, definition: object, computeArgs?: (context: object) => Partial<Arguments>): Cache<unknown>;
433declare const on: {};
434declare function renderSync(env: Environment, iterator: TemplateIterator): RenderResult;
435declare function renderMain(runtime: RuntimeContext, context: CompileTimeCompilationContext, owner: Owner, self: Reference, treeBuilder: ElementBuilder, layout: CompilableProgram, dynamicScope?: DynamicScope): TemplateIterator;
436declare function renderComponent(runtime: RuntimeContext, treeBuilder: ElementBuilder, context: CompileTimeCompilationContext, owner: Owner, definition: ComponentDefinitionState, args?: Record<string, unknown>, dynamicScope?: DynamicScope): TemplateIterator;
437declare class DynamicScopeImpl implements DynamicScope {
438 private bucket;
439 constructor(bucket?: Dict<Reference>);
440 get(key: string): Reference;
441 set(key: string, reference: Reference): Reference;
442 child(): DynamicScopeImpl;
443}
444declare class PartialScopeImpl implements PartialScope {
445 // the 0th slot is `self`
446 readonly slots: Array<ScopeSlot>;
447 readonly owner: Owner;
448 private callerScope;
449 // named arguments and blocks passed to a layout that uses eval
450 private evalScope;
451 // locals in scope when the partial was invoked
452 private partialMap;
453 static root(self: Reference<unknown>, size: number, owner: Owner): PartialScope;
454 static sized(size: number, owner: Owner): Scope;
455 constructor(slots: Array<ScopeSlot>, owner: Owner, callerScope: Scope | null, evalScope: Dict<ScopeSlot> | null, partialMap: Dict<Reference<unknown>> | null);
456 init({ self }: {
457 self: Reference<unknown>;
458 }): this;
459 getSelf(): Reference<unknown>;
460 getSymbol(symbol: number): Reference<unknown>;
461 getBlock(symbol: number): Nullable<ScopeBlock>;
462 getEvalScope(): Nullable<Dict<ScopeSlot>>;
463 getPartialMap(): Nullable<Dict<Reference<unknown>>>;
464 bind(symbol: number, value: ScopeSlot): void;
465 bindSelf(self: Reference<unknown>): void;
466 bindSymbol(symbol: number, value: Reference<unknown>): void;
467 bindBlock(symbol: number, value: Nullable<ScopeBlock>): void;
468 bindEvalScope(map: Nullable<Dict<ScopeSlot>>): void;
469 bindPartialMap(map: Dict<Reference<unknown>>): void;
470 bindCallerScope(scope: Nullable<Scope>): void;
471 getCallerScope(): Nullable<Scope>;
472 child(): Scope;
473 private get;
474 private set;
475}
476interface SafeString {
477 toHTML(): string;
478}
479interface LowLevelRegisters {
480 [MachineRegister.pc]: number;
481 [MachineRegister.ra]: number;
482 [MachineRegister.sp]: number;
483 [MachineRegister.fp]: number;
484}
485interface Stack {
486 push(value: unknown): void;
487 get(position: number): number;
488 pop<T>(): T;
489}
490interface Externs {
491 debugBefore(opcode: RuntimeOp): unknown;
492 debugAfter(state: unknown): void;
493}
494declare class LowLevelVM {
495 stack: Stack;
496 heap: RuntimeHeap;
497 program: RuntimeProgram;
498 externs: Externs;
499 readonly registers: LowLevelRegisters;
500 currentOpSize: number;
501 constructor(stack: Stack, heap: RuntimeHeap, program: RuntimeProgram, externs: Externs, registers: LowLevelRegisters);
502 fetchRegister(register: MachineRegister): number;
503 loadRegister(register: MachineRegister, value: number): void;
504 setPc(pc: number): void;
505 // Start a new frame and save $ra and $fp on the stack
506 pushFrame(): void;
507 // Restore $ra, $sp and $fp
508 popFrame(): void;
509 pushSmallFrame(): void;
510 popSmallFrame(): void;
511 // Jump to an address in `program`
512 goto(offset: number): void;
513 target(offset: number): number;
514 // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS)
515 call(handle: number): void;
516 // Put a specific `program` address in $ra
517 returnTo(offset: number): void;
518 // Return to the `program` address stored in $ra
519 return(): void;
520 nextStatement(): Nullable<RuntimeOp>;
521 evaluateOuter(opcode: RuntimeOp, vm: VM): void;
522 evaluateInner(opcode: RuntimeOp, vm: VM): void;
523 evaluateMachine(opcode: RuntimeOp): void;
524 evaluateSyscall(opcode: RuntimeOp, vm: VM): void;
525}
526// These symbols represent "friend" properties that are used inside of
527// the VM in other classes, but are not intended to be a part of
528// Glimmer's API.
529declare const INNER_VM: unique symbol;
530declare const DESTROYABLE_STACK: unique symbol;
531declare const STACKS: unique symbol;
532declare const REGISTERS: unique symbol;
533declare const HEAP: unique symbol;
534declare const CONSTANTS: unique symbol;
535declare const ARGS$0: unique symbol;
536interface EvaluationStack {
537 [REGISTERS]: LowLevelRegisters;
538 push(value: unknown): void;
539 dup(position?: MachineRegister): void;
540 copy(from: number, to: number): void;
541 pop<T>(n?: number): T;
542 peek<T>(offset?: number): T;
543 get<T>(offset: number, base?: number): T;
544 set(value: unknown, offset: number, base?: number): void;
545 slice<T = unknown>(start: number, end: number): T[];
546 capture(items: number): unknown[];
547 reset(): void;
548 toArray(): unknown[];
549}
550declare function dynamicAttribute(element: SimpleElement, attr: string, namespace: Nullable<AttrNamespace>, isTrusting?: boolean): DynamicAttribute;
551declare abstract class DynamicAttribute implements AttributeOperation {
552 attribute: AttributeCursor;
553 constructor(attribute: AttributeCursor);
554 abstract set(dom: ElementBuilder, value: unknown, env: Environment): void;
555 abstract update(value: unknown, env: Environment): void;
556}
557declare class SimpleDynamicAttribute extends DynamicAttribute {
558 set(dom: ElementBuilder, value: unknown, _env: Environment): void;
559 update(value: unknown, _env: Environment): void;
560}
561interface FirstNode {
562 firstNode(): SimpleNode;
563}
564interface LastNode {
565 lastNode(): SimpleNode;
566}
567declare const CURSOR_STACK: CursorStackSymbol;
568declare class NewElementBuilder implements ElementBuilder {
569 dom: GlimmerTreeConstruction;
570 updateOperations: GlimmerTreeChanges;
571 constructing: Nullable<SimpleElement>;
572 operations: Nullable<ElementOperations>;
573 private env;
574 [CURSOR_STACK]: Stack$0<Cursor>;
575 private modifierStack;
576 private blockStack;
577 static forInitialRender(env: Environment, cursor: CursorImpl): NewElementBuilder;
578 static resume(env: Environment, block: UpdatableBlock): NewElementBuilder;
579 constructor(env: Environment, parentNode: SimpleElement, nextSibling: Nullable<SimpleNode>);
580 protected initialize(): this;
581 debugBlocks(): LiveBlock[];
582 get element(): SimpleElement;
583 get nextSibling(): Nullable<SimpleNode>;
584 get hasBlocks(): boolean;
585 protected block(): LiveBlock;
586 popElement(): void;
587 pushSimpleBlock(): LiveBlock;
588 pushUpdatableBlock(): UpdatableBlockImpl;
589 pushBlockList(list: LiveBlock[]): LiveBlockList;
590 protected pushLiveBlock<T extends LiveBlock>(block: T, isRemote?: boolean): T;
591 popBlock(): LiveBlock;
592 __openBlock(): void;
593 __closeBlock(): void;
594 // todo return seems unused
595 openElement(tag: string): SimpleElement;
596 __openElement(tag: string): SimpleElement;
597 flushElement(modifiers: Nullable<ModifierInstance[]>): void;
598 __flushElement(parent: SimpleElement, constructing: SimpleElement): void;
599 closeElement(): Nullable<ModifierInstance[]>;
600 pushRemoteElement(element: SimpleElement, guid: string, insertBefore: Maybe<SimpleNode>): RemoteLiveBlock;
601 __pushRemoteElement(element: SimpleElement, _guid: string, insertBefore: Maybe<SimpleNode>): RemoteLiveBlock;
602 popRemoteElement(): RemoteLiveBlock;
603 protected pushElement(element: SimpleElement, nextSibling?: Maybe<SimpleNode>): void;
604 private pushModifiers;
605 private popModifiers;
606 didAppendBounds(bounds: Bounds): Bounds;
607 didAppendNode<T extends SimpleNode>(node: T): T;
608 didOpenElement(element: SimpleElement): SimpleElement;
609 willCloseElement(): void;
610 appendText(string: string): SimpleText;
611 __appendText(text: string): SimpleText;
612 __appendNode(node: SimpleNode): SimpleNode;
613 __appendFragment(fragment: SimpleDocumentFragment): Bounds;
614 __appendHTML(html: string): Bounds;
615 appendDynamicHTML(value: string): void;
616 appendDynamicText(value: string): SimpleText;
617 appendDynamicFragment(value: SimpleDocumentFragment): void;
618 appendDynamicNode(value: SimpleNode): void;
619 private trustedContent;
620 private untrustedContent;
621 appendComment(string: string): SimpleComment;
622 __appendComment(string: string): SimpleComment;
623 __setAttribute(name: string, value: string, namespace: Nullable<AttrNamespace>): void;
624 __setProperty(name: string, value: unknown): void;
625 setStaticAttribute(name: string, value: string, namespace: Nullable<AttrNamespace>): void;
626 setDynamicAttribute(name: string, value: unknown, trusting: boolean, namespace: Nullable<AttrNamespace>): DynamicAttribute;
627}
628declare class SimpleLiveBlock implements LiveBlock {
629 private parent;
630 protected first: Nullable<FirstNode>;
631 protected last: Nullable<LastNode>;
632 protected nesting: number;
633 constructor(parent: SimpleElement);
634 parentElement(): SimpleElement;
635 firstNode(): SimpleNode;
636 lastNode(): SimpleNode;
637 openElement(element: SimpleElement): void;
638 closeElement(): void;
639 didAppendNode(node: SimpleNode): void;
640 didAppendBounds(bounds: Bounds): void;
641 finalize(stack: ElementBuilder): void;
642}
643declare class RemoteLiveBlock extends SimpleLiveBlock {
644 constructor(parent: SimpleElement);
645}
646declare class UpdatableBlockImpl extends SimpleLiveBlock implements UpdatableBlock {
647 reset(): Nullable<SimpleNode>;
648}
649// FIXME: All the noops in here indicate a modelling problem
650declare class LiveBlockList implements LiveBlock {
651 private readonly parent;
652 boundList: LiveBlock[];
653 constructor(parent: SimpleElement, boundList: LiveBlock[]);
654 parentElement(): SimpleElement;
655 firstNode(): SimpleNode;
656 lastNode(): SimpleNode;
657 openElement(_element: SimpleElement): void;
658 closeElement(): void;
659 didAppendNode(_node: SimpleNode): void;
660 didAppendBounds(_bounds: Bounds): void;
661 finalize(_stack: ElementBuilder): void;
662}
663declare function clientBuilder(env: Environment, cursor: CursorImpl): ElementBuilder;
664declare class UpdatingVM implements IUpdatingVM {
665 env: Environment;
666 dom: GlimmerTreeChanges;
667 alwaysRevalidate: boolean;
668 private frameStack;
669 constructor(env: Environment, { alwaysRevalidate }: {
670 alwaysRevalidate?: boolean;
671 });
672 execute(opcodes: UpdatingOpcode[], handler: ExceptionHandler): void;
673 private _execute;
674 private get frame();
675 goto(index: number): void;
676 try(ops: UpdatingOpcode[], handler: Nullable<ExceptionHandler>): void;
677 throw(): void;
678}
679interface VMState {
680 readonly pc: number;
681 readonly scope: Scope;
682 readonly dynamicScope: DynamicScope;
683 readonly stack: unknown[];
684}
685interface ResumableVMState {
686 resume(runtime: RuntimeContext, builder: ElementBuilder): InternalVM;
687}
688declare abstract class BlockOpcode implements UpdatingOpcode, Bounds {
689 protected state: ResumableVMState;
690 protected runtime: RuntimeContext;
691 children: UpdatingOpcode[];
692 protected readonly bounds: LiveBlock;
693 constructor(state: ResumableVMState, runtime: RuntimeContext, bounds: LiveBlock, children: UpdatingOpcode[]);
694 parentElement(): import("@glimmer/interfaces").SimpleElement;
695 firstNode(): import("@glimmer/interfaces").SimpleNode;
696 lastNode(): import("@glimmer/interfaces").SimpleNode;
697 evaluate(vm: UpdatingVM): void;
698}
699declare class TryOpcode extends BlockOpcode implements ExceptionHandler {
700 type: string;
701 protected bounds: UpdatableBlock; // Hides property on base class
702 evaluate(vm: UpdatingVM): void;
703 handleException(): void;
704}
705declare class ListItemOpcode extends TryOpcode {
706 key: unknown;
707 memo: Reference;
708 value: Reference;
709 retained: boolean;
710 index: number;
711 constructor(state: ResumableVMState, runtime: RuntimeContext, bounds: UpdatableBlock, key: unknown, memo: Reference, value: Reference);
712 updateReferences(item: OpaqueIterationItem): void;
713 shouldRemove(): boolean;
714 reset(): void;
715}
716declare class ListBlockOpcode extends BlockOpcode {
717 private iterableRef;
718 type: string;
719 children: ListItemOpcode[];
720 private opcodeMap;
721 private marker;
722 private lastIterator;
723 protected readonly bounds: LiveBlockList;
724 constructor(state: ResumableVMState, runtime: RuntimeContext, bounds: LiveBlockList, children: ListItemOpcode[], iterableRef: Reference<OpaqueIterator>);
725 initializeChild(opcode: ListItemOpcode): void;
726 evaluate(vm: UpdatingVM): void;
727 private sync;
728 private retainItem;
729 private insertItem;
730 private moveItem;
731 private deleteItem;
732}
733/*
734The calling convention is:
735
736* 0-N block arguments at the bottom
737* 0-N positional arguments next (left-to-right)
738* 0-N named arguments next
739*/
740declare class VMArgumentsImpl implements VMArguments {
741 private stack;
742 positional: PositionalArgumentsImpl;
743 named: NamedArgumentsImpl;
744 blocks: BlockArgumentsImpl;
745 empty(stack: EvaluationStack): this;
746 setup(stack: EvaluationStack, names: readonly string[], blockNames: readonly string[], positionalCount: number, atNames: boolean): void;
747 get base(): number;
748 get length(): number;
749 at(pos: number): Reference;
750 realloc(offset: number): void;
751 capture(): CapturedArguments;
752 clear(): void;
753}
754declare class PositionalArgumentsImpl implements PositionalArguments {
755 base: number;
756 length: number;
757 private stack;
758 private _references;
759 empty(stack: EvaluationStack, base: number): void;
760 setup(stack: EvaluationStack, base: number, length: number): void;
761 at(position: number): Reference;
762 capture(): CapturedPositionalArguments;
763 prepend(other: Reference[]): void;
764 private get references();
765}
766declare class NamedArgumentsImpl implements NamedArguments {
767 base: number;
768 length: number;
769 private stack;
770 private _references;
771 private _names;
772 private _atNames;
773 empty(stack: EvaluationStack, base: number): void;
774 setup(stack: EvaluationStack, base: number, length: number, names: readonly string[], atNames: boolean): void;
775 get names(): readonly string[];
776 get atNames(): readonly string[];
777 has(name: string): boolean;
778 get(name: string, atNames?: boolean): Reference;
779 capture(): CapturedNamedArguments;
780 merge(other: Record<string, Reference>): void;
781 private get references();
782 private toSyntheticName;
783 private toAtName;
784}
785declare class BlockArgumentsImpl implements BlockArguments {
786 private stack;
787 private internalValues;
788 private _symbolNames;
789 internalTag: Nullable<Tag>;
790 names: readonly string[];
791 length: number;
792 base: number;
793 empty(stack: EvaluationStack, base: number): void;
794 setup(stack: EvaluationStack, base: number, length: number, names: readonly string[]): void;
795 get values(): readonly BlockValue[];
796 has(name: string): boolean;
797 get(name: string): Nullable<ScopeBlock>;
798 capture(): CapturedBlockArguments;
799 get symbolNames(): readonly string[];
800}
801declare function createCapturedArgs(named: Dict<Reference>, positional: Reference[]): CapturedArguments;
802declare function reifyNamed(named: CapturedNamedArguments): Dict<unknown>;
803declare function reifyPositional(positional: CapturedPositionalArguments): unknown[];
804declare function reifyArgs(args: CapturedArguments): {
805 named: Dict<unknown>;
806 positional: unknown[];
807};
808declare const EMPTY_NAMED: CapturedNamedArguments;
809declare const EMPTY_POSITIONAL: CapturedPositionalArguments;
810declare const EMPTY_ARGS: CapturedArguments;
811/**
812 * This interface is used by internal opcodes, and is more stable than
813 * the implementation of the Append VM itself.
814 */
815interface InternalVM {
816 readonly [CONSTANTS]: RuntimeConstants & ResolutionTimeConstants;
817 readonly [ARGS$0]: VMArgumentsImpl;
818 readonly env: Environment;
819 readonly stack: EvaluationStack;
820 readonly runtime: RuntimeContext;
821 readonly context: CompileTimeCompilationContext;
822 loadValue(register: MachineRegister, value: number): void;
823 loadValue(register: Register, value: unknown): void;
824 loadValue(register: Register | MachineRegister, value: unknown): void;
825 fetchValue(register: MachineRegister.ra | MachineRegister.pc): number;
826 // TODO: Something better than a type assertion?
827 fetchValue<T>(register: Register): T;
828 fetchValue(register: Register): unknown;
829 load(register: Register): void;
830 fetch(register: Register): void;
831 compile(block: CompilableTemplate): number;
832 scope(): Scope;
833 elements(): ElementBuilder;
834 getOwner(): Owner;
835 getSelf(): Reference;
836 updateWith(opcode: UpdatingOpcode): void;
837 associateDestroyable(d: Destroyable): void;
838 beginCacheGroup(name?: string): void;
839 commitCacheGroup(): void;
840 /// Iteration ///
841 enterList(iterableRef: Reference<OpaqueIterator>, offset: number): void;
842 exitList(): void;
843 enterItem(item: OpaqueIterationItem): ListItemOpcode;
844 registerItem(item: ListItemOpcode): void;
845 pushRootScope(size: number, owner: Owner): PartialScope;
846 pushChildScope(): void;
847 popScope(): void;
848 pushScope(scope: Scope): void;
849 dynamicScope(): DynamicScope;
850 bindDynamicScope(names: string[]): void;
851 pushDynamicScope(): void;
852 popDynamicScope(): void;
853 enter(args: number): void;
854 exit(): void;
855 goto(pc: number): void;
856 call(handle: number): void;
857 pushFrame(): void;
858 referenceForSymbol(symbol: number): Reference;
859 execute(initialize?: (vm: this) => void): RenderResult;
860 pushUpdating(list?: UpdatingOpcode[]): void;
861 next(): RichIteratorResult<null, RenderResult>;
862}
863declare class VM implements PublicVM, InternalVM {
864 readonly runtime: RuntimeContext;
865 private readonly elementStack;
866 readonly context: CompileTimeCompilationContext;
867 private readonly [STACKS];
868 private readonly [HEAP];
869 private readonly destructor;
870 private readonly [DESTROYABLE_STACK];
871 readonly [CONSTANTS]: RuntimeConstants & ResolutionTimeConstants;
872 readonly [ARGS$0]: VMArgumentsImpl;
873 readonly [INNER_VM]: LowLevelVM;
874 get stack(): EvaluationStack;
875 /* Registers */
876 get pc(): number;
877 s0: unknown;
878 s1: unknown;
879 t0: unknown;
880 t1: unknown;
881 v0: unknown;
882 // Fetch a value from a register onto the stack
883 fetch(register: SyscallRegister): void;
884 // Load a value from the stack into a register
885 load(register: SyscallRegister): void;
886 // Fetch a value from a register
887 fetchValue(register: MachineRegister): number;
888 fetchValue<T>(register: Register): T;
889 // Load a value into a register
890 loadValue<T>(register: Register | MachineRegister, value: T): void;
891 /**
892 * Migrated to Inner
893 */
894 // Start a new frame and save $ra and $fp on the stack
895 pushFrame(): void;
896 // Restore $ra, $sp and $fp
897 popFrame(): void;
898 // Jump to an address in `program`
899 goto(offset: number): void;
900 // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS)
901 call(handle: number): void;
902 // Put a specific `program` address in $ra
903 returnTo(offset: number): void;
904 // Return to the `program` address stored in $ra
905 return(): void;
906 /**
907 * End of migrated.
908 */
909 constructor(runtime: RuntimeContext, { pc, scope, dynamicScope, stack }: VMState, elementStack: ElementBuilder, context: CompileTimeCompilationContext);
910 static initial(runtime: RuntimeContext, context: CompileTimeCompilationContext, { handle, self, dynamicScope, treeBuilder, numSymbols, owner }: InitOptions): InternalVM;
911 static empty(runtime: RuntimeContext, { handle, treeBuilder, dynamicScope, owner }: MinimalInitOptions, context: CompileTimeCompilationContext): InternalVM;
912 private resume;
913 compile(block: CompilableTemplate): number;
914 get program(): RuntimeProgram;
915 get env(): Environment;
916 captureState(args: number, pc?: number): VMState;
917 capture(args: number, pc?: number): ResumableVMState;
918 beginCacheGroup(name?: string): void;
919 commitCacheGroup(): void;
920 enter(args: number): void;
921 enterItem({ key, value, memo }: OpaqueIterationItem): ListItemOpcode;
922 registerItem(opcode: ListItemOpcode): void;
923 enterList(iterableRef: Reference<OpaqueIterator>, offset: number): void;
924 private didEnter;
925 exit(): void;
926 exitList(): void;
927 pushUpdating(list?: UpdatingOpcode[]): void;
928 popUpdating(): UpdatingOpcode[];
929 updateWith(opcode: UpdatingOpcode): void;
930 listBlock(): ListBlockOpcode;
931 associateDestroyable(child: Destroyable): void;
932 tryUpdating(): Nullable<UpdatingOpcode[]>;
933 updating(): UpdatingOpcode[];
934 elements(): ElementBuilder;
935 scope(): Scope;
936 dynamicScope(): DynamicScope;
937 pushChildScope(): void;
938 pushDynamicScope(): DynamicScope;
939 pushRootScope(size: number, owner: Owner): PartialScope;
940 pushScope(scope: Scope): void;
941 popScope(): void;
942 popDynamicScope(): void;
943 /// SCOPE HELPERS
944 getOwner(): Owner;
945 getSelf(): Reference<any>;
946 referenceForSymbol(symbol: number): Reference;
947 /// EXECUTION
948 execute(initialize?: (vm: this) => void): RenderResult;
949 private _execute;
950 next(): RichIteratorResult<null, RenderResult>;
951 bindDynamicScope(names: string[]): void;
952}
953interface MinimalInitOptions {
954 handle: number;
955 treeBuilder: ElementBuilder;
956 dynamicScope: DynamicScope;
957 owner: Owner;
958}
959interface InitOptions extends MinimalInitOptions {
960 self: Reference;
961 numSymbols: number;
962}
963declare const SERIALIZATION_FIRST_NODE_STRING = "%+b:0%";
964declare function isSerializationFirstNode(node: SimpleNode): boolean;
965declare class RehydratingCursor extends CursorImpl {
966 readonly startingBlockDepth: number;
967 candidate: Nullable<SimpleNode>;
968 openBlockDepth: number;
969 injectedOmittedNode: boolean;
970 constructor(element: SimpleElement, nextSibling: Nullable<SimpleNode>, startingBlockDepth: number);
971}
972declare class RehydrateBuilder extends NewElementBuilder implements ElementBuilder {
973 private unmatchedAttributes;
974 [CURSOR_STACK]: Stack$0<RehydratingCursor>; // Hides property on base class
975 blockDepth: number;
976 startingBlockOffset: number;
977 constructor(env: Environment, parentNode: SimpleElement, nextSibling: Nullable<SimpleNode>);
978 get currentCursor(): Nullable<RehydratingCursor>;
979 get candidate(): Nullable<SimpleNode>;
980 set candidate(node: Nullable<SimpleNode>);
981 disableRehydration(nextSibling: Nullable<SimpleNode>): void;
982 enableRehydration(candidate: Nullable<SimpleNode>): void;
983 pushElement(/** called from parent constructor before we initialize this */
984 this: RehydrateBuilder | (NewElementBuilder & Partial<Pick<RehydrateBuilder, "blockDepth" | "candidate">>), element: SimpleElement, nextSibling?: Maybe<SimpleNode>): void;
985 // clears until the end of the current container
986 // either the current open block or higher
987 private clearMismatch;
988 __openBlock(): void;
989 __closeBlock(): void;
990 __appendNode(node: SimpleNode): SimpleNode;
991 __appendHTML(html: string): Bounds;
992 protected remove(node: SimpleNode): Nullable<SimpleNode>;
993 private markerBounds;
994 __appendText(string: string): SimpleText;
995 __appendComment(string: string): SimpleComment;
996 __openElement(tag: string): SimpleElement;
997 __setAttribute(name: string, value: string, namespace: Nullable<AttrNamespace>): void;
998 __setProperty(name: string, value: string): void;
999 __flushElement(parent: SimpleElement, constructing: SimpleElement): void;
1000 willCloseElement(): void;
1001 getMarker(element: HTMLElement, guid: string): Nullable<SimpleNode>;
1002 __pushRemoteElement(element: SimpleElement, cursorId: string, insertBefore: Maybe<SimpleNode>): RemoteLiveBlock;
1003 didAppendBounds(bounds: Bounds): Bounds;
1004}
1005declare function rehydrationBuilder(env: Environment, cursor: CursorImpl): ElementBuilder;
1006type IteratorResult<T> = RichIteratorResult<null, T>;
1007export { 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, runtimeContext, array, concat, fn, get, hash, invokeHelper, on, renderComponent, renderMain, renderSync, DynamicScopeImpl, PartialScopeImpl, InternalVM, VM as LowLevelVM, UpdatingVM, createCapturedArgs, EMPTY_ARGS, EMPTY_NAMED, EMPTY_POSITIONAL, reifyArgs, reifyNamed, reifyPositional, DynamicAttribute, dynamicAttribute, SimpleDynamicAttribute, clientBuilder, NewElementBuilder, RemoteLiveBlock, UpdatableBlockImpl, isSerializationFirstNode, RehydrateBuilder, rehydrationBuilder, SERIALIZATION_FIRST_NODE_STRING, IteratorResult };
1008export type { SafeString };
1009export { destroy, isDestroyed, isDestroying, registerDestructor } from "@glimmer/destroyable";
1010//# sourceMappingURL=index.d.ts.map
\No newline at end of file