nucleation 0.10.22 → 0.10.23

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 (303) hide show
  1. package/README.md +12 -0
  2. package/Schematic.d.mts +23 -0
  3. package/Schematic.d.ts +23 -0
  4. package/Schematic.mjs +70 -0
  5. package/nucleation.wasm +0 -0
  6. package/package.json +7 -2
  7. package/renderer/AnimationEffect.d.mts +44 -0
  8. package/renderer/AnimationEffect.d.ts +44 -0
  9. package/renderer/AnimationEffect.mjs +204 -0
  10. package/renderer/Autostack.d.mts +43 -0
  11. package/renderer/Autostack.d.ts +43 -0
  12. package/renderer/Autostack.mjs +134 -0
  13. package/renderer/BlockPos.d.mts +28 -0
  14. package/renderer/BlockPos.d.ts +28 -0
  15. package/renderer/BlockPos.mjs +130 -0
  16. package/renderer/BlockState.d.mts +39 -0
  17. package/renderer/BlockState.d.ts +39 -0
  18. package/renderer/BlockState.mjs +134 -0
  19. package/renderer/Blocks.d.mts +91 -0
  20. package/renderer/Blocks.d.ts +91 -0
  21. package/renderer/Blocks.mjs +308 -0
  22. package/renderer/Brush.d.mts +99 -0
  23. package/renderer/Brush.d.ts +99 -0
  24. package/renderer/Brush.mjs +335 -0
  25. package/renderer/BuildAnimation.d.mts +179 -0
  26. package/renderer/BuildAnimation.d.ts +179 -0
  27. package/renderer/BuildAnimation.mjs +1148 -0
  28. package/renderer/BuildingTool.d.mts +46 -0
  29. package/renderer/BuildingTool.d.ts +46 -0
  30. package/renderer/BuildingTool.mjs +121 -0
  31. package/renderer/CellExecutor.d.mts +51 -0
  32. package/renderer/CellExecutor.d.ts +51 -0
  33. package/renderer/CellExecutor.mjs +171 -0
  34. package/renderer/CellularSdfConfig.d.mts +22 -0
  35. package/renderer/CellularSdfConfig.d.ts +22 -0
  36. package/renderer/CellularSdfConfig.mjs +69 -0
  37. package/renderer/ChunkMeshResult.d.mts +75 -0
  38. package/renderer/ChunkMeshResult.d.ts +75 -0
  39. package/renderer/ChunkMeshResult.mjs +253 -0
  40. package/renderer/CircuitBuilder.d.mts +118 -0
  41. package/renderer/CircuitBuilder.d.ts +118 -0
  42. package/renderer/CircuitBuilder.mjs +516 -0
  43. package/renderer/Curve3D.d.mts +27 -0
  44. package/renderer/Curve3D.d.ts +27 -0
  45. package/renderer/Curve3D.mjs +101 -0
  46. package/renderer/DefinitionRegion.d.mts +274 -0
  47. package/renderer/DefinitionRegion.d.ts +274 -0
  48. package/renderer/DefinitionRegion.mjs +973 -0
  49. package/renderer/Design.d.mts +348 -0
  50. package/renderer/Design.d.ts +348 -0
  51. package/renderer/Design.mjs +1334 -0
  52. package/renderer/Diff.d.mts +88 -0
  53. package/renderer/Diff.d.ts +88 -0
  54. package/renderer/Diff.mjs +316 -0
  55. package/renderer/Dimensions.d.mts +28 -0
  56. package/renderer/Dimensions.d.ts +28 -0
  57. package/renderer/Dimensions.mjs +130 -0
  58. package/renderer/DistanceField.d.mts +39 -0
  59. package/renderer/DistanceField.d.ts +39 -0
  60. package/renderer/DistanceField.mjs +114 -0
  61. package/renderer/ExecutionMode.d.mts +42 -0
  62. package/renderer/ExecutionMode.d.ts +42 -0
  63. package/renderer/ExecutionMode.mjs +127 -0
  64. package/renderer/Field3.d.mts +40 -0
  65. package/renderer/Field3.d.ts +40 -0
  66. package/renderer/Field3.mjs +160 -0
  67. package/renderer/FieldProgram.d.mts +40 -0
  68. package/renderer/FieldProgram.d.ts +40 -0
  69. package/renderer/FieldProgram.mjs +167 -0
  70. package/renderer/FieldProgramBinaryOp.d.mts +42 -0
  71. package/renderer/FieldProgramBinaryOp.d.ts +42 -0
  72. package/renderer/FieldProgramBinaryOp.mjs +118 -0
  73. package/renderer/FieldProgramBuilder.d.mts +104 -0
  74. package/renderer/FieldProgramBuilder.d.ts +104 -0
  75. package/renderer/FieldProgramBuilder.mjs +486 -0
  76. package/renderer/FieldProgramDistanceKind.d.mts +26 -0
  77. package/renderer/FieldProgramDistanceKind.d.ts +26 -0
  78. package/renderer/FieldProgramDistanceKind.mjs +78 -0
  79. package/renderer/FieldProgramUnaryOp.d.mts +34 -0
  80. package/renderer/FieldProgramUnaryOp.d.ts +34 -0
  81. package/renderer/FieldProgramUnaryOp.mjs +102 -0
  82. package/renderer/FieldProgramValueType.d.mts +25 -0
  83. package/renderer/FieldProgramValueType.d.ts +25 -0
  84. package/renderer/FieldProgramValueType.mjs +75 -0
  85. package/renderer/FieldRange.d.mts +15 -0
  86. package/renderer/FieldRange.d.ts +15 -0
  87. package/renderer/FieldRange.mjs +109 -0
  88. package/renderer/Fingerprint.d.mts +44 -0
  89. package/renderer/Fingerprint.d.ts +44 -0
  90. package/renderer/Fingerprint.mjs +197 -0
  91. package/renderer/GeneratedChunk.d.mts +35 -0
  92. package/renderer/GeneratedChunk.d.ts +35 -0
  93. package/renderer/GeneratedChunk.mjs +178 -0
  94. package/renderer/GeneratedChunkCoverage.d.mts +25 -0
  95. package/renderer/GeneratedChunkCoverage.d.ts +25 -0
  96. package/renderer/GeneratedChunkCoverage.mjs +75 -0
  97. package/renderer/GeneratedChunkOverlayMode.d.mts +24 -0
  98. package/renderer/GeneratedChunkOverlayMode.d.ts +24 -0
  99. package/renderer/GeneratedChunkOverlayMode.mjs +72 -0
  100. package/renderer/GeneratedWorldStream.d.mts +28 -0
  101. package/renderer/GeneratedWorldStream.d.ts +28 -0
  102. package/renderer/GeneratedWorldStream.mjs +86 -0
  103. package/renderer/Geo.d.mts +41 -0
  104. package/renderer/Geo.d.ts +41 -0
  105. package/renderer/Geo.mjs +121 -0
  106. package/renderer/Hdl.d.mts +56 -0
  107. package/renderer/Hdl.d.ts +56 -0
  108. package/renderer/Hdl.mjs +163 -0
  109. package/renderer/InterpolationSpace.d.mts +25 -0
  110. package/renderer/InterpolationSpace.d.ts +25 -0
  111. package/renderer/InterpolationSpace.mjs +73 -0
  112. package/renderer/IoLayout.d.mts +26 -0
  113. package/renderer/IoLayout.d.ts +26 -0
  114. package/renderer/IoLayout.mjs +81 -0
  115. package/renderer/IoLayoutBuilder.d.mts +73 -0
  116. package/renderer/IoLayoutBuilder.d.ts +73 -0
  117. package/renderer/IoLayoutBuilder.mjs +315 -0
  118. package/renderer/IoType.d.mts +41 -0
  119. package/renderer/IoType.d.ts +41 -0
  120. package/renderer/IoType.mjs +125 -0
  121. package/renderer/ItemModelConfig.d.mts +65 -0
  122. package/renderer/ItemModelConfig.d.ts +65 -0
  123. package/renderer/ItemModelConfig.mjs +223 -0
  124. package/renderer/ItemModelPackBuilder.d.mts +32 -0
  125. package/renderer/ItemModelPackBuilder.d.ts +32 -0
  126. package/renderer/ItemModelPackBuilder.mjs +104 -0
  127. package/renderer/ItemModelResult.d.mts +72 -0
  128. package/renderer/ItemModelResult.d.ts +72 -0
  129. package/renderer/ItemModelResult.mjs +268 -0
  130. package/renderer/ItemScale.d.mts +31 -0
  131. package/renderer/ItemScale.d.ts +31 -0
  132. package/renderer/ItemScale.mjs +133 -0
  133. package/renderer/LayoutFunction.d.mts +52 -0
  134. package/renderer/LayoutFunction.d.ts +52 -0
  135. package/renderer/LayoutFunction.mjs +159 -0
  136. package/renderer/MchprsWorld.d.mts +131 -0
  137. package/renderer/MchprsWorld.d.ts +131 -0
  138. package/renderer/MchprsWorld.mjs +423 -0
  139. package/renderer/MeshBounds.d.mts +40 -0
  140. package/renderer/MeshBounds.d.ts +40 -0
  141. package/renderer/MeshBounds.mjs +181 -0
  142. package/renderer/MeshConfig.d.mts +101 -0
  143. package/renderer/MeshConfig.d.ts +101 -0
  144. package/renderer/MeshConfig.mjs +306 -0
  145. package/renderer/MeshJob.d.mts +44 -0
  146. package/renderer/MeshJob.d.ts +44 -0
  147. package/renderer/MeshJob.mjs +116 -0
  148. package/renderer/MeshPhase.d.mts +38 -0
  149. package/renderer/MeshPhase.d.ts +38 -0
  150. package/renderer/MeshPhase.mjs +90 -0
  151. package/renderer/MeshProgress.d.mts +32 -0
  152. package/renderer/MeshProgress.d.ts +32 -0
  153. package/renderer/MeshProgress.mjs +134 -0
  154. package/renderer/MeshResult.d.mts +76 -0
  155. package/renderer/MeshResult.d.ts +76 -0
  156. package/renderer/MeshResult.mjs +269 -0
  157. package/renderer/MultiMeshResult.d.mts +50 -0
  158. package/renderer/MultiMeshResult.d.ts +50 -0
  159. package/renderer/MultiMeshResult.mjs +166 -0
  160. package/renderer/Nbt.d.mts +50 -0
  161. package/renderer/Nbt.d.ts +50 -0
  162. package/renderer/Nbt.mjs +161 -0
  163. package/renderer/NucleationError.d.mts +53 -0
  164. package/renderer/NucleationError.d.ts +53 -0
  165. package/renderer/NucleationError.mjs +136 -0
  166. package/renderer/OutputCondition.d.mts +45 -0
  167. package/renderer/OutputCondition.d.ts +45 -0
  168. package/renderer/OutputCondition.mjs +129 -0
  169. package/renderer/Palette.d.mts +157 -0
  170. package/renderer/Palette.d.ts +157 -0
  171. package/renderer/Palette.mjs +487 -0
  172. package/renderer/PaletteBuilder.d.mts +119 -0
  173. package/renderer/PaletteBuilder.d.ts +119 -0
  174. package/renderer/PaletteBuilder.mjs +457 -0
  175. package/renderer/README.md +67 -0
  176. package/renderer/RawMeshExport.d.mts +74 -0
  177. package/renderer/RawMeshExport.d.ts +74 -0
  178. package/renderer/RawMeshExport.mjs +243 -0
  179. package/renderer/RedstoneGraph.d.mts +58 -0
  180. package/renderer/RedstoneGraph.d.ts +58 -0
  181. package/renderer/RedstoneGraph.mjs +242 -0
  182. package/renderer/RegionBounds.d.mts +41 -0
  183. package/renderer/RegionBounds.d.ts +41 -0
  184. package/renderer/RegionBounds.mjs +182 -0
  185. package/renderer/RenderConfig.d.mts +101 -0
  186. package/renderer/RenderConfig.d.ts +101 -0
  187. package/renderer/RenderConfig.mjs +271 -0
  188. package/renderer/Renderer.d.mts +51 -0
  189. package/renderer/Renderer.d.ts +51 -0
  190. package/renderer/Renderer.mjs +219 -0
  191. package/renderer/ResourcePack.d.mts +105 -0
  192. package/renderer/ResourcePack.d.ts +105 -0
  193. package/renderer/ResourcePack.mjs +447 -0
  194. package/renderer/ResourcePackList.d.mts +32 -0
  195. package/renderer/ResourcePackList.d.ts +32 -0
  196. package/renderer/ResourcePackList.mjs +96 -0
  197. package/renderer/Routing.d.mts +66 -0
  198. package/renderer/Routing.d.ts +66 -0
  199. package/renderer/Routing.mjs +220 -0
  200. package/renderer/Schematic.d.mts +977 -0
  201. package/renderer/Schematic.d.ts +977 -0
  202. package/renderer/Schematic.mjs +3820 -0
  203. package/renderer/SchematicBuilder.d.mts +103 -0
  204. package/renderer/SchematicBuilder.d.ts +103 -0
  205. package/renderer/SchematicBuilder.mjs +401 -0
  206. package/renderer/SchematicRegions.d.mts +93 -0
  207. package/renderer/SchematicRegions.d.ts +93 -0
  208. package/renderer/SchematicRegions.mjs +411 -0
  209. package/renderer/SchematicSplitResult.d.mts +26 -0
  210. package/renderer/SchematicSplitResult.d.ts +26 -0
  211. package/renderer/SchematicSplitResult.mjs +84 -0
  212. package/renderer/Scripting.d.mts +40 -0
  213. package/renderer/Scripting.d.ts +40 -0
  214. package/renderer/Scripting.mjs +138 -0
  215. package/renderer/Sdf.d.mts +234 -0
  216. package/renderer/Sdf.d.ts +234 -0
  217. package/renderer/Sdf.mjs +1234 -0
  218. package/renderer/SdfAxis.d.mts +25 -0
  219. package/renderer/SdfAxis.d.ts +25 -0
  220. package/renderer/SdfAxis.mjs +75 -0
  221. package/renderer/SdfBounds.d.mts +19 -0
  222. package/renderer/SdfBounds.d.ts +19 -0
  223. package/renderer/SdfBounds.mjs +161 -0
  224. package/renderer/SdfCellMode.d.mts +26 -0
  225. package/renderer/SdfCellMode.d.ts +26 -0
  226. package/renderer/SdfCellMode.mjs +78 -0
  227. package/renderer/SdfNormal.d.mts +16 -0
  228. package/renderer/SdfNormal.d.ts +16 -0
  229. package/renderer/SdfNormal.mjs +122 -0
  230. package/renderer/Shape.d.mts +143 -0
  231. package/renderer/Shape.d.ts +143 -0
  232. package/renderer/Shape.mjs +458 -0
  233. package/renderer/SortStrategy.d.mts +86 -0
  234. package/renderer/SortStrategy.d.ts +86 -0
  235. package/renderer/SortStrategy.mjs +272 -0
  236. package/renderer/Store.d.mts +83 -0
  237. package/renderer/Store.d.ts +83 -0
  238. package/renderer/Store.mjs +369 -0
  239. package/renderer/StoreIo.d.mts +71 -0
  240. package/renderer/StoreIo.d.ts +71 -0
  241. package/renderer/StoreIo.mjs +292 -0
  242. package/renderer/TextureAtlas.d.mts +40 -0
  243. package/renderer/TextureAtlas.d.ts +40 -0
  244. package/renderer/TextureAtlas.mjs +122 -0
  245. package/renderer/TextureInfo.d.mts +34 -0
  246. package/renderer/TextureInfo.d.ts +34 -0
  247. package/renderer/TextureInfo.mjs +149 -0
  248. package/renderer/TickSettleMode.d.mts +34 -0
  249. package/renderer/TickSettleMode.d.ts +34 -0
  250. package/renderer/TickSettleMode.mjs +84 -0
  251. package/renderer/TickSimulation.d.mts +572 -0
  252. package/renderer/TickSimulation.d.ts +572 -0
  253. package/renderer/TickSimulation.mjs +1299 -0
  254. package/renderer/TypedCircuitExecutor.d.mts +101 -0
  255. package/renderer/TypedCircuitExecutor.d.ts +101 -0
  256. package/renderer/TypedCircuitExecutor.mjs +378 -0
  257. package/renderer/Value.d.mts +73 -0
  258. package/renderer/Value.d.ts +73 -0
  259. package/renderer/Value.mjs +275 -0
  260. package/renderer/VideoConfig.d.mts +15 -0
  261. package/renderer/VideoConfig.d.ts +15 -0
  262. package/renderer/VideoConfig.mjs +44 -0
  263. package/renderer/VoxelModel.d.mts +34 -0
  264. package/renderer/VoxelModel.d.ts +34 -0
  265. package/renderer/VoxelModel.mjs +113 -0
  266. package/renderer/Voxelizer.d.mts +80 -0
  267. package/renderer/Voxelizer.d.ts +80 -0
  268. package/renderer/Voxelizer.mjs +261 -0
  269. package/renderer/WorldChunkView.d.mts +75 -0
  270. package/renderer/WorldChunkView.d.ts +75 -0
  271. package/renderer/WorldChunkView.mjs +224 -0
  272. package/renderer/WorldGenerator.d.mts +75 -0
  273. package/renderer/WorldGenerator.d.ts +75 -0
  274. package/renderer/WorldGenerator.mjs +255 -0
  275. package/renderer/WorldSink.d.mts +50 -0
  276. package/renderer/WorldSink.d.ts +50 -0
  277. package/renderer/WorldSink.mjs +177 -0
  278. package/renderer/WorldStream.d.mts +45 -0
  279. package/renderer/WorldStream.d.ts +45 -0
  280. package/renderer/WorldStream.mjs +184 -0
  281. package/renderer/WsPartitionHints.d.mts +29 -0
  282. package/renderer/WsPartitionHints.d.ts +29 -0
  283. package/renderer/WsPartitionHints.mjs +102 -0
  284. package/renderer/WsProfile.d.mts +46 -0
  285. package/renderer/WsProfile.d.ts +46 -0
  286. package/renderer/WsProfile.mjs +152 -0
  287. package/renderer/WsRunResult.d.mts +83 -0
  288. package/renderer/WsRunResult.d.ts +83 -0
  289. package/renderer/WsRunResult.mjs +326 -0
  290. package/renderer/WsSegmentJob.d.mts +28 -0
  291. package/renderer/WsSegmentJob.d.ts +28 -0
  292. package/renderer/WsSegmentJob.mjs +81 -0
  293. package/renderer/diplomat-runtime.d.mts +15 -0
  294. package/renderer/diplomat-runtime.d.ts +15 -0
  295. package/renderer/diplomat-runtime.mjs +779 -0
  296. package/renderer/diplomat-wasm.mjs +52 -0
  297. package/renderer/diplomat.config.mjs +5 -0
  298. package/renderer/index.d.mts +193 -0
  299. package/renderer/index.d.ts +193 -0
  300. package/renderer/index.mjs +196 -0
  301. package/renderer/nucleation.wasm +0 -0
  302. package/renderer/veneer/design.d.ts +167 -0
  303. package/renderer/veneer/design.mjs +480 -0
@@ -0,0 +1,224 @@
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
+ * Build a chunk view at (`cx`, `cz`) from a schematic — every non-air
113
+ * block whose world (x, z) falls in this chunk is copied in, the rest
114
+ * ignored. The write-side twin of `to_schematic`: this is how the
115
+ * schematic building tools become a *world generator*. Fill a schematic
116
+ * with any shape, SDF, brush, or footprint (intersect it with the
117
+ * chunk's cuboid to keep memory flat), then hand it here per chunk and
118
+ * `WorldSink.write_chunk` it. Also the transform step of a world filter:
119
+ * `to_schematic` a streamed chunk, edit it, rebuild with this.
120
+ */
121
+ static fromSchematic(schematic, cx, cz) {
122
+
123
+ const result = wasm.WorldChunkView_from_schematic(schematic.ffiValue, cx, cz);
124
+
125
+ try {
126
+ return new WorldChunkView(diplomatRuntime.internalConstructor, result, []);
127
+ }
128
+
129
+ finally {
130
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Set a block at absolute world coordinates inside this chunk view.
136
+ * `block_name` must be a valid Minecraft block identifier (e.g.
137
+ * `minecraft:stone`). Errors with `InvalidArgument` if (x, z) is outside
138
+ * this chunk's column.
139
+ */
140
+ setBlock(x, y, z, blockName) {
141
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
142
+
143
+ const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
144
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
145
+
146
+
147
+ const result = wasm.WorldChunkView_set_block(diplomatReceive.buffer, this.ffiValue, x, y, z, blockNameSlice.ptr);
148
+
149
+ try {
150
+ if (!diplomatReceive.resultFlag) {
151
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
152
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
153
+ }
154
+ }
155
+
156
+ finally {
157
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
158
+ functionCleanupArena.free();
159
+
160
+ diplomatReceive.free();
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Overwrite the biome of every currently-present section of the chunk
166
+ * view with `biome_name` (e.g. `minecraft:desert`). Sections are created
167
+ * lazily by `set_block`, so call this AFTER placing blocks.
168
+ */
169
+ setBiome(biomeName) {
170
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
171
+
172
+ const biomeNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, biomeName)));
173
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
174
+
175
+
176
+ const result = wasm.WorldChunkView_set_biome(diplomatReceive.buffer, this.ffiValue, biomeNameSlice.ptr);
177
+
178
+ try {
179
+ if (!diplomatReceive.resultFlag) {
180
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
181
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
182
+ }
183
+ }
184
+
185
+ finally {
186
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
187
+ functionCleanupArena.free();
188
+
189
+ diplomatReceive.free();
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Deduped union of all sections' biome palette entries, in order of
195
+ * first appearance, written as a JSON array string (`[]` if no section
196
+ * carries biome data).
197
+ */
198
+ biomePaletteJson() {
199
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
200
+
201
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
202
+
203
+
204
+ const result = wasm.WorldChunkView_biome_palette_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
205
+
206
+ try {
207
+ if (!diplomatReceive.resultFlag) {
208
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
209
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
210
+ }
211
+ return write.readString8();
212
+ }
213
+
214
+ finally {
215
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
216
+ diplomatReceive.free();
217
+ write.free();
218
+ }
219
+ }
220
+
221
+ constructor(symbol, ptr, selfEdge) {
222
+ return this.#internalConstructor(...arguments)
223
+ }
224
+ }
@@ -0,0 +1,75 @@
1
+ // generated by diplomat-tool
2
+ import type { Brush } from "./Brush.mjs"
3
+ import type { CellularSdfConfig } from "./CellularSdfConfig.mjs"
4
+ import type { GeneratedChunk } from "./GeneratedChunk.mjs"
5
+ import type { GeneratedChunkOverlayMode } from "./GeneratedChunkOverlayMode.mjs"
6
+ import type { GeneratedWorldStream } from "./GeneratedWorldStream.mjs"
7
+ import type { NucleationError } from "./NucleationError.mjs"
8
+ import type { Sdf } from "./Sdf.mjs"
9
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
10
+
11
+
12
+
13
+ /**
14
+ * An immutable native chunk source graph.
15
+ *
16
+ * Generated bindings expose concrete source constructors rather than host
17
+ * callbacks, so SDF evaluation and block placement stay entirely in Rust.
18
+ */
19
+ export class WorldGenerator {
20
+ /** @internal */
21
+ get ffiValue(): pointer;
22
+ /** @internal */
23
+ constructor();
24
+
25
+
26
+ /**
27
+ * Create an SDF-backed source evaluated at voxel centers over the inclusive
28
+ * Y range. `source_id` and `version` become chunk provenance/cache metadata.
29
+ */
30
+ static sdf(volume: Sdf, material: Brush, minY: number, maxY: number, sourceId: string, version: string): WorldGenerator;
31
+
32
+ /**
33
+ * Create a sparse infinite source by placing a bounded SDF motif once per
34
+ * deterministically transformed cell. Reuse `config` across layers to keep
35
+ * terrain, water, vegetation, paths, and structures coordinated.
36
+ */
37
+ static cellularSdf(volume: Sdf, material: Brush, minY: number, maxY: number, config: CellularSdfConfig, sourceId: string, version: string): WorldGenerator;
38
+
39
+ /**
40
+ * Create a sparse source from projected building footprints, including
41
+ * caller-projected OSM-derived data.
42
+ * `buildings_json` uses the same schema as `Geo.extrude_footprints`:
43
+ * `[{"polygon":[[x,z],...],"height":40,"min_y":1,
44
+ * "block":"minecraft:bricks"}]`. `height` is the absolute top Y, matching
45
+ * `Geo.extrude_footprints`. Fetching and lat/lon projection stay
46
+ * caller-controlled; this source rasterizes only requested chunks.
47
+ */
48
+ static projectedFootprints(buildingsJson: string, baseBlock: string, sourceId: string, version: string): WorldGenerator;
49
+
50
+ /**
51
+ * Create an initially empty ordered source composition.
52
+ */
53
+ static composite(sourceId: string, version: string): WorldGenerator;
54
+
55
+ /**
56
+ * Append a source to a composite. Later `Replace` layers win at occupied
57
+ * voxels; `KeepExisting` layers only fill air. Errors on non-composites.
58
+ *
59
+ * Streams already created from this generator keep the layer list they
60
+ * were built with; only later `generate`/`stream` calls see the addition.
61
+ */
62
+ addLayer(source: WorldGenerator, mode: GeneratedChunkOverlayMode): void;
63
+
64
+ /**
65
+ * Generate one random-access chunk.
66
+ */
67
+ generate(cx: number, cz: number): GeneratedChunk;
68
+
69
+ /**
70
+ * Traverse an inclusive chunk rectangle lazily in canonical region-major
71
+ * order. The stream snapshots the generator's sources at creation, so
72
+ * later `add_layer` calls do not affect a stream already in flight.
73
+ */
74
+ stream(minCx: number, minCz: number, maxCx: number, maxCz: number): GeneratedWorldStream;
75
+ }
@@ -0,0 +1,75 @@
1
+ // generated by diplomat-tool
2
+ import type { Brush } from "./Brush.mjs"
3
+ import type { CellularSdfConfig } from "./CellularSdfConfig.mjs"
4
+ import type { GeneratedChunk } from "./GeneratedChunk.mjs"
5
+ import type { GeneratedChunkOverlayMode } from "./GeneratedChunkOverlayMode.mjs"
6
+ import type { GeneratedWorldStream } from "./GeneratedWorldStream.mjs"
7
+ import type { NucleationError } from "./NucleationError.mjs"
8
+ import type { Sdf } from "./Sdf.mjs"
9
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
10
+
11
+
12
+
13
+ /**
14
+ * An immutable native chunk source graph.
15
+ *
16
+ * Generated bindings expose concrete source constructors rather than host
17
+ * callbacks, so SDF evaluation and block placement stay entirely in Rust.
18
+ */
19
+ export class WorldGenerator {
20
+ /** @internal */
21
+ get ffiValue(): pointer;
22
+ /** @internal */
23
+ constructor();
24
+
25
+
26
+ /**
27
+ * Create an SDF-backed source evaluated at voxel centers over the inclusive
28
+ * Y range. `source_id` and `version` become chunk provenance/cache metadata.
29
+ */
30
+ static sdf(volume: Sdf, material: Brush, minY: number, maxY: number, sourceId: string, version: string): WorldGenerator;
31
+
32
+ /**
33
+ * Create a sparse infinite source by placing a bounded SDF motif once per
34
+ * deterministically transformed cell. Reuse `config` across layers to keep
35
+ * terrain, water, vegetation, paths, and structures coordinated.
36
+ */
37
+ static cellularSdf(volume: Sdf, material: Brush, minY: number, maxY: number, config: CellularSdfConfig, sourceId: string, version: string): WorldGenerator;
38
+
39
+ /**
40
+ * Create a sparse source from projected building footprints, including
41
+ * caller-projected OSM-derived data.
42
+ * `buildings_json` uses the same schema as `Geo.extrude_footprints`:
43
+ * `[{"polygon":[[x,z],...],"height":40,"min_y":1,
44
+ * "block":"minecraft:bricks"}]`. `height` is the absolute top Y, matching
45
+ * `Geo.extrude_footprints`. Fetching and lat/lon projection stay
46
+ * caller-controlled; this source rasterizes only requested chunks.
47
+ */
48
+ static projectedFootprints(buildingsJson: string, baseBlock: string, sourceId: string, version: string): WorldGenerator;
49
+
50
+ /**
51
+ * Create an initially empty ordered source composition.
52
+ */
53
+ static composite(sourceId: string, version: string): WorldGenerator;
54
+
55
+ /**
56
+ * Append a source to a composite. Later `Replace` layers win at occupied
57
+ * voxels; `KeepExisting` layers only fill air. Errors on non-composites.
58
+ *
59
+ * Streams already created from this generator keep the layer list they
60
+ * were built with; only later `generate`/`stream` calls see the addition.
61
+ */
62
+ addLayer(source: WorldGenerator, mode: GeneratedChunkOverlayMode): void;
63
+
64
+ /**
65
+ * Generate one random-access chunk.
66
+ */
67
+ generate(cx: number, cz: number): GeneratedChunk;
68
+
69
+ /**
70
+ * Traverse an inclusive chunk rectangle lazily in canonical region-major
71
+ * order. The stream snapshots the generator's sources at creation, so
72
+ * later `add_layer` calls do not affect a stream already in flight.
73
+ */
74
+ stream(minCx: number, minCz: number, maxCx: number, maxCz: number): GeneratedWorldStream;
75
+ }
@@ -0,0 +1,255 @@
1
+ // generated by diplomat-tool
2
+ import { Brush } from "./Brush.mjs"
3
+ import { CellularSdfConfig } from "./CellularSdfConfig.mjs"
4
+ import { GeneratedChunk } from "./GeneratedChunk.mjs"
5
+ import { GeneratedChunkOverlayMode } from "./GeneratedChunkOverlayMode.mjs"
6
+ import { GeneratedWorldStream } from "./GeneratedWorldStream.mjs"
7
+ import { NucleationError } from "./NucleationError.mjs"
8
+ import { Sdf } from "./Sdf.mjs"
9
+ import wasm from "./diplomat-wasm.mjs";
10
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
11
+
12
+ const WorldGenerator_box_destroy_registry = new FinalizationRegistry((ptr) => {
13
+ wasm.WorldGenerator_destroy(ptr);
14
+ });
15
+
16
+ /**
17
+ * An immutable native chunk source graph.
18
+ *
19
+ * Generated bindings expose concrete source constructors rather than host
20
+ * callbacks, so SDF evaluation and block placement stay entirely in Rust.
21
+ */
22
+ export class WorldGenerator {
23
+ // Internal ptr reference:
24
+ #ptr = null;
25
+
26
+ // Lifetimes are only to keep dependencies alive.
27
+ // Since JS won't garbage collect until there are no incoming edges.
28
+ #selfEdge = [];
29
+
30
+ #internalConstructor(symbol, ptr, selfEdge) {
31
+ if (symbol !== diplomatRuntime.internalConstructor) {
32
+ console.error("WorldGenerator is an Opaque type. You cannot call its constructor.");
33
+ return;
34
+ }
35
+ this.#ptr = ptr;
36
+ this.#selfEdge = selfEdge;
37
+
38
+ // Are we being borrowed? If not, we can register.
39
+ if (this.#selfEdge.length === 0) {
40
+ WorldGenerator_box_destroy_registry.register(this, this.#ptr);
41
+ }
42
+
43
+ return this;
44
+ }
45
+ /** @internal */
46
+ get ffiValue() {
47
+ return this.#ptr;
48
+ }
49
+
50
+
51
+ /**
52
+ * Create an SDF-backed source evaluated at voxel centers over the inclusive
53
+ * Y range. `source_id` and `version` become chunk provenance/cache metadata.
54
+ */
55
+ static sdf(volume, material, minY, maxY, sourceId, version) {
56
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
57
+
58
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
59
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
60
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
61
+
62
+
63
+ const result = wasm.WorldGenerator_sdf(diplomatReceive.buffer, volume.ffiValue, material.ffiValue, minY, maxY, sourceIdSlice.ptr, versionSlice.ptr);
64
+
65
+ try {
66
+ if (!diplomatReceive.resultFlag) {
67
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
68
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
69
+ }
70
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
71
+ }
72
+
73
+ finally {
74
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
75
+ functionCleanupArena.free();
76
+
77
+ diplomatReceive.free();
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Create a sparse infinite source by placing a bounded SDF motif once per
83
+ * deterministically transformed cell. Reuse `config` across layers to keep
84
+ * terrain, water, vegetation, paths, and structures coordinated.
85
+ */
86
+ static cellularSdf(volume, material, minY, maxY, config, sourceId, version) {
87
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
88
+
89
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
90
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
91
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
92
+
93
+
94
+ const result = wasm.WorldGenerator_cellular_sdf(diplomatReceive.buffer, volume.ffiValue, material.ffiValue, minY, maxY, config.ffiValue, sourceIdSlice.ptr, versionSlice.ptr);
95
+
96
+ try {
97
+ if (!diplomatReceive.resultFlag) {
98
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
99
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
100
+ }
101
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
102
+ }
103
+
104
+ finally {
105
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
106
+ functionCleanupArena.free();
107
+
108
+ diplomatReceive.free();
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Create a sparse source from projected building footprints, including
114
+ * caller-projected OSM-derived data.
115
+ * `buildings_json` uses the same schema as `Geo.extrude_footprints`:
116
+ * `[{"polygon":[[x,z],...],"height":40,"min_y":1,
117
+ * "block":"minecraft:bricks"}]`. `height` is the absolute top Y, matching
118
+ * `Geo.extrude_footprints`. Fetching and lat/lon projection stay
119
+ * caller-controlled; this source rasterizes only requested chunks.
120
+ */
121
+ static projectedFootprints(buildingsJson, baseBlock, sourceId, version) {
122
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
123
+
124
+ const buildingsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, buildingsJson)));
125
+ const baseBlockSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, baseBlock)));
126
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
127
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
128
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
129
+
130
+
131
+ const result = wasm.WorldGenerator_projected_footprints(diplomatReceive.buffer, buildingsJsonSlice.ptr, baseBlockSlice.ptr, sourceIdSlice.ptr, versionSlice.ptr);
132
+
133
+ try {
134
+ if (!diplomatReceive.resultFlag) {
135
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
136
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
137
+ }
138
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
139
+ }
140
+
141
+ finally {
142
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
143
+ functionCleanupArena.free();
144
+
145
+ diplomatReceive.free();
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Create an initially empty ordered source composition.
151
+ */
152
+ static composite(sourceId, version) {
153
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
154
+
155
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
156
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
157
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
158
+
159
+
160
+ const result = wasm.WorldGenerator_composite(diplomatReceive.buffer, sourceIdSlice.ptr, versionSlice.ptr);
161
+
162
+ try {
163
+ if (!diplomatReceive.resultFlag) {
164
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
165
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
166
+ }
167
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
168
+ }
169
+
170
+ finally {
171
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
172
+ functionCleanupArena.free();
173
+
174
+ diplomatReceive.free();
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Append a source to a composite. Later `Replace` layers win at occupied
180
+ * voxels; `KeepExisting` layers only fill air. Errors on non-composites.
181
+ *
182
+ * Streams already created from this generator keep the layer list they
183
+ * were built with; only later `generate`/`stream` calls see the addition.
184
+ */
185
+ addLayer(source, mode) {
186
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
187
+
188
+
189
+ const result = wasm.WorldGenerator_add_layer(diplomatReceive.buffer, this.ffiValue, source.ffiValue, mode.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
+ }
197
+
198
+ finally {
199
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
200
+ diplomatReceive.free();
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Generate one random-access chunk.
206
+ */
207
+ generate(cx, cz) {
208
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
209
+
210
+
211
+ const result = wasm.WorldGenerator_generate(diplomatReceive.buffer, this.ffiValue, cx, cz);
212
+
213
+ try {
214
+ if (!diplomatReceive.resultFlag) {
215
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
216
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
217
+ }
218
+ return new GeneratedChunk(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
219
+ }
220
+
221
+ finally {
222
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
223
+ diplomatReceive.free();
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Traverse an inclusive chunk rectangle lazily in canonical region-major
229
+ * order. The stream snapshots the generator's sources at creation, so
230
+ * later `add_layer` calls do not affect a stream already in flight.
231
+ */
232
+ stream(minCx, minCz, maxCx, maxCz) {
233
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
234
+
235
+
236
+ const result = wasm.WorldGenerator_stream(diplomatReceive.buffer, this.ffiValue, minCx, minCz, maxCx, maxCz);
237
+
238
+ try {
239
+ if (!diplomatReceive.resultFlag) {
240
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
241
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
242
+ }
243
+ return new GeneratedWorldStream(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
244
+ }
245
+
246
+ finally {
247
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
248
+ diplomatReceive.free();
249
+ }
250
+ }
251
+
252
+ constructor(symbol, ptr, selfEdge) {
253
+ return this.#internalConstructor(...arguments)
254
+ }
255
+ }
@@ -0,0 +1,50 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
+ import type { WorldChunkView } from "./WorldChunkView.mjs"
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
+ }