textmatelib 0.1.0

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.
@@ -0,0 +1,33 @@
1
+ import type { WasmModule, TokenizeResult, TokenizeResult2, RuleStack } from './types';
2
+ /**
3
+ * Represents a TextMate grammar for syntax highlighting
4
+ */
5
+ export declare class Grammar {
6
+ private native;
7
+ /**
8
+ * Creates a Grammar wrapper for a native grammar handle
9
+ * @param module The WASM module
10
+ * @param handle The native grammar handle
11
+ * @internal
12
+ */
13
+ constructor(module: WasmModule, handle: number);
14
+ /**
15
+ * Tokenize a single line of text
16
+ * @param line The line text to tokenize
17
+ * @param prevState The rule stack from the previous line (null for first line)
18
+ * @returns The tokenization result with tokens and rule stack for next line
19
+ */
20
+ tokenizeLine(line: string, prevState?: RuleStack): TokenizeResult;
21
+ /**
22
+ * Tokenize a single line of text with binary format
23
+ * @param line The line text to tokenize
24
+ * @param prevState The rule stack from the previous line (null for first line)
25
+ * @returns The tokenization result with binary tokens and rule stack
26
+ */
27
+ tokenizeLine2(line: string, prevState?: RuleStack): TokenizeResult2;
28
+ /**
29
+ * Get the scope name of this grammar
30
+ * @returns The scope name (e.g., "source.js")
31
+ */
32
+ getScopeName(): string;
33
+ }
@@ -0,0 +1,33 @@
1
+ import type { WasmModule } from './types';
2
+ import { Grammar } from './Grammar';
3
+ /**
4
+ * Registry for managing TextMate grammars and themes
5
+ */
6
+ export declare class Registry {
7
+ private module;
8
+ private native;
9
+ /**
10
+ * Creates a new Registry
11
+ * @param module The WASM module
12
+ * @internal
13
+ */
14
+ constructor(module: WasmModule);
15
+ /**
16
+ * Load a grammar from JSON content
17
+ * @param scopeName The scope name for the grammar (e.g., "source.js")
18
+ * @param content The grammar JSON content
19
+ * @returns The loaded Grammar or null if loading failed
20
+ */
21
+ loadGrammar(scopeName: string, content: string): Grammar | null;
22
+ /**
23
+ * Set the theme from JSON content
24
+ * @param themeJson The theme JSON content
25
+ * @returns true if the theme was set successfully
26
+ */
27
+ setTheme(themeJson: string): boolean;
28
+ /**
29
+ * Get the color map from the current theme
30
+ * @returns Array of color strings
31
+ */
32
+ getColorMap(): string[];
33
+ }
@@ -0,0 +1,42 @@
1
+ import { Registry } from './Registry';
2
+ import { Grammar } from './Grammar';
3
+ /**
4
+ * Main entry point for TextMate syntax highlighting
5
+ */
6
+ export declare class TextMate {
7
+ private module;
8
+ private registry;
9
+ /**
10
+ * Private constructor - use TextMate.create() instead
11
+ * @param module The initialized WASM module
12
+ */
13
+ private constructor();
14
+ /**
15
+ * Create a new TextMate instance
16
+ * @returns A promise that resolves to an initialized TextMate instance
17
+ */
18
+ static create(): Promise<TextMate>;
19
+ /**
20
+ * Get the grammar registry
21
+ * @returns The Registry instance
22
+ */
23
+ getRegistry(): Registry;
24
+ /**
25
+ * Load a grammar from JSON content
26
+ * @param scopeName The scope name for the grammar (e.g., "source.js")
27
+ * @param content The grammar JSON content
28
+ * @returns The loaded Grammar or null if loading failed
29
+ */
30
+ loadGrammar(scopeName: string, content: string): Promise<Grammar | null>;
31
+ /**
32
+ * Set the theme from JSON content
33
+ * @param themeJson The theme JSON content
34
+ * @returns true if the theme was set successfully
35
+ */
36
+ setTheme(themeJson: string): boolean;
37
+ /**
38
+ * Get the color map from the current theme
39
+ * @returns Array of color strings
40
+ */
41
+ getColorMap(): string[];
42
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,144 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Represents a TextMate grammar for syntax highlighting
5
+ */
6
+ class Grammar {
7
+ /**
8
+ * Creates a Grammar wrapper for a native grammar handle
9
+ * @param module The WASM module
10
+ * @param handle The native grammar handle
11
+ * @internal
12
+ */
13
+ constructor(module, handle) {
14
+ this.native = new module.Grammar(handle);
15
+ }
16
+ /**
17
+ * Tokenize a single line of text
18
+ * @param line The line text to tokenize
19
+ * @param prevState The rule stack from the previous line (null for first line)
20
+ * @returns The tokenization result with tokens and rule stack for next line
21
+ */
22
+ tokenizeLine(line, prevState = null) {
23
+ return this.native.tokenizeLine(line, prevState);
24
+ }
25
+ /**
26
+ * Tokenize a single line of text with binary format
27
+ * @param line The line text to tokenize
28
+ * @param prevState The rule stack from the previous line (null for first line)
29
+ * @returns The tokenization result with binary tokens and rule stack
30
+ */
31
+ tokenizeLine2(line, prevState = null) {
32
+ return this.native.tokenizeLine2(line, prevState);
33
+ }
34
+ /**
35
+ * Get the scope name of this grammar
36
+ * @returns The scope name (e.g., "source.js")
37
+ */
38
+ getScopeName() {
39
+ return this.native.getScopeName();
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Registry for managing TextMate grammars and themes
45
+ */
46
+ class Registry {
47
+ /**
48
+ * Creates a new Registry
49
+ * @param module The WASM module
50
+ * @internal
51
+ */
52
+ constructor(module) {
53
+ this.module = module;
54
+ this.native = new module.Registry();
55
+ }
56
+ /**
57
+ * Load a grammar from JSON content
58
+ * @param scopeName The scope name for the grammar (e.g., "source.js")
59
+ * @param content The grammar JSON content
60
+ * @returns The loaded Grammar or null if loading failed
61
+ */
62
+ loadGrammar(scopeName, content) {
63
+ const handle = this.native.loadGrammarFromContent(content, scopeName);
64
+ if (handle === null || handle === 0) {
65
+ return null;
66
+ }
67
+ return new Grammar(this.module, handle);
68
+ }
69
+ /**
70
+ * Set the theme from JSON content
71
+ * @param themeJson The theme JSON content
72
+ * @returns true if the theme was set successfully
73
+ */
74
+ setTheme(themeJson) {
75
+ return this.native.setTheme(themeJson);
76
+ }
77
+ /**
78
+ * Get the color map from the current theme
79
+ * @returns Array of color strings
80
+ */
81
+ getColorMap() {
82
+ return this.native.getColorMap();
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Main entry point for TextMate syntax highlighting
88
+ */
89
+ class TextMate {
90
+ /**
91
+ * Private constructor - use TextMate.create() instead
92
+ * @param module The initialized WASM module
93
+ */
94
+ constructor(module) {
95
+ this.module = module;
96
+ this.registry = new Registry(module);
97
+ }
98
+ /**
99
+ * Create a new TextMate instance
100
+ * @returns A promise that resolves to an initialized TextMate instance
101
+ */
102
+ static async create() {
103
+ // Dynamic import of the WASM module
104
+ const createModule = await import('../wasm/tml-standard.js');
105
+ const module = await createModule.default();
106
+ return new TextMate(module);
107
+ }
108
+ /**
109
+ * Get the grammar registry
110
+ * @returns The Registry instance
111
+ */
112
+ getRegistry() {
113
+ return this.registry;
114
+ }
115
+ /**
116
+ * Load a grammar from JSON content
117
+ * @param scopeName The scope name for the grammar (e.g., "source.js")
118
+ * @param content The grammar JSON content
119
+ * @returns The loaded Grammar or null if loading failed
120
+ */
121
+ async loadGrammar(scopeName, content) {
122
+ return this.registry.loadGrammar(scopeName, content);
123
+ }
124
+ /**
125
+ * Set the theme from JSON content
126
+ * @param themeJson The theme JSON content
127
+ * @returns true if the theme was set successfully
128
+ */
129
+ setTheme(themeJson) {
130
+ return this.registry.setTheme(themeJson);
131
+ }
132
+ /**
133
+ * Get the color map from the current theme
134
+ * @returns Array of color strings
135
+ */
136
+ getColorMap() {
137
+ return this.registry.getColorMap();
138
+ }
139
+ }
140
+
141
+ exports.Grammar = Grammar;
142
+ exports.Registry = Registry;
143
+ exports.TextMate = TextMate;
144
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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,EAAA;AAC5C,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC;QACrE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,CAAC,EAAE;AACnC,YAAA,OAAO,IAAI;QACb;QACA,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IACzC;AAEA;;;;AAIG;AACH,IAAA,QAAQ,CAAC,SAAiB,EAAA;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;IACxC;AAEA;;;AAGG;IACH,WAAW,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;IAClC;AACD;;AC9CD;;AAEG;MACU,QAAQ,CAAA;AAInB;;;AAGG;AACH,IAAA,WAAA,CAAoB,MAAkB,EAAA;AACpC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC;IACtC;AAEA;;;AAGG;IACH,aAAa,MAAM,GAAA;;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;;;;;;"}
@@ -0,0 +1,4 @@
1
+ export { TextMate } from './TextMate';
2
+ export { Registry } from './Registry';
3
+ export { Grammar } from './Grammar';
4
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Represents a TextMate grammar for syntax highlighting
3
+ */
4
+ class Grammar {
5
+ /**
6
+ * Creates a Grammar wrapper for a native grammar handle
7
+ * @param module The WASM module
8
+ * @param handle The native grammar handle
9
+ * @internal
10
+ */
11
+ constructor(module, handle) {
12
+ this.native = new module.Grammar(handle);
13
+ }
14
+ /**
15
+ * Tokenize a single line of text
16
+ * @param line The line text to tokenize
17
+ * @param prevState The rule stack from the previous line (null for first line)
18
+ * @returns The tokenization result with tokens and rule stack for next line
19
+ */
20
+ tokenizeLine(line, prevState = null) {
21
+ return this.native.tokenizeLine(line, prevState);
22
+ }
23
+ /**
24
+ * Tokenize a single line of text with binary format
25
+ * @param line The line text to tokenize
26
+ * @param prevState The rule stack from the previous line (null for first line)
27
+ * @returns The tokenization result with binary tokens and rule stack
28
+ */
29
+ tokenizeLine2(line, prevState = null) {
30
+ return this.native.tokenizeLine2(line, prevState);
31
+ }
32
+ /**
33
+ * Get the scope name of this grammar
34
+ * @returns The scope name (e.g., "source.js")
35
+ */
36
+ getScopeName() {
37
+ return this.native.getScopeName();
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Registry for managing TextMate grammars and themes
43
+ */
44
+ class Registry {
45
+ /**
46
+ * Creates a new Registry
47
+ * @param module The WASM module
48
+ * @internal
49
+ */
50
+ constructor(module) {
51
+ this.module = module;
52
+ this.native = new module.Registry();
53
+ }
54
+ /**
55
+ * Load a grammar from JSON content
56
+ * @param scopeName The scope name for the grammar (e.g., "source.js")
57
+ * @param content The grammar JSON content
58
+ * @returns The loaded Grammar or null if loading failed
59
+ */
60
+ loadGrammar(scopeName, content) {
61
+ const handle = this.native.loadGrammarFromContent(content, scopeName);
62
+ if (handle === null || handle === 0) {
63
+ return null;
64
+ }
65
+ return new Grammar(this.module, handle);
66
+ }
67
+ /**
68
+ * Set the theme from JSON content
69
+ * @param themeJson The theme JSON content
70
+ * @returns true if the theme was set successfully
71
+ */
72
+ setTheme(themeJson) {
73
+ return this.native.setTheme(themeJson);
74
+ }
75
+ /**
76
+ * Get the color map from the current theme
77
+ * @returns Array of color strings
78
+ */
79
+ getColorMap() {
80
+ return this.native.getColorMap();
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Main entry point for TextMate syntax highlighting
86
+ */
87
+ class TextMate {
88
+ /**
89
+ * Private constructor - use TextMate.create() instead
90
+ * @param module The initialized WASM module
91
+ */
92
+ constructor(module) {
93
+ this.module = module;
94
+ this.registry = new Registry(module);
95
+ }
96
+ /**
97
+ * Create a new TextMate instance
98
+ * @returns A promise that resolves to an initialized TextMate instance
99
+ */
100
+ static async create() {
101
+ // Dynamic import of the WASM module
102
+ const createModule = await import('../wasm/tml-standard.js');
103
+ const module = await createModule.default();
104
+ return new TextMate(module);
105
+ }
106
+ /**
107
+ * Get the grammar registry
108
+ * @returns The Registry instance
109
+ */
110
+ getRegistry() {
111
+ return this.registry;
112
+ }
113
+ /**
114
+ * Load a grammar from JSON content
115
+ * @param scopeName The scope name for the grammar (e.g., "source.js")
116
+ * @param content The grammar JSON content
117
+ * @returns The loaded Grammar or null if loading failed
118
+ */
119
+ async loadGrammar(scopeName, content) {
120
+ return this.registry.loadGrammar(scopeName, content);
121
+ }
122
+ /**
123
+ * Set the theme from JSON content
124
+ * @param themeJson The theme JSON content
125
+ * @returns true if the theme was set successfully
126
+ */
127
+ setTheme(themeJson) {
128
+ return this.registry.setTheme(themeJson);
129
+ }
130
+ /**
131
+ * Get the color map from the current theme
132
+ * @returns Array of color strings
133
+ */
134
+ getColorMap() {
135
+ return this.registry.getColorMap();
136
+ }
137
+ }
138
+
139
+ export { Grammar, Registry, TextMate };
140
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,KAAK,IAAI,IAAI,MAAM,KAAK,CAAC,EAAE;AACnC,YAAA,OAAO,IAAI;QACb;QACA,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IACzC;AAEA;;;;AAIG;AACH,IAAA,QAAQ,CAAC,SAAiB,EAAA;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;IACxC;AAEA;;;AAGG;IACH,WAAW,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;IAClC;AACD;;AC9CD;;AAEG;MACU,QAAQ,CAAA;AAInB;;;AAGG;AACH,IAAA,WAAA,CAAoB,MAAkB,EAAA;AACpC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC;IACtC;AAEA;;;AAGG;IACH,aAAa,MAAM,GAAA;;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;;;;"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Represents a single token from tokenization
3
+ */
4
+ export interface Token {
5
+ /** Start index (inclusive) in the line */
6
+ startIndex: number;
7
+ /** End index (exclusive) in the line */
8
+ endIndex: number;
9
+ /** Scope names for this token */
10
+ scopes: string[];
11
+ }
12
+ /**
13
+ * Result of tokenizing a single line
14
+ */
15
+ export interface TokenizeResult {
16
+ /** Array of tokens for this line */
17
+ tokens: Token[];
18
+ /** Rule stack to pass to the next line's tokenization */
19
+ ruleStack: RuleStack;
20
+ }
21
+ /**
22
+ * Result of tokenizing a single line with binary format
23
+ */
24
+ export interface TokenizeResult2 {
25
+ /** Binary token data (Uint32Array-like) */
26
+ tokens: number[];
27
+ /** Rule stack to pass to the next line's tokenization */
28
+ ruleStack: RuleStack;
29
+ }
30
+ /**
31
+ * Opaque rule stack type (pointer)
32
+ */
33
+ export type RuleStack = number | null;
34
+ /**
35
+ * Theme settings for a scope
36
+ */
37
+ export interface ThemeSettings {
38
+ foreground?: string;
39
+ background?: string;
40
+ fontStyle?: string;
41
+ }
42
+ /**
43
+ * Internal WASM module interface
44
+ */
45
+ export interface WasmModule {
46
+ Registry: new () => NativeRegistry;
47
+ Grammar: new (handle: number) => NativeGrammar;
48
+ }
49
+ /**
50
+ * Native Registry interface from WASM bindings
51
+ */
52
+ export interface NativeRegistry {
53
+ loadGrammarFromContent(content: string, scopeName: string): number | null;
54
+ setTheme(themeContent: string): boolean;
55
+ getColorMap(): string[];
56
+ }
57
+ /**
58
+ * Native Grammar interface from WASM bindings
59
+ */
60
+ export interface NativeGrammar {
61
+ tokenizeLine(line: string, ruleStack: RuleStack): TokenizeResult;
62
+ tokenizeLine2(line: string, ruleStack: RuleStack): TokenizeResult2;
63
+ getScopeName(): string;
64
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "textmatelib",
3
+ "version": "0.1.0",
4
+ "description": "TextMate syntax highlighting library for JavaScript/WASM",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist/",
18
+ "wasm/"
19
+ ],
20
+ "scripts": {
21
+ "build": "rollup -c && tsc --emitDeclarationOnly",
22
+ "prepublishOnly": "npm run build",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "test:coverage": "vitest run --coverage"
26
+ },
27
+ "keywords": [
28
+ "textmate",
29
+ "syntax",
30
+ "highlighting",
31
+ "grammar",
32
+ "wasm",
33
+ "tokenizer"
34
+ ],
35
+ "author": "Mickael Bonfill <jbltx@protonmail.com>",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/jbltx/TextMateLib.git"
40
+ },
41
+ "devDependencies": {
42
+ "@rollup/plugin-node-resolve": "^16.0.0",
43
+ "@rollup/plugin-typescript": "^12.1.2",
44
+ "@vitest/coverage-v8": "^4.0.18",
45
+ "rollup": "^4.29.1",
46
+ "tm-grammars": "^1.30.2",
47
+ "tm-themes": "^1.11.0",
48
+ "tslib": "^2.8.1",
49
+ "typescript": "^5.7.2",
50
+ "vitest": "^4.0.18"
51
+ }
52
+ }
@@ -0,0 +1,4 @@
1
+ import type { WasmModule } from '../src/types';
2
+
3
+ declare function createModule(): Promise<WasmModule>;
4
+ export default createModule;
@@ -0,0 +1,2 @@
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&&registeredClass.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
+ ;return moduleRtn}})();if(typeof exports==="object"&&typeof module==="object"){module.exports=createTextMateModule;module.exports.default=createTextMateModule}else if(typeof define==="function"&&define["amd"])define([],()=>createTextMateModule);
Binary file