@reearth/ezu 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,697 @@
1
+ /* @ts-self-types="./ezu.d.ts" */
2
+
3
+ /**
4
+ * Buffered log sink that captures `tracing` events from the renderer.
5
+ *
6
+ * Construct once near the top of your bootstrap, then either set a
7
+ * callback for live forwarding (`onEvent(e => console.log(e))`) or
8
+ * `drainLines()` periodically to flush into a UI panel.
9
+ */
10
+ export class LogSink {
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ LogSinkFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_logsink_free(ptr, 0);
20
+ }
21
+ /**
22
+ * Drop all buffered records without returning them.
23
+ */
24
+ clear() {
25
+ wasm.logsink_clear(this.__wbg_ptr);
26
+ }
27
+ /**
28
+ * Drain every buffered record. Returns a JS array of structured
29
+ * objects `{ level, target, message, fields, timestampMs }`.
30
+ * @returns {Array<any>}
31
+ */
32
+ drain() {
33
+ const ret = wasm.logsink_drain(this.__wbg_ptr);
34
+ return ret;
35
+ }
36
+ /**
37
+ * Drain buffered records and return pre-formatted strings — the
38
+ * same shape the CLI prints. Convenient for `console.log(lines.join('\n'))`.
39
+ * @returns {string[]}
40
+ */
41
+ drainLines() {
42
+ const ret = wasm.logsink_drainLines(this.__wbg_ptr);
43
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
44
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
45
+ return v1;
46
+ }
47
+ /**
48
+ * `true` if no records are buffered.
49
+ * @returns {boolean}
50
+ */
51
+ isEmpty() {
52
+ const ret = wasm.logsink_isEmpty(this.__wbg_ptr);
53
+ return ret !== 0;
54
+ }
55
+ /**
56
+ * Number of records currently buffered.
57
+ * @returns {number}
58
+ */
59
+ get len() {
60
+ const ret = wasm.logsink_len(this.__wbg_ptr);
61
+ return ret >>> 0;
62
+ }
63
+ /**
64
+ * Install (idempotently) the global tracing subscriber. `level` is
65
+ * an `EnvFilter` string — e.g. `"info"`, `"debug"`,
66
+ * `"info,ezu_graph::eval=debug"`. Honoured on first call only.
67
+ * @param {string} level
68
+ */
69
+ constructor(level) {
70
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
71
+ const len0 = WASM_VECTOR_LEN;
72
+ const ret = wasm.logsink_new(ptr0, len0);
73
+ if (ret[2]) {
74
+ throw takeFromExternrefTable0(ret[1]);
75
+ }
76
+ this.__wbg_ptr = ret[0];
77
+ LogSinkFinalization.register(this, this.__wbg_ptr, this);
78
+ return this;
79
+ }
80
+ /**
81
+ * Set (or clear with `null` / `undefined`) the per-event JS
82
+ * callback. The callback receives a structured record object.
83
+ *
84
+ * No-op in multithreaded (`threads`) builds — events can originate
85
+ * on rayon worker threads, so live forwarding to a main-thread JS
86
+ * callback isn't available. Use `drain` / `drainLines` instead.
87
+ * @param {Function | null} [callback]
88
+ */
89
+ onEvent(callback) {
90
+ wasm.logsink_onEvent(this.__wbg_ptr, isLikeNone(callback) ? 0 : addToExternrefTable0(callback));
91
+ }
92
+ /**
93
+ * Resize the ring-buffer cap. Older entries are evicted FIFO once
94
+ * the buffer reaches the new cap. Default is 4096.
95
+ * @param {number} cap
96
+ */
97
+ setCapacity(cap) {
98
+ wasm.logsink_setCapacity(this.__wbg_ptr, cap);
99
+ }
100
+ }
101
+ if (Symbol.dispose) LogSink.prototype[Symbol.dispose] = LogSink.prototype.free;
102
+
103
+ /**
104
+ * Stateful WASM renderer.
105
+ */
106
+ export class Renderer {
107
+ __destroy_into_raw() {
108
+ const ptr = this.__wbg_ptr;
109
+ this.__wbg_ptr = 0;
110
+ RendererFinalization.unregister(this);
111
+ return ptr;
112
+ }
113
+ free() {
114
+ const ptr = this.__destroy_into_raw();
115
+ wasm.__wbg_renderer_free(ptr, 0);
116
+ }
117
+ /**
118
+ * Effective attribution declared by the style (document +
119
+ * sources), joined with ` | `. Upstream TileJSON / PMTiles
120
+ * metadata is the JS host's concern — merge it on that side.
121
+ * @returns {string | undefined}
122
+ */
123
+ get attribution() {
124
+ const ret = wasm.renderer_attribution(this.__wbg_ptr);
125
+ let v1;
126
+ if (ret[0] !== 0) {
127
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
128
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
129
+ }
130
+ return v1;
131
+ }
132
+ /**
133
+ * Bind raw tile bytes under a `sources.<name>` entry from the style.
134
+ * The renderer dispatches on the source's declared `type`:
135
+ *
136
+ * - `mvt` / `pmtiles` → store raw MVT bytes per `(dx, dy)` neighbour
137
+ * offset (centre `coord: [0, 0]`, the default). Layers are bound as
138
+ * `<source>.<layer>` (centre) or `<source>.<layer>@dx,dy`
139
+ * (neighbours) when [`render_tile`] runs. Binding only the centre
140
+ * degrades cross-tile label collision to centre-only at borders.
141
+ * - `dem` / `raster` → store the raw bytes per `(dx, dy)` neighbour
142
+ * offset. The centre tile is `coord: [0, 0]` (default). Decoding
143
+ * and 3×3 stitching happen at render time once the tile id is known.
144
+ * - `geojson` (remote) → store raw bytes per `(dx, dy)` offset;
145
+ * projected per tile (and neighbour) at render time.
146
+ *
147
+ * `opts` is a JS object: `{ coord?: [dx, dy] }`. Throws
148
+ * `UnknownSource` if `name` doesn't match any entry in the style's
149
+ * `sources` block, `MvtDecode` if MVT bytes don't parse, and
150
+ * `DemDecode` for non-image DEM bytes (the decode itself runs at
151
+ * render time, but obvious cases are caught here).
152
+ * @param {string} name
153
+ * @param {Uint8Array} bytes
154
+ * @param {object | null} [opts]
155
+ */
156
+ bindSource(name, bytes, opts) {
157
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
158
+ const len0 = WASM_VECTOR_LEN;
159
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc_command_export);
160
+ const len1 = WASM_VECTOR_LEN;
161
+ const ret = wasm.renderer_bindSource(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(opts) ? 0 : addToExternrefTable0(opts));
162
+ if (ret[1]) {
163
+ throw takeFromExternrefTable0(ret[0]);
164
+ }
165
+ }
166
+ /**
167
+ * Names of every source with at least one pending binding.
168
+ * Order matches the style's `sources` declaration order.
169
+ * @returns {string[]}
170
+ */
171
+ boundSources() {
172
+ const ret = wasm.renderer_boundSources(this.__wbg_ptr);
173
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
174
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
175
+ return v1;
176
+ }
177
+ /**
178
+ * Drop every pending source binding. Call between tile renders.
179
+ */
180
+ clearSources() {
181
+ wasm.renderer_clearSources(this.__wbg_ptr);
182
+ }
183
+ /**
184
+ * Glyph ranges the currently bound features can require, as
185
+ * `{ [glyphsSourceName]: number[] }` where each number is a range
186
+ * start (`0`, `256`, `512`, …) — i.e. the `{range}` in a
187
+ * `…/{fontstack}/{range}.pbf` URL is `<start>-<start + 255>`.
188
+ *
189
+ * This host cannot fetch glyph ranges lazily, so every range a
190
+ * tile's labels touch must be bound before `renderTile`. Rather than
191
+ * scraping every string in the MVT, call this after binding the
192
+ * vector sources and bind exactly the listed ranges.
193
+ *
194
+ * It is an over-approximation, deliberately: a range is listed if
195
+ * *any* feature in a text layer carries the codepoint in a property
196
+ * the layer's `text` expression reads, without evaluating filters,
197
+ * zoom ranges, or the expression itself, and it is listed for every
198
+ * fontstack in that layer's fallback chain. So it never omits a
199
+ * range a label needs, and it may name a few that go unused. Text
200
+ * layers that build their string from something other than a `get`
201
+ * of a feature property (a literal, a `concat` of formatted values)
202
+ * contribute their literal text where it is a plain string.
203
+ * @returns {object}
204
+ */
205
+ neededGlyphRanges() {
206
+ const ret = wasm.renderer_neededGlyphRanges(this.__wbg_ptr);
207
+ if (ret[2]) {
208
+ throw takeFromExternrefTable0(ret[1]);
209
+ }
210
+ return takeFromExternrefTable0(ret[0]);
211
+ }
212
+ /**
213
+ * Build a renderer from a style JSON document.
214
+ * @param {string} style_json
215
+ */
216
+ constructor(style_json) {
217
+ const ptr0 = passStringToWasm0(style_json, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
218
+ const len0 = WASM_VECTOR_LEN;
219
+ const ret = wasm.renderer_new(ptr0, len0);
220
+ if (ret[2]) {
221
+ throw takeFromExternrefTable0(ret[1]);
222
+ }
223
+ this.__wbg_ptr = ret[0];
224
+ RendererFinalization.register(this, this.__wbg_ptr, this);
225
+ return this;
226
+ }
227
+ /**
228
+ * Render a single tile using whatever sources are currently bound.
229
+ *
230
+ * `opts` (JS object, all fields optional):
231
+ * - `format`: `"png"` (default) / `"webp"` / `"rgba"`
232
+ * - `tileSize`, `pad`: override the style's canvas size for this
233
+ * call (hi-DPI / preview)
234
+ * - `png`: `{ compression?: "fast" | "default" | "best" }`
235
+ * @param {number} z
236
+ * @param {number} x
237
+ * @param {number} y
238
+ * @param {object | null} [opts]
239
+ * @returns {Uint8Array}
240
+ */
241
+ renderTile(z, x, y, opts) {
242
+ const ret = wasm.renderer_renderTile(this.__wbg_ptr, z, x, y, isLikeNone(opts) ? 0 : addToExternrefTable0(opts));
243
+ if (ret[3]) {
244
+ throw takeFromExternrefTable0(ret[2]);
245
+ }
246
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
247
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
248
+ return v1;
249
+ }
250
+ /**
251
+ * Neighbour tile offsets the active style actually asks for from
252
+ * `source`, as an array of `[dx, dy]` pairs (never including the
253
+ * centre `[0, 0]`).
254
+ *
255
+ * Cross-tile label collision and edge-continuous DEM shading are the
256
+ * only things that read neighbours, and only for the sources they
257
+ * name. A host that fetches the full 3×3 window unconditionally
258
+ * therefore pays for up to eight tiles it will not look at; passing
259
+ * each offset from this list to `bindSource(name, bytes, { coord })`
260
+ * fetches exactly what the recipe needs. An empty array means the
261
+ * centre tile is enough.
262
+ *
263
+ * Throws `UnknownSource` if `name` is not declared in the style.
264
+ * @param {string} name
265
+ * @returns {Array<any>}
266
+ */
267
+ requestedNeighborOffsets(name) {
268
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
269
+ const len0 = WASM_VECTOR_LEN;
270
+ const ret = wasm.renderer_requestedNeighborOffsets(this.__wbg_ptr, ptr0, len0);
271
+ if (ret[2]) {
272
+ throw takeFromExternrefTable0(ret[1]);
273
+ }
274
+ return takeFromExternrefTable0(ret[0]);
275
+ }
276
+ /**
277
+ * Replace the active style. Returns the new node count. Invalidates
278
+ * the intermediate cache and drops any pending source bindings.
279
+ * @param {string} style_json
280
+ * @returns {number}
281
+ */
282
+ setStyle(style_json) {
283
+ const ptr0 = passStringToWasm0(style_json, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
284
+ const len0 = WASM_VECTOR_LEN;
285
+ const ret = wasm.renderer_setStyle(this.__wbg_ptr, ptr0, len0);
286
+ if (ret[2]) {
287
+ throw takeFromExternrefTable0(ret[1]);
288
+ }
289
+ return ret[0] >>> 0;
290
+ }
291
+ /**
292
+ * `tile-size` declared by the current style.
293
+ * @returns {number}
294
+ */
295
+ get tileSize() {
296
+ const ret = wasm.renderer_tileSize(this.__wbg_ptr);
297
+ return ret >>> 0;
298
+ }
299
+ }
300
+ if (Symbol.dispose) Renderer.prototype[Symbol.dispose] = Renderer.prototype.free;
301
+
302
+ /**
303
+ * Whether the wasm binary was compiled with `+simd128`. Lets the demo
304
+ * page label the renderer build accurately.
305
+ * @returns {boolean}
306
+ */
307
+ export function simdEnabled() {
308
+ const ret = wasm.simdEnabled();
309
+ return ret !== 0;
310
+ }
311
+
312
+ /**
313
+ * Whether this build supports multithreaded rendering (compiled with
314
+ * the `threads` feature). When `false`, `initThreadPool` is absent and
315
+ * `renderTile`'s `parallel` option is a no-op. Mirrors `simdEnabled` so
316
+ * the host can label the build.
317
+ * @returns {boolean}
318
+ */
319
+ export function threadsEnabled() {
320
+ const ret = wasm.threadsEnabled();
321
+ return ret !== 0;
322
+ }
323
+ function __wbg_get_imports() {
324
+ const import0 = {
325
+ __proto__: null,
326
+ __wbg___wbindgen_boolean_get_2304fb8c853028c8: function(arg0) {
327
+ const v = arg0;
328
+ const ret = typeof(v) === 'boolean' ? v : undefined;
329
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
330
+ },
331
+ __wbg___wbindgen_is_null_2042690d351e14f0: function(arg0) {
332
+ const ret = arg0 === null;
333
+ return ret;
334
+ },
335
+ __wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
336
+ const ret = arg0 === undefined;
337
+ return ret;
338
+ },
339
+ __wbg___wbindgen_number_get_f73a1244370fcc2c: function(arg0, arg1) {
340
+ const obj = arg1;
341
+ const ret = typeof(obj) === 'number' ? obj : undefined;
342
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
343
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
344
+ },
345
+ __wbg___wbindgen_rethrow_2b7cc655458909c2: function(arg0) {
346
+ throw arg0;
347
+ },
348
+ __wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
349
+ const obj = arg1;
350
+ const ret = typeof(obj) === 'string' ? obj : undefined;
351
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
352
+ var len1 = WASM_VECTOR_LEN;
353
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
354
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
355
+ },
356
+ __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
357
+ throw new Error(getStringFromWasm0(arg0, arg1));
358
+ },
359
+ __wbg_call_dfde26266607c996: function() { return handleError(function (arg0, arg1, arg2) {
360
+ const ret = arg0.call(arg1, arg2);
361
+ return ret;
362
+ }, arguments); },
363
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
364
+ let deferred0_0;
365
+ let deferred0_1;
366
+ try {
367
+ deferred0_0 = arg0;
368
+ deferred0_1 = arg1;
369
+ console.error(getStringFromWasm0(arg0, arg1));
370
+ } finally {
371
+ wasm.__wbindgen_free_command_export(deferred0_0, deferred0_1, 1);
372
+ }
373
+ },
374
+ __wbg_get_98fdf51d029a75eb: function(arg0, arg1) {
375
+ const ret = arg0[arg1 >>> 0];
376
+ return ret;
377
+ },
378
+ __wbg_get_dcf82ab8aad1a593: function() { return handleError(function (arg0, arg1) {
379
+ const ret = Reflect.get(arg0, arg1);
380
+ return ret;
381
+ }, arguments); },
382
+ __wbg_instanceof_Object_03924e0dbda74bd8: function(arg0) {
383
+ let result;
384
+ try {
385
+ result = arg0 instanceof Object;
386
+ } catch (_) {
387
+ result = false;
388
+ }
389
+ const ret = result;
390
+ return ret;
391
+ },
392
+ __wbg_isArray_94898ed3aad6947b: function(arg0) {
393
+ const ret = Array.isArray(arg0);
394
+ return ret;
395
+ },
396
+ __wbg_length_2591a0f4f659a55c: function(arg0) {
397
+ const ret = arg0.length;
398
+ return ret;
399
+ },
400
+ __wbg_new_02d162bc6cf02f60: function() {
401
+ const ret = new Object();
402
+ return ret;
403
+ },
404
+ __wbg_new_1f236d63ba0c4784: function(arg0, arg1) {
405
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
406
+ return ret;
407
+ },
408
+ __wbg_new_227d7c05414eb861: function() {
409
+ const ret = new Error();
410
+ return ret;
411
+ },
412
+ __wbg_new_310879b66b6e95e1: function() {
413
+ const ret = new Array();
414
+ return ret;
415
+ },
416
+ __wbg_now_81363d44c96dd239: function() {
417
+ const ret = Date.now();
418
+ return ret;
419
+ },
420
+ __wbg_push_b77c476b01548d0a: function(arg0, arg1) {
421
+ const ret = arg0.push(arg1);
422
+ return ret;
423
+ },
424
+ __wbg_set_a0e911be3da02782: function() { return handleError(function (arg0, arg1, arg2) {
425
+ const ret = Reflect.set(arg0, arg1, arg2);
426
+ return ret;
427
+ }, arguments); },
428
+ __wbg_set_name_e500733c75ec36b0: function(arg0, arg1, arg2) {
429
+ arg0.name = getStringFromWasm0(arg1, arg2);
430
+ },
431
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
432
+ const ret = arg1.stack;
433
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
434
+ const len1 = WASM_VECTOR_LEN;
435
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
436
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
437
+ },
438
+ __wbindgen_cast_0000000000000001: function(arg0) {
439
+ // Cast intrinsic for `F64 -> Externref`.
440
+ const ret = arg0;
441
+ return ret;
442
+ },
443
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
444
+ // Cast intrinsic for `Ref(String) -> Externref`.
445
+ const ret = getStringFromWasm0(arg0, arg1);
446
+ return ret;
447
+ },
448
+ __wbindgen_init_externref_table: function() {
449
+ const table = wasm.__wbindgen_externrefs;
450
+ const offset = table.grow(4);
451
+ table.set(0, undefined);
452
+ table.set(offset + 0, undefined);
453
+ table.set(offset + 1, null);
454
+ table.set(offset + 2, true);
455
+ table.set(offset + 3, false);
456
+ },
457
+ };
458
+ return {
459
+ __proto__: null,
460
+ "./ezu_bg.js": import0,
461
+ };
462
+ }
463
+
464
+ const LogSinkFinalization = (typeof FinalizationRegistry === 'undefined')
465
+ ? { register: () => {}, unregister: () => {} }
466
+ : new FinalizationRegistry(ptr => wasm.__wbg_logsink_free(ptr, 1));
467
+ const RendererFinalization = (typeof FinalizationRegistry === 'undefined')
468
+ ? { register: () => {}, unregister: () => {} }
469
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderer_free(ptr, 1));
470
+
471
+ function addToExternrefTable0(obj) {
472
+ const idx = wasm.__externref_table_alloc_command_export();
473
+ wasm.__wbindgen_externrefs.set(idx, obj);
474
+ return idx;
475
+ }
476
+
477
+ function getArrayJsValueFromWasm0(ptr, len) {
478
+ ptr = ptr >>> 0;
479
+ const mem = getDataViewMemory0();
480
+ const result = [];
481
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
482
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
483
+ }
484
+ wasm.__externref_drop_slice_command_export(ptr, len);
485
+ return result;
486
+ }
487
+
488
+ function getArrayU8FromWasm0(ptr, len) {
489
+ ptr = ptr >>> 0;
490
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
491
+ }
492
+
493
+ let cachedDataViewMemory0 = null;
494
+ function getDataViewMemory0() {
495
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
496
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
497
+ }
498
+ return cachedDataViewMemory0;
499
+ }
500
+
501
+ function getStringFromWasm0(ptr, len) {
502
+ return decodeText(ptr >>> 0, len);
503
+ }
504
+
505
+ let cachedUint8ArrayMemory0 = null;
506
+ function getUint8ArrayMemory0() {
507
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
508
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
509
+ }
510
+ return cachedUint8ArrayMemory0;
511
+ }
512
+
513
+ function handleError(f, args) {
514
+ try {
515
+ return f.apply(this, args);
516
+ } catch (e) {
517
+ const idx = addToExternrefTable0(e);
518
+ wasm.__wbindgen_exn_store_command_export(idx);
519
+ }
520
+ }
521
+
522
+ function isLikeNone(x) {
523
+ return x === undefined || x === null;
524
+ }
525
+
526
+ function passArray8ToWasm0(arg, malloc) {
527
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
528
+ getUint8ArrayMemory0().set(arg, ptr / 1);
529
+ WASM_VECTOR_LEN = arg.length;
530
+ return ptr;
531
+ }
532
+
533
+ function passStringToWasm0(arg, malloc, realloc) {
534
+ if (realloc === undefined) {
535
+ const buf = cachedTextEncoder.encode(arg);
536
+ const ptr = malloc(buf.length, 1) >>> 0;
537
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
538
+ WASM_VECTOR_LEN = buf.length;
539
+ return ptr;
540
+ }
541
+
542
+ let len = arg.length;
543
+ let ptr = malloc(len, 1) >>> 0;
544
+
545
+ const mem = getUint8ArrayMemory0();
546
+
547
+ let offset = 0;
548
+
549
+ for (; offset < len; offset++) {
550
+ const code = arg.charCodeAt(offset);
551
+ if (code > 0x7F) break;
552
+ mem[ptr + offset] = code;
553
+ }
554
+ if (offset !== len) {
555
+ if (offset !== 0) {
556
+ arg = arg.slice(offset);
557
+ }
558
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
559
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
560
+ const ret = cachedTextEncoder.encodeInto(arg, view);
561
+
562
+ offset += ret.written;
563
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
564
+ }
565
+
566
+ WASM_VECTOR_LEN = offset;
567
+ return ptr;
568
+ }
569
+
570
+ function takeFromExternrefTable0(idx) {
571
+ const value = wasm.__wbindgen_externrefs.get(idx);
572
+ wasm.__externref_table_dealloc_command_export(idx);
573
+ return value;
574
+ }
575
+
576
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
577
+ cachedTextDecoder.decode();
578
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
579
+ let numBytesDecoded = 0;
580
+ function decodeText(ptr, len) {
581
+ numBytesDecoded += len;
582
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
583
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
584
+ cachedTextDecoder.decode();
585
+ numBytesDecoded = len;
586
+ }
587
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
588
+ }
589
+
590
+ const cachedTextEncoder = new TextEncoder();
591
+
592
+ if (!('encodeInto' in cachedTextEncoder)) {
593
+ cachedTextEncoder.encodeInto = function (arg, view) {
594
+ const buf = cachedTextEncoder.encode(arg);
595
+ view.set(buf);
596
+ return {
597
+ read: arg.length,
598
+ written: buf.length
599
+ };
600
+ };
601
+ }
602
+
603
+ let WASM_VECTOR_LEN = 0;
604
+
605
+ let wasmModule, wasmInstance, wasm;
606
+ function __wbg_finalize_init(instance, module) {
607
+ wasmInstance = instance;
608
+ wasm = instance.exports;
609
+ wasmModule = module;
610
+ cachedDataViewMemory0 = null;
611
+ cachedUint8ArrayMemory0 = null;
612
+ wasm.__wbindgen_start();
613
+ return wasm;
614
+ }
615
+
616
+ async function __wbg_load(module, imports) {
617
+ if (typeof Response === 'function' && module instanceof Response) {
618
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
619
+ try {
620
+ return await WebAssembly.instantiateStreaming(module, imports);
621
+ } catch (e) {
622
+ const validResponse = module.ok && expectedResponseType(module.type);
623
+
624
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
625
+ 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);
626
+
627
+ } else { throw e; }
628
+ }
629
+ }
630
+
631
+ const bytes = await module.arrayBuffer();
632
+ return await WebAssembly.instantiate(bytes, imports);
633
+ } else {
634
+ const instance = await WebAssembly.instantiate(module, imports);
635
+
636
+ if (instance instanceof WebAssembly.Instance) {
637
+ return { instance, module };
638
+ } else {
639
+ return instance;
640
+ }
641
+ }
642
+
643
+ function expectedResponseType(type) {
644
+ switch (type) {
645
+ case 'basic': case 'cors': case 'default': return true;
646
+ }
647
+ return false;
648
+ }
649
+ }
650
+
651
+ function initSync(module) {
652
+ if (wasm !== undefined) return wasm;
653
+
654
+
655
+ if (module !== undefined) {
656
+ if (Object.getPrototypeOf(module) === Object.prototype) {
657
+ ({module} = module)
658
+ } else {
659
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
660
+ }
661
+ }
662
+
663
+ const imports = __wbg_get_imports();
664
+ if (!(module instanceof WebAssembly.Module)) {
665
+ module = new WebAssembly.Module(module);
666
+ }
667
+ const instance = new WebAssembly.Instance(module, imports);
668
+ return __wbg_finalize_init(instance, module);
669
+ }
670
+
671
+ async function __wbg_init(module_or_path) {
672
+ if (wasm !== undefined) return wasm;
673
+
674
+
675
+ if (module_or_path !== undefined) {
676
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
677
+ ({module_or_path} = module_or_path)
678
+ } else {
679
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
680
+ }
681
+ }
682
+
683
+ if (module_or_path === undefined) {
684
+ module_or_path = new URL('ezu_bg.wasm', import.meta.url);
685
+ }
686
+ const imports = __wbg_get_imports();
687
+
688
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
689
+ module_or_path = fetch(module_or_path);
690
+ }
691
+
692
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
693
+
694
+ return __wbg_finalize_init(instance, module);
695
+ }
696
+
697
+ export { initSync, __wbg_init as default };
Binary file