@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.
Binary file
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@onimaxxing/worldgen-node",
3
+ "description": "WASM entry point for ONI worldgen",
4
+ "version": "0.15.0",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/tigin-backwards/help-i-want-to-customize-my-oxygen-not-included-worldgen.git"
9
+ },
10
+ "files": [
11
+ "index.cjs",
12
+ "yaml.cjs",
13
+ "index.d.ts",
14
+ "yaml.d.ts",
15
+ "editor_settings.d.ts",
16
+ "README.md",
17
+ "oni_wasm.js",
18
+ "oni_wasm.d.ts",
19
+ "oni_wasm_bg.wasm"
20
+ ],
21
+ "main": "index.cjs",
22
+ "types": "index.d.ts",
23
+ "dependencies": {
24
+ "js-yaml": "^4.1.0"
25
+ },
26
+ "publishConfig": {
27
+ "registry": "https://registry.npmjs.org/",
28
+ "access": "public"
29
+ }
30
+ }
package/yaml.cjs ADDED
@@ -0,0 +1,44 @@
1
+ // CommonJS variant of yaml.js. The published wrapper ships one or
2
+ // the other depending on `--target` (web → yaml.js, nodejs →
3
+ // yaml.cjs). The logic is identical; only the module syntax differs.
4
+ // See yaml.js for the full Klei-compatibility commentary.
5
+
6
+ const yaml = require('js-yaml');
7
+
8
+ const KleiBool = new yaml.Type('tag:yaml.org,2002:bool', {
9
+ kind: 'scalar',
10
+ resolve: (data) => typeof data === 'string'
11
+ && /^(yes|no|on|off|true|false)$/i.test(data),
12
+ construct: (data) => /^(yes|on|true)$/i.test(data),
13
+ });
14
+
15
+ const KleiSchema = yaml.DEFAULT_SCHEMA.extend({ implicit: [KleiBool] });
16
+
17
+ function parseKleiYaml(text) {
18
+ const preprocessed = text.replace(/\t/g, ' ');
19
+ const raw = yaml.load(preprocessed, { schema: KleiSchema });
20
+ return stripNulls(raw);
21
+ }
22
+
23
+ function stripNulls(node) {
24
+ if (node === null || node === undefined) return undefined;
25
+ if (Array.isArray(node)) {
26
+ const out = [];
27
+ for (const v of node) {
28
+ const stripped = stripNulls(v);
29
+ if (stripped !== undefined) out.push(stripped);
30
+ }
31
+ return out;
32
+ }
33
+ if (typeof node === 'object') {
34
+ const out = {};
35
+ for (const [k, v] of Object.entries(node)) {
36
+ const stripped = stripNulls(v);
37
+ if (stripped !== undefined) out[k] = stripped;
38
+ }
39
+ return out;
40
+ }
41
+ return node;
42
+ }
43
+
44
+ module.exports = { parseKleiYaml };
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;