@doenet/doenetml-headless 0.7.27-dev.0 → 0.7.27-dev.867

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.
@@ -1,204 +1,11 @@
1
1
  import me$2, { isTree, dopri, getComponent } from "math-expressions";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { fileURLToPath } from "node:url";
4
- let wasm;
5
- let cachedUint8ArrayMemory0 = null;
6
- function getUint8ArrayMemory0() {
7
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
8
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
9
- }
10
- return cachedUint8ArrayMemory0;
11
- }
12
- let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
13
- cachedTextDecoder.decode();
14
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
15
- let numBytesDecoded = 0;
16
- function decodeText(ptr, len) {
17
- numBytesDecoded += len;
18
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
19
- cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
20
- cachedTextDecoder.decode();
21
- numBytesDecoded = len;
22
- }
23
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
24
- }
25
- function getStringFromWasm0(ptr, len) {
26
- ptr = ptr >>> 0;
27
- return decodeText(ptr, len);
28
- }
29
- function logError(f2, args) {
30
- try {
31
- return f2.apply(this, args);
32
- } catch (e4) {
33
- let error = (function() {
34
- try {
35
- return e4 instanceof Error ? `${e4.message}
36
-
37
- Stack:
38
- ${e4.stack}` : e4.toString();
39
- } catch (_2) {
40
- return "<failed to stringify thrown value>";
41
- }
42
- })();
43
- console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
44
- throw e4;
45
- }
46
- }
47
- let WASM_VECTOR_LEN = 0;
48
- const cachedTextEncoder = new TextEncoder();
49
- if (!("encodeInto" in cachedTextEncoder)) {
50
- cachedTextEncoder.encodeInto = function(arg, view) {
51
- const buf = cachedTextEncoder.encode(arg);
52
- view.set(buf);
53
- return {
54
- read: arg.length,
55
- written: buf.length
56
- };
57
- };
58
- }
59
- function passStringToWasm0(arg, malloc, realloc) {
60
- if (typeof arg !== "string") throw new Error(`expected a string argument, found ${typeof arg}`);
61
- if (realloc === void 0) {
62
- const buf = cachedTextEncoder.encode(arg);
63
- const ptr2 = malloc(buf.length, 1) >>> 0;
64
- getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
65
- WASM_VECTOR_LEN = buf.length;
66
- return ptr2;
67
- }
68
- let len = arg.length;
69
- let ptr = malloc(len, 1) >>> 0;
70
- const mem = getUint8ArrayMemory0();
71
- let offset = 0;
72
- for (; offset < len; offset++) {
73
- const code = arg.charCodeAt(offset);
74
- if (code > 127) break;
75
- mem[ptr + offset] = code;
76
- }
77
- if (offset !== len) {
78
- if (offset !== 0) {
79
- arg = arg.slice(offset);
80
- }
81
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
82
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
83
- const ret = cachedTextEncoder.encodeInto(arg, view);
84
- if (ret.read !== arg.length) throw new Error("failed to pass whole string");
85
- offset += ret.written;
86
- ptr = realloc(ptr, len, offset, 1) >>> 0;
87
- }
88
- WASM_VECTOR_LEN = offset;
89
- return ptr;
90
- }
91
- let cachedDataViewMemory0 = null;
92
- function getDataViewMemory0() {
93
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
94
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
95
- }
96
- return cachedDataViewMemory0;
97
- }
98
- function debugString(val) {
99
- const type = typeof val;
100
- if (type == "number" || type == "boolean" || val == null) {
101
- return `${val}`;
102
- }
103
- if (type == "string") {
104
- return `"${val}"`;
105
- }
106
- if (type == "symbol") {
107
- const description = val.description;
108
- if (description == null) {
109
- return "Symbol";
110
- } else {
111
- return `Symbol(${description})`;
112
- }
113
- }
114
- if (type == "function") {
115
- const name2 = val.name;
116
- if (typeof name2 == "string" && name2.length > 0) {
117
- return `Function(${name2})`;
118
- } else {
119
- return "Function";
120
- }
121
- }
122
- if (Array.isArray(val)) {
123
- const length = val.length;
124
- let debug = "[";
125
- if (length > 0) {
126
- debug += debugString(val[0]);
127
- }
128
- for (let i2 = 1; i2 < length; i2++) {
129
- debug += ", " + debugString(val[i2]);
130
- }
131
- debug += "]";
132
- return debug;
133
- }
134
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
135
- let className;
136
- if (builtInMatches && builtInMatches.length > 1) {
137
- className = builtInMatches[1];
138
- } else {
139
- return toString.call(val);
140
- }
141
- if (className == "Object") {
142
- try {
143
- return "Object(" + JSON.stringify(val) + ")";
144
- } catch (_2) {
145
- return "Object";
146
- }
147
- }
148
- if (val instanceof Error) {
149
- return `${val.name}: ${val.message}
150
- ${val.stack}`;
151
- }
152
- return className;
153
- }
154
- function _assertBoolean(n2) {
155
- if (typeof n2 !== "boolean") {
156
- throw new Error(`expected a boolean argument, found ${typeof n2}`);
157
- }
158
- }
159
- function isLikeNone(x2) {
160
- return x2 === void 0 || x2 === null;
161
- }
162
- function _assertNum(n2) {
163
- if (typeof n2 !== "number") throw new Error(`expected a number argument, found ${typeof n2}`);
164
- }
165
- function addToExternrefTable0(obj) {
166
- const idx = wasm.__externref_table_alloc();
167
- wasm.__wbindgen_externrefs.set(idx, obj);
168
- return idx;
169
- }
170
- function handleError(f2, args) {
171
- try {
172
- return f2.apply(this, args);
173
- } catch (e4) {
174
- const idx = addToExternrefTable0(e4);
175
- wasm.__wbindgen_exn_store(idx);
176
- }
177
- }
178
- function getArrayJsValueFromWasm0(ptr, len) {
179
- ptr = ptr >>> 0;
180
- const mem = getDataViewMemory0();
181
- const result = [];
182
- for (let i2 = ptr; i2 < ptr + 4 * len; i2 += 4) {
183
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i2, true)));
184
- }
185
- wasm.__externref_drop_slice(ptr, len);
186
- return result;
187
- }
188
- function takeFromExternrefTable0(idx) {
189
- const value = wasm.__wbindgen_externrefs.get(idx);
190
- wasm.__externref_table_dealloc(idx);
191
- return value;
192
- }
193
- const PublicDoenetMLCoreFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
194
- }, unregister: () => {
195
- } } : new FinalizationRegistry((ptr) => wasm.__wbg_publicdoenetmlcore_free(ptr >>> 0, 1));
196
4
  let PublicDoenetMLCore$1 = class PublicDoenetMLCore {
197
5
  constructor() {
198
6
  throw new Error("cannot invoke `new` directly");
199
7
  }
200
8
  static __wrap(ptr) {
201
- ptr = ptr >>> 0;
202
9
  const obj = Object.create(PublicDoenetMLCore.prototype);
203
10
  obj.__wbg_ptr = ptr;
204
11
  PublicDoenetMLCoreFinalization.register(obj, obj.__wbg_ptr, obj);
@@ -221,85 +28,45 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore {
221
28
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
222
29
  _assertNum(this.__wbg_ptr);
223
30
  const ret = wasm.publicdoenetmlcore__get_tests(this.__wbg_ptr);
224
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
31
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
225
32
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
226
33
  return v1;
227
34
  }
228
35
  /**
229
- * @param {DastRoot} dast
230
- * @param {string} _source
36
+ * @param {string} test_name
231
37
  */
232
- set_source(dast, _source) {
38
+ _run_test(test_name) {
233
39
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
234
40
  _assertNum(this.__wbg_ptr);
235
- const ptr0 = passStringToWasm0(_source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const ptr0 = passStringToWasm0(test_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
236
42
  const len0 = WASM_VECTOR_LEN;
237
- const ret = wasm.publicdoenetmlcore_set_source(this.__wbg_ptr, dast, ptr0, len0);
238
- if (ret[1]) {
239
- throw takeFromExternrefTable0(ret[0]);
240
- }
241
- }
242
- /**
243
- * @returns {FlatDastRoot}
244
- */
245
- return_dast() {
246
- if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
247
- _assertNum(this.__wbg_ptr);
248
- const ret = wasm.publicdoenetmlcore_return_dast(this.__wbg_ptr);
249
- if (ret[2]) {
250
- throw takeFromExternrefTable0(ret[1]);
251
- }
252
- return takeFromExternrefTable0(ret[0]);
43
+ wasm.publicdoenetmlcore__run_test(this.__wbg_ptr, ptr0, len0);
253
44
  }
254
45
  /**
255
- * @param {PathToCheck} path
256
- * @param {number} origin
257
- * @param {boolean} skip_parent_search
258
- * @returns {RefResolution}
46
+ * @param {FlatFragment} flat_fragment
47
+ * @param {IndexResolution} index_resolution
259
48
  */
260
- resolve_path(path, origin, skip_parent_search) {
49
+ add_nodes_to_resolver(flat_fragment, index_resolution) {
261
50
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
262
51
  _assertNum(this.__wbg_ptr);
263
- _assertNum(origin);
264
- _assertBoolean(skip_parent_search);
265
- const ret = wasm.publicdoenetmlcore_resolve_path(this.__wbg_ptr, path, origin, skip_parent_search);
266
- if (ret[2]) {
267
- throw takeFromExternrefTable0(ret[1]);
268
- }
269
- return takeFromExternrefTable0(ret[0]);
52
+ wasm.publicdoenetmlcore_add_nodes_to_resolver(this.__wbg_ptr, flat_fragment, index_resolution);
270
53
  }
271
54
  /**
272
- * Save a copy of the resolver before the document loads (D57).
55
+ * @returns {RootNames}
273
56
  */
274
- save_resolver() {
57
+ calculate_root_names() {
275
58
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
276
59
  _assertNum(this.__wbg_ptr);
277
- wasm.publicdoenetmlcore_save_resolver(this.__wbg_ptr);
60
+ const ret = wasm.publicdoenetmlcore_calculate_root_names(this.__wbg_ptr);
61
+ return ret;
278
62
  }
279
63
  /**
280
- * Get the current value of the prop named `prop_name` (camelCase) of the
281
- * component at `component_idx`, calculating it if needed. Returns `undefined`
282
- * if there is no such component or prop.
283
- *
284
- * Intended for tests that read one value at a time rather than going through
285
- * the renderer; the read does not affect what the next `return_dast` reports.
286
- * A math value comes back as `{ math_object: <JSON of the math-expressions tree> }`,
287
- * and an empty value (such as the `title` of a section without one) as `null`.
288
- * @param {number} component_idx
289
- * @param {string} prop_name
290
- * @returns {any}
64
+ * @param {NodeList} node_list
291
65
  */
292
- get_prop_value(component_idx, prop_name) {
66
+ delete_nodes_from_resolver(node_list) {
293
67
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
294
68
  _assertNum(this.__wbg_ptr);
295
- _assertNum(component_idx);
296
- const ptr0 = passStringToWasm0(prop_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
297
- const len0 = WASM_VECTOR_LEN;
298
- const ret = wasm.publicdoenetmlcore_get_prop_value(this.__wbg_ptr, component_idx, ptr0, len0);
299
- if (ret[2]) {
300
- throw takeFromExternrefTable0(ret[1]);
301
- }
302
- return takeFromExternrefTable0(ret[0]);
69
+ wasm.publicdoenetmlcore_delete_nodes_from_resolver(this.__wbg_ptr, node_list);
303
70
  }
304
71
  /**
305
72
  * Send an action to DoenetMLCore. This is often in response to a user
@@ -319,28 +86,6 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore {
319
86
  }
320
87
  return takeFromExternrefTable0(ret[0]);
321
88
  }
322
- /**
323
- * Put back the resolver saved by `save_resolver`, for a load that is
324
- * rebuilt. Returns whether one was saved.
325
- * @returns {boolean}
326
- */
327
- restore_resolver() {
328
- if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
329
- _assertNum(this.__wbg_ptr);
330
- const ret = wasm.publicdoenetmlcore_restore_resolver(this.__wbg_ptr);
331
- return ret !== 0;
332
- }
333
- /**
334
- * @param {boolean} report_all
335
- * @returns {RootNameChanges}
336
- */
337
- update_root_names(report_all) {
338
- if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
339
- _assertNum(this.__wbg_ptr);
340
- _assertBoolean(report_all);
341
- const ret = wasm.publicdoenetmlcore_update_root_names(this.__wbg_ptr, report_all);
342
- return ret;
343
- }
344
89
  /**
345
90
  * Get the type of the component at `component_idx`, or `undefined` if there is none.
346
91
  *
@@ -355,28 +100,55 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore {
355
100
  const ret = wasm.publicdoenetmlcore_get_component_type(this.__wbg_ptr, component_idx);
356
101
  let v1;
357
102
  if (ret[0] !== 0) {
358
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
103
+ v1 = getStringFromWasm0(ret[0], ret[1]);
359
104
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
360
105
  }
361
106
  return v1;
362
107
  }
363
108
  /**
364
- * @returns {RootNames}
109
+ * Get the current value of the prop named `prop_name` (camelCase) of the
110
+ * component at `component_idx`, calculating it if needed. Returns `undefined`
111
+ * if there is no such component or prop.
112
+ *
113
+ * Intended for tests that read one value at a time rather than going through
114
+ * the renderer; the read does not affect what the next `return_dast` reports.
115
+ * A math value comes back as `{ math_object: <JSON of the math-expressions tree> }`,
116
+ * and an empty value (such as the `title` of a section without one) as `null`.
117
+ * @param {number} component_idx
118
+ * @param {string} prop_name
119
+ * @returns {any}
365
120
  */
366
- calculate_root_names() {
121
+ get_prop_value(component_idx, prop_name) {
367
122
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
368
123
  _assertNum(this.__wbg_ptr);
369
- const ret = wasm.publicdoenetmlcore_calculate_root_names(this.__wbg_ptr);
370
- return ret;
124
+ _assertNum(component_idx);
125
+ const val2 = +component_idx;
126
+ const ptr0 = passStringToWasm0(prop_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
127
+ const len0 = WASM_VECTOR_LEN;
128
+ const ret = wasm.publicdoenetmlcore_get_prop_value(this.__wbg_ptr, val2, ptr0, len0);
129
+ if (ret[2]) {
130
+ throw takeFromExternrefTable0(ret[1]);
131
+ }
132
+ return takeFromExternrefTable0(ret[0]);
371
133
  }
372
134
  /**
373
- * @param {FlatFragment} flat_fragment
374
- * @param {IndexResolution} index_resolution
135
+ * @returns {PublicDoenetMLCore}
375
136
  */
376
- add_nodes_to_resolver(flat_fragment, index_resolution) {
137
+ static new() {
138
+ const ret = wasm.publicdoenetmlcore_new();
139
+ return PublicDoenetMLCore.__wrap(ret);
140
+ }
141
+ /**
142
+ * Drop the data that is only needed while initializing a core
143
+ * (currently the document's DAST, which for large documents holds
144
+ * megabytes of WASM linear memory). Called by the worker once the
145
+ * JavaScript core has consumed the normalized DAST; calling
146
+ * `set_source` again repopulates the data.
147
+ */
148
+ release_initialization_data() {
377
149
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
378
150
  _assertNum(this.__wbg_ptr);
379
- wasm.publicdoenetmlcore_add_nodes_to_resolver(this.__wbg_ptr, flat_fragment, index_resolution);
151
+ wasm.publicdoenetmlcore_release_initialization_data(this.__wbg_ptr);
380
152
  }
381
153
  /**
382
154
  * Drop the resolver saved by `save_resolver`, once the load is over,
@@ -388,24 +160,53 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore {
388
160
  wasm.publicdoenetmlcore_release_saved_resolver(this.__wbg_ptr);
389
161
  }
390
162
  /**
391
- * @param {NodeList} node_list
163
+ * @param {ContentVector} components
164
+ * @param {IndexResolution} index_resolution
392
165
  */
393
- delete_nodes_from_resolver(node_list) {
166
+ replace_index_resolutions_in_resolver(components, index_resolution) {
394
167
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
395
168
  _assertNum(this.__wbg_ptr);
396
- wasm.publicdoenetmlcore_delete_nodes_from_resolver(this.__wbg_ptr, node_list);
169
+ wasm.publicdoenetmlcore_replace_index_resolutions_in_resolver(this.__wbg_ptr, components, index_resolution);
397
170
  }
398
171
  /**
399
- * Drop the data that is only needed while initializing a core
400
- * (currently the document's DAST, which for large documents holds
401
- * megabytes of WASM linear memory). Called by the worker once the
402
- * JavaScript core has consumed the normalized DAST; calling
403
- * `set_source` again repopulates the data.
172
+ * @param {PathToCheck} path
173
+ * @param {number} origin
174
+ * @param {boolean} skip_parent_search
175
+ * @returns {RefResolution}
404
176
  */
405
- release_initialization_data() {
177
+ resolve_path(path, origin, skip_parent_search) {
406
178
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
407
179
  _assertNum(this.__wbg_ptr);
408
- wasm.publicdoenetmlcore_release_initialization_data(this.__wbg_ptr);
180
+ _assertNum(origin);
181
+ _assertBoolean(skip_parent_search);
182
+ const ret = wasm.publicdoenetmlcore_resolve_path(this.__wbg_ptr, path, origin, skip_parent_search);
183
+ if (ret[2]) {
184
+ throw takeFromExternrefTable0(ret[1]);
185
+ }
186
+ return takeFromExternrefTable0(ret[0]);
187
+ }
188
+ /**
189
+ * Put back the resolver saved by `save_resolver`, for a load that is
190
+ * rebuilt. Returns whether one was saved.
191
+ * @returns {boolean}
192
+ */
193
+ restore_resolver() {
194
+ if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
195
+ _assertNum(this.__wbg_ptr);
196
+ const ret = wasm.publicdoenetmlcore_restore_resolver(this.__wbg_ptr);
197
+ return ret !== 0;
198
+ }
199
+ /**
200
+ * @returns {FlatDastRoot}
201
+ */
202
+ return_dast() {
203
+ if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
204
+ _assertNum(this.__wbg_ptr);
205
+ const ret = wasm.publicdoenetmlcore_return_dast(this.__wbg_ptr);
206
+ if (ret[2]) {
207
+ throw takeFromExternrefTable0(ret[1]);
208
+ }
209
+ return takeFromExternrefTable0(ret[0]);
409
210
  }
410
211
  /**
411
212
  * @returns {NormalizedRoot}
@@ -420,52 +221,496 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore {
420
221
  return takeFromExternrefTable0(ret[0]);
421
222
  }
422
223
  /**
423
- * @param {ContentVector} components
424
- * @param {IndexResolution} index_resolution
224
+ * Save a copy of the resolver before the document loads (D57).
425
225
  */
426
- replace_index_resolutions_in_resolver(components, index_resolution) {
226
+ save_resolver() {
427
227
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
428
228
  _assertNum(this.__wbg_ptr);
429
- wasm.publicdoenetmlcore_replace_index_resolutions_in_resolver(this.__wbg_ptr, components, index_resolution);
229
+ wasm.publicdoenetmlcore_save_resolver(this.__wbg_ptr);
430
230
  }
431
231
  /**
432
- * @returns {PublicDoenetMLCore}
232
+ * @param {string} flags
433
233
  */
434
- static new() {
435
- const ret = wasm.publicdoenetmlcore_new();
436
- return PublicDoenetMLCore.__wrap(ret);
234
+ set_flags(flags) {
235
+ if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
236
+ _assertNum(this.__wbg_ptr);
237
+ const ptr0 = passStringToWasm0(flags, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
238
+ const len0 = WASM_VECTOR_LEN;
239
+ wasm.publicdoenetmlcore_set_flags(this.__wbg_ptr, ptr0, len0);
437
240
  }
438
241
  /**
439
- * @param {string} test_name
242
+ * @param {DastRoot} dast
243
+ * @param {string} _source
440
244
  */
441
- _run_test(test_name) {
245
+ set_source(dast, _source) {
442
246
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
443
247
  _assertNum(this.__wbg_ptr);
444
- const ptr0 = passStringToWasm0(test_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
248
+ const ptr0 = passStringToWasm0(_source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
445
249
  const len0 = WASM_VECTOR_LEN;
446
- wasm.publicdoenetmlcore__run_test(this.__wbg_ptr, ptr0, len0);
250
+ const ret = wasm.publicdoenetmlcore_set_source(this.__wbg_ptr, dast, ptr0, len0);
251
+ if (ret[1]) {
252
+ throw takeFromExternrefTable0(ret[0]);
253
+ }
447
254
  }
448
255
  /**
449
- * @param {string} flags
256
+ * @param {boolean} report_all
257
+ * @returns {RootNameChanges}
450
258
  */
451
- set_flags(flags) {
259
+ update_root_names(report_all) {
452
260
  if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
453
261
  _assertNum(this.__wbg_ptr);
454
- const ptr0 = passStringToWasm0(flags, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
455
- const len0 = WASM_VECTOR_LEN;
456
- wasm.publicdoenetmlcore_set_flags(this.__wbg_ptr, ptr0, len0);
262
+ _assertBoolean(report_all);
263
+ const ret = wasm.publicdoenetmlcore_update_root_names(this.__wbg_ptr, report_all);
264
+ return ret;
457
265
  }
458
266
  };
459
267
  if (Symbol.dispose) PublicDoenetMLCore$1.prototype[Symbol.dispose] = PublicDoenetMLCore$1.prototype.free;
460
- typeof FinalizationRegistry === "undefined" ? {} : new FinalizationRegistry((ptr) => wasm.__wbg__typeexports_free(ptr >>> 0, 1));
461
- const EXPECTED_RESPONSE_TYPES = /* @__PURE__ */ new Set(["basic", "cors", "default"]);
268
+ function __wbg_get_imports() {
269
+ const import0 = {
270
+ __proto__: null,
271
+ __wbg_Error_208446807d0d1e30: function() {
272
+ return logError(function(arg0, arg1) {
273
+ const ret = Error(getStringFromWasm0(arg0, arg1));
274
+ return ret;
275
+ }, arguments);
276
+ },
277
+ __wbg_Number_ff192a72a0dcdf6d: function() {
278
+ return logError(function(arg0) {
279
+ const ret = Number(arg0);
280
+ return ret;
281
+ }, arguments);
282
+ },
283
+ __wbg_String_8564e559799eccda: function() {
284
+ return logError(function(arg0, arg1) {
285
+ const ret = String(arg1);
286
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
287
+ const len1 = WASM_VECTOR_LEN;
288
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
289
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
290
+ }, arguments);
291
+ },
292
+ __wbg___wbindgen_debug_string_f249a2a76caa9a55: function(arg0, arg1) {
293
+ const ret = debugString(arg1);
294
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
295
+ const len1 = WASM_VECTOR_LEN;
296
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
297
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
298
+ },
299
+ __wbg___wbindgen_is_string_fc456fee5d3317de: function(arg0) {
300
+ const ret = typeof arg0 === "string";
301
+ _assertBoolean(ret);
302
+ return ret;
303
+ },
304
+ __wbg___wbindgen_is_undefined_be5b34249ff1fc15: function(arg0) {
305
+ const ret = arg0 === void 0;
306
+ _assertBoolean(ret);
307
+ return ret;
308
+ },
309
+ __wbg___wbindgen_number_get_934b640d0889af78: function(arg0, arg1) {
310
+ const obj = arg1;
311
+ const ret = typeof obj === "number" ? obj : void 0;
312
+ if (!isLikeNone(ret)) {
313
+ _assertNum(ret);
314
+ }
315
+ getDataViewMemory0().setFloat64((arg0 >>> 0) + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
316
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, !isLikeNone(ret), true);
317
+ },
318
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
319
+ const obj = arg1;
320
+ const ret = typeof obj === "string" ? obj : void 0;
321
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
322
+ var len1 = WASM_VECTOR_LEN;
323
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
324
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
325
+ },
326
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
327
+ throw new Error(getStringFromWasm0(arg0, arg1));
328
+ },
329
+ __wbg_error_757e9472f8410341: function() {
330
+ return logError(function(arg0, arg1) {
331
+ let deferred0_0;
332
+ let deferred0_1;
333
+ try {
334
+ deferred0_0 = arg0;
335
+ deferred0_1 = arg1;
336
+ console.error(getStringFromWasm0(arg0, arg1));
337
+ } finally {
338
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
339
+ }
340
+ }, arguments);
341
+ },
342
+ __wbg_evalWithMathExpressionsInScope_32a10f102b835667: function() {
343
+ return handleError(function(arg0) {
344
+ const ret = __forDoenetWorker.evalWithMathExpressionsInScope(arg0);
345
+ return ret;
346
+ }, arguments);
347
+ },
348
+ __wbg_evaluateToNumber_8c64c9429c798d8b: function() {
349
+ return handleError(function(arg0) {
350
+ const ret = __forDoenetWorker.evaluateToNumber(arg0);
351
+ return ret;
352
+ }, arguments);
353
+ },
354
+ __wbg_log_ff86bbb34c295e21: function() {
355
+ return logError(function(arg0) {
356
+ console.log(arg0);
357
+ }, arguments);
358
+ },
359
+ __wbg_new_37eb45aaf5eeb820: function() {
360
+ return logError(function() {
361
+ const ret = new Array();
362
+ return ret;
363
+ }, arguments);
364
+ },
365
+ __wbg_new_7075786089b89c5e: function() {
366
+ return logError(function() {
367
+ const ret = /* @__PURE__ */ new Map();
368
+ return ret;
369
+ }, arguments);
370
+ },
371
+ __wbg_new_bb74001155cb8ca8: function() {
372
+ return logError(function() {
373
+ const ret = new Error();
374
+ return ret;
375
+ }, arguments);
376
+ },
377
+ __wbg_new_cd4348290afae586: function() {
378
+ return logError(function() {
379
+ const ret = new Object();
380
+ return ret;
381
+ }, arguments);
382
+ },
383
+ __wbg_normalizeMath_a7b09154415a1573: function() {
384
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
385
+ const ret = __forDoenetWorker.normalizeMath(arg0, arg1, arg2, arg3, arg4);
386
+ return ret;
387
+ }, arguments);
388
+ },
389
+ __wbg_parseLatexIntoMath_cae3e033ab0ac8f2: function() {
390
+ return handleError(function(arg0, arg1, arg2) {
391
+ const ret = __forDoenetWorker.parseLatexIntoMath(arg0, arg1, arg2);
392
+ return ret;
393
+ }, arguments);
394
+ },
395
+ __wbg_parseTextIntoMath_d0a9cb3c6cb50a05: function() {
396
+ return handleError(function(arg0, arg1, arg2) {
397
+ const ret = __forDoenetWorker.parseTextIntoMath(arg0, arg1, arg2);
398
+ return ret;
399
+ }, arguments);
400
+ },
401
+ __wbg_parseTextIntoNumber_fc15a7804b0eaf6f: function() {
402
+ return handleError(function(arg0) {
403
+ const ret = __forDoenetWorker.parseTextIntoNumber(arg0);
404
+ return ret;
405
+ }, arguments);
406
+ },
407
+ __wbg_parse_c7e066186c6c86eb: function() {
408
+ return logError(function(arg0, arg1) {
409
+ let deferred0_0;
410
+ let deferred0_1;
411
+ try {
412
+ deferred0_0 = arg0;
413
+ deferred0_1 = arg1;
414
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
415
+ return ret;
416
+ } finally {
417
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
418
+ }
419
+ }, arguments);
420
+ },
421
+ __wbg_push_c9f4893fc209f768: function() {
422
+ return logError(function(arg0, arg1) {
423
+ const ret = arg0.push(arg1);
424
+ _assertNum(ret);
425
+ return ret;
426
+ }, arguments);
427
+ },
428
+ __wbg_set_8282f7e0d2d01336: function() {
429
+ return logError(function(arg0, arg1, arg2) {
430
+ const ret = arg0.set(arg1, arg2);
431
+ return ret;
432
+ }, arguments);
433
+ },
434
+ __wbg_set_d2d33b52458e984a: function() {
435
+ return logError(function(arg0, arg1, arg2) {
436
+ arg0[arg1 >>> 0] = arg2;
437
+ }, arguments);
438
+ },
439
+ __wbg_set_e4b9a833d288759a: function() {
440
+ return logError(function(arg0, arg1, arg2) {
441
+ arg0[arg1] = arg2;
442
+ }, arguments);
443
+ },
444
+ __wbg_stack_575c4e0918581b9c: function() {
445
+ return logError(function(arg0, arg1) {
446
+ const ret = arg1.stack;
447
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
448
+ const len1 = WASM_VECTOR_LEN;
449
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
450
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
451
+ }, arguments);
452
+ },
453
+ __wbg_stringify_4c0abddfd9938268: function() {
454
+ return logError(function(arg0, arg1) {
455
+ const ret = JSON.stringify(arg1);
456
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
457
+ var len1 = WASM_VECTOR_LEN;
458
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
459
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
460
+ }, arguments);
461
+ },
462
+ __wbg_substituteIntoMath_b30d591abcf8045b: function() {
463
+ return handleError(function(arg0, arg1) {
464
+ const ret = __forDoenetWorker.substituteIntoMath(arg0, arg1);
465
+ return ret;
466
+ }, arguments);
467
+ },
468
+ __wbg_toLatex_d304339a4b45072e: function() {
469
+ return handleError(function(arg0, arg1, arg2, arg3) {
470
+ const ret = __forDoenetWorker.toLatex(arg0, arg1, arg2, arg3);
471
+ return ret;
472
+ }, arguments);
473
+ },
474
+ __wbg_toText_6fbdb98f692ea75f: function() {
475
+ return handleError(function(arg0, arg1, arg2, arg3) {
476
+ const ret = __forDoenetWorker.toText(arg0, arg1, arg2, arg3);
477
+ return ret;
478
+ }, arguments);
479
+ },
480
+ __wbindgen_generic_0000000000000001: function() {
481
+ return logError(function(arg0) {
482
+ const ret = arg0;
483
+ return ret;
484
+ }, arguments);
485
+ },
486
+ __wbindgen_generic_0000000000000002: function() {
487
+ return logError(function(arg0) {
488
+ const ret = arg0;
489
+ return ret;
490
+ }, arguments);
491
+ },
492
+ __wbindgen_generic_0000000000000003: function() {
493
+ return logError(function(arg0, arg1) {
494
+ const ret = getStringFromWasm0(arg0, arg1);
495
+ return ret;
496
+ }, arguments);
497
+ },
498
+ __wbindgen_generic_0000000000000004: function() {
499
+ return logError(function(arg0) {
500
+ const ret = BigInt.asUintN(64, arg0);
501
+ return ret;
502
+ }, arguments);
503
+ },
504
+ __wbindgen_init_externref_table: function() {
505
+ const table = wasm.__wbindgen_externrefs;
506
+ table.set(0, void 0);
507
+ table.set(1024, void 0);
508
+ table.set(1025, null);
509
+ table.set(1026, true);
510
+ table.set(1027, false);
511
+ }
512
+ };
513
+ return {
514
+ __proto__: null,
515
+ "./lib_doenetml_worker_bg.js": import0
516
+ };
517
+ }
518
+ const PublicDoenetMLCoreFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
519
+ }, unregister: () => {
520
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_publicdoenetmlcore_free(ptr, 1));
521
+ typeof FinalizationRegistry === "undefined" ? {} : new FinalizationRegistry((ptr) => wasm.__wbg__typeexports_free(ptr, 1));
522
+ function addToExternrefTable0(obj) {
523
+ const idx = wasm.__externref_table_alloc();
524
+ wasm.__wbindgen_externrefs.set(idx, obj);
525
+ return idx;
526
+ }
527
+ function _assertBoolean(n2) {
528
+ if (typeof n2 !== "boolean") {
529
+ throw new Error(`expected a boolean argument, found ${typeof n2}`);
530
+ }
531
+ }
532
+ function _assertNum(n2) {
533
+ if (typeof n2 !== "number") throw new Error(`expected a number argument, found ${typeof n2}`);
534
+ }
535
+ function debugString(val) {
536
+ switch (typeof val) {
537
+ // primitive types
538
+ case "number":
539
+ case "boolean":
540
+ case "undefined":
541
+ return `${val}`;
542
+ case "string":
543
+ return JSON.stringify(val);
544
+ case "bigint":
545
+ return `${val}n`;
546
+ case "symbol":
547
+ return val.description !== void 0 ? `Symbol(${val.description})` : "Symbol";
548
+ case "function":
549
+ return typeof val.name === "string" && val.name !== "" ? `Function(${val.name})` : "Function";
550
+ case "object": {
551
+ if (val === null) {
552
+ return "null";
553
+ }
554
+ if (Array.isArray(val)) {
555
+ return "[" + Array.from(val, debugString).join(", ") + "]";
556
+ }
557
+ if (val instanceof Error) {
558
+ return `${val.name}: ${val.message}
559
+ ${val.stack}`;
560
+ }
561
+ const toStringOutput = toString.call(val);
562
+ const className = /\[object ([^\]]+)\]/.exec(toStringOutput)?.[1];
563
+ if (className === void 0) {
564
+ return toStringOutput;
565
+ }
566
+ if (className === "Object") {
567
+ try {
568
+ return "Object(" + JSON.stringify(val) + ")";
569
+ } catch (_2) {
570
+ return "Object";
571
+ }
572
+ }
573
+ return className;
574
+ }
575
+ }
576
+ }
577
+ function getArrayJsValueFromWasm0(ptr, len) {
578
+ ptr = ptr >>> 0;
579
+ const mem = getDataViewMemory0();
580
+ const result = [];
581
+ for (let i2 = ptr; i2 < ptr + 4 * len; i2 += 4) {
582
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i2, true)));
583
+ }
584
+ wasm.__externref_drop_slice(ptr, len);
585
+ return result;
586
+ }
587
+ let cachedDataViewMemory0 = null;
588
+ function getDataViewMemory0() {
589
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
590
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
591
+ }
592
+ return cachedDataViewMemory0;
593
+ }
594
+ function getStringFromWasm0(ptr, len) {
595
+ ptr = ptr >>> 0;
596
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
597
+ }
598
+ let cachedUint8ArrayMemory0 = null;
599
+ function getUint8ArrayMemory0() {
600
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
601
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
602
+ }
603
+ return cachedUint8ArrayMemory0;
604
+ }
605
+ function handleError(f2, args) {
606
+ try {
607
+ return f2.apply(this, args);
608
+ } catch (e4) {
609
+ const idx = addToExternrefTable0(e4);
610
+ wasm.__wbindgen_exn_store(idx);
611
+ }
612
+ }
613
+ function isLikeNone(x2) {
614
+ return x2 === void 0 || x2 === null;
615
+ }
616
+ function logError(f2, args) {
617
+ try {
618
+ return f2.apply(this, args);
619
+ } catch (e4) {
620
+ let error = (function() {
621
+ try {
622
+ return e4 instanceof Error ? `${e4.message}
623
+
624
+ Stack:
625
+ ${e4.stack}` : e4.toString();
626
+ } catch (_2) {
627
+ return "<failed to stringify thrown value>";
628
+ }
629
+ })();
630
+ console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
631
+ throw e4;
632
+ }
633
+ }
634
+ function passStringToWasm0(arg, malloc, realloc) {
635
+ if (typeof arg !== "string") throw new Error(`expected a string argument, found ${typeof arg}`);
636
+ if (realloc === void 0) {
637
+ const buf = cachedTextEncoder.encode(arg);
638
+ const ptr2 = malloc(buf.length, 1) >>> 0;
639
+ getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
640
+ WASM_VECTOR_LEN = buf.length;
641
+ return ptr2;
642
+ }
643
+ let len = arg.length;
644
+ let ptr = malloc(len, 1) >>> 0;
645
+ const mem = getUint8ArrayMemory0();
646
+ let offset = 0;
647
+ for (; offset < len; offset++) {
648
+ const code = arg.charCodeAt(offset);
649
+ if (code > 127) break;
650
+ mem[ptr + offset] = code;
651
+ }
652
+ if (offset !== len) {
653
+ if (offset !== 0) {
654
+ arg = arg.slice(offset);
655
+ }
656
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
657
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
658
+ const ret = cachedTextEncoder.encodeInto(arg, view);
659
+ if (ret.read !== arg.length) throw new Error("failed to pass whole string");
660
+ offset += ret.written;
661
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
662
+ }
663
+ WASM_VECTOR_LEN = offset;
664
+ return ptr;
665
+ }
666
+ function takeFromExternrefTable0(idx) {
667
+ const value = wasm.__wbindgen_externrefs.get(idx);
668
+ wasm.__externref_table_dealloc(idx);
669
+ return value;
670
+ }
671
+ let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
672
+ cachedTextDecoder.decode();
673
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
674
+ let numBytesDecoded = 0;
675
+ function decodeText(bytes) {
676
+ numBytesDecoded += bytes.length;
677
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
678
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
679
+ cachedTextDecoder.decode();
680
+ numBytesDecoded = bytes.length;
681
+ }
682
+ return cachedTextDecoder.decode(bytes);
683
+ }
684
+ const cachedTextEncoder = new TextEncoder();
685
+ if (!("encodeInto" in cachedTextEncoder)) {
686
+ cachedTextEncoder.encodeInto = function(arg, view) {
687
+ const buf = cachedTextEncoder.encode(arg);
688
+ view.set(buf);
689
+ return {
690
+ read: arg.length,
691
+ written: buf.length
692
+ };
693
+ };
694
+ }
695
+ let WASM_VECTOR_LEN = 0;
696
+ let wasm;
697
+ function __wbg_finalize_init(instance, module) {
698
+ wasm = instance.exports;
699
+ cachedDataViewMemory0 = null;
700
+ cachedUint8ArrayMemory0 = null;
701
+ wasm.__wbindgen_start();
702
+ return wasm;
703
+ }
462
704
  async function __wbg_load(module, imports) {
463
705
  if (typeof Response === "function" && module instanceof Response) {
706
+ if (!module.ok) {
707
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
708
+ }
464
709
  if (typeof WebAssembly.instantiateStreaming === "function") {
465
710
  try {
466
711
  return await WebAssembly.instantiateStreaming(module, imports);
467
712
  } catch (e4) {
468
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
713
+ const validResponse = expectedResponseType(module.type);
469
714
  if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
470
715
  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", e4);
471
716
  } else {
@@ -483,272 +728,36 @@ async function __wbg_load(module, imports) {
483
728
  return instance;
484
729
  }
485
730
  }
731
+ function expectedResponseType(type) {
732
+ switch (type) {
733
+ case "basic":
734
+ case "cors":
735
+ case "default":
736
+ return true;
737
+ }
738
+ return false;
739
+ }
486
740
  }
487
- function __wbg_get_imports() {
488
- const imports = {};
489
- imports.wbg = {};
490
- imports.wbg.__wbg_Error_e83987f665cf5504 = function() {
491
- return logError(function(arg0, arg1) {
492
- const ret = Error(getStringFromWasm0(arg0, arg1));
493
- return ret;
494
- }, arguments);
495
- };
496
- imports.wbg.__wbg_Number_bb48ca12f395cd08 = function() {
497
- return logError(function(arg0) {
498
- const ret = Number(arg0);
499
- return ret;
500
- }, arguments);
501
- };
502
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function() {
503
- return logError(function(arg0, arg1) {
504
- const ret = String(arg1);
505
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
506
- const len1 = WASM_VECTOR_LEN;
507
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
508
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
509
- }, arguments);
510
- };
511
- imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
512
- const ret = debugString(arg1);
513
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
514
- const len1 = WASM_VECTOR_LEN;
515
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
516
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
517
- };
518
- imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
519
- const ret = typeof arg0 === "string";
520
- _assertBoolean(ret);
521
- return ret;
522
- };
523
- imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
524
- const ret = arg0 === void 0;
525
- _assertBoolean(ret);
526
- return ret;
527
- };
528
- imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
529
- const obj = arg1;
530
- const ret = typeof obj === "number" ? obj : void 0;
531
- if (!isLikeNone(ret)) {
532
- _assertNum(ret);
533
- }
534
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
535
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
536
- };
537
- imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
538
- const obj = arg1;
539
- const ret = typeof obj === "string" ? obj : void 0;
540
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
541
- var len1 = WASM_VECTOR_LEN;
542
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
543
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
544
- };
545
- imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
546
- throw new Error(getStringFromWasm0(arg0, arg1));
547
- };
548
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function() {
549
- return logError(function(arg0, arg1) {
550
- let deferred0_0;
551
- let deferred0_1;
552
- try {
553
- deferred0_0 = arg0;
554
- deferred0_1 = arg1;
555
- console.error(getStringFromWasm0(arg0, arg1));
556
- } finally {
557
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
558
- }
559
- }, arguments);
560
- };
561
- imports.wbg.__wbg_evalWithMathExpressionsInScope_f2c3945dcae25bf5 = function() {
562
- return handleError(function(arg0) {
563
- const ret = __forDoenetWorker.evalWithMathExpressionsInScope(arg0);
564
- return ret;
565
- }, arguments);
566
- };
567
- imports.wbg.__wbg_evaluateToNumber_c77d80e34ff1a84c = function() {
568
- return handleError(function(arg0) {
569
- const ret = __forDoenetWorker.evaluateToNumber(arg0);
570
- return ret;
571
- }, arguments);
572
- };
573
- imports.wbg.__wbg_log_8cec76766b8c0e33 = function() {
574
- return logError(function(arg0) {
575
- console.log(arg0);
576
- }, arguments);
577
- };
578
- imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
579
- return logError(function() {
580
- const ret = new Object();
581
- return ret;
582
- }, arguments);
583
- };
584
- imports.wbg.__wbg_new_68651c719dcda04e = function() {
585
- return logError(function() {
586
- const ret = /* @__PURE__ */ new Map();
587
- return ret;
588
- }, arguments);
589
- };
590
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
591
- return logError(function() {
592
- const ret = new Error();
593
- return ret;
594
- }, arguments);
595
- };
596
- imports.wbg.__wbg_new_e17d9f43105b08be = function() {
597
- return logError(function() {
598
- const ret = new Array();
599
- return ret;
600
- }, arguments);
601
- };
602
- imports.wbg.__wbg_normalizeMath_77b2b3b844087fa1 = function() {
603
- return handleError(function(arg0, arg1, arg2, arg3, arg4) {
604
- const ret = __forDoenetWorker.normalizeMath(arg0, arg1, arg2, arg3, arg4);
605
- return ret;
606
- }, arguments);
607
- };
608
- imports.wbg.__wbg_parseLatexIntoMath_d4550352c562f243 = function() {
609
- return handleError(function(arg0, arg1, arg2) {
610
- const ret = __forDoenetWorker.parseLatexIntoMath(arg0, arg1, arg2);
611
- return ret;
612
- }, arguments);
613
- };
614
- imports.wbg.__wbg_parseTextIntoMath_0326c56175d8a61a = function() {
615
- return handleError(function(arg0, arg1, arg2) {
616
- const ret = __forDoenetWorker.parseTextIntoMath(arg0, arg1, arg2);
617
- return ret;
618
- }, arguments);
619
- };
620
- imports.wbg.__wbg_parseTextIntoNumber_7e82fc583ed9674a = function() {
621
- return handleError(function(arg0) {
622
- const ret = __forDoenetWorker.parseTextIntoNumber(arg0);
623
- return ret;
624
- }, arguments);
625
- };
626
- imports.wbg.__wbg_parse_41503dcdc1dc43f2 = function() {
627
- return logError(function(arg0, arg1) {
628
- let deferred0_0;
629
- let deferred0_1;
630
- try {
631
- deferred0_0 = arg0;
632
- deferred0_1 = arg1;
633
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
634
- return ret;
635
- } finally {
636
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
637
- }
638
- }, arguments);
639
- };
640
- imports.wbg.__wbg_push_df81a39d04db858c = function() {
641
- return logError(function(arg0, arg1) {
642
- const ret = arg0.push(arg1);
643
- _assertNum(ret);
644
- return ret;
645
- }, arguments);
646
- };
647
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function() {
648
- return logError(function(arg0, arg1, arg2) {
649
- arg0[arg1] = arg2;
650
- }, arguments);
651
- };
652
- imports.wbg.__wbg_set_907fb406c34a251d = function() {
653
- return logError(function(arg0, arg1, arg2) {
654
- const ret = arg0.set(arg1, arg2);
655
- return ret;
656
- }, arguments);
657
- };
658
- imports.wbg.__wbg_set_c213c871859d6500 = function() {
659
- return logError(function(arg0, arg1, arg2) {
660
- arg0[arg1 >>> 0] = arg2;
661
- }, arguments);
662
- };
663
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function() {
664
- return logError(function(arg0, arg1) {
665
- const ret = arg1.stack;
666
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
667
- const len1 = WASM_VECTOR_LEN;
668
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
669
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
670
- }, arguments);
671
- };
672
- imports.wbg.__wbg_stringify_404baa47f2ce77aa = function() {
673
- return logError(function(arg0, arg1) {
674
- const ret = JSON.stringify(arg1);
675
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
676
- var len1 = WASM_VECTOR_LEN;
677
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
678
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
679
- }, arguments);
680
- };
681
- imports.wbg.__wbg_substituteIntoMath_9e581faa20674758 = function() {
682
- return handleError(function(arg0, arg1) {
683
- const ret = __forDoenetWorker.substituteIntoMath(arg0, arg1);
684
- return ret;
685
- }, arguments);
686
- };
687
- imports.wbg.__wbg_toLatex_2428de01e6384b9e = function() {
688
- return handleError(function(arg0, arg1, arg2, arg3) {
689
- const ret = __forDoenetWorker.toLatex(arg0, arg1, arg2, arg3);
690
- return ret;
691
- }, arguments);
692
- };
693
- imports.wbg.__wbg_toText_7c33e65b3711acbe = function() {
694
- return handleError(function(arg0, arg1, arg2, arg3) {
695
- const ret = __forDoenetWorker.toText(arg0, arg1, arg2, arg3);
696
- return ret;
697
- }, arguments);
698
- };
699
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function() {
700
- return logError(function(arg0, arg1) {
701
- const ret = getStringFromWasm0(arg0, arg1);
702
- return ret;
703
- }, arguments);
704
- };
705
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function() {
706
- return logError(function(arg0) {
707
- const ret = BigInt.asUintN(64, arg0);
708
- return ret;
709
- }, arguments);
710
- };
711
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function() {
712
- return logError(function(arg0) {
713
- const ret = arg0;
714
- return ret;
715
- }, arguments);
716
- };
717
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function() {
718
- return logError(function(arg0) {
719
- const ret = arg0;
720
- return ret;
721
- }, arguments);
722
- };
723
- imports.wbg.__wbindgen_init_externref_table = function() {
724
- const table = wasm.__wbindgen_externrefs;
725
- const offset = table.grow(4);
726
- table.set(0, void 0);
727
- table.set(offset + 0, void 0);
728
- table.set(offset + 1, null);
729
- table.set(offset + 2, true);
730
- table.set(offset + 3, false);
731
- };
732
- return imports;
733
- }
734
- function __wbg_finalize_init(instance, module) {
735
- wasm = instance.exports;
736
- __wbg_init.__wbindgen_wasm_module = module;
737
- cachedDataViewMemory0 = null;
738
- cachedUint8ArrayMemory0 = null;
739
- wasm.__wbindgen_start();
740
- return wasm;
741
- }
741
+ let __wbg_init_promise;
742
742
  async function __wbg_init(module_or_path) {
743
743
  if (wasm !== void 0) return wasm;
744
- if (typeof module_or_path !== "undefined") {
744
+ if (__wbg_init_promise === void 0) {
745
+ __wbg_init_promise = __wbg_init_once(module_or_path);
746
+ __wbg_init_promise.catch(() => {
747
+ __wbg_init_promise = void 0;
748
+ });
749
+ }
750
+ return __wbg_init_promise;
751
+ }
752
+ async function __wbg_init_once(module_or_path) {
753
+ if (module_or_path !== void 0) {
745
754
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
746
755
  ({ module_or_path } = module_or_path);
747
756
  } else {
748
757
  console.warn("using deprecated parameters for the initialization function; pass a single object instead");
749
758
  }
750
759
  }
751
- if (typeof module_or_path === "undefined") {
760
+ if (module_or_path === void 0) {
752
761
  module_or_path = new URL(
753
762
  /* @vite-ignore */
754
763
  "lib_doenetml_worker_bg.wasm",
@@ -760,7 +769,7 @@ async function __wbg_init(module_or_path) {
760
769
  module_or_path = fetch(module_or_path);
761
770
  }
762
771
  const { instance, module } = await __wbg_load(await module_or_path, imports);
763
- return __wbg_finalize_init(instance, module);
772
+ return __wbg_finalize_init(instance);
764
773
  }
765
774
  const OPENERS = "([{";
766
775
  const CLOSERS = ")]}";
@@ -9278,7 +9287,7 @@ async function cidFromArrayBuffer$1(data2) {
9278
9287
  await crypto.subtle.digest("SHA-256", new Uint8Array());
9279
9288
  digest$1 = (data22) => crypto.subtle.digest("SHA-256", data22);
9280
9289
  } catch (e22) {
9281
- const sha256 = (await import("./sha256-8sXzDnE0-BnWUgPS4-DZNAsg63.js").then((n2) => n2.s)).default;
9290
+ const sha256 = (await import("./sha256-8sXzDnE0-BnWUgPS4-Dmbjs5kC.js").then((n2) => n2.s)).default;
9282
9291
  digest$1 = (data22) => sha256(data22, {
9283
9292
  asBytes: true
9284
9293
  });
@@ -268725,7 +268734,7 @@ async function cidFromArrayBuffer(data2) {
268725
268734
  await crypto.subtle.digest("SHA-256", new Uint8Array());
268726
268735
  digest = (data22) => crypto.subtle.digest("SHA-256", data22);
268727
268736
  } catch (e22) {
268728
- const sha256 = (await import("./sha256-8sXzDnE0-BhSvVUps.js").then((n2) => n2.s)).default;
268737
+ const sha256 = (await import("./sha256-8sXzDnE0-Cn67cg22.js").then((n2) => n2.s)).default;
268729
268738
  digest = (data22) => sha256(data22, {
268730
268739
  asBytes: true
268731
268740
  });
@@ -269088,4 +269097,4 @@ export {
269088
269097
  defaultCoreFactory as d,
269089
269098
  gradeState as g
269090
269099
  };
269091
- //# sourceMappingURL=gradeState-Cr5WMUhc.js.map
269100
+ //# sourceMappingURL=gradeState-DgaD_akY.js.map