nucleation 0.2.18 → 0.3.1

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 (129) 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 +68 -0
  8. package/Brush.mjs +220 -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/Palette.d.ts +84 -0
  66. package/Palette.mjs +269 -0
  67. package/PaletteBuilder.d.ts +76 -0
  68. package/PaletteBuilder.mjs +297 -0
  69. package/README.md +28 -197
  70. package/RawMeshExport.d.ts +74 -0
  71. package/RawMeshExport.mjs +243 -0
  72. package/RedstoneGraph.d.ts +58 -0
  73. package/RedstoneGraph.mjs +242 -0
  74. package/RegionBounds.d.ts +41 -0
  75. package/RegionBounds.mjs +181 -0
  76. package/RenderConfig.d.ts +66 -0
  77. package/RenderConfig.mjs +170 -0
  78. package/Renderer.d.ts +35 -0
  79. package/Renderer.mjs +139 -0
  80. package/ResourcePack.d.ts +105 -0
  81. package/ResourcePack.mjs +447 -0
  82. package/ResourcePackList.d.ts +32 -0
  83. package/ResourcePackList.mjs +96 -0
  84. package/Schematic.d.ts +655 -0
  85. package/Schematic.mjs +2647 -0
  86. package/SchematicBuilder.d.ts +103 -0
  87. package/SchematicBuilder.mjs +401 -0
  88. package/SchematicRegions.d.ts +93 -0
  89. package/SchematicRegions.mjs +411 -0
  90. package/Scripting.d.ts +40 -0
  91. package/Scripting.mjs +138 -0
  92. package/Sdf.d.ts +31 -0
  93. package/Sdf.mjs +107 -0
  94. package/Shape.d.ts +108 -0
  95. package/Shape.mjs +336 -0
  96. package/SortStrategy.d.ts +86 -0
  97. package/SortStrategy.mjs +272 -0
  98. package/Store.d.ts +83 -0
  99. package/Store.mjs +369 -0
  100. package/StoreIo.d.ts +71 -0
  101. package/StoreIo.mjs +292 -0
  102. package/TextureAtlas.d.ts +40 -0
  103. package/TextureAtlas.mjs +122 -0
  104. package/TextureInfo.d.ts +34 -0
  105. package/TextureInfo.mjs +148 -0
  106. package/TypedCircuitExecutor.d.ts +101 -0
  107. package/TypedCircuitExecutor.mjs +378 -0
  108. package/Value.d.ts +73 -0
  109. package/Value.mjs +275 -0
  110. package/WorldChunkView.d.ts +63 -0
  111. package/WorldChunkView.mjs +201 -0
  112. package/WorldSink.d.ts +50 -0
  113. package/WorldSink.mjs +177 -0
  114. package/WorldStream.d.ts +45 -0
  115. package/WorldStream.mjs +184 -0
  116. package/diplomat-runtime.d.ts +15 -0
  117. package/diplomat-runtime.mjs +774 -0
  118. package/diplomat-wasm.mjs +52 -0
  119. package/diplomat.config.mjs +6 -0
  120. package/index.d.ts +117 -0
  121. package/index.mjs +120 -0
  122. package/{nucleation_bg.wasm → nucleation.wasm} +0 -0
  123. package/package.json +19 -41
  124. package/LICENSE +0 -21
  125. package/api.js +0 -608
  126. package/nucleation-cdn-loader.js +0 -15
  127. package/nucleation-original.js +0 -8383
  128. package/nucleation.d.ts +0 -2947
  129. package/nucleation.js +0 -36
@@ -0,0 +1,118 @@
1
+ // generated by diplomat-tool
2
+ import type { IoType } from "./IoType"
3
+ import type { LayoutFunction } from "./LayoutFunction"
4
+ import type { NucleationError } from "./NucleationError"
5
+ import type { Schematic } from "./Schematic"
6
+ import type { SortStrategy } from "./SortStrategy"
7
+ import type { TypedCircuitExecutor } from "./TypedCircuitExecutor"
8
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
9
+
10
+
11
+
12
+ /**
13
+ * High-level circuit builder. `build`/`build_validated` consume it
14
+ * (PORTING rule 11). Regions are given as flat `[x,y,z,...]` positions
15
+ * (see module notes).
16
+ */
17
+ export class CircuitBuilder {
18
+ /** @internal */
19
+ get ffiValue(): pointer;
20
+ /** @internal */
21
+ constructor();
22
+
23
+
24
+ /**
25
+ * Create a builder for a schematic (cloned; no IO defined yet).
26
+ */
27
+ static create(schematic: Schematic): CircuitBuilder;
28
+
29
+ /**
30
+ * Create a builder pre-populated from Insign annotations.
31
+ */
32
+ static fromInsign(schematic: Schematic): CircuitBuilder;
33
+
34
+ /**
35
+ * Add an input with full control.
36
+ */
37
+ withInput(name: string, ioType: IoType, layout: LayoutFunction, regionPositions: Array<number>): void;
38
+
39
+ /**
40
+ * Add an input with full control and a custom sort strategy.
41
+ */
42
+ withInputSorted(name: string, ioType: IoType, layout: LayoutFunction, regionPositions: Array<number>, sort: SortStrategy): void;
43
+
44
+ /**
45
+ * Add an input with automatic layout inference.
46
+ */
47
+ withInputAuto(name: string, ioType: IoType, regionPositions: Array<number>): void;
48
+
49
+ /**
50
+ * Add an input with automatic layout inference and a custom sort.
51
+ */
52
+ withInputAutoSorted(name: string, ioType: IoType, regionPositions: Array<number>, sort: SortStrategy): void;
53
+
54
+ /**
55
+ * Add an output with full control.
56
+ */
57
+ withOutput(name: string, ioType: IoType, layout: LayoutFunction, regionPositions: Array<number>): void;
58
+
59
+ /**
60
+ * Add an output with full control and a custom sort strategy.
61
+ */
62
+ withOutputSorted(name: string, ioType: IoType, layout: LayoutFunction, regionPositions: Array<number>, sort: SortStrategy): void;
63
+
64
+ /**
65
+ * Add an output with automatic layout inference.
66
+ */
67
+ withOutputAuto(name: string, ioType: IoType, regionPositions: Array<number>): void;
68
+
69
+ /**
70
+ * Add an output with automatic layout inference and a custom sort.
71
+ */
72
+ withOutputAutoSorted(name: string, ioType: IoType, regionPositions: Array<number>, sort: SortStrategy): void;
73
+
74
+ /**
75
+ * Set simulation options.
76
+ */
77
+ withOptions(optimize: boolean, ioOnly: boolean): void;
78
+
79
+ /**
80
+ * Set the state mode ("stateless" | "stateful" | "manual").
81
+ */
82
+ withStateMode(mode: string): void;
83
+
84
+ /**
85
+ * Validate the configuration without consuming the builder.
86
+ */
87
+ validate(): void;
88
+
89
+ /**
90
+ * Build the executor. Consumes the builder.
91
+ */
92
+ build(): TypedCircuitExecutor;
93
+
94
+ /**
95
+ * Build the executor with validation. Consumes the builder.
96
+ */
97
+ buildValidated(): TypedCircuitExecutor;
98
+
99
+ /**
100
+ * Number of inputs defined so far (0 if the builder was consumed).
101
+ */
102
+ inputCount(): number;
103
+
104
+ /**
105
+ * Number of outputs defined so far (0 if the builder was consumed).
106
+ */
107
+ outputCount(): number;
108
+
109
+ /**
110
+ * Input names as a JSON array string.
111
+ */
112
+ inputNamesJson(): string;
113
+
114
+ /**
115
+ * Output names as a JSON array string.
116
+ */
117
+ outputNamesJson(): string;
118
+ }
@@ -0,0 +1,516 @@
1
+ // generated by diplomat-tool
2
+ import { IoType } from "./IoType.mjs"
3
+ import { LayoutFunction } from "./LayoutFunction.mjs"
4
+ import { NucleationError } from "./NucleationError.mjs"
5
+ import { Schematic } from "./Schematic.mjs"
6
+ import { SortStrategy } from "./SortStrategy.mjs"
7
+ import { TypedCircuitExecutor } from "./TypedCircuitExecutor.mjs"
8
+ import wasm from "./diplomat-wasm.mjs";
9
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
10
+
11
+ const CircuitBuilder_box_destroy_registry = new FinalizationRegistry((ptr) => {
12
+ wasm.CircuitBuilder_destroy(ptr);
13
+ });
14
+
15
+ /**
16
+ * High-level circuit builder. `build`/`build_validated` consume it
17
+ * (PORTING rule 11). Regions are given as flat `[x,y,z,...]` positions
18
+ * (see module notes).
19
+ */
20
+ export class CircuitBuilder {
21
+ // Internal ptr reference:
22
+ #ptr = null;
23
+
24
+ // Lifetimes are only to keep dependencies alive.
25
+ // Since JS won't garbage collect until there are no incoming edges.
26
+ #selfEdge = [];
27
+
28
+ #internalConstructor(symbol, ptr, selfEdge) {
29
+ if (symbol !== diplomatRuntime.internalConstructor) {
30
+ console.error("CircuitBuilder is an Opaque type. You cannot call its constructor.");
31
+ return;
32
+ }
33
+ this.#ptr = ptr;
34
+ this.#selfEdge = selfEdge;
35
+
36
+ // Are we being borrowed? If not, we can register.
37
+ if (this.#selfEdge.length === 0) {
38
+ CircuitBuilder_box_destroy_registry.register(this, this.#ptr);
39
+ }
40
+
41
+ return this;
42
+ }
43
+ /** @internal */
44
+ get ffiValue() {
45
+ return this.#ptr;
46
+ }
47
+
48
+
49
+ /**
50
+ * Create a builder for a schematic (cloned; no IO defined yet).
51
+ */
52
+ static create(schematic) {
53
+
54
+ const result = wasm.CircuitBuilder_create(schematic.ffiValue);
55
+
56
+ try {
57
+ return new CircuitBuilder(diplomatRuntime.internalConstructor, result, []);
58
+ }
59
+
60
+ finally {
61
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Create a builder pre-populated from Insign annotations.
67
+ */
68
+ static fromInsign(schematic) {
69
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
70
+
71
+
72
+ const result = wasm.CircuitBuilder_from_insign(diplomatReceive.buffer, schematic.ffiValue);
73
+
74
+ try {
75
+ if (!diplomatReceive.resultFlag) {
76
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
77
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
78
+ }
79
+ return new CircuitBuilder(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
80
+ }
81
+
82
+ finally {
83
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
84
+ diplomatReceive.free();
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Add an input with full control.
90
+ */
91
+ withInput(name, ioType, layout, regionPositions) {
92
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
93
+
94
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
95
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
96
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
97
+
98
+
99
+ const result = wasm.CircuitBuilder_with_input(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, layout.ffiValue, regionPositionsSlice.ptr);
100
+
101
+ try {
102
+ if (!diplomatReceive.resultFlag) {
103
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
104
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
105
+ }
106
+ }
107
+
108
+ finally {
109
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
110
+ functionCleanupArena.free();
111
+
112
+ diplomatReceive.free();
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Add an input with full control and a custom sort strategy.
118
+ */
119
+ withInputSorted(name, ioType, layout, regionPositions, sort) {
120
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
121
+
122
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
123
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
124
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
125
+
126
+
127
+ const result = wasm.CircuitBuilder_with_input_sorted(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, layout.ffiValue, regionPositionsSlice.ptr, sort.ffiValue);
128
+
129
+ try {
130
+ if (!diplomatReceive.resultFlag) {
131
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
132
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
133
+ }
134
+ }
135
+
136
+ finally {
137
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
138
+ functionCleanupArena.free();
139
+
140
+ diplomatReceive.free();
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Add an input with automatic layout inference.
146
+ */
147
+ withInputAuto(name, ioType, regionPositions) {
148
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
149
+
150
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
151
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
152
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
153
+
154
+
155
+ const result = wasm.CircuitBuilder_with_input_auto(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, regionPositionsSlice.ptr);
156
+
157
+ try {
158
+ if (!diplomatReceive.resultFlag) {
159
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
160
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
161
+ }
162
+ }
163
+
164
+ finally {
165
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
166
+ functionCleanupArena.free();
167
+
168
+ diplomatReceive.free();
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Add an input with automatic layout inference and a custom sort.
174
+ */
175
+ withInputAutoSorted(name, ioType, regionPositions, sort) {
176
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
177
+
178
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
179
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
180
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
181
+
182
+
183
+ const result = wasm.CircuitBuilder_with_input_auto_sorted(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, regionPositionsSlice.ptr, sort.ffiValue);
184
+
185
+ try {
186
+ if (!diplomatReceive.resultFlag) {
187
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
188
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
189
+ }
190
+ }
191
+
192
+ finally {
193
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
194
+ functionCleanupArena.free();
195
+
196
+ diplomatReceive.free();
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Add an output with full control.
202
+ */
203
+ withOutput(name, ioType, layout, regionPositions) {
204
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
205
+
206
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
207
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
208
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
209
+
210
+
211
+ const result = wasm.CircuitBuilder_with_output(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, layout.ffiValue, regionPositionsSlice.ptr);
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
+ }
219
+
220
+ finally {
221
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
222
+ functionCleanupArena.free();
223
+
224
+ diplomatReceive.free();
225
+ }
226
+ }
227
+
228
+ /**
229
+ * Add an output with full control and a custom sort strategy.
230
+ */
231
+ withOutputSorted(name, ioType, layout, regionPositions, sort) {
232
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
233
+
234
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
235
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
236
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
237
+
238
+
239
+ const result = wasm.CircuitBuilder_with_output_sorted(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, layout.ffiValue, regionPositionsSlice.ptr, sort.ffiValue);
240
+
241
+ try {
242
+ if (!diplomatReceive.resultFlag) {
243
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
244
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
245
+ }
246
+ }
247
+
248
+ finally {
249
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
250
+ functionCleanupArena.free();
251
+
252
+ diplomatReceive.free();
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Add an output with automatic layout inference.
258
+ */
259
+ withOutputAuto(name, ioType, regionPositions) {
260
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
261
+
262
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
263
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
264
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
265
+
266
+
267
+ const result = wasm.CircuitBuilder_with_output_auto(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, regionPositionsSlice.ptr);
268
+
269
+ try {
270
+ if (!diplomatReceive.resultFlag) {
271
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
272
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
273
+ }
274
+ }
275
+
276
+ finally {
277
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
278
+ functionCleanupArena.free();
279
+
280
+ diplomatReceive.free();
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Add an output with automatic layout inference and a custom sort.
286
+ */
287
+ withOutputAutoSorted(name, ioType, regionPositions, sort) {
288
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
289
+
290
+ const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
291
+ const regionPositionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, regionPositions, "i32")));
292
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
293
+
294
+
295
+ const result = wasm.CircuitBuilder_with_output_auto_sorted(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr, ioType.ffiValue, regionPositionsSlice.ptr, sort.ffiValue);
296
+
297
+ try {
298
+ if (!diplomatReceive.resultFlag) {
299
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
300
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
301
+ }
302
+ }
303
+
304
+ finally {
305
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
306
+ functionCleanupArena.free();
307
+
308
+ diplomatReceive.free();
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Set simulation options.
314
+ */
315
+ withOptions(optimize, ioOnly) {
316
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
317
+
318
+
319
+ const result = wasm.CircuitBuilder_with_options(diplomatReceive.buffer, this.ffiValue, optimize, ioOnly);
320
+
321
+ try {
322
+ if (!diplomatReceive.resultFlag) {
323
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
324
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
325
+ }
326
+ }
327
+
328
+ finally {
329
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
330
+ diplomatReceive.free();
331
+ }
332
+ }
333
+
334
+ /**
335
+ * Set the state mode ("stateless" | "stateful" | "manual").
336
+ */
337
+ withStateMode(mode) {
338
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
339
+
340
+ const modeSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, mode)));
341
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
342
+
343
+
344
+ const result = wasm.CircuitBuilder_with_state_mode(diplomatReceive.buffer, this.ffiValue, modeSlice.ptr);
345
+
346
+ try {
347
+ if (!diplomatReceive.resultFlag) {
348
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
349
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
350
+ }
351
+ }
352
+
353
+ finally {
354
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
355
+ functionCleanupArena.free();
356
+
357
+ diplomatReceive.free();
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Validate the configuration without consuming the builder.
363
+ */
364
+ validate() {
365
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
366
+
367
+
368
+ const result = wasm.CircuitBuilder_validate(diplomatReceive.buffer, this.ffiValue);
369
+
370
+ try {
371
+ if (!diplomatReceive.resultFlag) {
372
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
373
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
374
+ }
375
+ }
376
+
377
+ finally {
378
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
379
+ diplomatReceive.free();
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Build the executor. Consumes the builder.
385
+ */
386
+ build() {
387
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
388
+
389
+
390
+ const result = wasm.CircuitBuilder_build(diplomatReceive.buffer, this.ffiValue);
391
+
392
+ try {
393
+ if (!diplomatReceive.resultFlag) {
394
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
395
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
396
+ }
397
+ return new TypedCircuitExecutor(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
398
+ }
399
+
400
+ finally {
401
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
402
+ diplomatReceive.free();
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Build the executor with validation. Consumes the builder.
408
+ */
409
+ buildValidated() {
410
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
411
+
412
+
413
+ const result = wasm.CircuitBuilder_build_validated(diplomatReceive.buffer, this.ffiValue);
414
+
415
+ try {
416
+ if (!diplomatReceive.resultFlag) {
417
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
418
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
419
+ }
420
+ return new TypedCircuitExecutor(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
421
+ }
422
+
423
+ finally {
424
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
425
+ diplomatReceive.free();
426
+ }
427
+ }
428
+
429
+ /**
430
+ * Number of inputs defined so far (0 if the builder was consumed).
431
+ */
432
+ inputCount() {
433
+
434
+ const result = wasm.CircuitBuilder_input_count(this.ffiValue);
435
+
436
+ try {
437
+ return result;
438
+ }
439
+
440
+ finally {
441
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
442
+ }
443
+ }
444
+
445
+ /**
446
+ * Number of outputs defined so far (0 if the builder was consumed).
447
+ */
448
+ outputCount() {
449
+
450
+ const result = wasm.CircuitBuilder_output_count(this.ffiValue);
451
+
452
+ try {
453
+ return result;
454
+ }
455
+
456
+ finally {
457
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
458
+ }
459
+ }
460
+
461
+ /**
462
+ * Input names as a JSON array string.
463
+ */
464
+ inputNamesJson() {
465
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
466
+
467
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
468
+
469
+
470
+ const result = wasm.CircuitBuilder_input_names_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
471
+
472
+ try {
473
+ if (!diplomatReceive.resultFlag) {
474
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
475
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
476
+ }
477
+ return write.readString8();
478
+ }
479
+
480
+ finally {
481
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
482
+ diplomatReceive.free();
483
+ write.free();
484
+ }
485
+ }
486
+
487
+ /**
488
+ * Output names as a JSON array string.
489
+ */
490
+ outputNamesJson() {
491
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
492
+
493
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
494
+
495
+
496
+ const result = wasm.CircuitBuilder_output_names_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
497
+
498
+ try {
499
+ if (!diplomatReceive.resultFlag) {
500
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
501
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
502
+ }
503
+ return write.readString8();
504
+ }
505
+
506
+ finally {
507
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
508
+ diplomatReceive.free();
509
+ write.free();
510
+ }
511
+ }
512
+
513
+ constructor(symbol, ptr, selfEdge) {
514
+ return this.#internalConstructor(...arguments)
515
+ }
516
+ }