@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.
- package/README.md +442 -0
- package/editor_settings.d.ts +1034 -0
- package/index.d.ts +682 -0
- package/index.js +286 -0
- package/package.json +35 -0
- package/parallel/LICENSE +21 -0
- package/parallel/index.js +13 -0
- package/parallel/oni_wasm.d.ts +852 -0
- package/parallel/oni_wasm.js +2368 -0
- package/parallel/oni_wasm_bg.wasm +0 -0
- package/parallel/oni_wasm_bg.wasm.d.ts +99 -0
- package/parallel/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js +107 -0
- package/serial/LICENSE +21 -0
- package/serial/oni_wasm.d.ts +346 -0
- package/serial/oni_wasm.js +1109 -0
- package/serial/oni_wasm_bg.wasm +0 -0
- package/serial/oni_wasm_bg.wasm.d.ts +47 -0
- package/yaml.d.ts +19 -0
- package/yaml.js +97 -0
|
Binary file
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const evaluate_noise: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
5
|
+
export const game_version: () => [number, number];
|
|
6
|
+
export const generate_cluster: (a: number, b: number, c: number) => [number, number];
|
|
7
|
+
export const generate_cluster_cells: (a: number, b: number, c: number) => [number, number];
|
|
8
|
+
export const generate_cluster_with_configs: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
9
|
+
export const generate_from_coordinate: (a: number, b: number) => [number, number];
|
|
10
|
+
export const generate_layout_cells: (a: number, b: number, c: number) => [number, number];
|
|
11
|
+
export const generate_map_data: (a: number, b: number) => any;
|
|
12
|
+
export const get_entity_spawners: () => [number, number];
|
|
13
|
+
export const noise_node_kinds: () => [number, number];
|
|
14
|
+
export const set_skip_templates: (a: number) => void;
|
|
15
|
+
export const settings_reset: () => void;
|
|
16
|
+
export const settle_cluster_advance: (a: number) => [number, number];
|
|
17
|
+
export const sim_env_drain_log: (a: number, b: number) => [number, number];
|
|
18
|
+
export const sim_env_set: (a: number, b: number, c: number, d: number) => void;
|
|
19
|
+
export const snapshot_checksum: (a: number, b: number) => [number, number, number, number];
|
|
20
|
+
export const snapshot_checksum_bytes: (a: number, b: number) => [number, number];
|
|
21
|
+
export const snapshot_from_files: (a: number, b: number) => [number, number, number, number];
|
|
22
|
+
export const snapshot_from_files_extensions: (a: number, b: number) => [number, number, number, number];
|
|
23
|
+
export const snapshot_load_vanilla: () => [number, number, number, number];
|
|
24
|
+
export const snapshot_load_vanilla_extensions: () => [number, number, number, number];
|
|
25
|
+
export const snapshot_merge_files: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
26
|
+
export const snapshot_remove_paths: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
27
|
+
export const snapshot_state_checksum: () => [number, number, number, number];
|
|
28
|
+
export const snapshot_state_drop_paths: (a: number, b: number) => [number, number, number];
|
|
29
|
+
export const snapshot_state_files: () => [number, number, number, number];
|
|
30
|
+
export const snapshot_state_load: (a: number, b: number) => [number, number, number];
|
|
31
|
+
export const snapshot_state_load_extensions: (a: number, b: number) => [number, number, number];
|
|
32
|
+
export const snapshot_state_merge: (a: number, b: number) => [number, number, number];
|
|
33
|
+
export const snapshot_state_reset: () => void;
|
|
34
|
+
export const snapshot_state_vanilla: () => number;
|
|
35
|
+
export const snapshot_state_vanilla_extensions: () => number;
|
|
36
|
+
export const snapshot_to_files: (a: number, b: number) => [number, number, number, number];
|
|
37
|
+
export const snapshot_checksum_canonical: (a: number, b: number) => [number, number, number, number];
|
|
38
|
+
export const clear_cluster_cache: () => void;
|
|
39
|
+
export const snapshot_state_version: () => number;
|
|
40
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
41
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
42
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
43
|
+
export const __externref_table_alloc: () => number;
|
|
44
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
45
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
46
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
47
|
+
export const __wbindgen_start: () => void;
|
package/yaml.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Type declaration for the Klei-faithful YAML parser. Mirrors
|
|
2
|
+
// `yaml.js` in the same directory. Consumers can also import
|
|
3
|
+
// `parseKleiYaml` directly from the package root (re-exported by
|
|
4
|
+
// `index.{js,cjs}`).
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parse a YAML string the way Klei (YamlDotNet) would:
|
|
8
|
+
*
|
|
9
|
+
* 1. Tabs are pre-expanded to 4 spaces (Klei's `readText.Replace`).
|
|
10
|
+
* 2. YAML 1.1 boolean sentinels (`yes/no/on/off`) on plain scalars
|
|
11
|
+
* become booleans; quoted forms stay as strings.
|
|
12
|
+
* 3. Duplicate mapping keys: last-wins.
|
|
13
|
+
* 4. Unknown YAML tags are silently stripped.
|
|
14
|
+
* 5. Null mapping values are dropped recursively (Klei's reflection-
|
|
15
|
+
* based loader treats `key:` as "field not present").
|
|
16
|
+
*
|
|
17
|
+
* Returns a plain JS object/array/scalar suitable for JSON.stringify.
|
|
18
|
+
*/
|
|
19
|
+
export function parseKleiYaml(text: string): unknown;
|
package/yaml.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Klei-faithful YAML parser. The single canonical implementation
|
|
2
|
+
// for both `scripts/yaml_to_json.mjs` (the batch CLI) and the
|
|
3
|
+
// published worldgen wrapper (re-exports `parseKleiYaml` from
|
|
4
|
+
// `index.{js,cjs}`).
|
|
5
|
+
//
|
|
6
|
+
// WASM stays JSON-only — every consumer that ingests a Klei `.yaml`
|
|
7
|
+
// file goes through this function first, then hands the resulting
|
|
8
|
+
// JSON to `worldgen.snapshot.load` / `merge`.
|
|
9
|
+
//
|
|
10
|
+
// Klei (YamlDotNet) compatibility — what we mimic via the schema/
|
|
11
|
+
// options below, matching the decompiled `Klei.YamlIO.Parse`:
|
|
12
|
+
//
|
|
13
|
+
// (1) Tab → 4-space preprocessing. Klei runs `readText.Replace(
|
|
14
|
+
// "\t", " ")` unconditionally before YamlDotNet. The YAML
|
|
15
|
+
// spec rejects tab indentation; mod authors use tabs constantly.
|
|
16
|
+
// (2) YAML 1.1 boolean sentinels (`yes/no/on/off`) as PLAIN scalars
|
|
17
|
+
// become booleans. Quoted forms ("yes") stay as strings.
|
|
18
|
+
// (3) Duplicate mapping keys: last-wins. js-yaml >=4 throws on
|
|
19
|
+
// duplicate keys unless `json: true` is passed; we opt in to
|
|
20
|
+
// that mode so YamlDotNet-style "last-wins" semantics carry
|
|
21
|
+
// through (mods like Baator ship feature/noise YAMLs with
|
|
22
|
+
// duplicated `source0:` / `add:` keys that YamlDotNet accepts
|
|
23
|
+
// silently).
|
|
24
|
+
// (4) Unknown YAML tags (`!Foo value`) silently stripped.
|
|
25
|
+
// (5) `key:` with null value: strip the key recursively so missing
|
|
26
|
+
// scalars stay at their default and missing lists become
|
|
27
|
+
// empty — serde rejects explicit `null` for non-Option types.
|
|
28
|
+
|
|
29
|
+
import yaml from 'js-yaml';
|
|
30
|
+
|
|
31
|
+
const KleiBool = new yaml.Type('tag:yaml.org,2002:bool', {
|
|
32
|
+
kind: 'scalar',
|
|
33
|
+
// Single-letter `y`/`n` are intentionally EXCLUDED: many files
|
|
34
|
+
// have keys like `X: 64, Y: 96` (Vec2/Vec3 components). js-yaml's
|
|
35
|
+
// resolvers run uniformly in key and value position, so accepting
|
|
36
|
+
// `y`/`Y` here would coerce `Y:` keys to literal `true:` and lose
|
|
37
|
+
// the data.
|
|
38
|
+
resolve: (data) => typeof data === 'string'
|
|
39
|
+
&& /^(yes|no|on|off|true|false)$/i.test(data),
|
|
40
|
+
construct: (data) => /^(yes|on|true)$/i.test(data),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// IMPORTANT: use `{ implicit: [...] }`, NOT a bare array. The bare
|
|
44
|
+
// form APPENDS — `string` (catch-all) matches "yes" first, so KleiBool
|
|
45
|
+
// never runs. Implicit-prepend wins.
|
|
46
|
+
//
|
|
47
|
+
// We do NOT register a custom Float Type here. js-yaml keys Types by
|
|
48
|
+
// (tag, kind), so an extension with the same `tag:yaml.org,2002:float`
|
|
49
|
+
// REPLACES the default float resolver entirely — we accidentally
|
|
50
|
+
// broke parsing of standard `0.4`/`1.5` floats this way once. The
|
|
51
|
+
// leading-dot-without-zero form (`.2`, `-.2`) that C# accepts but
|
|
52
|
+
// js-yaml emits as a string is handled in `coerceNumericStrings`
|
|
53
|
+
// below, which post-processes the parsed tree.
|
|
54
|
+
const KleiSchema = yaml.DEFAULT_SCHEMA.extend({ implicit: [KleiBool] });
|
|
55
|
+
|
|
56
|
+
/** Match strings of the form `.5`, `-.5`, `+.5`, with optional
|
|
57
|
+
* scientific exponent. Standard floats like `0.5` already become JS
|
|
58
|
+
* numbers via js-yaml's built-in resolver — only the leading-dot
|
|
59
|
+
* form needs this post-pass.
|
|
60
|
+
* See `worldgen/traits/MisalignedStart.yaml` (`min: -.2 / max: .2`)
|
|
61
|
+
* for an example shipped by Klei. */
|
|
62
|
+
const LEADING_DOT_FLOAT = /^[-+]?\.[0-9]+(?:[eE][-+]?[0-9]+)?$/;
|
|
63
|
+
|
|
64
|
+
/** Parse a YAML string the way Klei (YamlDotNet) would. Returns a
|
|
65
|
+
* plain JS object/array/scalar suitable for JSON.stringify. */
|
|
66
|
+
export function parseKleiYaml(text) {
|
|
67
|
+
const preprocessed = text.replace(/\t/g, ' ');
|
|
68
|
+
const raw = yaml.load(preprocessed, { schema: KleiSchema, json: true });
|
|
69
|
+
return stripNulls(raw);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function stripNulls(node) {
|
|
73
|
+
if (node === null || node === undefined) return undefined;
|
|
74
|
+
if (Array.isArray(node)) {
|
|
75
|
+
const out = [];
|
|
76
|
+
for (const v of node) {
|
|
77
|
+
const stripped = stripNulls(v);
|
|
78
|
+
if (stripped !== undefined) out.push(stripped);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
if (typeof node === 'object') {
|
|
83
|
+
const out = {};
|
|
84
|
+
for (const [k, v] of Object.entries(node)) {
|
|
85
|
+
const stripped = stripNulls(v);
|
|
86
|
+
if (stripped !== undefined) out[k] = stripped;
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
// Coerce leading-dot floats (`.5`, `-.5`) to JS numbers. Standard
|
|
91
|
+
// floats arrive as numbers already; this branch only catches
|
|
92
|
+
// strings that LOOK like floats but failed the default resolver.
|
|
93
|
+
if (typeof node === 'string' && LEADING_DOT_FLOAT.test(node)) {
|
|
94
|
+
return parseFloat(node);
|
|
95
|
+
}
|
|
96
|
+
return node;
|
|
97
|
+
}
|