nucleation 0.2.17 → 0.3.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.
Files changed (125) hide show
  1. package/Autostack.d.ts +43 -0
  2. package/Autostack.mjs +134 -0
  3. package/BlockPos.d.ts +28 -0
  4. package/BlockPos.mjs +129 -0
  5. package/BlockState.d.ts +39 -0
  6. package/BlockState.mjs +134 -0
  7. package/Brush.d.ts +59 -0
  8. package/Brush.mjs +203 -0
  9. package/BuildingTool.d.ts +29 -0
  10. package/BuildingTool.mjs +74 -0
  11. package/ChunkMeshResult.d.ts +75 -0
  12. package/ChunkMeshResult.mjs +253 -0
  13. package/CircuitBuilder.d.ts +118 -0
  14. package/CircuitBuilder.mjs +516 -0
  15. package/DefinitionRegion.d.ts +274 -0
  16. package/DefinitionRegion.mjs +973 -0
  17. package/Diff.d.ts +88 -0
  18. package/Diff.mjs +316 -0
  19. package/Dimensions.d.ts +28 -0
  20. package/Dimensions.mjs +129 -0
  21. package/ExecutionMode.d.ts +42 -0
  22. package/ExecutionMode.mjs +127 -0
  23. package/Fingerprint.d.ts +44 -0
  24. package/Fingerprint.mjs +197 -0
  25. package/InterpolationSpace.d.ts +25 -0
  26. package/InterpolationSpace.mjs +73 -0
  27. package/IoLayout.d.ts +26 -0
  28. package/IoLayout.mjs +81 -0
  29. package/IoLayoutBuilder.d.ts +73 -0
  30. package/IoLayoutBuilder.mjs +315 -0
  31. package/IoType.d.ts +41 -0
  32. package/IoType.mjs +125 -0
  33. package/ItemModelConfig.d.ts +65 -0
  34. package/ItemModelConfig.mjs +223 -0
  35. package/ItemModelPackBuilder.d.ts +32 -0
  36. package/ItemModelPackBuilder.mjs +104 -0
  37. package/ItemModelResult.d.ts +72 -0
  38. package/ItemModelResult.mjs +268 -0
  39. package/ItemScale.d.ts +31 -0
  40. package/ItemScale.mjs +132 -0
  41. package/LayoutFunction.d.ts +52 -0
  42. package/LayoutFunction.mjs +159 -0
  43. package/MchprsWorld.d.ts +131 -0
  44. package/MchprsWorld.mjs +423 -0
  45. package/MeshBounds.d.ts +40 -0
  46. package/MeshBounds.mjs +180 -0
  47. package/MeshConfig.d.ts +101 -0
  48. package/MeshConfig.mjs +306 -0
  49. package/MeshJob.d.ts +44 -0
  50. package/MeshJob.mjs +116 -0
  51. package/MeshPhase.d.ts +38 -0
  52. package/MeshPhase.mjs +90 -0
  53. package/MeshProgress.d.ts +32 -0
  54. package/MeshProgress.mjs +133 -0
  55. package/MeshResult.d.ts +60 -0
  56. package/MeshResult.mjs +206 -0
  57. package/MultiMeshResult.d.ts +50 -0
  58. package/MultiMeshResult.mjs +166 -0
  59. package/Nbt.d.ts +50 -0
  60. package/Nbt.mjs +161 -0
  61. package/NucleationError.d.ts +36 -0
  62. package/NucleationError.mjs +104 -0
  63. package/OutputCondition.d.ts +45 -0
  64. package/OutputCondition.mjs +129 -0
  65. package/README.md +28 -196
  66. package/RawMeshExport.d.ts +74 -0
  67. package/RawMeshExport.mjs +243 -0
  68. package/RedstoneGraph.d.ts +58 -0
  69. package/RedstoneGraph.mjs +242 -0
  70. package/RegionBounds.d.ts +41 -0
  71. package/RegionBounds.mjs +181 -0
  72. package/RenderConfig.d.ts +66 -0
  73. package/RenderConfig.mjs +170 -0
  74. package/Renderer.d.ts +35 -0
  75. package/Renderer.mjs +139 -0
  76. package/ResourcePack.d.ts +105 -0
  77. package/ResourcePack.mjs +447 -0
  78. package/ResourcePackList.d.ts +32 -0
  79. package/ResourcePackList.mjs +96 -0
  80. package/Schematic.d.ts +655 -0
  81. package/Schematic.mjs +2647 -0
  82. package/SchematicBuilder.d.ts +103 -0
  83. package/SchematicBuilder.mjs +401 -0
  84. package/SchematicRegions.d.ts +93 -0
  85. package/SchematicRegions.mjs +411 -0
  86. package/Scripting.d.ts +40 -0
  87. package/Scripting.mjs +138 -0
  88. package/Sdf.d.ts +31 -0
  89. package/Sdf.mjs +107 -0
  90. package/Shape.d.ts +108 -0
  91. package/Shape.mjs +336 -0
  92. package/SortStrategy.d.ts +86 -0
  93. package/SortStrategy.mjs +272 -0
  94. package/Store.d.ts +83 -0
  95. package/Store.mjs +369 -0
  96. package/StoreIo.d.ts +71 -0
  97. package/StoreIo.mjs +292 -0
  98. package/TextureAtlas.d.ts +40 -0
  99. package/TextureAtlas.mjs +122 -0
  100. package/TextureInfo.d.ts +34 -0
  101. package/TextureInfo.mjs +148 -0
  102. package/TypedCircuitExecutor.d.ts +101 -0
  103. package/TypedCircuitExecutor.mjs +378 -0
  104. package/Value.d.ts +73 -0
  105. package/Value.mjs +275 -0
  106. package/WorldChunkView.d.ts +63 -0
  107. package/WorldChunkView.mjs +201 -0
  108. package/WorldSink.d.ts +50 -0
  109. package/WorldSink.mjs +177 -0
  110. package/WorldStream.d.ts +45 -0
  111. package/WorldStream.mjs +184 -0
  112. package/diplomat-runtime.d.ts +15 -0
  113. package/diplomat-runtime.mjs +774 -0
  114. package/diplomat-wasm.mjs +52 -0
  115. package/diplomat.config.mjs +6 -0
  116. package/index.d.ts +113 -0
  117. package/index.mjs +116 -0
  118. package/{nucleation_bg.wasm → nucleation.wasm} +0 -0
  119. package/package.json +19 -41
  120. package/LICENSE +0 -21
  121. package/api.js +0 -608
  122. package/nucleation-cdn-loader.js +0 -15
  123. package/nucleation-original.js +0 -8383
  124. package/nucleation.d.ts +0 -2947
  125. package/nucleation.js +0 -36
package/README.md CHANGED
@@ -1,16 +1,10 @@
1
- # Nucleation for JavaScript / TypeScript
1
+ # nucleation
2
2
 
3
- [![npm](https://img.shields.io/npm/v/nucleation.svg)](https://www.npmjs.com/package/nucleation)
3
+ A high-performance Minecraft schematic engine, compiled to WebAssembly from Rust. Parse, edit,
4
+ diff, fingerprint, and generate schematics in Node or the browser.
4
5
 
5
- JavaScript / TypeScript bindings for **Nucleation**, a high-performance
6
- Minecraft schematic engine. Read, edit, build, simulate, and mesh
7
- `.schematic`, `.litematic`, `.nbt`, and `.mcstructure` files — in the
8
- browser or in Node.
9
-
10
- The core is written in Rust and compiled to WebAssembly via wasm-bindgen.
11
- A single package works in modern browsers, bundlers, and Node 18+.
12
-
13
- ---
6
+ This package ships generated ESM bindings (with TypeScript typings) plus the WASM binary. It
7
+ requires Node 18+ or a bundler; no native dependencies.
14
8
 
15
9
  ## Install
16
10
 
@@ -18,206 +12,44 @@ A single package works in modern browsers, bundlers, and Node 18+.
18
12
  npm install nucleation
19
13
  ```
20
14
 
21
- ```bash
22
- pnpm add nucleation
23
- ```
24
-
25
- ```bash
26
- bun add nucleation
27
- ```
28
-
29
- ---
30
-
31
15
  ## Quick start
32
16
 
33
- ```ts
34
- import init from "nucleation";
35
- import { Schematic } from "nucleation/api";
36
-
37
- await init(); // load the wasm module
17
+ ```javascript
18
+ import { Schematic } from "nucleation";
38
19
 
39
- const bytes = await fetch("example.litematic").then((r) => r.arrayBuffer());
40
- const schem = Schematic.open(new Uint8Array(bytes), {
41
- hint: "example.litematic",
42
- });
20
+ const schematic = Schematic.create("demo");
21
+ schematic.setBlock(1, 2, 3, "minecraft:stone");
22
+ console.log(schematic.getBlockName(1, 2, 3)); // "minecraft:stone"
43
23
 
44
- schem.setBlock([0, 0, 0], "minecraft:gold_block");
45
- schem.setBlock([0, 1, 0], "minecraft:repeater", {
46
- state: { delay: 4, facing: "east" },
47
- });
48
-
49
- const out = await schem.save("out.schem"); // Uint8Array
24
+ // Binary payloads cross the WASM boundary base64-encoded
25
+ const b64 = schematic.toLitematicB64();
26
+ const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
27
+ const loaded = Schematic.fromLitematic(bytes);
50
28
  ```
51
29
 
52
- ### Hot loops
53
-
54
- ```ts
55
- // One call into wasm — millions of placements/sec.
56
- const positions = Array.from({ length: 1_000_000 }, (_, x) => [x, 0, 0]);
57
- schem.setBlocks(positions, "minecraft:stone");
30
+ ## What is included
58
31
 
59
- // Pre-resolve once, place by index.
60
- const stone = schem.prepareBlock("minecraft:stone");
61
- for (const [x, y, z] of positions) {
62
- schem.place(x, y, z, stone);
63
- }
64
- ```
32
+ The published WASM contains the core feature set: schematic editing, all schematic formats,
33
+ world import (from zip) and export, the schematic builder, the procedural building tool,
34
+ definition regions, diff and fingerprinting, autostack, NBT helpers, SDF sampling, and the
35
+ in-memory store.
65
36
 
66
- ### Tile-entity helpers
67
-
68
- ```ts
69
- import { chest, sign, text, Item } from "nucleation/api";
70
-
71
- schem.setBlock([0, 0, 0], "minecraft:chest", {
72
- state: { facing: "north" },
73
- nbt: chest([
74
- Item("minecraft:diamond", { count: 64 }),
75
- Item("minecraft:elytra"),
76
- ]),
77
- });
78
-
79
- schem.setBlock([0, 1, 0], "minecraft:oak_sign", {
80
- nbt: sign([text("Loot", { color: "gold" }), "this way →"]),
81
- });
82
- ```
83
-
84
- For lossless, fully-typed reads/writes (64-bit NBT, item components), use the
85
- SNBT accessors: `getBlockEntitySnbt(x, y, z)` / `setBlockEntity(x, y, z, id, snbt)`
86
- and `getEntitiesSnbt()` / `addEntityFromSnbt(snbt)`.
87
-
88
- ### Version conversion (datafixers)
89
-
90
- Convert block / block-entity / item / entity data **between Minecraft data
91
- versions** — a Rust port of PaperMC's DataConverter. Forward conversion is
92
- lossless; down-converting to an older version returns a JSON **loss report** so
93
- you can warn before saving. Importers capture the source data version (set it
94
- manually for versionless formats; classic `.schematic` ≈ `1343`).
95
-
96
- ```ts
97
- schem.fromLitematic(bytes);
98
- console.log(schem.getSourceDataVersion()); // e.g. 3953 (1.21)
99
- console.log(SchematicWrapper.canonicalDataVersion()); // 4790 (in-memory target)
100
-
101
- // Save a copy for 1.16.5 (data version 2586); schem itself is untouched.
102
- const { bytes: out, loss } = schem.toLitematicForVersion(2586);
103
- const report = JSON.parse(loss); // [] when lossless
104
- for (const e of report) { // {version, kind, severity, path, detail}
105
- console.warn(`[${e.severity}] ${e.path}: ${e.detail}`);
106
- }
107
- ```
108
-
109
- ### Storage
110
-
111
- The `Store` class is pluggable byte storage — it decides *where bytes live*,
112
- independent of the schematic format. Keys are `/`-delimited UTF-8 paths.
113
-
114
- ```ts
115
- import { Store } from "nucleation";
116
-
117
- const store = new Store("mem://"); // throws on error
118
-
119
- store.put("schems/base.litematic", out); // (key, data: Uint8Array) -> void
120
- const data = store.get("schems/base.litematic"); // -> Uint8Array | undefined
121
- store.has("schems/base.litematic"); // -> boolean
122
- store.list("schems/"); // -> string[] (keys with this prefix)
123
- store.delete("schems/base.litematic"); // -> void (idempotent)
124
- ```
37
+ Redstone simulation and mesh generation also work on WASM but are not compiled into the
38
+ published binary. To use them, build a custom WASM from the
39
+ [repository](https://github.com/Schem-at/Nucleation):
125
40
 
126
- A schematic can read/write a `Store` directly — the format is inferred from the
127
- key's extension. This is the way to use remote/host storage on the web; it works
128
- with `mem://` and with `Store.fromCallbacks({ get, put, has, delete, list, health })`.
129
-
130
- ```ts
131
- const schem = SchematicWrapper.openFromStore(store, "schems/base.litematic");
132
- schem.saveToStore(store, "schems/copy.schem"); // format from extension
133
- ```
134
-
135
- > **Web = `mem://` only.** On `wasm32` the in-memory backend is the only one
136
- > available — the filesystem, S3, Redis, and Postgres backends are native-only
137
- > and compiled out of the WASM build. Errors surface as thrown JS exceptions.
138
-
139
- ---
140
-
141
- ## Diff & Fingerprint
142
-
143
- Canonically fingerprint a build, dedup near-duplicates, and structurally diff two
144
- builds — all under an equivalence ruleset chosen by **preset name**:
145
-
146
- - `"exact"` — material- and orientation-sensitive (identical blockstates only).
147
- - `"shape"` — occupancy only; palette and orientation ignored.
148
- - `"structural"` — functional shape, rotation- and material-agnostic.
149
- - `"redstone_computational"` (alias `"redstone"`) — redstone-logic equivalence,
150
- rotation- and cosmetic-material-agnostic.
151
- - `"redstone_survival"` — like `"redstone"`, keeping survival material constraints.
152
-
153
- `diff()` also takes an optional overrides object with per-edit cost weights and a
154
- symmetry group: `{ cost_add?, cost_delete?, cost_change?, cost_swap?, symmetry? }`.
155
-
156
- ```ts
157
- import { SchematicWrapper } from "nucleation";
158
-
159
- const a = new SchematicWrapper();
160
- a.from_litematic(aBytes);
161
- const b = new SchematicWrapper();
162
- b.from_litematic(bBytes);
163
-
164
- // 32-hex canonical hash (rotation/translation/palette-agnostic per preset).
165
- console.log(a.fingerprint("structural"));
166
-
167
- // Cheap exact dedup + fuzzy FFT shape distance (0.0 == same shape).
168
- if (a.isDuplicateOf(b, "structural")) console.log("duplicate build");
169
- console.log("footprint distance:", a.footprintDistance(b, "structural"));
170
-
171
- // Dims + token histogram as JSON.
172
- console.log(a.signature("structural"));
173
-
174
- // Structural diff -> DiffWrapper. `preset` defaults to "exact".
175
- const d = a.diff(b, "redstone");
176
- console.log("distance:", d.distance);
177
- // support = fraction of the larger build's cells that aligned (confidence,
178
- // NOT a similarity %).
179
- console.log("support:", d.support);
180
-
181
- // Each delta as its own SchematicWrapper.
182
- d.added(); d.removed(); d.changed(); d.swapped(); d.markers();
183
-
184
- // Lossless JSON round-trips via DiffWrapper.fromJson; summaryJson() is compact.
185
- import { DiffWrapper } from "nucleation";
186
- const full = d.toJson();
187
- const restored = DiffWrapper.fromJson(full);
188
- console.log(d.summaryJson());
189
- ```
190
-
191
- The glowing-overlay GLB requires a build compiled with the `meshing` feature
192
- (the published WASM bundle includes it):
193
-
194
- ```ts
195
- // `afterGlb` is the meshed "after" build (Uint8Array); returns a new GLB.
196
- const glb = d.toOverlayGlb(afterGlb); // -> Uint8Array
41
+ ```bash
42
+ cargo build --release --target wasm32-unknown-unknown --lib --features bridge,simulation,meshing
197
43
  ```
198
44
 
199
- ---
45
+ and point the package's `diplomat.config.mjs` at your `nucleation.wasm`. GPU rendering and
46
+ embedded scripting are native-only.
200
47
 
201
48
  ## Documentation
202
49
 
203
- Full reference, including simulation, meshing, and resource-pack rendering,
204
- lives in the main repository:
205
-
206
- - [Nucleation on GitHub](https://github.com/Schem-at/Nucleation)
207
50
  - [JavaScript API reference](https://github.com/Schem-at/Nucleation/blob/master/docs/javascript/README.md)
208
- - [Schematic Builder guide](https://github.com/Schem-at/Nucleation/blob/master/docs/guide/schematic-builder.md)
209
-
210
- ---
211
-
212
- ## Why Rust + WASM?
213
-
214
- Nucleation's core is shared across Rust, WebAssembly/JS, Python, and C/PHP —
215
- one engine, one set of behaviour, one set of tests. The npm package you
216
- install is the same engine that powers the Python and Rust libraries; the
217
- wasm boundary is the only thing between your JS and native-speed parsing
218
- and meshing.
51
+ - [Feature guides](https://github.com/Schem-at/Nucleation/tree/master/docs/guides)
219
52
 
220
53
  ## License
221
54
 
222
- MIT. See the [main repository](https://github.com/Schem-at/Nucleation)
223
- for details.
55
+ MIT
@@ -0,0 +1,74 @@
1
+ // generated by diplomat-tool
2
+ import type { MeshConfig } from "./MeshConfig"
3
+ import type { NucleationError } from "./NucleationError"
4
+ import type { ResourcePack } from "./ResourcePack"
5
+ import type { Schematic } from "./Schematic"
6
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
7
+
8
+
9
+
10
+ /**
11
+ * Raw vertex streams for custom rendering. Wraps {@link crate::meshing::RawMeshExport}.
12
+ */
13
+ export class RawMeshExport {
14
+ /** @internal */
15
+ get ffiValue(): pointer;
16
+ /** @internal */
17
+ constructor();
18
+
19
+
20
+ /**
21
+ * Export raw mesh data (old ABI: `schematic_to_raw_mesh`).
22
+ */
23
+ static create(schematic: Schematic, pack: ResourcePack, config: MeshConfig): RawMeshExport;
24
+
25
+ /**
26
+ * Number of vertices in the exported mesh.
27
+ */
28
+ vertexCount(): number;
29
+
30
+ /**
31
+ * Number of triangles in the exported mesh.
32
+ */
33
+ triangleCount(): number;
34
+
35
+ /**
36
+ * Flat `[x,y,z,...]` positions as little-endian `f32` bytes, base64-encoded.
37
+ */
38
+ positionsB64(): string;
39
+
40
+ /**
41
+ * Flat normals as little-endian `f32` bytes, base64-encoded.
42
+ */
43
+ normalsB64(): string;
44
+
45
+ /**
46
+ * Flat UVs as little-endian `f32` bytes, base64-encoded.
47
+ */
48
+ uvsB64(): string;
49
+
50
+ /**
51
+ * Flat vertex colors as little-endian `f32` bytes, base64-encoded.
52
+ */
53
+ colorsB64(): string;
54
+
55
+ /**
56
+ * Triangle indices as little-endian `u32` bytes, base64-encoded.
57
+ */
58
+ indicesB64(): string;
59
+
60
+ /**
61
+ * Raw RGBA texture pixels, base64-encoded.
62
+ */
63
+ textureRgbaB64(): string;
64
+
65
+ /**
66
+ * Width of the baked texture in pixels.
67
+ */
68
+ textureWidth(): number;
69
+
70
+ /**
71
+ * Height of the baked texture in pixels.
72
+ */
73
+ textureHeight(): number;
74
+ }
@@ -0,0 +1,243 @@
1
+ // generated by diplomat-tool
2
+ import { MeshConfig } from "./MeshConfig.mjs"
3
+ import { NucleationError } from "./NucleationError.mjs"
4
+ import { ResourcePack } from "./ResourcePack.mjs"
5
+ import { Schematic } from "./Schematic.mjs"
6
+ import wasm from "./diplomat-wasm.mjs";
7
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
8
+
9
+ const RawMeshExport_box_destroy_registry = new FinalizationRegistry((ptr) => {
10
+ wasm.RawMeshExport_destroy(ptr);
11
+ });
12
+
13
+ /**
14
+ * Raw vertex streams for custom rendering. Wraps {@link crate::meshing::RawMeshExport}.
15
+ */
16
+ export class RawMeshExport {
17
+ // Internal ptr reference:
18
+ #ptr = null;
19
+
20
+ // Lifetimes are only to keep dependencies alive.
21
+ // Since JS won't garbage collect until there are no incoming edges.
22
+ #selfEdge = [];
23
+
24
+ #internalConstructor(symbol, ptr, selfEdge) {
25
+ if (symbol !== diplomatRuntime.internalConstructor) {
26
+ console.error("RawMeshExport is an Opaque type. You cannot call its constructor.");
27
+ return;
28
+ }
29
+ this.#ptr = ptr;
30
+ this.#selfEdge = selfEdge;
31
+
32
+ // Are we being borrowed? If not, we can register.
33
+ if (this.#selfEdge.length === 0) {
34
+ RawMeshExport_box_destroy_registry.register(this, this.#ptr);
35
+ }
36
+
37
+ return this;
38
+ }
39
+ /** @internal */
40
+ get ffiValue() {
41
+ return this.#ptr;
42
+ }
43
+
44
+
45
+ /**
46
+ * Export raw mesh data (old ABI: `schematic_to_raw_mesh`).
47
+ */
48
+ static create(schematic, pack, config) {
49
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
50
+
51
+
52
+ const result = wasm.RawMeshExport_create(diplomatReceive.buffer, schematic.ffiValue, pack.ffiValue, config.ffiValue);
53
+
54
+ try {
55
+ if (!diplomatReceive.resultFlag) {
56
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
57
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
58
+ }
59
+ return new RawMeshExport(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
60
+ }
61
+
62
+ finally {
63
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
64
+ diplomatReceive.free();
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Number of vertices in the exported mesh.
70
+ */
71
+ vertexCount() {
72
+
73
+ const result = wasm.RawMeshExport_vertex_count(this.ffiValue);
74
+
75
+ try {
76
+ return result;
77
+ }
78
+
79
+ finally {
80
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Number of triangles in the exported mesh.
86
+ */
87
+ triangleCount() {
88
+
89
+ const result = wasm.RawMeshExport_triangle_count(this.ffiValue);
90
+
91
+ try {
92
+ return result;
93
+ }
94
+
95
+ finally {
96
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Flat `[x,y,z,...]` positions as little-endian `f32` bytes, base64-encoded.
102
+ */
103
+ positionsB64() {
104
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
105
+
106
+ wasm.RawMeshExport_positions_b64(this.ffiValue, write.buffer);
107
+
108
+ try {
109
+ return write.readString8();
110
+ }
111
+
112
+ finally {
113
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
114
+ write.free();
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Flat normals as little-endian `f32` bytes, base64-encoded.
120
+ */
121
+ normalsB64() {
122
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
123
+
124
+ wasm.RawMeshExport_normals_b64(this.ffiValue, write.buffer);
125
+
126
+ try {
127
+ return write.readString8();
128
+ }
129
+
130
+ finally {
131
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
132
+ write.free();
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Flat UVs as little-endian `f32` bytes, base64-encoded.
138
+ */
139
+ uvsB64() {
140
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
141
+
142
+ wasm.RawMeshExport_uvs_b64(this.ffiValue, write.buffer);
143
+
144
+ try {
145
+ return write.readString8();
146
+ }
147
+
148
+ finally {
149
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
150
+ write.free();
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Flat vertex colors as little-endian `f32` bytes, base64-encoded.
156
+ */
157
+ colorsB64() {
158
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
159
+
160
+ wasm.RawMeshExport_colors_b64(this.ffiValue, write.buffer);
161
+
162
+ try {
163
+ return write.readString8();
164
+ }
165
+
166
+ finally {
167
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
168
+ write.free();
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Triangle indices as little-endian `u32` bytes, base64-encoded.
174
+ */
175
+ indicesB64() {
176
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
177
+
178
+ wasm.RawMeshExport_indices_b64(this.ffiValue, write.buffer);
179
+
180
+ try {
181
+ return write.readString8();
182
+ }
183
+
184
+ finally {
185
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
186
+ write.free();
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Raw RGBA texture pixels, base64-encoded.
192
+ */
193
+ textureRgbaB64() {
194
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
195
+
196
+ wasm.RawMeshExport_texture_rgba_b64(this.ffiValue, write.buffer);
197
+
198
+ try {
199
+ return write.readString8();
200
+ }
201
+
202
+ finally {
203
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
204
+ write.free();
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Width of the baked texture in pixels.
210
+ */
211
+ textureWidth() {
212
+
213
+ const result = wasm.RawMeshExport_texture_width(this.ffiValue);
214
+
215
+ try {
216
+ return result;
217
+ }
218
+
219
+ finally {
220
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Height of the baked texture in pixels.
226
+ */
227
+ textureHeight() {
228
+
229
+ const result = wasm.RawMeshExport_texture_height(this.ffiValue);
230
+
231
+ try {
232
+ return result;
233
+ }
234
+
235
+ finally {
236
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
237
+ }
238
+ }
239
+
240
+ constructor(symbol, ptr, selfEdge) {
241
+ return this.#internalConstructor(...arguments)
242
+ }
243
+ }
@@ -0,0 +1,58 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError"
3
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
+
5
+
6
+
7
+ /**
8
+ * An extracted redstone logic graph. Wraps
9
+ * {@link crate::simulation::graph::RedstoneGraph}.
10
+ */
11
+ export class RedstoneGraph {
12
+ /** @internal */
13
+ get ffiValue(): pointer;
14
+ /** @internal */
15
+ constructor();
16
+
17
+
18
+ /**
19
+ * Number of nodes in the graph.
20
+ */
21
+ nodeCount(): number;
22
+
23
+ /**
24
+ * Total number of directed edges in the graph.
25
+ */
26
+ edgeCount(): number;
27
+
28
+ /**
29
+ * The nodes as a JSON array string.
30
+ */
31
+ nodesJson(): string;
32
+
33
+ /**
34
+ * The directed edges as a JSON array string.
35
+ */
36
+ edgesJson(): string;
37
+
38
+ /**
39
+ * Computed graph features as a JSON object string.
40
+ */
41
+ featuresJson(): string;
42
+
43
+ /**
44
+ * Fingerprint (hex string) for `preset` ("structural" | "functional" |
45
+ * "exact"; empty defaults to "structural").
46
+ */
47
+ fingerprint(preset: string): string;
48
+
49
+ /**
50
+ * Serialize the whole graph to JSON.
51
+ */
52
+ toJson(): string;
53
+
54
+ /**
55
+ * Deserialize a graph from a JSON string.
56
+ */
57
+ static fromJson(json: string): RedstoneGraph;
58
+ }