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/Value.mjs ADDED
@@ -0,0 +1,275 @@
1
+ // generated by diplomat-tool
2
+ import { NucleationError } from "./NucleationError.mjs"
3
+ import wasm from "./diplomat-wasm.mjs";
4
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
5
+
6
+ const Value_box_destroy_registry = new FinalizationRegistry((ptr) => {
7
+ wasm.Value_destroy(ptr);
8
+ });
9
+
10
+ /**
11
+ * A typed circuit value (payload-carrying enum; PORTING rule 10).
12
+ */
13
+ export class Value {
14
+ // Internal ptr reference:
15
+ #ptr = null;
16
+
17
+ // Lifetimes are only to keep dependencies alive.
18
+ // Since JS won't garbage collect until there are no incoming edges.
19
+ #selfEdge = [];
20
+
21
+ #internalConstructor(symbol, ptr, selfEdge) {
22
+ if (symbol !== diplomatRuntime.internalConstructor) {
23
+ console.error("Value is an Opaque type. You cannot call its constructor.");
24
+ return;
25
+ }
26
+ this.#ptr = ptr;
27
+ this.#selfEdge = selfEdge;
28
+
29
+ // Are we being borrowed? If not, we can register.
30
+ if (this.#selfEdge.length === 0) {
31
+ Value_box_destroy_registry.register(this, this.#ptr);
32
+ }
33
+
34
+ return this;
35
+ }
36
+ /** @internal */
37
+ get ffiValue() {
38
+ return this.#ptr;
39
+ }
40
+
41
+
42
+ /**
43
+ * Create an unsigned 32-bit integer value.
44
+ */
45
+ static fromU32(v) {
46
+
47
+ const result = wasm.Value_from_u32(v);
48
+
49
+ try {
50
+ return new Value(diplomatRuntime.internalConstructor, result, []);
51
+ }
52
+
53
+ finally {
54
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Create a signed 32-bit integer value.
60
+ */
61
+ static fromI32(v) {
62
+
63
+ const result = wasm.Value_from_i32(v);
64
+
65
+ try {
66
+ return new Value(diplomatRuntime.internalConstructor, result, []);
67
+ }
68
+
69
+ finally {
70
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Create a 32-bit IEEE 754 float value.
76
+ */
77
+ static fromF32(v) {
78
+
79
+ const result = wasm.Value_from_f32(v);
80
+
81
+ try {
82
+ return new Value(diplomatRuntime.internalConstructor, result, []);
83
+ }
84
+
85
+ finally {
86
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Create a boolean value.
92
+ */
93
+ static fromBool(v) {
94
+
95
+ const result = wasm.Value_from_bool(v);
96
+
97
+ try {
98
+ return new Value(diplomatRuntime.internalConstructor, result, []);
99
+ }
100
+
101
+ finally {
102
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Create a string value. Fails if the bytes are not valid UTF-8.
108
+ */
109
+ static fromString(s) {
110
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
111
+
112
+ const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, s)));
113
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
114
+
115
+
116
+ const result = wasm.Value_from_string(diplomatReceive.buffer, sSlice.ptr);
117
+
118
+ try {
119
+ if (!diplomatReceive.resultFlag) {
120
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
121
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
122
+ }
123
+ return new Value(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
124
+ }
125
+
126
+ finally {
127
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
128
+ functionCleanupArena.free();
129
+
130
+ diplomatReceive.free();
131
+ }
132
+ }
133
+
134
+ /**
135
+ * The value as u32. Also accepts u64/non-negative signed ints that
136
+ * fit, and bool (false → 0, true → 1); fails otherwise.
137
+ */
138
+ asU32() {
139
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
140
+
141
+
142
+ const result = wasm.Value_as_u32(diplomatReceive.buffer, this.ffiValue);
143
+
144
+ try {
145
+ if (!diplomatReceive.resultFlag) {
146
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
147
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
148
+ }
149
+ return (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
150
+ }
151
+
152
+ finally {
153
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
154
+ diplomatReceive.free();
155
+ }
156
+ }
157
+
158
+ /**
159
+ * The value as i32. Also accepts i64 values in i32 range; fails for
160
+ * other types.
161
+ */
162
+ asI32() {
163
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
164
+
165
+
166
+ const result = wasm.Value_as_i32(diplomatReceive.buffer, this.ffiValue);
167
+
168
+ try {
169
+ if (!diplomatReceive.resultFlag) {
170
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
171
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
172
+ }
173
+ return (new Int32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
174
+ }
175
+
176
+ finally {
177
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
178
+ diplomatReceive.free();
179
+ }
180
+ }
181
+
182
+ /**
183
+ * The value as f32; fails if this is not an f32 value.
184
+ */
185
+ asF32() {
186
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
187
+
188
+
189
+ const result = wasm.Value_as_f32(diplomatReceive.buffer, this.ffiValue);
190
+
191
+ try {
192
+ if (!diplomatReceive.resultFlag) {
193
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
194
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
195
+ }
196
+ return (new Float32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
197
+ }
198
+
199
+ finally {
200
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
201
+ diplomatReceive.free();
202
+ }
203
+ }
204
+
205
+ /**
206
+ * The value as bool; fails if this is not a bool value.
207
+ */
208
+ asBool() {
209
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 1, true);
210
+
211
+
212
+ const result = wasm.Value_as_bool(diplomatReceive.buffer, this.ffiValue);
213
+
214
+ try {
215
+ if (!diplomatReceive.resultFlag) {
216
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
217
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
218
+ }
219
+ return (new Uint8Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0] === 1;
220
+ }
221
+
222
+ finally {
223
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
224
+ diplomatReceive.free();
225
+ }
226
+ }
227
+
228
+ /**
229
+ * The string payload; fails if this is not a string value.
230
+ */
231
+ asString() {
232
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
233
+
234
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
235
+
236
+
237
+ const result = wasm.Value_as_string(diplomatReceive.buffer, this.ffiValue, write.buffer);
238
+
239
+ try {
240
+ if (!diplomatReceive.resultFlag) {
241
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
242
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
243
+ }
244
+ return write.readString8();
245
+ }
246
+
247
+ finally {
248
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
249
+ diplomatReceive.free();
250
+ write.free();
251
+ }
252
+ }
253
+
254
+ /**
255
+ * The type name (e.g. "u32", "bool", "string").
256
+ */
257
+ typeName() {
258
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
259
+
260
+ wasm.Value_type_name(this.ffiValue, write.buffer);
261
+
262
+ try {
263
+ return write.readString8();
264
+ }
265
+
266
+ finally {
267
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
268
+ write.free();
269
+ }
270
+ }
271
+
272
+ constructor(symbol, ptr, selfEdge) {
273
+ return this.#internalConstructor(...arguments)
274
+ }
275
+ }
@@ -0,0 +1,63 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError"
3
+ import type { Schematic } from "./Schematic"
4
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
5
+
6
+
7
+
8
+ /**
9
+ * A single decoded chunk (or a from-scratch chunk under construction).
10
+ */
11
+ export class WorldChunkView {
12
+ /** @internal */
13
+ get ffiValue(): pointer;
14
+ /** @internal */
15
+ constructor();
16
+
17
+
18
+ /**
19
+ * Create an empty chunk view at the given chunk coordinates — the
20
+ * starting point for generating worlds from scratch. Sections are
21
+ * created on demand by `set_block`. Serialized with
22
+ * `status = "minecraft:full"` (Minecraft will not regenerate over it)
23
+ * and the default data version.
24
+ */
25
+ static create(cx: number, cz: number): WorldChunkView;
26
+
27
+ /**
28
+ * The chunk X coordinate (in chunk units).
29
+ */
30
+ cx(): number;
31
+
32
+ /**
33
+ * The chunk Z coordinate (in chunk units).
34
+ */
35
+ cz(): number;
36
+
37
+ /**
38
+ * Convert the chunk view to a standalone schematic.
39
+ */
40
+ toSchematic(): Schematic;
41
+
42
+ /**
43
+ * Set a block at absolute world coordinates inside this chunk view.
44
+ * `block_name` must be a valid Minecraft block identifier (e.g.
45
+ * `minecraft:stone`). Errors with `InvalidArgument` if (x, z) is outside
46
+ * this chunk's column.
47
+ */
48
+ setBlock(x: number, y: number, z: number, blockName: string): void;
49
+
50
+ /**
51
+ * Overwrite the biome of every currently-present section of the chunk
52
+ * view with `biome_name` (e.g. `minecraft:desert`). Sections are created
53
+ * lazily by `set_block`, so call this AFTER placing blocks.
54
+ */
55
+ setBiome(biomeName: string): void;
56
+
57
+ /**
58
+ * Deduped union of all sections' biome palette entries, in order of
59
+ * first appearance, written as a JSON array string (`[]` if no section
60
+ * carries biome data).
61
+ */
62
+ biomePaletteJson(): string;
63
+ }
@@ -0,0 +1,201 @@
1
+ // generated by diplomat-tool
2
+ import { NucleationError } from "./NucleationError.mjs"
3
+ import { Schematic } from "./Schematic.mjs"
4
+ import wasm from "./diplomat-wasm.mjs";
5
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
6
+
7
+ const WorldChunkView_box_destroy_registry = new FinalizationRegistry((ptr) => {
8
+ wasm.WorldChunkView_destroy(ptr);
9
+ });
10
+
11
+ /**
12
+ * A single decoded chunk (or a from-scratch chunk under construction).
13
+ */
14
+ export class WorldChunkView {
15
+ // Internal ptr reference:
16
+ #ptr = null;
17
+
18
+ // Lifetimes are only to keep dependencies alive.
19
+ // Since JS won't garbage collect until there are no incoming edges.
20
+ #selfEdge = [];
21
+
22
+ #internalConstructor(symbol, ptr, selfEdge) {
23
+ if (symbol !== diplomatRuntime.internalConstructor) {
24
+ console.error("WorldChunkView is an Opaque type. You cannot call its constructor.");
25
+ return;
26
+ }
27
+ this.#ptr = ptr;
28
+ this.#selfEdge = selfEdge;
29
+
30
+ // Are we being borrowed? If not, we can register.
31
+ if (this.#selfEdge.length === 0) {
32
+ WorldChunkView_box_destroy_registry.register(this, this.#ptr);
33
+ }
34
+
35
+ return this;
36
+ }
37
+ /** @internal */
38
+ get ffiValue() {
39
+ return this.#ptr;
40
+ }
41
+
42
+
43
+ /**
44
+ * Create an empty chunk view at the given chunk coordinates — the
45
+ * starting point for generating worlds from scratch. Sections are
46
+ * created on demand by `set_block`. Serialized with
47
+ * `status = "minecraft:full"` (Minecraft will not regenerate over it)
48
+ * and the default data version.
49
+ */
50
+ static create(cx, cz) {
51
+
52
+ const result = wasm.WorldChunkView_create(cx, cz);
53
+
54
+ try {
55
+ return new WorldChunkView(diplomatRuntime.internalConstructor, result, []);
56
+ }
57
+
58
+ finally {
59
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
60
+ }
61
+ }
62
+
63
+ /**
64
+ * The chunk X coordinate (in chunk units).
65
+ */
66
+ cx() {
67
+
68
+ const result = wasm.WorldChunkView_cx(this.ffiValue);
69
+
70
+ try {
71
+ return result;
72
+ }
73
+
74
+ finally {
75
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
76
+ }
77
+ }
78
+
79
+ /**
80
+ * The chunk Z coordinate (in chunk units).
81
+ */
82
+ cz() {
83
+
84
+ const result = wasm.WorldChunkView_cz(this.ffiValue);
85
+
86
+ try {
87
+ return result;
88
+ }
89
+
90
+ finally {
91
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Convert the chunk view to a standalone schematic.
97
+ */
98
+ toSchematic() {
99
+
100
+ const result = wasm.WorldChunkView_to_schematic(this.ffiValue);
101
+
102
+ try {
103
+ return new Schematic(diplomatRuntime.internalConstructor, result, []);
104
+ }
105
+
106
+ finally {
107
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Set a block at absolute world coordinates inside this chunk view.
113
+ * `block_name` must be a valid Minecraft block identifier (e.g.
114
+ * `minecraft:stone`). Errors with `InvalidArgument` if (x, z) is outside
115
+ * this chunk's column.
116
+ */
117
+ setBlock(x, y, z, blockName) {
118
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
119
+
120
+ const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
121
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
122
+
123
+
124
+ const result = wasm.WorldChunkView_set_block(diplomatReceive.buffer, this.ffiValue, x, y, z, blockNameSlice.ptr);
125
+
126
+ try {
127
+ if (!diplomatReceive.resultFlag) {
128
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
129
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
130
+ }
131
+ }
132
+
133
+ finally {
134
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
135
+ functionCleanupArena.free();
136
+
137
+ diplomatReceive.free();
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Overwrite the biome of every currently-present section of the chunk
143
+ * view with `biome_name` (e.g. `minecraft:desert`). Sections are created
144
+ * lazily by `set_block`, so call this AFTER placing blocks.
145
+ */
146
+ setBiome(biomeName) {
147
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
148
+
149
+ const biomeNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, biomeName)));
150
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
151
+
152
+
153
+ const result = wasm.WorldChunkView_set_biome(diplomatReceive.buffer, this.ffiValue, biomeNameSlice.ptr);
154
+
155
+ try {
156
+ if (!diplomatReceive.resultFlag) {
157
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
158
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
159
+ }
160
+ }
161
+
162
+ finally {
163
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
164
+ functionCleanupArena.free();
165
+
166
+ diplomatReceive.free();
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Deduped union of all sections' biome palette entries, in order of
172
+ * first appearance, written as a JSON array string (`[]` if no section
173
+ * carries biome data).
174
+ */
175
+ biomePaletteJson() {
176
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
177
+
178
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
179
+
180
+
181
+ const result = wasm.WorldChunkView_biome_palette_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
182
+
183
+ try {
184
+ if (!diplomatReceive.resultFlag) {
185
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
186
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
187
+ }
188
+ return write.readString8();
189
+ }
190
+
191
+ finally {
192
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
193
+ diplomatReceive.free();
194
+ write.free();
195
+ }
196
+ }
197
+
198
+ constructor(symbol, ptr, selfEdge) {
199
+ return this.#internalConstructor(...arguments)
200
+ }
201
+ }
package/WorldSink.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError"
3
+ import type { WorldChunkView } from "./WorldChunkView"
4
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
5
+
6
+
7
+
8
+ /**
9
+ * A world writer. `finish` is consuming (PORTING rule 11): the inner sink is
10
+ * held in an `Option` and taken on `finish`; every method afterwards returns
11
+ * `AlreadyConsumed`. Dropping the handle without `finish` abandons the sink.
12
+ */
13
+ export class WorldSink {
14
+ /** @internal */
15
+ get ffiValue(): pointer;
16
+ /** @internal */
17
+ constructor();
18
+
19
+
20
+ /**
21
+ * Create a new world sink that writes fresh chunk data to `dir`.
22
+ * `options_json` is a serialized `WorldExportOptions` (empty string =
23
+ * defaults).
24
+ */
25
+ static create(dir: string, optionsJson: string): WorldSink;
26
+
27
+ /**
28
+ * Open an existing world directory for patching via `put_chunk`.
29
+ */
30
+ static openExisting(dir: string): WorldSink;
31
+
32
+ /**
33
+ * Write (append) a chunk view into the sink. The view is not consumed.
34
+ */
35
+ writeChunk(view: WorldChunkView): void;
36
+
37
+ /**
38
+ * Overwrite the chunk at (`view.cx`, `view.cz`) of the sink's world with
39
+ * the supplied view's block data. Only valid on sinks opened with
40
+ * `open_existing`; errors with `Io` on a create-mode sink. The view is
41
+ * not consumed.
42
+ */
43
+ putChunk(view: WorldChunkView): void;
44
+
45
+ /**
46
+ * Finalise and flush all pending writes. Consuming (PORTING rule 11):
47
+ * afterwards every method on this sink returns `AlreadyConsumed`.
48
+ */
49
+ finish(): void;
50
+ }