1 | import { Dict, Nullable, Stack, SimpleElement, InsertPosition, Namespace, SimpleNode, Maybe, Present, PresentArray, SimpleDocument, ErrHandle, HandleResult, OkHandle, Template, TemplateOk } from "@glimmer/interfaces";
|
2 | declare const EMPTY_ARRAY: readonly unknown[];
|
3 | declare function emptyArray<T>(): T[];
|
4 | declare const EMPTY_STRING_ARRAY: string[];
|
5 | declare const EMPTY_NUMBER_ARRAY: number[];
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | declare function isEmptyArray(input: unknown[] | readonly unknown[]): boolean;
|
11 | declare function reverse<T>(input: T[]): IterableIterator<T>;
|
12 | declare function enumerate<T>(input: Iterable<T>): IterableIterator<[
|
13 | number,
|
14 | T
|
15 | ]>;
|
16 |
|
17 | declare function debugAssert(test: any, msg: string): asserts test;
|
18 | declare function deprecate(desc: string): void;
|
19 | declare function dict<T = unknown>(): Dict<T>;
|
20 | declare function isDict<T>(u: T): u is Dict & T;
|
21 | declare function isObject<T>(u: T): u is object & T;
|
22 | declare class StackImpl<T> implements Stack<T> {
|
23 | private stack;
|
24 | current: Nullable<T>;
|
25 | constructor(values?: T[]);
|
26 | get size(): number;
|
27 | push(item: T): void;
|
28 | pop(): Nullable<T>;
|
29 | nth(from: number): Nullable<T>;
|
30 | isEmpty(): boolean;
|
31 | toArray(): T[];
|
32 | }
|
33 | declare let beginTestSteps: (() => void) | undefined;
|
34 | declare let endTestSteps: (() => void) | undefined;
|
35 | declare let verifySteps: ((type: string, steps: unknown[] | ((steps: unknown[]) => void), message?: string) => void) | undefined;
|
36 | declare let logStep: ((type: string, steps: unknown) => void) | undefined;
|
37 | declare let debugToString: undefined | ((value: unknown) => string);
|
38 | declare function clearElement(parent: SimpleElement): void;
|
39 | declare const RAW_NODE = -1;
|
40 | declare const ELEMENT_NODE = 1;
|
41 | declare const TEXT_NODE = 3;
|
42 | declare const COMMENT_NODE = 8;
|
43 | declare const DOCUMENT_NODE = 9;
|
44 | declare const DOCUMENT_TYPE_NODE = 10;
|
45 | declare const DOCUMENT_FRAGMENT_NODE = 11;
|
46 | declare const NS_HTML: Namespace.HTML;
|
47 | declare const NS_MATHML: Namespace.MathML;
|
48 | declare const NS_SVG: Namespace.SVG;
|
49 | declare const NS_XLINK: Namespace.XLink;
|
50 | declare const NS_XML: Namespace.XML;
|
51 | declare const NS_XMLNS: Namespace.XMLNS;
|
52 | declare const INSERT_BEFORE_BEGIN: InsertPosition.beforebegin;
|
53 | declare const INSERT_AFTER_BEGIN: InsertPosition.afterbegin;
|
54 | declare const INSERT_BEFORE_END: InsertPosition.beforeend;
|
55 | declare const INSERT_AFTER_END: InsertPosition.afterend;
|
56 | /*
|
57 | Encoding notes
|
58 |
|
59 | We use 30 bit integers for encoding, so that we don't ever encode a non-SMI
|
60 | integer to push on the stack.
|
61 |
|
62 | Handles are >= 0
|
63 | Immediates are < 0
|
64 |
|
65 | True, False, Undefined and Null are pushed as handles into the symbol table,
|
66 | with well known handles (0, 1, 2, 3)
|
67 |
|
68 | The negative space is divided into positives and negatives. Positives are
|
69 | higher numbers (-1, -2, -3, etc), negatives are lower.
|
70 |
|
71 | We only encode immediates for two reasons:
|
72 |
|
73 | 1. To transfer over the wire, so they're smaller in general
|
74 | 2. When pushing values onto the stack from the low level/inner VM, which may
|
75 | be converted into WASM one day.
|
76 |
|
77 | This allows the low-level VM to always use SMIs, and to minimize using JS
|
78 | values via handles for things like the stack pointer and frame pointer.
|
79 | Externally, most code pushes values as JS values, except when being pulled
|
80 | from the append byte code where it was already encoded.
|
81 |
|
82 | Logically, this is because the low level VM doesn't really care about these
|
83 | higher level values. For instance, the result of a userland helper may be a
|
84 | number, or a boolean, or undefined/null, but it's extra work to figure that
|
85 | out and push it correctly, vs. just pushing the value as a JS value with a
|
86 | handle.
|
87 |
|
88 | Note: The details could change here in the future, this is just the current
|
89 | strategy.
|
90 | */
|
91 | declare enum ImmediateConstants {
|
92 | MAX_SMI = 1073741823,
|
93 | MIN_SMI = -1073741824,
|
94 | SIGN_BIT = -536870913,
|
95 | MAX_INT = 536870911,
|
96 | MIN_INT = -536870912,
|
97 | FALSE_HANDLE = 0,
|
98 | TRUE_HANDLE = 1,
|
99 | NULL_HANDLE = 2,
|
100 | UNDEFINED_HANDLE = 3,
|
101 | ENCODED_FALSE_HANDLE = 0,
|
102 | ENCODED_TRUE_HANDLE = 1,
|
103 | ENCODED_NULL_HANDLE = 2,
|
104 | ENCODED_UNDEFINED_HANDLE = 3
|
105 | }
|
106 | declare function isHandle(value: number): boolean;
|
107 | declare function isNonPrimitiveHandle(value: number): boolean;
|
108 | declare function constants(...values: unknown[]): unknown[];
|
109 | declare function isSmallInt(value: number): boolean;
|
110 | declare function encodeNegative(num: number): number;
|
111 | declare function decodeNegative(num: number): number;
|
112 | declare function encodePositive(num: number): number;
|
113 | declare function decodePositive(num: number): number;
|
114 | declare function encodeHandle(num: number): number;
|
115 | declare function decodeHandle(num: number): number;
|
116 | declare function encodeImmediate(num: number): number;
|
117 | declare function decodeImmediate(num: number): number;
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | declare function intern(str: string): string;
|
158 | declare const SERIALIZATION_FIRST_NODE_STRING = "%+b:0%";
|
159 | declare function isSerializationFirstNode(node: SimpleNode): boolean;
|
160 | declare let assign: {
|
161 | <T extends {}, U>(target: T, source: U): T & U;
|
162 | <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
163 | <T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
164 | (target: object, ...sources: any[]): any;
|
165 | };
|
166 | declare function values<T>(obj: {
|
167 | [s: string]: T;
|
168 | }): T[];
|
169 | type ObjectEntry<D extends object> = {
|
170 | [P in keyof D]: [
|
171 | P,
|
172 | D[P]
|
173 | ];
|
174 | }[keyof D];
|
175 | declare function entries<D extends object>(dict: D): ObjectEntry<D>[];
|
176 | type Factory<T> = new (...args: unknown[]) => T;
|
177 | declare function keys<T extends object>(obj: T): Array<keyof T>;
|
178 | declare function unwrap<T>(val: Maybe<T>): T;
|
179 | declare function expect<T>(val: T, message: string): Present<T>;
|
180 | declare function unreachable(message?: string): Error;
|
181 | declare function exhausted(value: never): never;
|
182 | type Lit = string | number | boolean | undefined | null | void | {};
|
183 | declare const tuple: <T extends Lit[]>(...args: T) => T;
|
184 | declare function isPresent<T>(value: T): value is Present<T>;
|
185 | declare function assertPresent<T extends string>(value: T): asserts value is Present<T>;
|
186 | declare function assertPresent<T>(value: T, message: string): asserts value is Present<T>;
|
187 | declare function isPresentArray<T>(list: readonly T[]): list is PresentArray<T>;
|
188 | declare function ifPresent<T, U, V>(list: T[], ifPresent: (input: PresentArray<T>) => U, otherwise: () => V): U | V;
|
189 | declare function arrayToOption<T>(list: T[]): Nullable<PresentArray<T>>;
|
190 | declare function assertPresentArray<T>(list: T[], message?: string): asserts list is PresentArray<T>;
|
191 | declare function asPresentArray<T>(list: T[], message?: string): PresentArray<T>;
|
192 | declare function getLast<T>(list: PresentArray<T>): T;
|
193 | declare function getLast<T>(list: T[]): T | undefined;
|
194 | declare function getFirst<T>(list: PresentArray<T>): T;
|
195 | declare function getFirst<T>(list: T[]): T | undefined;
|
196 | declare function mapPresentArray<T, U>(list: PresentArray<T>, mapper: (input: T) => U): PresentArray<U>;
|
197 | declare function mapPresentArray<T, U>(list: PresentArray<T> | null, mapper: (input: T) => U): PresentArray<U> | null;
|
198 | interface GenericElementTags {
|
199 | HTML: HTMLElement;
|
200 | SVG: SVGElement;
|
201 | ELEMENT: HTMLElement | SVGElement;
|
202 | }
|
203 | interface GenericNodeTags {
|
204 | NODE: Node;
|
205 | }
|
206 | type GenericNodeTag = keyof GenericNodeTags;
|
207 | interface BrowserElementTags extends HTMLElementTagNameMap, GenericElementTags {
|
208 | }
|
209 | type BrowserElementTag = keyof BrowserElementTags;
|
210 | interface BrowserTags extends BrowserElementTags, GenericNodeTags {
|
211 | }
|
212 | type BrowserTag = keyof BrowserTags;
|
213 | type NodeCheck<N extends Node> = (node: Node) => node is N;
|
214 | type SugaryNodeCheck<K extends BrowserTag = BrowserTag> = NodeCheck<BrowserTags[K]> | K | K[];
|
215 | type NodeForSugaryCheck<S extends SugaryNodeCheck<BrowserTag>> = S extends NodeCheck<infer N> ? N : S extends keyof BrowserTags ? BrowserTags[S] : S extends (keyof BrowserTags)[] ? BrowserTags[S[number]] : never;
|
216 | type BrowserNode = Element | Document | DocumentFragment | Text | Comment | Node;
|
217 | declare function castToSimple(doc: Document | SimpleDocument): SimpleDocument;
|
218 | declare function castToSimple(elem: Element | SimpleElement): SimpleElement;
|
219 | declare function castToSimple(node: Node | SimpleNode): SimpleNode;
|
220 |
|
221 | declare function castToBrowser(doc: Document | SimpleDocument): Document;
|
222 |
|
223 |
|
224 | declare function castToBrowser<S extends SugaryNodeCheck<BrowserElementTag>>(node: BrowserNode | SimpleNode, check: S): NodeForSugaryCheck<S>;
|
225 |
|
226 |
|
227 | declare function castToBrowser<S extends SugaryNodeCheck<GenericNodeTag>>(element: BrowserNode | SimpleNode, check: S): NodeForSugaryCheck<S>;
|
228 | declare function castToBrowser<K extends keyof HTMLElementTagNameMap>(element: SimpleElement | Element, check: K): HTMLElementTagNameMap[K];
|
229 | declare function isSimpleElement(node: Maybe<SimpleNode | Node>): node is SimpleElement;
|
230 | declare function isElement(node: Maybe<Node | SimpleNode>): node is Element;
|
231 | declare function checkBrowserNode<S extends SugaryNodeCheck>(node: Node | SimpleNode | null, check: S): NodeForSugaryCheck<S>;
|
232 | declare function strip(strings: TemplateStringsArray, ...args: unknown[]): string;
|
233 | declare function unwrapHandle(handle: HandleResult): number;
|
234 | declare function unwrapTemplate(template: Template): TemplateOk;
|
235 | declare function extractHandle(handle: HandleResult): number;
|
236 | declare function isOkHandle(handle: HandleResult): handle is OkHandle;
|
237 | declare function isErrHandle(handle: HandleResult): handle is ErrHandle;
|
238 | declare function buildUntouchableThis(source: string): null | object;
|
239 | type FIXME<T, S extends string> = (T & S) | T;
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 | declare const LOCAL_LOGGER: Console;
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | declare const LOGGER: Console;
|
256 | declare function assertNever(value: never, desc?: string): never;
|
257 | export { EMPTY_ARRAY, emptyArray, EMPTY_STRING_ARRAY, EMPTY_NUMBER_ARRAY, isEmptyArray, reverse, enumerate, debugAssert as assert, deprecate, dict, isDict, isObject, StackImpl as Stack, beginTestSteps, endTestSteps, logStep, verifySteps, debugToString, clearElement, RAW_NODE, ELEMENT_NODE, TEXT_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NS_HTML, NS_MATHML, NS_SVG, NS_XLINK, NS_XML, NS_XMLNS, INSERT_BEFORE_BEGIN, INSERT_AFTER_BEGIN, INSERT_BEFORE_END, INSERT_AFTER_END, ImmediateConstants, isHandle, isNonPrimitiveHandle, constants, isSmallInt, encodeNegative, decodeNegative, encodePositive, decodePositive, encodeHandle, decodeHandle, encodeImmediate, decodeImmediate, intern, isSerializationFirstNode, SERIALIZATION_FIRST_NODE_STRING, assign, entries, values, Factory, keys, unwrap, expect, unreachable, exhausted, Lit, tuple, isPresent, assertPresent, isPresentArray, ifPresent, arrayToOption, assertPresentArray, asPresentArray, getLast, getFirst, mapPresentArray, castToBrowser, castToSimple, checkBrowserNode as checkNode, isElement, isSimpleElement, strip, unwrapHandle, unwrapTemplate, extractHandle, isOkHandle, isErrHandle, buildUntouchableThis, FIXME, LOCAL_LOGGER, LOGGER, assertNever };
|
258 |
|
\ | No newline at end of file |