onda-engine 0.1.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,598 @@
1
+ /* @ts-self-types="./onda_wasm.d.ts" */
2
+
3
+ /**
4
+ * Font-level vertical metrics exposed to JS — distances in pixels at the
5
+ * measured font size. Returned by [`OndaEngine::font_metrics`].
6
+ */
7
+ export class FontMetricsJs {
8
+ static __wrap(ptr) {
9
+ const obj = Object.create(FontMetricsJs.prototype);
10
+ obj.__wbg_ptr = ptr;
11
+ FontMetricsJsFinalization.register(obj, obj.__wbg_ptr, obj);
12
+ return obj;
13
+ }
14
+ __destroy_into_raw() {
15
+ const ptr = this.__wbg_ptr;
16
+ this.__wbg_ptr = 0;
17
+ FontMetricsJsFinalization.unregister(this);
18
+ return ptr;
19
+ }
20
+ free() {
21
+ const ptr = this.__destroy_into_raw();
22
+ wasm.__wbg_fontmetricsjs_free(ptr, 0);
23
+ }
24
+ /**
25
+ * Distance from node's `y` to the baseline (same as `TextMetrics.ascent`, px).
26
+ * @returns {number}
27
+ */
28
+ get ascent() {
29
+ const ret = wasm.fontmetricsjs_ascent(this.__wbg_ptr);
30
+ return ret;
31
+ }
32
+ /**
33
+ * Height of capital letters (top of caps to baseline, px).
34
+ * @returns {number}
35
+ */
36
+ get cap_height() {
37
+ const ret = wasm.fontmetricsjs_cap_height(this.__wbg_ptr);
38
+ return ret;
39
+ }
40
+ /**
41
+ * Distance from the node's `y` to the top of capital letters (px).
42
+ * @returns {number}
43
+ */
44
+ get cap_top() {
45
+ const ret = wasm.fontmetricsjs_cap_top(this.__wbg_ptr);
46
+ return ret;
47
+ }
48
+ /**
49
+ * Baseline to bottom of the line box (px).
50
+ * @returns {number}
51
+ */
52
+ get descent() {
53
+ const ret = wasm.fontmetricsjs_descent(this.__wbg_ptr);
54
+ return ret;
55
+ }
56
+ /**
57
+ * Baseline-to-baseline line height (px).
58
+ * @returns {number}
59
+ */
60
+ get lineHeight() {
61
+ const ret = wasm.fontmetricsjs_lineHeight(this.__wbg_ptr);
62
+ return ret;
63
+ }
64
+ /**
65
+ * x-height in px (top of 'x' to baseline).
66
+ * @returns {number}
67
+ */
68
+ get x_height() {
69
+ const ret = wasm.fontmetricsjs_x_height(this.__wbg_ptr);
70
+ return ret;
71
+ }
72
+ /**
73
+ * Distance from the node's `y` to the top of lowercase x (px).
74
+ * @returns {number}
75
+ */
76
+ get x_top() {
77
+ const ret = wasm.fontmetricsjs_x_top(this.__wbg_ptr);
78
+ return ret;
79
+ }
80
+ }
81
+ if (Symbol.dispose) FontMetricsJs.prototype[Symbol.dispose] = FontMetricsJs.prototype.free;
82
+
83
+ /**
84
+ * The engine: holds a renderer (with the bundled default font) and rasterizes
85
+ * scene-graph JSON to frames. Construct once and reuse across frames.
86
+ */
87
+ export class OndaEngine {
88
+ __destroy_into_raw() {
89
+ const ptr = this.__wbg_ptr;
90
+ this.__wbg_ptr = 0;
91
+ OndaEngineFinalization.unregister(this);
92
+ return ptr;
93
+ }
94
+ free() {
95
+ const ptr = this.__destroy_into_raw();
96
+ wasm.__wbg_ondaengine_free(ptr, 0);
97
+ }
98
+ /**
99
+ * Font-level vertical metrics for `font_size` + optional family/weight/italic.
100
+ * Derived by rasterizing 'H' (cap height) and 'x' (x-height) — pixel-accurate
101
+ * for the actual rendered font. Call once per (size, family, weight) combo, not
102
+ * per frame. Use the returned `capTop`/`capHeight` to vertically center text
103
+ * without empirical guesswork.
104
+ * @param {number} font_size
105
+ * @param {string | null} [family]
106
+ * @param {number | null} [weight]
107
+ * @param {boolean | null} [italic]
108
+ * @returns {FontMetricsJs}
109
+ */
110
+ fontMetrics(font_size, family, weight, italic) {
111
+ var ptr0 = isLikeNone(family) ? 0 : passStringToWasm0(family, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
+ var len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.ondaengine_fontMetrics(this.__wbg_ptr, font_size, ptr0, len0, isLikeNone(weight) ? 0xFFFFFF : weight, isLikeNone(italic) ? 0xFFFFFF : italic ? 1 : 0);
114
+ return FontMetricsJs.__wrap(ret);
115
+ }
116
+ /**
117
+ * Kerning-aware glyph layout for `content` at `font_size`. Returns a
118
+ * `Float32Array` with 4 floats per cluster: `[start_byte, end_byte, x, advance]`.
119
+ * Unlike calling `measureText` per character, `advance` includes kern pairs.
120
+ * Slice with stride 4; the total advance sum equals the shaped line width.
121
+ * @param {string} content
122
+ * @param {number} font_size
123
+ * @param {string | null} [family]
124
+ * @param {number | null} [weight]
125
+ * @param {boolean | null} [italic]
126
+ * @param {number | null} [letter_spacing]
127
+ * @returns {Float32Array}
128
+ */
129
+ glyphLayout(content, font_size, family, weight, italic, letter_spacing) {
130
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ var ptr1 = isLikeNone(family) ? 0 : passStringToWasm0(family, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ var len1 = WASM_VECTOR_LEN;
134
+ const ret = wasm.ondaengine_glyphLayout(this.__wbg_ptr, ptr0, len0, font_size, ptr1, len1, isLikeNone(weight) ? 0xFFFFFF : weight, isLikeNone(italic) ? 0xFFFFFF : italic ? 1 : 0, isLikeNone(letter_spacing) ? Number.MAX_SAFE_INTEGER : Math.fround(letter_spacing));
135
+ var v3 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
136
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
137
+ return v3;
138
+ }
139
+ /**
140
+ * Load an additional font (`.ttf`/`.otf` bytes) so text can select it by
141
+ * family (e.g. a brand display face for kinetic typography). Returns the
142
+ * family name(s) it provides, newline-joined. Loaded into BOTH the renderer
143
+ * (which draws the glyphs) and the layout/measurement font context, so
144
+ * author-time `measureText`/`glyphLayout`/`fontMetrics` — and therefore
145
+ * `<TextAnimator>`/`KineticText` glyph placement — match what the engine
146
+ * draws. This is the custom-font parity guarantee: same bytes, same shaping,
147
+ * for measure and render. Mirrors `VelloEngine::load_font`.
148
+ * @param {Uint8Array} data
149
+ * @returns {string}
150
+ */
151
+ loadFont(data) {
152
+ let deferred2_0;
153
+ let deferred2_1;
154
+ try {
155
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
156
+ const len0 = WASM_VECTOR_LEN;
157
+ const ret = wasm.ondaengine_loadFont(this.__wbg_ptr, ptr0, len0);
158
+ deferred2_0 = ret[0];
159
+ deferred2_1 = ret[1];
160
+ return getStringFromWasm0(ret[0], ret[1]);
161
+ } finally {
162
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
163
+ }
164
+ }
165
+ /**
166
+ * Measure `content` at `font_size` (px) with optional family / weight /
167
+ * italic, returning its [`TextMetricsJs`]. The same shaping the engine draws,
168
+ * so a component can size underlines/pills/carets to the real text — in both
169
+ * the browser preview and (warmed once) the Node export path.
170
+ * @param {string} content
171
+ * @param {number} font_size
172
+ * @param {string | null} [family]
173
+ * @param {number | null} [weight]
174
+ * @param {boolean | null} [italic]
175
+ * @param {number | null} [letter_spacing]
176
+ * @returns {TextMetricsJs}
177
+ */
178
+ measureText(content, font_size, family, weight, italic, letter_spacing) {
179
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
180
+ const len0 = WASM_VECTOR_LEN;
181
+ var ptr1 = isLikeNone(family) ? 0 : passStringToWasm0(family, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
182
+ var len1 = WASM_VECTOR_LEN;
183
+ const ret = wasm.ondaengine_measureText(this.__wbg_ptr, ptr0, len0, font_size, ptr1, len1, isLikeNone(weight) ? 0xFFFFFF : weight, isLikeNone(italic) ? 0xFFFFFF : italic ? 1 : 0, isLikeNone(letter_spacing) ? Number.MAX_SAFE_INTEGER : Math.fround(letter_spacing));
184
+ return TextMetricsJs.__wrap(ret);
185
+ }
186
+ constructor() {
187
+ const ret = wasm.ondaengine_new();
188
+ this.__wbg_ptr = ret;
189
+ OndaEngineFinalization.register(this, this.__wbg_ptr, this);
190
+ return this;
191
+ }
192
+ /**
193
+ * Render a scene-graph JSON document (onda-scene format) to a frame.
194
+ * Resolves `data:` images and flex layout first (the same pre-passes the
195
+ * CLI runs), so an in-browser preview matches `onda export`.
196
+ * @param {string} scene_json
197
+ * @returns {RenderedFrame}
198
+ */
199
+ render(scene_json) {
200
+ const ptr0 = passStringToWasm0(scene_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
201
+ const len0 = WASM_VECTOR_LEN;
202
+ const ret = wasm.ondaengine_render(this.__wbg_ptr, ptr0, len0);
203
+ if (ret[2]) {
204
+ throw takeFromExternrefTable0(ret[1]);
205
+ }
206
+ return RenderedFrame.__wrap(ret[0]);
207
+ }
208
+ }
209
+ if (Symbol.dispose) OndaEngine.prototype[Symbol.dispose] = OndaEngine.prototype.free;
210
+
211
+ /**
212
+ * A rendered frame: RGBA8 pixels plus dimensions.
213
+ */
214
+ export class RenderedFrame {
215
+ static __wrap(ptr) {
216
+ const obj = Object.create(RenderedFrame.prototype);
217
+ obj.__wbg_ptr = ptr;
218
+ RenderedFrameFinalization.register(obj, obj.__wbg_ptr, obj);
219
+ return obj;
220
+ }
221
+ __destroy_into_raw() {
222
+ const ptr = this.__wbg_ptr;
223
+ this.__wbg_ptr = 0;
224
+ RenderedFrameFinalization.unregister(this);
225
+ return ptr;
226
+ }
227
+ free() {
228
+ const ptr = this.__destroy_into_raw();
229
+ wasm.__wbg_renderedframe_free(ptr, 0);
230
+ }
231
+ /**
232
+ * @returns {number}
233
+ */
234
+ get height() {
235
+ const ret = wasm.renderedframe_height(this.__wbg_ptr);
236
+ return ret >>> 0;
237
+ }
238
+ /**
239
+ * Straight-alpha RGBA8 bytes (`width * height * 4`), ready for an
240
+ * `ImageData` and `putImageData`.
241
+ * @returns {Uint8Array}
242
+ */
243
+ get pixels() {
244
+ const ret = wasm.renderedframe_pixels(this.__wbg_ptr);
245
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
246
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
247
+ return v1;
248
+ }
249
+ /**
250
+ * @returns {number}
251
+ */
252
+ get width() {
253
+ const ret = wasm.renderedframe_width(this.__wbg_ptr);
254
+ return ret >>> 0;
255
+ }
256
+ }
257
+ if (Symbol.dispose) RenderedFrame.prototype[Symbol.dispose] = RenderedFrame.prototype.free;
258
+
259
+ /**
260
+ * Rendered text dimensions ([`onda_renderer::TextMetrics`]) for JS — what a
261
+ * component needs to size things to the *actual* text (proportional advance,
262
+ * ascent/descent) instead of a glyph-count guess. Pixels at the measured size.
263
+ */
264
+ export class TextMetricsJs {
265
+ static __wrap(ptr) {
266
+ const obj = Object.create(TextMetricsJs.prototype);
267
+ obj.__wbg_ptr = ptr;
268
+ TextMetricsJsFinalization.register(obj, obj.__wbg_ptr, obj);
269
+ return obj;
270
+ }
271
+ __destroy_into_raw() {
272
+ const ptr = this.__wbg_ptr;
273
+ this.__wbg_ptr = 0;
274
+ TextMetricsJsFinalization.unregister(this);
275
+ return ptr;
276
+ }
277
+ free() {
278
+ const ptr = this.__destroy_into_raw();
279
+ wasm.__wbg_textmetricsjs_free(ptr, 0);
280
+ }
281
+ /**
282
+ * Top of the line box to the baseline.
283
+ * @returns {number}
284
+ */
285
+ get ascent() {
286
+ const ret = wasm.textmetricsjs_ascent(this.__wbg_ptr);
287
+ return ret;
288
+ }
289
+ /**
290
+ * Baseline to the bottom of the line box.
291
+ * @returns {number}
292
+ */
293
+ get descent() {
294
+ const ret = wasm.textmetricsjs_descent(this.__wbg_ptr);
295
+ return ret;
296
+ }
297
+ /**
298
+ * Total laid-out height (line height × line count).
299
+ * @returns {number}
300
+ */
301
+ get height() {
302
+ const ret = wasm.textmetricsjs_height(this.__wbg_ptr);
303
+ return ret;
304
+ }
305
+ /**
306
+ * Baseline-to-baseline line height.
307
+ * @returns {number}
308
+ */
309
+ get lineHeight() {
310
+ const ret = wasm.textmetricsjs_lineHeight(this.__wbg_ptr);
311
+ return ret;
312
+ }
313
+ /**
314
+ * Shaped advance width — the true rendered width of the string.
315
+ * @returns {number}
316
+ */
317
+ get width() {
318
+ const ret = wasm.textmetricsjs_width(this.__wbg_ptr);
319
+ return ret;
320
+ }
321
+ }
322
+ if (Symbol.dispose) TextMetricsJs.prototype[Symbol.dispose] = TextMetricsJs.prototype.free;
323
+ function __wbg_get_imports() {
324
+ const import0 = {
325
+ __proto__: null,
326
+ __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
327
+ const ret = Error(getStringFromWasm0(arg0, arg1));
328
+ return ret;
329
+ },
330
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
331
+ throw new Error(getStringFromWasm0(arg0, arg1));
332
+ },
333
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
334
+ let deferred0_0;
335
+ let deferred0_1;
336
+ try {
337
+ deferred0_0 = arg0;
338
+ deferred0_1 = arg1;
339
+ console.error(getStringFromWasm0(arg0, arg1));
340
+ } finally {
341
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
342
+ }
343
+ },
344
+ __wbg_new_227d7c05414eb861: function() {
345
+ const ret = new Error();
346
+ return ret;
347
+ },
348
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
349
+ const ret = arg1.stack;
350
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
351
+ const len1 = WASM_VECTOR_LEN;
352
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
353
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
354
+ },
355
+ __wbindgen_init_externref_table: function() {
356
+ const table = wasm.__wbindgen_externrefs;
357
+ const offset = table.grow(4);
358
+ table.set(0, undefined);
359
+ table.set(offset + 0, undefined);
360
+ table.set(offset + 1, null);
361
+ table.set(offset + 2, true);
362
+ table.set(offset + 3, false);
363
+ },
364
+ };
365
+ return {
366
+ __proto__: null,
367
+ "./onda_wasm_bg.js": import0,
368
+ };
369
+ }
370
+
371
+ const FontMetricsJsFinalization = (typeof FinalizationRegistry === 'undefined')
372
+ ? { register: () => {}, unregister: () => {} }
373
+ : new FinalizationRegistry(ptr => wasm.__wbg_fontmetricsjs_free(ptr, 1));
374
+ const OndaEngineFinalization = (typeof FinalizationRegistry === 'undefined')
375
+ ? { register: () => {}, unregister: () => {} }
376
+ : new FinalizationRegistry(ptr => wasm.__wbg_ondaengine_free(ptr, 1));
377
+ const RenderedFrameFinalization = (typeof FinalizationRegistry === 'undefined')
378
+ ? { register: () => {}, unregister: () => {} }
379
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderedframe_free(ptr, 1));
380
+ const TextMetricsJsFinalization = (typeof FinalizationRegistry === 'undefined')
381
+ ? { register: () => {}, unregister: () => {} }
382
+ : new FinalizationRegistry(ptr => wasm.__wbg_textmetricsjs_free(ptr, 1));
383
+
384
+ function getArrayF32FromWasm0(ptr, len) {
385
+ ptr = ptr >>> 0;
386
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
387
+ }
388
+
389
+ function getArrayU8FromWasm0(ptr, len) {
390
+ ptr = ptr >>> 0;
391
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
392
+ }
393
+
394
+ let cachedDataViewMemory0 = null;
395
+ function getDataViewMemory0() {
396
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
397
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
398
+ }
399
+ return cachedDataViewMemory0;
400
+ }
401
+
402
+ let cachedFloat32ArrayMemory0 = null;
403
+ function getFloat32ArrayMemory0() {
404
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
405
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
406
+ }
407
+ return cachedFloat32ArrayMemory0;
408
+ }
409
+
410
+ function getStringFromWasm0(ptr, len) {
411
+ return decodeText(ptr >>> 0, len);
412
+ }
413
+
414
+ let cachedUint8ArrayMemory0 = null;
415
+ function getUint8ArrayMemory0() {
416
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
417
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
418
+ }
419
+ return cachedUint8ArrayMemory0;
420
+ }
421
+
422
+ function isLikeNone(x) {
423
+ return x === undefined || x === null;
424
+ }
425
+
426
+ function passArray8ToWasm0(arg, malloc) {
427
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
428
+ getUint8ArrayMemory0().set(arg, ptr / 1);
429
+ WASM_VECTOR_LEN = arg.length;
430
+ return ptr;
431
+ }
432
+
433
+ function passStringToWasm0(arg, malloc, realloc) {
434
+ if (realloc === undefined) {
435
+ const buf = cachedTextEncoder.encode(arg);
436
+ const ptr = malloc(buf.length, 1) >>> 0;
437
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
438
+ WASM_VECTOR_LEN = buf.length;
439
+ return ptr;
440
+ }
441
+
442
+ let len = arg.length;
443
+ let ptr = malloc(len, 1) >>> 0;
444
+
445
+ const mem = getUint8ArrayMemory0();
446
+
447
+ let offset = 0;
448
+
449
+ for (; offset < len; offset++) {
450
+ const code = arg.charCodeAt(offset);
451
+ if (code > 0x7F) break;
452
+ mem[ptr + offset] = code;
453
+ }
454
+ if (offset !== len) {
455
+ if (offset !== 0) {
456
+ arg = arg.slice(offset);
457
+ }
458
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
459
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
460
+ const ret = cachedTextEncoder.encodeInto(arg, view);
461
+
462
+ offset += ret.written;
463
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
464
+ }
465
+
466
+ WASM_VECTOR_LEN = offset;
467
+ return ptr;
468
+ }
469
+
470
+ function takeFromExternrefTable0(idx) {
471
+ const value = wasm.__wbindgen_externrefs.get(idx);
472
+ wasm.__externref_table_dealloc(idx);
473
+ return value;
474
+ }
475
+
476
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
477
+ cachedTextDecoder.decode();
478
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
479
+ let numBytesDecoded = 0;
480
+ function decodeText(ptr, len) {
481
+ numBytesDecoded += len;
482
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
483
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
484
+ cachedTextDecoder.decode();
485
+ numBytesDecoded = len;
486
+ }
487
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
488
+ }
489
+
490
+ const cachedTextEncoder = new TextEncoder();
491
+
492
+ if (!('encodeInto' in cachedTextEncoder)) {
493
+ cachedTextEncoder.encodeInto = function (arg, view) {
494
+ const buf = cachedTextEncoder.encode(arg);
495
+ view.set(buf);
496
+ return {
497
+ read: arg.length,
498
+ written: buf.length
499
+ };
500
+ };
501
+ }
502
+
503
+ let WASM_VECTOR_LEN = 0;
504
+
505
+ let wasmModule, wasmInstance, wasm;
506
+ function __wbg_finalize_init(instance, module) {
507
+ wasmInstance = instance;
508
+ wasm = instance.exports;
509
+ wasmModule = module;
510
+ cachedDataViewMemory0 = null;
511
+ cachedFloat32ArrayMemory0 = null;
512
+ cachedUint8ArrayMemory0 = null;
513
+ wasm.__wbindgen_start();
514
+ return wasm;
515
+ }
516
+
517
+ async function __wbg_load(module, imports) {
518
+ if (typeof Response === 'function' && module instanceof Response) {
519
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
520
+ try {
521
+ return await WebAssembly.instantiateStreaming(module, imports);
522
+ } catch (e) {
523
+ const validResponse = module.ok && expectedResponseType(module.type);
524
+
525
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
526
+ 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);
527
+
528
+ } else { throw e; }
529
+ }
530
+ }
531
+
532
+ const bytes = await module.arrayBuffer();
533
+ return await WebAssembly.instantiate(bytes, imports);
534
+ } else {
535
+ const instance = await WebAssembly.instantiate(module, imports);
536
+
537
+ if (instance instanceof WebAssembly.Instance) {
538
+ return { instance, module };
539
+ } else {
540
+ return instance;
541
+ }
542
+ }
543
+
544
+ function expectedResponseType(type) {
545
+ switch (type) {
546
+ case 'basic': case 'cors': case 'default': return true;
547
+ }
548
+ return false;
549
+ }
550
+ }
551
+
552
+ function initSync(module) {
553
+ if (wasm !== undefined) return wasm;
554
+
555
+
556
+ if (module !== undefined) {
557
+ if (Object.getPrototypeOf(module) === Object.prototype) {
558
+ ({module} = module)
559
+ } else {
560
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
561
+ }
562
+ }
563
+
564
+ const imports = __wbg_get_imports();
565
+ if (!(module instanceof WebAssembly.Module)) {
566
+ module = new WebAssembly.Module(module);
567
+ }
568
+ const instance = new WebAssembly.Instance(module, imports);
569
+ return __wbg_finalize_init(instance, module);
570
+ }
571
+
572
+ async function __wbg_init(module_or_path) {
573
+ if (wasm !== undefined) return wasm;
574
+
575
+
576
+ if (module_or_path !== undefined) {
577
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
578
+ ({module_or_path} = module_or_path)
579
+ } else {
580
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
581
+ }
582
+ }
583
+
584
+ if (module_or_path === undefined) {
585
+ module_or_path = new URL('onda_wasm_bg.wasm', import.meta.url);
586
+ }
587
+ const imports = __wbg_get_imports();
588
+
589
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
590
+ module_or_path = fetch(module_or_path);
591
+ }
592
+
593
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
594
+
595
+ return __wbg_finalize_init(instance, module);
596
+ }
597
+
598
+ export { initSync, __wbg_init as default };
Binary file