fratmscript 0.0.0-stage → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,301 @@
1
+ /* @ts-self-types="./fratm_wasm.d.ts" */
2
+
3
+ /**
4
+ * Compile FratmScript source to JavaScript
5
+ *
6
+ * Returns a JSON object with:
7
+ * - `success`: boolean
8
+ * - `code`: string (if success)
9
+ * - `sourceMap`: string (if success and requested)
10
+ * - `error`: string (if failure)
11
+ * - `line`: number (if failure)
12
+ * - `column`: number (if failure)
13
+ *
14
+ * `jsx_import_source` picks the library of the JSX runtime (`react` when
15
+ * left out).
16
+ * @param {string} source
17
+ * @param {boolean} generate_source_map
18
+ * @param {string | null} [jsx_import_source]
19
+ * @returns {any}
20
+ */
21
+ function compile(source, generate_source_map, jsx_import_source) {
22
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
23
+ const len0 = WASM_VECTOR_LEN;
24
+ var ptr1 = isLikeNone(jsx_import_source) ? 0 : passStringToWasm0(jsx_import_source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
25
+ var len1 = WASM_VECTOR_LEN;
26
+ const ret = wasm.compile(ptr0, len0, generate_source_map, ptr1, len1);
27
+ return ret;
28
+ }
29
+ exports.compile = compile;
30
+
31
+ /**
32
+ * Format FratmScript source like `fratm fmt`
33
+ *
34
+ * Returns a JSON object with `success`, `code` (the formatted source) or
35
+ * `error`, `line`, `column` and `suggestion`.
36
+ * @param {string} source
37
+ * @returns {any}
38
+ */
39
+ function format(source) {
40
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ const ret = wasm.format(ptr0, len0);
43
+ return ret;
44
+ }
45
+ exports.format = format;
46
+
47
+ /**
48
+ * Initialize panic hook for better error messages in browser console
49
+ */
50
+ function init() {
51
+ wasm.init();
52
+ }
53
+ exports.init = init;
54
+
55
+ /**
56
+ * Tokens and syntax tree for the playground's Token and Tree tabs, as a
57
+ * JSON string: `{ tokens, tree, error }` (positions in UTF-16 units)
58
+ * @param {string} source
59
+ * @returns {string}
60
+ */
61
+ function inspect(source) {
62
+ let deferred2_0;
63
+ let deferred2_1;
64
+ try {
65
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
66
+ const len0 = WASM_VECTOR_LEN;
67
+ const ret = wasm.inspect(ptr0, len0);
68
+ deferred2_0 = ret[0];
69
+ deferred2_1 = ret[1];
70
+ return getStringFromWasm0(ret[0], ret[1]);
71
+ } finally {
72
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
73
+ }
74
+ }
75
+ exports.inspect = inspect;
76
+
77
+ /**
78
+ * Neapolitan version of a JavaScript runtime error, with the original in
79
+ * brackets (`'x' nun esiste … (ReferenceError: x is not defined)`)
80
+ * @param {string} name
81
+ * @param {string} message
82
+ * @returns {string}
83
+ */
84
+ function runtimeError(name, message) {
85
+ let deferred3_0;
86
+ let deferred3_1;
87
+ try {
88
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
89
+ const len0 = WASM_VECTOR_LEN;
90
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ const ret = wasm.runtimeError(ptr0, len0, ptr1, len1);
93
+ deferred3_0 = ret[0];
94
+ deferred3_1 = ret[1];
95
+ return getStringFromWasm0(ret[0], ret[1]);
96
+ } finally {
97
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
98
+ }
99
+ }
100
+ exports.runtimeError = runtimeError;
101
+
102
+ /**
103
+ * Tokenize source code (for syntax highlighting)
104
+ * @param {string} source
105
+ * @returns {any}
106
+ */
107
+ function tokenize(source) {
108
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
+ const len0 = WASM_VECTOR_LEN;
110
+ const ret = wasm.tokenize(ptr0, len0);
111
+ return ret;
112
+ }
113
+ exports.tokenize = tokenize;
114
+
115
+ /**
116
+ * Get the compiler version
117
+ * @returns {string}
118
+ */
119
+ function version() {
120
+ let deferred1_0;
121
+ let deferred1_1;
122
+ try {
123
+ const ret = wasm.version();
124
+ deferred1_0 = ret[0];
125
+ deferred1_1 = ret[1];
126
+ return getStringFromWasm0(ret[0], ret[1]);
127
+ } finally {
128
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
129
+ }
130
+ }
131
+ exports.version = version;
132
+
133
+ function __wbg_get_imports() {
134
+ const import0 = {
135
+ __proto__: null,
136
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
137
+ const ret = Error(getStringFromWasm0(arg0, arg1));
138
+ return ret;
139
+ },
140
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
141
+ const ret = Number(arg0);
142
+ return ret;
143
+ },
144
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
145
+ throw new Error(getStringFromWasm0(arg0, arg1));
146
+ },
147
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
148
+ let deferred0_0;
149
+ let deferred0_1;
150
+ try {
151
+ deferred0_0 = arg0;
152
+ deferred0_1 = arg1;
153
+ console.error(getStringFromWasm0(arg0, arg1));
154
+ } finally {
155
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
156
+ }
157
+ },
158
+ __wbg_new_361308b2356cecd0: function() {
159
+ const ret = new Object();
160
+ return ret;
161
+ },
162
+ __wbg_new_3eb36ae241fe6f44: function() {
163
+ const ret = new Array();
164
+ return ret;
165
+ },
166
+ __wbg_new_8a6f238a6ece86ea: function() {
167
+ const ret = new Error();
168
+ return ret;
169
+ },
170
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
171
+ arg0[arg1] = arg2;
172
+ },
173
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
174
+ arg0[arg1 >>> 0] = arg2;
175
+ },
176
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
177
+ const ret = arg1.stack;
178
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
179
+ const len1 = WASM_VECTOR_LEN;
180
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
181
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
182
+ },
183
+ __wbindgen_cast_0000000000000001: function(arg0) {
184
+ // Cast intrinsic for `F64 -> Externref`.
185
+ const ret = arg0;
186
+ return ret;
187
+ },
188
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
189
+ // Cast intrinsic for `Ref(String) -> Externref`.
190
+ const ret = getStringFromWasm0(arg0, arg1);
191
+ return ret;
192
+ },
193
+ __wbindgen_cast_0000000000000003: function(arg0) {
194
+ // Cast intrinsic for `U64 -> Externref`.
195
+ const ret = BigInt.asUintN(64, arg0);
196
+ return ret;
197
+ },
198
+ __wbindgen_init_externref_table: function() {
199
+ const table = wasm.__wbindgen_externrefs;
200
+ const offset = table.grow(4);
201
+ table.set(0, undefined);
202
+ table.set(offset + 0, undefined);
203
+ table.set(offset + 1, null);
204
+ table.set(offset + 2, true);
205
+ table.set(offset + 3, false);
206
+ },
207
+ };
208
+ return {
209
+ __proto__: null,
210
+ "./fratm_wasm_bg.js": import0,
211
+ };
212
+ }
213
+
214
+ let cachedDataViewMemory0 = null;
215
+ function getDataViewMemory0() {
216
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
217
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
218
+ }
219
+ return cachedDataViewMemory0;
220
+ }
221
+
222
+ function getStringFromWasm0(ptr, len) {
223
+ ptr = ptr >>> 0;
224
+ return decodeText(ptr, len);
225
+ }
226
+
227
+ let cachedUint8ArrayMemory0 = null;
228
+ function getUint8ArrayMemory0() {
229
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
230
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
231
+ }
232
+ return cachedUint8ArrayMemory0;
233
+ }
234
+
235
+ function isLikeNone(x) {
236
+ return x === undefined || x === null;
237
+ }
238
+
239
+ function passStringToWasm0(arg, malloc, realloc) {
240
+ if (realloc === undefined) {
241
+ const buf = cachedTextEncoder.encode(arg);
242
+ const ptr = malloc(buf.length, 1) >>> 0;
243
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
244
+ WASM_VECTOR_LEN = buf.length;
245
+ return ptr;
246
+ }
247
+
248
+ let len = arg.length;
249
+ let ptr = malloc(len, 1) >>> 0;
250
+
251
+ const mem = getUint8ArrayMemory0();
252
+
253
+ let offset = 0;
254
+
255
+ for (; offset < len; offset++) {
256
+ const code = arg.charCodeAt(offset);
257
+ if (code > 0x7F) break;
258
+ mem[ptr + offset] = code;
259
+ }
260
+ if (offset !== len) {
261
+ if (offset !== 0) {
262
+ arg = arg.slice(offset);
263
+ }
264
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
265
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
266
+ const ret = cachedTextEncoder.encodeInto(arg, view);
267
+
268
+ offset += ret.written;
269
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
270
+ }
271
+
272
+ WASM_VECTOR_LEN = offset;
273
+ return ptr;
274
+ }
275
+
276
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
277
+ cachedTextDecoder.decode();
278
+ function decodeText(ptr, len) {
279
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
280
+ }
281
+
282
+ const cachedTextEncoder = new TextEncoder();
283
+
284
+ if (!('encodeInto' in cachedTextEncoder)) {
285
+ cachedTextEncoder.encodeInto = function (arg, view) {
286
+ const buf = cachedTextEncoder.encode(arg);
287
+ view.set(buf);
288
+ return {
289
+ read: arg.length,
290
+ written: buf.length
291
+ };
292
+ };
293
+ }
294
+
295
+ let WASM_VECTOR_LEN = 0;
296
+
297
+ const wasmPath = `${__dirname}/fratm_wasm_bg.wasm`;
298
+ const wasmBytes = require('fs').readFileSync(wasmPath);
299
+ const wasmModule = new WebAssembly.Module(wasmBytes);
300
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
301
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1,389 @@
1
+ /* @ts-self-types="./fratm_wasm.d.ts" */
2
+
3
+ /**
4
+ * Compile FratmScript source to JavaScript
5
+ *
6
+ * Returns a JSON object with:
7
+ * - `success`: boolean
8
+ * - `code`: string (if success)
9
+ * - `sourceMap`: string (if success and requested)
10
+ * - `error`: string (if failure)
11
+ * - `line`: number (if failure)
12
+ * - `column`: number (if failure)
13
+ *
14
+ * `jsx_import_source` picks the library of the JSX runtime (`react` when
15
+ * left out).
16
+ * @param {string} source
17
+ * @param {boolean} generate_source_map
18
+ * @param {string | null} [jsx_import_source]
19
+ * @returns {any}
20
+ */
21
+ export function compile(source, generate_source_map, jsx_import_source) {
22
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
23
+ const len0 = WASM_VECTOR_LEN;
24
+ var ptr1 = isLikeNone(jsx_import_source) ? 0 : passStringToWasm0(jsx_import_source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
25
+ var len1 = WASM_VECTOR_LEN;
26
+ const ret = wasm.compile(ptr0, len0, generate_source_map, ptr1, len1);
27
+ return ret;
28
+ }
29
+
30
+ /**
31
+ * Format FratmScript source like `fratm fmt`
32
+ *
33
+ * Returns a JSON object with `success`, `code` (the formatted source) or
34
+ * `error`, `line`, `column` and `suggestion`.
35
+ * @param {string} source
36
+ * @returns {any}
37
+ */
38
+ export function format(source) {
39
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
40
+ const len0 = WASM_VECTOR_LEN;
41
+ const ret = wasm.format(ptr0, len0);
42
+ return ret;
43
+ }
44
+
45
+ /**
46
+ * Initialize panic hook for better error messages in browser console
47
+ */
48
+ export function init() {
49
+ wasm.init();
50
+ }
51
+
52
+ /**
53
+ * Tokens and syntax tree for the playground's Token and Tree tabs, as a
54
+ * JSON string: `{ tokens, tree, error }` (positions in UTF-16 units)
55
+ * @param {string} source
56
+ * @returns {string}
57
+ */
58
+ export function inspect(source) {
59
+ let deferred2_0;
60
+ let deferred2_1;
61
+ try {
62
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
63
+ const len0 = WASM_VECTOR_LEN;
64
+ const ret = wasm.inspect(ptr0, len0);
65
+ deferred2_0 = ret[0];
66
+ deferred2_1 = ret[1];
67
+ return getStringFromWasm0(ret[0], ret[1]);
68
+ } finally {
69
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Neapolitan version of a JavaScript runtime error, with the original in
75
+ * brackets (`'x' nun esiste … (ReferenceError: x is not defined)`)
76
+ * @param {string} name
77
+ * @param {string} message
78
+ * @returns {string}
79
+ */
80
+ export function runtimeError(name, message) {
81
+ let deferred3_0;
82
+ let deferred3_1;
83
+ try {
84
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
85
+ const len0 = WASM_VECTOR_LEN;
86
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
87
+ const len1 = WASM_VECTOR_LEN;
88
+ const ret = wasm.runtimeError(ptr0, len0, ptr1, len1);
89
+ deferred3_0 = ret[0];
90
+ deferred3_1 = ret[1];
91
+ return getStringFromWasm0(ret[0], ret[1]);
92
+ } finally {
93
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Tokenize source code (for syntax highlighting)
99
+ * @param {string} source
100
+ * @returns {any}
101
+ */
102
+ export function tokenize(source) {
103
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ const ret = wasm.tokenize(ptr0, len0);
106
+ return ret;
107
+ }
108
+
109
+ /**
110
+ * Get the compiler version
111
+ * @returns {string}
112
+ */
113
+ export function version() {
114
+ let deferred1_0;
115
+ let deferred1_1;
116
+ try {
117
+ const ret = wasm.version();
118
+ deferred1_0 = ret[0];
119
+ deferred1_1 = ret[1];
120
+ return getStringFromWasm0(ret[0], ret[1]);
121
+ } finally {
122
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
123
+ }
124
+ }
125
+
126
+ function __wbg_get_imports() {
127
+ const import0 = {
128
+ __proto__: null,
129
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
130
+ const ret = Error(getStringFromWasm0(arg0, arg1));
131
+ return ret;
132
+ },
133
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
134
+ const ret = Number(arg0);
135
+ return ret;
136
+ },
137
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
138
+ throw new Error(getStringFromWasm0(arg0, arg1));
139
+ },
140
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
141
+ let deferred0_0;
142
+ let deferred0_1;
143
+ try {
144
+ deferred0_0 = arg0;
145
+ deferred0_1 = arg1;
146
+ console.error(getStringFromWasm0(arg0, arg1));
147
+ } finally {
148
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
149
+ }
150
+ },
151
+ __wbg_new_361308b2356cecd0: function() {
152
+ const ret = new Object();
153
+ return ret;
154
+ },
155
+ __wbg_new_3eb36ae241fe6f44: function() {
156
+ const ret = new Array();
157
+ return ret;
158
+ },
159
+ __wbg_new_8a6f238a6ece86ea: function() {
160
+ const ret = new Error();
161
+ return ret;
162
+ },
163
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
164
+ arg0[arg1] = arg2;
165
+ },
166
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
167
+ arg0[arg1 >>> 0] = arg2;
168
+ },
169
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
170
+ const ret = arg1.stack;
171
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
172
+ const len1 = WASM_VECTOR_LEN;
173
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
174
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
175
+ },
176
+ __wbindgen_cast_0000000000000001: function(arg0) {
177
+ // Cast intrinsic for `F64 -> Externref`.
178
+ const ret = arg0;
179
+ return ret;
180
+ },
181
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
182
+ // Cast intrinsic for `Ref(String) -> Externref`.
183
+ const ret = getStringFromWasm0(arg0, arg1);
184
+ return ret;
185
+ },
186
+ __wbindgen_cast_0000000000000003: function(arg0) {
187
+ // Cast intrinsic for `U64 -> Externref`.
188
+ const ret = BigInt.asUintN(64, arg0);
189
+ return ret;
190
+ },
191
+ __wbindgen_init_externref_table: function() {
192
+ const table = wasm.__wbindgen_externrefs;
193
+ const offset = table.grow(4);
194
+ table.set(0, undefined);
195
+ table.set(offset + 0, undefined);
196
+ table.set(offset + 1, null);
197
+ table.set(offset + 2, true);
198
+ table.set(offset + 3, false);
199
+ },
200
+ };
201
+ return {
202
+ __proto__: null,
203
+ "./fratm_wasm_bg.js": import0,
204
+ };
205
+ }
206
+
207
+ let cachedDataViewMemory0 = null;
208
+ function getDataViewMemory0() {
209
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
210
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
211
+ }
212
+ return cachedDataViewMemory0;
213
+ }
214
+
215
+ function getStringFromWasm0(ptr, len) {
216
+ ptr = ptr >>> 0;
217
+ return decodeText(ptr, len);
218
+ }
219
+
220
+ let cachedUint8ArrayMemory0 = null;
221
+ function getUint8ArrayMemory0() {
222
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
223
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
224
+ }
225
+ return cachedUint8ArrayMemory0;
226
+ }
227
+
228
+ function isLikeNone(x) {
229
+ return x === undefined || x === null;
230
+ }
231
+
232
+ function passStringToWasm0(arg, malloc, realloc) {
233
+ if (realloc === undefined) {
234
+ const buf = cachedTextEncoder.encode(arg);
235
+ const ptr = malloc(buf.length, 1) >>> 0;
236
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
237
+ WASM_VECTOR_LEN = buf.length;
238
+ return ptr;
239
+ }
240
+
241
+ let len = arg.length;
242
+ let ptr = malloc(len, 1) >>> 0;
243
+
244
+ const mem = getUint8ArrayMemory0();
245
+
246
+ let offset = 0;
247
+
248
+ for (; offset < len; offset++) {
249
+ const code = arg.charCodeAt(offset);
250
+ if (code > 0x7F) break;
251
+ mem[ptr + offset] = code;
252
+ }
253
+ if (offset !== len) {
254
+ if (offset !== 0) {
255
+ arg = arg.slice(offset);
256
+ }
257
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
258
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
259
+ const ret = cachedTextEncoder.encodeInto(arg, view);
260
+
261
+ offset += ret.written;
262
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
263
+ }
264
+
265
+ WASM_VECTOR_LEN = offset;
266
+ return ptr;
267
+ }
268
+
269
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
270
+ cachedTextDecoder.decode();
271
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
272
+ let numBytesDecoded = 0;
273
+ function decodeText(ptr, len) {
274
+ numBytesDecoded += len;
275
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
276
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
277
+ cachedTextDecoder.decode();
278
+ numBytesDecoded = len;
279
+ }
280
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
281
+ }
282
+
283
+ const cachedTextEncoder = new TextEncoder();
284
+
285
+ if (!('encodeInto' in cachedTextEncoder)) {
286
+ cachedTextEncoder.encodeInto = function (arg, view) {
287
+ const buf = cachedTextEncoder.encode(arg);
288
+ view.set(buf);
289
+ return {
290
+ read: arg.length,
291
+ written: buf.length
292
+ };
293
+ };
294
+ }
295
+
296
+ let WASM_VECTOR_LEN = 0;
297
+
298
+ let wasmModule, wasm;
299
+ function __wbg_finalize_init(instance, module) {
300
+ wasm = instance.exports;
301
+ wasmModule = module;
302
+ cachedDataViewMemory0 = null;
303
+ cachedUint8ArrayMemory0 = null;
304
+ wasm.__wbindgen_start();
305
+ return wasm;
306
+ }
307
+
308
+ async function __wbg_load(module, imports) {
309
+ if (typeof Response === 'function' && module instanceof Response) {
310
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
311
+ try {
312
+ return await WebAssembly.instantiateStreaming(module, imports);
313
+ } catch (e) {
314
+ const validResponse = module.ok && expectedResponseType(module.type);
315
+
316
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
317
+ 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);
318
+
319
+ } else { throw e; }
320
+ }
321
+ }
322
+
323
+ const bytes = await module.arrayBuffer();
324
+ return await WebAssembly.instantiate(bytes, imports);
325
+ } else {
326
+ const instance = await WebAssembly.instantiate(module, imports);
327
+
328
+ if (instance instanceof WebAssembly.Instance) {
329
+ return { instance, module };
330
+ } else {
331
+ return instance;
332
+ }
333
+ }
334
+
335
+ function expectedResponseType(type) {
336
+ switch (type) {
337
+ case 'basic': case 'cors': case 'default': return true;
338
+ }
339
+ return false;
340
+ }
341
+ }
342
+
343
+ function initSync(module) {
344
+ if (wasm !== undefined) return wasm;
345
+
346
+
347
+ if (module !== undefined) {
348
+ if (Object.getPrototypeOf(module) === Object.prototype) {
349
+ ({module} = module)
350
+ } else {
351
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
352
+ }
353
+ }
354
+
355
+ const imports = __wbg_get_imports();
356
+ if (!(module instanceof WebAssembly.Module)) {
357
+ module = new WebAssembly.Module(module);
358
+ }
359
+ const instance = new WebAssembly.Instance(module, imports);
360
+ return __wbg_finalize_init(instance, module);
361
+ }
362
+
363
+ async function __wbg_init(module_or_path) {
364
+ if (wasm !== undefined) return wasm;
365
+
366
+
367
+ if (module_or_path !== undefined) {
368
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
369
+ ({module_or_path} = module_or_path)
370
+ } else {
371
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
372
+ }
373
+ }
374
+
375
+ if (module_or_path === undefined) {
376
+ module_or_path = new URL('fratm_wasm_bg.wasm', import.meta.url);
377
+ }
378
+ const imports = __wbg_get_imports();
379
+
380
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
381
+ module_or_path = fetch(module_or_path);
382
+ }
383
+
384
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
385
+
386
+ return __wbg_finalize_init(instance, module);
387
+ }
388
+
389
+ export { initSync, __wbg_init as default };
Binary file
package/web.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export type { CompileOptions, CompileResult, FormatResult, FratmError, SourceMapV3 } from './index.js';
2
+ import type { CompileOptions, CompileResult, FormatResult } from './index.js';
3
+
4
+ /**
5
+ * Loads the WebAssembly module. By default it is fetched next to this file;
6
+ * pass a URL, a Response or a compiled WebAssembly.Module to load it yourself.
7
+ */
8
+ export function init(input?: string | URL | Request | Response | BufferSource | WebAssembly.Module): Promise<void>;
9
+ export function compile(source: string, options?: CompileOptions): CompileResult;
10
+ export function format(source: string): FormatResult;
11
+ export function version(): string;
12
+ export function runtimeError(error: unknown): string;