hephaestus-wasm 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1155 @@
1
+ /* @ts-self-types="./hephaestus_wasm.d.ts" */
2
+
3
+ /**
4
+ * One document bound to one canvas.
5
+ *
6
+ * The low-level binding. A page normally uses the `PlotView` class in
7
+ * `js/hephaestus.js`, which owns the resize and color-scheme wiring and
8
+ * calls through to this.
9
+ */
10
+ export class PlotHandle {
11
+ static __wrap(ptr) {
12
+ const obj = Object.create(PlotHandle.prototype);
13
+ obj.__wbg_ptr = ptr;
14
+ PlotHandleFinalization.register(obj, obj.__wbg_ptr, obj);
15
+ return obj;
16
+ }
17
+ __destroy_into_raw() {
18
+ const ptr = this.__wbg_ptr;
19
+ this.__wbg_ptr = 0;
20
+ PlotHandleFinalization.unregister(this);
21
+ return ptr;
22
+ }
23
+ free() {
24
+ const ptr = this.__destroy_into_raw();
25
+ wasm.__wbg_plothandle_free(ptr, 0);
26
+ }
27
+ /**
28
+ * Read `doc` and attach it to `canvas`.
29
+ *
30
+ * Awaits GPU adapter and device acquisition, which a browser cannot do
31
+ * synchronously. Fails if the document is unreadable or if no WebGPU
32
+ * adapter is available — see [`is_supported`].
33
+ *
34
+ * `picking` allocates a second render target and reads it back after
35
+ * every frame, so it stays off unless [`Self::pick_at`] is going to be
36
+ * called.
37
+ * @param {HTMLCanvasElement} canvas
38
+ * @param {Uint8Array} doc
39
+ * @param {boolean} picking
40
+ * @returns {Promise<PlotHandle>}
41
+ */
42
+ static create(canvas, doc, picking) {
43
+ const ptr0 = passArray8ToWasm0(doc, wasm.__wbindgen_export);
44
+ const len0 = WASM_VECTOR_LEN;
45
+ const ret = wasm.plothandle_create(addHeapObject(canvas), ptr0, len0, picking);
46
+ return takeObject(ret);
47
+ }
48
+ /**
49
+ * Dots per inch the document's writer rendered at, if it recorded one.
50
+ * @returns {number | undefined}
51
+ */
52
+ hintDpi() {
53
+ try {
54
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
55
+ wasm.plothandle_hintDpi(retptr, this.__wbg_ptr);
56
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
57
+ var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true);
58
+ return r0 === 0 ? undefined : r2;
59
+ } finally {
60
+ wasm.__wbindgen_add_to_stack_pointer(16);
61
+ }
62
+ }
63
+ /**
64
+ * Height, in points, the document's writer rendered at, if it recorded one.
65
+ * @returns {number | undefined}
66
+ */
67
+ hintHeight() {
68
+ try {
69
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
70
+ wasm.plothandle_hintHeight(retptr, this.__wbg_ptr);
71
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
72
+ var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true);
73
+ return r0 === 0 ? undefined : r2;
74
+ } finally {
75
+ wasm.__wbindgen_add_to_stack_pointer(16);
76
+ }
77
+ }
78
+ /**
79
+ * Width, in points, the document's writer rendered at, if it recorded one.
80
+ *
81
+ * Advisory — a document can be drawn at any size. Useful as an aspect
82
+ * ratio for a container that has to be sized before anything is laid out.
83
+ * @returns {number | undefined}
84
+ */
85
+ hintWidth() {
86
+ try {
87
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
88
+ wasm.plothandle_hintWidth(retptr, this.__wbg_ptr);
89
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
90
+ var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true);
91
+ return r0 === 0 ? undefined : r2;
92
+ } finally {
93
+ wasm.__wbindgen_add_to_stack_pointer(16);
94
+ }
95
+ }
96
+ /**
97
+ * Whether the inverted theme is in use.
98
+ * @returns {boolean}
99
+ */
100
+ isDark() {
101
+ const ret = wasm.plothandle_isDark(this.__wbg_ptr);
102
+ return ret !== 0;
103
+ }
104
+ /**
105
+ * The row id under a point, or `undefined` for empty space.
106
+ *
107
+ * Coordinates are device pixels — the canvas backing store, not CSS
108
+ * pixels, so scale a pointer event by the device pixel ratio. Always
109
+ * `undefined` unless `picking` was passed to [`Self::create`].
110
+ *
111
+ * The readback is never waited on, so this can answer from a frame or
112
+ * two ago. That is invisible for hover and is what keeps the call off
113
+ * the main thread's critical path.
114
+ * @param {number} x
115
+ * @param {number} y
116
+ * @returns {number | undefined}
117
+ */
118
+ pickAt(x, y) {
119
+ const ret = wasm.plothandle_pickAt(this.__wbg_ptr, x, y);
120
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
121
+ }
122
+ /**
123
+ * Draw one frame at the current size.
124
+ */
125
+ render() {
126
+ try {
127
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
128
+ wasm.plothandle_render(retptr, this.__wbg_ptr);
129
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
130
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
131
+ if (r1) {
132
+ throw takeObject(r0);
133
+ }
134
+ } finally {
135
+ wasm.__wbindgen_add_to_stack_pointer(16);
136
+ }
137
+ }
138
+ /**
139
+ * Resize the drawing surface.
140
+ *
141
+ * `width` and `height` are device pixels — a CSS box times the device
142
+ * pixel ratio — and `ratio` is that same ratio, which sets the dpi so
143
+ * theme lengths in points come out the right physical size. Does not
144
+ * draw; call [`Self::render`] after.
145
+ * @param {number} width
146
+ * @param {number} height
147
+ * @param {number} ratio
148
+ */
149
+ resize(width, height, ratio) {
150
+ wasm.plothandle_resize(this.__wbg_ptr, width, height, ratio);
151
+ }
152
+ /**
153
+ * Switch between the document's theme and its inverted form.
154
+ *
155
+ * Inversion swaps the palette's paper and ink anchors, which every
156
+ * chrome element references, so gridlines, axis text and titles all
157
+ * follow. A geom given an explicit color keeps it — marks adapt only
158
+ * when the plot expressed them as palette references.
159
+ *
160
+ * Does not draw; call [`Self::render`] after.
161
+ * @param {boolean} dark
162
+ */
163
+ setDark(dark) {
164
+ wasm.plothandle_setDark(this.__wbg_ptr, dark);
165
+ }
166
+ }
167
+ if (Symbol.dispose) PlotHandle.prototype[Symbol.dispose] = PlotHandle.prototype.free;
168
+
169
+ /**
170
+ * Major version of the plot-document format this build reads.
171
+ *
172
+ * A document whose major differs is refused outright — the check is equality,
173
+ * not a floor — so a site and whatever writes its documents have to agree on
174
+ * this number. Publish it alongside the bundle and assert on it in a build
175
+ * step: nothing at runtime can recover from a mismatch, and the failure is a
176
+ * plot that never appears.
177
+ * @returns {number}
178
+ */
179
+ export function documentFormatVersion() {
180
+ const ret = wasm.documentFormatVersion();
181
+ return ret;
182
+ }
183
+
184
+ /**
185
+ * Whether any font family is available to shape with.
186
+ *
187
+ * A browser starts with none, so this answers "does this page still need a
188
+ * font?" — and it answers it after a document has been read, so a document
189
+ * carrying embedded faces counts. That is what lets a fallback be fetched
190
+ * only when it is genuinely needed rather than on a guess.
191
+ * @returns {boolean}
192
+ */
193
+ export function hasFonts() {
194
+ const ret = wasm.hasFonts();
195
+ return ret !== 0;
196
+ }
197
+
198
+ /**
199
+ * Whether this browser can run the renderer at all.
200
+ *
201
+ * What it tests depends on which backend was built. The wgpu build rasterises
202
+ * through compute pipelines, so WebGPU is a hard requirement rather than a
203
+ * preference. The WebGL2 build needs only a WebGL2 context, which is available
204
+ * essentially everywhere — so it is very nearly always `true`, and the check
205
+ * is kept so a page can use one code path for either bundle.
206
+ *
207
+ * A page should check this before creating a view and fall back to a static
208
+ * image when it is `false`.
209
+ * @returns {boolean}
210
+ */
211
+ export function isSupported() {
212
+ const ret = wasm.isSupported();
213
+ return ret !== 0;
214
+ }
215
+
216
+ /**
217
+ * Register every font face in `bytes`, returning the family names they
218
+ * landed under.
219
+ *
220
+ * A browser starts with no fonts at all — nothing enumerates a system font
221
+ * set — so a page that registers none renders chrome with no text. Call
222
+ * this before creating any view: the first thing a document decodes is its
223
+ * theme, and that is enough to shape.
224
+ *
225
+ * Registration is process-global and permanent, so one call serves every
226
+ * view on the page for the lifetime of the module.
227
+ *
228
+ * The family names are the point of the return value: [`set_generic_family`]
229
+ * takes names, and the only place a family's name exists is inside the file,
230
+ * so a caller cannot pair the two without being told. Guessing from a
231
+ * filename does not survive contact with a real font.
232
+ *
233
+ * Accepts TTF, OTF, TTC, OTC and — with the `webfonts` feature, on by
234
+ * default — WOFF and WOFF2, which are unwrapped to the sfnt inside first.
235
+ * A blob holding no recognisable face is an error rather than an empty
236
+ * list, since registering nothing silently would render a textless plot
237
+ * with no indication why.
238
+ * @param {Uint8Array} bytes
239
+ * @returns {string[]}
240
+ */
241
+ export function registerFont(bytes) {
242
+ try {
243
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
244
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
245
+ const len0 = WASM_VECTOR_LEN;
246
+ wasm.registerFont(retptr, ptr0, len0);
247
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
248
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
249
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
250
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
251
+ if (r3) {
252
+ throw takeObject(r2);
253
+ }
254
+ var v2 = getArrayJsValueFromWasm0(r0, r1);
255
+ wasm.__wbindgen_export5(r0, r1 * 4, 4);
256
+ return v2;
257
+ } finally {
258
+ wasm.__wbindgen_add_to_stack_pointer(16);
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Point a generic family at concrete families already registered.
264
+ *
265
+ * `kind` is one of `serif`, `sans-serif`, `monospace`, `cursive`,
266
+ * `fantasy`, `system-ui`. A generic is an indirection through the font
267
+ * context rather than a name, so registering a font is not enough on its
268
+ * own — a theme asking for `sans-serif` resolves to nothing until this
269
+ * says what `sans-serif` means here. Call it after [`register_font`], since
270
+ * names that aren't registered are skipped.
271
+ * @param {string} kind
272
+ * @param {string[]} families
273
+ */
274
+ export function setGenericFamily(kind, families) {
275
+ try {
276
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
277
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
278
+ const len0 = WASM_VECTOR_LEN;
279
+ const ptr1 = passArrayJsValueToWasm0(families, wasm.__wbindgen_export);
280
+ const len1 = WASM_VECTOR_LEN;
281
+ wasm.setGenericFamily(retptr, ptr0, len0, ptr1, len1);
282
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
283
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
284
+ if (r1) {
285
+ throw takeObject(r0);
286
+ }
287
+ } finally {
288
+ wasm.__wbindgen_add_to_stack_pointer(16);
289
+ }
290
+ }
291
+ function __wbg_get_imports() {
292
+ const import0 = {
293
+ __proto__: null,
294
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
295
+ const ret = Error(getStringFromWasm0(arg0, arg1));
296
+ return addHeapObject(ret);
297
+ },
298
+ __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
299
+ const v = getObject(arg0);
300
+ const ret = typeof(v) === 'boolean' ? v : undefined;
301
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
302
+ },
303
+ __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
304
+ const ret = debugString(getObject(arg1));
305
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
306
+ const len1 = WASM_VECTOR_LEN;
307
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
308
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
309
+ },
310
+ __wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
311
+ const ret = typeof(getObject(arg0)) === 'function';
312
+ return ret;
313
+ },
314
+ __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
315
+ const ret = getObject(arg0) === undefined;
316
+ return ret;
317
+ },
318
+ __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
319
+ const obj = getObject(arg1);
320
+ const ret = typeof(obj) === 'number' ? obj : undefined;
321
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
322
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
323
+ },
324
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
325
+ const obj = getObject(arg1);
326
+ const ret = typeof(obj) === 'string' ? obj : undefined;
327
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
328
+ var len1 = WASM_VECTOR_LEN;
329
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
330
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
331
+ },
332
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
333
+ throw new Error(getStringFromWasm0(arg0, arg1));
334
+ },
335
+ __wbg__wbg_cb_unref_be22cc64ae6946a0: function(arg0) {
336
+ getObject(arg0)._wbg_cb_unref();
337
+ },
338
+ __wbg_activeTexture_8e65ac2e8d488478: function(arg0, arg1) {
339
+ getObject(arg0).activeTexture(arg1 >>> 0);
340
+ },
341
+ __wbg_attachShader_26751604f00d1f1b: function(arg0, arg1, arg2) {
342
+ getObject(arg0).attachShader(getObject(arg1), getObject(arg2));
343
+ },
344
+ __wbg_bindBufferBase_6302905d2ff7534b: function(arg0, arg1, arg2, arg3) {
345
+ getObject(arg0).bindBufferBase(arg1 >>> 0, arg2 >>> 0, getObject(arg3));
346
+ },
347
+ __wbg_bindBuffer_1fb12d083d2a22af: function(arg0, arg1, arg2) {
348
+ getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2));
349
+ },
350
+ __wbg_bindFramebuffer_e620067056f9316f: function(arg0, arg1, arg2) {
351
+ getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2));
352
+ },
353
+ __wbg_bindTexture_4c54ffb64c33564f: function(arg0, arg1, arg2) {
354
+ getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2));
355
+ },
356
+ __wbg_bindVertexArray_0185d931d681d806: function(arg0, arg1) {
357
+ getObject(arg0).bindVertexArray(getObject(arg1));
358
+ },
359
+ __wbg_blendFunc_b7f382e97db2fd5b: function(arg0, arg1, arg2) {
360
+ getObject(arg0).blendFunc(arg1 >>> 0, arg2 >>> 0);
361
+ },
362
+ __wbg_bufferData_24222e82bbd52cb0: function(arg0, arg1, arg2, arg3, arg4) {
363
+ getObject(arg0).bufferData(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3), arg4 >>> 0);
364
+ },
365
+ __wbg_bufferData_6c10d3e07ec9a2a9: function(arg0, arg1, arg2, arg3) {
366
+ getObject(arg0).bufferData(arg1 >>> 0, arg2, arg3 >>> 0);
367
+ },
368
+ __wbg_bufferSubData_c4503642340c40b9: function(arg0, arg1, arg2, arg3, arg4) {
369
+ getObject(arg0).bufferSubData(arg1 >>> 0, arg2, getArrayU8FromWasm0(arg3, arg4));
370
+ },
371
+ __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
372
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
373
+ return addHeapObject(ret);
374
+ }, arguments); },
375
+ __wbg_clearColor_9d880eee3619dbf5: function(arg0, arg1, arg2, arg3, arg4) {
376
+ getObject(arg0).clearColor(arg1, arg2, arg3, arg4);
377
+ },
378
+ __wbg_clearDepth_887000180cc9eb2e: function(arg0, arg1) {
379
+ getObject(arg0).clearDepth(arg1);
380
+ },
381
+ __wbg_clear_332f205d7e52df87: function(arg0, arg1) {
382
+ getObject(arg0).clear(arg1 >>> 0);
383
+ },
384
+ __wbg_compileShader_ac457ada9042f08e: function(arg0, arg1) {
385
+ getObject(arg0).compileShader(getObject(arg1));
386
+ },
387
+ __wbg_copyTexSubImage3D_89064e67340a38b3: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
388
+ getObject(arg0).copyTexSubImage3D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
389
+ },
390
+ __wbg_createBuffer_af6c411fe2b091f8: function(arg0) {
391
+ const ret = getObject(arg0).createBuffer();
392
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
393
+ },
394
+ __wbg_createElement_7f42344eee7bb810: function() { return handleError(function (arg0, arg1, arg2) {
395
+ const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2));
396
+ return addHeapObject(ret);
397
+ }, arguments); },
398
+ __wbg_createFramebuffer_e6d8917bf9291c65: function(arg0) {
399
+ const ret = getObject(arg0).createFramebuffer();
400
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
401
+ },
402
+ __wbg_createProgram_81b37242eadef893: function(arg0) {
403
+ const ret = getObject(arg0).createProgram();
404
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
405
+ },
406
+ __wbg_createShader_9a8e5f335caac850: function(arg0, arg1) {
407
+ const ret = getObject(arg0).createShader(arg1 >>> 0);
408
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
409
+ },
410
+ __wbg_createTexture_c74740f68b5c2a93: function(arg0) {
411
+ const ret = getObject(arg0).createTexture();
412
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
413
+ },
414
+ __wbg_createVertexArray_abd18ded26b75653: function(arg0) {
415
+ const ret = getObject(arg0).createVertexArray();
416
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
417
+ },
418
+ __wbg_deleteBuffer_42bd497a20b76d88: function(arg0, arg1) {
419
+ getObject(arg0).deleteBuffer(getObject(arg1));
420
+ },
421
+ __wbg_deleteFramebuffer_07fcc16563d17920: function(arg0, arg1) {
422
+ getObject(arg0).deleteFramebuffer(getObject(arg1));
423
+ },
424
+ __wbg_deleteProgram_0191056307686073: function(arg0, arg1) {
425
+ getObject(arg0).deleteProgram(getObject(arg1));
426
+ },
427
+ __wbg_deleteShader_413961eb94f5c67c: function(arg0, arg1) {
428
+ getObject(arg0).deleteShader(getObject(arg1));
429
+ },
430
+ __wbg_deleteTexture_0ccd278d6db819ff: function(arg0, arg1) {
431
+ getObject(arg0).deleteTexture(getObject(arg1));
432
+ },
433
+ __wbg_deleteVertexArray_106030034355d246: function(arg0, arg1) {
434
+ getObject(arg0).deleteVertexArray(getObject(arg1));
435
+ },
436
+ __wbg_depthFunc_6c6f948417f5bde4: function(arg0, arg1) {
437
+ getObject(arg0).depthFunc(arg1 >>> 0);
438
+ },
439
+ __wbg_depthMask_4e0075e07739355b: function(arg0, arg1) {
440
+ getObject(arg0).depthMask(arg1 !== 0);
441
+ },
442
+ __wbg_disable_bb1df5a6c75eaecd: function(arg0, arg1) {
443
+ getObject(arg0).disable(arg1 >>> 0);
444
+ },
445
+ __wbg_document_ac38448dbfd31a57: function(arg0) {
446
+ const ret = getObject(arg0).document;
447
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
448
+ },
449
+ __wbg_drawArraysInstanced_45317b22bbf7ffe8: function(arg0, arg1, arg2, arg3, arg4) {
450
+ getObject(arg0).drawArraysInstanced(arg1 >>> 0, arg2, arg3, arg4);
451
+ },
452
+ __wbg_enableVertexAttribArray_b072ffcbe4f26e2b: function(arg0, arg1) {
453
+ getObject(arg0).enableVertexAttribArray(arg1 >>> 0);
454
+ },
455
+ __wbg_enable_17346ff3b2257cae: function(arg0, arg1) {
456
+ getObject(arg0).enable(arg1 >>> 0);
457
+ },
458
+ __wbg_flush_918ffb9cfebcbaab: function(arg0) {
459
+ getObject(arg0).flush();
460
+ },
461
+ __wbg_framebufferTexture2D_9abab99d6209666a: function(arg0, arg1, arg2, arg3, arg4, arg5) {
462
+ getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5);
463
+ },
464
+ __wbg_framebufferTextureLayer_e236352620170c5a: function(arg0, arg1, arg2, arg3, arg4, arg5) {
465
+ getObject(arg0).framebufferTextureLayer(arg1 >>> 0, arg2 >>> 0, getObject(arg3), arg4, arg5);
466
+ },
467
+ __wbg_getContext_123ddade3a0fb2f5: function() { return handleError(function (arg0, arg1, arg2, arg3) {
468
+ const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2), getObject(arg3));
469
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
470
+ }, arguments); },
471
+ __wbg_getContext_71c33f14b63da593: function() { return handleError(function (arg0, arg1, arg2) {
472
+ const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2));
473
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
474
+ }, arguments); },
475
+ __wbg_getParameter_7ddbe9f9606f6a80: function() { return handleError(function (arg0, arg1) {
476
+ const ret = getObject(arg0).getParameter(arg1 >>> 0);
477
+ return addHeapObject(ret);
478
+ }, arguments); },
479
+ __wbg_getProgramInfoLog_72665662cf78b5a2: function(arg0, arg1, arg2) {
480
+ const ret = getObject(arg1).getProgramInfoLog(getObject(arg2));
481
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
482
+ var len1 = WASM_VECTOR_LEN;
483
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
484
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
485
+ },
486
+ __wbg_getProgramParameter_41e1ea6f52a71ba5: function(arg0, arg1, arg2) {
487
+ const ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0);
488
+ return addHeapObject(ret);
489
+ },
490
+ __wbg_getShaderInfoLog_663a9b136ab42b32: function(arg0, arg1, arg2) {
491
+ const ret = getObject(arg1).getShaderInfoLog(getObject(arg2));
492
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
493
+ var len1 = WASM_VECTOR_LEN;
494
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
495
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
496
+ },
497
+ __wbg_getShaderParameter_9e9aa18598294f3b: function(arg0, arg1, arg2) {
498
+ const ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0);
499
+ return addHeapObject(ret);
500
+ },
501
+ __wbg_getUniformBlockIndex_78264d4d94f8252d: function(arg0, arg1, arg2, arg3) {
502
+ const ret = getObject(arg0).getUniformBlockIndex(getObject(arg1), getStringFromWasm0(arg2, arg3));
503
+ return ret;
504
+ },
505
+ __wbg_getUniformLocation_c493d2f5f1a6213d: function(arg0, arg1, arg2, arg3) {
506
+ const ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3));
507
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
508
+ },
509
+ __wbg_height_e56f6fb197710e09: function(arg0) {
510
+ const ret = getObject(arg0).height;
511
+ return ret;
512
+ },
513
+ __wbg_instanceof_HtmlCanvasElement_327e7f7530c72bbd: function(arg0) {
514
+ let result;
515
+ try {
516
+ result = getObject(arg0) instanceof HTMLCanvasElement;
517
+ } catch (_) {
518
+ result = false;
519
+ }
520
+ const ret = result;
521
+ return ret;
522
+ },
523
+ __wbg_instanceof_Int32Array_0397e5b856c93c47: function(arg0) {
524
+ let result;
525
+ try {
526
+ result = getObject(arg0) instanceof Int32Array;
527
+ } catch (_) {
528
+ result = false;
529
+ }
530
+ const ret = result;
531
+ return ret;
532
+ },
533
+ __wbg_instanceof_WebGl2RenderingContext_e27143c72f888655: function(arg0) {
534
+ let result;
535
+ try {
536
+ result = getObject(arg0) instanceof WebGL2RenderingContext;
537
+ } catch (_) {
538
+ result = false;
539
+ }
540
+ const ret = result;
541
+ return ret;
542
+ },
543
+ __wbg_instanceof_WebGlBuffer_f76774bcedd2e973: function(arg0) {
544
+ let result;
545
+ try {
546
+ result = getObject(arg0) instanceof WebGLBuffer;
547
+ } catch (_) {
548
+ result = false;
549
+ }
550
+ const ret = result;
551
+ return ret;
552
+ },
553
+ __wbg_instanceof_WebGlFramebuffer_93e18f1a54eca034: function(arg0) {
554
+ let result;
555
+ try {
556
+ result = getObject(arg0) instanceof WebGLFramebuffer;
557
+ } catch (_) {
558
+ result = false;
559
+ }
560
+ const ret = result;
561
+ return ret;
562
+ },
563
+ __wbg_instanceof_WebGlTexture_ea7617e025242f56: function(arg0) {
564
+ let result;
565
+ try {
566
+ result = getObject(arg0) instanceof WebGLTexture;
567
+ } catch (_) {
568
+ result = false;
569
+ }
570
+ const ret = result;
571
+ return ret;
572
+ },
573
+ __wbg_instanceof_Window_5625ff9937037a38: function(arg0) {
574
+ let result;
575
+ try {
576
+ result = getObject(arg0) instanceof Window;
577
+ } catch (_) {
578
+ result = false;
579
+ }
580
+ const ret = result;
581
+ return ret;
582
+ },
583
+ __wbg_invalidateFramebuffer_9a711eeb3940aba0: function() { return handleError(function (arg0, arg1, arg2) {
584
+ getObject(arg0).invalidateFramebuffer(arg1 >>> 0, getObject(arg2));
585
+ }, arguments); },
586
+ __wbg_isEnabled_c8e8d3ff01307a49: function(arg0, arg1) {
587
+ const ret = getObject(arg0).isEnabled(arg1 >>> 0);
588
+ return ret;
589
+ },
590
+ __wbg_length_c812b8efd064d998: function(arg0) {
591
+ const ret = getObject(arg0).length;
592
+ return ret;
593
+ },
594
+ __wbg_linkProgram_124252d16ea0ef40: function(arg0, arg1) {
595
+ getObject(arg0).linkProgram(getObject(arg1));
596
+ },
597
+ __wbg_new_ebe3e0f6837f0879: function() {
598
+ const ret = new Object();
599
+ return addHeapObject(ret);
600
+ },
601
+ __wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
602
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
603
+ return addHeapObject(ret);
604
+ },
605
+ __wbg_new_typed_cceaf62d8d95e9f2: function(arg0, arg1) {
606
+ try {
607
+ var state0 = {a: arg0, b: arg1};
608
+ var cb0 = (arg0, arg1) => {
609
+ const a = state0.a;
610
+ state0.a = 0;
611
+ try {
612
+ return __wasm_bindgen_func_elem_4273(a, state0.b, arg0, arg1);
613
+ } finally {
614
+ state0.a = a;
615
+ }
616
+ };
617
+ const ret = new Promise(cb0);
618
+ return addHeapObject(ret);
619
+ } finally {
620
+ state0.a = 0;
621
+ }
622
+ },
623
+ __wbg_of_0c6464fa8d2aa86d: function(arg0) {
624
+ const ret = Array.of(getObject(arg0));
625
+ return addHeapObject(ret);
626
+ },
627
+ __wbg_plothandle_new: function(arg0) {
628
+ const ret = PlotHandle.__wrap(arg0);
629
+ return addHeapObject(ret);
630
+ },
631
+ __wbg_prototypesetcall_e30a3abb428d3d47: function(arg0, arg1, arg2) {
632
+ Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), getObject(arg2));
633
+ },
634
+ __wbg_queueMicrotask_ac694eae12e92dfb: function(arg0) {
635
+ queueMicrotask(getObject(arg0));
636
+ },
637
+ __wbg_queueMicrotask_be5fe34a8f4cad4d: function(arg0) {
638
+ const ret = getObject(arg0).queueMicrotask;
639
+ return addHeapObject(ret);
640
+ },
641
+ __wbg_readPixels_044c4e00430dd6f5: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
642
+ getObject(arg0).readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7 === 0 ? undefined : getArrayU8FromWasm0(arg7, arg8));
643
+ }, arguments); },
644
+ __wbg_resolve_020f95d838c6ef25: function(arg0) {
645
+ const ret = Promise.resolve(getObject(arg0));
646
+ return addHeapObject(ret);
647
+ },
648
+ __wbg_scissor_2f02706fbca6e98a: function(arg0, arg1, arg2, arg3, arg4) {
649
+ getObject(arg0).scissor(arg1, arg2, arg3, arg4);
650
+ },
651
+ __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
652
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
653
+ return ret;
654
+ }, arguments); },
655
+ __wbg_set_height_d72f2b76484a44de: function(arg0, arg1) {
656
+ getObject(arg0).height = arg1 >>> 0;
657
+ },
658
+ __wbg_set_width_36ef6630b22fc519: function(arg0, arg1) {
659
+ getObject(arg0).width = arg1 >>> 0;
660
+ },
661
+ __wbg_shaderSource_7d3f360b4b626db7: function(arg0, arg1, arg2, arg3) {
662
+ getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3));
663
+ },
664
+ __wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76: function() {
665
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
666
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
667
+ },
668
+ __wbg_static_accessor_GLOBAL_c7aea38d4de089bc: function() {
669
+ const ret = typeof global === 'undefined' ? null : global;
670
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
671
+ },
672
+ __wbg_static_accessor_SELF_42d4fae05e59267a: function() {
673
+ const ret = typeof self === 'undefined' ? null : self;
674
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
675
+ },
676
+ __wbg_static_accessor_WINDOW_e0db14a0eba6a812: function() {
677
+ const ret = typeof window === 'undefined' ? null : window;
678
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
679
+ },
680
+ __wbg_texImage2D_053488112c3d702f: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
681
+ getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, getObject(arg9));
682
+ }, arguments); },
683
+ __wbg_texImage2D_2d1f12e7c67a36d0: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
684
+ getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10));
685
+ }, arguments); },
686
+ __wbg_texImage3D_c46d69d4d0ddd1f4: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) {
687
+ getObject(arg0).texImage3D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7, arg8 >>> 0, arg9 >>> 0, arg10 === 0 ? undefined : getArrayU8FromWasm0(arg10, arg11));
688
+ }, arguments); },
689
+ __wbg_texParameteri_dd4f56c2acbbe859: function(arg0, arg1, arg2, arg3) {
690
+ getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
691
+ },
692
+ __wbg_texSubImage3D_d041ee9d4883aef5: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) {
693
+ getObject(arg0).texSubImage3D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 >>> 0, arg10 >>> 0, arg11 === 0 ? undefined : getArrayU8FromWasm0(arg11, arg12));
694
+ }, arguments); },
695
+ __wbg_then_7026b513a94278a8: function(arg0, arg1) {
696
+ const ret = getObject(arg0).then(getObject(arg1));
697
+ return addHeapObject(ret);
698
+ },
699
+ __wbg_uniform1i_235dff1d94e0df95: function(arg0, arg1, arg2) {
700
+ getObject(arg0).uniform1i(getObject(arg1), arg2);
701
+ },
702
+ __wbg_uniformBlockBinding_057177606c8b522f: function(arg0, arg1, arg2, arg3) {
703
+ getObject(arg0).uniformBlockBinding(getObject(arg1), arg2 >>> 0, arg3 >>> 0);
704
+ },
705
+ __wbg_useProgram_1c047de878f20b72: function(arg0, arg1) {
706
+ getObject(arg0).useProgram(getObject(arg1));
707
+ },
708
+ __wbg_vertexAttribDivisor_f910af52b19ce382: function(arg0, arg1, arg2) {
709
+ getObject(arg0).vertexAttribDivisor(arg1 >>> 0, arg2 >>> 0);
710
+ },
711
+ __wbg_vertexAttribIPointer_54e6be6fa5e39567: function(arg0, arg1, arg2, arg3, arg4, arg5) {
712
+ getObject(arg0).vertexAttribIPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4, arg5);
713
+ },
714
+ __wbg_viewport_07bb1829f0fe2245: function(arg0, arg1, arg2, arg3, arg4) {
715
+ getObject(arg0).viewport(arg1, arg2, arg3, arg4);
716
+ },
717
+ __wbg_width_1952934caca67137: function(arg0) {
718
+ const ret = getObject(arg0).width;
719
+ return ret;
720
+ },
721
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
722
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 246, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
723
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_4214);
724
+ return addHeapObject(ret);
725
+ },
726
+ __wbindgen_cast_0000000000000002: function(arg0) {
727
+ // Cast intrinsic for `F64 -> Externref`.
728
+ const ret = arg0;
729
+ return addHeapObject(ret);
730
+ },
731
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
732
+ // Cast intrinsic for `Ref(Slice(U32)) -> NamedExternref("Uint32Array")`.
733
+ const ret = getArrayU32FromWasm0(arg0, arg1);
734
+ return addHeapObject(ret);
735
+ },
736
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
737
+ // Cast intrinsic for `Ref(String) -> Externref`.
738
+ const ret = getStringFromWasm0(arg0, arg1);
739
+ return addHeapObject(ret);
740
+ },
741
+ __wbindgen_object_clone_ref: function(arg0) {
742
+ const ret = getObject(arg0);
743
+ return addHeapObject(ret);
744
+ },
745
+ __wbindgen_object_drop_ref: function(arg0) {
746
+ takeObject(arg0);
747
+ },
748
+ };
749
+ return {
750
+ __proto__: null,
751
+ "./hephaestus_wasm_bg.js": import0,
752
+ };
753
+ }
754
+
755
+ function __wasm_bindgen_func_elem_4214(arg0, arg1, arg2) {
756
+ try {
757
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
758
+ wasm.__wasm_bindgen_func_elem_4214(retptr, arg0, arg1, addHeapObject(arg2));
759
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
760
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
761
+ if (r1) {
762
+ throw takeObject(r0);
763
+ }
764
+ } finally {
765
+ wasm.__wbindgen_add_to_stack_pointer(16);
766
+ }
767
+ }
768
+
769
+ function __wasm_bindgen_func_elem_4273(arg0, arg1, arg2, arg3) {
770
+ wasm.__wasm_bindgen_func_elem_4273(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
771
+ }
772
+
773
+ const PlotHandleFinalization = (typeof FinalizationRegistry === 'undefined')
774
+ ? { register: () => {}, unregister: () => {} }
775
+ : new FinalizationRegistry(ptr => wasm.__wbg_plothandle_free(ptr, 1));
776
+
777
+ function addHeapObject(obj) {
778
+ if (heap_next === heap.length) heap.push(heap.length + 1);
779
+ const idx = heap_next;
780
+ heap_next = heap[idx];
781
+
782
+ heap[idx] = obj;
783
+ return idx;
784
+ }
785
+
786
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
787
+ ? { register: () => {}, unregister: () => {} }
788
+ : new FinalizationRegistry(state => wasm.__wbindgen_export4(state.a, state.b));
789
+
790
+ function debugString(val) {
791
+ // primitive types
792
+ const type = typeof val;
793
+ if (type == 'number' || type == 'boolean' || val == null) {
794
+ return `${val}`;
795
+ }
796
+ if (type == 'string') {
797
+ return `"${val}"`;
798
+ }
799
+ if (type == 'symbol') {
800
+ const description = val.description;
801
+ if (description == null) {
802
+ return 'Symbol';
803
+ } else {
804
+ return `Symbol(${description})`;
805
+ }
806
+ }
807
+ if (type == 'function') {
808
+ const name = val.name;
809
+ if (typeof name == 'string' && name.length > 0) {
810
+ return `Function(${name})`;
811
+ } else {
812
+ return 'Function';
813
+ }
814
+ }
815
+ // objects
816
+ if (Array.isArray(val)) {
817
+ const length = val.length;
818
+ let debug = '[';
819
+ if (length > 0) {
820
+ debug += debugString(val[0]);
821
+ }
822
+ for(let i = 1; i < length; i++) {
823
+ debug += ', ' + debugString(val[i]);
824
+ }
825
+ debug += ']';
826
+ return debug;
827
+ }
828
+ // Test for built-in
829
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
830
+ let className;
831
+ if (builtInMatches && builtInMatches.length > 1) {
832
+ className = builtInMatches[1];
833
+ } else {
834
+ // Failed to match the standard '[object ClassName]'
835
+ return toString.call(val);
836
+ }
837
+ if (className == 'Object') {
838
+ // we're a user defined class or Object
839
+ // JSON.stringify avoids problems with cycles, and is generally much
840
+ // easier than looping through ownProperties of `val`.
841
+ try {
842
+ return 'Object(' + JSON.stringify(val) + ')';
843
+ } catch (_) {
844
+ return 'Object';
845
+ }
846
+ }
847
+ // errors
848
+ if (val instanceof Error) {
849
+ return `${val.name}: ${val.message}\n${val.stack}`;
850
+ }
851
+ // TODO we could test for more things here, like `Set`s and `Map`s.
852
+ return className;
853
+ }
854
+
855
+ function dropObject(idx) {
856
+ if (idx < 1028) return;
857
+ heap[idx] = heap_next;
858
+ heap_next = idx;
859
+ }
860
+
861
+ function getArrayI32FromWasm0(ptr, len) {
862
+ ptr = ptr >>> 0;
863
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
864
+ }
865
+
866
+ function getArrayJsValueFromWasm0(ptr, len) {
867
+ ptr = ptr >>> 0;
868
+ const mem = getDataViewMemory0();
869
+ const result = [];
870
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
871
+ result.push(takeObject(mem.getUint32(i, true)));
872
+ }
873
+ return result;
874
+ }
875
+
876
+ function getArrayU32FromWasm0(ptr, len) {
877
+ ptr = ptr >>> 0;
878
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
879
+ }
880
+
881
+ function getArrayU8FromWasm0(ptr, len) {
882
+ ptr = ptr >>> 0;
883
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
884
+ }
885
+
886
+ let cachedDataViewMemory0 = null;
887
+ function getDataViewMemory0() {
888
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
889
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
890
+ }
891
+ return cachedDataViewMemory0;
892
+ }
893
+
894
+ let cachedInt32ArrayMemory0 = null;
895
+ function getInt32ArrayMemory0() {
896
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
897
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
898
+ }
899
+ return cachedInt32ArrayMemory0;
900
+ }
901
+
902
+ function getStringFromWasm0(ptr, len) {
903
+ return decodeText(ptr >>> 0, len);
904
+ }
905
+
906
+ let cachedUint32ArrayMemory0 = null;
907
+ function getUint32ArrayMemory0() {
908
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
909
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
910
+ }
911
+ return cachedUint32ArrayMemory0;
912
+ }
913
+
914
+ let cachedUint8ArrayMemory0 = null;
915
+ function getUint8ArrayMemory0() {
916
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
917
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
918
+ }
919
+ return cachedUint8ArrayMemory0;
920
+ }
921
+
922
+ function getObject(idx) { return heap[idx]; }
923
+
924
+ function handleError(f, args) {
925
+ try {
926
+ return f.apply(this, args);
927
+ } catch (e) {
928
+ wasm.__wbindgen_export3(addHeapObject(e));
929
+ }
930
+ }
931
+
932
+ let heap = new Array(1024).fill(undefined);
933
+ heap.push(undefined, null, true, false);
934
+
935
+ let heap_next = heap.length;
936
+
937
+ function isLikeNone(x) {
938
+ return x === undefined || x === null;
939
+ }
940
+
941
+ function makeMutClosure(arg0, arg1, f) {
942
+ const state = { a: arg0, b: arg1, cnt: 1 };
943
+ const real = (...args) => {
944
+
945
+ // First up with a closure we increment the internal reference
946
+ // count. This ensures that the Rust closure environment won't
947
+ // be deallocated while we're invoking it.
948
+ state.cnt++;
949
+ const a = state.a;
950
+ state.a = 0;
951
+ try {
952
+ return f(a, state.b, ...args);
953
+ } finally {
954
+ state.a = a;
955
+ real._wbg_cb_unref();
956
+ }
957
+ };
958
+ real._wbg_cb_unref = () => {
959
+ if (--state.cnt === 0) {
960
+ wasm.__wbindgen_export4(state.a, state.b);
961
+ state.a = 0;
962
+ CLOSURE_DTORS.unregister(state);
963
+ }
964
+ };
965
+ CLOSURE_DTORS.register(real, state, state);
966
+ return real;
967
+ }
968
+
969
+ function passArray8ToWasm0(arg, malloc) {
970
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
971
+ getUint8ArrayMemory0().set(arg, ptr / 1);
972
+ WASM_VECTOR_LEN = arg.length;
973
+ return ptr;
974
+ }
975
+
976
+ function passArrayJsValueToWasm0(array, malloc) {
977
+ const ptr = malloc(array.length * 4, 4) >>> 0;
978
+ const mem = getDataViewMemory0();
979
+ for (let i = 0; i < array.length; i++) {
980
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
981
+ }
982
+ WASM_VECTOR_LEN = array.length;
983
+ return ptr;
984
+ }
985
+
986
+ function passStringToWasm0(arg, malloc, realloc) {
987
+ if (realloc === undefined) {
988
+ const buf = cachedTextEncoder.encode(arg);
989
+ const ptr = malloc(buf.length, 1) >>> 0;
990
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
991
+ WASM_VECTOR_LEN = buf.length;
992
+ return ptr;
993
+ }
994
+
995
+ let len = arg.length;
996
+ let ptr = malloc(len, 1) >>> 0;
997
+
998
+ const mem = getUint8ArrayMemory0();
999
+
1000
+ let offset = 0;
1001
+
1002
+ for (; offset < len; offset++) {
1003
+ const code = arg.charCodeAt(offset);
1004
+ if (code > 0x7F) break;
1005
+ mem[ptr + offset] = code;
1006
+ }
1007
+ if (offset !== len) {
1008
+ if (offset !== 0) {
1009
+ arg = arg.slice(offset);
1010
+ }
1011
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1012
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1013
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1014
+
1015
+ offset += ret.written;
1016
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1017
+ }
1018
+
1019
+ WASM_VECTOR_LEN = offset;
1020
+ return ptr;
1021
+ }
1022
+
1023
+ function takeObject(idx) {
1024
+ const ret = getObject(idx);
1025
+ dropObject(idx);
1026
+ return ret;
1027
+ }
1028
+
1029
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1030
+ cachedTextDecoder.decode();
1031
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1032
+ let numBytesDecoded = 0;
1033
+ function decodeText(ptr, len) {
1034
+ numBytesDecoded += len;
1035
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1036
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1037
+ cachedTextDecoder.decode();
1038
+ numBytesDecoded = len;
1039
+ }
1040
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1041
+ }
1042
+
1043
+ const cachedTextEncoder = new TextEncoder();
1044
+
1045
+ if (!('encodeInto' in cachedTextEncoder)) {
1046
+ cachedTextEncoder.encodeInto = function (arg, view) {
1047
+ const buf = cachedTextEncoder.encode(arg);
1048
+ view.set(buf);
1049
+ return {
1050
+ read: arg.length,
1051
+ written: buf.length
1052
+ };
1053
+ };
1054
+ }
1055
+
1056
+ let WASM_VECTOR_LEN = 0;
1057
+
1058
+ let wasmModule, wasmInstance, wasm;
1059
+ function __wbg_finalize_init(instance, module) {
1060
+ wasmInstance = instance;
1061
+ wasm = instance.exports;
1062
+ wasmModule = module;
1063
+ cachedDataViewMemory0 = null;
1064
+ cachedInt32ArrayMemory0 = null;
1065
+ cachedUint32ArrayMemory0 = null;
1066
+ cachedUint8ArrayMemory0 = null;
1067
+ return wasm;
1068
+ }
1069
+
1070
+ async function __wbg_load(module, imports) {
1071
+ if (typeof Response === 'function' && module instanceof Response) {
1072
+ if (!module.ok) {
1073
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1074
+ }
1075
+
1076
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1077
+ try {
1078
+ return await WebAssembly.instantiateStreaming(module, imports);
1079
+ } catch (e) {
1080
+ const validResponse = expectedResponseType(module.type);
1081
+
1082
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1083
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1084
+
1085
+ } else { throw e; }
1086
+ }
1087
+ }
1088
+
1089
+ const bytes = await module.arrayBuffer();
1090
+ return await WebAssembly.instantiate(bytes, imports);
1091
+ } else {
1092
+ const instance = await WebAssembly.instantiate(module, imports);
1093
+
1094
+ if (instance instanceof WebAssembly.Instance) {
1095
+ return { instance, module };
1096
+ } else {
1097
+ return instance;
1098
+ }
1099
+ }
1100
+
1101
+ function expectedResponseType(type) {
1102
+ switch (type) {
1103
+ case 'basic': case 'cors': case 'default': return true;
1104
+ }
1105
+ return false;
1106
+ }
1107
+ }
1108
+
1109
+ function initSync(module) {
1110
+ if (wasm !== undefined) return wasm;
1111
+
1112
+
1113
+ if (module !== undefined) {
1114
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1115
+ ({module} = module)
1116
+ } else {
1117
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1118
+ }
1119
+ }
1120
+
1121
+ const imports = __wbg_get_imports();
1122
+ if (!(module instanceof WebAssembly.Module)) {
1123
+ module = new WebAssembly.Module(module);
1124
+ }
1125
+ const instance = new WebAssembly.Instance(module, imports);
1126
+ return __wbg_finalize_init(instance, module);
1127
+ }
1128
+
1129
+ async function __wbg_init(module_or_path) {
1130
+ if (wasm !== undefined) return wasm;
1131
+
1132
+
1133
+ if (module_or_path !== undefined) {
1134
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1135
+ ({module_or_path} = module_or_path)
1136
+ } else {
1137
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1138
+ }
1139
+ }
1140
+
1141
+ if (module_or_path === undefined) {
1142
+ module_or_path = new URL('hephaestus_wasm_bg.wasm', import.meta.url);
1143
+ }
1144
+ const imports = __wbg_get_imports();
1145
+
1146
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1147
+ module_or_path = fetch(module_or_path);
1148
+ }
1149
+
1150
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1151
+
1152
+ return __wbg_finalize_init(instance, module);
1153
+ }
1154
+
1155
+ export { initSync, __wbg_init as default };