nucleation 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BuildAnimation.d.ts +12 -0
- package/BuildAnimation.mjs +38 -0
- package/RenderConfig.d.ts +11 -0
- package/RenderConfig.mjs +45 -0
- package/Renderer.d.ts +16 -0
- package/Renderer.mjs +80 -0
- package/VideoConfig.d.ts +15 -0
- package/VideoConfig.mjs +44 -0
- package/WsPartitionHints.d.ts +29 -0
- package/WsPartitionHints.mjs +102 -0
- package/WsProfile.d.ts +46 -0
- package/WsProfile.mjs +152 -0
- package/WsRunResult.d.ts +83 -0
- package/WsRunResult.mjs +326 -0
- package/WsSegmentJob.d.ts +28 -0
- package/WsSegmentJob.mjs +81 -0
- package/index.d.ts +10 -0
- package/index.mjs +10 -0
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
package/BuildAnimation.d.ts
CHANGED
|
@@ -20,6 +20,18 @@ export class BuildAnimation {
|
|
|
20
20
|
|
|
21
21
|
static create(name: string): BuildAnimation;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Clone an existing schematic into one animation group. Entity-only
|
|
25
|
+
* schematics are supported; overlapping block/entity integer positions
|
|
26
|
+
* are rejected rather than silently dropping a model.
|
|
27
|
+
*/
|
|
28
|
+
static fromSchematic(schematic: Schematic): BuildAnimation;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Apply one effect to every existing animation group.
|
|
32
|
+
*/
|
|
33
|
+
animateAll(effect: AnimationEffect): void;
|
|
34
|
+
|
|
23
35
|
setDefaultEffect(effect: AnimationEffect): void;
|
|
24
36
|
|
|
25
37
|
/**
|
package/BuildAnimation.mjs
CHANGED
|
@@ -61,6 +61,44 @@ export class BuildAnimation {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Clone an existing schematic into one animation group. Entity-only
|
|
66
|
+
* schematics are supported; overlapping block/entity integer positions
|
|
67
|
+
* are rejected rather than silently dropping a model.
|
|
68
|
+
*/
|
|
69
|
+
static fromSchematic(schematic) {
|
|
70
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const result = wasm.BuildAnimation_from_schematic(diplomatReceive.buffer, schematic.ffiValue);
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
if (!diplomatReceive.resultFlag) {
|
|
77
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
78
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
79
|
+
}
|
|
80
|
+
return new BuildAnimation(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
finally {
|
|
84
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
85
|
+
diplomatReceive.free();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Apply one effect to every existing animation group.
|
|
91
|
+
*/
|
|
92
|
+
animateAll(effect) {
|
|
93
|
+
wasm.BuildAnimation_animate_all(this.ffiValue, effect.ffiValue);
|
|
94
|
+
|
|
95
|
+
try {}
|
|
96
|
+
|
|
97
|
+
finally {
|
|
98
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
64
102
|
setDefaultEffect(effect) {
|
|
65
103
|
wasm.BuildAnimation_set_default_effect(this.ffiValue, effect.ffiValue);
|
|
66
104
|
|
package/RenderConfig.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
2
3
|
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
4
|
|
|
4
5
|
|
|
@@ -52,6 +53,16 @@ export class RenderConfig {
|
|
|
52
53
|
*/
|
|
53
54
|
setFov(fov: number): void;
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Set the world-space directional light and its non-negative intensity.
|
|
58
|
+
*/
|
|
59
|
+
setDirectionalLight(x: number, y: number, z: number, intensity: number): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Set the unlit floor for non-HDRI rendering, in `0..=1`.
|
|
63
|
+
*/
|
|
64
|
+
setAmbientLight(ambient: number): void;
|
|
65
|
+
|
|
55
66
|
/**
|
|
56
67
|
* Set a solid RGBA clear color (linear 0.0–1.0). Alpha < 1.0 yields a
|
|
57
68
|
* transparent PNG. Ignored when HDRI is enabled.
|
package/RenderConfig.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
2
3
|
import wasm from "./diplomat-wasm.mjs";
|
|
3
4
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
5
|
|
|
@@ -128,6 +129,50 @@ export class RenderConfig {
|
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Set the world-space directional light and its non-negative intensity.
|
|
134
|
+
*/
|
|
135
|
+
setDirectionalLight(x, y, z, intensity) {
|
|
136
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const result = wasm.RenderConfig_set_directional_light(diplomatReceive.buffer, this.ffiValue, x, y, z, intensity);
|
|
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
|
+
}
|
|
147
|
+
|
|
148
|
+
finally {
|
|
149
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
150
|
+
diplomatReceive.free();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Set the unlit floor for non-HDRI rendering, in `0..=1`.
|
|
156
|
+
*/
|
|
157
|
+
setAmbientLight(ambient) {
|
|
158
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
const result = wasm.RenderConfig_set_ambient_light(diplomatReceive.buffer, this.ffiValue, ambient);
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
if (!diplomatReceive.resultFlag) {
|
|
165
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
166
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
finally {
|
|
171
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
172
|
+
diplomatReceive.free();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
131
176
|
/**
|
|
132
177
|
* Set a solid RGBA clear color (linear 0.0–1.0). Alpha < 1.0 yields a
|
|
133
178
|
* transparent PNG. Ignored when HDRI is enabled.
|
package/Renderer.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { NucleationError } from "./NucleationError"
|
|
3
3
|
import type { RenderConfig } from "./RenderConfig"
|
|
4
|
+
import type { ResourcePack } from "./ResourcePack"
|
|
4
5
|
import type { Schematic } from "./Schematic"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
7
|
|
|
@@ -32,4 +33,19 @@ export class Renderer {
|
|
|
32
33
|
* Render a schematic to a PNG file at `path`.
|
|
33
34
|
*/
|
|
34
35
|
static renderToFile(schematic: Schematic, packZip: Array<number>, config: RenderConfig, path: string): void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Render with an already parsed resource pack, avoiding repeated ZIP parsing.
|
|
39
|
+
*/
|
|
40
|
+
static renderToFileWithPack(schematic: Schematic, pack: ResourcePack, config: RenderConfig, path: string): void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Render raw RGBA pixels with an already parsed resource pack.
|
|
44
|
+
*/
|
|
45
|
+
static renderPixelsB64WithPack(schematic: Schematic, pack: ResourcePack, config: RenderConfig): string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Render PNG bytes with an already parsed resource pack.
|
|
49
|
+
*/
|
|
50
|
+
static renderPngB64WithPack(schematic: Schematic, pack: ResourcePack, config: RenderConfig): string;
|
|
35
51
|
}
|
package/Renderer.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { NucleationError } from "./NucleationError.mjs"
|
|
3
3
|
import { RenderConfig } from "./RenderConfig.mjs"
|
|
4
|
+
import { ResourcePack } from "./ResourcePack.mjs"
|
|
4
5
|
import { Schematic } from "./Schematic.mjs"
|
|
5
6
|
import wasm from "./diplomat-wasm.mjs";
|
|
6
7
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
@@ -133,6 +134,85 @@ export class Renderer {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Render with an already parsed resource pack, avoiding repeated ZIP parsing.
|
|
139
|
+
*/
|
|
140
|
+
static renderToFileWithPack(schematic, pack, config, path) {
|
|
141
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
142
|
+
|
|
143
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
144
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
const result = wasm.Renderer_render_to_file_with_pack(diplomatReceive.buffer, schematic.ffiValue, pack.ffiValue, config.ffiValue, pathSlice.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
|
+
* Render raw RGBA pixels with an already parsed resource pack.
|
|
166
|
+
*/
|
|
167
|
+
static renderPixelsB64WithPack(schematic, pack, config) {
|
|
168
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
169
|
+
|
|
170
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
const result = wasm.Renderer_render_pixels_b64_with_pack(diplomatReceive.buffer, schematic.ffiValue, pack.ffiValue, config.ffiValue, write.buffer);
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
if (!diplomatReceive.resultFlag) {
|
|
177
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
178
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
179
|
+
}
|
|
180
|
+
return write.readString8();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
finally {
|
|
184
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
185
|
+
diplomatReceive.free();
|
|
186
|
+
write.free();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Render PNG bytes with an already parsed resource pack.
|
|
192
|
+
*/
|
|
193
|
+
static renderPngB64WithPack(schematic, pack, config) {
|
|
194
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
195
|
+
|
|
196
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
const result = wasm.Renderer_render_png_b64_with_pack(diplomatReceive.buffer, schematic.ffiValue, pack.ffiValue, config.ffiValue, write.buffer);
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
if (!diplomatReceive.resultFlag) {
|
|
203
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
204
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
205
|
+
}
|
|
206
|
+
return write.readString8();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
finally {
|
|
210
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
211
|
+
diplomatReceive.free();
|
|
212
|
+
write.free();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
136
216
|
constructor(symbol, ptr, selfEdge) {
|
|
137
217
|
return this.#internalConstructor(...arguments)
|
|
138
218
|
}
|
package/VideoConfig.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Native FFmpeg video output preset.
|
|
8
|
+
*/
|
|
9
|
+
export class VideoConfig {
|
|
10
|
+
/** @internal */
|
|
11
|
+
get ffiValue(): pointer;
|
|
12
|
+
/** @internal */
|
|
13
|
+
constructor();
|
|
14
|
+
|
|
15
|
+
}
|
package/VideoConfig.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
3
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
const VideoConfig_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
6
|
+
wasm.VideoConfig_destroy(ptr);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Native FFmpeg video output preset.
|
|
11
|
+
*/
|
|
12
|
+
export class VideoConfig {
|
|
13
|
+
// Internal ptr reference:
|
|
14
|
+
#ptr = null;
|
|
15
|
+
|
|
16
|
+
// Lifetimes are only to keep dependencies alive.
|
|
17
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
18
|
+
#selfEdge = [];
|
|
19
|
+
|
|
20
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
21
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
22
|
+
console.error("VideoConfig is an Opaque type. You cannot call its constructor.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.#ptr = ptr;
|
|
26
|
+
this.#selfEdge = selfEdge;
|
|
27
|
+
|
|
28
|
+
// Are we being borrowed? If not, we can register.
|
|
29
|
+
if (this.#selfEdge.length === 0) {
|
|
30
|
+
VideoConfig_box_destroy_registry.register(this, this.#ptr);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
/** @internal */
|
|
36
|
+
get ffiValue() {
|
|
37
|
+
return this.#ptr;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
constructor(symbol, ptr, selfEdge) {
|
|
42
|
+
return this.#internalConstructor(...arguments)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Caller-supplied partition hints (full-column boxes a cluster may never
|
|
9
|
+
* span under {@link PartitionPolicy::HardCut}). Order does not matter:
|
|
10
|
+
* {@link PartitionIndex::new}(crate::world_segment::partition::PartitionIndex)
|
|
11
|
+
* sorts hints by full content at construction time.
|
|
12
|
+
*/
|
|
13
|
+
export class WsPartitionHints {
|
|
14
|
+
/** @internal */
|
|
15
|
+
get ffiValue(): pointer;
|
|
16
|
+
/** @internal */
|
|
17
|
+
constructor();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
static create(): WsPartitionHints;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Add a full-column hint (`y_range: None`) covering inclusive
|
|
24
|
+
* `x0..=x1, z0..=z1`.
|
|
25
|
+
*/
|
|
26
|
+
add(id: string, x0: number, x1: number, z0: number, z1: number): void;
|
|
27
|
+
|
|
28
|
+
len(): number;
|
|
29
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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 WsPartitionHints_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.WsPartitionHints_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Caller-supplied partition hints (full-column boxes a cluster may never
|
|
12
|
+
* span under {@link PartitionPolicy::HardCut}). Order does not matter:
|
|
13
|
+
* {@link PartitionIndex::new}(crate::world_segment::partition::PartitionIndex)
|
|
14
|
+
* sorts hints by full content at construction time.
|
|
15
|
+
*/
|
|
16
|
+
export class WsPartitionHints {
|
|
17
|
+
// Internal ptr reference:
|
|
18
|
+
#ptr = null;
|
|
19
|
+
|
|
20
|
+
// Lifetimes are only to keep dependencies alive.
|
|
21
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
22
|
+
#selfEdge = [];
|
|
23
|
+
|
|
24
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
25
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
26
|
+
console.error("WsPartitionHints is an Opaque type. You cannot call its constructor.");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.#ptr = ptr;
|
|
30
|
+
this.#selfEdge = selfEdge;
|
|
31
|
+
|
|
32
|
+
// Are we being borrowed? If not, we can register.
|
|
33
|
+
if (this.#selfEdge.length === 0) {
|
|
34
|
+
WsPartitionHints_box_destroy_registry.register(this, this.#ptr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/** @internal */
|
|
40
|
+
get ffiValue() {
|
|
41
|
+
return this.#ptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
static create() {
|
|
46
|
+
|
|
47
|
+
const result = wasm.WsPartitionHints_create();
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
return new WsPartitionHints(diplomatRuntime.internalConstructor, result, []);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
finally {
|
|
54
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Add a full-column hint (`y_range: None`) covering inclusive
|
|
60
|
+
* `x0..=x1, z0..=z1`.
|
|
61
|
+
*/
|
|
62
|
+
add(id, x0, x1, z0, z1) {
|
|
63
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
64
|
+
|
|
65
|
+
const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
|
|
66
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const result = wasm.WsPartitionHints_add(diplomatReceive.buffer, this.ffiValue, idSlice.ptr, x0, x1, z0, z1);
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
if (!diplomatReceive.resultFlag) {
|
|
73
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
74
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
finally {
|
|
79
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
80
|
+
functionCleanupArena.free();
|
|
81
|
+
|
|
82
|
+
diplomatReceive.free();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
len() {
|
|
87
|
+
|
|
88
|
+
const result = wasm.WsPartitionHints_len(this.ffiValue);
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
finally {
|
|
95
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
constructor(symbol, ptr, selfEdge) {
|
|
100
|
+
return this.#internalConstructor(...arguments)
|
|
101
|
+
}
|
|
102
|
+
}
|
package/WsProfile.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A pinned {@link WorldProfile}(crate::world_segment::profile::WorldProfile):
|
|
9
|
+
* the substrate palette + Y band derived (or supplied) once per world and
|
|
10
|
+
* reused across every segmentation run against it.
|
|
11
|
+
*/
|
|
12
|
+
export class WsProfile {
|
|
13
|
+
/** @internal */
|
|
14
|
+
get ffiValue(): pointer;
|
|
15
|
+
/** @internal */
|
|
16
|
+
constructor();
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Derive a profile from up to `sample` tiles (regions) of a world
|
|
21
|
+
* directory, in ascending `(x, z)` region order. `coverage` is
|
|
22
|
+
* `ProfileParams::min_slab_coverage`; every other `ProfileParams`
|
|
23
|
+
* field uses its default (`sample_stride: 1`, `y_scan: (-64, 320)`).
|
|
24
|
+
*/
|
|
25
|
+
static deriveFromDir(worldDir: string, minY: number, maxY: number, sample: number, coverage: number): WsProfile;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The derived substrate Y band's lower bound (inclusive).
|
|
29
|
+
*/
|
|
30
|
+
bandMin(): number;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The derived substrate Y band's upper bound (inclusive).
|
|
34
|
+
*/
|
|
35
|
+
bandMax(): number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Number of distinct block names in the substrate palette.
|
|
39
|
+
*/
|
|
40
|
+
paletteLen(): number;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The substrate palette as a JSON array of block-name strings.
|
|
44
|
+
*/
|
|
45
|
+
writePaletteJson(): string;
|
|
46
|
+
}
|
package/WsProfile.mjs
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
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 WsProfile_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.WsProfile_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A pinned {@link WorldProfile}(crate::world_segment::profile::WorldProfile):
|
|
12
|
+
* the substrate palette + Y band derived (or supplied) once per world and
|
|
13
|
+
* reused across every segmentation run against it.
|
|
14
|
+
*/
|
|
15
|
+
export class WsProfile {
|
|
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("WsProfile 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
|
+
WsProfile_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
|
+
* Derive a profile from up to `sample` tiles (regions) of a world
|
|
46
|
+
* directory, in ascending `(x, z)` region order. `coverage` is
|
|
47
|
+
* `ProfileParams::min_slab_coverage`; every other `ProfileParams`
|
|
48
|
+
* field uses its default (`sample_stride: 1`, `y_scan: (-64, 320)`).
|
|
49
|
+
*/
|
|
50
|
+
static deriveFromDir(worldDir, minY, maxY, sample, coverage) {
|
|
51
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
52
|
+
|
|
53
|
+
const worldDirSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, worldDir)));
|
|
54
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
const result = wasm.WsProfile_derive_from_dir(diplomatReceive.buffer, worldDirSlice.ptr, minY, maxY, sample, coverage);
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
if (!diplomatReceive.resultFlag) {
|
|
61
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
62
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
63
|
+
}
|
|
64
|
+
return new WsProfile(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
finally {
|
|
68
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
69
|
+
functionCleanupArena.free();
|
|
70
|
+
|
|
71
|
+
diplomatReceive.free();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The derived substrate Y band's lower bound (inclusive).
|
|
77
|
+
*/
|
|
78
|
+
bandMin() {
|
|
79
|
+
|
|
80
|
+
const result = wasm.WsProfile_band_min(this.ffiValue);
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
finally {
|
|
87
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The derived substrate Y band's upper bound (inclusive).
|
|
93
|
+
*/
|
|
94
|
+
bandMax() {
|
|
95
|
+
|
|
96
|
+
const result = wasm.WsProfile_band_max(this.ffiValue);
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
finally {
|
|
103
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Number of distinct block names in the substrate palette.
|
|
109
|
+
*/
|
|
110
|
+
paletteLen() {
|
|
111
|
+
|
|
112
|
+
const result = wasm.WsProfile_palette_len(this.ffiValue);
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
finally {
|
|
119
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The substrate palette as a JSON array of block-name strings.
|
|
125
|
+
*/
|
|
126
|
+
writePaletteJson() {
|
|
127
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
128
|
+
|
|
129
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
const result = wasm.WsProfile_write_palette_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
if (!diplomatReceive.resultFlag) {
|
|
136
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
137
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
138
|
+
}
|
|
139
|
+
return write.readString8();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
finally {
|
|
143
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
144
|
+
diplomatReceive.free();
|
|
145
|
+
write.free();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
constructor(symbol, ptr, selfEdge) {
|
|
150
|
+
return this.#internalConstructor(...arguments)
|
|
151
|
+
}
|
|
152
|
+
}
|
package/WsRunResult.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { BlockPos } from "./BlockPos"
|
|
3
|
+
import type { NucleationError } from "./NucleationError"
|
|
4
|
+
import type { WsPartitionHints } from "./WsPartitionHints"
|
|
5
|
+
import type { WsProfile } from "./WsProfile"
|
|
6
|
+
import type { WsSegmentJob } from "./WsSegmentJob"
|
|
7
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The materialized output of one segmentation run: every build (in the
|
|
13
|
+
* pipeline's deterministic stable-id order) plus the aggregate
|
|
14
|
+
* {@link RunStats}(crate::world_segment::runner::RunStats).
|
|
15
|
+
*/
|
|
16
|
+
export class WsRunResult {
|
|
17
|
+
/** @internal */
|
|
18
|
+
get ffiValue(): pointer;
|
|
19
|
+
/** @internal */
|
|
20
|
+
constructor();
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Run the full pipeline (source -> segment -> stitch -> score ->
|
|
25
|
+
* identity -> materialize) over a world directory. No prior-snapshot
|
|
26
|
+
* builds are supplied, so every build seeds a fresh stable id (see
|
|
27
|
+
* `StableBuildId::seed`).
|
|
28
|
+
*
|
|
29
|
+
* See the module docs for why this catches a panic instead of
|
|
30
|
+
* propagating it.
|
|
31
|
+
*/
|
|
32
|
+
static runDir(job: WsSegmentJob, hints: WsPartitionHints, profile: WsProfile, worldDir: string): WsRunResult;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Total builds materialized (same as `build_count`, from `RunStats`).
|
|
36
|
+
*/
|
|
37
|
+
builds(): bigint;
|
|
38
|
+
|
|
39
|
+
tierConfident(): bigint;
|
|
40
|
+
|
|
41
|
+
tierProbable(): bigint;
|
|
42
|
+
|
|
43
|
+
tierDebris(): bigint;
|
|
44
|
+
|
|
45
|
+
crossTile(): bigint;
|
|
46
|
+
|
|
47
|
+
largestBlockCount(): bigint;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Number of builds held in this result (indices `0..build_count()`
|
|
51
|
+
* are valid for every per-index accessor below).
|
|
52
|
+
*/
|
|
53
|
+
buildCount(): number;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The build's stable id (hex), stable across re-runs against the
|
|
57
|
+
* same source under the same config, absent a prior-snapshot match.
|
|
58
|
+
*/
|
|
59
|
+
stableIdHex(index: number): string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The build's content fingerprint, as 32 lowercase hex digits (u128,
|
|
63
|
+
* big-endian).
|
|
64
|
+
*/
|
|
65
|
+
fingerprintHex(index: number): string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* `0` = Confident, `1` = Probable, `2` = Debris.
|
|
69
|
+
*/
|
|
70
|
+
tierOf(index: number): number;
|
|
71
|
+
|
|
72
|
+
blockCountOf(index: number): bigint;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The build's world-space bounding box minimum (inclusive).
|
|
76
|
+
*/
|
|
77
|
+
bboxMinOf(index: number): BlockPos;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The build's world-space bounding box maximum (inclusive).
|
|
81
|
+
*/
|
|
82
|
+
bboxMaxOf(index: number): BlockPos;
|
|
83
|
+
}
|
package/WsRunResult.mjs
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { BlockPos } from "./BlockPos.mjs"
|
|
3
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
4
|
+
import { WsPartitionHints } from "./WsPartitionHints.mjs"
|
|
5
|
+
import { WsProfile } from "./WsProfile.mjs"
|
|
6
|
+
import { WsSegmentJob } from "./WsSegmentJob.mjs"
|
|
7
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
8
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
9
|
+
|
|
10
|
+
const WsRunResult_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
11
|
+
wasm.WsRunResult_destroy(ptr);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The materialized output of one segmentation run: every build (in the
|
|
16
|
+
* pipeline's deterministic stable-id order) plus the aggregate
|
|
17
|
+
* {@link RunStats}(crate::world_segment::runner::RunStats).
|
|
18
|
+
*/
|
|
19
|
+
export class WsRunResult {
|
|
20
|
+
// Internal ptr reference:
|
|
21
|
+
#ptr = null;
|
|
22
|
+
|
|
23
|
+
// Lifetimes are only to keep dependencies alive.
|
|
24
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
25
|
+
#selfEdge = [];
|
|
26
|
+
|
|
27
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
28
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
29
|
+
console.error("WsRunResult is an Opaque type. You cannot call its constructor.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.#ptr = ptr;
|
|
33
|
+
this.#selfEdge = selfEdge;
|
|
34
|
+
|
|
35
|
+
// Are we being borrowed? If not, we can register.
|
|
36
|
+
if (this.#selfEdge.length === 0) {
|
|
37
|
+
WsRunResult_box_destroy_registry.register(this, this.#ptr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
get ffiValue() {
|
|
44
|
+
return this.#ptr;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Run the full pipeline (source -> segment -> stitch -> score ->
|
|
50
|
+
* identity -> materialize) over a world directory. No prior-snapshot
|
|
51
|
+
* builds are supplied, so every build seeds a fresh stable id (see
|
|
52
|
+
* `StableBuildId::seed`).
|
|
53
|
+
*
|
|
54
|
+
* See the module docs for why this catches a panic instead of
|
|
55
|
+
* propagating it.
|
|
56
|
+
*/
|
|
57
|
+
static runDir(job, hints, profile, worldDir) {
|
|
58
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
59
|
+
|
|
60
|
+
const worldDirSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, worldDir)));
|
|
61
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
const result = wasm.WsRunResult_run_dir(diplomatReceive.buffer, job.ffiValue, hints.ffiValue, profile.ffiValue, worldDirSlice.ptr);
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
if (!diplomatReceive.resultFlag) {
|
|
68
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
69
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
70
|
+
}
|
|
71
|
+
return new WsRunResult(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
finally {
|
|
75
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
76
|
+
functionCleanupArena.free();
|
|
77
|
+
|
|
78
|
+
diplomatReceive.free();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Total builds materialized (same as `build_count`, from `RunStats`).
|
|
84
|
+
*/
|
|
85
|
+
builds() {
|
|
86
|
+
|
|
87
|
+
const result = wasm.WsRunResult_builds(this.ffiValue);
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
finally {
|
|
94
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
tierConfident() {
|
|
99
|
+
|
|
100
|
+
const result = wasm.WsRunResult_tier_confident(this.ffiValue);
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
finally {
|
|
107
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
tierProbable() {
|
|
112
|
+
|
|
113
|
+
const result = wasm.WsRunResult_tier_probable(this.ffiValue);
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
finally {
|
|
120
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
tierDebris() {
|
|
125
|
+
|
|
126
|
+
const result = wasm.WsRunResult_tier_debris(this.ffiValue);
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
finally {
|
|
133
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
crossTile() {
|
|
138
|
+
|
|
139
|
+
const result = wasm.WsRunResult_cross_tile(this.ffiValue);
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
finally {
|
|
146
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
largestBlockCount() {
|
|
151
|
+
|
|
152
|
+
const result = wasm.WsRunResult_largest_block_count(this.ffiValue);
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
finally {
|
|
159
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Number of builds held in this result (indices `0..build_count()`
|
|
165
|
+
* are valid for every per-index accessor below).
|
|
166
|
+
*/
|
|
167
|
+
buildCount() {
|
|
168
|
+
|
|
169
|
+
const result = wasm.WsRunResult_build_count(this.ffiValue);
|
|
170
|
+
|
|
171
|
+
try {
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
finally {
|
|
176
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The build's stable id (hex), stable across re-runs against the
|
|
182
|
+
* same source under the same config, absent a prior-snapshot match.
|
|
183
|
+
*/
|
|
184
|
+
stableIdHex(index) {
|
|
185
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
186
|
+
|
|
187
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
const result = wasm.WsRunResult_stable_id_hex(diplomatReceive.buffer, this.ffiValue, index, write.buffer);
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
if (!diplomatReceive.resultFlag) {
|
|
194
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
195
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
196
|
+
}
|
|
197
|
+
return write.readString8();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
finally {
|
|
201
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
202
|
+
diplomatReceive.free();
|
|
203
|
+
write.free();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The build's content fingerprint, as 32 lowercase hex digits (u128,
|
|
209
|
+
* big-endian).
|
|
210
|
+
*/
|
|
211
|
+
fingerprintHex(index) {
|
|
212
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
213
|
+
|
|
214
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
const result = wasm.WsRunResult_fingerprint_hex(diplomatReceive.buffer, this.ffiValue, index, write.buffer);
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
if (!diplomatReceive.resultFlag) {
|
|
221
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
222
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
223
|
+
}
|
|
224
|
+
return write.readString8();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
finally {
|
|
228
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
229
|
+
diplomatReceive.free();
|
|
230
|
+
write.free();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* `0` = Confident, `1` = Probable, `2` = Debris.
|
|
236
|
+
*/
|
|
237
|
+
tierOf(index) {
|
|
238
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 1, true);
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
const result = wasm.WsRunResult_tier_of(diplomatReceive.buffer, this.ffiValue, index);
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
if (!diplomatReceive.resultFlag) {
|
|
245
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
246
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
247
|
+
}
|
|
248
|
+
return (new Uint8Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
finally {
|
|
252
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
253
|
+
diplomatReceive.free();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
blockCountOf(index) {
|
|
258
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 8, true);
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
const result = wasm.WsRunResult_block_count_of(diplomatReceive.buffer, this.ffiValue, index);
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
if (!diplomatReceive.resultFlag) {
|
|
265
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
266
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
267
|
+
}
|
|
268
|
+
return (new BigUint64Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
finally {
|
|
272
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
273
|
+
diplomatReceive.free();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The build's world-space bounding box minimum (inclusive).
|
|
279
|
+
*/
|
|
280
|
+
bboxMinOf(index) {
|
|
281
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true);
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
const result = wasm.WsRunResult_bbox_min_of(diplomatReceive.buffer, this.ffiValue, index);
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
if (!diplomatReceive.resultFlag) {
|
|
288
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
289
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
290
|
+
}
|
|
291
|
+
return BlockPos._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
finally {
|
|
295
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
296
|
+
diplomatReceive.free();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* The build's world-space bounding box maximum (inclusive).
|
|
302
|
+
*/
|
|
303
|
+
bboxMaxOf(index) {
|
|
304
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true);
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
const result = wasm.WsRunResult_bbox_max_of(diplomatReceive.buffer, this.ffiValue, index);
|
|
308
|
+
|
|
309
|
+
try {
|
|
310
|
+
if (!diplomatReceive.resultFlag) {
|
|
311
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
312
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
313
|
+
}
|
|
314
|
+
return BlockPos._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
finally {
|
|
318
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
319
|
+
diplomatReceive.free();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
constructor(symbol, ptr, selfEdge) {
|
|
324
|
+
return this.#internalConstructor(...arguments)
|
|
325
|
+
}
|
|
326
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* One segmentation run's parameters (the primitive knobs of
|
|
9
|
+
* {@link SegmentJob}(crate::world_segment::runner::SegmentJob), plus a
|
|
10
|
+
* `hard_cut` flag selecting {@link PartitionPolicy}). Built once, passed by
|
|
11
|
+
* reference into {@link WsRunResult::run_dir}.
|
|
12
|
+
*/
|
|
13
|
+
export class WsSegmentJob {
|
|
14
|
+
/** @internal */
|
|
15
|
+
get ffiValue(): pointer;
|
|
16
|
+
/** @internal */
|
|
17
|
+
constructor();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `algorithm_version` is pinned to
|
|
22
|
+
* {@link SegConfig::default}(crate::world_segment::segment::SegConfig)'s
|
|
23
|
+
* value; `score_config` uses `ScoreConfig::default()`. Neither is
|
|
24
|
+
* exposed as a knob here — construct a `SegmentJob` directly in Rust
|
|
25
|
+
* if you need to override them.
|
|
26
|
+
*/
|
|
27
|
+
static create(cellSize: number, closingRadius: number, minClusterBlocks: bigint, sourceId: string, snapshotId: string, minY: number, maxY: number, extractedAt: bigint, matchIou: number, hardCut: boolean): WsSegmentJob;
|
|
28
|
+
}
|
package/WsSegmentJob.mjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
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 WsSegmentJob_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.WsSegmentJob_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* One segmentation run's parameters (the primitive knobs of
|
|
12
|
+
* {@link SegmentJob}(crate::world_segment::runner::SegmentJob), plus a
|
|
13
|
+
* `hard_cut` flag selecting {@link PartitionPolicy}). Built once, passed by
|
|
14
|
+
* reference into {@link WsRunResult::run_dir}.
|
|
15
|
+
*/
|
|
16
|
+
export class WsSegmentJob {
|
|
17
|
+
// Internal ptr reference:
|
|
18
|
+
#ptr = null;
|
|
19
|
+
|
|
20
|
+
// Lifetimes are only to keep dependencies alive.
|
|
21
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
22
|
+
#selfEdge = [];
|
|
23
|
+
|
|
24
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
25
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
26
|
+
console.error("WsSegmentJob is an Opaque type. You cannot call its constructor.");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.#ptr = ptr;
|
|
30
|
+
this.#selfEdge = selfEdge;
|
|
31
|
+
|
|
32
|
+
// Are we being borrowed? If not, we can register.
|
|
33
|
+
if (this.#selfEdge.length === 0) {
|
|
34
|
+
WsSegmentJob_box_destroy_registry.register(this, this.#ptr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/** @internal */
|
|
40
|
+
get ffiValue() {
|
|
41
|
+
return this.#ptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `algorithm_version` is pinned to
|
|
47
|
+
* {@link SegConfig::default}(crate::world_segment::segment::SegConfig)'s
|
|
48
|
+
* value; `score_config` uses `ScoreConfig::default()`. Neither is
|
|
49
|
+
* exposed as a knob here — construct a `SegmentJob` directly in Rust
|
|
50
|
+
* if you need to override them.
|
|
51
|
+
*/
|
|
52
|
+
static create(cellSize, closingRadius, minClusterBlocks, sourceId, snapshotId, minY, maxY, extractedAt, matchIou, hardCut) {
|
|
53
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
54
|
+
|
|
55
|
+
const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
|
|
56
|
+
const snapshotIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, snapshotId)));
|
|
57
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const result = wasm.WsSegmentJob_create(diplomatReceive.buffer, cellSize, closingRadius, minClusterBlocks, sourceIdSlice.ptr, snapshotIdSlice.ptr, minY, maxY, extractedAt, matchIou, hardCut);
|
|
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 new WsSegmentJob(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
finally {
|
|
71
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
72
|
+
functionCleanupArena.free();
|
|
73
|
+
|
|
74
|
+
diplomatReceive.free();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
constructor(symbol, ptr, selfEdge) {
|
|
79
|
+
return this.#internalConstructor(...arguments)
|
|
80
|
+
}
|
|
81
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export { AnimationEffect } from "./AnimationEffect"
|
|
|
20
20
|
|
|
21
21
|
export { BuildAnimation } from "./BuildAnimation"
|
|
22
22
|
|
|
23
|
+
export { VideoConfig } from "./VideoConfig"
|
|
24
|
+
|
|
23
25
|
export { Autostack } from "./Autostack"
|
|
24
26
|
|
|
25
27
|
export { Blocks } from "./Blocks"
|
|
@@ -118,6 +120,14 @@ export { StoreIo } from "./StoreIo"
|
|
|
118
120
|
|
|
119
121
|
export { Voxelizer } from "./Voxelizer"
|
|
120
122
|
|
|
123
|
+
export { WsPartitionHints } from "./WsPartitionHints"
|
|
124
|
+
|
|
125
|
+
export { WsProfile } from "./WsProfile"
|
|
126
|
+
|
|
127
|
+
export { WsRunResult } from "./WsRunResult"
|
|
128
|
+
|
|
129
|
+
export { WsSegmentJob } from "./WsSegmentJob"
|
|
130
|
+
|
|
121
131
|
export { WorldChunkView } from "./WorldChunkView"
|
|
122
132
|
|
|
123
133
|
export { WorldSink } from "./WorldSink"
|
package/index.mjs
CHANGED
|
@@ -18,6 +18,8 @@ export { AnimationEffect } from "./AnimationEffect.mjs"
|
|
|
18
18
|
|
|
19
19
|
export { BuildAnimation } from "./BuildAnimation.mjs"
|
|
20
20
|
|
|
21
|
+
export { VideoConfig } from "./VideoConfig.mjs"
|
|
22
|
+
|
|
21
23
|
export { Autostack } from "./Autostack.mjs"
|
|
22
24
|
|
|
23
25
|
export { Blocks } from "./Blocks.mjs"
|
|
@@ -116,6 +118,14 @@ export { StoreIo } from "./StoreIo.mjs"
|
|
|
116
118
|
|
|
117
119
|
export { Voxelizer } from "./Voxelizer.mjs"
|
|
118
120
|
|
|
121
|
+
export { WsPartitionHints } from "./WsPartitionHints.mjs"
|
|
122
|
+
|
|
123
|
+
export { WsProfile } from "./WsProfile.mjs"
|
|
124
|
+
|
|
125
|
+
export { WsRunResult } from "./WsRunResult.mjs"
|
|
126
|
+
|
|
127
|
+
export { WsSegmentJob } from "./WsSegmentJob.mjs"
|
|
128
|
+
|
|
119
129
|
export { WorldChunkView } from "./WorldChunkView.mjs"
|
|
120
130
|
|
|
121
131
|
export { WorldSink } from "./WorldSink.mjs"
|
package/nucleation.wasm
CHANGED
|
Binary file
|