@mirascript/wasm 0.1.35 → 0.1.38

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/lib/wasm.d.ts CHANGED
@@ -2,69 +2,69 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  export class CompileResult {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- diagnostics(): Uint32Array;
9
- chunk(): Uint8Array | undefined;
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ chunk(): Uint8Array | undefined;
9
+ diagnostics(): Uint32Array;
10
10
  }
11
11
 
12
12
  export class Config {
13
- free(): void;
14
- [Symbol.dispose](): void;
15
- constructor();
16
- trivia: boolean;
17
- input_mode: InputMode;
18
- diagnostic_position_encoding: DiagnosticPositionEncoding;
19
- diagnostic_error: boolean;
20
- diagnostic_warning: boolean;
21
- diagnostic_info: boolean;
22
- diagnostic_hint: boolean;
23
- diagnostic_reference: boolean;
24
- diagnostic_tag: boolean;
25
- diagnostic_sourcemap: boolean;
13
+ free(): void;
14
+ [Symbol.dispose](): void;
15
+ constructor();
16
+ diagnostic_error: boolean;
17
+ diagnostic_hint: boolean;
18
+ diagnostic_info: boolean;
19
+ diagnostic_position_encoding: DiagnosticPositionEncoding;
20
+ diagnostic_reference: boolean;
21
+ diagnostic_sourcemap: boolean;
22
+ diagnostic_tag: boolean;
23
+ diagnostic_warning: boolean;
24
+ input_mode: InputMode;
25
+ trivia: boolean;
26
26
  }
27
27
 
28
28
  /**
29
29
  * Encoding for counting positions in diagnostics.
30
30
  */
31
31
  export enum DiagnosticPositionEncoding {
32
- /**
33
- * Use the default encoding (UTF-8) and
34
- * 0-based indexing from the start of the file.
35
- * Do not convert positions to line-column format.
36
- */
37
- None = 0,
38
- /**
39
- * Convert positions to 1-based UTF-8 line-column format.
40
- */
41
- Utf8 = 1,
42
- /**
43
- * Convert positions to 1-based UTF-16 line-column format.
44
- */
45
- Utf16 = 2,
46
- /**
47
- * Convert positions to 1-based UTF-32 line-column format.
48
- */
49
- Utf32 = 3,
32
+ /**
33
+ * Use the default encoding (UTF-8) and
34
+ * 0-based indexing from the start of the file.
35
+ * Do not convert positions to line-column format.
36
+ */
37
+ None = 0,
38
+ /**
39
+ * Convert positions to 1-based UTF-8 line-column format.
40
+ */
41
+ Utf8 = 1,
42
+ /**
43
+ * Convert positions to 1-based UTF-16 line-column format.
44
+ */
45
+ Utf16 = 2,
46
+ /**
47
+ * Convert positions to 1-based UTF-32 line-column format.
48
+ */
49
+ Utf32 = 3,
50
50
  }
51
51
 
52
52
  /**
53
53
  * Mode for reading input.
54
54
  */
55
55
  export enum InputMode {
56
- Script = 0,
57
- Template = 1,
56
+ Script = 0,
57
+ Template = 1,
58
58
  }
59
59
 
60
60
  export class MonacoCompiler {
61
- free(): void;
62
- [Symbol.dispose](): void;
63
- diagnostics(): Uint32Array;
64
- constructor(input: string, config: Config);
65
- emit(): Uint8Array | undefined;
66
- parse(): boolean;
67
- format(): string | undefined;
61
+ free(): void;
62
+ [Symbol.dispose](): void;
63
+ diagnostics(): Uint32Array;
64
+ emit(): Uint8Array | undefined;
65
+ format(): string | undefined;
66
+ constructor(input: string, config: Config);
67
+ parse(): boolean;
68
68
  }
69
69
 
70
70
  export function compile(script: string, config: Config): CompileResult;
@@ -76,66 +76,66 @@ export function main(): void;
76
76
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
77
77
 
78
78
  export interface InitOutput {
79
- readonly memory: WebAssembly.Memory;
80
- readonly __wbg_compileresult_free: (a: number, b: number) => void;
81
- readonly __wbg_monacocompiler_free: (a: number, b: number) => void;
82
- readonly compile: (a: number, b: number, c: number) => number;
83
- readonly compile_buffer: (a: number, b: number, c: number) => number;
84
- readonly compileresult_chunk: (a: number, b: number) => void;
85
- readonly compileresult_diagnostics: (a: number, b: number) => void;
86
- readonly main: () => void;
87
- readonly monacocompiler_diagnostics: (a: number, b: number) => void;
88
- readonly monacocompiler_emit: (a: number, b: number) => void;
89
- readonly monacocompiler_format: (a: number, b: number) => void;
90
- readonly monacocompiler_new: (a: number, b: number, c: number) => number;
91
- readonly monacocompiler_parse: (a: number) => number;
92
- readonly __wbg_config_free: (a: number, b: number) => void;
93
- readonly __wbg_get_config_diagnostic_error: (a: number) => number;
94
- readonly __wbg_get_config_diagnostic_hint: (a: number) => number;
95
- readonly __wbg_get_config_diagnostic_info: (a: number) => number;
96
- readonly __wbg_get_config_diagnostic_position_encoding: (a: number) => number;
97
- readonly __wbg_get_config_diagnostic_reference: (a: number) => number;
98
- readonly __wbg_get_config_diagnostic_sourcemap: (a: number) => number;
99
- readonly __wbg_get_config_diagnostic_tag: (a: number) => number;
100
- readonly __wbg_get_config_diagnostic_warning: (a: number) => number;
101
- readonly __wbg_get_config_input_mode: (a: number) => number;
102
- readonly __wbg_get_config_trivia: (a: number) => number;
103
- readonly __wbg_set_config_diagnostic_error: (a: number, b: number) => void;
104
- readonly __wbg_set_config_diagnostic_hint: (a: number, b: number) => void;
105
- readonly __wbg_set_config_diagnostic_info: (a: number, b: number) => void;
106
- readonly __wbg_set_config_diagnostic_position_encoding: (a: number, b: number) => void;
107
- readonly __wbg_set_config_diagnostic_reference: (a: number, b: number) => void;
108
- readonly __wbg_set_config_diagnostic_sourcemap: (a: number, b: number) => void;
109
- readonly __wbg_set_config_diagnostic_tag: (a: number, b: number) => void;
110
- readonly __wbg_set_config_diagnostic_warning: (a: number, b: number) => void;
111
- readonly __wbg_set_config_input_mode: (a: number, b: number) => void;
112
- readonly __wbg_set_config_trivia: (a: number, b: number) => void;
113
- readonly config_new: () => number;
114
- readonly __wbindgen_export: (a: number, b: number, c: number) => void;
115
- readonly __wbindgen_export2: (a: number, b: number) => number;
116
- readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
117
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
118
- readonly __wbindgen_start: () => void;
79
+ readonly memory: WebAssembly.Memory;
80
+ readonly __wbg_compileresult_free: (a: number, b: number) => void;
81
+ readonly __wbg_monacocompiler_free: (a: number, b: number) => void;
82
+ readonly compile: (a: number, b: number, c: number) => number;
83
+ readonly compile_buffer: (a: number, b: number, c: number) => number;
84
+ readonly compileresult_chunk: (a: number, b: number) => void;
85
+ readonly compileresult_diagnostics: (a: number, b: number) => void;
86
+ readonly main: () => void;
87
+ readonly monacocompiler_diagnostics: (a: number, b: number) => void;
88
+ readonly monacocompiler_emit: (a: number, b: number) => void;
89
+ readonly monacocompiler_format: (a: number, b: number) => void;
90
+ readonly monacocompiler_new: (a: number, b: number, c: number) => number;
91
+ readonly monacocompiler_parse: (a: number) => number;
92
+ readonly __wbg_config_free: (a: number, b: number) => void;
93
+ readonly __wbg_get_config_diagnostic_error: (a: number) => number;
94
+ readonly __wbg_get_config_diagnostic_hint: (a: number) => number;
95
+ readonly __wbg_get_config_diagnostic_info: (a: number) => number;
96
+ readonly __wbg_get_config_diagnostic_position_encoding: (a: number) => number;
97
+ readonly __wbg_get_config_diagnostic_reference: (a: number) => number;
98
+ readonly __wbg_get_config_diagnostic_sourcemap: (a: number) => number;
99
+ readonly __wbg_get_config_diagnostic_tag: (a: number) => number;
100
+ readonly __wbg_get_config_diagnostic_warning: (a: number) => number;
101
+ readonly __wbg_get_config_input_mode: (a: number) => number;
102
+ readonly __wbg_get_config_trivia: (a: number) => number;
103
+ readonly __wbg_set_config_diagnostic_error: (a: number, b: number) => void;
104
+ readonly __wbg_set_config_diagnostic_hint: (a: number, b: number) => void;
105
+ readonly __wbg_set_config_diagnostic_info: (a: number, b: number) => void;
106
+ readonly __wbg_set_config_diagnostic_position_encoding: (a: number, b: number) => void;
107
+ readonly __wbg_set_config_diagnostic_reference: (a: number, b: number) => void;
108
+ readonly __wbg_set_config_diagnostic_sourcemap: (a: number, b: number) => void;
109
+ readonly __wbg_set_config_diagnostic_tag: (a: number, b: number) => void;
110
+ readonly __wbg_set_config_diagnostic_warning: (a: number, b: number) => void;
111
+ readonly __wbg_set_config_input_mode: (a: number, b: number) => void;
112
+ readonly __wbg_set_config_trivia: (a: number, b: number) => void;
113
+ readonly config_new: () => number;
114
+ readonly __wbindgen_export: (a: number, b: number, c: number) => void;
115
+ readonly __wbindgen_export2: (a: number, b: number) => number;
116
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
117
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
118
+ readonly __wbindgen_start: () => void;
119
119
  }
120
120
 
121
121
  export type SyncInitInput = BufferSource | WebAssembly.Module;
122
122
 
123
123
  /**
124
- * Instantiates the given `module`, which can either be bytes or
125
- * a precompiled `WebAssembly.Module`.
126
- *
127
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
128
- *
129
- * @returns {InitOutput}
130
- */
124
+ * Instantiates the given `module`, which can either be bytes or
125
+ * a precompiled `WebAssembly.Module`.
126
+ *
127
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
128
+ *
129
+ * @returns {InitOutput}
130
+ */
131
131
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
132
132
 
133
133
  /**
134
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
135
- * for everything else, calls `WebAssembly.instantiate` directly.
136
- *
137
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
138
- *
139
- * @returns {Promise<InitOutput>}
140
- */
134
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
135
+ * for everything else, calls `WebAssembly.instantiate` directly.
136
+ *
137
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
138
+ *
139
+ * @returns {Promise<InitOutput>}
140
+ */
141
141
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/lib/wasm.js CHANGED
@@ -1,162 +1,4 @@
1
- let wasm;
2
-
3
- function addHeapObject(obj) {
4
- if (heap_next === heap.length) heap.push(heap.length + 1);
5
- const idx = heap_next;
6
- heap_next = heap[idx];
7
-
8
- heap[idx] = obj;
9
- return idx;
10
- }
11
-
12
- function _assertClass(instance, klass) {
13
- if (!(instance instanceof klass)) {
14
- throw new Error(`expected instance of ${klass.name}`);
15
- }
16
- }
17
-
18
- function dropObject(idx) {
19
- if (idx < 132) return;
20
- heap[idx] = heap_next;
21
- heap_next = idx;
22
- }
23
-
24
- function getArrayU32FromWasm0(ptr, len) {
25
- ptr = ptr >>> 0;
26
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
27
- }
28
-
29
- function getArrayU8FromWasm0(ptr, len) {
30
- ptr = ptr >>> 0;
31
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
32
- }
33
-
34
- let cachedDataViewMemory0 = null;
35
- function getDataViewMemory0() {
36
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
37
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
38
- }
39
- return cachedDataViewMemory0;
40
- }
41
-
42
- function getStringFromWasm0(ptr, len) {
43
- ptr = ptr >>> 0;
44
- return decodeText(ptr, len);
45
- }
46
-
47
- let cachedUint32ArrayMemory0 = null;
48
- function getUint32ArrayMemory0() {
49
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
50
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
51
- }
52
- return cachedUint32ArrayMemory0;
53
- }
54
-
55
- let cachedUint8ArrayMemory0 = null;
56
- function getUint8ArrayMemory0() {
57
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
58
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
59
- }
60
- return cachedUint8ArrayMemory0;
61
- }
62
-
63
- function getObject(idx) { return heap[idx]; }
64
-
65
- let heap = new Array(128).fill(undefined);
66
- heap.push(undefined, null, true, false);
67
-
68
- let heap_next = heap.length;
69
-
70
- function passArray8ToWasm0(arg, malloc) {
71
- const ptr = malloc(arg.length * 1, 1) >>> 0;
72
- getUint8ArrayMemory0().set(arg, ptr / 1);
73
- WASM_VECTOR_LEN = arg.length;
74
- return ptr;
75
- }
76
-
77
- function passStringToWasm0(arg, malloc, realloc) {
78
- if (realloc === undefined) {
79
- const buf = cachedTextEncoder.encode(arg);
80
- const ptr = malloc(buf.length, 1) >>> 0;
81
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
82
- WASM_VECTOR_LEN = buf.length;
83
- return ptr;
84
- }
85
-
86
- let len = arg.length;
87
- let ptr = malloc(len, 1) >>> 0;
88
-
89
- const mem = getUint8ArrayMemory0();
90
-
91
- let offset = 0;
92
-
93
- for (; offset < len; offset++) {
94
- const code = arg.charCodeAt(offset);
95
- if (code > 0x7F) break;
96
- mem[ptr + offset] = code;
97
- }
98
- if (offset !== len) {
99
- if (offset !== 0) {
100
- arg = arg.slice(offset);
101
- }
102
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
103
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
104
- const ret = cachedTextEncoder.encodeInto(arg, view);
105
-
106
- offset += ret.written;
107
- ptr = realloc(ptr, len, offset, 1) >>> 0;
108
- }
109
-
110
- WASM_VECTOR_LEN = offset;
111
- return ptr;
112
- }
113
-
114
- function takeObject(idx) {
115
- const ret = getObject(idx);
116
- dropObject(idx);
117
- return ret;
118
- }
119
-
120
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
121
- cachedTextDecoder.decode();
122
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
123
- let numBytesDecoded = 0;
124
- function decodeText(ptr, len) {
125
- numBytesDecoded += len;
126
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
127
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
128
- cachedTextDecoder.decode();
129
- numBytesDecoded = len;
130
- }
131
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
132
- }
133
-
134
- const cachedTextEncoder = new TextEncoder();
135
-
136
- if (!('encodeInto' in cachedTextEncoder)) {
137
- cachedTextEncoder.encodeInto = function (arg, view) {
138
- const buf = cachedTextEncoder.encode(arg);
139
- view.set(buf);
140
- return {
141
- read: arg.length,
142
- written: buf.length
143
- };
144
- }
145
- }
146
-
147
- let WASM_VECTOR_LEN = 0;
148
-
149
- const CompileResultFinalization = (typeof FinalizationRegistry === 'undefined')
150
- ? { register: () => {}, unregister: () => {} }
151
- : new FinalizationRegistry(ptr => wasm.__wbg_compileresult_free(ptr >>> 0, 1));
152
-
153
- const ConfigFinalization = (typeof FinalizationRegistry === 'undefined')
154
- ? { register: () => {}, unregister: () => {} }
155
- : new FinalizationRegistry(ptr => wasm.__wbg_config_free(ptr >>> 0, 1));
156
-
157
- const MonacoCompilerFinalization = (typeof FinalizationRegistry === 'undefined')
158
- ? { register: () => {}, unregister: () => {} }
159
- : new FinalizationRegistry(ptr => wasm.__wbg_monacocompiler_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./wasm.d.ts" */
160
2
 
161
3
  export class CompileResult {
162
4
  static __wrap(ptr) {
@@ -177,35 +19,35 @@ export class CompileResult {
177
19
  wasm.__wbg_compileresult_free(ptr, 0);
178
20
  }
179
21
  /**
180
- * @returns {Uint32Array}
22
+ * @returns {Uint8Array | undefined}
181
23
  */
182
- diagnostics() {
24
+ chunk() {
183
25
  try {
184
26
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
185
- wasm.compileresult_diagnostics(retptr, this.__wbg_ptr);
27
+ wasm.compileresult_chunk(retptr, this.__wbg_ptr);
186
28
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
187
29
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
188
- var v1 = getArrayU32FromWasm0(r0, r1).slice();
189
- wasm.__wbindgen_export(r0, r1 * 4, 4);
30
+ let v1;
31
+ if (r0 !== 0) {
32
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
33
+ wasm.__wbindgen_export(r0, r1 * 1, 1);
34
+ }
190
35
  return v1;
191
36
  } finally {
192
37
  wasm.__wbindgen_add_to_stack_pointer(16);
193
38
  }
194
39
  }
195
40
  /**
196
- * @returns {Uint8Array | undefined}
41
+ * @returns {Uint32Array}
197
42
  */
198
- chunk() {
43
+ diagnostics() {
199
44
  try {
200
45
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
201
- wasm.compileresult_chunk(retptr, this.__wbg_ptr);
46
+ wasm.compileresult_diagnostics(retptr, this.__wbg_ptr);
202
47
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
203
48
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
204
- let v1;
205
- if (r0 !== 0) {
206
- v1 = getArrayU8FromWasm0(r0, r1).slice();
207
- wasm.__wbindgen_export(r0, r1 * 1, 1);
208
- }
49
+ var v1 = getArrayU32FromWasm0(r0, r1).slice();
50
+ wasm.__wbindgen_export(r0, r1 * 4, 4);
209
51
  return v1;
210
52
  } finally {
211
53
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -225,31 +67,32 @@ export class Config {
225
67
  const ptr = this.__destroy_into_raw();
226
68
  wasm.__wbg_config_free(ptr, 0);
227
69
  }
70
+ constructor() {
71
+ const ret = wasm.config_new();
72
+ this.__wbg_ptr = ret >>> 0;
73
+ ConfigFinalization.register(this, this.__wbg_ptr, this);
74
+ return this;
75
+ }
228
76
  /**
229
77
  * @returns {boolean}
230
78
  */
231
- get trivia() {
232
- const ret = wasm.__wbg_get_config_trivia(this.__wbg_ptr);
79
+ get diagnostic_error() {
80
+ const ret = wasm.__wbg_get_config_diagnostic_error(this.__wbg_ptr);
233
81
  return ret !== 0;
234
82
  }
235
83
  /**
236
- * @param {boolean} arg0
237
- */
238
- set trivia(arg0) {
239
- wasm.__wbg_set_config_trivia(this.__wbg_ptr, arg0);
240
- }
241
- /**
242
- * @returns {InputMode}
84
+ * @returns {boolean}
243
85
  */
244
- get input_mode() {
245
- const ret = wasm.__wbg_get_config_input_mode(this.__wbg_ptr);
246
- return ret;
86
+ get diagnostic_hint() {
87
+ const ret = wasm.__wbg_get_config_diagnostic_hint(this.__wbg_ptr);
88
+ return ret !== 0;
247
89
  }
248
90
  /**
249
- * @param {InputMode} arg0
91
+ * @returns {boolean}
250
92
  */
251
- set input_mode(arg0) {
252
- wasm.__wbg_set_config_input_mode(this.__wbg_ptr, arg0);
93
+ get diagnostic_info() {
94
+ const ret = wasm.__wbg_get_config_diagnostic_info(this.__wbg_ptr);
95
+ return ret !== 0;
253
96
  }
254
97
  /**
255
98
  * @returns {DiagnosticPositionEncoding}
@@ -259,23 +102,25 @@ export class Config {
259
102
  return ret;
260
103
  }
261
104
  /**
262
- * @param {DiagnosticPositionEncoding} arg0
105
+ * @returns {boolean}
263
106
  */
264
- set diagnostic_position_encoding(arg0) {
265
- wasm.__wbg_set_config_diagnostic_position_encoding(this.__wbg_ptr, arg0);
107
+ get diagnostic_reference() {
108
+ const ret = wasm.__wbg_get_config_diagnostic_reference(this.__wbg_ptr);
109
+ return ret !== 0;
266
110
  }
267
111
  /**
268
112
  * @returns {boolean}
269
113
  */
270
- get diagnostic_error() {
271
- const ret = wasm.__wbg_get_config_diagnostic_error(this.__wbg_ptr);
114
+ get diagnostic_sourcemap() {
115
+ const ret = wasm.__wbg_get_config_diagnostic_sourcemap(this.__wbg_ptr);
272
116
  return ret !== 0;
273
117
  }
274
118
  /**
275
- * @param {boolean} arg0
119
+ * @returns {boolean}
276
120
  */
277
- set diagnostic_error(arg0) {
278
- wasm.__wbg_set_config_diagnostic_error(this.__wbg_ptr, arg0);
121
+ get diagnostic_tag() {
122
+ const ret = wasm.__wbg_get_config_diagnostic_tag(this.__wbg_ptr);
123
+ return ret !== 0;
279
124
  }
280
125
  /**
281
126
  * @returns {boolean}
@@ -285,43 +130,42 @@ export class Config {
285
130
  return ret !== 0;
286
131
  }
287
132
  /**
288
- * @param {boolean} arg0
133
+ * @returns {InputMode}
289
134
  */
290
- set diagnostic_warning(arg0) {
291
- wasm.__wbg_set_config_diagnostic_warning(this.__wbg_ptr, arg0);
135
+ get input_mode() {
136
+ const ret = wasm.__wbg_get_config_input_mode(this.__wbg_ptr);
137
+ return ret;
292
138
  }
293
139
  /**
294
140
  * @returns {boolean}
295
141
  */
296
- get diagnostic_info() {
297
- const ret = wasm.__wbg_get_config_diagnostic_info(this.__wbg_ptr);
142
+ get trivia() {
143
+ const ret = wasm.__wbg_get_config_trivia(this.__wbg_ptr);
298
144
  return ret !== 0;
299
145
  }
300
146
  /**
301
147
  * @param {boolean} arg0
302
148
  */
303
- set diagnostic_info(arg0) {
304
- wasm.__wbg_set_config_diagnostic_info(this.__wbg_ptr, arg0);
149
+ set diagnostic_error(arg0) {
150
+ wasm.__wbg_set_config_diagnostic_error(this.__wbg_ptr, arg0);
305
151
  }
306
152
  /**
307
- * @returns {boolean}
153
+ * @param {boolean} arg0
308
154
  */
309
- get diagnostic_hint() {
310
- const ret = wasm.__wbg_get_config_diagnostic_hint(this.__wbg_ptr);
311
- return ret !== 0;
155
+ set diagnostic_hint(arg0) {
156
+ wasm.__wbg_set_config_diagnostic_hint(this.__wbg_ptr, arg0);
312
157
  }
313
158
  /**
314
159
  * @param {boolean} arg0
315
160
  */
316
- set diagnostic_hint(arg0) {
317
- wasm.__wbg_set_config_diagnostic_hint(this.__wbg_ptr, arg0);
161
+ set diagnostic_info(arg0) {
162
+ wasm.__wbg_set_config_diagnostic_info(this.__wbg_ptr, arg0);
318
163
  }
319
164
  /**
320
- * @returns {boolean}
165
+ * @param {DiagnosticPositionEncoding} arg0
321
166
  */
322
- get diagnostic_reference() {
323
- const ret = wasm.__wbg_get_config_diagnostic_reference(this.__wbg_ptr);
324
- return ret !== 0;
167
+ set diagnostic_position_encoding(arg0) {
168
+ wasm.__wbg_set_config_diagnostic_position_encoding(this.__wbg_ptr, arg0);
325
169
  }
326
170
  /**
327
171
  * @param {boolean} arg0
@@ -330,11 +174,10 @@ export class Config {
330
174
  wasm.__wbg_set_config_diagnostic_reference(this.__wbg_ptr, arg0);
331
175
  }
332
176
  /**
333
- * @returns {boolean}
177
+ * @param {boolean} arg0
334
178
  */
335
- get diagnostic_tag() {
336
- const ret = wasm.__wbg_get_config_diagnostic_tag(this.__wbg_ptr);
337
- return ret !== 0;
179
+ set diagnostic_sourcemap(arg0) {
180
+ wasm.__wbg_set_config_diagnostic_sourcemap(this.__wbg_ptr, arg0);
338
181
  }
339
182
  /**
340
183
  * @param {boolean} arg0
@@ -343,23 +186,22 @@ export class Config {
343
186
  wasm.__wbg_set_config_diagnostic_tag(this.__wbg_ptr, arg0);
344
187
  }
345
188
  /**
346
- * @returns {boolean}
189
+ * @param {boolean} arg0
347
190
  */
348
- get diagnostic_sourcemap() {
349
- const ret = wasm.__wbg_get_config_diagnostic_sourcemap(this.__wbg_ptr);
350
- return ret !== 0;
191
+ set diagnostic_warning(arg0) {
192
+ wasm.__wbg_set_config_diagnostic_warning(this.__wbg_ptr, arg0);
351
193
  }
352
194
  /**
353
- * @param {boolean} arg0
195
+ * @param {InputMode} arg0
354
196
  */
355
- set diagnostic_sourcemap(arg0) {
356
- wasm.__wbg_set_config_diagnostic_sourcemap(this.__wbg_ptr, arg0);
197
+ set input_mode(arg0) {
198
+ wasm.__wbg_set_config_input_mode(this.__wbg_ptr, arg0);
357
199
  }
358
- constructor() {
359
- const ret = wasm.config_new();
360
- this.__wbg_ptr = ret >>> 0;
361
- ConfigFinalization.register(this, this.__wbg_ptr, this);
362
- return this;
200
+ /**
201
+ * @param {boolean} arg0
202
+ */
203
+ set trivia(arg0) {
204
+ wasm.__wbg_set_config_trivia(this.__wbg_ptr, arg0);
363
205
  }
364
206
  }
365
207
  if (Symbol.dispose) Config.prototype[Symbol.dispose] = Config.prototype.free;
@@ -425,19 +267,6 @@ export class MonacoCompiler {
425
267
  wasm.__wbindgen_add_to_stack_pointer(16);
426
268
  }
427
269
  }
428
- /**
429
- * @param {string} input
430
- * @param {Config} config
431
- */
432
- constructor(input, config) {
433
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
434
- const len0 = WASM_VECTOR_LEN;
435
- _assertClass(config, Config);
436
- const ret = wasm.monacocompiler_new(ptr0, len0, config.__wbg_ptr);
437
- this.__wbg_ptr = ret >>> 0;
438
- MonacoCompilerFinalization.register(this, this.__wbg_ptr, this);
439
- return this;
440
- }
441
270
  /**
442
271
  * @returns {Uint8Array | undefined}
443
272
  */
@@ -457,13 +286,6 @@ export class MonacoCompiler {
457
286
  wasm.__wbindgen_add_to_stack_pointer(16);
458
287
  }
459
288
  }
460
- /**
461
- * @returns {boolean}
462
- */
463
- parse() {
464
- const ret = wasm.monacocompiler_parse(this.__wbg_ptr);
465
- return ret !== 0;
466
- }
467
289
  /**
468
290
  * @returns {string | undefined}
469
291
  */
@@ -483,6 +305,26 @@ export class MonacoCompiler {
483
305
  wasm.__wbindgen_add_to_stack_pointer(16);
484
306
  }
485
307
  }
308
+ /**
309
+ * @param {string} input
310
+ * @param {Config} config
311
+ */
312
+ constructor(input, config) {
313
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
314
+ const len0 = WASM_VECTOR_LEN;
315
+ _assertClass(config, Config);
316
+ const ret = wasm.monacocompiler_new(ptr0, len0, config.__wbg_ptr);
317
+ this.__wbg_ptr = ret >>> 0;
318
+ MonacoCompilerFinalization.register(this, this.__wbg_ptr, this);
319
+ return this;
320
+ }
321
+ /**
322
+ * @returns {boolean}
323
+ */
324
+ parse() {
325
+ const ret = wasm.monacocompiler_parse(this.__wbg_ptr);
326
+ return ret !== 0;
327
+ }
486
328
  }
487
329
  if (Symbol.dispose) MonacoCompiler.prototype[Symbol.dispose] = MonacoCompiler.prototype.free;
488
330
 
@@ -516,7 +358,210 @@ export function main() {
516
358
  wasm.main();
517
359
  }
518
360
 
519
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
361
+ function __wbg_get_imports() {
362
+ const import0 = {
363
+ __proto__: null,
364
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
365
+ throw new Error(getStringFromWasm0(arg0, arg1));
366
+ },
367
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
368
+ let deferred0_0;
369
+ let deferred0_1;
370
+ try {
371
+ deferred0_0 = arg0;
372
+ deferred0_1 = arg1;
373
+ console.error(getStringFromWasm0(arg0, arg1));
374
+ } finally {
375
+ wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
376
+ }
377
+ },
378
+ __wbg_new_8a6f238a6ece86ea: function() {
379
+ const ret = new Error();
380
+ return addHeapObject(ret);
381
+ },
382
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
383
+ const ret = getObject(arg1).stack;
384
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
385
+ const len1 = WASM_VECTOR_LEN;
386
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
387
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
388
+ },
389
+ __wbindgen_object_drop_ref: function(arg0) {
390
+ takeObject(arg0);
391
+ },
392
+ };
393
+ return {
394
+ __proto__: null,
395
+ "./wasm_bg.js": import0,
396
+ };
397
+ }
398
+
399
+ const CompileResultFinalization = (typeof FinalizationRegistry === 'undefined')
400
+ ? { register: () => {}, unregister: () => {} }
401
+ : new FinalizationRegistry(ptr => wasm.__wbg_compileresult_free(ptr >>> 0, 1));
402
+ const ConfigFinalization = (typeof FinalizationRegistry === 'undefined')
403
+ ? { register: () => {}, unregister: () => {} }
404
+ : new FinalizationRegistry(ptr => wasm.__wbg_config_free(ptr >>> 0, 1));
405
+ const MonacoCompilerFinalization = (typeof FinalizationRegistry === 'undefined')
406
+ ? { register: () => {}, unregister: () => {} }
407
+ : new FinalizationRegistry(ptr => wasm.__wbg_monacocompiler_free(ptr >>> 0, 1));
408
+
409
+ function addHeapObject(obj) {
410
+ if (heap_next === heap.length) heap.push(heap.length + 1);
411
+ const idx = heap_next;
412
+ heap_next = heap[idx];
413
+
414
+ heap[idx] = obj;
415
+ return idx;
416
+ }
417
+
418
+ function _assertClass(instance, klass) {
419
+ if (!(instance instanceof klass)) {
420
+ throw new Error(`expected instance of ${klass.name}`);
421
+ }
422
+ }
423
+
424
+ function dropObject(idx) {
425
+ if (idx < 132) return;
426
+ heap[idx] = heap_next;
427
+ heap_next = idx;
428
+ }
429
+
430
+ function getArrayU32FromWasm0(ptr, len) {
431
+ ptr = ptr >>> 0;
432
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
433
+ }
434
+
435
+ function getArrayU8FromWasm0(ptr, len) {
436
+ ptr = ptr >>> 0;
437
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
438
+ }
439
+
440
+ let cachedDataViewMemory0 = null;
441
+ function getDataViewMemory0() {
442
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
443
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
444
+ }
445
+ return cachedDataViewMemory0;
446
+ }
447
+
448
+ function getStringFromWasm0(ptr, len) {
449
+ ptr = ptr >>> 0;
450
+ return decodeText(ptr, len);
451
+ }
452
+
453
+ let cachedUint32ArrayMemory0 = null;
454
+ function getUint32ArrayMemory0() {
455
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
456
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
457
+ }
458
+ return cachedUint32ArrayMemory0;
459
+ }
460
+
461
+ let cachedUint8ArrayMemory0 = null;
462
+ function getUint8ArrayMemory0() {
463
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
464
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
465
+ }
466
+ return cachedUint8ArrayMemory0;
467
+ }
468
+
469
+ function getObject(idx) { return heap[idx]; }
470
+
471
+ let heap = new Array(128).fill(undefined);
472
+ heap.push(undefined, null, true, false);
473
+
474
+ let heap_next = heap.length;
475
+
476
+ function passArray8ToWasm0(arg, malloc) {
477
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
478
+ getUint8ArrayMemory0().set(arg, ptr / 1);
479
+ WASM_VECTOR_LEN = arg.length;
480
+ return ptr;
481
+ }
482
+
483
+ function passStringToWasm0(arg, malloc, realloc) {
484
+ if (realloc === undefined) {
485
+ const buf = cachedTextEncoder.encode(arg);
486
+ const ptr = malloc(buf.length, 1) >>> 0;
487
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
488
+ WASM_VECTOR_LEN = buf.length;
489
+ return ptr;
490
+ }
491
+
492
+ let len = arg.length;
493
+ let ptr = malloc(len, 1) >>> 0;
494
+
495
+ const mem = getUint8ArrayMemory0();
496
+
497
+ let offset = 0;
498
+
499
+ for (; offset < len; offset++) {
500
+ const code = arg.charCodeAt(offset);
501
+ if (code > 0x7F) break;
502
+ mem[ptr + offset] = code;
503
+ }
504
+ if (offset !== len) {
505
+ if (offset !== 0) {
506
+ arg = arg.slice(offset);
507
+ }
508
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
509
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
510
+ const ret = cachedTextEncoder.encodeInto(arg, view);
511
+
512
+ offset += ret.written;
513
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
514
+ }
515
+
516
+ WASM_VECTOR_LEN = offset;
517
+ return ptr;
518
+ }
519
+
520
+ function takeObject(idx) {
521
+ const ret = getObject(idx);
522
+ dropObject(idx);
523
+ return ret;
524
+ }
525
+
526
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
527
+ cachedTextDecoder.decode();
528
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
529
+ let numBytesDecoded = 0;
530
+ function decodeText(ptr, len) {
531
+ numBytesDecoded += len;
532
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
533
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
534
+ cachedTextDecoder.decode();
535
+ numBytesDecoded = len;
536
+ }
537
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
538
+ }
539
+
540
+ const cachedTextEncoder = new TextEncoder();
541
+
542
+ if (!('encodeInto' in cachedTextEncoder)) {
543
+ cachedTextEncoder.encodeInto = function (arg, view) {
544
+ const buf = cachedTextEncoder.encode(arg);
545
+ view.set(buf);
546
+ return {
547
+ read: arg.length,
548
+ written: buf.length
549
+ };
550
+ };
551
+ }
552
+
553
+ let WASM_VECTOR_LEN = 0;
554
+
555
+ let wasmModule, wasm;
556
+ function __wbg_finalize_init(instance, module) {
557
+ wasm = instance.exports;
558
+ wasmModule = module;
559
+ cachedDataViewMemory0 = null;
560
+ cachedUint32ArrayMemory0 = null;
561
+ cachedUint8ArrayMemory0 = null;
562
+ wasm.__wbindgen_start();
563
+ return wasm;
564
+ }
520
565
 
521
566
  async function __wbg_load(module, imports) {
522
567
  if (typeof Response === 'function' && module instanceof Response) {
@@ -524,14 +569,12 @@ async function __wbg_load(module, imports) {
524
569
  try {
525
570
  return await WebAssembly.instantiateStreaming(module, imports);
526
571
  } catch (e) {
527
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
572
+ const validResponse = module.ok && expectedResponseType(module.type);
528
573
 
529
574
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
530
575
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
531
576
 
532
- } else {
533
- throw e;
534
- }
577
+ } else { throw e; }
535
578
  }
536
579
  }
537
580
 
@@ -546,60 +589,20 @@ async function __wbg_load(module, imports) {
546
589
  return instance;
547
590
  }
548
591
  }
549
- }
550
592
 
551
- function __wbg_get_imports() {
552
- const imports = {};
553
- imports.wbg = {};
554
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
555
- throw new Error(getStringFromWasm0(arg0, arg1));
556
- };
557
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
558
- let deferred0_0;
559
- let deferred0_1;
560
- try {
561
- deferred0_0 = arg0;
562
- deferred0_1 = arg1;
563
- console.error(getStringFromWasm0(arg0, arg1));
564
- } finally {
565
- wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
593
+ function expectedResponseType(type) {
594
+ switch (type) {
595
+ case 'basic': case 'cors': case 'default': return true;
566
596
  }
567
- };
568
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
569
- const ret = new Error();
570
- return addHeapObject(ret);
571
- };
572
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
573
- const ret = getObject(arg1).stack;
574
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
575
- const len1 = WASM_VECTOR_LEN;
576
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
577
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
578
- };
579
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
580
- takeObject(arg0);
581
- };
582
-
583
- return imports;
584
- }
585
-
586
- function __wbg_finalize_init(instance, module) {
587
- wasm = instance.exports;
588
- __wbg_init.__wbindgen_wasm_module = module;
589
- cachedDataViewMemory0 = null;
590
- cachedUint32ArrayMemory0 = null;
591
- cachedUint8ArrayMemory0 = null;
592
-
593
-
594
- wasm.__wbindgen_start();
595
- return wasm;
597
+ return false;
598
+ }
596
599
  }
597
600
 
598
601
  function initSync(module) {
599
602
  if (wasm !== undefined) return wasm;
600
603
 
601
604
 
602
- if (typeof module !== 'undefined') {
605
+ if (module !== undefined) {
603
606
  if (Object.getPrototypeOf(module) === Object.prototype) {
604
607
  ({module} = module)
605
608
  } else {
@@ -619,7 +622,7 @@ async function __wbg_init(module_or_path) {
619
622
  if (wasm !== undefined) return wasm;
620
623
 
621
624
 
622
- if (typeof module_or_path !== 'undefined') {
625
+ if (module_or_path !== undefined) {
623
626
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
624
627
  ({module_or_path} = module_or_path)
625
628
  } else {
@@ -627,7 +630,7 @@ async function __wbg_init(module_or_path) {
627
630
  }
628
631
  }
629
632
 
630
- if (typeof module_or_path === 'undefined') {
633
+ if (module_or_path === undefined) {
631
634
  module_or_path = new URL('wasm_bg.wasm', import.meta.url);
632
635
  }
633
636
  const imports = __wbg_get_imports();
@@ -641,5 +644,4 @@ async function __wbg_init(module_or_path) {
641
644
  return __wbg_finalize_init(instance, module);
642
645
  }
643
646
 
644
- export { initSync };
645
- export default __wbg_init;
647
+ export { initSync, __wbg_init as default };
package/lib/wasm_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirascript/wasm",
3
- "version": "0.1.35",
3
+ "version": "0.1.38",
4
4
  "author": "CloudPSS",
5
5
  "license": "MIT",
6
6
  "description": "MiraScript compiler for WebAssembly",
@@ -16,9 +16,9 @@
16
16
  }
17
17
  },
18
18
  "devDependencies": {
19
- "@types/node": "^25.0.6",
19
+ "@types/node": "^25.0.8",
20
20
  "nodemon": "^3.1.11",
21
- "@mirascript/constants": "~0.1.35"
21
+ "@mirascript/constants": "~0.1.38"
22
22
  },
23
23
  "scripts": {
24
24
  "wasm": "wasm-pack build --target web --out-dir ../../packages/wasm/lib --no-pack ../../crates/wasm",