@i7r.tech/moveby 0.0.0-stage → 0.21.1-ywc

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,766 @@
1
+ /* @ts-self-types="./wasm_engine.d.ts" */
2
+
3
+ /**
4
+ * The SHAPE of a lane divider (engine-lanes.v1.1 §4, lane-divider-type.md). `#[wasm_bindgen]` exports it to
5
+ * TS as a NUMERIC enum (`DividerPattern.Dashed = 0`, `Solid = 1`, `Double = 2`), so the JS config writes
6
+ * `dividerPattern: wasm.DividerPattern.Double`. The decoder reads that number through `TryFrom<u8>` (rejects
7
+ * out-of-range at the boundary — its validity IS the type, the `Side` precedent, no domain-error row). COLOUR
8
+ * and dash lengths are SEPARATE `LaneSpan` axes, not folded into this enum (option B of OQ#3).
9
+ * @enum {0 | 1 | 2}
10
+ */
11
+ export const DividerPattern = Object.freeze({
12
+ Dashed: 0, "0": "Dashed",
13
+ Solid: 1, "1": "Solid",
14
+ Double: 2, "2": "Double",
15
+ });
16
+
17
+ export class Engine {
18
+ static __wrap(ptr) {
19
+ const obj = Object.create(Engine.prototype);
20
+ obj.__wbg_ptr = ptr;
21
+ EngineFinalization.register(obj, obj.__wbg_ptr, obj);
22
+ return obj;
23
+ }
24
+ __destroy_into_raw() {
25
+ const ptr = this.__wbg_ptr;
26
+ this.__wbg_ptr = 0;
27
+ EngineFinalization.unregister(this);
28
+ return ptr;
29
+ }
30
+ free() {
31
+ const ptr = this.__destroy_into_raw();
32
+ wasm.__wbg_engine_free(ptr, 0);
33
+ }
34
+ /**
35
+ * The live viewport aspect (canvasW / canvasH), for the scenery vertex shader's `u_aspect` — the
36
+ * ONLY place project-in-shader lets aspect enter the scenery projection (never baked into
37
+ * the camera that `fill_camera` writes, so a stray second divide can't creep in). JS already knows this value locally (it
38
+ * computed it to call `set_aspect`); this getter exists so the scenery pass can read it back the
39
+ * same way every other per-frame uniform is read, off `&self`.
40
+ * @returns {number}
41
+ */
42
+ aspect() {
43
+ const ret = wasm.engine_aspect(this.__wbg_ptr);
44
+ return ret;
45
+ }
46
+ /**
47
+ * The focal length (`CAMERA_DEPTH`, consts.rs) for the scenery vertex shader's `u_cameraDepth`
48
+ * uniform — sent so a FOV change in Rust can't silently desync from a hardcoded GLSL literal (OQ4,
49
+ * project-in-shader.md; the same precedent `depth_bounds` already set for `u_scaleNear/Far`).
50
+ * @returns {number}
51
+ */
52
+ camera_depth() {
53
+ const ret = wasm.engine_camera_depth(this.__wbg_ptr);
54
+ return ret;
55
+ }
56
+ /**
57
+ * The byte address of the camera scratch in WebAssembly memory: six `f32`, written by `fill_camera`.
58
+ * A query (`&self`). The address does not move for the life of the engine, so JavaScript reads it
59
+ * once.
60
+ * @returns {number}
61
+ */
62
+ camera_ptr() {
63
+ const ret = wasm.engine_camera_ptr(this.__wbg_ptr);
64
+ return ret >>> 0;
65
+ }
66
+ /**
67
+ * The JS entry of the frame's value block (lib-value-entry): check the staging block that
68
+ * `value_view` handed out; on success copy it into the live block and seat the camera from its
69
+ * slots 0 and 1 (decision 62). ALL-OR-NOTHING, like `set_value_block`: a bad value changes
70
+ * nothing — the live block AND the camera — so the next draw never mixes two frames' values and
71
+ * never rides a seat no good frame named. Returns −1 on success, else the first bad value's
72
+ * index in the block. A number only: the binding names the fault (`SCENE_VALUE`); the engine
73
+ * sends no prose across the seam.
74
+ * @returns {number}
75
+ */
76
+ commit_value_block() {
77
+ const ret = wasm.engine_commit_value_block(this.__wbg_ptr);
78
+ return ret;
79
+ }
80
+ /**
81
+ * Per-frame dash anchor for the road vertex shader's `u_dashAnchor` — the largest whole number of
82
+ * FULL dash periods at or below the PLAYER's road-SURFACE distance (not horizontal `position`: the
83
+ * dash ruler is `surface_length`, the slant distance, so a climbing road's stripes don't
84
+ * foreshorten). Thin wrapper on the existing free `dash_anchor` (layers/road.rs) — not re-derived.
85
+ * @returns {number}
86
+ */
87
+ dash_anchor() {
88
+ const ret = wasm.engine_dash_anchor(this.__wbg_ptr);
89
+ return ret;
90
+ }
91
+ /**
92
+ * The two perspective-scale bounds the depth map brackets: `[SCALE_NEAR, SCALE_FAR]`.
93
+ * The renderer feeds these to the vertex shader's `u_scaleNear` / `u_scaleFar` uniforms so
94
+ * the GLSL depth map reads the SAME source as the Rust `depth_ndc` mirror — no GLSL↔Rust
95
+ * constant can drift (unlike the DASH_* duplication). Static (derived from camera consts),
96
+ * so the renderer reads this ONCE and caches it — no per-frame marshalling. See depth-test.md.
97
+ * @returns {Float32Array}
98
+ */
99
+ depth_bounds() {
100
+ const ret = wasm.engine_depth_bounds(this.__wbg_ptr);
101
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
102
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
103
+ return v1;
104
+ }
105
+ /**
106
+ * v1.1 (scenery-atlas-cells) — ATLAS-CELL field draw buckets from the last `fill_field_*`: a flat
107
+ * `[u0, v0, u1, v1, start_vertex, count]` per bucket (the sub-rect as a per-draw `u_cellRect` uniform +
108
+ * the vertex range). The renderer draws these with the fract-tile program on the SHARED atlas (NEAREST/
109
+ * no-mips). CACHED like `field_draw_ranges` — valid only after this frame's `fill_field_*`, empty before.
110
+ *
111
+ * A VIEW, like `field_draw_ranges`: valid until the next call into WebAssembly.
112
+ * @returns {Float32Array}
113
+ */
114
+ field_atlas_draw_ranges() {
115
+ const ret = wasm.engine_field_atlas_draw_ranges(this.__wbg_ptr);
116
+ return ret;
117
+ }
118
+ /**
119
+ * Per-texture field draw buckets from the LAST `fill_field_*`: a flat `[texture_id, start_vertex,
120
+ * count, …]` triple per non-empty bucket, ascending by id (the renderer binds `registry[id]` then
121
+ * draws `count` verts from `start_vertex`, once per ground texture). **CACHED, not re-emitted** —
122
+ * a query whose validity depends on a prior `fill_field_*` (re-emitting would re-allocate a
123
+ * field-sized buffer every frame, the GC churn zero-copy kills): the CURRENT frame's buckets only
124
+ * after this frame's fill, **empty before the first fill**. Per-frame order:
125
+ * `seek → fill_field_and_view → bufferSubData → field_draw_ranges → bind+draw`.
126
+ *
127
+ * A VIEW of the cached list, not a copy (frame-static-memory): it aliases WebAssembly memory and is
128
+ * valid until the next call into WebAssembly. Read it at once, and take no engine call while a loop
129
+ * reads it. The Rust name has `_view` because the `cargo test` seam `EngineTestExt::field_draw_ranges`
130
+ * keeps the plain name and returns a `Vec`.
131
+ * @returns {Uint32Array}
132
+ */
133
+ field_draw_ranges() {
134
+ const ret = wasm.engine_field_draw_ranges(this.__wbg_ptr);
135
+ return ret;
136
+ }
137
+ /**
138
+ * @returns {Float32Array}
139
+ */
140
+ fill_and_view() {
141
+ const ret = wasm.engine_fill_and_view(this.__wbg_ptr);
142
+ return ret;
143
+ }
144
+ /**
145
+ * The per-frame camera basis for the scenery vertex shader's projection: `[pos.x,y,z, forward.x,y,z]`
146
+ * (6 floats — NOT the 12 a naive `{pos,forward,right,up}` flattening would send). `right` and
147
+ * world-`up` are deliberately NOT included: `Camera::right()` DERIVES right from forward
148
+ * (`(forward.z, 0, −forward.x)`, camera.rs) rather than storing it, and `Camera::project`'s `cy` is
149
+ * just `ray.y` (world-up is the constant (0,1,0), never dotted). Sending only the minimal
150
+ * independent basis means the GLSL `project()` must derive `right` the same way — which is exactly
151
+ * what keeps it an auditable line-for-line mirror of `Camera::project` (camera.rs) rather than a
152
+ * second copy that could silently drift out of orthogonality.
153
+ *
154
+ * This writes the six floats into the engine's own scratch; it returns nothing. JavaScript reads
155
+ * them through two views over that scratch (`camera_ptr`, `wasm_memory`), and calls this once per
156
+ * frame, after the frame's position is set. The views stay valid until WebAssembly memory grows.
157
+ */
158
+ fill_camera() {
159
+ wasm.engine_fill_camera(this.__wbg_ptr);
160
+ }
161
+ /**
162
+ * @returns {Float32Array}
163
+ */
164
+ fill_field_and_view() {
165
+ const ret = wasm.engine_fill_field_and_view(this.__wbg_ptr);
166
+ return ret;
167
+ }
168
+ /**
169
+ * @returns {Float32Array}
170
+ */
171
+ fill_scenery_and_view() {
172
+ const ret = wasm.engine_fill_scenery_and_view(this.__wbg_ptr);
173
+ return ret;
174
+ }
175
+ /**
176
+ * @returns {Float32Array}
177
+ */
178
+ fill_text_and_view() {
179
+ const ret = wasm.engine_fill_text_and_view(this.__wbg_ptr);
180
+ return ret;
181
+ }
182
+ /**
183
+ * The first asset of `rows` whose cell block does not fit the atlas grid of the track in
184
+ * `bytes`: its index among the rows' assets, or −1 when every one fits. A query: it builds
185
+ * nothing and consumes nothing. Construction refuses such an asset too (O12), with a code that
186
+ * names no asset; this lets the library name the record. `bytes` is a `Uint8Array`.
187
+ * @param {Uint8Array} bytes
188
+ * @param {Rows} rows
189
+ * @returns {number}
190
+ */
191
+ static first_asset_outside_grid(bytes, rows) {
192
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
193
+ const len0 = WASM_VECTOR_LEN;
194
+ _assertClass(rows, Rows);
195
+ const ret = wasm.engine_first_asset_outside_grid(ptr0, len0, rows.__wbg_ptr);
196
+ if (ret[2]) {
197
+ throw takeFromExternrefTable0(ret[1]);
198
+ }
199
+ return ret[0];
200
+ }
201
+ /**
202
+ * Construction from the **X2 binary wire** (`config_wire`, engine-config-wire.md) — the byte twin of
203
+ * `new`'s JS-object path, coexisting with it (additive, non-breaking). Decodes the (possibly
204
+ * UNTRUSTED) blob into the SAME `EngineConfig` and runs the SAME `from_parts` — so the two
205
+ * constructors CONVERGE by construction: ONLY field EXTRACTION differs (a bounds-checked byte cursor
206
+ * vs `Reflect::get`); the O-table validation + sizing + build are shared verbatim. A byte fault
207
+ * crosses the seam as a short STABLE code (`WireError::code()`, e.g. `WIRE_TRUNCATED`) — never a
208
+ * panic, never an empty-as-success render (Core Principle 3 / PRINCIPLES §7). A fetched blob is
209
+ * untrusted (unlike the build-baked polyline), so this is adversarial hardening
210
+ * (feedback_build_time_input_not_untrusted). `bytes` is a `Uint8Array` at the JS seam.
211
+ * @param {Uint8Array} bytes
212
+ * @returns {Engine}
213
+ */
214
+ static from_config_bytes(bytes) {
215
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
216
+ const len0 = WASM_VECTOR_LEN;
217
+ const ret = wasm.engine_from_config_bytes(ptr0, len0);
218
+ if (ret[2]) {
219
+ throw takeFromExternrefTable0(ret[1]);
220
+ }
221
+ return Engine.__wrap(ret[0]);
222
+ }
223
+ /**
224
+ * Construction from the track bytes AND the scene's placed rows (scene-wasm-handoff, decision
225
+ * 76). `rows` holds what a scene module declares: its assets, its objects and its labels. The
226
+ * track holds the rest — the route, the atlas grid, the font. The engine consumes `rows`. The
227
+ * track must declare no placed rows of its own, and must hold each section a row needs (the
228
+ * atlas grid for an asset or an object, the font for a label): else `SCENE_TRACK`. Then the same
229
+ * rules apply as for `from_config_bytes` (O12, O13, T6). `bytes` is a `Uint8Array`.
230
+ * @param {Uint8Array} bytes
231
+ * @param {Rows} rows
232
+ * @returns {Engine}
233
+ */
234
+ static from_config_bytes_with_rows(bytes, rows) {
235
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
236
+ const len0 = WASM_VECTOR_LEN;
237
+ _assertClass(rows, Rows);
238
+ var ptr1 = rows.__destroy_into_raw();
239
+ const ret = wasm.engine_from_config_bytes_with_rows(ptr0, len0, ptr1);
240
+ if (ret[2]) {
241
+ throw takeFromExternrefTable0(ret[1]);
242
+ }
243
+ return Engine.__wrap(ret[0]);
244
+ }
245
+ /**
246
+ * The screen height (ndc_y ∈ [-1, 1]) of the visible horizon: the HIGHEST point of the road
247
+ * ribbon (centre + both edges) over the visible window, projected. On a climb that is the far
248
+ * end; on a crest, the crest; on a descent, a near sample. The renderer fills the GROUND
249
+ * background up to this line and paints SKY above it — so the off-road region the field cannot
250
+ * reach (depth-capped, and folded on the inside of a bend) reads as ground, not as the sharp-bend
251
+ * sky slivers. Per-frame (depends on `position`) but cheap: ~3 projects per window sample, all
252
+ * flops, no allocation. Returns 0.0 when nothing is visible (player past the track end).
253
+ * @returns {number}
254
+ */
255
+ horizon_ndc_y() {
256
+ const ret = wasm.engine_horizon_ndc_y(this.__wbg_ptr);
257
+ return ret;
258
+ }
259
+ /**
260
+ * The layers this track declares, as the track file's section tags, ascending: 1 ROUTE (always),
261
+ * 2 LANES, 3 FIELD, 4 SCENERY, 5 TEXT. A track built from a JS object answers the same way. The
262
+ * binding compares this list with the layers a page lists.
263
+ * @returns {Uint8Array}
264
+ */
265
+ layers() {
266
+ const ret = wasm.engine_layers(this.__wbg_ptr);
267
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
268
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
269
+ return v1;
270
+ }
271
+ /**
272
+ * @returns {number}
273
+ */
274
+ max_draw_bytes() {
275
+ const ret = wasm.engine_max_draw_bytes(this.__wbg_ptr);
276
+ return ret >>> 0;
277
+ }
278
+ /**
279
+ * @returns {number}
280
+ */
281
+ max_field_draw_bytes() {
282
+ const ret = wasm.engine_max_field_draw_bytes(this.__wbg_ptr);
283
+ return ret >>> 0;
284
+ }
285
+ /**
286
+ * @returns {number}
287
+ */
288
+ max_scenery_draw_bytes() {
289
+ const ret = wasm.engine_max_scenery_draw_bytes(this.__wbg_ptr);
290
+ return ret >>> 0;
291
+ }
292
+ /**
293
+ * @returns {number}
294
+ */
295
+ max_text_draw_bytes() {
296
+ const ret = wasm.engine_max_text_draw_bytes(this.__wbg_ptr);
297
+ return ret >>> 0;
298
+ }
299
+ /**
300
+ * The near-clip margin (`NEAR_PLANE`, consts.rs) for the scenery vertex shader's `u_nearPlane`
301
+ * uniform — the shader's per-vertex `step(u_nearPlane, cz)` defense-in-depth twin of the
302
+ * authoritative per-corner cull `SceneryLayer::emit` already applies before emitting a card at all
303
+ * (a GLSL vertex invocation can't see its quad's sibling corners, so it can't reject "if ANY corner
304
+ * is unsafe" — only flag its OWN). Sent as a uniform, not a GLSL literal, for the same reason
305
+ * `camera_depth()` is (OQ4) — a `NEAR_PLANE` tune in Rust can't silently desync from the shader.
306
+ * @returns {number}
307
+ */
308
+ near_plane() {
309
+ const ret = wasm.engine_near_plane(this.__wbg_ptr);
310
+ return ret;
311
+ }
312
+ /**
313
+ * @returns {number}
314
+ */
315
+ position() {
316
+ const ret = wasm.engine_position(this.__wbg_ptr);
317
+ return ret;
318
+ }
319
+ /**
320
+ * Jump the vehicle to `meters` along the track, clamped to `[0, track_length]` — the timeline-scrub
321
+ * seam. The ONE way the playhead moves (lib-route-camera removed the integrator): a pure position
322
+ * setter (CQS command). A NaN target is ignored: the playhead keeps its position.
323
+ * @param {number} meters
324
+ */
325
+ seek(meters) {
326
+ wasm.engine_seek(this.__wbg_ptr, meters);
327
+ }
328
+ /**
329
+ * Set the viewport aspect ratio (canvasW / canvasH). The binding calls this each frame from the live
330
+ * canvas size so the projection corrects ndc_x (aspect-ratio-correction RFC). Fail-soft on a
331
+ * degenerate value (non-finite / ≤ 0, e.g. a 0-height frame): keep the prior aspect rather than
332
+ * poison the projection with NaN/∞.
333
+ * @param {number} aspect
334
+ */
335
+ set_aspect(aspect) {
336
+ wasm.engine_set_aspect(this.__wbg_ptr, aspect);
337
+ }
338
+ /**
339
+ * Set the camera's ride offsets — `x` metres along the road's right vector, `y` metres above the
340
+ * route's surface (decisions 25–27, lib-route-camera). The camera's heading stays the road's
341
+ * tangent; only the eye's seat moves. A scene seats the camera through the value block:
342
+ * `commit_value_block` reads slots 0–1 (lib-value-entry, decision 62) and calls this. This
343
+ * method stays for a page with no scene; the last write of either wins, and a host that writes
344
+ * neither gets the centreline camera. Fail-soft on a non-finite value (either one): keep the
345
+ * prior offsets — a NaN here would put a NaN in the eye and garble every later frame (the
346
+ * `set_aspect` contract).
347
+ * @param {number} x
348
+ * @param {number} y
349
+ */
350
+ set_camera_offset(x, y) {
351
+ wasm.engine_set_camera_offset(this.__wbg_ptr, x, y);
352
+ }
353
+ /**
354
+ * The sky pass's horizontal parallax offset (`u_skyOffset`, sky-cloud.md Decision 5) — a pure
355
+ * function of the camera's YAW (heading), never the wall clock (Core Principle 13), so `cargo
356
+ * test` can pin it exactly like `horizon_ndc_y()`.
357
+ *
358
+ * `heading` is the track's absolute turn angle (θ, `track.rs`: `tangent_x = sin θ`, `κ > 0` = a
359
+ * right turn increases θ). A cloud "at infinity" in a FIXED world direction has true screen
360
+ * position `-CAMERA_DEPTH·tan(θ)/aspect` (the same `Camera::project` limit as any far point) — this
361
+ * uses the bounded first-order term `-sin(θ)` instead: identical SIGN (a right turn still yaws the
362
+ * cloud negative ⇒ left on screen, matching the shader's `p = v_uv - vec2(u_skyOffset, 0)`
363
+ * convention), no pole at θ = ±90°, and `sin`/`tan` agree to within 3% under 30° — comfortably
364
+ * inside the shipped route's heading swing (`lib_test.rs`'s `sky_parallax` mod pins it with a tripwire).
365
+ * @returns {number}
366
+ */
367
+ sky_parallax() {
368
+ const ret = wasm.engine_sky_parallax(this.__wbg_ptr);
369
+ return ret;
370
+ }
371
+ /**
372
+ * Per-label text draw ranges from the LAST `fill_text_*`: a flat `[start_vertex, count, r, g, b, a]`
373
+ * 6-tuple per emitted label (road-anchored, depth-tested; `r,g,b,a` = the label's `u_color` —
374
+ * road labels carry a = 1.0, a placed label's `alpha` arrives in its record, lib-world-objects
375
+ * Decision 2). The renderer sets `u_color` and draws `count` verts from `start_vertex`. **CACHED, not re-emitted** (the
376
+ * `field_draw_ranges` idiom — re-emitting would re-allocate a text-sized buffer every frame): valid only
377
+ * after THIS frame's `fill_text_*`, **empty before the first fill**. Per-frame order:
378
+ * `seek → fill_text_and_view → bufferSubData → text_draw_ranges → draw`.
379
+ * sets `u_color` and draws `count` verts from `start_vertex`. **CACHED, not re-emitted** (the
380
+ * `field_draw_ranges` idiom — re-emitting would re-allocate a text-sized buffer every frame): valid only
381
+ * after THIS frame's `fill_text_*`, **empty before the first fill**. Per-frame order:
382
+ * `seek → fill_text_and_view → bufferSubData → text_draw_ranges → draw`.
383
+ *
384
+ * A VIEW, like `field_draw_ranges`: valid until the next call into WebAssembly.
385
+ * @returns {Float32Array}
386
+ */
387
+ text_draw_ranges() {
388
+ const ret = wasm.engine_text_draw_ranges(this.__wbg_ptr);
389
+ return ret;
390
+ }
391
+ /**
392
+ * Total HORIZONTAL arc length of the loaded track (metres) — the upper bound of any field
393
+ * span's `end` (contract §3.1). Pure query (CQS): the table is built once at construction and
394
+ * is never empty (`from_parts`/`demo` guarantee ≥ 1 sample), so the index never underflows.
395
+ * @returns {number}
396
+ */
397
+ track_length() {
398
+ const ret = wasm.engine_track_length(this.__wbg_ptr);
399
+ return ret;
400
+ }
401
+ /**
402
+ * A `Float32Array` view of the frame's STAGING block (lib-value-entry) — the JS entry's write
403
+ * side. JavaScript writes one frame of values into it (`value_block_len()` long, the layout of
404
+ * `values`), then calls `commit_value_block`. A pure query (`&self`): it changes nothing. The
405
+ * view aliases WebAssembly memory and dies when that memory grows, so JavaScript takes a new
406
+ * view each frame (the `fill_*_and_view` contract). The block was sized by `install_layers`, so
407
+ * the view allocates nothing in WebAssembly memory.
408
+ * @returns {Float32Array}
409
+ */
410
+ value_view() {
411
+ const ret = wasm.engine_value_view(this.__wbg_ptr);
412
+ return ret;
413
+ }
414
+ /**
415
+ * The memory of the WebAssembly module that this engine lives in. JavaScript builds views over its
416
+ * `buffer` (`camera_ptr`); the `buffer` is replaced when the memory grows, and the views of the old one
417
+ * then have length 0. A method, not a free function, so a scene reads it from the engine it was
418
+ * given and imports no module.
419
+ * @returns {WebAssembly.Memory}
420
+ */
421
+ wasm_memory() {
422
+ const ret = wasm.engine_wasm_memory(this.__wbg_ptr);
423
+ return ret;
424
+ }
425
+ }
426
+ if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
427
+
428
+ /**
429
+ * The placed rows of a scene before the engine is built: the assets, the placed objects in the
430
+ * engine's record order, and the placed labels in theirs. Each method appends one row, so an index
431
+ * is the order of the calls. The arguments inside a call are positional.
432
+ */
433
+ export class Rows {
434
+ __destroy_into_raw() {
435
+ const ptr = this.__wbg_ptr;
436
+ this.__wbg_ptr = 0;
437
+ RowsFinalization.unregister(this);
438
+ return ptr;
439
+ }
440
+ free() {
441
+ const ptr = this.__destroy_into_raw();
442
+ wasm.__wbg_rows_free(ptr, 0);
443
+ }
444
+ /**
445
+ * One asset: the atlas cell at its block's top-left, and the block's span in cells. Its index
446
+ * is the order of the `asset` calls — what an `image` call names, and what the scene module
447
+ * holds for it.
448
+ * @param {number} cell
449
+ * @param {number} cols
450
+ * @param {number} rows
451
+ */
452
+ asset(cell, cols, rows) {
453
+ wasm.rows_asset(this.__wbg_ptr, cell, cols, rows);
454
+ }
455
+ /**
456
+ * One placed object, bound to the asset at index `asset`. Its record (9 values a frame) follows
457
+ * the order of the `image` calls.
458
+ * @param {number} asset
459
+ */
460
+ image(asset) {
461
+ wasm.rows_image(this.__wbg_ptr, asset);
462
+ }
463
+ /**
464
+ * No rows.
465
+ */
466
+ constructor() {
467
+ const ret = wasm.rows_new();
468
+ this.__wbg_ptr = ret;
469
+ RowsFinalization.register(this, this.__wbg_ptr, this);
470
+ return this;
471
+ }
472
+ /**
473
+ * One placed label with its text. Its record (9 values a frame) follows the order of the `text`
474
+ * calls.
475
+ * @param {string} text
476
+ */
477
+ text(text) {
478
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
479
+ const len0 = WASM_VECTOR_LEN;
480
+ wasm.rows_text(this.__wbg_ptr, ptr0, len0);
481
+ }
482
+ }
483
+ if (Symbol.dispose) Rows.prototype[Symbol.dispose] = Rows.prototype.free;
484
+
485
+ /**
486
+ * Which side(s) of the road a field span covers, in driving direction. `#[wasm_bindgen]` exports
487
+ * it to TS as a NUMERIC enum (`Side.Left = 0`, `Right = 1`, `Both = 2`), so the JS config writes
488
+ * `side: wasm.Side.Both`. The decoder reads that number and maps it through `TryFrom<u8>` below, which
489
+ * rejects an out-of-range value at the boundary (contract §5: `side` has no domain-error row; its
490
+ * validity IS the type).
491
+ * @enum {0 | 1 | 2}
492
+ */
493
+ export const Side = Object.freeze({
494
+ Left: 0, "0": "Left",
495
+ Right: 1, "1": "Right",
496
+ Both: 2, "2": "Both",
497
+ });
498
+ function __wbg_get_imports() {
499
+ const import0 = {
500
+ __proto__: null,
501
+ __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
502
+ const ret = Error(getStringFromWasm0(arg0, arg1));
503
+ return ret;
504
+ },
505
+ __wbg___wbindgen_memory_9751d9a3017e7c25: function() {
506
+ const ret = wasm.memory;
507
+ return ret;
508
+ },
509
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
510
+ throw new Error(getStringFromWasm0(arg0, arg1));
511
+ },
512
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
513
+ // Cast intrinsic for `Ref(Slice(F32)) -> NamedExternref("Float32Array")`.
514
+ const ret = getArrayF32FromWasm0(arg0, arg1);
515
+ return ret;
516
+ },
517
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
518
+ // Cast intrinsic for `Ref(Slice(U32)) -> NamedExternref("Uint32Array")`.
519
+ const ret = getArrayU32FromWasm0(arg0, arg1);
520
+ return ret;
521
+ },
522
+ __wbindgen_init_externref_table: function() {
523
+ const table = wasm.__wbindgen_externrefs;
524
+ const offset = table.grow(4);
525
+ table.set(0, undefined);
526
+ table.set(offset + 0, undefined);
527
+ table.set(offset + 1, null);
528
+ table.set(offset + 2, true);
529
+ table.set(offset + 3, false);
530
+ },
531
+ };
532
+ return {
533
+ __proto__: null,
534
+ "./wasm_engine_bg.js": import0,
535
+ };
536
+ }
537
+
538
+ const EngineFinalization = (typeof FinalizationRegistry === 'undefined')
539
+ ? { register: () => {}, unregister: () => {} }
540
+ : new FinalizationRegistry(ptr => wasm.__wbg_engine_free(ptr, 1));
541
+ const RowsFinalization = (typeof FinalizationRegistry === 'undefined')
542
+ ? { register: () => {}, unregister: () => {} }
543
+ : new FinalizationRegistry(ptr => wasm.__wbg_rows_free(ptr, 1));
544
+
545
+ function _assertClass(instance, klass) {
546
+ if (!(instance instanceof klass)) {
547
+ throw new Error(`expected instance of ${klass.name}`);
548
+ }
549
+ }
550
+
551
+ function getArrayF32FromWasm0(ptr, len) {
552
+ ptr = ptr >>> 0;
553
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
554
+ }
555
+
556
+ function getArrayU32FromWasm0(ptr, len) {
557
+ ptr = ptr >>> 0;
558
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
559
+ }
560
+
561
+ function getArrayU8FromWasm0(ptr, len) {
562
+ ptr = ptr >>> 0;
563
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
564
+ }
565
+
566
+ let cachedFloat32ArrayMemory0 = null;
567
+ function getFloat32ArrayMemory0() {
568
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
569
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
570
+ }
571
+ return cachedFloat32ArrayMemory0;
572
+ }
573
+
574
+ function getStringFromWasm0(ptr, len) {
575
+ return decodeText(ptr >>> 0, len);
576
+ }
577
+
578
+ let cachedUint32ArrayMemory0 = null;
579
+ function getUint32ArrayMemory0() {
580
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
581
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
582
+ }
583
+ return cachedUint32ArrayMemory0;
584
+ }
585
+
586
+ let cachedUint8ArrayMemory0 = null;
587
+ function getUint8ArrayMemory0() {
588
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
589
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
590
+ }
591
+ return cachedUint8ArrayMemory0;
592
+ }
593
+
594
+ function passArray8ToWasm0(arg, malloc) {
595
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
596
+ getUint8ArrayMemory0().set(arg, ptr / 1);
597
+ WASM_VECTOR_LEN = arg.length;
598
+ return ptr;
599
+ }
600
+
601
+ function passStringToWasm0(arg, malloc, realloc) {
602
+ if (realloc === undefined) {
603
+ const buf = cachedTextEncoder.encode(arg);
604
+ const ptr = malloc(buf.length, 1) >>> 0;
605
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
606
+ WASM_VECTOR_LEN = buf.length;
607
+ return ptr;
608
+ }
609
+
610
+ let len = arg.length;
611
+ let ptr = malloc(len, 1) >>> 0;
612
+
613
+ const mem = getUint8ArrayMemory0();
614
+
615
+ let offset = 0;
616
+
617
+ for (; offset < len; offset++) {
618
+ const code = arg.charCodeAt(offset);
619
+ if (code > 0x7F) break;
620
+ mem[ptr + offset] = code;
621
+ }
622
+ if (offset !== len) {
623
+ if (offset !== 0) {
624
+ arg = arg.slice(offset);
625
+ }
626
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
627
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
628
+ const ret = cachedTextEncoder.encodeInto(arg, view);
629
+
630
+ offset += ret.written;
631
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
632
+ }
633
+
634
+ WASM_VECTOR_LEN = offset;
635
+ return ptr;
636
+ }
637
+
638
+ function takeFromExternrefTable0(idx) {
639
+ const value = wasm.__wbindgen_externrefs.get(idx);
640
+ wasm.__externref_table_dealloc(idx);
641
+ return value;
642
+ }
643
+
644
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
645
+ cachedTextDecoder.decode();
646
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
647
+ let numBytesDecoded = 0;
648
+ function decodeText(ptr, len) {
649
+ numBytesDecoded += len;
650
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
651
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
652
+ cachedTextDecoder.decode();
653
+ numBytesDecoded = len;
654
+ }
655
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
656
+ }
657
+
658
+ const cachedTextEncoder = new TextEncoder();
659
+
660
+ if (!('encodeInto' in cachedTextEncoder)) {
661
+ cachedTextEncoder.encodeInto = function (arg, view) {
662
+ const buf = cachedTextEncoder.encode(arg);
663
+ view.set(buf);
664
+ return {
665
+ read: arg.length,
666
+ written: buf.length
667
+ };
668
+ };
669
+ }
670
+
671
+ let WASM_VECTOR_LEN = 0;
672
+
673
+ let wasmModule, wasmInstance, wasm;
674
+ function __wbg_finalize_init(instance, module) {
675
+ wasmInstance = instance;
676
+ wasm = instance.exports;
677
+ wasmModule = module;
678
+ cachedFloat32ArrayMemory0 = null;
679
+ cachedUint32ArrayMemory0 = null;
680
+ cachedUint8ArrayMemory0 = null;
681
+ wasm.__wbindgen_start();
682
+ return wasm;
683
+ }
684
+
685
+ async function __wbg_load(module, imports) {
686
+ if (typeof Response === 'function' && module instanceof Response) {
687
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
688
+ try {
689
+ return await WebAssembly.instantiateStreaming(module, imports);
690
+ } catch (e) {
691
+ const validResponse = module.ok && expectedResponseType(module.type);
692
+
693
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
694
+ 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);
695
+
696
+ } else { throw e; }
697
+ }
698
+ }
699
+
700
+ const bytes = await module.arrayBuffer();
701
+ return await WebAssembly.instantiate(bytes, imports);
702
+ } else {
703
+ const instance = await WebAssembly.instantiate(module, imports);
704
+
705
+ if (instance instanceof WebAssembly.Instance) {
706
+ return { instance, module };
707
+ } else {
708
+ return instance;
709
+ }
710
+ }
711
+
712
+ function expectedResponseType(type) {
713
+ switch (type) {
714
+ case 'basic': case 'cors': case 'default': return true;
715
+ }
716
+ return false;
717
+ }
718
+ }
719
+
720
+ function initSync(module) {
721
+ if (wasm !== undefined) return wasm;
722
+
723
+
724
+ if (module !== undefined) {
725
+ if (Object.getPrototypeOf(module) === Object.prototype) {
726
+ ({module} = module)
727
+ } else {
728
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
729
+ }
730
+ }
731
+
732
+ const imports = __wbg_get_imports();
733
+ if (!(module instanceof WebAssembly.Module)) {
734
+ module = new WebAssembly.Module(module);
735
+ }
736
+ const instance = new WebAssembly.Instance(module, imports);
737
+ return __wbg_finalize_init(instance, module);
738
+ }
739
+
740
+ async function __wbg_init(module_or_path) {
741
+ if (wasm !== undefined) return wasm;
742
+
743
+
744
+ if (module_or_path !== undefined) {
745
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
746
+ ({module_or_path} = module_or_path)
747
+ } else {
748
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
749
+ }
750
+ }
751
+
752
+ if (module_or_path === undefined) {
753
+ module_or_path = new URL('wasm_engine_bg.wasm', import.meta.url);
754
+ }
755
+ const imports = __wbg_get_imports();
756
+
757
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
758
+ module_or_path = fetch(module_or_path);
759
+ }
760
+
761
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
762
+
763
+ return __wbg_finalize_init(instance, module);
764
+ }
765
+
766
+ export { initSync, __wbg_init as default };