textmatelib 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Grammar.d.ts +36 -1
- package/dist/index.cjs +95 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +95 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +44 -0
- package/package.json +1 -1
- package/wasm/package.json +3 -0
- package/wasm/tml-standard.js +20 -2
- package/wasm/tml-standard.wasm +0 -0
package/dist/Grammar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WasmModule, TokenizeResult, TokenizeResult2, RuleStack } from './types';
|
|
1
|
+
import type { WasmModule, Token, TokenizeResult, TokenizeResult2, TokenizeLinesResult2, TokenizeLinesScopeFlatResult, RuleStack } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a TextMate grammar for syntax highlighting
|
|
4
4
|
*/
|
|
@@ -25,6 +25,41 @@ export declare class Grammar {
|
|
|
25
25
|
* @returns The tokenization result with binary tokens and rule stack
|
|
26
26
|
*/
|
|
27
27
|
tokenizeLine2(line: string, prevState?: RuleStack): TokenizeResult2;
|
|
28
|
+
/**
|
|
29
|
+
* Tokenize a whole document in a single call.
|
|
30
|
+
*
|
|
31
|
+
* The rule stack is carried across lines inside WASM, so this performs one JS<->WASM
|
|
32
|
+
* crossing for the entire document instead of one per line. Prefer this over looping
|
|
33
|
+
* {@link tokenizeLine} when highlighting static text; use the per-line API for live
|
|
34
|
+
* editing where individual lines change.
|
|
35
|
+
*
|
|
36
|
+
* @param lines The document lines (already split on newlines)
|
|
37
|
+
* @returns An array with one entry per line, each an array of scope tokens
|
|
38
|
+
*/
|
|
39
|
+
tokenizeLines(lines: string[]): Token[][];
|
|
40
|
+
/**
|
|
41
|
+
* Tokenize a whole document in a single call, binary (themed) format.
|
|
42
|
+
*
|
|
43
|
+
* Like {@link tokenizeLines} but returns the compact encoded-token representation that
|
|
44
|
+
* a highlighter consumes. All tokens are packed into one flat `Uint32Array`; walk
|
|
45
|
+
* `lineTokenCounts` to recover per-line ranges.
|
|
46
|
+
*
|
|
47
|
+
* @param lines The document lines (already split on newlines)
|
|
48
|
+
* @returns The packed tokens plus per-line token counts
|
|
49
|
+
*/
|
|
50
|
+
tokenizeLines2(lines: string[]): TokenizeLinesResult2;
|
|
51
|
+
/**
|
|
52
|
+
* Tokenize a whole document into a flat, dictionary-encoded scope representation.
|
|
53
|
+
*
|
|
54
|
+
* Equivalent scope information to {@link tokenizeLines} but encoded as a single numeric
|
|
55
|
+
* buffer plus an interned scope-name dictionary, avoiding the per-token object marshalling
|
|
56
|
+
* across the WASM boundary. Prefer this over {@link tokenizeLines} when highlighting static
|
|
57
|
+
* text and you can consume the flat layout directly.
|
|
58
|
+
*
|
|
59
|
+
* @param lines The document lines (already split on newlines)
|
|
60
|
+
* @returns The flat token buffer, per-line token counts, and the scope-name dictionary
|
|
61
|
+
*/
|
|
62
|
+
tokenizeLinesScopeFlat(lines: string[]): TokenizeLinesScopeFlatResult;
|
|
28
63
|
/**
|
|
29
64
|
* Get the scope name of this grammar
|
|
30
65
|
* @returns The scope name (e.g., "source.js")
|
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,24 @@ class Grammar {
|
|
|
20
20
|
* @returns The tokenization result with tokens and rule stack for next line
|
|
21
21
|
*/
|
|
22
22
|
tokenizeLine(line, prevState = null) {
|
|
23
|
-
|
|
23
|
+
// Build the token objects in JS from a flat numeric buffer + per-line scope dictionary
|
|
24
|
+
// rather than marshalling one object (and a scope-string array) per token across the WASM
|
|
25
|
+
// boundary — same output, but native JS object construction is far cheaper than building
|
|
26
|
+
// `val` objects. The flat buffer is a view into WASM heap memory only valid until the next
|
|
27
|
+
// WASM call, so we consume it fully here within this synchronous call.
|
|
28
|
+
const { tokens, scopeNames, ruleStack } = this.native.tokenizeLineScopeFlat(line, prevState);
|
|
29
|
+
const out = [];
|
|
30
|
+
let cursor = 0;
|
|
31
|
+
while (cursor < tokens.length) {
|
|
32
|
+
const startIndex = tokens[cursor++];
|
|
33
|
+
const endIndex = tokens[cursor++];
|
|
34
|
+
const scopeCount = tokens[cursor++];
|
|
35
|
+
const scopes = new Array(scopeCount);
|
|
36
|
+
for (let s = 0; s < scopeCount; s++)
|
|
37
|
+
scopes[s] = scopeNames[tokens[cursor++]];
|
|
38
|
+
out.push({ startIndex, endIndex, scopes });
|
|
39
|
+
}
|
|
40
|
+
return { tokens: out, ruleStack };
|
|
24
41
|
}
|
|
25
42
|
/**
|
|
26
43
|
* Tokenize a single line of text with binary format
|
|
@@ -31,6 +48,83 @@ class Grammar {
|
|
|
31
48
|
tokenizeLine2(line, prevState = null) {
|
|
32
49
|
return this.native.tokenizeLine2(line, prevState);
|
|
33
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Tokenize a whole document in a single call.
|
|
53
|
+
*
|
|
54
|
+
* The rule stack is carried across lines inside WASM, so this performs one JS<->WASM
|
|
55
|
+
* crossing for the entire document instead of one per line. Prefer this over looping
|
|
56
|
+
* {@link tokenizeLine} when highlighting static text; use the per-line API for live
|
|
57
|
+
* editing where individual lines change.
|
|
58
|
+
*
|
|
59
|
+
* @param lines The document lines (already split on newlines)
|
|
60
|
+
* @returns An array with one entry per line, each an array of scope tokens
|
|
61
|
+
*/
|
|
62
|
+
tokenizeLines(lines) {
|
|
63
|
+
// Build the rich token objects in JS from a flat numeric buffer + interned scope
|
|
64
|
+
// dictionary, rather than marshalling one object (and a scope-string array) per token
|
|
65
|
+
// across the WASM boundary. The embind object path costs ~1.5x more for identical output
|
|
66
|
+
// — native JS object construction is far cheaper than constructing `val` objects. The
|
|
67
|
+
// flat buffers are views into WASM heap memory only valid until the next WASM call, so we
|
|
68
|
+
// consume them fully here within this synchronous call.
|
|
69
|
+
const { tokens, lineTokenCounts, scopeNames } = this.native.tokenizeLinesScopeFlat(lines);
|
|
70
|
+
const out = new Array(lineTokenCounts.length);
|
|
71
|
+
let cursor = 0;
|
|
72
|
+
for (let li = 0; li < lineTokenCounts.length; li++) {
|
|
73
|
+
const n = lineTokenCounts[li];
|
|
74
|
+
const lineTokens = new Array(n);
|
|
75
|
+
for (let t = 0; t < n; t++) {
|
|
76
|
+
const startIndex = tokens[cursor++];
|
|
77
|
+
const endIndex = tokens[cursor++];
|
|
78
|
+
const scopeCount = tokens[cursor++];
|
|
79
|
+
const scopes = new Array(scopeCount);
|
|
80
|
+
for (let s = 0; s < scopeCount; s++)
|
|
81
|
+
scopes[s] = scopeNames[tokens[cursor++]];
|
|
82
|
+
lineTokens[t] = { startIndex, endIndex, scopes };
|
|
83
|
+
}
|
|
84
|
+
out[li] = lineTokens;
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Tokenize a whole document in a single call, binary (themed) format.
|
|
90
|
+
*
|
|
91
|
+
* Like {@link tokenizeLines} but returns the compact encoded-token representation that
|
|
92
|
+
* a highlighter consumes. All tokens are packed into one flat `Uint32Array`; walk
|
|
93
|
+
* `lineTokenCounts` to recover per-line ranges.
|
|
94
|
+
*
|
|
95
|
+
* @param lines The document lines (already split on newlines)
|
|
96
|
+
* @returns The packed tokens plus per-line token counts
|
|
97
|
+
*/
|
|
98
|
+
tokenizeLines2(lines) {
|
|
99
|
+
const result = this.native.tokenizeLines2(lines);
|
|
100
|
+
// The native arrays are views into WASM heap memory that are reused on the next
|
|
101
|
+
// call; copy them into JS-owned arrays before returning.
|
|
102
|
+
return {
|
|
103
|
+
tokens: new Uint32Array(result.tokens),
|
|
104
|
+
lineTokenCounts: new Uint32Array(result.lineTokenCounts),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Tokenize a whole document into a flat, dictionary-encoded scope representation.
|
|
109
|
+
*
|
|
110
|
+
* Equivalent scope information to {@link tokenizeLines} but encoded as a single numeric
|
|
111
|
+
* buffer plus an interned scope-name dictionary, avoiding the per-token object marshalling
|
|
112
|
+
* across the WASM boundary. Prefer this over {@link tokenizeLines} when highlighting static
|
|
113
|
+
* text and you can consume the flat layout directly.
|
|
114
|
+
*
|
|
115
|
+
* @param lines The document lines (already split on newlines)
|
|
116
|
+
* @returns The flat token buffer, per-line token counts, and the scope-name dictionary
|
|
117
|
+
*/
|
|
118
|
+
tokenizeLinesScopeFlat(lines) {
|
|
119
|
+
const result = this.native.tokenizeLinesScopeFlat(lines);
|
|
120
|
+
// The numeric arrays are views into WASM heap memory reused on the next call; copy them
|
|
121
|
+
// into JS-owned arrays before returning. scopeNames is already a JS array.
|
|
122
|
+
return {
|
|
123
|
+
tokens: new Uint32Array(result.tokens),
|
|
124
|
+
lineTokenCounts: new Uint32Array(result.lineTokenCounts),
|
|
125
|
+
scopeNames: result.scopeNames,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
34
128
|
/**
|
|
35
129
|
* Get the scope name of this grammar
|
|
36
130
|
* @returns The scope name (e.g., "source.js")
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/Grammar.ts","../src/Registry.ts","../src/TextMate.ts"],"sourcesContent":["import type { WasmModule, NativeGrammar, TokenizeResult, TokenizeResult2, RuleStack } from './types';\n\n/**\n * Represents a TextMate grammar for syntax highlighting\n */\nexport class Grammar {\n private native: NativeGrammar;\n\n /**\n * Creates a Grammar wrapper for a native grammar handle\n * @param module The WASM module\n * @param handle The native grammar handle\n * @internal\n */\n constructor(module: WasmModule, handle: number) {\n this.native = new module.Grammar(handle);\n }\n\n /**\n * Tokenize a single line of text\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with tokens and rule stack for next line\n */\n tokenizeLine(line: string, prevState: RuleStack = null): TokenizeResult {\n return this.native.tokenizeLine(line, prevState);\n }\n\n /**\n * Tokenize a single line of text with binary format\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with binary tokens and rule stack\n */\n tokenizeLine2(line: string, prevState: RuleStack = null): TokenizeResult2 {\n return this.native.tokenizeLine2(line, prevState);\n }\n\n /**\n * Get the scope name of this grammar\n * @returns The scope name (e.g., \"source.js\")\n */\n getScopeName(): string {\n return this.native.getScopeName();\n }\n}\n","import type { WasmModule, NativeRegistry } from './types';\nimport { Grammar } from './Grammar';\n\n/**\n * Registry for managing TextMate grammars and themes\n */\nexport class Registry {\n private module: WasmModule;\n private native: NativeRegistry;\n\n /**\n * Creates a new Registry\n * @param module The WASM module\n * @internal\n */\n constructor(module: WasmModule) {\n this.module = module;\n this.native = new module.Registry();\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n loadGrammar(scopeName: string, content: string): Grammar | null {\n const handle = this.native.loadGrammarFromContent(content, scopeName);\n if (handle === null || handle === 0) {\n return null;\n }\n return new Grammar(this.module, handle);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.native.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.native.getColorMap();\n }\n}\n","import type { WasmModule } from './types';\nimport { Registry } from './Registry';\nimport { Grammar } from './Grammar';\n\n/**\n * Main entry point for TextMate syntax highlighting\n */\nexport class TextMate {\n private module: WasmModule;\n private registry: Registry;\n\n /**\n * Private constructor - use TextMate.create() instead\n * @param module The initialized WASM module\n */\n private constructor(module: WasmModule) {\n this.module = module;\n this.registry = new Registry(module);\n }\n\n /**\n * Create a new TextMate instance\n * @returns A promise that resolves to an initialized TextMate instance\n */\n static async create(): Promise<TextMate> {\n // Dynamic import of the WASM module\n const createModule = await import('../wasm/tml-standard.js');\n const module = await createModule.default() as WasmModule;\n return new TextMate(module);\n }\n\n /**\n * Get the grammar registry\n * @returns The Registry instance\n */\n getRegistry(): Registry {\n return this.registry;\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n async loadGrammar(scopeName: string, content: string): Promise<Grammar | null> {\n return this.registry.loadGrammar(scopeName, content);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.registry.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.registry.getColorMap();\n }\n}\n"],"names":[],"mappings":";;AAEA;;AAEG;MACU,OAAO,CAAA;AAGlB;;;;;AAKG;IACH,WAAA,CAAY,MAAkB,EAAE,MAAc,EAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAC1C;AAEA;;;;;AAKG;AACH,IAAA,YAAY,CAAC,IAAY,EAAE,SAAA,GAAuB,IAAI,EAAA;QACpD,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC;IAClD;AAEA;;;;;AAKG;AACH,IAAA,aAAa,CAAC,IAAY,EAAE,SAAA,GAAuB,IAAI,EAAA;QACrD,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC;IACnD;AAEA;;;AAGG;IACH,YAAY,GAAA;AACV,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;IACnC;AACD;;AC1CD;;AAEG;MACU,QAAQ,CAAA;AAInB;;;;AAIG;AACH,IAAA,WAAA,CAAY,MAAkB,EAAA;AAC5B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE;IACrC;AAEA;;;;;AAKG;IACH,WAAW,CAAC,SAAiB,EAAE,OAAe,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;;;AAGG;IACH,WAAW,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;IACpC;AACD;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/Grammar.ts","../src/Registry.ts","../src/TextMate.ts"],"sourcesContent":["import type {\n WasmModule,\n NativeGrammar,\n Token,\n TokenizeResult,\n TokenizeResult2,\n TokenizeLinesResult2,\n TokenizeLinesScopeFlatResult,\n RuleStack,\n} from './types';\n\n/**\n * Represents a TextMate grammar for syntax highlighting\n */\nexport class Grammar {\n private native: NativeGrammar;\n\n /**\n * Creates a Grammar wrapper for a native grammar handle\n * @param module The WASM module\n * @param handle The native grammar handle\n * @internal\n */\n constructor(module: WasmModule, handle: number) {\n this.native = new module.Grammar(handle);\n }\n\n /**\n * Tokenize a single line of text\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with tokens and rule stack for next line\n */\n tokenizeLine(line: string, prevState: RuleStack = null): TokenizeResult {\n // Build the token objects in JS from a flat numeric buffer + per-line scope dictionary\n // rather than marshalling one object (and a scope-string array) per token across the WASM\n // boundary — same output, but native JS object construction is far cheaper than building\n // `val` objects. The flat buffer is a view into WASM heap memory only valid until the next\n // WASM call, so we consume it fully here within this synchronous call.\n const { tokens, scopeNames, ruleStack } = this.native.tokenizeLineScopeFlat(line, prevState);\n const out: Token[] = [];\n let cursor = 0;\n while (cursor < tokens.length) {\n const startIndex = tokens[cursor++];\n const endIndex = tokens[cursor++];\n const scopeCount = tokens[cursor++];\n const scopes: string[] = new Array(scopeCount);\n for (let s = 0; s < scopeCount; s++) scopes[s] = scopeNames[tokens[cursor++]];\n out.push({ startIndex, endIndex, scopes });\n }\n return { tokens: out, ruleStack };\n }\n\n /**\n * Tokenize a single line of text with binary format\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with binary tokens and rule stack\n */\n tokenizeLine2(line: string, prevState: RuleStack = null): TokenizeResult2 {\n return this.native.tokenizeLine2(line, prevState);\n }\n\n /**\n * Tokenize a whole document in a single call.\n *\n * The rule stack is carried across lines inside WASM, so this performs one JS<->WASM\n * crossing for the entire document instead of one per line. Prefer this over looping\n * {@link tokenizeLine} when highlighting static text; use the per-line API for live\n * editing where individual lines change.\n *\n * @param lines The document lines (already split on newlines)\n * @returns An array with one entry per line, each an array of scope tokens\n */\n tokenizeLines(lines: string[]): Token[][] {\n // Build the rich token objects in JS from a flat numeric buffer + interned scope\n // dictionary, rather than marshalling one object (and a scope-string array) per token\n // across the WASM boundary. The embind object path costs ~1.5x more for identical output\n // — native JS object construction is far cheaper than constructing `val` objects. The\n // flat buffers are views into WASM heap memory only valid until the next WASM call, so we\n // consume them fully here within this synchronous call.\n const { tokens, lineTokenCounts, scopeNames } = this.native.tokenizeLinesScopeFlat(lines);\n const out: Token[][] = new Array(lineTokenCounts.length);\n let cursor = 0;\n for (let li = 0; li < lineTokenCounts.length; li++) {\n const n = lineTokenCounts[li];\n const lineTokens: Token[] = new Array(n);\n for (let t = 0; t < n; t++) {\n const startIndex = tokens[cursor++];\n const endIndex = tokens[cursor++];\n const scopeCount = tokens[cursor++];\n const scopes: string[] = new Array(scopeCount);\n for (let s = 0; s < scopeCount; s++) scopes[s] = scopeNames[tokens[cursor++]];\n lineTokens[t] = { startIndex, endIndex, scopes };\n }\n out[li] = lineTokens;\n }\n return out;\n }\n\n /**\n * Tokenize a whole document in a single call, binary (themed) format.\n *\n * Like {@link tokenizeLines} but returns the compact encoded-token representation that\n * a highlighter consumes. All tokens are packed into one flat `Uint32Array`; walk\n * `lineTokenCounts` to recover per-line ranges.\n *\n * @param lines The document lines (already split on newlines)\n * @returns The packed tokens plus per-line token counts\n */\n tokenizeLines2(lines: string[]): TokenizeLinesResult2 {\n const result = this.native.tokenizeLines2(lines);\n // The native arrays are views into WASM heap memory that are reused on the next\n // call; copy them into JS-owned arrays before returning.\n return {\n tokens: new Uint32Array(result.tokens),\n lineTokenCounts: new Uint32Array(result.lineTokenCounts),\n };\n }\n\n /**\n * Tokenize a whole document into a flat, dictionary-encoded scope representation.\n *\n * Equivalent scope information to {@link tokenizeLines} but encoded as a single numeric\n * buffer plus an interned scope-name dictionary, avoiding the per-token object marshalling\n * across the WASM boundary. Prefer this over {@link tokenizeLines} when highlighting static\n * text and you can consume the flat layout directly.\n *\n * @param lines The document lines (already split on newlines)\n * @returns The flat token buffer, per-line token counts, and the scope-name dictionary\n */\n tokenizeLinesScopeFlat(lines: string[]): TokenizeLinesScopeFlatResult {\n const result = this.native.tokenizeLinesScopeFlat(lines);\n // The numeric arrays are views into WASM heap memory reused on the next call; copy them\n // into JS-owned arrays before returning. scopeNames is already a JS array.\n return {\n tokens: new Uint32Array(result.tokens),\n lineTokenCounts: new Uint32Array(result.lineTokenCounts),\n scopeNames: result.scopeNames,\n };\n }\n\n /**\n * Get the scope name of this grammar\n * @returns The scope name (e.g., \"source.js\")\n */\n getScopeName(): string {\n return this.native.getScopeName();\n }\n}\n","import type { WasmModule, NativeRegistry } from './types';\nimport { Grammar } from './Grammar';\n\n/**\n * Registry for managing TextMate grammars and themes\n */\nexport class Registry {\n private module: WasmModule;\n private native: NativeRegistry;\n\n /**\n * Creates a new Registry\n * @param module The WASM module\n * @internal\n */\n constructor(module: WasmModule) {\n this.module = module;\n this.native = new module.Registry();\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n loadGrammar(scopeName: string, content: string): Grammar | null {\n const handle = this.native.loadGrammarFromContent(content, scopeName);\n if (handle === null || handle === 0) {\n return null;\n }\n return new Grammar(this.module, handle);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.native.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.native.getColorMap();\n }\n}\n","import type { WasmModule } from './types';\nimport { Registry } from './Registry';\nimport { Grammar } from './Grammar';\n\n/**\n * Main entry point for TextMate syntax highlighting\n */\nexport class TextMate {\n private module: WasmModule;\n private registry: Registry;\n\n /**\n * Private constructor - use TextMate.create() instead\n * @param module The initialized WASM module\n */\n private constructor(module: WasmModule) {\n this.module = module;\n this.registry = new Registry(module);\n }\n\n /**\n * Create a new TextMate instance\n * @returns A promise that resolves to an initialized TextMate instance\n */\n static async create(): Promise<TextMate> {\n // Dynamic import of the WASM module\n const createModule = await import('../wasm/tml-standard.js');\n const module = await createModule.default() as WasmModule;\n return new TextMate(module);\n }\n\n /**\n * Get the grammar registry\n * @returns The Registry instance\n */\n getRegistry(): Registry {\n return this.registry;\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n async loadGrammar(scopeName: string, content: string): Promise<Grammar | null> {\n return this.registry.loadGrammar(scopeName, content);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.registry.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.registry.getColorMap();\n }\n}\n"],"names":[],"mappings":";;AAWA;;AAEG;MACU,OAAO,CAAA;AAGlB;;;;;AAKG;IACH,WAAA,CAAY,MAAkB,EAAE,MAAc,EAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAC1C;AAEA;;;;;AAKG;AACH,IAAA,YAAY,CAAC,IAAY,EAAE,SAAA,GAAuB,IAAI,EAAA;;;;;;AAMpD,QAAA,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,EA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AAEjB,QAAA,MAAM,YAAY,GAAG,MAAM,OAAO,yBAAyB,CAAC;AAC5D,QAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,EAAgB;AACzD,QAAA,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC;IAC7B;AAEA;;;AAGG;IACH,WAAW,GAAA;QACT,OAAO,IAAI,CAAC,QAAQ;IACtB;AAEA;;;;;AAKG;AACH,IAAA,MAAM,WAAW,CAAC,SAAiB,EAAE,OAAe,EAAA;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC;IACtD;AAEA;;;;AAIG;AACH,IAAA,QAAQ,CAAC,SAAiB,EAAA;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC1C;AAEA;;;AAGG;IACH,WAAW,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;IACpC;AACD;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,24 @@ class Grammar {
|
|
|
18
18
|
* @returns The tokenization result with tokens and rule stack for next line
|
|
19
19
|
*/
|
|
20
20
|
tokenizeLine(line, prevState = null) {
|
|
21
|
-
|
|
21
|
+
// Build the token objects in JS from a flat numeric buffer + per-line scope dictionary
|
|
22
|
+
// rather than marshalling one object (and a scope-string array) per token across the WASM
|
|
23
|
+
// boundary — same output, but native JS object construction is far cheaper than building
|
|
24
|
+
// `val` objects. The flat buffer is a view into WASM heap memory only valid until the next
|
|
25
|
+
// WASM call, so we consume it fully here within this synchronous call.
|
|
26
|
+
const { tokens, scopeNames, ruleStack } = this.native.tokenizeLineScopeFlat(line, prevState);
|
|
27
|
+
const out = [];
|
|
28
|
+
let cursor = 0;
|
|
29
|
+
while (cursor < tokens.length) {
|
|
30
|
+
const startIndex = tokens[cursor++];
|
|
31
|
+
const endIndex = tokens[cursor++];
|
|
32
|
+
const scopeCount = tokens[cursor++];
|
|
33
|
+
const scopes = new Array(scopeCount);
|
|
34
|
+
for (let s = 0; s < scopeCount; s++)
|
|
35
|
+
scopes[s] = scopeNames[tokens[cursor++]];
|
|
36
|
+
out.push({ startIndex, endIndex, scopes });
|
|
37
|
+
}
|
|
38
|
+
return { tokens: out, ruleStack };
|
|
22
39
|
}
|
|
23
40
|
/**
|
|
24
41
|
* Tokenize a single line of text with binary format
|
|
@@ -29,6 +46,83 @@ class Grammar {
|
|
|
29
46
|
tokenizeLine2(line, prevState = null) {
|
|
30
47
|
return this.native.tokenizeLine2(line, prevState);
|
|
31
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Tokenize a whole document in a single call.
|
|
51
|
+
*
|
|
52
|
+
* The rule stack is carried across lines inside WASM, so this performs one JS<->WASM
|
|
53
|
+
* crossing for the entire document instead of one per line. Prefer this over looping
|
|
54
|
+
* {@link tokenizeLine} when highlighting static text; use the per-line API for live
|
|
55
|
+
* editing where individual lines change.
|
|
56
|
+
*
|
|
57
|
+
* @param lines The document lines (already split on newlines)
|
|
58
|
+
* @returns An array with one entry per line, each an array of scope tokens
|
|
59
|
+
*/
|
|
60
|
+
tokenizeLines(lines) {
|
|
61
|
+
// Build the rich token objects in JS from a flat numeric buffer + interned scope
|
|
62
|
+
// dictionary, rather than marshalling one object (and a scope-string array) per token
|
|
63
|
+
// across the WASM boundary. The embind object path costs ~1.5x more for identical output
|
|
64
|
+
// — native JS object construction is far cheaper than constructing `val` objects. The
|
|
65
|
+
// flat buffers are views into WASM heap memory only valid until the next WASM call, so we
|
|
66
|
+
// consume them fully here within this synchronous call.
|
|
67
|
+
const { tokens, lineTokenCounts, scopeNames } = this.native.tokenizeLinesScopeFlat(lines);
|
|
68
|
+
const out = new Array(lineTokenCounts.length);
|
|
69
|
+
let cursor = 0;
|
|
70
|
+
for (let li = 0; li < lineTokenCounts.length; li++) {
|
|
71
|
+
const n = lineTokenCounts[li];
|
|
72
|
+
const lineTokens = new Array(n);
|
|
73
|
+
for (let t = 0; t < n; t++) {
|
|
74
|
+
const startIndex = tokens[cursor++];
|
|
75
|
+
const endIndex = tokens[cursor++];
|
|
76
|
+
const scopeCount = tokens[cursor++];
|
|
77
|
+
const scopes = new Array(scopeCount);
|
|
78
|
+
for (let s = 0; s < scopeCount; s++)
|
|
79
|
+
scopes[s] = scopeNames[tokens[cursor++]];
|
|
80
|
+
lineTokens[t] = { startIndex, endIndex, scopes };
|
|
81
|
+
}
|
|
82
|
+
out[li] = lineTokens;
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Tokenize a whole document in a single call, binary (themed) format.
|
|
88
|
+
*
|
|
89
|
+
* Like {@link tokenizeLines} but returns the compact encoded-token representation that
|
|
90
|
+
* a highlighter consumes. All tokens are packed into one flat `Uint32Array`; walk
|
|
91
|
+
* `lineTokenCounts` to recover per-line ranges.
|
|
92
|
+
*
|
|
93
|
+
* @param lines The document lines (already split on newlines)
|
|
94
|
+
* @returns The packed tokens plus per-line token counts
|
|
95
|
+
*/
|
|
96
|
+
tokenizeLines2(lines) {
|
|
97
|
+
const result = this.native.tokenizeLines2(lines);
|
|
98
|
+
// The native arrays are views into WASM heap memory that are reused on the next
|
|
99
|
+
// call; copy them into JS-owned arrays before returning.
|
|
100
|
+
return {
|
|
101
|
+
tokens: new Uint32Array(result.tokens),
|
|
102
|
+
lineTokenCounts: new Uint32Array(result.lineTokenCounts),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Tokenize a whole document into a flat, dictionary-encoded scope representation.
|
|
107
|
+
*
|
|
108
|
+
* Equivalent scope information to {@link tokenizeLines} but encoded as a single numeric
|
|
109
|
+
* buffer plus an interned scope-name dictionary, avoiding the per-token object marshalling
|
|
110
|
+
* across the WASM boundary. Prefer this over {@link tokenizeLines} when highlighting static
|
|
111
|
+
* text and you can consume the flat layout directly.
|
|
112
|
+
*
|
|
113
|
+
* @param lines The document lines (already split on newlines)
|
|
114
|
+
* @returns The flat token buffer, per-line token counts, and the scope-name dictionary
|
|
115
|
+
*/
|
|
116
|
+
tokenizeLinesScopeFlat(lines) {
|
|
117
|
+
const result = this.native.tokenizeLinesScopeFlat(lines);
|
|
118
|
+
// The numeric arrays are views into WASM heap memory reused on the next call; copy them
|
|
119
|
+
// into JS-owned arrays before returning. scopeNames is already a JS array.
|
|
120
|
+
return {
|
|
121
|
+
tokens: new Uint32Array(result.tokens),
|
|
122
|
+
lineTokenCounts: new Uint32Array(result.lineTokenCounts),
|
|
123
|
+
scopeNames: result.scopeNames,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
32
126
|
/**
|
|
33
127
|
* Get the scope name of this grammar
|
|
34
128
|
* @returns The scope name (e.g., "source.js")
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/Grammar.ts","../src/Registry.ts","../src/TextMate.ts"],"sourcesContent":["import type { WasmModule, NativeGrammar, TokenizeResult, TokenizeResult2, RuleStack } from './types';\n\n/**\n * Represents a TextMate grammar for syntax highlighting\n */\nexport class Grammar {\n private native: NativeGrammar;\n\n /**\n * Creates a Grammar wrapper for a native grammar handle\n * @param module The WASM module\n * @param handle The native grammar handle\n * @internal\n */\n constructor(module: WasmModule, handle: number) {\n this.native = new module.Grammar(handle);\n }\n\n /**\n * Tokenize a single line of text\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with tokens and rule stack for next line\n */\n tokenizeLine(line: string, prevState: RuleStack = null): TokenizeResult {\n return this.native.tokenizeLine(line, prevState);\n }\n\n /**\n * Tokenize a single line of text with binary format\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with binary tokens and rule stack\n */\n tokenizeLine2(line: string, prevState: RuleStack = null): TokenizeResult2 {\n return this.native.tokenizeLine2(line, prevState);\n }\n\n /**\n * Get the scope name of this grammar\n * @returns The scope name (e.g., \"source.js\")\n */\n getScopeName(): string {\n return this.native.getScopeName();\n }\n}\n","import type { WasmModule, NativeRegistry } from './types';\nimport { Grammar } from './Grammar';\n\n/**\n * Registry for managing TextMate grammars and themes\n */\nexport class Registry {\n private module: WasmModule;\n private native: NativeRegistry;\n\n /**\n * Creates a new Registry\n * @param module The WASM module\n * @internal\n */\n constructor(module: WasmModule) {\n this.module = module;\n this.native = new module.Registry();\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n loadGrammar(scopeName: string, content: string): Grammar | null {\n const handle = this.native.loadGrammarFromContent(content, scopeName);\n if (handle === null || handle === 0) {\n return null;\n }\n return new Grammar(this.module, handle);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.native.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.native.getColorMap();\n }\n}\n","import type { WasmModule } from './types';\nimport { Registry } from './Registry';\nimport { Grammar } from './Grammar';\n\n/**\n * Main entry point for TextMate syntax highlighting\n */\nexport class TextMate {\n private module: WasmModule;\n private registry: Registry;\n\n /**\n * Private constructor - use TextMate.create() instead\n * @param module The initialized WASM module\n */\n private constructor(module: WasmModule) {\n this.module = module;\n this.registry = new Registry(module);\n }\n\n /**\n * Create a new TextMate instance\n * @returns A promise that resolves to an initialized TextMate instance\n */\n static async create(): Promise<TextMate> {\n // Dynamic import of the WASM module\n const createModule = await import('../wasm/tml-standard.js');\n const module = await createModule.default() as WasmModule;\n return new TextMate(module);\n }\n\n /**\n * Get the grammar registry\n * @returns The Registry instance\n */\n getRegistry(): Registry {\n return this.registry;\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n async loadGrammar(scopeName: string, content: string): Promise<Grammar | null> {\n return this.registry.loadGrammar(scopeName, content);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.registry.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.registry.getColorMap();\n }\n}\n"],"names":[],"mappings":"AAEA;;AAEG;MACU,OAAO,CAAA;AAGlB;;;;;AAKG;IACH,WAAA,CAAY,MAAkB,EAAE,MAAc,EAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAC1C;AAEA;;;;;AAKG;AACH,IAAA,YAAY,CAAC,IAAY,EAAE,SAAA,GAAuB,IAAI,EAAA;QACpD,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC;IAClD;AAEA;;;;;AAKG;AACH,IAAA,aAAa,CAAC,IAAY,EAAE,SAAA,GAAuB,IAAI,EAAA;QACrD,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC;IACnD;AAEA;;;AAGG;IACH,YAAY,GAAA;AACV,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;IACnC;AACD;;AC1CD;;AAEG;MACU,QAAQ,CAAA;AAInB;;;;AAIG;AACH,IAAA,WAAA,CAAY,MAAkB,EAAA;AAC5B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE;IACrC;AAEA;;;;;AAKG;IACH,WAAW,CAAC,SAAiB,EAAE,OAAe,EAAA;AAC5C,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC;QACrE,IAAI,MAAM,KA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":"index.js","sources":["../src/Grammar.ts","../src/Registry.ts","../src/TextMate.ts"],"sourcesContent":["import type {\n WasmModule,\n NativeGrammar,\n Token,\n TokenizeResult,\n TokenizeResult2,\n TokenizeLinesResult2,\n TokenizeLinesScopeFlatResult,\n RuleStack,\n} from './types';\n\n/**\n * Represents a TextMate grammar for syntax highlighting\n */\nexport class Grammar {\n private native: NativeGrammar;\n\n /**\n * Creates a Grammar wrapper for a native grammar handle\n * @param module The WASM module\n * @param handle The native grammar handle\n * @internal\n */\n constructor(module: WasmModule, handle: number) {\n this.native = new module.Grammar(handle);\n }\n\n /**\n * Tokenize a single line of text\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with tokens and rule stack for next line\n */\n tokenizeLine(line: string, prevState: RuleStack = null): TokenizeResult {\n // Build the token objects in JS from a flat numeric buffer + per-line scope dictionary\n // rather than marshalling one object (and a scope-string array) per token across the WASM\n // boundary — same output, but native JS object construction is far cheaper than building\n // `val` objects. The flat buffer is a view into WASM heap memory only valid until the next\n // WASM call, so we consume it fully here within this synchronous call.\n const { tokens, scopeNames, ruleStack } = this.native.tokenizeLineScopeFlat(line, prevState);\n const out: Token[] = [];\n let cursor = 0;\n while (cursor < tokens.length) {\n const startIndex = tokens[cursor++];\n const endIndex = tokens[cursor++];\n const scopeCount = tokens[cursor++];\n const scopes: string[] = new Array(scopeCount);\n for (let s = 0; s < scopeCount; s++) scopes[s] = scopeNames[tokens[cursor++]];\n out.push({ startIndex, endIndex, scopes });\n }\n return { tokens: out, ruleStack };\n }\n\n /**\n * Tokenize a single line of text with binary format\n * @param line The line text to tokenize\n * @param prevState The rule stack from the previous line (null for first line)\n * @returns The tokenization result with binary tokens and rule stack\n */\n tokenizeLine2(line: string, prevState: RuleStack = null): TokenizeResult2 {\n return this.native.tokenizeLine2(line, prevState);\n }\n\n /**\n * Tokenize a whole document in a single call.\n *\n * The rule stack is carried across lines inside WASM, so this performs one JS<->WASM\n * crossing for the entire document instead of one per line. Prefer this over looping\n * {@link tokenizeLine} when highlighting static text; use the per-line API for live\n * editing where individual lines change.\n *\n * @param lines The document lines (already split on newlines)\n * @returns An array with one entry per line, each an array of scope tokens\n */\n tokenizeLines(lines: string[]): Token[][] {\n // Build the rich token objects in JS from a flat numeric buffer + interned scope\n // dictionary, rather than marshalling one object (and a scope-string array) per token\n // across the WASM boundary. The embind object path costs ~1.5x more for identical output\n // — native JS object construction is far cheaper than constructing `val` objects. The\n // flat buffers are views into WASM heap memory only valid until the next WASM call, so we\n // consume them fully here within this synchronous call.\n const { tokens, lineTokenCounts, scopeNames } = this.native.tokenizeLinesScopeFlat(lines);\n const out: Token[][] = new Array(lineTokenCounts.length);\n let cursor = 0;\n for (let li = 0; li < lineTokenCounts.length; li++) {\n const n = lineTokenCounts[li];\n const lineTokens: Token[] = new Array(n);\n for (let t = 0; t < n; t++) {\n const startIndex = tokens[cursor++];\n const endIndex = tokens[cursor++];\n const scopeCount = tokens[cursor++];\n const scopes: string[] = new Array(scopeCount);\n for (let s = 0; s < scopeCount; s++) scopes[s] = scopeNames[tokens[cursor++]];\n lineTokens[t] = { startIndex, endIndex, scopes };\n }\n out[li] = lineTokens;\n }\n return out;\n }\n\n /**\n * Tokenize a whole document in a single call, binary (themed) format.\n *\n * Like {@link tokenizeLines} but returns the compact encoded-token representation that\n * a highlighter consumes. All tokens are packed into one flat `Uint32Array`; walk\n * `lineTokenCounts` to recover per-line ranges.\n *\n * @param lines The document lines (already split on newlines)\n * @returns The packed tokens plus per-line token counts\n */\n tokenizeLines2(lines: string[]): TokenizeLinesResult2 {\n const result = this.native.tokenizeLines2(lines);\n // The native arrays are views into WASM heap memory that are reused on the next\n // call; copy them into JS-owned arrays before returning.\n return {\n tokens: new Uint32Array(result.tokens),\n lineTokenCounts: new Uint32Array(result.lineTokenCounts),\n };\n }\n\n /**\n * Tokenize a whole document into a flat, dictionary-encoded scope representation.\n *\n * Equivalent scope information to {@link tokenizeLines} but encoded as a single numeric\n * buffer plus an interned scope-name dictionary, avoiding the per-token object marshalling\n * across the WASM boundary. Prefer this over {@link tokenizeLines} when highlighting static\n * text and you can consume the flat layout directly.\n *\n * @param lines The document lines (already split on newlines)\n * @returns The flat token buffer, per-line token counts, and the scope-name dictionary\n */\n tokenizeLinesScopeFlat(lines: string[]): TokenizeLinesScopeFlatResult {\n const result = this.native.tokenizeLinesScopeFlat(lines);\n // The numeric arrays are views into WASM heap memory reused on the next call; copy them\n // into JS-owned arrays before returning. scopeNames is already a JS array.\n return {\n tokens: new Uint32Array(result.tokens),\n lineTokenCounts: new Uint32Array(result.lineTokenCounts),\n scopeNames: result.scopeNames,\n };\n }\n\n /**\n * Get the scope name of this grammar\n * @returns The scope name (e.g., \"source.js\")\n */\n getScopeName(): string {\n return this.native.getScopeName();\n }\n}\n","import type { WasmModule, NativeRegistry } from './types';\nimport { Grammar } from './Grammar';\n\n/**\n * Registry for managing TextMate grammars and themes\n */\nexport class Registry {\n private module: WasmModule;\n private native: NativeRegistry;\n\n /**\n * Creates a new Registry\n * @param module The WASM module\n * @internal\n */\n constructor(module: WasmModule) {\n this.module = module;\n this.native = new module.Registry();\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n loadGrammar(scopeName: string, content: string): Grammar | null {\n const handle = this.native.loadGrammarFromContent(content, scopeName);\n if (handle === null || handle === 0) {\n return null;\n }\n return new Grammar(this.module, handle);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.native.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.native.getColorMap();\n }\n}\n","import type { WasmModule } from './types';\nimport { Registry } from './Registry';\nimport { Grammar } from './Grammar';\n\n/**\n * Main entry point for TextMate syntax highlighting\n */\nexport class TextMate {\n private module: WasmModule;\n private registry: Registry;\n\n /**\n * Private constructor - use TextMate.create() instead\n * @param module The initialized WASM module\n */\n private constructor(module: WasmModule) {\n this.module = module;\n this.registry = new Registry(module);\n }\n\n /**\n * Create a new TextMate instance\n * @returns A promise that resolves to an initialized TextMate instance\n */\n static async create(): Promise<TextMate> {\n // Dynamic import of the WASM module\n const createModule = await import('../wasm/tml-standard.js');\n const module = await createModule.default() as WasmModule;\n return new TextMate(module);\n }\n\n /**\n * Get the grammar registry\n * @returns The Registry instance\n */\n getRegistry(): Registry {\n return this.registry;\n }\n\n /**\n * Load a grammar from JSON content\n * @param scopeName The scope name for the grammar (e.g., \"source.js\")\n * @param content The grammar JSON content\n * @returns The loaded Grammar or null if loading failed\n */\n async loadGrammar(scopeName: string, content: string): Promise<Grammar | null> {\n return this.registry.loadGrammar(scopeName, content);\n }\n\n /**\n * Set the theme from JSON content\n * @param themeJson The theme JSON content\n * @returns true if the theme was set successfully\n */\n setTheme(themeJson: string): boolean {\n return this.registry.setTheme(themeJson);\n }\n\n /**\n * Get the color map from the current theme\n * @returns Array of color strings\n */\n getColorMap(): string[] {\n return this.registry.getColorMap();\n }\n}\n"],"names":[],"mappings":"AAWA;;AAEG;MACU,OAAO,CAAA;AAGlB;;;;;AAKG;IACH,WAAA,CAAY,MAAkB,EAAE,MAAc,EAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAC1C;AAEA;;;;;AAKG;AACH,IAAA,YAAY,CAAC,IAAY,EAAE,SAAA,GAAuB,IAAI,EAAA;;;;;;AAMpD,QAAA,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,EAAE,SAAS,CAAC;QAC5F,MAAM,GAAG,GAAY,EAAE;QACvB,IAAI,MAAM,GAAG,CAAC;AACd,QAAA,OAAO,MAAM,GAAG,MAAM,CAAC,MAAM,EA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QAAA,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC;IAC7B;AAEA;;;AAGG;IACH,WAAW,GAAA;QACT,OAAO,IAAI,CAAC,QAAQ;IACtB;AAEA;;;;;AAKG;AACH,IAAA,MAAM,WAAW,CAAC,SAAiB,EAAE,OAAe,EAAA;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC;IACtD;AAEA;;;;AAIG;AACH,IAAA,QAAQ,CAAC,SAAiB,EAAA;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC1C;AAEA;;;AAGG;IACH,WAAW,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;IACpC;AACD;;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -27,6 +27,35 @@ export interface TokenizeResult2 {
|
|
|
27
27
|
/** Rule stack to pass to the next line's tokenization */
|
|
28
28
|
ruleStack: RuleStack;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of tokenizing a whole document with binary format in a single call.
|
|
32
|
+
*
|
|
33
|
+
* Tokens for every line are packed contiguously into `tokens` as [startIndex, metadata]
|
|
34
|
+
* pairs. `lineTokenCounts[i]` is the number of uint32 entries (2 per token) belonging to
|
|
35
|
+
* line `i`, so the per-line slices can be reconstructed by walking `lineTokenCounts`.
|
|
36
|
+
*/
|
|
37
|
+
export interface TokenizeLinesResult2 {
|
|
38
|
+
/** Flat binary token data for all lines, concatenated in line order */
|
|
39
|
+
tokens: Uint32Array;
|
|
40
|
+
/** Number of uint32 entries in `tokens` produced for each line */
|
|
41
|
+
lineTokenCounts: Uint32Array;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result of the flat scope batch path.
|
|
45
|
+
*
|
|
46
|
+
* `tokens` is a single flat buffer; per token it holds
|
|
47
|
+
* `[startIndex, endIndex, scopeCount, scopeId0, scopeId1, ...]`. `lineTokenCounts[i]` is the
|
|
48
|
+
* number of tokens on line `i`, and `scopeNames[id]` resolves a scope id back to its string.
|
|
49
|
+
* This avoids building a JS object per token across the WASM boundary.
|
|
50
|
+
*/
|
|
51
|
+
export interface TokenizeLinesScopeFlatResult {
|
|
52
|
+
/** Flat token buffer: per token [startIndex, endIndex, scopeCount, ...scopeIds] */
|
|
53
|
+
tokens: Uint32Array;
|
|
54
|
+
/** Number of tokens produced for each line */
|
|
55
|
+
lineTokenCounts: Uint32Array;
|
|
56
|
+
/** Scope-name dictionary; index with the scope ids stored in `tokens` */
|
|
57
|
+
scopeNames: string[];
|
|
58
|
+
}
|
|
30
59
|
/**
|
|
31
60
|
* Opaque rule stack type (pointer)
|
|
32
61
|
*/
|
|
@@ -59,6 +88,21 @@ export interface NativeRegistry {
|
|
|
59
88
|
*/
|
|
60
89
|
export interface NativeGrammar {
|
|
61
90
|
tokenizeLine(line: string, ruleStack: RuleStack): TokenizeResult;
|
|
91
|
+
tokenizeLineScopeFlat(line: string, ruleStack: RuleStack): {
|
|
92
|
+
tokens: Uint32Array;
|
|
93
|
+
scopeNames: string[];
|
|
94
|
+
ruleStack: RuleStack;
|
|
95
|
+
};
|
|
62
96
|
tokenizeLine2(line: string, ruleStack: RuleStack): TokenizeResult2;
|
|
97
|
+
tokenizeLines(lines: string[]): Token[][];
|
|
98
|
+
tokenizeLines2(lines: string[]): {
|
|
99
|
+
tokens: Uint32Array;
|
|
100
|
+
lineTokenCounts: Uint32Array;
|
|
101
|
+
};
|
|
102
|
+
tokenizeLinesScopeFlat(lines: string[]): {
|
|
103
|
+
tokens: Uint32Array;
|
|
104
|
+
lineTokenCounts: Uint32Array;
|
|
105
|
+
scopeNames: string[];
|
|
106
|
+
};
|
|
63
107
|
getScopeName(): string;
|
|
64
108
|
}
|
package/package.json
CHANGED
package/wasm/tml-standard.js
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
var createTextMateModule=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(typeof __filename!="undefined"){_scriptName=__filename}else if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["C"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";if(runtimeInitialized){___trap()}var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("tml-standard.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP64[ptr>>3];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort(`invalid type for getValue: ${type}`)}}var noExitRuntime=true;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort(`invalid type for setValue: ${type}`)}}var __abort_js=()=>abort("");var AsciiToString=ptr=>{var str="";while(1){var ch=HEAPU8[ptr++];if(!ch)return str;str+=String.fromCharCode(ch)}};var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var BindingError=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){return sharedRegisterType(rawType,registeredInstance,options)}var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>HEAP8[pointer]:pointer=>HEAPU8[pointer];case 2:return signed?pointer=>HEAP16[pointer>>1]:pointer=>HEAPU16[pointer>>1];case 4:return signed?pointer=>HEAP32[pointer>>2]:pointer=>HEAPU32[pointer>>2];case 8:return signed?pointer=>HEAP64[pointer>>3]:pointer=>HEAPU64[pointer>>3];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_bigint=(primitiveType,name,size,minRange,maxRange)=>{name=AsciiToString(name);const isUnsignedType=minRange===0n;let fromWireType=value=>value;if(isUnsignedType){const bitSize=size*8;fromWireType=value=>BigInt.asUintN(bitSize,value);maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>{if(typeof value=="number"){value=BigInt(value)}return value},readValueFromPointer:integerReadValueFromPointer(name,size,!isUnsignedType),destructorFunction:null})};var __embind_register_bool=(rawType,name,trueValue,falseValue)=>{name=AsciiToString(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},readValueFromPointer:function(pointer){return this.fromWireType(HEAPU8[pointer])},destructorFunction:null})};var shallowCopyInternalPointer=o=>({count:o.count,deleteScheduled:o.deleteScheduled,preservePointerOnDelete:o.preservePointerOnDelete,ptr:o.ptr,ptrType:o.ptrType,smartPtr:o.smartPtr,smartPtrType:o.smartPtrType});var throwInstanceAlreadyDeleted=obj=>{function getInstanceTypeName(handle){return handle.$$.ptrType.registeredClass.name}throwBindingError(getInstanceTypeName(obj)+" instance already deleted")};var finalizationRegistry=false;var detachFinalizer=handle=>{};var runDestructor=$$=>{if($$.smartPtr){$$.smartPtrType.rawDestructor($$.smartPtr)}else{$$.ptrType.registeredClass.rawDestructor($$.ptr)}};var releaseClassHandle=$$=>{$$.count.value-=1;var toDelete=0===$$.count.value;if(toDelete){runDestructor($$)}};var attachFinalizer=handle=>{if(!globalThis.FinalizationRegistry){attachFinalizer=handle=>handle;return handle}finalizationRegistry=new FinalizationRegistry(info=>{releaseClassHandle(info.$$)});attachFinalizer=handle=>{var $$=handle.$$;var hasSmartPtr=!!$$.smartPtr;if(hasSmartPtr){var info={$$};finalizationRegistry.register(handle,info,handle)}return handle};detachFinalizer=handle=>finalizationRegistry.unregister(handle);return attachFinalizer(handle)};var deletionQueue=[];var flushPendingDeletes=()=>{while(deletionQueue.length){var obj=deletionQueue.pop();obj.$$.deleteScheduled=false;obj["delete"]()}};var delayFunction;var init_ClassHandle=()=>{let proto=ClassHandle.prototype;Object.assign(proto,{isAliasOf(other){if(!(this instanceof ClassHandle)){return false}if(!(other instanceof ClassHandle)){return false}var leftClass=this.$$.ptrType.registeredClass;var left=this.$$.ptr;other.$$=other.$$;var rightClass=other.$$.ptrType.registeredClass;var right=other.$$.ptr;while(leftClass.baseClass){left=leftClass.upcast(left);leftClass=leftClass.baseClass}while(rightClass.baseClass){right=rightClass.upcast(right);rightClass=rightClass.baseClass}return leftClass===rightClass&&left===right},clone(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.preservePointerOnDelete){this.$$.count.value+=1;return this}else{var clone=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));clone.$$.count.value+=1;clone.$$.deleteScheduled=false;return clone}},delete(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}detachFinalizer(this);releaseClassHandle(this.$$);if(!this.$$.preservePointerOnDelete){this.$$.smartPtr=undefined;this.$$.ptr=undefined}},isDeleted(){return!this.$$.ptr},deleteLater(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}deletionQueue.push(this);if(deletionQueue.length===1&&delayFunction){delayFunction(flushPendingDeletes)}this.$$.deleteScheduled=true;return this}});const symbolDispose=Symbol.dispose;if(symbolDispose){proto[symbolDispose]=proto["delete"]}};function ClassHandle(){}var createNamedFunction=(name,func)=>Object.defineProperty(func,"name",{value:name});var registeredPointers={};var ensureOverloadTable=(proto,methodName,humanName)=>{if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(...args){if(!proto[methodName].overloadTable.hasOwnProperty(args.length)){throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`)}return proto[methodName].overloadTable[args.length].apply(this,args)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}};var exposePublicSymbol=(name,value,numArguments)=>{if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError(`Cannot register public name '${name}' twice`)}ensureOverloadTable(Module,name,name);if(Module[name].overloadTable.hasOwnProperty(numArguments)){throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`)}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var char_0=48;var char_9=57;var makeLegalFunctionName=name=>{name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return`_${name}`}return name};function RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast){this.name=name;this.constructor=constructor;this.instancePrototype=instancePrototype;this.rawDestructor=rawDestructor;this.baseClass=baseClass;this.getActualType=getActualType;this.upcast=upcast;this.downcast=downcast;this.pureVirtualFunctions=[]}var upcastPointer=(ptr,ptrClass,desiredClass)=>{while(ptrClass!==desiredClass){if(!ptrClass.upcast){throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`)}ptr=ptrClass.upcast(ptr);ptrClass=ptrClass.baseClass}return ptr};var embindRepr=v=>{if(v===null){return"null"}var t=typeof v;if(t==="object"||t==="array"||t==="function"){return v.toString()}else{return""+v}};function constNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function genericPointerToWireType(destructors,handle){var ptr;if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}if(this.isSmartPointer){ptr=this.rawConstructor();if(destructors!==null){destructors.push(this.rawDestructor,ptr)}return ptr}else{return 0}}if(!handle||!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(!this.isConst&&handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);if(this.isSmartPointer){if(undefined===handle.$$.smartPtr){throwBindingError("Passing raw pointer to smart pointer is illegal")}switch(this.sharingPolicy){case 0:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}break;case 1:ptr=handle.$$.smartPtr;break;case 2:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{var clonedHandle=handle["clone"]();ptr=this.rawShare(ptr,Emval.toHandle(()=>clonedHandle["delete"]()));if(destructors!==null){destructors.push(this.rawDestructor,ptr)}}break;default:throwBindingError("Unsupporting sharing policy")}}return ptr}function nonConstNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function readPointer(pointer){return this.fromWireType(HEAPU32[pointer>>2])}var downcastPointer=(ptr,ptrClass,desiredClass)=>{if(ptrClass===desiredClass){return ptr}if(undefined===desiredClass.baseClass){return null}var rv=downcastPointer(ptr,ptrClass,desiredClass.baseClass);if(rv===null){return null}return desiredClass.downcast(rv)};var registeredInstances={};var getBasestPointer=(class_,ptr)=>{if(ptr===undefined){throwBindingError("ptr should not be undefined")}while(class_.baseClass){ptr=class_.upcast(ptr);class_=class_.baseClass}return ptr};var getInheritedInstance=(class_,ptr)=>{ptr=getBasestPointer(class_,ptr);return registeredInstances[ptr]};var InternalError=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};var throwInternalError=message=>{throw new InternalError(message)};var makeClassHandle=(prototype,record)=>{if(!record.ptrType||!record.ptr){throwInternalError("makeClassHandle requires ptr and ptrType")}var hasSmartPtrType=!!record.smartPtrType;var hasSmartPtr=!!record.smartPtr;if(hasSmartPtrType!==hasSmartPtr){throwInternalError("Both smartPtrType and smartPtr must be specified")}record.count={value:1};return attachFinalizer(Object.create(prototype,{$$:{value:record,writable:true}}))};function RegisteredPointer_fromWireType(ptr){var rawPointer=this.getPointee(ptr);if(!rawPointer){this.destructor(ptr);return null}var registeredInstance=getInheritedInstance(this.registeredClass,rawPointer);if(undefined!==registeredInstance){if(0===registeredInstance.$$.count.value){registeredInstance.$$.ptr=rawPointer;registeredInstance.$$.smartPtr=ptr;return registeredInstance["clone"]()}else{var rv=registeredInstance["clone"]();this.destructor(ptr);return rv}}function makeDefaultHandle(){if(this.isSmartPointer){return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:rawPointer,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr})}}var actualType=this.registeredClass.getActualType(rawPointer);var registeredPointerRecord=registeredPointers[actualType];if(!registeredPointerRecord){return makeDefaultHandle.call(this)}var toType;if(this.isConst){toType=registeredPointerRecord.constPointerType}else{toType=registeredPointerRecord.pointerType}var dp=downcastPointer(rawPointer,this.registeredClass,toType.registeredClass);if(dp===null){return makeDefaultHandle.call(this)}if(this.isSmartPointer){return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp})}}var init_RegisteredPointer=()=>{Object.assign(RegisteredPointer.prototype,{getPointee(ptr){if(this.rawGetPointee){ptr=this.rawGetPointee(ptr)}return ptr},destructor(ptr){this.rawDestructor?.(ptr)},readValueFromPointer:readPointer,fromWireType:RegisteredPointer_fromWireType})};function RegisteredPointer(name,registeredClass,isReference,isConst,isSmartPointer,pointeeType,sharingPolicy,rawGetPointee,rawConstructor,rawShare,rawDestructor){this.name=name;this.registeredClass=registeredClass;this.isReference=isReference;this.isConst=isConst;this.isSmartPointer=isSmartPointer;this.pointeeType=pointeeType;this.sharingPolicy=sharingPolicy;this.rawGetPointee=rawGetPointee;this.rawConstructor=rawConstructor;this.rawShare=rawShare;this.rawDestructor=rawDestructor;if(!isSmartPointer&®isteredClass.baseClass===undefined){if(isConst){this.toWireType=constNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else{this.toWireType=nonConstNoSmartPtrRawPointerToWireType;this.destructorFunction=null}}else{this.toWireType=genericPointerToWireType}}var replacePublicSymbol=(name,value,numArguments)=>{if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistent public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var embind__requireFunction=(signature,rawFunction,isAsync=false)=>{signature=AsciiToString(signature);function makeDynCaller(){var rtn=getWasmTableEntry(rawFunction);return rtn}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`)}return fp};class UnboundTypeError extends Error{}var getTypeName=type=>{var ptr=___getTypeName(type);var rv=AsciiToString(ptr);_free(ptr);return rv};var throwUnboundTypeError=(message,types)=>{var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(`${message}: `+unboundTypes.map(getTypeName).join([", "]))};var whenDependentTypesAreResolved=(myTypes,dependentTypes,getTypeConverters)=>{myTypes.forEach(type=>typeDependencies[type]=dependentTypes);function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i<myTypes.length;++i){registerType(myTypes[i],myTypeConverters[i])}}var typeConverters=new Array(dependentTypes.length);var unregisteredTypes=[];var registered=0;dependentTypes.forEach((dt,i)=>{if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}});if(0===unregisteredTypes.length){onComplete(typeConverters)}};var __embind_register_class=(rawType,rawPointerType,rawConstPointerType,baseClassRawType,getActualTypeSignature,getActualType,upcastSignature,upcast,downcastSignature,downcast,name,destructorSignature,rawDestructor)=>{name=AsciiToString(name);getActualType=embind__requireFunction(getActualTypeSignature,getActualType);upcast&&=embind__requireFunction(upcastSignature,upcast);downcast&&=embind__requireFunction(downcastSignature,downcast);rawDestructor=embind__requireFunction(destructorSignature,rawDestructor);var legalFunctionName=makeLegalFunctionName(name);exposePublicSymbol(legalFunctionName,function(){throwUnboundTypeError(`Cannot construct ${name} due to unbound types`,[baseClassRawType])});whenDependentTypesAreResolved([rawType,rawPointerType,rawConstPointerType],baseClassRawType?[baseClassRawType]:[],base=>{base=base[0];var baseClass;var basePrototype;if(baseClassRawType){baseClass=base.registeredClass;basePrototype=baseClass.instancePrototype}else{basePrototype=ClassHandle.prototype}var constructor=createNamedFunction(name,function(...args){if(Object.getPrototypeOf(this)!==instancePrototype){throw new BindingError(`Use 'new' to construct ${name}`)}if(undefined===registeredClass.constructor_body){throw new BindingError(`${name} has no accessible constructor`)}var body=registeredClass.constructor_body[args.length];if(undefined===body){throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`)}return body.apply(this,args)});var instancePrototype=Object.create(basePrototype,{constructor:{value:constructor}});constructor.prototype=instancePrototype;var registeredClass=new RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast);if(registeredClass.baseClass){registeredClass.baseClass.__derivedClasses??=[];registeredClass.baseClass.__derivedClasses.push(registeredClass)}var referenceConverter=new RegisteredPointer(name,registeredClass,true,false,false);var pointerConverter=new RegisteredPointer(name+"*",registeredClass,false,false,false);var constPointerConverter=new RegisteredPointer(name+" const*",registeredClass,false,true,false);registeredPointers[rawType]={pointerType:pointerConverter,constPointerType:constPointerConverter};replacePublicSymbol(legalFunctionName,constructor);return[referenceConverter,pointerConverter,constPointerConverter]})};var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i<count;i++){array.push(HEAPU32[firstElement+i*4>>2])}return array};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};function usesDestructorStack(argTypes){for(var i=1;i<argTypes.length;++i){if(argTypes[i]!==null&&argTypes[i].destructorFunction===undefined){return true}}return false}function createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync){var needsDestructorStack=usesDestructorStack(argTypes);var argCount=argTypes.length-2;var argsList=[];var argsListWired=["fn"];if(isClassMethodFunc){argsListWired.push("thisWired")}for(var i=0;i<argCount;++i){argsList.push(`arg${i}`);argsListWired.push(`arg${i}Wired`)}argsList=argsList.join(",");argsListWired=argsListWired.join(",");var invokerFnBody=`return function (${argsList}) {\n`;if(needsDestructorStack){invokerFnBody+="var destructors = [];\n"}var dtorStack=needsDestructorStack?"destructors":"null";var args1=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];if(isClassMethodFunc){invokerFnBody+=`var thisWired = toClassParamWire(${dtorStack}, this);\n`}for(var i=0;i<argCount;++i){var argName=`toArg${i}Wire`;invokerFnBody+=`var arg${i}Wired = ${argName}(${dtorStack}, arg${i});\n`;args1.push(argName)}invokerFnBody+=(returns||isAsync?"var rv = ":"")+`invoker(${argsListWired});\n`;if(needsDestructorStack){invokerFnBody+="runDestructors(destructors);\n"}else{for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){var paramName=i===1?"thisWired":"arg"+(i-2)+"Wired";if(argTypes[i].destructorFunction!==null){invokerFnBody+=`${paramName}_dtor(${paramName});\n`;args1.push(`${paramName}_dtor`)}}}if(returns){invokerFnBody+="var ret = fromRetWire(rv);\n"+"return ret;\n"}else{}invokerFnBody+="}\n";return new Function(args1,invokerFnBody)}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc,isAsync){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var needsDestructorStack=usesDestructorStack(argTypes);var returns=!argTypes[0].isVoid;var retType=argTypes[0];var instType=argTypes[1];var closureArgs=[humanName,throwBindingError,cppInvokerFunc,cppTargetFunc,runDestructors,retType.fromWireType.bind(retType),instType?.toWireType.bind(instType)];for(var i=2;i<argCount;++i){var argType=argTypes[i];closureArgs.push(argType.toWireType.bind(argType))}if(!needsDestructorStack){for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){if(argTypes[i].destructorFunction!==null){closureArgs.push(argTypes[i].destructorFunction)}}}let invokerFactory=createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync);var invokerFn=invokerFactory(...closureArgs);return createNamedFunction(humanName,invokerFn)}var __embind_register_class_constructor=(rawClassType,argCount,rawArgTypesAddr,invokerSignature,invoker,rawConstructor)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);invoker=embind__requireFunction(invokerSignature,invoker);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`constructor ${classType.name}`;if(undefined===classType.registeredClass.constructor_body){classType.registeredClass.constructor_body=[]}if(undefined!==classType.registeredClass.constructor_body[argCount-1]){throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${argCount-1}) for class '${classType.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`)}classType.registeredClass.constructor_body[argCount-1]=()=>{throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`,rawArgTypes)};whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{argTypes.splice(1,0,null);classType.registeredClass.constructor_body[argCount-1]=craftInvokerFunction(humanName,argTypes,null,invoker,rawConstructor);return[]});return[]})};var getFunctionName=signature=>{signature=signature.trim();const argsIndex=signature.indexOf("(");if(argsIndex===-1)return signature;return signature.slice(0,argsIndex)};var __embind_register_class_function=(rawClassType,methodName,argCount,rawArgTypesAddr,invokerSignature,rawInvoker,context,isPureVirtual,isAsync,isNonnullReturn)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);methodName=AsciiToString(methodName);methodName=getFunctionName(methodName);rawInvoker=embind__requireFunction(invokerSignature,rawInvoker,isAsync);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`${classType.name}.${methodName}`;if(methodName.startsWith("@@")){methodName=Symbol[methodName.substring(2)]}if(isPureVirtual){classType.registeredClass.pureVirtualFunctions.push(methodName)}function unboundTypesHandler(){throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`,rawArgTypes)}var proto=classType.registeredClass.instancePrototype;var method=proto[methodName];if(undefined===method||undefined===method.overloadTable&&method.className!==classType.name&&method.argCount===argCount-2){unboundTypesHandler.argCount=argCount-2;unboundTypesHandler.className=classType.name;proto[methodName]=unboundTypesHandler}else{ensureOverloadTable(proto,methodName,humanName);proto[methodName].overloadTable[argCount-2]=unboundTypesHandler}whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{var memberFunction=craftInvokerFunction(humanName,argTypes,classType,rawInvoker,context,isAsync);if(undefined===proto[methodName].overloadTable){memberFunction.argCount=argCount-2;proto[methodName]=memberFunction}else{proto[methodName].overloadTable[argCount-2]=memberFunction}return[]});return[]})};var emval_freelist=[];var emval_handles=[0,1,,1,null,1,true,1,false,1];var __emval_decref=handle=>{if(handle>9&&0===--emval_handles[handle+1]){emval_handles[handle]=undefined;emval_freelist.push(handle)}};var Emval={toValue:handle=>{if(!handle){throwBindingError(`Cannot use deleted val. handle = ${handle}`)}return emval_handles[handle]},toHandle:value=>{switch(value){case undefined:return 2;case null:return 4;case true:return 6;case false:return 8;default:{const handle=emval_freelist.pop()||emval_handles.length;emval_handles[handle]=value;emval_handles[handle+1]=1;return handle}}}};var EmValType={name:"emscripten::val",fromWireType:handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},toWireType:(destructors,value)=>Emval.toHandle(value),readValueFromPointer:readPointer,destructorFunction:null};var __embind_register_emval=rawType=>registerType(rawType,EmValType);var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this.fromWireType(HEAPF32[pointer>>2])};case 8:return function(pointer){return this.fromWireType(HEAPF64[pointer>>3])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=(rawType,name,size)=>{name=AsciiToString(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};var __embind_register_integer=(primitiveType,name,size,minRange,maxRange)=>{name=AsciiToString(name);const isUnsignedType=minRange===0;let fromWireType=value=>value;if(isUnsignedType){var bitshift=32-8*size;fromWireType=value=>value<<bitshift>>>bitshift;maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>value,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};var __embind_register_memory_view=(rawType,dataTypeIndex,name)=>{var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=HEAPU32[handle>>2];var data=HEAPU32[handle+4>>2];return new TA(HEAP8.buffer,data,size)}name=AsciiToString(name);registerType(rawType,{name,fromWireType:decodeMemoryView,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):"";var __embind_register_std_string=(rawType,name)=>{name=AsciiToString(name);var stdStringIsUTF8=true;registerType(rawType,{name,fromWireType(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){str=UTF8ToString(payload,length,true)}else{str="";for(var i=0;i<length;++i){str+=String.fromCharCode(HEAPU8[payload+i])}}_free(value);return str},toWireType(destructors,value){if(value instanceof ArrayBuffer){value=new Uint8Array(value)}var length;var valueIsOfTypeString=typeof value=="string";if(!(valueIsOfTypeString||ArrayBuffer.isView(value)&&value.BYTES_PER_ELEMENT==1)){throwBindingError("Cannot pass non-string to std::string")}if(stdStringIsUTF8&&valueIsOfTypeString){length=lengthBytesUTF8(value)}else{length=value.length}var base=_malloc(4+length+1);var ptr=base+4;HEAPU32[base>>2]=length;if(valueIsOfTypeString){if(stdStringIsUTF8){stringToUTF8(value,ptr,length+1)}else{for(var i=0;i<length;++i){var charCode=value.charCodeAt(i);if(charCode>255){_free(base);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}}else{HEAPU8.set(value,ptr)}if(destructors!==null){destructors.push(_free,base)}return base},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var UTF16Decoder=globalThis.TextDecoder?new TextDecoder("utf-16le"):undefined;var UTF16ToString=(ptr,maxBytesToRead,ignoreNul)=>{var idx=ptr>>1;var endIdx=findStringEnd(HEAPU16,idx,maxBytesToRead/2,ignoreNul);if(endIdx-idx>16&&UTF16Decoder)return UTF16Decoder.decode(HEAPU16.subarray(idx,endIdx));var str="";for(var i=idx;i<endIdx;++i){var codeUnit=HEAPU16[i];str+=String.fromCharCode(codeUnit)}return str};var stringToUTF16=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite<str.length*2?maxBytesToWrite/2:str.length;for(var i=0;i<numCharsToWrite;++i){var codeUnit=str.charCodeAt(i);HEAP16[outPtr>>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead,ignoreNul)=>{var str="";var startIdx=ptr>>2;for(var i=0;!(i>=maxBytesToRead/4);i++){var utf32=HEAPU32[startIdx+i];if(!utf32&&!ignoreNul)break;str+=String.fromCodePoint(utf32)}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i<str.length;++i){var codePoint=str.codePointAt(i);if(codePoint>65535){i++}HEAP32[outPtr>>2]=codePoint;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i<str.length;++i){var codePoint=str.codePointAt(i);if(codePoint>65535){i++}len+=4}return len};var __embind_register_std_wstring=(rawType,charSize,name)=>{name=AsciiToString(name);var decodeString,encodeString,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16}else{decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32}registerType(rawType,{name,fromWireType:value=>{var length=HEAPU32[value>>2];var str=decodeString(value+4,length*charSize,true);_free(value);return str},toWireType:(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);HEAPU32[ptr>>2]=length/charSize;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var __embind_register_void=(rawType,name)=>{name=AsciiToString(name);registerType(rawType,{isVoid:true,name,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var emval_methodCallers=[];var emval_addMethodCaller=caller=>{var id=emval_methodCallers.length;emval_methodCallers.push(caller);return id};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`)}return impl};var emval_lookupTypes=(argCount,argTypes)=>{var a=new Array(argCount);for(var i=0;i<argCount;++i){a[i]=requireRegisteredType(HEAPU32[argTypes+i*4>>2],`parameter ${i}`)}return a};var emval_returnValue=(toReturnWire,destructorsRef,handle)=>{var destructors=[];var result=toReturnWire(destructors,handle);if(destructors.length){HEAPU32[destructorsRef>>2]=Emval.toHandle(destructors)}return result};var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return AsciiToString(address)}return symbol};var __emval_create_invoker=(argCount,argTypesPtr,kind)=>{var GenericWireTypeSize=8;var[retType,...argTypes]=emval_lookupTypes(argCount,argTypesPtr);var toReturnWire=retType.toWireType.bind(retType);var argFromPtr=argTypes.map(type=>type.readValueFromPointer.bind(type));argCount--;var captures={toValue:Emval.toValue};var args=argFromPtr.map((argFromPtr,i)=>{var captureName=`argFromPtr${i}`;captures[captureName]=argFromPtr;return`${captureName}(args${i?"+"+i*GenericWireTypeSize:""})`});var functionBody;switch(kind){case 0:functionBody="toValue(handle)";break;case 2:functionBody="new (toValue(handle))";break;case 3:functionBody="";break;case 1:captures["getStringOrSymbol"]=getStringOrSymbol;functionBody="toValue(handle)[getStringOrSymbol(methodName)]";break}functionBody+=`(${args})`;if(!retType.isVoid){captures["toReturnWire"]=toReturnWire;captures["emval_returnValue"]=emval_returnValue;functionBody=`return emval_returnValue(toReturnWire, destructorsRef, ${functionBody})`}functionBody=`return function (handle, methodName, destructorsRef, args) {\n ${functionBody}\n }`;var invokerFunction=new Function(Object.keys(captures),functionBody)(...Object.values(captures));var functionName=`methodCaller<(${argTypes.map(t=>t.name)}) => ${retType.name}>`;return emval_addMethodCaller(createNamedFunction(functionName,invokerFunction))};var __emval_incref=handle=>{if(handle>9){emval_handles[handle+1]+=1}};var __emval_invoke=(caller,handle,methodName,destructorsRef,args)=>emval_methodCallers[caller](handle,methodName,destructorsRef,args);var __emval_new_array=()=>Emval.toHandle([]);var __emval_new_cstring=v=>Emval.toHandle(getStringOrSymbol(v));var __emval_new_object=()=>Emval.toHandle({});var __emval_run_destructors=handle=>{var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)};var __emval_set_property=(handle,key,value)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);value=Emval.toValue(value);handle[key]=value};var __tzset_js=(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);HEAP64[ptime>>3]=BigInt(nsec);return 0}var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.language||"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var stackSave=()=>_emscripten_stack_get_current();var stackRestore=val=>__emscripten_stack_restore(val);var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};init_ClassHandle();init_RegisteredPointer();{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["setValue"]=setValue;Module["getValue"]=getValue;var ___getTypeName,_free,_malloc,___trap,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){___getTypeName=wasmExports["D"];_free=wasmExports["F"];_malloc=wasmExports["G"];___trap=wasmExports["H"];__emscripten_stack_restore=wasmExports["I"];__emscripten_stack_alloc=wasmExports["J"];_emscripten_stack_get_current=wasmExports["K"];memory=wasmMemory=wasmExports["B"];__indirect_function_table=wasmTable=wasmExports["E"]}var wasmImports={q:__abort_js,n:__embind_register_bigint,y:__embind_register_bool,p:__embind_register_class,o:__embind_register_class_constructor,h:__embind_register_class_function,w:__embind_register_emval,m:__embind_register_float,f:__embind_register_integer,a:__embind_register_memory_view,x:__embind_register_std_string,l:__embind_register_std_wstring,z:__embind_register_void,e:__emval_create_invoker,b:__emval_decref,A:__emval_incref,d:__emval_invoke,j:__emval_new_array,i:__emval_new_cstring,k:__emval_new_object,c:__emval_run_destructors,g:__emval_set_property,r:__tzset_js,u:_clock_time_get,v:_emscripten_resize_heap,s:_environ_get,t:_environ_sizes_get};function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
2
|
-
|
|
1
|
+
var createTextMateModule = (() => {
|
|
2
|
+
var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
|
|
3
|
+
return (
|
|
4
|
+
async function(moduleArg = {}) {
|
|
5
|
+
var moduleRtn;
|
|
6
|
+
|
|
7
|
+
var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&process.versions?.node&&process.type!="renderer";if(ENVIRONMENT_IS_NODE){}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(typeof __filename!="undefined"){_scriptName=__filename}else if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var wasmMemory;var ABORT=false;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;var runtimeInitialized=false;var isFileURI=filename=>filename.startsWith("file://");function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["C"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";if(runtimeInitialized){___trap()}var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("tml-standard.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["B"];updateMemoryViews();wasmTable=wasmExports["E"];removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}wasmBinaryFile??=findWasmBinary();try{var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}catch(e){readyPromiseReject(e);return Promise.reject(e)}}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP64[ptr>>3];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort(`invalid type for getValue: ${type}`)}}var noExitRuntime=true;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort(`invalid type for setValue: ${type}`)}}var __abort_js=()=>abort("");var embind_init_charCodes=()=>{var codes=new Array(256);for(var i=0;i<256;++i){codes[i]=String.fromCharCode(i)}embind_charCodes=codes};var embind_charCodes;var readLatin1String=ptr=>{var ret="";var c=ptr;while(HEAPU8[c]){ret+=embind_charCodes[HEAPU8[c++]]}return ret};var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var BindingError=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){return sharedRegisterType(rawType,registeredInstance,options)}var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>HEAP8[pointer]:pointer=>HEAPU8[pointer];case 2:return signed?pointer=>HEAP16[pointer>>1]:pointer=>HEAPU16[pointer>>1];case 4:return signed?pointer=>HEAP32[pointer>>2]:pointer=>HEAPU32[pointer>>2];case 8:return signed?pointer=>HEAP64[pointer>>3]:pointer=>HEAPU64[pointer>>3];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_bigint=(primitiveType,name,size,minRange,maxRange)=>{name=readLatin1String(name);const isUnsignedType=minRange===0n;let fromWireType=value=>value;if(isUnsignedType){const bitSize=size*8;fromWireType=value=>BigInt.asUintN(bitSize,value);maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>{if(typeof value=="number"){value=BigInt(value)}return value},argPackAdvance:GenericWireTypeSize,readValueFromPointer:integerReadValueFromPointer(name,size,!isUnsignedType),destructorFunction:null})};var GenericWireTypeSize=8;var __embind_register_bool=(rawType,name,trueValue,falseValue)=>{name=readLatin1String(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},argPackAdvance:GenericWireTypeSize,readValueFromPointer:function(pointer){return this["fromWireType"](HEAPU8[pointer])},destructorFunction:null})};var shallowCopyInternalPointer=o=>({count:o.count,deleteScheduled:o.deleteScheduled,preservePointerOnDelete:o.preservePointerOnDelete,ptr:o.ptr,ptrType:o.ptrType,smartPtr:o.smartPtr,smartPtrType:o.smartPtrType});var throwInstanceAlreadyDeleted=obj=>{function getInstanceTypeName(handle){return handle.$$.ptrType.registeredClass.name}throwBindingError(getInstanceTypeName(obj)+" instance already deleted")};var finalizationRegistry=false;var detachFinalizer=handle=>{};var runDestructor=$$=>{if($$.smartPtr){$$.smartPtrType.rawDestructor($$.smartPtr)}else{$$.ptrType.registeredClass.rawDestructor($$.ptr)}};var releaseClassHandle=$$=>{$$.count.value-=1;var toDelete=0===$$.count.value;if(toDelete){runDestructor($$)}};var attachFinalizer=handle=>{if("undefined"===typeof FinalizationRegistry){attachFinalizer=handle=>handle;return handle}finalizationRegistry=new FinalizationRegistry(info=>{releaseClassHandle(info.$$)});attachFinalizer=handle=>{var $$=handle.$$;var hasSmartPtr=!!$$.smartPtr;if(hasSmartPtr){var info={$$};finalizationRegistry.register(handle,info,handle)}return handle};detachFinalizer=handle=>finalizationRegistry.unregister(handle);return attachFinalizer(handle)};var deletionQueue=[];var flushPendingDeletes=()=>{while(deletionQueue.length){var obj=deletionQueue.pop();obj.$$.deleteScheduled=false;obj["delete"]()}};var delayFunction;var init_ClassHandle=()=>{let proto=ClassHandle.prototype;Object.assign(proto,{isAliasOf(other){if(!(this instanceof ClassHandle)){return false}if(!(other instanceof ClassHandle)){return false}var leftClass=this.$$.ptrType.registeredClass;var left=this.$$.ptr;other.$$=other.$$;var rightClass=other.$$.ptrType.registeredClass;var right=other.$$.ptr;while(leftClass.baseClass){left=leftClass.upcast(left);leftClass=leftClass.baseClass}while(rightClass.baseClass){right=rightClass.upcast(right);rightClass=rightClass.baseClass}return leftClass===rightClass&&left===right},clone(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.preservePointerOnDelete){this.$$.count.value+=1;return this}else{var clone=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));clone.$$.count.value+=1;clone.$$.deleteScheduled=false;return clone}},delete(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}detachFinalizer(this);releaseClassHandle(this.$$);if(!this.$$.preservePointerOnDelete){this.$$.smartPtr=undefined;this.$$.ptr=undefined}},isDeleted(){return!this.$$.ptr},deleteLater(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}deletionQueue.push(this);if(deletionQueue.length===1&&delayFunction){delayFunction(flushPendingDeletes)}this.$$.deleteScheduled=true;return this}});const symbolDispose=Symbol.dispose;if(symbolDispose){proto[symbolDispose]=proto["delete"]}};function ClassHandle(){}var createNamedFunction=(name,func)=>Object.defineProperty(func,"name",{value:name});var registeredPointers={};var ensureOverloadTable=(proto,methodName,humanName)=>{if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(...args){if(!proto[methodName].overloadTable.hasOwnProperty(args.length)){throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`)}return proto[methodName].overloadTable[args.length].apply(this,args)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}};var exposePublicSymbol=(name,value,numArguments)=>{if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError(`Cannot register public name '${name}' twice`)}ensureOverloadTable(Module,name,name);if(Module[name].overloadTable.hasOwnProperty(numArguments)){throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`)}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var char_0=48;var char_9=57;var makeLegalFunctionName=name=>{name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return`_${name}`}return name};function RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast){this.name=name;this.constructor=constructor;this.instancePrototype=instancePrototype;this.rawDestructor=rawDestructor;this.baseClass=baseClass;this.getActualType=getActualType;this.upcast=upcast;this.downcast=downcast;this.pureVirtualFunctions=[]}var upcastPointer=(ptr,ptrClass,desiredClass)=>{while(ptrClass!==desiredClass){if(!ptrClass.upcast){throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`)}ptr=ptrClass.upcast(ptr);ptrClass=ptrClass.baseClass}return ptr};var embindRepr=v=>{if(v===null){return"null"}var t=typeof v;if(t==="object"||t==="array"||t==="function"){return v.toString()}else{return""+v}};function constNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function genericPointerToWireType(destructors,handle){var ptr;if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}if(this.isSmartPointer){ptr=this.rawConstructor();if(destructors!==null){destructors.push(this.rawDestructor,ptr)}return ptr}else{return 0}}if(!handle||!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(!this.isConst&&handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);if(this.isSmartPointer){if(undefined===handle.$$.smartPtr){throwBindingError("Passing raw pointer to smart pointer is illegal")}switch(this.sharingPolicy){case 0:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}break;case 1:ptr=handle.$$.smartPtr;break;case 2:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{var clonedHandle=handle["clone"]();ptr=this.rawShare(ptr,Emval.toHandle(()=>clonedHandle["delete"]()));if(destructors!==null){destructors.push(this.rawDestructor,ptr)}}break;default:throwBindingError("Unsupporting sharing policy")}}return ptr}function nonConstNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function readPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])}var downcastPointer=(ptr,ptrClass,desiredClass)=>{if(ptrClass===desiredClass){return ptr}if(undefined===desiredClass.baseClass){return null}var rv=downcastPointer(ptr,ptrClass,desiredClass.baseClass);if(rv===null){return null}return desiredClass.downcast(rv)};var registeredInstances={};var getBasestPointer=(class_,ptr)=>{if(ptr===undefined){throwBindingError("ptr should not be undefined")}while(class_.baseClass){ptr=class_.upcast(ptr);class_=class_.baseClass}return ptr};var getInheritedInstance=(class_,ptr)=>{ptr=getBasestPointer(class_,ptr);return registeredInstances[ptr]};var InternalError=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};var throwInternalError=message=>{throw new InternalError(message)};var makeClassHandle=(prototype,record)=>{if(!record.ptrType||!record.ptr){throwInternalError("makeClassHandle requires ptr and ptrType")}var hasSmartPtrType=!!record.smartPtrType;var hasSmartPtr=!!record.smartPtr;if(hasSmartPtrType!==hasSmartPtr){throwInternalError("Both smartPtrType and smartPtr must be specified")}record.count={value:1};return attachFinalizer(Object.create(prototype,{$$:{value:record,writable:true}}))};function RegisteredPointer_fromWireType(ptr){var rawPointer=this.getPointee(ptr);if(!rawPointer){this.destructor(ptr);return null}var registeredInstance=getInheritedInstance(this.registeredClass,rawPointer);if(undefined!==registeredInstance){if(0===registeredInstance.$$.count.value){registeredInstance.$$.ptr=rawPointer;registeredInstance.$$.smartPtr=ptr;return registeredInstance["clone"]()}else{var rv=registeredInstance["clone"]();this.destructor(ptr);return rv}}function makeDefaultHandle(){if(this.isSmartPointer){return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:rawPointer,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr})}}var actualType=this.registeredClass.getActualType(rawPointer);var registeredPointerRecord=registeredPointers[actualType];if(!registeredPointerRecord){return makeDefaultHandle.call(this)}var toType;if(this.isConst){toType=registeredPointerRecord.constPointerType}else{toType=registeredPointerRecord.pointerType}var dp=downcastPointer(rawPointer,this.registeredClass,toType.registeredClass);if(dp===null){return makeDefaultHandle.call(this)}if(this.isSmartPointer){return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp})}}var init_RegisteredPointer=()=>{Object.assign(RegisteredPointer.prototype,{getPointee(ptr){if(this.rawGetPointee){ptr=this.rawGetPointee(ptr)}return ptr},destructor(ptr){this.rawDestructor?.(ptr)},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,fromWireType:RegisteredPointer_fromWireType})};function RegisteredPointer(name,registeredClass,isReference,isConst,isSmartPointer,pointeeType,sharingPolicy,rawGetPointee,rawConstructor,rawShare,rawDestructor){this.name=name;this.registeredClass=registeredClass;this.isReference=isReference;this.isConst=isConst;this.isSmartPointer=isSmartPointer;this.pointeeType=pointeeType;this.sharingPolicy=sharingPolicy;this.rawGetPointee=rawGetPointee;this.rawConstructor=rawConstructor;this.rawShare=rawShare;this.rawDestructor=rawDestructor;if(!isSmartPointer&®isteredClass.baseClass===undefined){if(isConst){this["toWireType"]=constNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else{this["toWireType"]=nonConstNoSmartPtrRawPointerToWireType;this.destructorFunction=null}}else{this["toWireType"]=genericPointerToWireType}}var replacePublicSymbol=(name,value,numArguments)=>{if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistent public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var embind__requireFunction=(signature,rawFunction,isAsync=false)=>{signature=readLatin1String(signature);function makeDynCaller(){var rtn=getWasmTableEntry(rawFunction);return rtn}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`)}return fp};class UnboundTypeError extends Error{}var getTypeName=type=>{var ptr=___getTypeName(type);var rv=readLatin1String(ptr);_free(ptr);return rv};var throwUnboundTypeError=(message,types)=>{var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(`${message}: `+unboundTypes.map(getTypeName).join([", "]))};var whenDependentTypesAreResolved=(myTypes,dependentTypes,getTypeConverters)=>{myTypes.forEach(type=>typeDependencies[type]=dependentTypes);function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i<myTypes.length;++i){registerType(myTypes[i],myTypeConverters[i])}}var typeConverters=new Array(dependentTypes.length);var unregisteredTypes=[];var registered=0;dependentTypes.forEach((dt,i)=>{if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}});if(0===unregisteredTypes.length){onComplete(typeConverters)}};var __embind_register_class=(rawType,rawPointerType,rawConstPointerType,baseClassRawType,getActualTypeSignature,getActualType,upcastSignature,upcast,downcastSignature,downcast,name,destructorSignature,rawDestructor)=>{name=readLatin1String(name);getActualType=embind__requireFunction(getActualTypeSignature,getActualType);upcast&&=embind__requireFunction(upcastSignature,upcast);downcast&&=embind__requireFunction(downcastSignature,downcast);rawDestructor=embind__requireFunction(destructorSignature,rawDestructor);var legalFunctionName=makeLegalFunctionName(name);exposePublicSymbol(legalFunctionName,function(){throwUnboundTypeError(`Cannot construct ${name} due to unbound types`,[baseClassRawType])});whenDependentTypesAreResolved([rawType,rawPointerType,rawConstPointerType],baseClassRawType?[baseClassRawType]:[],base=>{base=base[0];var baseClass;var basePrototype;if(baseClassRawType){baseClass=base.registeredClass;basePrototype=baseClass.instancePrototype}else{basePrototype=ClassHandle.prototype}var constructor=createNamedFunction(name,function(...args){if(Object.getPrototypeOf(this)!==instancePrototype){throw new BindingError(`Use 'new' to construct ${name}`)}if(undefined===registeredClass.constructor_body){throw new BindingError(`${name} has no accessible constructor`)}var body=registeredClass.constructor_body[args.length];if(undefined===body){throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`)}return body.apply(this,args)});var instancePrototype=Object.create(basePrototype,{constructor:{value:constructor}});constructor.prototype=instancePrototype;var registeredClass=new RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast);if(registeredClass.baseClass){registeredClass.baseClass.__derivedClasses??=[];registeredClass.baseClass.__derivedClasses.push(registeredClass)}var referenceConverter=new RegisteredPointer(name,registeredClass,true,false,false);var pointerConverter=new RegisteredPointer(name+"*",registeredClass,false,false,false);var constPointerConverter=new RegisteredPointer(name+" const*",registeredClass,false,true,false);registeredPointers[rawType]={pointerType:pointerConverter,constPointerType:constPointerConverter};replacePublicSymbol(legalFunctionName,constructor);return[referenceConverter,pointerConverter,constPointerConverter]})};var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i<count;i++){array.push(HEAPU32[firstElement+i*4>>2])}return array};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};function usesDestructorStack(argTypes){for(var i=1;i<argTypes.length;++i){if(argTypes[i]!==null&&argTypes[i].destructorFunction===undefined){return true}}return false}function createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync){var needsDestructorStack=usesDestructorStack(argTypes);var argCount=argTypes.length-2;var argsList=[];var argsListWired=["fn"];if(isClassMethodFunc){argsListWired.push("thisWired")}for(var i=0;i<argCount;++i){argsList.push(`arg${i}`);argsListWired.push(`arg${i}Wired`)}argsList=argsList.join(",");argsListWired=argsListWired.join(",");var invokerFnBody=`return function (${argsList}) {\n`;if(needsDestructorStack){invokerFnBody+="var destructors = [];\n"}var dtorStack=needsDestructorStack?"destructors":"null";var args1=["humanName","throwBindingError","invoker","fn","runDestructors","retType","classParam"];if(isClassMethodFunc){invokerFnBody+=`var thisWired = classParam['toWireType'](${dtorStack}, this);\n`}for(var i=0;i<argCount;++i){invokerFnBody+=`var arg${i}Wired = argType${i}['toWireType'](${dtorStack}, arg${i});\n`;args1.push(`argType${i}`)}invokerFnBody+=(returns||isAsync?"var rv = ":"")+`invoker(${argsListWired});\n`;if(needsDestructorStack){invokerFnBody+="runDestructors(destructors);\n"}else{for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){var paramName=i===1?"thisWired":"arg"+(i-2)+"Wired";if(argTypes[i].destructorFunction!==null){invokerFnBody+=`${paramName}_dtor(${paramName});\n`;args1.push(`${paramName}_dtor`)}}}if(returns){invokerFnBody+="var ret = retType['fromWireType'](rv);\n"+"return ret;\n"}else{}invokerFnBody+="}\n";return[args1,invokerFnBody]}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc,isAsync){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var needsDestructorStack=usesDestructorStack(argTypes);var returns=argTypes[0].name!=="void";var closureArgs=[humanName,throwBindingError,cppInvokerFunc,cppTargetFunc,runDestructors,argTypes[0],argTypes[1]];for(var i=0;i<argCount-2;++i){closureArgs.push(argTypes[i+2])}if(!needsDestructorStack){for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){if(argTypes[i].destructorFunction!==null){closureArgs.push(argTypes[i].destructorFunction)}}}let[args,invokerFnBody]=createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync);var invokerFn=new Function(...args,invokerFnBody)(...closureArgs);return createNamedFunction(humanName,invokerFn)}var __embind_register_class_constructor=(rawClassType,argCount,rawArgTypesAddr,invokerSignature,invoker,rawConstructor)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);invoker=embind__requireFunction(invokerSignature,invoker);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`constructor ${classType.name}`;if(undefined===classType.registeredClass.constructor_body){classType.registeredClass.constructor_body=[]}if(undefined!==classType.registeredClass.constructor_body[argCount-1]){throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${argCount-1}) for class '${classType.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`)}classType.registeredClass.constructor_body[argCount-1]=()=>{throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`,rawArgTypes)};whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{argTypes.splice(1,0,null);classType.registeredClass.constructor_body[argCount-1]=craftInvokerFunction(humanName,argTypes,null,invoker,rawConstructor);return[]});return[]})};var getFunctionName=signature=>{signature=signature.trim();const argsIndex=signature.indexOf("(");if(argsIndex===-1)return signature;return signature.slice(0,argsIndex)};var __embind_register_class_function=(rawClassType,methodName,argCount,rawArgTypesAddr,invokerSignature,rawInvoker,context,isPureVirtual,isAsync,isNonnullReturn)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);methodName=readLatin1String(methodName);methodName=getFunctionName(methodName);rawInvoker=embind__requireFunction(invokerSignature,rawInvoker,isAsync);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`${classType.name}.${methodName}`;if(methodName.startsWith("@@")){methodName=Symbol[methodName.substring(2)]}if(isPureVirtual){classType.registeredClass.pureVirtualFunctions.push(methodName)}function unboundTypesHandler(){throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`,rawArgTypes)}var proto=classType.registeredClass.instancePrototype;var method=proto[methodName];if(undefined===method||undefined===method.overloadTable&&method.className!==classType.name&&method.argCount===argCount-2){unboundTypesHandler.argCount=argCount-2;unboundTypesHandler.className=classType.name;proto[methodName]=unboundTypesHandler}else{ensureOverloadTable(proto,methodName,humanName);proto[methodName].overloadTable[argCount-2]=unboundTypesHandler}whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{var memberFunction=craftInvokerFunction(humanName,argTypes,classType,rawInvoker,context,isAsync);if(undefined===proto[methodName].overloadTable){memberFunction.argCount=argCount-2;proto[methodName]=memberFunction}else{proto[methodName].overloadTable[argCount-2]=memberFunction}return[]});return[]})};var emval_freelist=[];var emval_handles=[0,1,,1,null,1,true,1,false,1];var __emval_decref=handle=>{if(handle>9&&0===--emval_handles[handle+1]){emval_handles[handle]=undefined;emval_freelist.push(handle)}};var Emval={toValue:handle=>{if(!handle){throwBindingError(`Cannot use deleted val. handle = ${handle}`)}return emval_handles[handle]},toHandle:value=>{switch(value){case undefined:return 2;case null:return 4;case true:return 6;case false:return 8;default:{const handle=emval_freelist.pop()||emval_handles.length;emval_handles[handle]=value;emval_handles[handle+1]=1;return handle}}}};var EmValType={name:"emscripten::val",fromWireType:handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},toWireType:(destructors,value)=>Emval.toHandle(value),argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction:null};var __embind_register_emval=rawType=>registerType(rawType,EmValType);var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 8:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=(rawType,name,size)=>{name=readLatin1String(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};var __embind_register_integer=(primitiveType,name,size,minRange,maxRange)=>{name=readLatin1String(name);const isUnsignedType=minRange===0;let fromWireType=value=>value;if(isUnsignedType){var bitshift=32-8*size;fromWireType=value=>value<<bitshift>>>bitshift;maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};var __embind_register_memory_view=(rawType,dataTypeIndex,name)=>{var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=HEAPU32[handle>>2];var data=HEAPU32[handle+4>>2];return new TA(HEAP8.buffer,data,size)}name=readLatin1String(name);registerType(rawType,{name,fromWireType:decodeMemoryView,argPackAdvance:GenericWireTypeSize,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var __embind_register_std_string=(rawType,name)=>{name=readLatin1String(name);var stdStringIsUTF8=true;registerType(rawType,{name,fromWireType(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){var decodeStartPtr=payload;for(var i=0;i<=length;++i){var currentBytePtr=payload+i;if(i==length||HEAPU8[currentBytePtr]==0){var maxRead=currentBytePtr-decodeStartPtr;var stringSegment=UTF8ToString(decodeStartPtr,maxRead);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+1}}}else{var a=new Array(length);for(var i=0;i<length;++i){a[i]=String.fromCharCode(HEAPU8[payload+i])}str=a.join("")}_free(value);return str},toWireType(destructors,value){if(value instanceof ArrayBuffer){value=new Uint8Array(value)}var length;var valueIsOfTypeString=typeof value=="string";if(!(valueIsOfTypeString||ArrayBuffer.isView(value)&&value.BYTES_PER_ELEMENT==1)){throwBindingError("Cannot pass non-string to std::string")}if(stdStringIsUTF8&&valueIsOfTypeString){length=lengthBytesUTF8(value)}else{length=value.length}var base=_malloc(4+length+1);var ptr=base+4;HEAPU32[base>>2]=length;if(valueIsOfTypeString){if(stdStringIsUTF8){stringToUTF8(value,ptr,length+1)}else{for(var i=0;i<length;++i){var charCode=value.charCodeAt(i);if(charCode>255){_free(base);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}}else{HEAPU8.set(value,ptr)}if(destructors!==null){destructors.push(_free,base)}return base},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var UTF16Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):undefined;var UTF16ToString=(ptr,maxBytesToRead)=>{var idx=ptr>>1;var maxIdx=idx+maxBytesToRead/2;var endIdx=idx;while(!(endIdx>=maxIdx)&&HEAPU16[endIdx])++endIdx;if(endIdx-idx>16&&UTF16Decoder)return UTF16Decoder.decode(HEAPU16.subarray(idx,endIdx));var str="";for(var i=idx;!(i>=maxIdx);++i){var codeUnit=HEAPU16[i];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str};var stringToUTF16=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite<str.length*2?maxBytesToWrite/2:str.length;for(var i=0;i<numCharsToWrite;++i){var codeUnit=str.charCodeAt(i);HEAP16[outPtr>>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead)=>{var i=0;var str="";while(!(i>=maxBytesToRead/4)){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)break;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i<str.length;++i){var codeUnit=str.charCodeAt(i);if(codeUnit>=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i<str.length;++i){var codeUnit=str.charCodeAt(i);if(codeUnit>=55296&&codeUnit<=57343)++i;len+=4}return len};var __embind_register_std_wstring=(rawType,charSize,name)=>{name=readLatin1String(name);var decodeString,encodeString,readCharAt,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16;readCharAt=pointer=>HEAPU16[pointer>>1]}else if(charSize===4){decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32;readCharAt=pointer=>HEAPU32[pointer>>2]}registerType(rawType,{name,fromWireType:value=>{var length=HEAPU32[value>>2];var str;var decodeStartPtr=value+4;for(var i=0;i<=length;++i){var currentBytePtr=value+4+i*charSize;if(i==length||readCharAt(currentBytePtr)==0){var maxReadBytes=currentBytePtr-decodeStartPtr;var stringSegment=decodeString(decodeStartPtr,maxReadBytes);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+charSize}}_free(value);return str},toWireType:(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);HEAPU32[ptr>>2]=length/charSize;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var __embind_register_void=(rawType,name)=>{name=readLatin1String(name);registerType(rawType,{isVoid:true,name,argPackAdvance:0,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`)}return impl};var emval_returnValue=(returnType,destructorsRef,handle)=>{var destructors=[];var result=returnType["toWireType"](destructors,handle);if(destructors.length){HEAPU32[destructorsRef>>2]=Emval.toHandle(destructors)}return result};var __emval_as=(handle,returnType,destructorsRef)=>{handle=Emval.toValue(handle);returnType=requireRegisteredType(returnType,"emval::as");return emval_returnValue(returnType,destructorsRef,handle)};var __emval_get_property=(handle,key)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);return Emval.toHandle(handle[key])};var __emval_new_array=()=>Emval.toHandle([]);var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return readLatin1String(address)}return symbol};var __emval_new_cstring=v=>Emval.toHandle(getStringOrSymbol(v));var __emval_new_object=()=>Emval.toHandle({});var __emval_run_destructors=handle=>{var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)};var __emval_set_property=(handle,key,value)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);value=Emval.toValue(value);handle[key]=value};var __emval_take_value=(type,arg)=>{type=requireRegisteredType(type,"_emval_take_value");var v=type["readValueFromPointer"](arg);return Emval.toHandle(v)};var __tzset_js=(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);HEAP64[ptime>>3]=BigInt(nsec);return 0}var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var stackSave=()=>_emscripten_stack_get_current();var stackRestore=val=>__emscripten_stack_restore(val);var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};embind_init_charCodes();init_ClassHandle();init_RegisteredPointer();{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"]}Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["setValue"]=setValue;Module["getValue"]=getValue;var wasmImports={r:__abort_js,n:__embind_register_bigint,z:__embind_register_bool,q:__embind_register_class,p:__embind_register_class_constructor,g:__embind_register_class_function,x:__embind_register_emval,m:__embind_register_float,h:__embind_register_integer,d:__embind_register_memory_view,y:__embind_register_std_string,l:__embind_register_std_wstring,A:__embind_register_void,k:__emval_as,a:__emval_decref,o:__emval_get_property,f:__emval_new_array,e:__emval_new_cstring,i:__emval_new_object,j:__emval_run_destructors,b:__emval_set_property,c:__emval_take_value,s:__tzset_js,v:_clock_time_get,w:_emscripten_resize_heap,t:_environ_get,u:_environ_sizes_get};var wasmExports=await createWasm();var ___wasm_call_ctors=wasmExports["C"];var ___getTypeName=wasmExports["D"];var _free=wasmExports["F"];var _malloc=wasmExports["G"];var ___trap=wasmExports["H"];var __emscripten_stack_restore=wasmExports["I"];var __emscripten_stack_alloc=wasmExports["J"];var _emscripten_stack_get_current=wasmExports["K"];function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}function preInit(){if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}preInit();run();moduleRtn=readyPromise;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
return moduleRtn;
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
})();
|
|
14
|
+
if (typeof exports === 'object' && typeof module === 'object') {
|
|
15
|
+
module.exports = createTextMateModule;
|
|
16
|
+
// This default export looks redundant, but it allows TS to import this
|
|
17
|
+
// commonjs style module.
|
|
18
|
+
module.exports.default = createTextMateModule;
|
|
19
|
+
} else if (typeof define === 'function' && define['amd'])
|
|
20
|
+
define([], () => createTextMateModule);
|
package/wasm/tml-standard.wasm
CHANGED
|
Binary file
|