UNPKG

1.18 kBTypeScriptView Raw
1import { Environment } from './environment';
2// eslint-disable-next-line node/no-extraneous-import
3import { Reference } from '@glimmer/reference';
4import { Destroyable } from '../core';
5import { DynamicScope } from './scope';
6import { Owner } from './owner';
7import { GlimmerTreeChanges } from '../dom/changes';
8import { ExceptionHandler } from './render';
9/**
10 * This is used in the Glimmer Embedding API. In particular, embeddings
11 * provide helpers through the `CompileTimeLookup` interface, and the
12 * helpers they provide implement the `Helper` interface, which is a
13 * function that takes a `VM` as a parameter.
14 */
15export interface VM<O extends Owner = Owner> {
16 env: Environment;
17 dynamicScope(): DynamicScope;
18 getOwner(): O;
19 getSelf(): Reference;
20 associateDestroyable(child: Destroyable): void;
21}
22
23export interface UpdatingVM {
24 env: Environment;
25 dom: GlimmerTreeChanges;
26 alwaysRevalidate: boolean;
27
28 execute(opcodes: UpdatingOpcode[], handler: ExceptionHandler): void;
29 goto(index: number): void;
30 try(ops: UpdatingOpcode[], handler: ExceptionHandler | null): void;
31 throw(): void;
32}
33
34export interface UpdatingOpcode {
35 evaluate(vm: UpdatingVM): void;
36}