@onimaxxing/worldgen 0.15.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,2368 @@
1
+ /* @ts-self-types="./oni_wasm.d.ts" */
2
+ import { startWorkers } from './snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js';
3
+
4
+ /**
5
+ * Arm the per-pair thermal tracer used to bisect the OASIS W1
6
+ * wasm-vs-native divergence. Targets one sim cell index, one tick.
7
+ * @param {number} target_sim_idx
8
+ * @param {number} target_tick
9
+ */
10
+ export function arm_thermal_pair_trace(target_sim_idx, target_tick) {
11
+ wasm.arm_thermal_pair_trace(target_sim_idx, target_tick);
12
+ }
13
+
14
+ /**
15
+ * Bench harness — time just the Rust `generate_with_settings` call without
16
+ * the JSON-serialization overhead every production entry point pays.
17
+ *
18
+ * Gated behind `debug` so release WASM doesn't ship with it. Returns a
19
+ * small JSON blob containing per-phase wall-clock in ms so the bench
20
+ * script can separate cluster-gen time from
21
+ * `build_result` + `serde_json::to_string` cost.
22
+ * @param {number} seed
23
+ * @param {string} cluster_id
24
+ * @returns {string}
25
+ */
26
+ export function bench_cluster_phases(seed, cluster_id) {
27
+ let deferred2_0;
28
+ let deferred2_1;
29
+ try {
30
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
31
+ const len0 = WASM_VECTOR_LEN;
32
+ const ret = wasm.bench_cluster_phases(seed, ptr0, len0);
33
+ deferred2_0 = ret[0];
34
+ deferred2_1 = ret[1];
35
+ return getStringFromWasm0(ret[0], ret[1]);
36
+ } finally {
37
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Bench harness — returns the accumulated phase totals as JSON
43
+ * (`{"phase": {"ms": number, "calls": number}, ...}`) and clears the
44
+ * accumulator. Gated behind `debug`.
45
+ * @returns {string}
46
+ */
47
+ export function bench_profile_dump() {
48
+ let deferred1_0;
49
+ let deferred1_1;
50
+ try {
51
+ const ret = wasm.bench_profile_dump();
52
+ deferred1_0 = ret[0];
53
+ deferred1_1 = ret[1];
54
+ return getStringFromWasm0(ret[0], ret[1]);
55
+ } finally {
56
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Bench harness — enable the fine-grained `oni_worldgen::profile`
62
+ * phase accumulator. Pair with `bench_profile_dump()` after running the
63
+ * measured work. Gated behind `debug`.
64
+ */
65
+ export function bench_profile_enable() {
66
+ wasm.bench_profile_enable();
67
+ }
68
+
69
+ /**
70
+ * Drop the cached cluster. Snapshot edits persist.
71
+ */
72
+ export function clear_cluster_cache() {
73
+ wasm.clear_cluster_cache();
74
+ }
75
+
76
+ /**
77
+ * Compute a `ClusterDigest` from a coordinate, returning JSON.
78
+ *
79
+ * This is the canonical Rust path for digest regeneration — calling
80
+ * this function from JS via wasm-pack ensures the digest comes from
81
+ * the SAME math the production WASM build uses, not from a separate
82
+ * native binary that might have different precision.
83
+ *
84
+ * `mode` must be either "templates" or "notemplates".
85
+ *
86
+ * On parse error returns a JSON object with an `error` field.
87
+ * Variant of [`compute_digest_from_coordinate`] that takes the
88
+ * cluster id directly instead of going through `parse_coordinate`.
89
+ * Required when the coordinate's prefix maps to multiple clusters —
90
+ * e.g. when a mod registers several clusters with the same
91
+ * `coordinatePrefix` (Cluster Generation Manager has three clusters
92
+ * at `CGSM-C`). The C# side disambiguates via `SNAPSHOT_CLUSTER`
93
+ * for the same reason; this is the symmetric Rust knob.
94
+ *
95
+ * `coordinate` is still used for output schema fields (`coordinate`,
96
+ * story/mixing extraction via the matching CS-side parser), but the
97
+ * cluster lookup is performed against `cluster_id` directly. For
98
+ * vanilla unambiguous prefixes the two functions produce identical
99
+ * digests when `cluster_id` matches the prefix's mapped cluster.
100
+ * @param {string} coordinate
101
+ * @param {string} cluster_id
102
+ * @param {number} seed
103
+ * @param {string} mode
104
+ * @returns {string}
105
+ */
106
+ export function compute_digest_for_cluster(coordinate, cluster_id, seed, mode) {
107
+ let deferred4_0;
108
+ let deferred4_1;
109
+ try {
110
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
111
+ const len0 = WASM_VECTOR_LEN;
112
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ const len1 = WASM_VECTOR_LEN;
114
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
115
+ const len2 = WASM_VECTOR_LEN;
116
+ const ret = wasm.compute_digest_for_cluster(ptr0, len0, ptr1, len1, seed, ptr2, len2);
117
+ deferred4_0 = ret[0];
118
+ deferred4_1 = ret[1];
119
+ return getStringFromWasm0(ret[0], ret[1]);
120
+ } finally {
121
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * @param {string} coordinate
127
+ * @param {string} mode
128
+ * @returns {string}
129
+ */
130
+ export function compute_digest_from_coordinate(coordinate, mode) {
131
+ let deferred3_0;
132
+ let deferred3_1;
133
+ try {
134
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
137
+ const len1 = WASM_VECTOR_LEN;
138
+ const ret = wasm.compute_digest_from_coordinate(ptr0, len0, ptr1, len1);
139
+ deferred3_0 = ret[0];
140
+ deferred3_1 = ret[1];
141
+ return getStringFromWasm0(ret[0], ret[1]);
142
+ } finally {
143
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Apply a structured mutations payload to the generated cluster
149
+ * before computing the digest. Used by mod extensions to fold
150
+ * post-snapshot overrides (CGM geyser swap, SO_POI pins, vanilla-
151
+ * starmap replacement) into the digest without modifying the
152
+ * worldgen pipeline.
153
+ *
154
+ * The `overrides_json` schema is generic — not CGM-named — so any
155
+ * mod can use it:
156
+ * ```json
157
+ * {
158
+ * "entityReplacements": [
159
+ * { "worldIdx": 0, "cell": 100, "newTag": "GeyserGeneric_hot_water",
160
+ * "newResolvedTemplate": "hot_water" }
161
+ * ],
162
+ * "worldLocationOverrides": [
163
+ * { "worldIdx": 2, "q": 3, "r": -2 }
164
+ * ],
165
+ * "poiUpserts": [
166
+ * { "poiType": "HarvestableSpacePOI_X", "q": 5, "r": 5 }
167
+ * ],
168
+ * "vanillaDestinationsReplace": [
169
+ * { "destType": "CarbonaceousAsteroid", "distance": 0 }
170
+ * ]
171
+ * }
172
+ * ```
173
+ *
174
+ * Pass `""` or `"{}"` for `overrides_json` to skip mutations entirely
175
+ * (equivalent to [`compute_digest_for_cluster`]).
176
+ * @param {string} coordinate
177
+ * @param {string} cluster_id
178
+ * @param {number} seed
179
+ * @param {string} mode
180
+ * @param {string} overrides_json
181
+ * @returns {string}
182
+ */
183
+ export function compute_digest_with_overrides(coordinate, cluster_id, seed, mode, overrides_json) {
184
+ let deferred5_0;
185
+ let deferred5_1;
186
+ try {
187
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
188
+ const len0 = WASM_VECTOR_LEN;
189
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ const len1 = WASM_VECTOR_LEN;
191
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
192
+ const len2 = WASM_VECTOR_LEN;
193
+ const ptr3 = passStringToWasm0(overrides_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
194
+ const len3 = WASM_VECTOR_LEN;
195
+ const ret = wasm.compute_digest_with_overrides(ptr0, len0, ptr1, len1, seed, ptr2, len2, ptr3, len3);
196
+ deferred5_0 = ret[0];
197
+ deferred5_1 = ret[1];
198
+ return getStringFromWasm0(ret[0], ret[1]);
199
+ } finally {
200
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Geyser stats compute, exposed for the mod-extensions transformer.
206
+ * After a CGM blacklist re-roll substitutes a generic geyser
207
+ * template, this function re-derives the 5 MNI-projected ints
208
+ * (emit/avg/idle/erupt/dormant/active) the digest hashes.
209
+ *
210
+ * `template` is a bare geyser id (no `GeyserGeneric_` prefix) —
211
+ * e.g. `"hot_water"`, `"small_volcano"`, `"oil_drip"`. Returns
212
+ * `{"error": "..."}` for unknown templates.
213
+ *
214
+ * `seed` is the per-cell `globalWorldSeed + cluster_x + cluster_y` —
215
+ * same as the existing geyser RNG path.
216
+ *
217
+ * Output JSON schema mirrors the `GeyserStats` interface in the
218
+ * `mod-extensions` transformer module:
219
+ * ```json
220
+ * {
221
+ * "rate": 4310,
222
+ * "idle": 112,
223
+ * "erupt": 500,
224
+ * "dorm": 71,
225
+ * "active": 125
226
+ * }
227
+ * ```
228
+ * @param {number} seed
229
+ * @param {string} template
230
+ * @returns {string}
231
+ */
232
+ export function compute_geyser_stats(seed, template) {
233
+ let deferred2_0;
234
+ let deferred2_1;
235
+ try {
236
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
237
+ const len0 = WASM_VECTOR_LEN;
238
+ const ret = wasm.compute_geyser_stats(seed, ptr0, len0);
239
+ deferred2_0 = ret[0];
240
+ deferred2_1 = ret[1];
241
+ return getStringFromWasm0(ret[0], ret[1]);
242
+ } finally {
243
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
244
+ }
245
+ }
246
+
247
+ /**
248
+ * are sampled. Used for vibe-checking U59 backwall plumbing.
249
+ * @param {string} coordinate
250
+ * @param {number} world_idx
251
+ * @returns {string}
252
+ */
253
+ export function debug_dump_backwall_distribution(coordinate, world_idx) {
254
+ let deferred2_0;
255
+ let deferred2_1;
256
+ try {
257
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
258
+ const len0 = WASM_VECTOR_LEN;
259
+ const ret = wasm.debug_dump_backwall_distribution(ptr0, len0, world_idx);
260
+ deferred2_0 = ret[0];
261
+ deferred2_1 = ret[1];
262
+ return getStringFromWasm0(ret[0], ret[1]);
263
+ } finally {
264
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Probe the cluster-level (overworld) PointGenerator seed state for a
270
+ * coordinate. Returns the values that drive the very first PD pass in
271
+ * `WorldLayout.GenerateOverworld` so we can diff them against the C#
272
+ * snapshot's equivalent fields to localize early OW-site divergence.
273
+ * @param {string} coordinate
274
+ * @returns {string}
275
+ */
276
+ export function debug_dump_cluster_pd_seed_state(coordinate) {
277
+ let deferred2_0;
278
+ let deferred2_1;
279
+ try {
280
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
281
+ const len0 = WASM_VECTOR_LEN;
282
+ const ret = wasm.debug_dump_cluster_pd_seed_state(ptr0, len0);
283
+ deferred2_0 = ret[0];
284
+ deferred2_1 = ret[1];
285
+ return getStringFromWasm0(ret[0], ret[1]);
286
+ } finally {
287
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Probe per-channel noise hashes for one coordinate. Output:
293
+ * `{"base":"<sha>","override":"...","density":"...","heat":"..."}`.
294
+ * Used to find which noise channel diverges from CS for AQU-A.
295
+ * @param {string} coordinate
296
+ * @returns {string}
297
+ */
298
+ export function debug_dump_noise_channel_hashes(coordinate) {
299
+ let deferred2_0;
300
+ let deferred2_1;
301
+ try {
302
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
303
+ const len0 = WASM_VECTOR_LEN;
304
+ const ret = wasm.debug_dump_noise_channel_hashes(ptr0, len0);
305
+ deferred2_0 = ret[0];
306
+ deferred2_1 = ret[1];
307
+ return getStringFromWasm0(ret[0], ret[1]);
308
+ } finally {
309
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Per-TC backwall lookup tag inspector. For each spawn_backwall TC,
315
+ * dumps: node_type, tags, biome_tag found, derived band name, and
316
+ * whether the lookup resolves in base or DLC-scoped form.
317
+ * Bisect tool for "Reef/Abyss backwall stamps never fire" findings.
318
+ * @param {string} coordinate
319
+ * @param {number} world_idx
320
+ * @returns {string}
321
+ */
322
+ export function debug_dump_noise_channels(coordinate, world_idx) {
323
+ let deferred2_0;
324
+ let deferred2_1;
325
+ try {
326
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
327
+ const len0 = WASM_VECTOR_LEN;
328
+ const ret = wasm.debug_dump_noise_channels(ptr0, len0, world_idx);
329
+ deferred2_0 = ret[0];
330
+ deferred2_1 = ret[1];
331
+ return getStringFromWasm0(ret[0], ret[1]);
332
+ } finally {
333
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
334
+ }
335
+ }
336
+
337
+ /**
338
+ * Dump `placed_templates` (template name + cluster-space anchor cell)
339
+ * per world for one coordinate. Returns
340
+ * `{"worlds":[{"name":..,"placed":[[name,x,y],...]},...]}`.
341
+ * @param {string} coordinate
342
+ * @returns {string}
343
+ */
344
+ export function debug_dump_placed_templates(coordinate) {
345
+ let deferred2_0;
346
+ let deferred2_1;
347
+ try {
348
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
349
+ const len0 = WASM_VECTOR_LEN;
350
+ const ret = wasm.debug_dump_placed_templates(ptr0, len0);
351
+ deferred2_0 = ret[0];
352
+ deferred2_1 = ret[1];
353
+ return getStringFromWasm0(ret[0], ret[1]);
354
+ } finally {
355
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
356
+ }
357
+ }
358
+
359
+ /**
360
+ * @param {string} coordinate
361
+ * @param {number} world_idx
362
+ * @returns {string}
363
+ */
364
+ export function debug_dump_tc_backwall_lookup(coordinate, world_idx) {
365
+ let deferred2_0;
366
+ let deferred2_1;
367
+ try {
368
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
369
+ const len0 = WASM_VECTOR_LEN;
370
+ const ret = wasm.debug_dump_tc_backwall_lookup(ptr0, len0, world_idx);
371
+ deferred2_0 = ret[0];
372
+ deferred2_1 = ret[1];
373
+ return getStringFromWasm0(ret[0], ret[1]);
374
+ } finally {
375
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
376
+ }
377
+ }
378
+
379
+ /**
380
+ * Dump the U59 backwall layer for one world of a coordinate.
381
+ *
382
+ * Returns JSON:
383
+ * ```json
384
+ * {
385
+ * "world_name": "...", "width": w, "height": h,
386
+ * "spawn_backwall_tc_count": N,
387
+ * "total_tc_count": M,
388
+ * "backwall_histogram": { "Vacuum": k, "Coquina": k, ... },
389
+ * "samples_by_tc": [
390
+ * {"tc_idx": i, "node_type": "...", "biome_tag": "...",
391
+ * "all_cells_count": n, "spawn_backwall": true|false,
392
+ * "sample_cells": [{"cell": idx, "element": "...", "mass": f, "temp": f}, ...]}
393
+ * ]
394
+ * }
395
+ * ```
396
+ * Sampling: up to `max_tc_samples` TCs whose `spawn_backwall=true` are
397
+ * shown; for each, up to 5 random cells (deterministic seed = tc_idx)
398
+ * Dump raw backwall_noise samples + per-cell backwall element
399
+ * for selected TCs. Filters cells to `available_terrain_points`
400
+ * (the actually-stamped set), so reports the TRUE noise / element
401
+ * distribution rather than the broader polygon containment set
402
+ * that the prior vibe check used.
403
+ * @param {string} coordinate
404
+ * @param {number} world_idx
405
+ * @param {string} target_biome
406
+ * @returns {string}
407
+ */
408
+ export function debug_dump_tc_backwall_noise(coordinate, world_idx, target_biome) {
409
+ let deferred3_0;
410
+ let deferred3_1;
411
+ try {
412
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
413
+ const len0 = WASM_VECTOR_LEN;
414
+ const ptr1 = passStringToWasm0(target_biome, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
415
+ const len1 = WASM_VECTOR_LEN;
416
+ const ret = wasm.debug_dump_tc_backwall_noise(ptr0, len0, world_idx, ptr1, len1);
417
+ deferred3_0 = ret[0];
418
+ deferred3_1 = ret[1];
419
+ return getStringFromWasm0(ret[0], ret[1]);
420
+ } finally {
421
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
422
+ }
423
+ }
424
+
425
+ /**
426
+ * Dump TC properties for parity diff. Returns per-TC type, position,
427
+ * poly vertices (hex bits), all_cells count, available_terrain count.
428
+ * @param {string} coordinate
429
+ * @param {number} world_idx
430
+ * @returns {string}
431
+ */
432
+ export function debug_dump_tc_details(coordinate, world_idx) {
433
+ let deferred2_0;
434
+ let deferred2_1;
435
+ try {
436
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
437
+ const len0 = WASM_VECTOR_LEN;
438
+ const ret = wasm.debug_dump_tc_details(ptr0, len0, world_idx);
439
+ deferred2_0 = ret[0];
440
+ deferred2_1 = ret[1];
441
+ return getStringFromWasm0(ret[0], ret[1]);
442
+ } finally {
443
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
444
+ }
445
+ }
446
+
447
+ /**
448
+ * Dump per-TC RNG states for one coordinate. Each entry mirrors CS
449
+ * rng_trace format: (pre_inext, pre_inextp, pre_seed, post_inext,
450
+ * post_inextp, post_seed) per terrain cell. Used to localize the first
451
+ * TC where RNG state diverges from CS.
452
+ * @param {string} coordinate
453
+ * @returns {string}
454
+ */
455
+ export function debug_dump_tc_rng_states(coordinate) {
456
+ let deferred2_0;
457
+ let deferred2_1;
458
+ try {
459
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
460
+ const len0 = WASM_VECTOR_LEN;
461
+ const ret = wasm.debug_dump_tc_rng_states(ptr0, len0);
462
+ deferred2_0 = ret[0];
463
+ deferred2_1 = ret[1];
464
+ return getStringFromWasm0(ret[0], ret[1]);
465
+ } finally {
466
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
467
+ }
468
+ }
469
+
470
+ /**
471
+ * Dump raw `mob_spawns` for one world of a coordinate, as JSON
472
+ * `{template:[{cell,tag,...},...], ambient:[...], world_name, width, height}`.
473
+ * Debug-only — used to localize the V-AQU w[0] +1000 ambient mob delta.
474
+ * @param {string} coordinate
475
+ * @param {number} world_idx
476
+ * @returns {string}
477
+ */
478
+ export function debug_dump_world_mobs(coordinate, world_idx) {
479
+ let deferred2_0;
480
+ let deferred2_1;
481
+ try {
482
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
483
+ const len0 = WASM_VECTOR_LEN;
484
+ const ret = wasm.debug_dump_world_mobs(ptr0, len0, world_idx);
485
+ deferred2_0 = ret[0];
486
+ deferred2_1 = ret[1];
487
+ return getStringFromWasm0(ret[0], ret[1]);
488
+ } finally {
489
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
490
+ }
491
+ }
492
+
493
+ /**
494
+ * Diagnostic: return the current SETTINGS.element_overrides as JSON.
495
+ * Lets callers verify a `snapshot_*` push actually landed in the
496
+ * thread-local cache before invoking a `generate_*` / digest call.
497
+ * Gated behind the `debug` feature so production builds stay slim.
498
+ * @returns {string}
499
+ */
500
+ export function debug_settings_element_overrides() {
501
+ let deferred1_0;
502
+ let deferred1_1;
503
+ try {
504
+ const ret = wasm.debug_settings_element_overrides();
505
+ deferred1_0 = ret[0];
506
+ deferred1_1 = ret[1];
507
+ return getStringFromWasm0(ret[0], ret[1]);
508
+ } finally {
509
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
510
+ }
511
+ }
512
+
513
+ /**
514
+ * Drain the per-thread debug-capture buffer populated by
515
+ * instrumented points in `oni-worldgen`. Returns the accumulated
516
+ * lines as a single newline-separated string and empties the
517
+ * buffer. Pair with `compute_digest_for_cluster` or
518
+ * `dump_tc_polys_for_cluster` to capture intermediate state during
519
+ * worldgen.
520
+ * @returns {string}
521
+ */
522
+ export function drain_debug_capture() {
523
+ let deferred1_0;
524
+ let deferred1_1;
525
+ try {
526
+ const ret = wasm.drain_debug_capture();
527
+ deferred1_0 = ret[0];
528
+ deferred1_1 = ret[1];
529
+ return getStringFromWasm0(ret[0], ret[1]);
530
+ } finally {
531
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
532
+ }
533
+ }
534
+
535
+ /**
536
+ * Diagnostic: dump the cluster layout's world placements as seen by
537
+ * Rust after snapshot merge. Used to verify CGM augmentations
538
+ * (sizeMultiplier, forcedWorldTraits, etc) survived the JSON
539
+ * round-trip into Rust's `WorldPlacement` struct.
540
+ * @param {string} cluster_id
541
+ * @returns {string}
542
+ */
543
+ export function dump_cluster_placements(cluster_id) {
544
+ let deferred2_0;
545
+ let deferred2_1;
546
+ try {
547
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
548
+ const len0 = WASM_VECTOR_LEN;
549
+ const ret = wasm.dump_cluster_placements(ptr0, len0);
550
+ deferred2_0 = ret[0];
551
+ deferred2_1 = ret[1];
552
+ return getStringFromWasm0(ret[0], ret[1]);
553
+ } finally {
554
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
555
+ }
556
+ }
557
+
558
+ /**
559
+ * Diagnostic: dump every terrain cell's polygon vertices. Returns a
560
+ * JSON object `{ site_id: [[vx_hex, vy_hex], ...], ... }` so the
561
+ * mod-parity scripts can diff per-cell polygons against the CS
562
+ * snapshot. Pairs with `dump_tc_positions_for_cluster` for full
563
+ * per-cell geometry diff.
564
+ * @param {string} coordinate
565
+ * @param {string} cluster_id
566
+ * @param {number} seed
567
+ * @param {number} world_idx
568
+ * @returns {string}
569
+ */
570
+ export function dump_tc_polys_for_cluster(coordinate, cluster_id, seed, world_idx) {
571
+ let deferred3_0;
572
+ let deferred3_1;
573
+ try {
574
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
575
+ const len0 = WASM_VECTOR_LEN;
576
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
577
+ const len1 = WASM_VECTOR_LEN;
578
+ const ret = wasm.dump_tc_polys_for_cluster(ptr0, len0, ptr1, len1, seed, world_idx);
579
+ deferred3_0 = ret[0];
580
+ deferred3_1 = ret[1];
581
+ return getStringFromWasm0(ret[0], ret[1]);
582
+ } finally {
583
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
584
+ }
585
+ }
586
+
587
+ /**
588
+ * Diagnostic: dump every terrain cell's site_id + node_type +
589
+ * polygon centroid (raw bits) for a generated cluster. Lets the
590
+ * mod-parity scripts diff per-cell positions directly against the
591
+ * CS snapshot's `tc_positions` field when only `tc_positions_sha`
592
+ * fails. Output is a JSON array of "site_id,node_type,cx_hex,cy_hex"
593
+ * strings sorted by site_id (matching the digest hash input).
594
+ * @param {string} coordinate
595
+ * @param {string} cluster_id
596
+ * @param {number} seed
597
+ * @param {number} world_idx
598
+ * @returns {string}
599
+ */
600
+ export function dump_tc_positions_for_cluster(coordinate, cluster_id, seed, world_idx) {
601
+ let deferred3_0;
602
+ let deferred3_1;
603
+ try {
604
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
605
+ const len0 = WASM_VECTOR_LEN;
606
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
607
+ const len1 = WASM_VECTOR_LEN;
608
+ const ret = wasm.dump_tc_positions_for_cluster(ptr0, len0, ptr1, len1, seed, world_idx);
609
+ deferred3_0 = ret[0];
610
+ deferred3_1 = ret[1];
611
+ return getStringFromWasm0(ret[0], ret[1]);
612
+ } finally {
613
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
614
+ }
615
+ }
616
+
617
+ /**
618
+ * Diagnostic: dump every terrain cell's node_type for a given world
619
+ * in a CGM-style pipeline run. Comparing direct vs pipeline output
620
+ * reveals whether the divergence is in subworld assignment (upstream
621
+ * of element bands) or in element-band sampling (downstream).
622
+ * @param {string} cluster_id
623
+ * @param {number} seed
624
+ * @param {number} world_idx
625
+ * @param {string} coordinate
626
+ * @returns {string}
627
+ */
628
+ export function dump_terrain_cell_node_types(cluster_id, seed, world_idx, coordinate) {
629
+ let deferred3_0;
630
+ let deferred3_1;
631
+ try {
632
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
633
+ const len0 = WASM_VECTOR_LEN;
634
+ const ptr1 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
635
+ const len1 = WASM_VECTOR_LEN;
636
+ const ret = wasm.dump_terrain_cell_node_types(ptr0, len0, seed, world_idx, ptr1, len1);
637
+ deferred3_0 = ret[0];
638
+ deferred3_1 = ret[1];
639
+ return getStringFromWasm0(ret[0], ret[1]);
640
+ } finally {
641
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
642
+ }
643
+ }
644
+
645
+ /**
646
+ * Diagnostic: compute f32 transcendentals on a list of test inputs and
647
+ * dump the bit patterns. Used to confirm wasm32 libm vs x86 ucrt have
648
+ * different f32::ln/f32::exp outputs (suspected root of OASIS W1
649
+ * thermal divergence).
650
+ * @returns {string}
651
+ */
652
+ export function dump_transcendental_test() {
653
+ let deferred1_0;
654
+ let deferred1_1;
655
+ try {
656
+ const ret = wasm.dump_transcendental_test();
657
+ deferred1_0 = ret[0];
658
+ deferred1_1 = ret[1];
659
+ return getStringFromWasm0(ret[0], ret[1]);
660
+ } finally {
661
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
662
+ }
663
+ }
664
+
665
+ /**
666
+ * Diagnostic: dump per-cell element_idx + mass-bits + temp-bits for
667
+ * one world's `sim_cells`. Used to find the FIRST concretely-different
668
+ * cell when a digest hash diverges. Output is TSV (idx, elem_idx,
669
+ * mass_bits, temp_bits) — bits so f32s round-trip exactly through JSON.
670
+ * @param {string} coordinate
671
+ * @param {string} cluster_id
672
+ * @param {number} seed
673
+ * @param {string} mode
674
+ * @param {number} world_idx
675
+ * @param {string} overrides_json
676
+ * @returns {string}
677
+ */
678
+ export function dump_world_cells(coordinate, cluster_id, seed, mode, world_idx, overrides_json) {
679
+ let deferred5_0;
680
+ let deferred5_1;
681
+ try {
682
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
683
+ const len0 = WASM_VECTOR_LEN;
684
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
685
+ const len1 = WASM_VECTOR_LEN;
686
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
687
+ const len2 = WASM_VECTOR_LEN;
688
+ const ptr3 = passStringToWasm0(overrides_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
689
+ const len3 = WASM_VECTOR_LEN;
690
+ const ret = wasm.dump_world_cells(ptr0, len0, ptr1, len1, seed, ptr2, len2, world_idx, ptr3, len3);
691
+ deferred5_0 = ret[0];
692
+ deferred5_1 = ret[1];
693
+ return getStringFromWasm0(ret[0], ret[1]);
694
+ } finally {
695
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
696
+ }
697
+ }
698
+
699
+ /**
700
+ * Dump cell state after exactly N settle ticks for a specific world.
701
+ * Used to bisect wasm-vs-native f32 divergence at tick granularity.
702
+ * @param {string} coordinate
703
+ * @param {number} world_idx
704
+ * @param {number} target_tick
705
+ * @returns {string}
706
+ */
707
+ export function dump_world_cells_at_tick(coordinate, world_idx, target_tick) {
708
+ let deferred2_0;
709
+ let deferred2_1;
710
+ try {
711
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
712
+ const len0 = WASM_VECTOR_LEN;
713
+ const ret = wasm.dump_world_cells_at_tick(ptr0, len0, world_idx, target_tick);
714
+ deferred2_0 = ret[0];
715
+ deferred2_1 = ret[1];
716
+ return getStringFromWasm0(ret[0], ret[1]);
717
+ } finally {
718
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
719
+ }
720
+ }
721
+
722
+ /**
723
+ * Dump post-settle cell-state for a specific world (debug feature).
724
+ *
725
+ * Returns NDJSON-like JSON `{ "world_index": N, "width": W, "height": H,
726
+ * "element_idx": [Rust idx per cell], "element_names": [Rust ELEMENTS],
727
+ * "mass_hex": ["%08X" per cell, BE digit order],
728
+ * "temp_hex": ["%08X" per cell, BE digit order] }`.
729
+ *
730
+ * Mirrors `compute_digest_from_coordinate` setup so the post-settle
731
+ * state is identical to what the digest hashes — enables cell-by-cell
732
+ * diff between WASM and native, which is the diagnostic needed to
733
+ * hunt the OASIS W1 wasm-vs-native settle divergence (May 2026).
734
+ * Variant of [`dump_world_cells_settled`] that takes the cluster id +
735
+ * seed directly instead of going through `parse_coordinate`. Mirrors
736
+ * `compute_digest_for_cluster` — required when the coordinate prefix
737
+ * is ambiguous across mod clusters (e.g. CGSM has 3 clusters at
738
+ * `CGSM-C`).
739
+ * @param {string} cluster_id
740
+ * @param {number} seed
741
+ * @param {number} world_idx
742
+ * @returns {string}
743
+ */
744
+ export function dump_world_cells_for_cluster(cluster_id, seed, world_idx) {
745
+ let deferred2_0;
746
+ let deferred2_1;
747
+ try {
748
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
749
+ const len0 = WASM_VECTOR_LEN;
750
+ const ret = wasm.dump_world_cells_for_cluster(ptr0, len0, seed, world_idx);
751
+ deferred2_0 = ret[0];
752
+ deferred2_1 = ret[1];
753
+ return getStringFromWasm0(ret[0], ret[1]);
754
+ } finally {
755
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
756
+ }
757
+ }
758
+
759
+ /**
760
+ * Variant that ALSO sets story / mixing levels from a coordinate
761
+ * string (matching the `compute_digest_for_cluster` semantics). Use
762
+ * when you want the dump to reflect the same worldgen pass the
763
+ * digest is computed against.
764
+ * @param {string} cluster_id
765
+ * @param {number} seed
766
+ * @param {number} world_idx
767
+ * @param {string} coordinate
768
+ * @returns {string}
769
+ */
770
+ export function dump_world_cells_for_cluster_coord(cluster_id, seed, world_idx, coordinate) {
771
+ let deferred3_0;
772
+ let deferred3_1;
773
+ try {
774
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
775
+ const len0 = WASM_VECTOR_LEN;
776
+ const ptr1 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
777
+ const len1 = WASM_VECTOR_LEN;
778
+ const ret = wasm.dump_world_cells_for_cluster_coord(ptr0, len0, seed, world_idx, ptr1, len1);
779
+ deferred3_0 = ret[0];
780
+ deferred3_1 = ret[1];
781
+ return getStringFromWasm0(ret[0], ret[1]);
782
+ } finally {
783
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
784
+ }
785
+ }
786
+
787
+ /**
788
+ * @param {string} coordinate
789
+ * @param {number} world_idx
790
+ * @returns {string}
791
+ */
792
+ export function dump_world_cells_settled(coordinate, world_idx) {
793
+ let deferred2_0;
794
+ let deferred2_1;
795
+ try {
796
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
797
+ const len0 = WASM_VECTOR_LEN;
798
+ const ret = wasm.dump_world_cells_settled(ptr0, len0, world_idx);
799
+ deferred2_0 = ret[0];
800
+ deferred2_1 = ret[1];
801
+ return getStringFromWasm0(ret[0], ret[1]);
802
+ } finally {
803
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
804
+ }
805
+ }
806
+
807
+ /**
808
+ * Diagnostic: dump per-TC info (node_id, position, node_type, tags)
809
+ * for one world. Used to detect per-overworld-cell subworld-assignment
810
+ * drift when `ow_types_sha` matches (set/count) but actual placement
811
+ * differs.
812
+ * @param {string} coordinate
813
+ * @param {string} cluster_id
814
+ * @param {number} seed
815
+ * @param {string} mode
816
+ * @param {number} world_idx
817
+ * @returns {string}
818
+ */
819
+ export function dump_world_tcs(coordinate, cluster_id, seed, mode, world_idx) {
820
+ let deferred4_0;
821
+ let deferred4_1;
822
+ try {
823
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
824
+ const len0 = WASM_VECTOR_LEN;
825
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
826
+ const len1 = WASM_VECTOR_LEN;
827
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
828
+ const len2 = WASM_VECTOR_LEN;
829
+ const ret = wasm.dump_world_tcs(ptr0, len0, ptr1, len1, seed, ptr2, len2, world_idx);
830
+ deferred4_0 = ret[0];
831
+ deferred4_1 = ret[1];
832
+ return getStringFromWasm0(ret[0], ret[1]);
833
+ } finally {
834
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
835
+ }
836
+ }
837
+
838
+ /**
839
+ * Diagnostic: dump per-world traits + subworld files for a generated
840
+ * cluster. Used to debug `world_traits_sha` / `subworld_files_sha`
841
+ * divergence — once a digest hash diverges, this tells you the
842
+ * actual content difference.
843
+ * @param {string} coordinate
844
+ * @param {string} cluster_id
845
+ * @param {number} seed
846
+ * @param {string} mode
847
+ * @returns {string}
848
+ */
849
+ export function dump_world_traits(coordinate, cluster_id, seed, mode) {
850
+ let deferred4_0;
851
+ let deferred4_1;
852
+ try {
853
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
854
+ const len0 = WASM_VECTOR_LEN;
855
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
856
+ const len1 = WASM_VECTOR_LEN;
857
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
858
+ const len2 = WASM_VECTOR_LEN;
859
+ const ret = wasm.dump_world_traits(ptr0, len0, ptr1, len1, seed, ptr2, len2);
860
+ deferred4_0 = ret[0];
861
+ deferred4_1 = ret[1];
862
+ return getStringFromWasm0(ret[0], ret[1]);
863
+ } finally {
864
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
865
+ }
866
+ }
867
+
868
+ /**
869
+ * Evaluate a noise tree over a `width × height` 2D grid and return
870
+ * one `f32` per cell, row-major (`y * width + x`). Values are
871
+ * unnormalised; the consumer applies any colour ramp.
872
+ *
873
+ * `tree_kind`:
874
+ * - `"named"`: look up `tree_value` in the live `SettingsCache.noise`
875
+ * map (the same map the editor mutates).
876
+ * - `"inline"`: parse `tree_value` as a YAML document in isolation.
877
+ *
878
+ * Output is bit-identical to the engine's own evaluation at the
879
+ * given seed. Sample coords map `width × height` linearly onto the
880
+ * tree's `settings.lowerBound..upperBound` rectangle (cell-centred),
881
+ * at `z = 0` (worldgen samples the XZ plane at y = 0).
882
+ * @param {string} tree_kind
883
+ * @param {string} tree_value
884
+ * @param {number} width
885
+ * @param {number} height
886
+ * @param {number} seed
887
+ * @returns {Float32Array}
888
+ */
889
+ export function evaluate_noise(tree_kind, tree_value, width, height, seed) {
890
+ const ptr0 = passStringToWasm0(tree_kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
891
+ const len0 = WASM_VECTOR_LEN;
892
+ const ptr1 = passStringToWasm0(tree_value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
893
+ const len1 = WASM_VECTOR_LEN;
894
+ const ret = wasm.evaluate_noise(ptr0, len0, ptr1, len1, width, height, seed);
895
+ if (ret[3]) {
896
+ throw takeFromExternrefTable0(ret[2]);
897
+ }
898
+ var v3 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
899
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
900
+ return v3;
901
+ }
902
+
903
+ /**
904
+ * Extract the parts of a generated cluster's state that mod
905
+ * extensions (CGM and equivalents) need to compute post-snapshot
906
+ * overrides. Companion to [`compute_digest_with_overrides`].
907
+ *
908
+ * Mod-extensions consume this snapshot, compute structured
909
+ * mutations (e.g. CGM's geyser blacklist re-rolls, SO_POI pins,
910
+ * vanilla-starmap replacements) in TS, then pass the resulting
911
+ * `overrides_json` back to [`compute_digest_with_overrides`] to
912
+ * fold them into the digest.
913
+ *
914
+ * Schema (JSON):
915
+ * ```json
916
+ * {
917
+ * "globalWorldSeed": 1000824071,
918
+ * "isExpansion1": true,
919
+ * "worlds": [
920
+ * { "placementIndex": 0, "offsetX": 0, "offsetY": 0,
921
+ * "worldWidth": 96, "clusterLocation": { "q": 0, "r": 0 },
922
+ * "entitySpawners": [
923
+ * { "tag": "GeyserGeneric", "cell": 100,
924
+ * "resolvedGeyserTemplate": "hot_water" }
925
+ * ]
926
+ * }
927
+ * ],
928
+ * "poiLocations": [
929
+ * { "poiType": "HarvestableSpacePOI_X", "location": { "q": 5, "r": 5 } }
930
+ * ],
931
+ * "vanillaDestinations": [ { "destType": "...", "distance": 0 } ]
932
+ * }
933
+ * ```
934
+ *
935
+ * The schema is the symmetric input to the TS `Snapshot` interface
936
+ * in `packages/oxygen-not-included-mod-extensions/src/cgm/transformer.ts`.
937
+ * @param {string} coordinate
938
+ * @param {string} cluster_id
939
+ * @param {number} seed
940
+ * @param {string} mode
941
+ * @returns {string}
942
+ */
943
+ export function extract_overrideable_state(coordinate, cluster_id, seed, mode) {
944
+ let deferred4_0;
945
+ let deferred4_1;
946
+ try {
947
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
948
+ const len0 = WASM_VECTOR_LEN;
949
+ const ptr1 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
950
+ const len1 = WASM_VECTOR_LEN;
951
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
952
+ const len2 = WASM_VECTOR_LEN;
953
+ const ret = wasm.extract_overrideable_state(ptr0, len0, ptr1, len1, seed, ptr2, len2);
954
+ deferred4_0 = ret[0];
955
+ deferred4_1 = ret[1];
956
+ return getStringFromWasm0(ret[0], ret[1]);
957
+ } finally {
958
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
959
+ }
960
+ }
961
+
962
+ /**
963
+ * The ONI game build this WASM was parity-baselined against (e.g.
964
+ * `"737195"`).
965
+ * @returns {string}
966
+ */
967
+ export function game_version() {
968
+ let deferred1_0;
969
+ let deferred1_1;
970
+ try {
971
+ const ret = wasm.game_version();
972
+ deferred1_0 = ret[0];
973
+ deferred1_1 = ret[1];
974
+ return getStringFromWasm0(ret[0], ret[1]);
975
+ } finally {
976
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
977
+ }
978
+ }
979
+
980
+ /**
981
+ * Generate a cluster by cluster id + seed. Returns a `ClusterResult`
982
+ * JSON envelope. For the coordinate-string form (story traits +
983
+ * mixing) use `generate_from_coordinate`.
984
+ * @param {number} seed
985
+ * @param {string} cluster_id
986
+ * @returns {string}
987
+ */
988
+ export function generate_cluster(seed, cluster_id) {
989
+ let deferred2_0;
990
+ let deferred2_1;
991
+ try {
992
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
993
+ const len0 = WASM_VECTOR_LEN;
994
+ const ret = wasm.generate_cluster(seed, ptr0, len0);
995
+ deferred2_0 = ret[0];
996
+ deferred2_1 = ret[1];
997
+ return getStringFromWasm0(ret[0], ret[1]);
998
+ } finally {
999
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1000
+ }
1001
+ }
1002
+
1003
+ /**
1004
+ * Generate all worlds in a cluster and return per-cell polygon data for each.
1005
+ *
1006
+ * Returns JSON: `{ "cluster_id", "seed", "worlds": [{ "name", "width", "height", "is_starting", "cells": [...] }] }`
1007
+ * @param {number} seed
1008
+ * @param {string} cluster_id
1009
+ * @returns {string}
1010
+ */
1011
+ export function generate_cluster_cells(seed, cluster_id) {
1012
+ let deferred2_0;
1013
+ let deferred2_1;
1014
+ try {
1015
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1016
+ const len0 = WASM_VECTOR_LEN;
1017
+ const ret = wasm.generate_cluster_cells(seed, ptr0, len0);
1018
+ deferred2_0 = ret[0];
1019
+ deferred2_1 = ret[1];
1020
+ return getStringFromWasm0(ret[0], ret[1]);
1021
+ } finally {
1022
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1023
+ }
1024
+ }
1025
+
1026
+ /**
1027
+ * Generate a cluster and return the rendered SimCell grid for each world.
1028
+ * Returns JSON with element_idx, mass_hex, temp_hex, disease_idx, disease_count arrays.
1029
+ * This is the same data format as the C# snapshot for parity verification.
1030
+ * @param {number} seed
1031
+ * @param {string} cluster_id
1032
+ * @returns {string}
1033
+ */
1034
+ export function generate_cluster_rendered(seed, cluster_id) {
1035
+ let deferred2_0;
1036
+ let deferred2_1;
1037
+ try {
1038
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1039
+ const len0 = WASM_VECTOR_LEN;
1040
+ const ret = wasm.generate_cluster_rendered(seed, ptr0, len0);
1041
+ deferred2_0 = ret[0];
1042
+ deferred2_1 = ret[1];
1043
+ return getStringFromWasm0(ret[0], ret[1]);
1044
+ } finally {
1045
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1046
+ }
1047
+ }
1048
+
1049
+ /**
1050
+ * Generate a cluster with provided cluster YAML config override.
1051
+ * @param {number} seed
1052
+ * @param {string} cluster_id
1053
+ * @param {string} cluster_yaml
1054
+ * @param {string} _world_yamls
1055
+ * @returns {string}
1056
+ */
1057
+ export function generate_cluster_with_configs(seed, cluster_id, cluster_yaml, _world_yamls) {
1058
+ let deferred4_0;
1059
+ let deferred4_1;
1060
+ try {
1061
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1062
+ const len0 = WASM_VECTOR_LEN;
1063
+ const ptr1 = passStringToWasm0(cluster_yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1064
+ const len1 = WASM_VECTOR_LEN;
1065
+ const ptr2 = passStringToWasm0(_world_yamls, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1066
+ const len2 = WASM_VECTOR_LEN;
1067
+ const ret = wasm.generate_cluster_with_configs(seed, ptr0, len0, ptr1, len1, ptr2, len2);
1068
+ deferred4_0 = ret[0];
1069
+ deferred4_1 = ret[1];
1070
+ return getStringFromWasm0(ret[0], ret[1]);
1071
+ } finally {
1072
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1073
+ }
1074
+ }
1075
+
1076
+ /**
1077
+ * Generate a cluster from a game coordinate string (e.g.
1078
+ * `"SNDST-A-42-0-4A-MUWF1"`). Returns a `ClusterResult` JSON
1079
+ * envelope; for the typed-array `MapData` shape use
1080
+ * `generate_map_data`.
1081
+ * @param {string} coordinate
1082
+ * @returns {string}
1083
+ */
1084
+ export function generate_from_coordinate(coordinate) {
1085
+ let deferred2_0;
1086
+ let deferred2_1;
1087
+ try {
1088
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1089
+ const len0 = WASM_VECTOR_LEN;
1090
+ const ret = wasm.generate_from_coordinate(ptr0, len0);
1091
+ deferred2_0 = ret[0];
1092
+ deferred2_1 = ret[1];
1093
+ return getStringFromWasm0(ret[0], ret[1]);
1094
+ } finally {
1095
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1096
+ }
1097
+ }
1098
+
1099
+ /**
1100
+ * Generate the layout for a cluster's starting world and return
1101
+ * per-cell data as JSON: `{ cells: [{ site_id, x, y, type }, ...] }`.
1102
+ * Used for cell-level comparison against C# reference snapshots.
1103
+ * @param {number} seed
1104
+ * @param {string} cluster_id
1105
+ * @returns {string}
1106
+ */
1107
+ export function generate_layout_cells(seed, cluster_id) {
1108
+ let deferred2_0;
1109
+ let deferred2_1;
1110
+ try {
1111
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1112
+ const len0 = WASM_VECTOR_LEN;
1113
+ const ret = wasm.generate_layout_cells(seed, ptr0, len0);
1114
+ deferred2_0 = ret[0];
1115
+ deferred2_1 = ret[1];
1116
+ return getStringFromWasm0(ret[0], ret[1]);
1117
+ } finally {
1118
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1119
+ }
1120
+ }
1121
+
1122
+ /**
1123
+ * Generate a cluster from a game coordinate and return a `MapData`
1124
+ * value: per-world element grids, biome cell polygons, entity spawns,
1125
+ * and starmap locations. Caches the cluster for the two-phase API
1126
+ * (`settle_cluster_advance`, `get_entity_spawners`).
1127
+ *
1128
+ * Per-cell grids ship as typed arrays (`Uint16Array`, `Float32Array`,
1129
+ * etc.) on `JsValue` so JS consumers don't pay a JSON parse.
1130
+ * @param {string} coordinate
1131
+ * @returns {any}
1132
+ */
1133
+ export function generate_map_data(coordinate) {
1134
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1135
+ const len0 = WASM_VECTOR_LEN;
1136
+ const ret = wasm.generate_map_data(ptr0, len0);
1137
+ return ret;
1138
+ }
1139
+
1140
+ /**
1141
+ * Generate a cluster from coordinate and return per-world element grids.
1142
+ * Used for parity verification against C# snapshots.
1143
+ * @param {string} coordinate
1144
+ * @returns {string}
1145
+ */
1146
+ export function generate_rendered_from_coordinate(coordinate) {
1147
+ let deferred2_0;
1148
+ let deferred2_1;
1149
+ try {
1150
+ const ptr0 = passStringToWasm0(coordinate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1151
+ const len0 = WASM_VECTOR_LEN;
1152
+ const ret = wasm.generate_rendered_from_coordinate(ptr0, len0);
1153
+ deferred2_0 = ret[0];
1154
+ deferred2_1 = ret[1];
1155
+ return getStringFromWasm0(ret[0], ret[1]);
1156
+ } finally {
1157
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1158
+ }
1159
+ }
1160
+
1161
+ /**
1162
+ * Generate a single SandstoneDefault world and return timing + cell count data.
1163
+ * @param {number} seed
1164
+ * @returns {string}
1165
+ */
1166
+ export function generate_sandstone_default(seed) {
1167
+ let deferred1_0;
1168
+ let deferred1_1;
1169
+ try {
1170
+ const ret = wasm.generate_sandstone_default(seed);
1171
+ deferred1_0 = ret[0];
1172
+ deferred1_1 = ret[1];
1173
+ return getStringFromWasm0(ret[0], ret[1]);
1174
+ } finally {
1175
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1176
+ }
1177
+ }
1178
+
1179
+ /**
1180
+ * Generate terrain cells for the starting world and return as JSON.
1181
+ * Used to verify WASM vs native parity.
1182
+ * @param {number} seed
1183
+ * @param {string} cluster_id
1184
+ * @returns {string}
1185
+ */
1186
+ export function generate_terrain_cells(seed, cluster_id) {
1187
+ let deferred2_0;
1188
+ let deferred2_1;
1189
+ try {
1190
+ const ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1191
+ const len0 = WASM_VECTOR_LEN;
1192
+ const ret = wasm.generate_terrain_cells(seed, ptr0, len0);
1193
+ deferred2_0 = ret[0];
1194
+ deferred2_1 = ret[1];
1195
+ return getStringFromWasm0(ret[0], ret[1]);
1196
+ } finally {
1197
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1198
+ }
1199
+ }
1200
+
1201
+ /**
1202
+ * Generate a VanillaSandstoneCluster (8-world DLC cluster) and return timing + cell count data.
1203
+ * @param {number} seed
1204
+ * @returns {string}
1205
+ */
1206
+ export function generate_vanilla_sandstone_cluster(seed) {
1207
+ let deferred1_0;
1208
+ let deferred1_1;
1209
+ try {
1210
+ const ret = wasm.generate_vanilla_sandstone_cluster(seed);
1211
+ deferred1_0 = ret[0];
1212
+ deferred1_1 = ret[1];
1213
+ return getStringFromWasm0(ret[0], ret[1]);
1214
+ } finally {
1215
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1216
+ }
1217
+ }
1218
+
1219
+ /**
1220
+ * Re-run ambient mob spawning against the cached cluster's current
1221
+ * cell state and return the refreshed entity lists. Call after
1222
+ * `settle_cluster_advance` chunks when settled liquid/gas flow may
1223
+ * have invalidated earlier mob placements. Requires a prior
1224
+ * `generate_map_data`. Template-placed entities (geysers, oil wells,
1225
+ * props) persist across calls.
1226
+ * @returns {string}
1227
+ */
1228
+ export function get_entity_spawners() {
1229
+ let deferred1_0;
1230
+ let deferred1_1;
1231
+ try {
1232
+ const ret = wasm.get_entity_spawners();
1233
+ deferred1_0 = ret[0];
1234
+ deferred1_1 = ret[1];
1235
+ return getStringFromWasm0(ret[0], ret[1]);
1236
+ } finally {
1237
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1238
+ }
1239
+ }
1240
+
1241
+ /**
1242
+ * @param {number} num_threads
1243
+ * @returns {Promise<any>}
1244
+ */
1245
+ export function initThreadPool(num_threads) {
1246
+ const ret = wasm.initThreadPool(num_threads);
1247
+ return ret;
1248
+ }
1249
+
1250
+ /**
1251
+ * Returns a JSON-encoded `NoiseNodeKindSpec[]` enumerating every
1252
+ * noise node variant the engine recognises (primitives, filters,
1253
+ * modifiers, transformers, selectors, combiners) plus its param
1254
+ * schema. Static across the lifetime of the build.
1255
+ * @returns {string}
1256
+ */
1257
+ export function noise_node_kinds() {
1258
+ let deferred1_0;
1259
+ let deferred1_1;
1260
+ try {
1261
+ const ret = wasm.noise_node_kinds();
1262
+ deferred1_0 = ret[0];
1263
+ deferred1_1 = ret[1];
1264
+ return getStringFromWasm0(ret[0], ret[1]);
1265
+ } finally {
1266
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1267
+ }
1268
+ }
1269
+
1270
+ /**
1271
+ * Diagnostic: hash every category of the active SettingsCache to a
1272
+ * stable JSON fingerprint. Used to compare load_generated state vs
1273
+ * post-snapshot-roundtrip state to find which category drifts.
1274
+ * @returns {string}
1275
+ */
1276
+ export function probe_settings_fingerprint() {
1277
+ let deferred1_0;
1278
+ let deferred1_1;
1279
+ try {
1280
+ const ret = wasm.probe_settings_fingerprint();
1281
+ deferred1_0 = ret[0];
1282
+ deferred1_1 = ret[1];
1283
+ return getStringFromWasm0(ret[0], ret[1]);
1284
+ } finally {
1285
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1286
+ }
1287
+ }
1288
+
1289
+ /**
1290
+ * Diagnostic: serialize a specific subworld via its name lookup and
1291
+ * return both an alphabetical-keys hash AND an iteration-order JSON.
1292
+ * The two should match across "direct load" and "snapshot roundtrip"
1293
+ * paths if the bug isn't in HashMap iteration order.
1294
+ * @param {string} name
1295
+ * @returns {string}
1296
+ */
1297
+ export function probe_subworld_raw_json(name) {
1298
+ let deferred2_0;
1299
+ let deferred2_1;
1300
+ try {
1301
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1302
+ const len0 = WASM_VECTOR_LEN;
1303
+ const ret = wasm.probe_subworld_raw_json(ptr0, len0);
1304
+ deferred2_0 = ret[0];
1305
+ deferred2_1 = ret[1];
1306
+ return getStringFromWasm0(ret[0], ret[1]);
1307
+ } finally {
1308
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1309
+ }
1310
+ }
1311
+
1312
+ /**
1313
+ * Diagnostic: dump cache.subworlds in its raw HashMap iteration
1314
+ * order (NOT sorted), with each subworld's JSON. Used to detect
1315
+ * HashMap iteration-order drift that's invisible to sorted-key
1316
+ * fingerprints.
1317
+ * @returns {string}
1318
+ */
1319
+ export function probe_subworlds_iteration_order_hash() {
1320
+ let deferred1_0;
1321
+ let deferred1_1;
1322
+ try {
1323
+ const ret = wasm.probe_subworlds_iteration_order_hash();
1324
+ deferred1_0 = ret[0];
1325
+ deferred1_1 = ret[1];
1326
+ return getStringFromWasm0(ret[0], ret[1]);
1327
+ } finally {
1328
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1329
+ }
1330
+ }
1331
+
1332
+ /**
1333
+ * Toggle template placement. WASM-side counterpart of the native
1334
+ * `SKIP_TEMPLATES` env var.
1335
+ * @param {boolean} skip
1336
+ */
1337
+ export function set_skip_templates(skip) {
1338
+ wasm.set_skip_templates(skip);
1339
+ }
1340
+
1341
+ /**
1342
+ * Toggle the per-thread oni-voronoi debug-capture flag. Off by
1343
+ * default so production hot paths don't pay for the per-iteration
1344
+ * trace. Mod-parity diff scripts flip this on around the worldgen
1345
+ * call.
1346
+ * @param {boolean} enabled
1347
+ */
1348
+ export function set_voronoi_debug_capture(enabled) {
1349
+ wasm.set_voronoi_debug_capture(enabled);
1350
+ }
1351
+
1352
+ /**
1353
+ * Drop both the SettingsCache and the cluster cache. The next
1354
+ * `generate_*` call reloads the embedded stock defaults.
1355
+ */
1356
+ export function settings_reset() {
1357
+ wasm.settings_reset();
1358
+ }
1359
+
1360
+ /**
1361
+ * Advance the cached cluster's settle sim to `target_tick` and
1362
+ * return a binary snapshot at that tick covering every world. Call
1363
+ * repeatedly with increasing ticks to paint intermediate frames;
1364
+ * `target_tick = 499` finalises the cluster.
1365
+ *
1366
+ * `target_tick` must be in `1..=499`. A tick `<=` the current cached
1367
+ * tick re-emits the current frame. Returns an empty buffer on
1368
+ * out-of-range tick or empty/stale cache; call `generate_map_data`
1369
+ * first to populate.
1370
+ *
1371
+ * Binary format (all little-endian, v5):
1372
+ * - `u32` version tag (= 5)
1373
+ * - `u32` tick
1374
+ * - `u32` world count
1375
+ * - per world: `u32` width, `u32` height, then `width * height`
1376
+ * cells of 25 bytes each: `u16 elem, f32 mass, f32 temp, u8 dis,
1377
+ * i32 dis_count, u16 bw_elem, f32 bw_mass, f32 bw_temp`. Worlds
1378
+ * without `backwallNoise` emit Vacuum + 0 mass + 0 temp.
1379
+ * @param {number} target_tick
1380
+ * @returns {Uint8Array}
1381
+ */
1382
+ export function settle_cluster_advance(target_tick) {
1383
+ const ret = wasm.settle_cluster_advance(target_tick);
1384
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1385
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1386
+ return v1;
1387
+ }
1388
+
1389
+ /**
1390
+ * Drain the in-memory log buffer for `channel` (e.g. `"ppc_prng"`).
1391
+ * WASM-side stand-in for native diag sites that would write to
1392
+ * `std::fs::*`.
1393
+ * @param {string} channel
1394
+ * @returns {string}
1395
+ */
1396
+ export function sim_env_drain_log(channel) {
1397
+ let deferred2_0;
1398
+ let deferred2_1;
1399
+ try {
1400
+ const ptr0 = passStringToWasm0(channel, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1401
+ const len0 = WASM_VECTOR_LEN;
1402
+ const ret = wasm.sim_env_drain_log(ptr0, len0);
1403
+ deferred2_0 = ret[0];
1404
+ deferred2_1 = ret[1];
1405
+ return getStringFromWasm0(ret[0], ret[1]);
1406
+ } finally {
1407
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1408
+ }
1409
+ }
1410
+
1411
+ /**
1412
+ * Set a `(key, value)` in the cross-target env overlay read by
1413
+ * `oni_sim::sim_env::var`. WASM-side stand-in for the `SIM_*_PATH` /
1414
+ * `SIM_*_TICK` env vars used by native diag sites.
1415
+ * @param {string} key
1416
+ * @param {string} value
1417
+ */
1418
+ export function sim_env_set(key, value) {
1419
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1420
+ const len0 = WASM_VECTOR_LEN;
1421
+ const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1422
+ const len1 = WASM_VECTOR_LEN;
1423
+ wasm.sim_env_set(ptr0, len0, ptr1, len1);
1424
+ }
1425
+
1426
+ /**
1427
+ * Stable hex hash of a snapshot JSON. Alias of
1428
+ * `snapshot_checksum_canonical`; same content always hashes to the
1429
+ * same value regardless of HashMap/IndexMap iteration order.
1430
+ * @param {string} snapshot_json
1431
+ * @returns {string}
1432
+ */
1433
+ export function snapshot_checksum(snapshot_json) {
1434
+ let deferred3_0;
1435
+ let deferred3_1;
1436
+ try {
1437
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1438
+ const len0 = WASM_VECTOR_LEN;
1439
+ const ret = wasm.snapshot_checksum(ptr0, len0);
1440
+ var ptr2 = ret[0];
1441
+ var len2 = ret[1];
1442
+ if (ret[3]) {
1443
+ ptr2 = 0; len2 = 0;
1444
+ throw takeFromExternrefTable0(ret[2]);
1445
+ }
1446
+ deferred3_0 = ptr2;
1447
+ deferred3_1 = len2;
1448
+ return getStringFromWasm0(ptr2, len2);
1449
+ } finally {
1450
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1451
+ }
1452
+ }
1453
+
1454
+ /**
1455
+ * Byte-hash variant: FNV-1a-64 over the raw input bytes. Weak
1456
+ * contract; same logical content with different HashMap/IndexMap
1457
+ * iteration orders produces different hashes. Only safe when the
1458
+ * consumer caches the exact bytes it hashed.
1459
+ * @param {string} snapshot_json
1460
+ * @returns {string}
1461
+ */
1462
+ export function snapshot_checksum_bytes(snapshot_json) {
1463
+ let deferred2_0;
1464
+ let deferred2_1;
1465
+ try {
1466
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1467
+ const len0 = WASM_VECTOR_LEN;
1468
+ const ret = wasm.snapshot_checksum_bytes(ptr0, len0);
1469
+ deferred2_0 = ret[0];
1470
+ deferred2_1 = ret[1];
1471
+ return getStringFromWasm0(ret[0], ret[1]);
1472
+ } finally {
1473
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1474
+ }
1475
+ }
1476
+
1477
+ /**
1478
+ * Canonical-form variant: parses to a `serde_json::Value` (sorted
1479
+ * keys at every level), then FNV-1a-64 with type tags + length
1480
+ * prefixes. Same logical content always produces the same hash;
1481
+ * what `snapshot_checksum` (the default) and `snapshot_state_checksum`
1482
+ * route through.
1483
+ * @param {string} snapshot_json
1484
+ * @returns {string}
1485
+ */
1486
+ export function snapshot_checksum_canonical(snapshot_json) {
1487
+ let deferred3_0;
1488
+ let deferred3_1;
1489
+ try {
1490
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1491
+ const len0 = WASM_VECTOR_LEN;
1492
+ const ret = wasm.snapshot_checksum_canonical(ptr0, len0);
1493
+ var ptr2 = ret[0];
1494
+ var len2 = ret[1];
1495
+ if (ret[3]) {
1496
+ ptr2 = 0; len2 = 0;
1497
+ throw takeFromExternrefTable0(ret[2]);
1498
+ }
1499
+ deferred3_0 = ptr2;
1500
+ deferred3_1 = len2;
1501
+ return getStringFromWasm0(ptr2, len2);
1502
+ } finally {
1503
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1504
+ }
1505
+ }
1506
+
1507
+ /**
1508
+ * Build a `WorldgenSnapshot` from a `{path: JSON-string}` files map,
1509
+ * apply it to SETTINGS, and return the resulting snapshot JSON.
1510
+ * Strict mode.
1511
+ * @param {string} files_json
1512
+ * @returns {string}
1513
+ */
1514
+ export function snapshot_from_files(files_json) {
1515
+ let deferred3_0;
1516
+ let deferred3_1;
1517
+ try {
1518
+ const ptr0 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1519
+ const len0 = WASM_VECTOR_LEN;
1520
+ const ret = wasm.snapshot_from_files(ptr0, len0);
1521
+ var ptr2 = ret[0];
1522
+ var len2 = ret[1];
1523
+ if (ret[3]) {
1524
+ ptr2 = 0; len2 = 0;
1525
+ throw takeFromExternrefTable0(ret[2]);
1526
+ }
1527
+ deferred3_0 = ptr2;
1528
+ deferred3_1 = len2;
1529
+ return getStringFromWasm0(ptr2, len2);
1530
+ } finally {
1531
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1532
+ }
1533
+ }
1534
+
1535
+ /**
1536
+ * Extensions-mode counterpart of `snapshot_from_files`.
1537
+ * @param {string} files_json
1538
+ * @returns {string}
1539
+ */
1540
+ export function snapshot_from_files_extensions(files_json) {
1541
+ let deferred3_0;
1542
+ let deferred3_1;
1543
+ try {
1544
+ const ptr0 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1545
+ const len0 = WASM_VECTOR_LEN;
1546
+ const ret = wasm.snapshot_from_files_extensions(ptr0, len0);
1547
+ var ptr2 = ret[0];
1548
+ var len2 = ret[1];
1549
+ if (ret[3]) {
1550
+ ptr2 = 0; len2 = 0;
1551
+ throw takeFromExternrefTable0(ret[2]);
1552
+ }
1553
+ deferred3_0 = ptr2;
1554
+ deferred3_1 = len2;
1555
+ return getStringFromWasm0(ptr2, len2);
1556
+ } finally {
1557
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1558
+ }
1559
+ }
1560
+
1561
+ /**
1562
+ * Reset SETTINGS to the embedded U59 vanilla baseline and return the
1563
+ * vanilla snapshot as a JSON string. Strict mode.
1564
+ * @returns {string}
1565
+ */
1566
+ export function snapshot_load_vanilla() {
1567
+ let deferred2_0;
1568
+ let deferred2_1;
1569
+ try {
1570
+ const ret = wasm.snapshot_load_vanilla();
1571
+ var ptr1 = ret[0];
1572
+ var len1 = ret[1];
1573
+ if (ret[3]) {
1574
+ ptr1 = 0; len1 = 0;
1575
+ throw takeFromExternrefTable0(ret[2]);
1576
+ }
1577
+ deferred2_0 = ptr1;
1578
+ deferred2_1 = len1;
1579
+ return getStringFromWasm0(ptr1, len1);
1580
+ } finally {
1581
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1582
+ }
1583
+ }
1584
+
1585
+ /**
1586
+ * Extensions-mode counterpart of `snapshot_load_vanilla`. Subsequent
1587
+ * `merge_files` calls accept mod-defined enum extensions.
1588
+ * @returns {string}
1589
+ */
1590
+ export function snapshot_load_vanilla_extensions() {
1591
+ let deferred2_0;
1592
+ let deferred2_1;
1593
+ try {
1594
+ const ret = wasm.snapshot_load_vanilla_extensions();
1595
+ var ptr1 = ret[0];
1596
+ var len1 = ret[1];
1597
+ if (ret[3]) {
1598
+ ptr1 = 0; len1 = 0;
1599
+ throw takeFromExternrefTable0(ret[2]);
1600
+ }
1601
+ deferred2_0 = ptr1;
1602
+ deferred2_1 = len1;
1603
+ return getStringFromWasm0(ptr1, len1);
1604
+ } finally {
1605
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1606
+ }
1607
+ }
1608
+
1609
+ /**
1610
+ * Merge a `{path: JSON-string}` files map into an existing snapshot
1611
+ * JSON. Last-wins on duplicate paths. Applies the merged snapshot to
1612
+ * SETTINGS as a side effect.
1613
+ * @param {string} snapshot_json
1614
+ * @param {string} files_json
1615
+ * @returns {string}
1616
+ */
1617
+ export function snapshot_merge_files(snapshot_json, files_json) {
1618
+ let deferred4_0;
1619
+ let deferred4_1;
1620
+ try {
1621
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1622
+ const len0 = WASM_VECTOR_LEN;
1623
+ const ptr1 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1624
+ const len1 = WASM_VECTOR_LEN;
1625
+ const ret = wasm.snapshot_merge_files(ptr0, len0, ptr1, len1);
1626
+ var ptr3 = ret[0];
1627
+ var len3 = ret[1];
1628
+ if (ret[3]) {
1629
+ ptr3 = 0; len3 = 0;
1630
+ throw takeFromExternrefTable0(ret[2]);
1631
+ }
1632
+ deferred4_0 = ptr3;
1633
+ deferred4_1 = len3;
1634
+ return getStringFromWasm0(ptr3, len3);
1635
+ } finally {
1636
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1637
+ }
1638
+ }
1639
+
1640
+ /**
1641
+ * Drop `paths_json` (a JSON array of path strings) from a snapshot
1642
+ * JSON, apply the result to SETTINGS, and return the updated
1643
+ * snapshot JSON. Paths not present are silently ignored; mode and
1644
+ * element overrides are preserved.
1645
+ * @param {string} snapshot_json
1646
+ * @param {string} paths_json
1647
+ * @returns {string}
1648
+ */
1649
+ export function snapshot_remove_paths(snapshot_json, paths_json) {
1650
+ let deferred4_0;
1651
+ let deferred4_1;
1652
+ try {
1653
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1654
+ const len0 = WASM_VECTOR_LEN;
1655
+ const ptr1 = passStringToWasm0(paths_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1656
+ const len1 = WASM_VECTOR_LEN;
1657
+ const ret = wasm.snapshot_remove_paths(ptr0, len0, ptr1, len1);
1658
+ var ptr3 = ret[0];
1659
+ var len3 = ret[1];
1660
+ if (ret[3]) {
1661
+ ptr3 = 0; len3 = 0;
1662
+ throw takeFromExternrefTable0(ret[2]);
1663
+ }
1664
+ deferred4_0 = ptr3;
1665
+ deferred4_1 = len3;
1666
+ return getStringFromWasm0(ptr3, len3);
1667
+ } finally {
1668
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1669
+ }
1670
+ }
1671
+
1672
+ /**
1673
+ * Stable hex hash of the resident snapshot. Same content produces
1674
+ * the same hash regardless of HashMap/IndexMap iteration order or
1675
+ * load history. Auto-loads vanilla if empty.
1676
+ * @returns {string}
1677
+ */
1678
+ export function snapshot_state_checksum() {
1679
+ let deferred2_0;
1680
+ let deferred2_1;
1681
+ try {
1682
+ const ret = wasm.snapshot_state_checksum();
1683
+ var ptr1 = ret[0];
1684
+ var len1 = ret[1];
1685
+ if (ret[3]) {
1686
+ ptr1 = 0; len1 = 0;
1687
+ throw takeFromExternrefTable0(ret[2]);
1688
+ }
1689
+ deferred2_0 = ptr1;
1690
+ deferred2_1 = len1;
1691
+ return getStringFromWasm0(ptr1, len1);
1692
+ } finally {
1693
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1694
+ }
1695
+ }
1696
+
1697
+ /**
1698
+ * Drop the listed paths from the resident snapshot. `paths_json` is
1699
+ * a JSON array of path strings; paths not present are silently
1700
+ * ignored.
1701
+ * @param {string} paths_json
1702
+ * @returns {number}
1703
+ */
1704
+ export function snapshot_state_drop_paths(paths_json) {
1705
+ const ptr0 = passStringToWasm0(paths_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1706
+ const len0 = WASM_VECTOR_LEN;
1707
+ const ret = wasm.snapshot_state_drop_paths(ptr0, len0);
1708
+ if (ret[2]) {
1709
+ throw takeFromExternrefTable0(ret[1]);
1710
+ }
1711
+ return ret[0];
1712
+ }
1713
+
1714
+ /**
1715
+ * Return the resident snapshot as a JSON-encoded
1716
+ * `{path: JSON-string}` files map. Auto-loads vanilla if empty.
1717
+ * @returns {string}
1718
+ */
1719
+ export function snapshot_state_files() {
1720
+ let deferred2_0;
1721
+ let deferred2_1;
1722
+ try {
1723
+ const ret = wasm.snapshot_state_files();
1724
+ var ptr1 = ret[0];
1725
+ var len1 = ret[1];
1726
+ if (ret[3]) {
1727
+ ptr1 = 0; len1 = 0;
1728
+ throw takeFromExternrefTable0(ret[2]);
1729
+ }
1730
+ deferred2_0 = ptr1;
1731
+ deferred2_1 = len1;
1732
+ return getStringFromWasm0(ptr1, len1);
1733
+ } finally {
1734
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1735
+ }
1736
+ }
1737
+
1738
+ /**
1739
+ * Replace the resident snapshot from a `{path: JSON-string}` files
1740
+ * map. Strict; atomic. Throws and leaves the snapshot untouched on
1741
+ * invalid input.
1742
+ * @param {string} files_json
1743
+ * @returns {number}
1744
+ */
1745
+ export function snapshot_state_load(files_json) {
1746
+ const ptr0 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1747
+ const len0 = WASM_VECTOR_LEN;
1748
+ const ret = wasm.snapshot_state_load(ptr0, len0);
1749
+ if (ret[2]) {
1750
+ throw takeFromExternrefTable0(ret[1]);
1751
+ }
1752
+ return ret[0];
1753
+ }
1754
+
1755
+ /**
1756
+ * Extensions-mode counterpart of `snapshot_state_load`. Subsequent
1757
+ * merges inherit the Extensions mode from the loaded snapshot.
1758
+ * @param {string} files_json
1759
+ * @returns {number}
1760
+ */
1761
+ export function snapshot_state_load_extensions(files_json) {
1762
+ const ptr0 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1763
+ const len0 = WASM_VECTOR_LEN;
1764
+ const ret = wasm.snapshot_state_load_extensions(ptr0, len0);
1765
+ if (ret[2]) {
1766
+ throw takeFromExternrefTable0(ret[1]);
1767
+ }
1768
+ return ret[0];
1769
+ }
1770
+
1771
+ /**
1772
+ * Merge a `{path: JSON-string}` files map into the resident snapshot.
1773
+ * Last-wins on duplicate paths. Auto-loads vanilla if empty; atomic
1774
+ * on parse failure. Mode is inherited from the resident snapshot.
1775
+ * @param {string} files_json
1776
+ * @returns {number}
1777
+ */
1778
+ export function snapshot_state_merge(files_json) {
1779
+ const ptr0 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1780
+ const len0 = WASM_VECTOR_LEN;
1781
+ const ret = wasm.snapshot_state_merge(ptr0, len0);
1782
+ if (ret[2]) {
1783
+ throw takeFromExternrefTable0(ret[1]);
1784
+ }
1785
+ return ret[0];
1786
+ }
1787
+
1788
+ /**
1789
+ * Clear the resident snapshot and bump the version. The next
1790
+ * `snapshot_state_*` call auto-loads vanilla.
1791
+ */
1792
+ export function snapshot_state_reset() {
1793
+ wasm.snapshot_state_reset();
1794
+ }
1795
+
1796
+ /**
1797
+ * Reset the resident snapshot to the embedded vanilla baseline.
1798
+ * Strict mode.
1799
+ * @returns {number}
1800
+ */
1801
+ export function snapshot_state_vanilla() {
1802
+ const ret = wasm.snapshot_state_vanilla();
1803
+ return ret;
1804
+ }
1805
+
1806
+ /**
1807
+ * Same as `snapshot_state_vanilla`, Extensions mode. Subsequent
1808
+ * merges accept mod-defined enum extensions.
1809
+ * @returns {number}
1810
+ */
1811
+ export function snapshot_state_vanilla_extensions() {
1812
+ const ret = wasm.snapshot_state_vanilla_extensions();
1813
+ return ret;
1814
+ }
1815
+
1816
+ /**
1817
+ * Monotonic mutation counter. Bumps on every successful mutation;
1818
+ * 0 if the slot has never been touched.
1819
+ * @returns {number}
1820
+ */
1821
+ export function snapshot_state_version() {
1822
+ const ret = wasm.snapshot_state_version();
1823
+ return ret;
1824
+ }
1825
+
1826
+ /**
1827
+ * Convert a snapshot JSON into a `{path: JSON-string}` files map.
1828
+ * Round-trips back through `snapshot_from_files`.
1829
+ * @param {string} snapshot_json
1830
+ * @returns {string}
1831
+ */
1832
+ export function snapshot_to_files(snapshot_json) {
1833
+ let deferred3_0;
1834
+ let deferred3_1;
1835
+ try {
1836
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1837
+ const len0 = WASM_VECTOR_LEN;
1838
+ const ret = wasm.snapshot_to_files(ptr0, len0);
1839
+ var ptr2 = ret[0];
1840
+ var len2 = ret[1];
1841
+ if (ret[3]) {
1842
+ ptr2 = 0; len2 = 0;
1843
+ throw takeFromExternrefTable0(ret[2]);
1844
+ }
1845
+ deferred3_0 = ptr2;
1846
+ deferred3_1 = len2;
1847
+ return getStringFromWasm0(ptr2, len2);
1848
+ } finally {
1849
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1850
+ }
1851
+ }
1852
+
1853
+ /**
1854
+ * Drain the thermal pair trace buffer (one entry per pair-fire).
1855
+ * @returns {string}
1856
+ */
1857
+ export function take_thermal_pair_trace() {
1858
+ let deferred1_0;
1859
+ let deferred1_1;
1860
+ try {
1861
+ const ret = wasm.take_thermal_pair_trace();
1862
+ deferred1_0 = ret[0];
1863
+ deferred1_1 = ret[1];
1864
+ return getStringFromWasm0(ret[0], ret[1]);
1865
+ } finally {
1866
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1867
+ }
1868
+ }
1869
+
1870
+ /**
1871
+ * Diagnostic: test f64::cos / f64::sin for a specific input. Used
1872
+ * to verify WASM precision against native Rust + system libm.
1873
+ * @param {bigint} angle_bits
1874
+ * @returns {string}
1875
+ */
1876
+ export function test_cos_sin(angle_bits) {
1877
+ let deferred1_0;
1878
+ let deferred1_1;
1879
+ try {
1880
+ const ret = wasm.test_cos_sin(angle_bits);
1881
+ deferred1_0 = ret[0];
1882
+ deferred1_1 = ret[1];
1883
+ return getStringFromWasm0(ret[0], ret[1]);
1884
+ } finally {
1885
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1886
+ }
1887
+ }
1888
+
1889
+ /**
1890
+ * Diagnostic: ucrt-port logf on a JSON list of input bit patterns.
1891
+ * Returns per-input output bit pattern for cross-platform verification.
1892
+ * @param {string} input_bits_json
1893
+ * @returns {string}
1894
+ */
1895
+ export function ucrt_logf_batch(input_bits_json) {
1896
+ let deferred2_0;
1897
+ let deferred2_1;
1898
+ try {
1899
+ const ptr0 = passStringToWasm0(input_bits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1900
+ const len0 = WASM_VECTOR_LEN;
1901
+ const ret = wasm.ucrt_logf_batch(ptr0, len0);
1902
+ deferred2_0 = ret[0];
1903
+ deferred2_1 = ret[1];
1904
+ return getStringFromWasm0(ret[0], ret[1]);
1905
+ } finally {
1906
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1907
+ }
1908
+ }
1909
+
1910
+ export class wbg_rayon_PoolBuilder {
1911
+ static __wrap(ptr) {
1912
+ ptr = ptr >>> 0;
1913
+ const obj = Object.create(wbg_rayon_PoolBuilder.prototype);
1914
+ obj.__wbg_ptr = ptr;
1915
+ wbg_rayon_PoolBuilderFinalization.register(obj, obj.__wbg_ptr, obj);
1916
+ return obj;
1917
+ }
1918
+ __destroy_into_raw() {
1919
+ const ptr = this.__wbg_ptr;
1920
+ this.__wbg_ptr = 0;
1921
+ wbg_rayon_PoolBuilderFinalization.unregister(this);
1922
+ return ptr;
1923
+ }
1924
+ free() {
1925
+ const ptr = this.__destroy_into_raw();
1926
+ wasm.__wbg_wbg_rayon_poolbuilder_free(ptr, 0);
1927
+ }
1928
+ build() {
1929
+ wasm.wbg_rayon_poolbuilder_build(this.__wbg_ptr);
1930
+ }
1931
+ /**
1932
+ * @returns {number}
1933
+ */
1934
+ numThreads() {
1935
+ const ret = wasm.wbg_rayon_poolbuilder_numThreads(this.__wbg_ptr);
1936
+ return ret >>> 0;
1937
+ }
1938
+ /**
1939
+ * @returns {number}
1940
+ */
1941
+ receiver() {
1942
+ const ret = wasm.wbg_rayon_poolbuilder_receiver(this.__wbg_ptr);
1943
+ return ret >>> 0;
1944
+ }
1945
+ }
1946
+ if (Symbol.dispose) wbg_rayon_PoolBuilder.prototype[Symbol.dispose] = wbg_rayon_PoolBuilder.prototype.free;
1947
+
1948
+ /**
1949
+ * @param {number} receiver
1950
+ */
1951
+ export function wbg_rayon_start_worker(receiver) {
1952
+ wasm.wbg_rayon_start_worker(receiver);
1953
+ }
1954
+
1955
+ function __wbg_get_imports(memory) {
1956
+ const import0 = {
1957
+ __proto__: null,
1958
+ __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
1959
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1960
+ return ret;
1961
+ },
1962
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
1963
+ const ret = String(arg1);
1964
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1965
+ const len1 = WASM_VECTOR_LEN;
1966
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1967
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1968
+ },
1969
+ __wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
1970
+ const ret = typeof(arg0) === 'string';
1971
+ return ret;
1972
+ },
1973
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
1974
+ const ret = arg0 === undefined;
1975
+ return ret;
1976
+ },
1977
+ __wbg___wbindgen_memory_edb3f01e3930bbf6: function() {
1978
+ const ret = wasm.memory;
1979
+ return ret;
1980
+ },
1981
+ __wbg___wbindgen_module_bf945c07123bafe2: function() {
1982
+ const ret = wasmModule;
1983
+ return ret;
1984
+ },
1985
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
1986
+ throw new Error(getStringFromWasm0(arg0, arg1));
1987
+ },
1988
+ __wbg_get_3ef1eba1850ade27: function() { return handleError(function (arg0, arg1) {
1989
+ const ret = Reflect.get(arg0, arg1);
1990
+ return ret;
1991
+ }, arguments); },
1992
+ __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
1993
+ const ret = arg0[arg1 >>> 0];
1994
+ return ret;
1995
+ },
1996
+ __wbg_instanceof_Window_23e677d2c6843922: function(arg0) {
1997
+ let result;
1998
+ try {
1999
+ result = arg0 instanceof Window;
2000
+ } catch (_) {
2001
+ result = false;
2002
+ }
2003
+ const ret = result;
2004
+ return ret;
2005
+ },
2006
+ __wbg_new_49d5571bd3f0c4d4: function() {
2007
+ const ret = new Map();
2008
+ return ret;
2009
+ },
2010
+ __wbg_new_a70fbab9066b301f: function() {
2011
+ const ret = new Array();
2012
+ return ret;
2013
+ },
2014
+ __wbg_new_ab79df5bd7c26067: function() {
2015
+ const ret = new Object();
2016
+ return ret;
2017
+ },
2018
+ __wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
2019
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2020
+ return ret;
2021
+ },
2022
+ __wbg_new_from_slice_c62f8165d6102476: function(arg0, arg1) {
2023
+ const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
2024
+ return ret;
2025
+ },
2026
+ __wbg_new_from_slice_dddccc7a7dc2cc04: function(arg0, arg1) {
2027
+ const ret = new Uint16Array(getArrayU16FromWasm0(arg0, arg1));
2028
+ return ret;
2029
+ },
2030
+ __wbg_new_from_slice_ff2c15e8e05ffdfc: function(arg0, arg1) {
2031
+ const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
2032
+ return ret;
2033
+ },
2034
+ __wbg_now_16f0c993d5dd6c27: function() {
2035
+ const ret = Date.now();
2036
+ return ret;
2037
+ },
2038
+ __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
2039
+ arg0[arg1 >>> 0] = arg2;
2040
+ },
2041
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
2042
+ arg0[arg1] = arg2;
2043
+ },
2044
+ __wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
2045
+ const ret = Reflect.set(arg0, arg1, arg2);
2046
+ return ret;
2047
+ }, arguments); },
2048
+ __wbg_set_bf7251625df30a02: function(arg0, arg1, arg2) {
2049
+ const ret = arg0.set(arg1, arg2);
2050
+ return ret;
2051
+ },
2052
+ __wbg_startWorkers_8b582d57e92bd2d4: function(arg0, arg1, arg2) {
2053
+ const ret = startWorkers(arg0, arg1, wbg_rayon_PoolBuilder.__wrap(arg2));
2054
+ return ret;
2055
+ },
2056
+ __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
2057
+ const ret = typeof global === 'undefined' ? null : global;
2058
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2059
+ },
2060
+ __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
2061
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2062
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2063
+ },
2064
+ __wbg_static_accessor_SELF_f207c857566db248: function() {
2065
+ const ret = typeof self === 'undefined' ? null : self;
2066
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2067
+ },
2068
+ __wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
2069
+ const ret = typeof window === 'undefined' ? null : window;
2070
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2071
+ },
2072
+ __wbindgen_cast_0000000000000001: function(arg0) {
2073
+ // Cast intrinsic for `F64 -> Externref`.
2074
+ const ret = arg0;
2075
+ return ret;
2076
+ },
2077
+ __wbindgen_cast_0000000000000002: function(arg0) {
2078
+ // Cast intrinsic for `I64 -> Externref`.
2079
+ const ret = arg0;
2080
+ return ret;
2081
+ },
2082
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
2083
+ // Cast intrinsic for `Ref(String) -> Externref`.
2084
+ const ret = getStringFromWasm0(arg0, arg1);
2085
+ return ret;
2086
+ },
2087
+ __wbindgen_cast_0000000000000004: function(arg0) {
2088
+ // Cast intrinsic for `U64 -> Externref`.
2089
+ const ret = BigInt.asUintN(64, arg0);
2090
+ return ret;
2091
+ },
2092
+ __wbindgen_init_externref_table: function() {
2093
+ const table = wasm.__wbindgen_externrefs;
2094
+ const offset = table.grow(4);
2095
+ table.set(0, undefined);
2096
+ table.set(offset + 0, undefined);
2097
+ table.set(offset + 1, null);
2098
+ table.set(offset + 2, true);
2099
+ table.set(offset + 3, false);
2100
+ },
2101
+ memory: memory || new WebAssembly.Memory({initial:144,maximum:16384,shared:true}),
2102
+ };
2103
+ return {
2104
+ __proto__: null,
2105
+ "./oni_wasm_bg.js": import0,
2106
+ };
2107
+ }
2108
+
2109
+ const wbg_rayon_PoolBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
2110
+ ? { register: () => {}, unregister: () => {} }
2111
+ : new FinalizationRegistry(ptr => wasm.__wbg_wbg_rayon_poolbuilder_free(ptr >>> 0, 1));
2112
+
2113
+ function addToExternrefTable0(obj) {
2114
+ const idx = wasm.__externref_table_alloc();
2115
+ wasm.__wbindgen_externrefs.set(idx, obj);
2116
+ return idx;
2117
+ }
2118
+
2119
+ function getArrayF32FromWasm0(ptr, len) {
2120
+ ptr = ptr >>> 0;
2121
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
2122
+ }
2123
+
2124
+ function getArrayI32FromWasm0(ptr, len) {
2125
+ ptr = ptr >>> 0;
2126
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
2127
+ }
2128
+
2129
+ function getArrayU16FromWasm0(ptr, len) {
2130
+ ptr = ptr >>> 0;
2131
+ return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
2132
+ }
2133
+
2134
+ function getArrayU8FromWasm0(ptr, len) {
2135
+ ptr = ptr >>> 0;
2136
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2137
+ }
2138
+
2139
+ let cachedDataViewMemory0 = null;
2140
+ function getDataViewMemory0() {
2141
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
2142
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2143
+ }
2144
+ return cachedDataViewMemory0;
2145
+ }
2146
+
2147
+ let cachedFloat32ArrayMemory0 = null;
2148
+ function getFloat32ArrayMemory0() {
2149
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.buffer !== wasm.memory.buffer) {
2150
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
2151
+ }
2152
+ return cachedFloat32ArrayMemory0;
2153
+ }
2154
+
2155
+ let cachedInt32ArrayMemory0 = null;
2156
+ function getInt32ArrayMemory0() {
2157
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.buffer !== wasm.memory.buffer) {
2158
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
2159
+ }
2160
+ return cachedInt32ArrayMemory0;
2161
+ }
2162
+
2163
+ function getStringFromWasm0(ptr, len) {
2164
+ ptr = ptr >>> 0;
2165
+ return decodeText(ptr, len);
2166
+ }
2167
+
2168
+ let cachedUint16ArrayMemory0 = null;
2169
+ function getUint16ArrayMemory0() {
2170
+ if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.buffer !== wasm.memory.buffer) {
2171
+ cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
2172
+ }
2173
+ return cachedUint16ArrayMemory0;
2174
+ }
2175
+
2176
+ let cachedUint8ArrayMemory0 = null;
2177
+ function getUint8ArrayMemory0() {
2178
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.buffer !== wasm.memory.buffer) {
2179
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2180
+ }
2181
+ return cachedUint8ArrayMemory0;
2182
+ }
2183
+
2184
+ function handleError(f, args) {
2185
+ try {
2186
+ return f.apply(this, args);
2187
+ } catch (e) {
2188
+ const idx = addToExternrefTable0(e);
2189
+ wasm.__wbindgen_exn_store(idx);
2190
+ }
2191
+ }
2192
+
2193
+ function isLikeNone(x) {
2194
+ return x === undefined || x === null;
2195
+ }
2196
+
2197
+ function passStringToWasm0(arg, malloc, realloc) {
2198
+ if (realloc === undefined) {
2199
+ const buf = cachedTextEncoder.encode(arg);
2200
+ const ptr = malloc(buf.length, 1) >>> 0;
2201
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2202
+ WASM_VECTOR_LEN = buf.length;
2203
+ return ptr;
2204
+ }
2205
+
2206
+ let len = arg.length;
2207
+ let ptr = malloc(len, 1) >>> 0;
2208
+
2209
+ const mem = getUint8ArrayMemory0();
2210
+
2211
+ let offset = 0;
2212
+
2213
+ for (; offset < len; offset++) {
2214
+ const code = arg.charCodeAt(offset);
2215
+ if (code > 0x7F) break;
2216
+ mem[ptr + offset] = code;
2217
+ }
2218
+ if (offset !== len) {
2219
+ if (offset !== 0) {
2220
+ arg = arg.slice(offset);
2221
+ }
2222
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2223
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2224
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2225
+
2226
+ offset += ret.written;
2227
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2228
+ }
2229
+
2230
+ WASM_VECTOR_LEN = offset;
2231
+ return ptr;
2232
+ }
2233
+
2234
+ function takeFromExternrefTable0(idx) {
2235
+ const value = wasm.__wbindgen_externrefs.get(idx);
2236
+ wasm.__externref_table_dealloc(idx);
2237
+ return value;
2238
+ }
2239
+
2240
+ let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : undefined);
2241
+ if (cachedTextDecoder) cachedTextDecoder.decode();
2242
+
2243
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2244
+ let numBytesDecoded = 0;
2245
+ function decodeText(ptr, len) {
2246
+ numBytesDecoded += len;
2247
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2248
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2249
+ cachedTextDecoder.decode();
2250
+ numBytesDecoded = len;
2251
+ }
2252
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().slice(ptr, ptr + len));
2253
+ }
2254
+
2255
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder() : undefined);
2256
+
2257
+ if (cachedTextEncoder) {
2258
+ cachedTextEncoder.encodeInto = function (arg, view) {
2259
+ const buf = cachedTextEncoder.encode(arg);
2260
+ view.set(buf);
2261
+ return {
2262
+ read: arg.length,
2263
+ written: buf.length
2264
+ };
2265
+ };
2266
+ }
2267
+
2268
+ let WASM_VECTOR_LEN = 0;
2269
+
2270
+ let wasmModule, wasm;
2271
+ function __wbg_finalize_init(instance, module, thread_stack_size) {
2272
+ wasm = instance.exports;
2273
+ wasmModule = module;
2274
+ cachedDataViewMemory0 = null;
2275
+ cachedFloat32ArrayMemory0 = null;
2276
+ cachedInt32ArrayMemory0 = null;
2277
+ cachedUint16ArrayMemory0 = null;
2278
+ cachedUint8ArrayMemory0 = null;
2279
+ if (typeof thread_stack_size !== 'undefined' && (typeof thread_stack_size !== 'number' || thread_stack_size === 0 || thread_stack_size % 65536 !== 0)) {
2280
+ throw new Error('invalid stack size');
2281
+ }
2282
+
2283
+ wasm.__wbindgen_start(thread_stack_size);
2284
+ return wasm;
2285
+ }
2286
+
2287
+ async function __wbg_load(module, imports) {
2288
+ if (typeof Response === 'function' && module instanceof Response) {
2289
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2290
+ try {
2291
+ return await WebAssembly.instantiateStreaming(module, imports);
2292
+ } catch (e) {
2293
+ const validResponse = module.ok && expectedResponseType(module.type);
2294
+
2295
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2296
+ 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);
2297
+
2298
+ } else { throw e; }
2299
+ }
2300
+ }
2301
+
2302
+ const bytes = await module.arrayBuffer();
2303
+ return await WebAssembly.instantiate(bytes, imports);
2304
+ } else {
2305
+ const instance = await WebAssembly.instantiate(module, imports);
2306
+
2307
+ if (instance instanceof WebAssembly.Instance) {
2308
+ return { instance, module };
2309
+ } else {
2310
+ return instance;
2311
+ }
2312
+ }
2313
+
2314
+ function expectedResponseType(type) {
2315
+ switch (type) {
2316
+ case 'basic': case 'cors': case 'default': return true;
2317
+ }
2318
+ return false;
2319
+ }
2320
+ }
2321
+
2322
+ function initSync(module, memory) {
2323
+ if (wasm !== undefined) return wasm;
2324
+
2325
+ let thread_stack_size
2326
+ if (module !== undefined) {
2327
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2328
+ ({module, memory, thread_stack_size} = module)
2329
+ } else {
2330
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2331
+ }
2332
+ }
2333
+
2334
+ const imports = __wbg_get_imports(memory);
2335
+ if (!(module instanceof WebAssembly.Module)) {
2336
+ module = new WebAssembly.Module(module);
2337
+ }
2338
+ const instance = new WebAssembly.Instance(module, imports);
2339
+ return __wbg_finalize_init(instance, module, thread_stack_size);
2340
+ }
2341
+
2342
+ async function __wbg_init(module_or_path, memory) {
2343
+ if (wasm !== undefined) return wasm;
2344
+
2345
+ let thread_stack_size
2346
+ if (module_or_path !== undefined) {
2347
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2348
+ ({module_or_path, memory, thread_stack_size} = module_or_path)
2349
+ } else {
2350
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2351
+ }
2352
+ }
2353
+
2354
+ if (module_or_path === undefined) {
2355
+ module_or_path = new URL('oni_wasm_bg.wasm', import.meta.url);
2356
+ }
2357
+ const imports = __wbg_get_imports(memory);
2358
+
2359
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2360
+ module_or_path = fetch(module_or_path);
2361
+ }
2362
+
2363
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2364
+
2365
+ return __wbg_finalize_init(instance, module, thread_stack_size);
2366
+ }
2367
+
2368
+ export { initSync, __wbg_init as default };