@onimaxxing/worldgen-node 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.
package/oni_wasm.d.ts ADDED
@@ -0,0 +1,274 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Drop the cached cluster. Snapshot edits persist.
6
+ */
7
+ export function clear_cluster_cache(): void;
8
+
9
+ /**
10
+ * Evaluate a noise tree over a `width × height` 2D grid and return
11
+ * one `f32` per cell, row-major (`y * width + x`). Values are
12
+ * unnormalised; the consumer applies any colour ramp.
13
+ *
14
+ * `tree_kind`:
15
+ * - `"named"`: look up `tree_value` in the live `SettingsCache.noise`
16
+ * map (the same map the editor mutates).
17
+ * - `"inline"`: parse `tree_value` as a YAML document in isolation.
18
+ *
19
+ * Output is bit-identical to the engine's own evaluation at the
20
+ * given seed. Sample coords map `width × height` linearly onto the
21
+ * tree's `settings.lowerBound..upperBound` rectangle (cell-centred),
22
+ * at `z = 0` (worldgen samples the XZ plane at y = 0).
23
+ */
24
+ export function evaluate_noise(tree_kind: string, tree_value: string, width: number, height: number, seed: number): Float32Array;
25
+
26
+ /**
27
+ * The ONI game build this WASM was parity-baselined against (e.g.
28
+ * `"737195"`).
29
+ */
30
+ export function game_version(): string;
31
+
32
+ /**
33
+ * Generate a cluster by cluster id + seed. Returns a `ClusterResult`
34
+ * JSON envelope. For the coordinate-string form (story traits +
35
+ * mixing) use `generate_from_coordinate`.
36
+ */
37
+ export function generate_cluster(seed: number, cluster_id: string): string;
38
+
39
+ /**
40
+ * Generate all worlds in a cluster and return per-cell polygon data for each.
41
+ *
42
+ * Returns JSON: `{ "cluster_id", "seed", "worlds": [{ "name", "width", "height", "is_starting", "cells": [...] }] }`
43
+ */
44
+ export function generate_cluster_cells(seed: number, cluster_id: string): string;
45
+
46
+ /**
47
+ * Generate a cluster with provided cluster YAML config override.
48
+ */
49
+ export function generate_cluster_with_configs(seed: number, cluster_id: string, cluster_yaml: string, _world_yamls: string): string;
50
+
51
+ /**
52
+ * Generate a cluster from a game coordinate string (e.g.
53
+ * `"SNDST-A-42-0-4A-MUWF1"`). Returns a `ClusterResult` JSON
54
+ * envelope; for the typed-array `MapData` shape use
55
+ * `generate_map_data`.
56
+ */
57
+ export function generate_from_coordinate(coordinate: string): string;
58
+
59
+ /**
60
+ * Generate the layout for a cluster's starting world and return
61
+ * per-cell data as JSON: `{ cells: [{ site_id, x, y, type }, ...] }`.
62
+ * Used for cell-level comparison against C# reference snapshots.
63
+ */
64
+ export function generate_layout_cells(seed: number, cluster_id: string): string;
65
+
66
+ /**
67
+ * Generate a cluster from a game coordinate and return a `MapData`
68
+ * value: per-world element grids, biome cell polygons, entity spawns,
69
+ * and starmap locations. Caches the cluster for the two-phase API
70
+ * (`settle_cluster_advance`, `get_entity_spawners`).
71
+ *
72
+ * Per-cell grids ship as typed arrays (`Uint16Array`, `Float32Array`,
73
+ * etc.) on `JsValue` so JS consumers don't pay a JSON parse.
74
+ */
75
+ export function generate_map_data(coordinate: string): any;
76
+
77
+ /**
78
+ * Re-run ambient mob spawning against the cached cluster's current
79
+ * cell state and return the refreshed entity lists. Call after
80
+ * `settle_cluster_advance` chunks when settled liquid/gas flow may
81
+ * have invalidated earlier mob placements. Requires a prior
82
+ * `generate_map_data`. Template-placed entities (geysers, oil wells,
83
+ * props) persist across calls.
84
+ */
85
+ export function get_entity_spawners(): string;
86
+
87
+ /**
88
+ * Returns a JSON-encoded `NoiseNodeKindSpec[]` enumerating every
89
+ * noise node variant the engine recognises (primitives, filters,
90
+ * modifiers, transformers, selectors, combiners) plus its param
91
+ * schema. Static across the lifetime of the build.
92
+ */
93
+ export function noise_node_kinds(): string;
94
+
95
+ /**
96
+ * Toggle template placement. WASM-side counterpart of the native
97
+ * `SKIP_TEMPLATES` env var.
98
+ */
99
+ export function set_skip_templates(skip: boolean): void;
100
+
101
+ /**
102
+ * Drop both the SettingsCache and the cluster cache. The next
103
+ * `generate_*` call reloads the embedded stock defaults.
104
+ */
105
+ export function settings_reset(): void;
106
+
107
+ /**
108
+ * Advance the cached cluster's settle sim to `target_tick` and
109
+ * return a binary snapshot at that tick covering every world. Call
110
+ * repeatedly with increasing ticks to paint intermediate frames;
111
+ * `target_tick = 499` finalises the cluster.
112
+ *
113
+ * `target_tick` must be in `1..=499`. A tick `<=` the current cached
114
+ * tick re-emits the current frame. Returns an empty buffer on
115
+ * out-of-range tick or empty/stale cache; call `generate_map_data`
116
+ * first to populate.
117
+ *
118
+ * Binary format (all little-endian, v5):
119
+ * - `u32` version tag (= 5)
120
+ * - `u32` tick
121
+ * - `u32` world count
122
+ * - per world: `u32` width, `u32` height, then `width * height`
123
+ * cells of 25 bytes each: `u16 elem, f32 mass, f32 temp, u8 dis,
124
+ * i32 dis_count, u16 bw_elem, f32 bw_mass, f32 bw_temp`. Worlds
125
+ * without `backwallNoise` emit Vacuum + 0 mass + 0 temp.
126
+ */
127
+ export function settle_cluster_advance(target_tick: number): Uint8Array;
128
+
129
+ /**
130
+ * Drain the in-memory log buffer for `channel` (e.g. `"ppc_prng"`).
131
+ * WASM-side stand-in for native diag sites that would write to
132
+ * `std::fs::*`.
133
+ */
134
+ export function sim_env_drain_log(channel: string): string;
135
+
136
+ /**
137
+ * Set a `(key, value)` in the cross-target env overlay read by
138
+ * `oni_sim::sim_env::var`. WASM-side stand-in for the `SIM_*_PATH` /
139
+ * `SIM_*_TICK` env vars used by native diag sites.
140
+ */
141
+ export function sim_env_set(key: string, value: string): void;
142
+
143
+ /**
144
+ * Stable hex hash of a snapshot JSON. Alias of
145
+ * `snapshot_checksum_canonical`; same content always hashes to the
146
+ * same value regardless of HashMap/IndexMap iteration order.
147
+ */
148
+ export function snapshot_checksum(snapshot_json: string): string;
149
+
150
+ /**
151
+ * Byte-hash variant: FNV-1a-64 over the raw input bytes. Weak
152
+ * contract; same logical content with different HashMap/IndexMap
153
+ * iteration orders produces different hashes. Only safe when the
154
+ * consumer caches the exact bytes it hashed.
155
+ */
156
+ export function snapshot_checksum_bytes(snapshot_json: string): string;
157
+
158
+ /**
159
+ * Canonical-form variant: parses to a `serde_json::Value` (sorted
160
+ * keys at every level), then FNV-1a-64 with type tags + length
161
+ * prefixes. Same logical content always produces the same hash;
162
+ * what `snapshot_checksum` (the default) and `snapshot_state_checksum`
163
+ * route through.
164
+ */
165
+ export function snapshot_checksum_canonical(snapshot_json: string): string;
166
+
167
+ /**
168
+ * Build a `WorldgenSnapshot` from a `{path: JSON-string}` files map,
169
+ * apply it to SETTINGS, and return the resulting snapshot JSON.
170
+ * Strict mode.
171
+ */
172
+ export function snapshot_from_files(files_json: string): string;
173
+
174
+ /**
175
+ * Extensions-mode counterpart of `snapshot_from_files`.
176
+ */
177
+ export function snapshot_from_files_extensions(files_json: string): string;
178
+
179
+ /**
180
+ * Reset SETTINGS to the embedded U59 vanilla baseline and return the
181
+ * vanilla snapshot as a JSON string. Strict mode.
182
+ */
183
+ export function snapshot_load_vanilla(): string;
184
+
185
+ /**
186
+ * Extensions-mode counterpart of `snapshot_load_vanilla`. Subsequent
187
+ * `merge_files` calls accept mod-defined enum extensions.
188
+ */
189
+ export function snapshot_load_vanilla_extensions(): string;
190
+
191
+ /**
192
+ * Merge a `{path: JSON-string}` files map into an existing snapshot
193
+ * JSON. Last-wins on duplicate paths. Applies the merged snapshot to
194
+ * SETTINGS as a side effect.
195
+ */
196
+ export function snapshot_merge_files(snapshot_json: string, files_json: string): string;
197
+
198
+ /**
199
+ * Drop `paths_json` (a JSON array of path strings) from a snapshot
200
+ * JSON, apply the result to SETTINGS, and return the updated
201
+ * snapshot JSON. Paths not present are silently ignored; mode and
202
+ * element overrides are preserved.
203
+ */
204
+ export function snapshot_remove_paths(snapshot_json: string, paths_json: string): string;
205
+
206
+ /**
207
+ * Stable hex hash of the resident snapshot. Same content produces
208
+ * the same hash regardless of HashMap/IndexMap iteration order or
209
+ * load history. Auto-loads vanilla if empty.
210
+ */
211
+ export function snapshot_state_checksum(): string;
212
+
213
+ /**
214
+ * Drop the listed paths from the resident snapshot. `paths_json` is
215
+ * a JSON array of path strings; paths not present are silently
216
+ * ignored.
217
+ */
218
+ export function snapshot_state_drop_paths(paths_json: string): number;
219
+
220
+ /**
221
+ * Return the resident snapshot as a JSON-encoded
222
+ * `{path: JSON-string}` files map. Auto-loads vanilla if empty.
223
+ */
224
+ export function snapshot_state_files(): string;
225
+
226
+ /**
227
+ * Replace the resident snapshot from a `{path: JSON-string}` files
228
+ * map. Strict; atomic. Throws and leaves the snapshot untouched on
229
+ * invalid input.
230
+ */
231
+ export function snapshot_state_load(files_json: string): number;
232
+
233
+ /**
234
+ * Extensions-mode counterpart of `snapshot_state_load`. Subsequent
235
+ * merges inherit the Extensions mode from the loaded snapshot.
236
+ */
237
+ export function snapshot_state_load_extensions(files_json: string): number;
238
+
239
+ /**
240
+ * Merge a `{path: JSON-string}` files map into the resident snapshot.
241
+ * Last-wins on duplicate paths. Auto-loads vanilla if empty; atomic
242
+ * on parse failure. Mode is inherited from the resident snapshot.
243
+ */
244
+ export function snapshot_state_merge(files_json: string): number;
245
+
246
+ /**
247
+ * Clear the resident snapshot and bump the version. The next
248
+ * `snapshot_state_*` call auto-loads vanilla.
249
+ */
250
+ export function snapshot_state_reset(): void;
251
+
252
+ /**
253
+ * Reset the resident snapshot to the embedded vanilla baseline.
254
+ * Strict mode.
255
+ */
256
+ export function snapshot_state_vanilla(): number;
257
+
258
+ /**
259
+ * Same as `snapshot_state_vanilla`, Extensions mode. Subsequent
260
+ * merges accept mod-defined enum extensions.
261
+ */
262
+ export function snapshot_state_vanilla_extensions(): number;
263
+
264
+ /**
265
+ * Monotonic mutation counter. Bumps on every successful mutation;
266
+ * 0 if the slot has never been touched.
267
+ */
268
+ export function snapshot_state_version(): number;
269
+
270
+ /**
271
+ * Convert a snapshot JSON into a `{path: JSON-string}` files map.
272
+ * Round-trips back through `snapshot_from_files`.
273
+ */
274
+ export function snapshot_to_files(snapshot_json: string): string;