nucleation 0.10.21 → 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 (314) hide show
  1. package/BlockPos.mjs +1 -0
  2. package/Dimensions.mjs +1 -0
  3. package/FieldRange.mjs +1 -0
  4. package/ItemScale.mjs +1 -0
  5. package/MeshBounds.mjs +1 -0
  6. package/MeshProgress.mjs +1 -0
  7. package/README.md +12 -0
  8. package/RegionBounds.mjs +1 -0
  9. package/Schematic.d.mts +32 -0
  10. package/Schematic.d.ts +32 -0
  11. package/Schematic.mjs +100 -0
  12. package/SdfBounds.mjs +1 -0
  13. package/SdfNormal.mjs +1 -0
  14. package/TextureInfo.mjs +1 -0
  15. package/diplomat-runtime.mjs +19 -14
  16. package/nucleation.wasm +0 -0
  17. package/package.json +7 -2
  18. package/renderer/AnimationEffect.d.mts +44 -0
  19. package/renderer/AnimationEffect.d.ts +44 -0
  20. package/renderer/AnimationEffect.mjs +204 -0
  21. package/renderer/Autostack.d.mts +43 -0
  22. package/renderer/Autostack.d.ts +43 -0
  23. package/renderer/Autostack.mjs +134 -0
  24. package/renderer/BlockPos.d.mts +28 -0
  25. package/renderer/BlockPos.d.ts +28 -0
  26. package/renderer/BlockPos.mjs +130 -0
  27. package/renderer/BlockState.d.mts +39 -0
  28. package/renderer/BlockState.d.ts +39 -0
  29. package/renderer/BlockState.mjs +134 -0
  30. package/renderer/Blocks.d.mts +91 -0
  31. package/renderer/Blocks.d.ts +91 -0
  32. package/renderer/Blocks.mjs +308 -0
  33. package/renderer/Brush.d.mts +99 -0
  34. package/renderer/Brush.d.ts +99 -0
  35. package/renderer/Brush.mjs +335 -0
  36. package/renderer/BuildAnimation.d.mts +179 -0
  37. package/renderer/BuildAnimation.d.ts +179 -0
  38. package/renderer/BuildAnimation.mjs +1148 -0
  39. package/renderer/BuildingTool.d.mts +46 -0
  40. package/renderer/BuildingTool.d.ts +46 -0
  41. package/renderer/BuildingTool.mjs +121 -0
  42. package/renderer/CellExecutor.d.mts +51 -0
  43. package/renderer/CellExecutor.d.ts +51 -0
  44. package/renderer/CellExecutor.mjs +171 -0
  45. package/renderer/CellularSdfConfig.d.mts +22 -0
  46. package/renderer/CellularSdfConfig.d.ts +22 -0
  47. package/renderer/CellularSdfConfig.mjs +69 -0
  48. package/renderer/ChunkMeshResult.d.mts +75 -0
  49. package/renderer/ChunkMeshResult.d.ts +75 -0
  50. package/renderer/ChunkMeshResult.mjs +253 -0
  51. package/renderer/CircuitBuilder.d.mts +118 -0
  52. package/renderer/CircuitBuilder.d.ts +118 -0
  53. package/renderer/CircuitBuilder.mjs +516 -0
  54. package/renderer/Curve3D.d.mts +27 -0
  55. package/renderer/Curve3D.d.ts +27 -0
  56. package/renderer/Curve3D.mjs +101 -0
  57. package/renderer/DefinitionRegion.d.mts +274 -0
  58. package/renderer/DefinitionRegion.d.ts +274 -0
  59. package/renderer/DefinitionRegion.mjs +973 -0
  60. package/renderer/Design.d.mts +348 -0
  61. package/renderer/Design.d.ts +348 -0
  62. package/renderer/Design.mjs +1334 -0
  63. package/renderer/Diff.d.mts +88 -0
  64. package/renderer/Diff.d.ts +88 -0
  65. package/renderer/Diff.mjs +316 -0
  66. package/renderer/Dimensions.d.mts +28 -0
  67. package/renderer/Dimensions.d.ts +28 -0
  68. package/renderer/Dimensions.mjs +130 -0
  69. package/renderer/DistanceField.d.mts +39 -0
  70. package/renderer/DistanceField.d.ts +39 -0
  71. package/renderer/DistanceField.mjs +114 -0
  72. package/renderer/ExecutionMode.d.mts +42 -0
  73. package/renderer/ExecutionMode.d.ts +42 -0
  74. package/renderer/ExecutionMode.mjs +127 -0
  75. package/renderer/Field3.d.mts +40 -0
  76. package/renderer/Field3.d.ts +40 -0
  77. package/renderer/Field3.mjs +160 -0
  78. package/renderer/FieldProgram.d.mts +40 -0
  79. package/renderer/FieldProgram.d.ts +40 -0
  80. package/renderer/FieldProgram.mjs +167 -0
  81. package/renderer/FieldProgramBinaryOp.d.mts +42 -0
  82. package/renderer/FieldProgramBinaryOp.d.ts +42 -0
  83. package/renderer/FieldProgramBinaryOp.mjs +118 -0
  84. package/renderer/FieldProgramBuilder.d.mts +104 -0
  85. package/renderer/FieldProgramBuilder.d.ts +104 -0
  86. package/renderer/FieldProgramBuilder.mjs +486 -0
  87. package/renderer/FieldProgramDistanceKind.d.mts +26 -0
  88. package/renderer/FieldProgramDistanceKind.d.ts +26 -0
  89. package/renderer/FieldProgramDistanceKind.mjs +78 -0
  90. package/renderer/FieldProgramUnaryOp.d.mts +34 -0
  91. package/renderer/FieldProgramUnaryOp.d.ts +34 -0
  92. package/renderer/FieldProgramUnaryOp.mjs +102 -0
  93. package/renderer/FieldProgramValueType.d.mts +25 -0
  94. package/renderer/FieldProgramValueType.d.ts +25 -0
  95. package/renderer/FieldProgramValueType.mjs +75 -0
  96. package/renderer/FieldRange.d.mts +15 -0
  97. package/renderer/FieldRange.d.ts +15 -0
  98. package/renderer/FieldRange.mjs +109 -0
  99. package/renderer/Fingerprint.d.mts +44 -0
  100. package/renderer/Fingerprint.d.ts +44 -0
  101. package/renderer/Fingerprint.mjs +197 -0
  102. package/renderer/GeneratedChunk.d.mts +35 -0
  103. package/renderer/GeneratedChunk.d.ts +35 -0
  104. package/renderer/GeneratedChunk.mjs +178 -0
  105. package/renderer/GeneratedChunkCoverage.d.mts +25 -0
  106. package/renderer/GeneratedChunkCoverage.d.ts +25 -0
  107. package/renderer/GeneratedChunkCoverage.mjs +75 -0
  108. package/renderer/GeneratedChunkOverlayMode.d.mts +24 -0
  109. package/renderer/GeneratedChunkOverlayMode.d.ts +24 -0
  110. package/renderer/GeneratedChunkOverlayMode.mjs +72 -0
  111. package/renderer/GeneratedWorldStream.d.mts +28 -0
  112. package/renderer/GeneratedWorldStream.d.ts +28 -0
  113. package/renderer/GeneratedWorldStream.mjs +86 -0
  114. package/renderer/Geo.d.mts +41 -0
  115. package/renderer/Geo.d.ts +41 -0
  116. package/renderer/Geo.mjs +121 -0
  117. package/renderer/Hdl.d.mts +56 -0
  118. package/renderer/Hdl.d.ts +56 -0
  119. package/renderer/Hdl.mjs +163 -0
  120. package/renderer/InterpolationSpace.d.mts +25 -0
  121. package/renderer/InterpolationSpace.d.ts +25 -0
  122. package/renderer/InterpolationSpace.mjs +73 -0
  123. package/renderer/IoLayout.d.mts +26 -0
  124. package/renderer/IoLayout.d.ts +26 -0
  125. package/renderer/IoLayout.mjs +81 -0
  126. package/renderer/IoLayoutBuilder.d.mts +73 -0
  127. package/renderer/IoLayoutBuilder.d.ts +73 -0
  128. package/renderer/IoLayoutBuilder.mjs +315 -0
  129. package/renderer/IoType.d.mts +41 -0
  130. package/renderer/IoType.d.ts +41 -0
  131. package/renderer/IoType.mjs +125 -0
  132. package/renderer/ItemModelConfig.d.mts +65 -0
  133. package/renderer/ItemModelConfig.d.ts +65 -0
  134. package/renderer/ItemModelConfig.mjs +223 -0
  135. package/renderer/ItemModelPackBuilder.d.mts +32 -0
  136. package/renderer/ItemModelPackBuilder.d.ts +32 -0
  137. package/renderer/ItemModelPackBuilder.mjs +104 -0
  138. package/renderer/ItemModelResult.d.mts +72 -0
  139. package/renderer/ItemModelResult.d.ts +72 -0
  140. package/renderer/ItemModelResult.mjs +268 -0
  141. package/renderer/ItemScale.d.mts +31 -0
  142. package/renderer/ItemScale.d.ts +31 -0
  143. package/renderer/ItemScale.mjs +133 -0
  144. package/renderer/LayoutFunction.d.mts +52 -0
  145. package/renderer/LayoutFunction.d.ts +52 -0
  146. package/renderer/LayoutFunction.mjs +159 -0
  147. package/renderer/MchprsWorld.d.mts +131 -0
  148. package/renderer/MchprsWorld.d.ts +131 -0
  149. package/renderer/MchprsWorld.mjs +423 -0
  150. package/renderer/MeshBounds.d.mts +40 -0
  151. package/renderer/MeshBounds.d.ts +40 -0
  152. package/renderer/MeshBounds.mjs +181 -0
  153. package/renderer/MeshConfig.d.mts +101 -0
  154. package/renderer/MeshConfig.d.ts +101 -0
  155. package/renderer/MeshConfig.mjs +306 -0
  156. package/renderer/MeshJob.d.mts +44 -0
  157. package/renderer/MeshJob.d.ts +44 -0
  158. package/renderer/MeshJob.mjs +116 -0
  159. package/renderer/MeshPhase.d.mts +38 -0
  160. package/renderer/MeshPhase.d.ts +38 -0
  161. package/renderer/MeshPhase.mjs +90 -0
  162. package/renderer/MeshProgress.d.mts +32 -0
  163. package/renderer/MeshProgress.d.ts +32 -0
  164. package/renderer/MeshProgress.mjs +134 -0
  165. package/renderer/MeshResult.d.mts +76 -0
  166. package/renderer/MeshResult.d.ts +76 -0
  167. package/renderer/MeshResult.mjs +269 -0
  168. package/renderer/MultiMeshResult.d.mts +50 -0
  169. package/renderer/MultiMeshResult.d.ts +50 -0
  170. package/renderer/MultiMeshResult.mjs +166 -0
  171. package/renderer/Nbt.d.mts +50 -0
  172. package/renderer/Nbt.d.ts +50 -0
  173. package/renderer/Nbt.mjs +161 -0
  174. package/renderer/NucleationError.d.mts +53 -0
  175. package/renderer/NucleationError.d.ts +53 -0
  176. package/renderer/NucleationError.mjs +136 -0
  177. package/renderer/OutputCondition.d.mts +45 -0
  178. package/renderer/OutputCondition.d.ts +45 -0
  179. package/renderer/OutputCondition.mjs +129 -0
  180. package/renderer/Palette.d.mts +157 -0
  181. package/renderer/Palette.d.ts +157 -0
  182. package/renderer/Palette.mjs +487 -0
  183. package/renderer/PaletteBuilder.d.mts +119 -0
  184. package/renderer/PaletteBuilder.d.ts +119 -0
  185. package/renderer/PaletteBuilder.mjs +457 -0
  186. package/renderer/README.md +67 -0
  187. package/renderer/RawMeshExport.d.mts +74 -0
  188. package/renderer/RawMeshExport.d.ts +74 -0
  189. package/renderer/RawMeshExport.mjs +243 -0
  190. package/renderer/RedstoneGraph.d.mts +58 -0
  191. package/renderer/RedstoneGraph.d.ts +58 -0
  192. package/renderer/RedstoneGraph.mjs +242 -0
  193. package/renderer/RegionBounds.d.mts +41 -0
  194. package/renderer/RegionBounds.d.ts +41 -0
  195. package/renderer/RegionBounds.mjs +182 -0
  196. package/renderer/RenderConfig.d.mts +101 -0
  197. package/renderer/RenderConfig.d.ts +101 -0
  198. package/renderer/RenderConfig.mjs +271 -0
  199. package/renderer/Renderer.d.mts +51 -0
  200. package/renderer/Renderer.d.ts +51 -0
  201. package/renderer/Renderer.mjs +219 -0
  202. package/renderer/ResourcePack.d.mts +105 -0
  203. package/renderer/ResourcePack.d.ts +105 -0
  204. package/renderer/ResourcePack.mjs +447 -0
  205. package/renderer/ResourcePackList.d.mts +32 -0
  206. package/renderer/ResourcePackList.d.ts +32 -0
  207. package/renderer/ResourcePackList.mjs +96 -0
  208. package/renderer/Routing.d.mts +66 -0
  209. package/renderer/Routing.d.ts +66 -0
  210. package/renderer/Routing.mjs +220 -0
  211. package/renderer/Schematic.d.mts +977 -0
  212. package/renderer/Schematic.d.ts +977 -0
  213. package/renderer/Schematic.mjs +3820 -0
  214. package/renderer/SchematicBuilder.d.mts +103 -0
  215. package/renderer/SchematicBuilder.d.ts +103 -0
  216. package/renderer/SchematicBuilder.mjs +401 -0
  217. package/renderer/SchematicRegions.d.mts +93 -0
  218. package/renderer/SchematicRegions.d.ts +93 -0
  219. package/renderer/SchematicRegions.mjs +411 -0
  220. package/renderer/SchematicSplitResult.d.mts +26 -0
  221. package/renderer/SchematicSplitResult.d.ts +26 -0
  222. package/renderer/SchematicSplitResult.mjs +84 -0
  223. package/renderer/Scripting.d.mts +40 -0
  224. package/renderer/Scripting.d.ts +40 -0
  225. package/renderer/Scripting.mjs +138 -0
  226. package/renderer/Sdf.d.mts +234 -0
  227. package/renderer/Sdf.d.ts +234 -0
  228. package/renderer/Sdf.mjs +1234 -0
  229. package/renderer/SdfAxis.d.mts +25 -0
  230. package/renderer/SdfAxis.d.ts +25 -0
  231. package/renderer/SdfAxis.mjs +75 -0
  232. package/renderer/SdfBounds.d.mts +19 -0
  233. package/renderer/SdfBounds.d.ts +19 -0
  234. package/renderer/SdfBounds.mjs +161 -0
  235. package/renderer/SdfCellMode.d.mts +26 -0
  236. package/renderer/SdfCellMode.d.ts +26 -0
  237. package/renderer/SdfCellMode.mjs +78 -0
  238. package/renderer/SdfNormal.d.mts +16 -0
  239. package/renderer/SdfNormal.d.ts +16 -0
  240. package/renderer/SdfNormal.mjs +122 -0
  241. package/renderer/Shape.d.mts +143 -0
  242. package/renderer/Shape.d.ts +143 -0
  243. package/renderer/Shape.mjs +458 -0
  244. package/renderer/SortStrategy.d.mts +86 -0
  245. package/renderer/SortStrategy.d.ts +86 -0
  246. package/renderer/SortStrategy.mjs +272 -0
  247. package/renderer/Store.d.mts +83 -0
  248. package/renderer/Store.d.ts +83 -0
  249. package/renderer/Store.mjs +369 -0
  250. package/renderer/StoreIo.d.mts +71 -0
  251. package/renderer/StoreIo.d.ts +71 -0
  252. package/renderer/StoreIo.mjs +292 -0
  253. package/renderer/TextureAtlas.d.mts +40 -0
  254. package/renderer/TextureAtlas.d.ts +40 -0
  255. package/renderer/TextureAtlas.mjs +122 -0
  256. package/renderer/TextureInfo.d.mts +34 -0
  257. package/renderer/TextureInfo.d.ts +34 -0
  258. package/renderer/TextureInfo.mjs +149 -0
  259. package/renderer/TickSettleMode.d.mts +34 -0
  260. package/renderer/TickSettleMode.d.ts +34 -0
  261. package/renderer/TickSettleMode.mjs +84 -0
  262. package/renderer/TickSimulation.d.mts +572 -0
  263. package/renderer/TickSimulation.d.ts +572 -0
  264. package/renderer/TickSimulation.mjs +1299 -0
  265. package/renderer/TypedCircuitExecutor.d.mts +101 -0
  266. package/renderer/TypedCircuitExecutor.d.ts +101 -0
  267. package/renderer/TypedCircuitExecutor.mjs +378 -0
  268. package/renderer/Value.d.mts +73 -0
  269. package/renderer/Value.d.ts +73 -0
  270. package/renderer/Value.mjs +275 -0
  271. package/renderer/VideoConfig.d.mts +15 -0
  272. package/renderer/VideoConfig.d.ts +15 -0
  273. package/renderer/VideoConfig.mjs +44 -0
  274. package/renderer/VoxelModel.d.mts +34 -0
  275. package/renderer/VoxelModel.d.ts +34 -0
  276. package/renderer/VoxelModel.mjs +113 -0
  277. package/renderer/Voxelizer.d.mts +80 -0
  278. package/renderer/Voxelizer.d.ts +80 -0
  279. package/renderer/Voxelizer.mjs +261 -0
  280. package/renderer/WorldChunkView.d.mts +75 -0
  281. package/renderer/WorldChunkView.d.ts +75 -0
  282. package/renderer/WorldChunkView.mjs +224 -0
  283. package/renderer/WorldGenerator.d.mts +75 -0
  284. package/renderer/WorldGenerator.d.ts +75 -0
  285. package/renderer/WorldGenerator.mjs +255 -0
  286. package/renderer/WorldSink.d.mts +50 -0
  287. package/renderer/WorldSink.d.ts +50 -0
  288. package/renderer/WorldSink.mjs +177 -0
  289. package/renderer/WorldStream.d.mts +45 -0
  290. package/renderer/WorldStream.d.ts +45 -0
  291. package/renderer/WorldStream.mjs +184 -0
  292. package/renderer/WsPartitionHints.d.mts +29 -0
  293. package/renderer/WsPartitionHints.d.ts +29 -0
  294. package/renderer/WsPartitionHints.mjs +102 -0
  295. package/renderer/WsProfile.d.mts +46 -0
  296. package/renderer/WsProfile.d.ts +46 -0
  297. package/renderer/WsProfile.mjs +152 -0
  298. package/renderer/WsRunResult.d.mts +83 -0
  299. package/renderer/WsRunResult.d.ts +83 -0
  300. package/renderer/WsRunResult.mjs +326 -0
  301. package/renderer/WsSegmentJob.d.mts +28 -0
  302. package/renderer/WsSegmentJob.d.ts +28 -0
  303. package/renderer/WsSegmentJob.mjs +81 -0
  304. package/renderer/diplomat-runtime.d.mts +15 -0
  305. package/renderer/diplomat-runtime.d.ts +15 -0
  306. package/renderer/diplomat-runtime.mjs +779 -0
  307. package/renderer/diplomat-wasm.mjs +52 -0
  308. package/renderer/diplomat.config.mjs +5 -0
  309. package/renderer/index.d.mts +193 -0
  310. package/renderer/index.d.ts +193 -0
  311. package/renderer/index.mjs +196 -0
  312. package/renderer/nucleation.wasm +0 -0
  313. package/renderer/veneer/design.d.ts +167 -0
  314. package/renderer/veneer/design.mjs +480 -0
@@ -0,0 +1,161 @@
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 Nbt_box_destroy_registry = new FinalizationRegistry((ptr) => {
7
+ wasm.Nbt_destroy(ptr);
8
+ });
9
+
10
+ /**
11
+ * Namespace type for the free-standing NBT builder helpers (the old
12
+ * `nbt_text_build` / `nbt_chest_build` / `nbt_sign_build`), following the
13
+ * static-methods-on-a-dummy-opaque pattern.
14
+ */
15
+ export class Nbt {
16
+ // Internal ptr reference:
17
+ #ptr = null;
18
+
19
+ // Lifetimes are only to keep dependencies alive.
20
+ // Since JS won't garbage collect until there are no incoming edges.
21
+ #selfEdge = [];
22
+
23
+ #internalConstructor(symbol, ptr, selfEdge) {
24
+ if (symbol !== diplomatRuntime.internalConstructor) {
25
+ console.error("Nbt is an Opaque type. You cannot call its constructor.");
26
+ return;
27
+ }
28
+ this.#ptr = ptr;
29
+ this.#selfEdge = selfEdge;
30
+
31
+ // Are we being borrowed? If not, we can register.
32
+ if (this.#selfEdge.length === 0) {
33
+ Nbt_box_destroy_registry.register(this, this.#ptr);
34
+ }
35
+
36
+ return this;
37
+ }
38
+ /** @internal */
39
+ get ffiValue() {
40
+ return this.#ptr;
41
+ }
42
+
43
+
44
+ /**
45
+ * Build a Minecraft JSON text-component string.
46
+ *
47
+ * `color` may be empty (no color). `bold` and `italic` use `-1` for
48
+ * unset, `0` for false, nonzero for true.
49
+ */
50
+ static textBuild(s, color, bold, italic) {
51
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
52
+
53
+ const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, s)));
54
+ const colorSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, color)));
55
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
56
+
57
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
58
+
59
+
60
+ const result = wasm.Nbt_text_build(diplomatReceive.buffer, sSlice.ptr, colorSlice.ptr, bold, italic, write.buffer);
61
+
62
+ try {
63
+ if (!diplomatReceive.resultFlag) {
64
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
65
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
66
+ }
67
+ return write.readString8();
68
+ }
69
+
70
+ finally {
71
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
72
+ functionCleanupArena.free();
73
+
74
+ diplomatReceive.free();
75
+ write.free();
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Build a chest-NBT SNBT string for use as the `{...}` portion of a block
81
+ * string.
82
+ *
83
+ * `items_json` is a JSON array of `{"id": string, "count"?: int,
84
+ * "slot"?: int}` entries (may be empty or `[]`); a missing/non-positive
85
+ * `count` defaults to 1, a missing/negative `slot` auto-assigns
86
+ * positionally. `name` is an optional plain-text custom name (empty = no
87
+ * `CustomName`); it is wrapped in a JSON text component automatically
88
+ * unless it already starts with `{`.
89
+ */
90
+ static chestBuild(itemsJson, name) {
91
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
92
+
93
+ const itemsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, itemsJson)));
94
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
95
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
96
+
97
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
98
+
99
+
100
+ const result = wasm.Nbt_chest_build(diplomatReceive.buffer, itemsJsonSlice.ptr, nameSlice.ptr, write.buffer);
101
+
102
+ try {
103
+ if (!diplomatReceive.resultFlag) {
104
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
105
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
106
+ }
107
+ return write.readString8();
108
+ }
109
+
110
+ finally {
111
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
112
+ functionCleanupArena.free();
113
+
114
+ diplomatReceive.free();
115
+ write.free();
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Build a modern (1.20+) sign-NBT SNBT string.
121
+ *
122
+ * `front_json` and `back_json` are JSON arrays of up to 4 line strings
123
+ * (either may be empty or `[]`). Each line may be a plain string
124
+ * (auto-wrapped via `text_build`) or an already-built JSON component
125
+ * (starts with `{`). `color` is the dye color string (empty defaults to
126
+ * `"black"`).
127
+ */
128
+ static signBuild(frontJson, backJson, color, glowing, waxed) {
129
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
130
+
131
+ const frontJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, frontJson)));
132
+ const backJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, backJson)));
133
+ const colorSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, color)));
134
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
135
+
136
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
137
+
138
+
139
+ const result = wasm.Nbt_sign_build(diplomatReceive.buffer, frontJsonSlice.ptr, backJsonSlice.ptr, colorSlice.ptr, glowing, waxed, write.buffer);
140
+
141
+ try {
142
+ if (!diplomatReceive.resultFlag) {
143
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
144
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
145
+ }
146
+ return write.readString8();
147
+ }
148
+
149
+ finally {
150
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
151
+ functionCleanupArena.free();
152
+
153
+ diplomatReceive.free();
154
+ write.free();
155
+ }
156
+ }
157
+
158
+ constructor(symbol, ptr, selfEdge) {
159
+ return this.#internalConstructor(...arguments)
160
+ }
161
+ }
@@ -0,0 +1,53 @@
1
+ // generated by diplomat-tool
2
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
3
+
4
+
5
+
6
+ /**
7
+ * Every fallible method in the bridge returns `Result<T, NucleationError>` —
8
+ * see `stencil/docs/nucleation-error.md` for how these variants were derived from
9
+ * the three error conventions the old hand-written `ffi` module mixed.
10
+ */
11
+ export class NucleationError {
12
+
13
+ /** @internal */
14
+ static fromValue(value: NucleationError | string): NucleationError;
15
+
16
+ get value(): string;
17
+
18
+ /** @internal */
19
+ get ffiValue(): number;
20
+
21
+ static NullArgument : NucleationError;
22
+ static InvalidArgument : NucleationError;
23
+ static Parse : NucleationError;
24
+ static Serialize : NucleationError;
25
+ static Io : NucleationError;
26
+ static Lock : NucleationError;
27
+ static Store : NucleationError;
28
+ static Mesh : NucleationError;
29
+ static Render : NucleationError;
30
+ static Simulation : NucleationError;
31
+ static AlreadyConsumed : NucleationError;
32
+ static NotFound : NucleationError;
33
+ /**
34
+ * A world-generation source failed while producing a chunk, even though
35
+ * the request itself was well-formed (see `world_generation`).
36
+ */
37
+ static Generation : NucleationError;
38
+
39
+
40
+ /**
41
+ * Why the last failing bridge call on this thread failed, in words.
42
+ *
43
+ * The enum cannot carry a message across the FFI, so a caught error
44
+ * is a bare variant — `InvalidArgument` — while the layer that
45
+ * refused already knew it was "19.2M cells over the 8M cap". Modules
46
+ * that know the story record it; this reads it back, so an exception
47
+ * handler holding the error value can ask it for the words. Empty
48
+ * when the last detail-carrying call succeeded.
49
+ */
50
+ detail(): string;
51
+
52
+ constructor(value: NucleationError | string );
53
+ }
@@ -0,0 +1,53 @@
1
+ // generated by diplomat-tool
2
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
3
+
4
+
5
+
6
+ /**
7
+ * Every fallible method in the bridge returns `Result<T, NucleationError>` —
8
+ * see `stencil/docs/nucleation-error.md` for how these variants were derived from
9
+ * the three error conventions the old hand-written `ffi` module mixed.
10
+ */
11
+ export class NucleationError {
12
+
13
+ /** @internal */
14
+ static fromValue(value: NucleationError | string): NucleationError;
15
+
16
+ get value(): string;
17
+
18
+ /** @internal */
19
+ get ffiValue(): number;
20
+
21
+ static NullArgument : NucleationError;
22
+ static InvalidArgument : NucleationError;
23
+ static Parse : NucleationError;
24
+ static Serialize : NucleationError;
25
+ static Io : NucleationError;
26
+ static Lock : NucleationError;
27
+ static Store : NucleationError;
28
+ static Mesh : NucleationError;
29
+ static Render : NucleationError;
30
+ static Simulation : NucleationError;
31
+ static AlreadyConsumed : NucleationError;
32
+ static NotFound : NucleationError;
33
+ /**
34
+ * A world-generation source failed while producing a chunk, even though
35
+ * the request itself was well-formed (see `world_generation`).
36
+ */
37
+ static Generation : NucleationError;
38
+
39
+
40
+ /**
41
+ * Why the last failing bridge call on this thread failed, in words.
42
+ *
43
+ * The enum cannot carry a message across the FFI, so a caught error
44
+ * is a bare variant — `InvalidArgument` — while the layer that
45
+ * refused already knew it was "19.2M cells over the 8M cap". Modules
46
+ * that know the story record it; this reads it back, so an exception
47
+ * handler holding the error value can ask it for the words. Empty
48
+ * when the last detail-carrying call succeeded.
49
+ */
50
+ detail(): string;
51
+
52
+ constructor(value: NucleationError | string );
53
+ }
@@ -0,0 +1,136 @@
1
+ // generated by diplomat-tool
2
+ import wasm from "./diplomat-wasm.mjs";
3
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
4
+
5
+
6
+
7
+ /**
8
+ * Every fallible method in the bridge returns `Result<T, NucleationError>` —
9
+ * see `stencil/docs/nucleation-error.md` for how these variants were derived from
10
+ * the three error conventions the old hand-written `ffi` module mixed.
11
+ */
12
+ export class NucleationError {
13
+ #value = undefined;
14
+
15
+ static #values = new Map([
16
+ ["NullArgument", 0],
17
+ ["InvalidArgument", 1],
18
+ ["Parse", 2],
19
+ ["Serialize", 3],
20
+ ["Io", 4],
21
+ ["Lock", 5],
22
+ ["Store", 6],
23
+ ["Mesh", 7],
24
+ ["Render", 8],
25
+ ["Simulation", 9],
26
+ ["AlreadyConsumed", 10],
27
+ ["NotFound", 11],
28
+ ["Generation", 12]
29
+ ]);
30
+
31
+ static getAllEntries() {
32
+ return NucleationError.#values.entries();
33
+ }
34
+
35
+ #internalConstructor(value) {
36
+ if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
37
+ // We pass in two internalConstructor arguments to create *new*
38
+ // instances of this type, otherwise the enums are treated as singletons.
39
+ if (arguments[1] === diplomatRuntime.internalConstructor ) {
40
+ this.#value = arguments[2];
41
+ return this;
42
+ }
43
+ return NucleationError.#objectValues[arguments[1]];
44
+ }
45
+
46
+ if (value instanceof NucleationError) {
47
+ return value;
48
+ }
49
+
50
+ let intVal = NucleationError.#values.get(value);
51
+
52
+ // Nullish check, checks for null or undefined
53
+ if (intVal != null) {
54
+ return NucleationError.#objectValues[intVal];
55
+ }
56
+
57
+ throw TypeError(value + " is not a NucleationError and does not correspond to any of its enumerator values.");
58
+ }
59
+
60
+ /** @internal */
61
+ static fromValue(value) {
62
+ return new NucleationError(value);
63
+ }
64
+
65
+ get value(){
66
+ return [...NucleationError.#values.keys()][this.#value];
67
+ }
68
+
69
+ /** @internal */
70
+ get ffiValue(){
71
+ return this.#value;
72
+ }
73
+ static #objectValues = [
74
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
75
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
76
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
77
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
78
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
79
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
80
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
81
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7),
82
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8),
83
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9),
84
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10),
85
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11),
86
+ new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12),
87
+ ];
88
+
89
+ static NullArgument = NucleationError.#objectValues[0];
90
+ static InvalidArgument = NucleationError.#objectValues[1];
91
+ static Parse = NucleationError.#objectValues[2];
92
+ static Serialize = NucleationError.#objectValues[3];
93
+ static Io = NucleationError.#objectValues[4];
94
+ static Lock = NucleationError.#objectValues[5];
95
+ static Store = NucleationError.#objectValues[6];
96
+ static Mesh = NucleationError.#objectValues[7];
97
+ static Render = NucleationError.#objectValues[8];
98
+ static Simulation = NucleationError.#objectValues[9];
99
+ static AlreadyConsumed = NucleationError.#objectValues[10];
100
+ static NotFound = NucleationError.#objectValues[11];
101
+ /**
102
+ * A world-generation source failed while producing a chunk, even though
103
+ * the request itself was well-formed (see `world_generation`).
104
+ */
105
+ static Generation = NucleationError.#objectValues[12];
106
+
107
+
108
+ /**
109
+ * Why the last failing bridge call on this thread failed, in words.
110
+ *
111
+ * The enum cannot carry a message across the FFI, so a caught error
112
+ * is a bare variant — `InvalidArgument` — while the layer that
113
+ * refused already knew it was "19.2M cells over the 8M cap". Modules
114
+ * that know the story record it; this reads it back, so an exception
115
+ * handler holding the error value can ask it for the words. Empty
116
+ * when the last detail-carrying call succeeded.
117
+ */
118
+ detail() {
119
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
120
+
121
+ wasm.NucleationError_detail(this.ffiValue, write.buffer);
122
+
123
+ try {
124
+ return write.readString8();
125
+ }
126
+
127
+ finally {
128
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
129
+ write.free();
130
+ }
131
+ }
132
+
133
+ constructor(value) {
134
+ return this.#internalConstructor(...arguments)
135
+ }
136
+ }
@@ -0,0 +1,45 @@
1
+ // generated by diplomat-tool
2
+ import type { Value } from "./Value.mjs"
3
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
+
5
+
6
+
7
+ /**
8
+ * A condition on an output value, for `ExecutionMode::until_condition`
9
+ * (PORTING rule 10).
10
+ */
11
+ export class OutputCondition {
12
+ /** @internal */
13
+ get ffiValue(): pointer;
14
+ /** @internal */
15
+ constructor();
16
+
17
+
18
+ /**
19
+ * Met when the output equals `value`.
20
+ */
21
+ static equals(value: Value): OutputCondition;
22
+
23
+ /**
24
+ * Met when the output does not equal `value`.
25
+ */
26
+ static notEquals(value: Value): OutputCondition;
27
+
28
+ /**
29
+ * Met when the output is greater than `value`. Numeric only: both
30
+ * sides must be the same numeric type (u32/i32/f32), else never met.
31
+ */
32
+ static greaterThan(value: Value): OutputCondition;
33
+
34
+ /**
35
+ * Met when the output is less than `value`. Numeric only: both sides
36
+ * must be the same numeric type (u32/i32/f32), else never met.
37
+ */
38
+ static lessThan(value: Value): OutputCondition;
39
+
40
+ /**
41
+ * Met when `output & mask` is non-zero (flag checking). Integer
42
+ * outputs (u32/i32) only; never met for other types.
43
+ */
44
+ static bitwiseAnd(mask: number): OutputCondition;
45
+ }
@@ -0,0 +1,45 @@
1
+ // generated by diplomat-tool
2
+ import type { Value } from "./Value.mjs"
3
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
+
5
+
6
+
7
+ /**
8
+ * A condition on an output value, for `ExecutionMode::until_condition`
9
+ * (PORTING rule 10).
10
+ */
11
+ export class OutputCondition {
12
+ /** @internal */
13
+ get ffiValue(): pointer;
14
+ /** @internal */
15
+ constructor();
16
+
17
+
18
+ /**
19
+ * Met when the output equals `value`.
20
+ */
21
+ static equals(value: Value): OutputCondition;
22
+
23
+ /**
24
+ * Met when the output does not equal `value`.
25
+ */
26
+ static notEquals(value: Value): OutputCondition;
27
+
28
+ /**
29
+ * Met when the output is greater than `value`. Numeric only: both
30
+ * sides must be the same numeric type (u32/i32/f32), else never met.
31
+ */
32
+ static greaterThan(value: Value): OutputCondition;
33
+
34
+ /**
35
+ * Met when the output is less than `value`. Numeric only: both sides
36
+ * must be the same numeric type (u32/i32/f32), else never met.
37
+ */
38
+ static lessThan(value: Value): OutputCondition;
39
+
40
+ /**
41
+ * Met when `output & mask` is non-zero (flag checking). Integer
42
+ * outputs (u32/i32) only; never met for other types.
43
+ */
44
+ static bitwiseAnd(mask: number): OutputCondition;
45
+ }
@@ -0,0 +1,129 @@
1
+ // generated by diplomat-tool
2
+ import { Value } from "./Value.mjs"
3
+ import wasm from "./diplomat-wasm.mjs";
4
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
5
+
6
+ const OutputCondition_box_destroy_registry = new FinalizationRegistry((ptr) => {
7
+ wasm.OutputCondition_destroy(ptr);
8
+ });
9
+
10
+ /**
11
+ * A condition on an output value, for `ExecutionMode::until_condition`
12
+ * (PORTING rule 10).
13
+ */
14
+ export class OutputCondition {
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("OutputCondition 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
+ OutputCondition_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
+ * Met when the output equals `value`.
45
+ */
46
+ static equals(value) {
47
+
48
+ const result = wasm.OutputCondition_equals(value.ffiValue);
49
+
50
+ try {
51
+ return new OutputCondition(diplomatRuntime.internalConstructor, result, []);
52
+ }
53
+
54
+ finally {
55
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Met when the output does not equal `value`.
61
+ */
62
+ static notEquals(value) {
63
+
64
+ const result = wasm.OutputCondition_not_equals(value.ffiValue);
65
+
66
+ try {
67
+ return new OutputCondition(diplomatRuntime.internalConstructor, result, []);
68
+ }
69
+
70
+ finally {
71
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Met when the output is greater than `value`. Numeric only: both
77
+ * sides must be the same numeric type (u32/i32/f32), else never met.
78
+ */
79
+ static greaterThan(value) {
80
+
81
+ const result = wasm.OutputCondition_greater_than(value.ffiValue);
82
+
83
+ try {
84
+ return new OutputCondition(diplomatRuntime.internalConstructor, result, []);
85
+ }
86
+
87
+ finally {
88
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Met when the output is less than `value`. Numeric only: both sides
94
+ * must be the same numeric type (u32/i32/f32), else never met.
95
+ */
96
+ static lessThan(value) {
97
+
98
+ const result = wasm.OutputCondition_less_than(value.ffiValue);
99
+
100
+ try {
101
+ return new OutputCondition(diplomatRuntime.internalConstructor, result, []);
102
+ }
103
+
104
+ finally {
105
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Met when `output & mask` is non-zero (flag checking). Integer
111
+ * outputs (u32/i32) only; never met for other types.
112
+ */
113
+ static bitwiseAnd(mask) {
114
+
115
+ const result = wasm.OutputCondition_bitwise_and(mask);
116
+
117
+ try {
118
+ return new OutputCondition(diplomatRuntime.internalConstructor, result, []);
119
+ }
120
+
121
+ finally {
122
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
123
+ }
124
+ }
125
+
126
+ constructor(symbol, ptr, selfEdge) {
127
+ return this.#internalConstructor(...arguments)
128
+ }
129
+ }