woxi-wasm 0.2.0 → 0.4.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.
package/pkg/woxi.js CHANGED
@@ -1,312 +1,86 @@
1
+ /* @ts-self-types="./woxi.d.ts" */
1
2
 
2
- let imports = {};
3
- imports['__wbindgen_placeholder__'] = module.exports;
4
-
5
- function debugString(val) {
6
- // primitive types
7
- const type = typeof val;
8
- if (type == 'number' || type == 'boolean' || val == null) {
9
- return `${val}`;
10
- }
11
- if (type == 'string') {
12
- return `"${val}"`;
13
- }
14
- if (type == 'symbol') {
15
- const description = val.description;
16
- if (description == null) {
17
- return 'Symbol';
18
- } else {
19
- return `Symbol(${description})`;
20
- }
21
- }
22
- if (type == 'function') {
23
- const name = val.name;
24
- if (typeof name == 'string' && name.length > 0) {
25
- return `Function(${name})`;
26
- } else {
27
- return 'Function';
28
- }
29
- }
30
- // objects
31
- if (Array.isArray(val)) {
32
- const length = val.length;
33
- let debug = '[';
34
- if (length > 0) {
35
- debug += debugString(val[0]);
36
- }
37
- for(let i = 1; i < length; i++) {
38
- debug += ', ' + debugString(val[i]);
39
- }
40
- debug += ']';
41
- return debug;
42
- }
43
- // Test for built-in
44
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
45
- let className;
46
- if (builtInMatches && builtInMatches.length > 1) {
47
- className = builtInMatches[1];
48
- } else {
49
- // Failed to match the standard '[object ClassName]'
50
- return toString.call(val);
51
- }
52
- if (className == 'Object') {
53
- // we're a user defined class or Object
54
- // JSON.stringify avoids problems with cycles, and is generally much
55
- // easier than looping through ownProperties of `val`.
56
- try {
57
- return 'Object(' + JSON.stringify(val) + ')';
58
- } catch (_) {
59
- return 'Object';
60
- }
61
- }
62
- // errors
63
- if (val instanceof Error) {
64
- return `${val.name}: ${val.message}\n${val.stack}`;
65
- }
66
- // TODO we could test for more things here, like `Set`s and `Map`s.
67
- return className;
68
- }
69
-
70
- let WASM_VECTOR_LEN = 0;
71
-
72
- let cachedUint8ArrayMemory0 = null;
73
-
74
- function getUint8ArrayMemory0() {
75
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
76
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
77
- }
78
- return cachedUint8ArrayMemory0;
79
- }
80
-
81
- const cachedTextEncoder = new TextEncoder();
82
-
83
- if (!('encodeInto' in cachedTextEncoder)) {
84
- cachedTextEncoder.encodeInto = function (arg, view) {
85
- const buf = cachedTextEncoder.encode(arg);
86
- view.set(buf);
87
- return {
88
- read: arg.length,
89
- written: buf.length
90
- };
91
- }
92
- }
93
-
94
- function passStringToWasm0(arg, malloc, realloc) {
95
-
96
- if (realloc === undefined) {
97
- const buf = cachedTextEncoder.encode(arg);
98
- const ptr = malloc(buf.length, 1) >>> 0;
99
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
100
- WASM_VECTOR_LEN = buf.length;
101
- return ptr;
102
- }
103
-
104
- let len = arg.length;
105
- let ptr = malloc(len, 1) >>> 0;
106
-
107
- const mem = getUint8ArrayMemory0();
108
-
109
- let offset = 0;
110
-
111
- for (; offset < len; offset++) {
112
- const code = arg.charCodeAt(offset);
113
- if (code > 0x7F) break;
114
- mem[ptr + offset] = code;
115
- }
116
-
117
- if (offset !== len) {
118
- if (offset !== 0) {
119
- arg = arg.slice(offset);
120
- }
121
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
122
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
123
- const ret = cachedTextEncoder.encodeInto(arg, view);
124
-
125
- offset += ret.written;
126
- ptr = realloc(ptr, len, offset, 1) >>> 0;
127
- }
128
-
129
- WASM_VECTOR_LEN = offset;
130
- return ptr;
131
- }
132
-
133
- let cachedDataViewMemory0 = null;
134
-
135
- function getDataViewMemory0() {
136
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
137
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
138
- }
139
- return cachedDataViewMemory0;
140
- }
141
-
142
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
143
-
144
- cachedTextDecoder.decode();
145
-
146
- function decodeText(ptr, len) {
147
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
148
- }
149
-
150
- function getStringFromWasm0(ptr, len) {
151
- ptr = ptr >>> 0;
152
- return decodeText(ptr, len);
153
- }
154
-
155
- function addToExternrefTable0(obj) {
156
- const idx = wasm.__externref_table_alloc();
157
- wasm.__wbindgen_externrefs.set(idx, obj);
158
- return idx;
159
- }
160
-
161
- function handleError(f, args) {
162
- try {
163
- return f.apply(this, args);
164
- } catch (e) {
165
- const idx = addToExternrefTable0(e);
166
- wasm.__wbindgen_exn_store(idx);
167
- }
168
- }
169
-
170
- function isLikeNone(x) {
171
- return x === undefined || x === null;
172
- }
173
-
174
- function getArrayU8FromWasm0(ptr, len) {
175
- ptr = ptr >>> 0;
176
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
177
- }
178
3
  /**
179
- * Return the playable audio (base64-encoded) from the last `evaluate()`
180
- * call, if any. Returns an empty string when there is no sound.
181
- * @returns {string}
4
+ * Clear all interpreter state (variables and function definitions).
182
5
  */
183
- exports.get_sound = function() {
184
- let deferred1_0;
185
- let deferred1_1;
186
- try {
187
- const ret = wasm.get_sound();
188
- deferred1_0 = ret[0];
189
- deferred1_1 = ret[1];
190
- return getStringFromWasm0(ret[0], ret[1]);
191
- } finally {
192
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
193
- }
194
- };
6
+ function clear() {
7
+ wasm.clear();
8
+ }
9
+ exports.clear = clear;
195
10
 
196
11
  /**
197
12
  * Remove all host-registered in-memory files.
198
13
  */
199
- exports.clear_virtual_files = function() {
14
+ function clear_virtual_files() {
200
15
  wasm.clear_virtual_files();
201
- };
16
+ }
17
+ exports.clear_virtual_files = clear_virtual_files;
202
18
 
203
19
  /**
204
- * Return SVG rendering of the last text result (with superscripts etc.).
205
- * Returns an empty string when there is no output SVG (e.g. for Graphics results).
20
+ * Evaluate a Wolfram Language expression and return the result.
21
+ * If the expression produces Print output, it is prepended to the result.
22
+ * @param {string} input
206
23
  * @returns {string}
207
24
  */
208
- exports.get_output_svg = function() {
209
- let deferred1_0;
210
- let deferred1_1;
25
+ function evaluate(input) {
26
+ let deferred2_0;
27
+ let deferred2_1;
211
28
  try {
212
- const ret = wasm.get_output_svg();
213
- deferred1_0 = ret[0];
214
- deferred1_1 = ret[1];
29
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
30
+ const len0 = WASM_VECTOR_LEN;
31
+ const ret = wasm.evaluate(ptr0, len0);
32
+ deferred2_0 = ret[0];
33
+ deferred2_1 = ret[1];
215
34
  return getStringFromWasm0(ret[0], ret[1]);
216
35
  } finally {
217
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
36
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
218
37
  }
219
- };
38
+ }
39
+ exports.evaluate = evaluate;
220
40
 
221
41
  /**
222
- * Split `input` into top-level statements and return a JSON array of strings.
223
- * Lets the front-end loop one statement at a time so output (and side
224
- * effects like `Pause[n]`) appear progressively rather than batched.
42
+ * Evaluate all top-level statements and return a JSON array of output items.
43
+ * Each item has a "type" field ("text", "graphics", "print", "warning", "error",
44
+ * "manipulate") and corresponding content fields.
225
45
  * @param {string} input
226
46
  * @returns {string}
227
47
  */
228
- exports.split_statements = function(input) {
48
+ function evaluate_all(input) {
229
49
  let deferred2_0;
230
50
  let deferred2_1;
231
51
  try {
232
52
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
233
53
  const len0 = WASM_VECTOR_LEN;
234
- const ret = wasm.split_statements(ptr0, len0);
54
+ const ret = wasm.evaluate_all(ptr0, len0);
235
55
  deferred2_0 = ret[0];
236
56
  deferred2_1 = ret[1];
237
57
  return getStringFromWasm0(ret[0], ret[1]);
238
58
  } finally {
239
59
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
240
60
  }
241
- };
242
-
243
- function passArray8ToWasm0(arg, malloc) {
244
- const ptr = malloc(arg.length * 1, 1) >>> 0;
245
- getUint8ArrayMemory0().set(arg, ptr / 1);
246
- WASM_VECTOR_LEN = arg.length;
247
- return ptr;
248
61
  }
249
- /**
250
- * Register (or replace) an in-memory file so `Import["name"]` can read it
251
- * in the browser.
252
- * @param {string} name
253
- * @param {Uint8Array} data
254
- */
255
- exports.set_virtual_file = function(name, data) {
256
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
257
- const len0 = WASM_VECTOR_LEN;
258
- const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
259
- const len1 = WASM_VECTOR_LEN;
260
- wasm.set_virtual_file(ptr0, len0, ptr1, len1);
261
- };
62
+ exports.evaluate_all = evaluate_all;
262
63
 
263
64
  /**
264
- * Render a Manipulate body, its extra display elements, and any pending
265
- * interactive write-backs in one call. Used by widgets that have display
266
- * elements (e.g. a `Checkbox` grid) that both read and rewrite shared
267
- * state.
268
- *
269
- * `displays_json` and `mutations_json` are JSON string arrays. Each
270
- * mutation is an assignment (e.g. `data[[3, 5]] = 1`) applied before the
271
- * re-render; the updated value of every mutated variable is returned under
272
- * `state` so the frontend can keep its binding set in sync.
273
- *
274
- * The result is `{"output":{svg|text|textSvg}, "displays":[<tree>…],
275
- * "state":{name:value,…}}`.
276
- * @param {string} body
277
- * @param {string} displays_json
278
- * @param {string} bindings_json
279
- * @param {string} mutations_json
65
+ * Evaluate, returning only the final expression result (no Print output).
66
+ * @param {string} input
280
67
  * @returns {string}
281
68
  */
282
- exports.evaluate_manipulate_full = function(body, displays_json, bindings_json, mutations_json) {
283
- let deferred5_0;
284
- let deferred5_1;
69
+ function evaluate_expr(input) {
70
+ let deferred2_0;
71
+ let deferred2_1;
285
72
  try {
286
- const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
73
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
287
74
  const len0 = WASM_VECTOR_LEN;
288
- const ptr1 = passStringToWasm0(displays_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
289
- const len1 = WASM_VECTOR_LEN;
290
- const ptr2 = passStringToWasm0(bindings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
291
- const len2 = WASM_VECTOR_LEN;
292
- const ptr3 = passStringToWasm0(mutations_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
293
- const len3 = WASM_VECTOR_LEN;
294
- const ret = wasm.evaluate_manipulate_full(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
295
- deferred5_0 = ret[0];
296
- deferred5_1 = ret[1];
75
+ const ret = wasm.evaluate_expr(ptr0, len0);
76
+ deferred2_0 = ret[0];
77
+ deferred2_1 = ret[1];
297
78
  return getStringFromWasm0(ret[0], ret[1]);
298
79
  } finally {
299
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
80
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
300
81
  }
301
- };
302
-
303
- /**
304
- * Enable or disable dark mode for SVG output colors.
305
- * @param {boolean} enabled
306
- */
307
- exports.set_dark_mode = function(enabled) {
308
- wasm.set_dark_mode(enabled);
309
- };
82
+ }
83
+ exports.evaluate_expr = evaluate_expr;
310
84
 
311
85
  /**
312
86
  * Evaluate a Manipulate body with a specific set of variable bindings
@@ -323,7 +97,7 @@ exports.set_dark_mode = function(enabled) {
323
97
  * @param {string} bindings_json
324
98
  * @returns {string}
325
99
  */
326
- exports.evaluate_manipulate = function(body, bindings_json) {
100
+ function evaluate_manipulate(body, bindings_json) {
327
101
  let deferred3_0;
328
102
  let deferred3_1;
329
103
  try {
@@ -338,54 +112,8 @@ exports.evaluate_manipulate = function(body, bindings_json) {
338
112
  } finally {
339
113
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
340
114
  }
341
- };
342
-
343
- /**
344
- * Evaluate all top-level statements and return a JSON array of output items.
345
- * Each item has a "type" field ("text", "graphics", "print", "warning", "error",
346
- * "manipulate") and corresponding content fields.
347
- * @param {string} input
348
- * @returns {string}
349
- */
350
- exports.evaluate_all = function(input) {
351
- let deferred2_0;
352
- let deferred2_1;
353
- try {
354
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
355
- const len0 = WASM_VECTOR_LEN;
356
- const ret = wasm.evaluate_all(ptr0, len0);
357
- deferred2_0 = ret[0];
358
- deferred2_1 = ret[1];
359
- return getStringFromWasm0(ret[0], ret[1]);
360
- } finally {
361
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
362
- }
363
- };
364
-
365
- /**
366
- * Return the captured GraphicsBox expression from the last `evaluate()` call.
367
- * Returns an empty string when there is no graphics output.
368
- * @returns {string}
369
- */
370
- exports.get_graphicsbox = function() {
371
- let deferred1_0;
372
- let deferred1_1;
373
- try {
374
- const ret = wasm.get_graphicsbox();
375
- deferred1_0 = ret[0];
376
- deferred1_1 = ret[1];
377
- return getStringFromWasm0(ret[0], ret[1]);
378
- } finally {
379
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
380
- }
381
- };
382
-
383
- /**
384
- * Clear all interpreter state (variables and function definitions).
385
- */
386
- exports.clear = function() {
387
- wasm.clear();
388
- };
115
+ }
116
+ exports.evaluate_manipulate = evaluate_manipulate;
389
117
 
390
118
  /**
391
119
  * Evaluate each Manipulate control's `Enabled` condition against a binding
@@ -394,13 +122,13 @@ exports.clear = function() {
394
122
  * `conditions_json` is a JSON string array aligned with the control list;
395
123
  * an empty string marks a control with no condition (always enabled).
396
124
  * `bindings_json` is the same JSON object of variable bindings used by
397
- * `evaluate_manipulate`. Used by the Playground to grey out controls that a
125
+ * `evaluate_manipulate`. Used by the Playground to gray out controls that a
398
126
  * `Enabled -> Dynamic[…]` option has switched off for the current state.
399
127
  * @param {string} conditions_json
400
128
  * @param {string} bindings_json
401
129
  * @returns {string}
402
130
  */
403
- exports.evaluate_manipulate_enabled = function(conditions_json, bindings_json) {
131
+ function evaluate_manipulate_enabled(conditions_json, bindings_json) {
404
132
  let deferred3_0;
405
133
  let deferred3_1;
406
134
  try {
@@ -413,9 +141,51 @@ exports.evaluate_manipulate_enabled = function(conditions_json, bindings_json) {
413
141
  deferred3_1 = ret[1];
414
142
  return getStringFromWasm0(ret[0], ret[1]);
415
143
  } finally {
416
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
144
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
145
+ }
146
+ }
147
+ exports.evaluate_manipulate_enabled = evaluate_manipulate_enabled;
148
+
149
+ /**
150
+ * Render a Manipulate body, its extra display elements, and any pending
151
+ * interactive write-backs in one call. Used by widgets that have display
152
+ * elements (e.g. a `Checkbox` grid) that both read and rewrite shared
153
+ * state.
154
+ *
155
+ * `displays_json` and `mutations_json` are JSON string arrays. Each
156
+ * mutation is an assignment (e.g. `data[[3, 5]] = 1`) applied before the
157
+ * re-render; the updated value of every mutated variable is returned under
158
+ * `state` so the frontend can keep its binding set in sync.
159
+ *
160
+ * The result is `{"output":{svg|text|textSvg}, "displays":[<tree>…],
161
+ * "state":{name:value,…}}`.
162
+ * @param {string} body
163
+ * @param {string} displays_json
164
+ * @param {string} bindings_json
165
+ * @param {string} mutations_json
166
+ * @returns {string}
167
+ */
168
+ function evaluate_manipulate_full(body, displays_json, bindings_json, mutations_json) {
169
+ let deferred5_0;
170
+ let deferred5_1;
171
+ try {
172
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
173
+ const len0 = WASM_VECTOR_LEN;
174
+ const ptr1 = passStringToWasm0(displays_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
175
+ const len1 = WASM_VECTOR_LEN;
176
+ const ptr2 = passStringToWasm0(bindings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
177
+ const len2 = WASM_VECTOR_LEN;
178
+ const ptr3 = passStringToWasm0(mutations_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
179
+ const len3 = WASM_VECTOR_LEN;
180
+ const ret = wasm.evaluate_manipulate_full(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
181
+ deferred5_0 = ret[0];
182
+ deferred5_1 = ret[1];
183
+ return getStringFromWasm0(ret[0], ret[1]);
184
+ } finally {
185
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
417
186
  }
418
- };
187
+ }
188
+ exports.evaluate_manipulate_full = evaluate_manipulate_full;
419
189
 
420
190
  /**
421
191
  * Evaluate a single statement and return a JSON array of output items
@@ -424,7 +194,7 @@ exports.evaluate_manipulate_enabled = function(conditions_json, bindings_json) {
424
194
  * @param {string} stmt
425
195
  * @returns {string}
426
196
  */
427
- exports.evaluate_statement = function(stmt) {
197
+ function evaluate_statement(stmt) {
428
198
  let deferred2_0;
429
199
  let deferred2_1;
430
200
  try {
@@ -437,422 +207,589 @@ exports.evaluate_statement = function(stmt) {
437
207
  } finally {
438
208
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
439
209
  }
440
- };
210
+ }
211
+ exports.evaluate_statement = evaluate_statement;
441
212
 
442
213
  /**
443
- * Evaluate, returning only the final expression result (no Print output).
444
- * @param {string} input
214
+ * Return the captured SVG graphics from the last `evaluate()` call, if any.
215
+ * Returns an empty string when there is no graphics output.
445
216
  * @returns {string}
446
217
  */
447
- exports.evaluate_expr = function(input) {
448
- let deferred2_0;
449
- let deferred2_1;
218
+ function get_graphics() {
219
+ let deferred1_0;
220
+ let deferred1_1;
450
221
  try {
451
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
452
- const len0 = WASM_VECTOR_LEN;
453
- const ret = wasm.evaluate_expr(ptr0, len0);
454
- deferred2_0 = ret[0];
455
- deferred2_1 = ret[1];
222
+ const ret = wasm.get_graphics();
223
+ deferred1_0 = ret[0];
224
+ deferred1_1 = ret[1];
456
225
  return getStringFromWasm0(ret[0], ret[1]);
457
226
  } finally {
458
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
227
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
459
228
  }
460
- };
229
+ }
230
+ exports.get_graphics = get_graphics;
461
231
 
462
232
  /**
463
- * Return warnings from the last `evaluate()` call as newline-separated text.
464
- * Returns an empty string when there are no warnings.
233
+ * Return the playable audio (base64-encoded) from the last `evaluate()`
234
+ * call, if any. Returns an empty string when there is no sound.
465
235
  * @returns {string}
466
236
  */
467
- exports.get_warnings = function() {
237
+ function get_sound() {
468
238
  let deferred1_0;
469
239
  let deferred1_1;
470
240
  try {
471
- const ret = wasm.get_warnings();
241
+ const ret = wasm.get_sound();
472
242
  deferred1_0 = ret[0];
473
243
  deferred1_1 = ret[1];
474
244
  return getStringFromWasm0(ret[0], ret[1]);
475
245
  } finally {
476
246
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
477
247
  }
478
- };
248
+ }
249
+ exports.get_sound = get_sound;
479
250
 
480
251
  /**
481
- * Return the captured SVG graphics from the last `evaluate()` call, if any.
482
- * Returns an empty string when there is no graphics output.
252
+ * Return warnings from the last `evaluate()` call as newline-separated text.
253
+ * Returns an empty string when there are no warnings.
483
254
  * @returns {string}
484
255
  */
485
- exports.get_graphics = function() {
256
+ function get_warnings() {
486
257
  let deferred1_0;
487
258
  let deferred1_1;
488
259
  try {
489
- const ret = wasm.get_graphics();
260
+ const ret = wasm.get_warnings();
490
261
  deferred1_0 = ret[0];
491
262
  deferred1_1 = ret[1];
492
263
  return getStringFromWasm0(ret[0], ret[1]);
493
264
  } finally {
494
265
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
495
266
  }
496
- };
267
+ }
268
+ exports.get_warnings = get_warnings;
497
269
 
498
- exports.init = function() {
270
+ function init() {
499
271
  wasm.init();
500
- };
272
+ }
273
+ exports.init = init;
501
274
 
502
275
  /**
503
- * Evaluate a Wolfram Language expression and return the result.
504
- * If the expression produces Print output, it is prepended to the result.
276
+ * Enable or disable dark mode for SVG output colors.
277
+ * @param {boolean} enabled
278
+ */
279
+ function set_dark_mode(enabled) {
280
+ wasm.set_dark_mode(enabled);
281
+ }
282
+ exports.set_dark_mode = set_dark_mode;
283
+
284
+ /**
285
+ * Register (or replace) an in-memory file so `Import["name"]` can read it
286
+ * in the browser.
287
+ * @param {string} name
288
+ * @param {Uint8Array} data
289
+ */
290
+ function set_virtual_file(name, data) {
291
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
294
+ const len1 = WASM_VECTOR_LEN;
295
+ wasm.set_virtual_file(ptr0, len0, ptr1, len1);
296
+ }
297
+ exports.set_virtual_file = set_virtual_file;
298
+
299
+ /**
300
+ * Split `input` into top-level statements and return a JSON array of strings.
301
+ * Lets the front-end loop one statement at a time so output (and side
302
+ * effects like `Pause[n]`) appear progressively rather than batched.
505
303
  * @param {string} input
506
304
  * @returns {string}
507
305
  */
508
- exports.evaluate = function(input) {
306
+ function split_statements(input) {
509
307
  let deferred2_0;
510
308
  let deferred2_1;
511
309
  try {
512
310
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
513
311
  const len0 = WASM_VECTOR_LEN;
514
- const ret = wasm.evaluate(ptr0, len0);
312
+ const ret = wasm.split_statements(ptr0, len0);
515
313
  deferred2_0 = ret[0];
516
314
  deferred2_1 = ret[1];
517
315
  return getStringFromWasm0(ret[0], ret[1]);
518
316
  } finally {
519
317
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
520
318
  }
521
- };
319
+ }
320
+ exports.split_statements = split_statements;
522
321
 
523
- exports.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
524
- const ret = debugString(arg1);
525
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
526
- const len1 = WASM_VECTOR_LEN;
527
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
528
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
529
- };
530
-
531
- exports.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
532
- const ret = typeof(arg0) === 'function';
533
- return ret;
534
- };
535
-
536
- exports.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
537
- const val = arg0;
538
- const ret = typeof(val) === 'object' && val !== null;
539
- return ret;
540
- };
541
-
542
- exports.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
543
- const ret = typeof(arg0) === 'string';
544
- return ret;
545
- };
546
-
547
- exports.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
548
- const ret = arg0 === undefined;
549
- return ret;
550
- };
551
-
552
- exports.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
553
- throw new Error(getStringFromWasm0(arg0, arg1));
554
- };
555
-
556
- exports.__wbg___woxi_fetch_url_a5ed8b2ee9da4ed7 = function() { return handleError(function (arg0, arg1, arg2) {
557
- const ret = __woxi_fetch_url(getStringFromWasm0(arg1, arg2));
558
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
559
- const len1 = WASM_VECTOR_LEN;
560
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
561
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
562
- }, arguments) };
563
-
564
- exports.__wbg___woxi_report_panic_be5ad4a7b740d1b8 = function() { return handleError(function (arg0, arg1) {
565
- __woxi_report_panic(getStringFromWasm0(arg0, arg1));
566
- }, arguments) };
567
-
568
- exports.__wbg_append_ed363d026656dfbd = function() { return handleError(function (arg0, arg1) {
569
- arg0.append(arg1);
570
- }, arguments) };
571
-
572
- exports.__wbg_body_8c26b54829a0c4cb = function(arg0) {
573
- const ret = arg0.body;
574
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
575
- };
576
-
577
- exports.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
578
- const ret = arg0.call(arg1, arg2);
579
- return ret;
580
- }, arguments) };
581
-
582
- exports.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
583
- const ret = arg0.call(arg1);
584
- return ret;
585
- }, arguments) };
586
-
587
- exports.__wbg_createElement_964ab674a0176cd8 = function() { return handleError(function (arg0, arg1, arg2) {
588
- const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
589
- return ret;
590
- }, arguments) };
591
-
592
- exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
593
- const ret = arg0.crypto;
594
- return ret;
595
- };
596
-
597
- exports.__wbg_document_725ae06eb442a6db = function(arg0) {
598
- const ret = arg0.document;
599
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
600
- };
601
-
602
- exports.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
603
- let deferred0_0;
604
- let deferred0_1;
322
+ /**
323
+ * Return every file produced by `Export` since the last call as a JSON array
324
+ * of `{"name":…, "data":<base64>[, "rasterize":"png"]}`, then clear the store.
325
+ * The host decodes each base64 payload into a Blob and renders a download
326
+ * link; entries carrying `rasterize` hold SVG the host converts to that raster
327
+ * format first. Draining on read keeps each evaluation's exports separate.
328
+ * @returns {string}
329
+ */
330
+ function take_exported_files() {
331
+ let deferred1_0;
332
+ let deferred1_1;
605
333
  try {
606
- deferred0_0 = arg0;
607
- deferred0_1 = arg1;
608
- console.error(getStringFromWasm0(arg0, arg1));
334
+ const ret = wasm.take_exported_files();
335
+ deferred1_0 = ret[0];
336
+ deferred1_1 = ret[1];
337
+ return getStringFromWasm0(ret[0], ret[1]);
609
338
  } finally {
610
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
339
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
611
340
  }
612
- };
613
-
614
- exports.__wbg_getDate_5a70d2f6a482d99f = function(arg0) {
615
- const ret = arg0.getDate();
616
- return ret;
617
- };
618
-
619
- exports.__wbg_getFullYear_8240d5a15191feae = function(arg0) {
620
- const ret = arg0.getFullYear();
621
- return ret;
622
- };
623
-
624
- exports.__wbg_getHours_5e476e0b9ebc42d1 = function(arg0) {
625
- const ret = arg0.getHours();
626
- return ret;
627
- };
628
-
629
- exports.__wbg_getMilliseconds_9fc7184d90e04a16 = function(arg0) {
630
- const ret = arg0.getMilliseconds();
631
- return ret;
632
- };
633
-
634
- exports.__wbg_getMinutes_c95dfb65f1ea8f02 = function(arg0) {
635
- const ret = arg0.getMinutes();
636
- return ret;
637
- };
638
-
639
- exports.__wbg_getMonth_25c1c5a601d72773 = function(arg0) {
640
- const ret = arg0.getMonth();
641
- return ret;
642
- };
643
-
644
- exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
645
- arg0.getRandomValues(arg1);
646
- }, arguments) };
647
-
648
- exports.__wbg_getSeconds_8113bf8709718eb2 = function(arg0) {
649
- const ret = arg0.getSeconds();
650
- return ret;
651
- };
652
-
653
- exports.__wbg_getTime_14776bfb48a1bff9 = function(arg0) {
654
- const ret = arg0.getTime();
655
- return ret;
656
- };
657
-
658
- exports.__wbg_getTimezoneOffset_d391cb11d54969f8 = function(arg0) {
659
- const ret = arg0.getTimezoneOffset();
660
- return ret;
661
- };
662
-
663
- exports.__wbg_instanceof_HtmlElement_e20a729df22f9e1c = function(arg0) {
664
- let result;
665
- try {
666
- result = arg0 instanceof HTMLElement;
667
- } catch (_) {
668
- result = false;
341
+ }
342
+ exports.take_exported_files = take_exported_files;
343
+ function __wbg_get_imports() {
344
+ const import0 = {
345
+ __proto__: null,
346
+ __wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
347
+ const ret = debugString(arg1);
348
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
349
+ const len1 = WASM_VECTOR_LEN;
350
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
351
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
352
+ },
353
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
354
+ const ret = typeof(arg0) === 'function';
355
+ return ret;
356
+ },
357
+ __wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
358
+ const val = arg0;
359
+ const ret = typeof(val) === 'object' && val !== null;
360
+ return ret;
361
+ },
362
+ __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
363
+ const ret = typeof(arg0) === 'string';
364
+ return ret;
365
+ },
366
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
367
+ const ret = arg0 === undefined;
368
+ return ret;
369
+ },
370
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
371
+ throw new Error(getStringFromWasm0(arg0, arg1));
372
+ },
373
+ __wbg___woxi_fetch_url_168031ca5a4c2c20: function() { return handleError(function (arg0, arg1, arg2) {
374
+ const ret = __woxi_fetch_url(getStringFromWasm0(arg1, arg2));
375
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
376
+ const len1 = WASM_VECTOR_LEN;
377
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
378
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
379
+ }, arguments); },
380
+ __wbg___woxi_report_panic_0d15031b779e8727: function() { return handleError(function (arg0, arg1) {
381
+ __woxi_report_panic(getStringFromWasm0(arg0, arg1));
382
+ }, arguments); },
383
+ __wbg_append_c2f0f7a240a1df4f: function() { return handleError(function (arg0, arg1) {
384
+ arg0.append(arg1);
385
+ }, arguments); },
386
+ __wbg_body_e549239eaff082e1: function(arg0) {
387
+ const ret = arg0.body;
388
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
389
+ },
390
+ __wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
391
+ const ret = arg0.call(arg1, arg2);
392
+ return ret;
393
+ }, arguments); },
394
+ __wbg_createElement_74049073a11f9c31: function() { return handleError(function (arg0, arg1, arg2) {
395
+ const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
396
+ return ret;
397
+ }, arguments); },
398
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
399
+ const ret = arg0.crypto;
400
+ return ret;
401
+ },
402
+ __wbg_document_9854e03c05fc8834: function(arg0) {
403
+ const ret = arg0.document;
404
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
405
+ },
406
+ __wbg_error_757e9472f8410341: function(arg0, arg1) {
407
+ let deferred0_0;
408
+ let deferred0_1;
409
+ try {
410
+ deferred0_0 = arg0;
411
+ deferred0_1 = arg1;
412
+ console.error(getStringFromWasm0(arg0, arg1));
413
+ } finally {
414
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
415
+ }
416
+ },
417
+ __wbg_getDate_1181c785ea4fdd21: function(arg0) {
418
+ const ret = arg0.getDate();
419
+ return ret;
420
+ },
421
+ __wbg_getFullYear_32050b2c56c56cd8: function(arg0) {
422
+ const ret = arg0.getFullYear();
423
+ return ret;
424
+ },
425
+ __wbg_getHours_f57dcda3efee150c: function(arg0) {
426
+ const ret = arg0.getHours();
427
+ return ret;
428
+ },
429
+ __wbg_getMilliseconds_041f71bbf3fde00e: function(arg0) {
430
+ const ret = arg0.getMilliseconds();
431
+ return ret;
432
+ },
433
+ __wbg_getMinutes_951e7f98fc4fdb30: function(arg0) {
434
+ const ret = arg0.getMinutes();
435
+ return ret;
436
+ },
437
+ __wbg_getMonth_aae5f530fd173536: function(arg0) {
438
+ const ret = arg0.getMonth();
439
+ return ret;
440
+ },
441
+ __wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
442
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
443
+ }, arguments); },
444
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
445
+ arg0.getRandomValues(arg1);
446
+ }, arguments); },
447
+ __wbg_getSeconds_8ffcca0e220547af: function(arg0) {
448
+ const ret = arg0.getSeconds();
449
+ return ret;
450
+ },
451
+ __wbg_getTime_f5a55efff2585d5d: function(arg0) {
452
+ const ret = arg0.getTime();
453
+ return ret;
454
+ },
455
+ __wbg_getTimezoneOffset_2e851fdaecc2dc92: function(arg0) {
456
+ const ret = arg0.getTimezoneOffset();
457
+ return ret;
458
+ },
459
+ __wbg_instanceof_HtmlElement_32fb153a5a0e2349: function(arg0) {
460
+ let result;
461
+ try {
462
+ result = arg0 instanceof HTMLElement;
463
+ } catch (_) {
464
+ result = false;
465
+ }
466
+ const ret = result;
467
+ return ret;
468
+ },
469
+ __wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
470
+ let result;
471
+ try {
472
+ result = arg0 instanceof Window;
473
+ } catch (_) {
474
+ result = false;
475
+ }
476
+ const ret = result;
477
+ return ret;
478
+ },
479
+ __wbg_length_7f3c00c40364105e: function(arg0) {
480
+ const ret = arg0.length;
481
+ return ret;
482
+ },
483
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
484
+ const ret = arg0.msCrypto;
485
+ return ret;
486
+ },
487
+ __wbg_new_0_72d020f0c63443d4: function() {
488
+ const ret = new Date();
489
+ return ret;
490
+ },
491
+ __wbg_new_227d7c05414eb861: function() {
492
+ const ret = new Error();
493
+ return ret;
494
+ },
495
+ __wbg_new_34e56228080aa9f8: function(arg0) {
496
+ const ret = new Date(arg0);
497
+ return ret;
498
+ },
499
+ __wbg_new_with_length_3da0ad195f6f63ba: function(arg0) {
500
+ const ret = new Uint8Array(arg0 >>> 0);
501
+ return ret;
502
+ },
503
+ __wbg_new_with_year_month_day_0d952a48f939d06b: function(arg0, arg1, arg2) {
504
+ const ret = new Date(arg0 >>> 0, arg1, arg2);
505
+ return ret;
506
+ },
507
+ __wbg_node_84ea875411254db1: function(arg0) {
508
+ const ret = arg0.node;
509
+ return ret;
510
+ },
511
+ __wbg_now_aa4ccb83129e9e55: function() {
512
+ const ret = Date.now();
513
+ return ret;
514
+ },
515
+ __wbg_now_e7c6795a7f81e10f: function(arg0) {
516
+ const ret = arg0.now();
517
+ return ret;
518
+ },
519
+ __wbg_offsetHeight_427aaf53442f1586: function(arg0) {
520
+ const ret = arg0.offsetHeight;
521
+ return ret;
522
+ },
523
+ __wbg_offsetWidth_1d736667aa04ab3a: function(arg0) {
524
+ const ret = arg0.offsetWidth;
525
+ return ret;
526
+ },
527
+ __wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
528
+ const ret = arg0.performance;
529
+ return ret;
530
+ },
531
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
532
+ const ret = arg0.process;
533
+ return ret;
534
+ },
535
+ __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
536
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
537
+ },
538
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
539
+ arg0.randomFillSync(arg1);
540
+ }, arguments); },
541
+ __wbg_remove_9a5288388316028c: function(arg0) {
542
+ arg0.remove();
543
+ },
544
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
545
+ const ret = module.require;
546
+ return ret;
547
+ }, arguments); },
548
+ __wbg_setAttribute_9e7d603908f63705: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
549
+ arg0.setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
550
+ }, arguments); },
551
+ __wbg_set_textContent_6d6fc559f198055f: function(arg0, arg1, arg2) {
552
+ arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
553
+ },
554
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
555
+ const ret = arg1.stack;
556
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
557
+ const len1 = WASM_VECTOR_LEN;
558
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
559
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
560
+ },
561
+ __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
562
+ const ret = typeof global === 'undefined' ? null : global;
563
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
564
+ },
565
+ __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
566
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
567
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
568
+ },
569
+ __wbg_static_accessor_SELF_0b583911f537483a: function() {
570
+ const ret = typeof self === 'undefined' ? null : self;
571
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
572
+ },
573
+ __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
574
+ const ret = typeof window === 'undefined' ? null : window;
575
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
576
+ },
577
+ __wbg_subarray_002b94d5e13d1411: function(arg0, arg1, arg2) {
578
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
579
+ return ret;
580
+ },
581
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
582
+ const ret = arg0.versions;
583
+ return ret;
584
+ },
585
+ __wbindgen_generic_0000000000000001: function(arg0) {
586
+ // Cast intrinsic for `F64 -> Externref`.
587
+ const ret = arg0;
588
+ return ret;
589
+ },
590
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
591
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
592
+ const ret = getArrayU8FromWasm0(arg0, arg1);
593
+ return ret;
594
+ },
595
+ __wbindgen_generic_0000000000000003: function(arg0, arg1) {
596
+ // Cast intrinsic for `Ref(String) -> Externref`.
597
+ const ret = getStringFromWasm0(arg0, arg1);
598
+ return ret;
599
+ },
600
+ __wbindgen_init_externref_table: function() {
601
+ const table = wasm.__wbindgen_externrefs;
602
+ const offset = table.grow(4);
603
+ table.set(0, undefined);
604
+ table.set(offset + 0, undefined);
605
+ table.set(offset + 1, null);
606
+ table.set(offset + 2, true);
607
+ table.set(offset + 3, false);
608
+ },
609
+ };
610
+ return {
611
+ __proto__: null,
612
+ "./woxi_bg.js": import0,
613
+ };
614
+ }
615
+
616
+ function addToExternrefTable0(obj) {
617
+ const idx = wasm.__externref_table_alloc();
618
+ wasm.__wbindgen_externrefs.set(idx, obj);
619
+ return idx;
620
+ }
621
+
622
+ function debugString(val) {
623
+ // primitive types
624
+ const type = typeof val;
625
+ if (type == 'number' || type == 'boolean' || val == null) {
626
+ return `${val}`;
627
+ }
628
+ if (type == 'string') {
629
+ return `"${val}"`;
630
+ }
631
+ if (type == 'symbol') {
632
+ const description = val.description;
633
+ if (description == null) {
634
+ return 'Symbol';
635
+ } else {
636
+ return `Symbol(${description})`;
637
+ }
638
+ }
639
+ if (type == 'function') {
640
+ const name = val.name;
641
+ if (typeof name == 'string' && name.length > 0) {
642
+ return `Function(${name})`;
643
+ } else {
644
+ return 'Function';
645
+ }
646
+ }
647
+ // objects
648
+ if (Array.isArray(val)) {
649
+ const length = val.length;
650
+ let debug = '[';
651
+ if (length > 0) {
652
+ debug += debugString(val[0]);
653
+ }
654
+ for(let i = 1; i < length; i++) {
655
+ debug += ', ' + debugString(val[i]);
656
+ }
657
+ debug += ']';
658
+ return debug;
659
+ }
660
+ // Test for built-in
661
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
662
+ let className;
663
+ if (builtInMatches && builtInMatches.length > 1) {
664
+ className = builtInMatches[1];
665
+ } else {
666
+ // Failed to match the standard '[object ClassName]'
667
+ return toString.call(val);
668
+ }
669
+ if (className == 'Object') {
670
+ // we're a user defined class or Object
671
+ // JSON.stringify avoids problems with cycles, and is generally much
672
+ // easier than looping through ownProperties of `val`.
673
+ try {
674
+ return 'Object(' + JSON.stringify(val) + ')';
675
+ } catch (_) {
676
+ return 'Object';
677
+ }
678
+ }
679
+ // errors
680
+ if (val instanceof Error) {
681
+ return `${val.name}: ${val.message}\n${val.stack}`;
682
+ }
683
+ // TODO we could test for more things here, like `Set`s and `Map`s.
684
+ return className;
685
+ }
686
+
687
+ function getArrayU8FromWasm0(ptr, len) {
688
+ ptr = ptr >>> 0;
689
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
690
+ }
691
+
692
+ let cachedDataViewMemory0 = null;
693
+ function getDataViewMemory0() {
694
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
695
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
696
+ }
697
+ return cachedDataViewMemory0;
698
+ }
699
+
700
+ function getStringFromWasm0(ptr, len) {
701
+ return decodeText(ptr >>> 0, len);
702
+ }
703
+
704
+ let cachedUint8ArrayMemory0 = null;
705
+ function getUint8ArrayMemory0() {
706
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
707
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
669
708
  }
670
- const ret = result;
671
- return ret;
672
- };
709
+ return cachedUint8ArrayMemory0;
710
+ }
673
711
 
674
- exports.__wbg_instanceof_Window_4846dbb3de56c84c = function(arg0) {
675
- let result;
712
+ function handleError(f, args) {
676
713
  try {
677
- result = arg0 instanceof Window;
678
- } catch (_) {
679
- result = false;
714
+ return f.apply(this, args);
715
+ } catch (e) {
716
+ const idx = addToExternrefTable0(e);
717
+ wasm.__wbindgen_exn_store(idx);
680
718
  }
681
- const ret = result;
682
- return ret;
683
- };
684
-
685
- exports.__wbg_length_69bca3cb64fc8748 = function(arg0) {
686
- const ret = arg0.length;
687
- return ret;
688
- };
689
-
690
- exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
691
- const ret = arg0.msCrypto;
692
- return ret;
693
- };
694
-
695
- exports.__wbg_new_0_f9740686d739025c = function() {
696
- const ret = new Date();
697
- return ret;
698
- };
699
-
700
- exports.__wbg_new_8a6f238a6ece86ea = function() {
701
- const ret = new Error();
702
- return ret;
703
- };
704
-
705
- exports.__wbg_new_93d9417ed3fb115d = function(arg0) {
706
- const ret = new Date(arg0);
707
- return ret;
708
- };
709
-
710
- exports.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
711
- const ret = new Function(getStringFromWasm0(arg0, arg1));
712
- return ret;
713
- };
714
-
715
- exports.__wbg_new_with_length_01aa0dc35aa13543 = function(arg0) {
716
- const ret = new Uint8Array(arg0 >>> 0);
717
- return ret;
718
- };
719
-
720
- exports.__wbg_new_with_year_month_day_6236812cf591750d = function(arg0, arg1, arg2) {
721
- const ret = new Date(arg0 >>> 0, arg1, arg2);
722
- return ret;
723
- };
724
-
725
- exports.__wbg_node_905d3e251edff8a2 = function(arg0) {
726
- const ret = arg0.node;
727
- return ret;
728
- };
729
-
730
- exports.__wbg_now_2c95c9de01293173 = function(arg0) {
731
- const ret = arg0.now();
732
- return ret;
733
- };
734
-
735
- exports.__wbg_now_793306c526e2e3b6 = function() {
736
- const ret = Date.now();
737
- return ret;
738
- };
739
-
740
- exports.__wbg_offsetHeight_9cb4257b24361e2a = function(arg0) {
741
- const ret = arg0.offsetHeight;
742
- return ret;
743
- };
744
-
745
- exports.__wbg_offsetWidth_16b33c540f3e9ddb = function(arg0) {
746
- const ret = arg0.offsetWidth;
747
- return ret;
748
- };
749
-
750
- exports.__wbg_performance_7a3ffd0b17f663ad = function(arg0) {
751
- const ret = arg0.performance;
752
- return ret;
753
- };
754
-
755
- exports.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
756
- const ret = arg0.process;
757
- return ret;
758
- };
759
-
760
- exports.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
761
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
762
- };
763
-
764
- exports.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
765
- arg0.randomFillSync(arg1);
766
- }, arguments) };
767
-
768
- exports.__wbg_remove_4ba46706a8e17d9d = function(arg0) {
769
- arg0.remove();
770
- };
771
-
772
- exports.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
773
- const ret = module.require;
774
- return ret;
775
- }, arguments) };
776
-
777
- exports.__wbg_setAttribute_9bad76f39609daac = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
778
- arg0.setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
779
- }, arguments) };
780
-
781
- exports.__wbg_set_textContent_12af0b0f84feb710 = function(arg0, arg1, arg2) {
782
- arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
783
- };
784
-
785
- exports.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
786
- const ret = arg1.stack;
787
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
788
- const len1 = WASM_VECTOR_LEN;
789
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
790
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
791
- };
792
-
793
- exports.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
794
- const ret = typeof global === 'undefined' ? null : global;
795
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
796
- };
797
-
798
- exports.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
799
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
800
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
801
- };
802
-
803
- exports.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
804
- const ret = typeof self === 'undefined' ? null : self;
805
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
806
- };
807
-
808
- exports.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
809
- const ret = typeof window === 'undefined' ? null : window;
810
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
811
- };
812
-
813
- exports.__wbg_subarray_480600f3d6a9f26c = function(arg0, arg1, arg2) {
814
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
815
- return ret;
816
- };
817
-
818
- exports.__wbg_versions_c01dfd4722a88165 = function(arg0) {
819
- const ret = arg0.versions;
820
- return ret;
821
- };
822
-
823
- exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
824
- // Cast intrinsic for `Ref(String) -> Externref`.
825
- const ret = getStringFromWasm0(arg0, arg1);
826
- return ret;
827
- };
828
-
829
- exports.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
830
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
831
- const ret = getArrayU8FromWasm0(arg0, arg1);
832
- return ret;
833
- };
834
-
835
- exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
836
- // Cast intrinsic for `F64 -> Externref`.
837
- const ret = arg0;
838
- return ret;
839
- };
840
-
841
- exports.__wbindgen_init_externref_table = function() {
842
- const table = wasm.__wbindgen_externrefs;
843
- const offset = table.grow(4);
844
- table.set(0, undefined);
845
- table.set(offset + 0, undefined);
846
- table.set(offset + 1, null);
847
- table.set(offset + 2, true);
848
- table.set(offset + 3, false);
849
- ;
850
- };
719
+ }
720
+
721
+ function isLikeNone(x) {
722
+ return x === undefined || x === null;
723
+ }
724
+
725
+ function passArray8ToWasm0(arg, malloc) {
726
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
727
+ getUint8ArrayMemory0().set(arg, ptr / 1);
728
+ WASM_VECTOR_LEN = arg.length;
729
+ return ptr;
730
+ }
731
+
732
+ function passStringToWasm0(arg, malloc, realloc) {
733
+ if (realloc === undefined) {
734
+ const buf = cachedTextEncoder.encode(arg);
735
+ const ptr = malloc(buf.length, 1) >>> 0;
736
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
737
+ WASM_VECTOR_LEN = buf.length;
738
+ return ptr;
739
+ }
740
+
741
+ let len = arg.length;
742
+ let ptr = malloc(len, 1) >>> 0;
743
+
744
+ const mem = getUint8ArrayMemory0();
745
+
746
+ let offset = 0;
747
+
748
+ for (; offset < len; offset++) {
749
+ const code = arg.charCodeAt(offset);
750
+ if (code > 0x7F) break;
751
+ mem[ptr + offset] = code;
752
+ }
753
+ if (offset !== len) {
754
+ if (offset !== 0) {
755
+ arg = arg.slice(offset);
756
+ }
757
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
758
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
759
+ const ret = cachedTextEncoder.encodeInto(arg, view);
760
+
761
+ offset += ret.written;
762
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
763
+ }
764
+
765
+ WASM_VECTOR_LEN = offset;
766
+ return ptr;
767
+ }
768
+
769
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
770
+ cachedTextDecoder.decode();
771
+ function decodeText(ptr, len) {
772
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
773
+ }
774
+
775
+ const cachedTextEncoder = new TextEncoder();
776
+
777
+ if (!('encodeInto' in cachedTextEncoder)) {
778
+ cachedTextEncoder.encodeInto = function (arg, view) {
779
+ const buf = cachedTextEncoder.encode(arg);
780
+ view.set(buf);
781
+ return {
782
+ read: arg.length,
783
+ written: buf.length
784
+ };
785
+ };
786
+ }
787
+
788
+ let WASM_VECTOR_LEN = 0;
851
789
 
852
790
  const wasmPath = `${__dirname}/woxi_bg.wasm`;
853
791
  const wasmBytes = require('fs').readFileSync(wasmPath);
854
792
  const wasmModule = new WebAssembly.Module(wasmBytes);
855
- const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
856
-
793
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
794
+ let wasm = wasmInstance.exports;
857
795
  wasm.__wbindgen_start();
858
-