nucleation 0.10.21 → 0.10.22
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/BlockPos.mjs +1 -0
- package/Dimensions.mjs +1 -0
- package/FieldRange.mjs +1 -0
- package/ItemScale.mjs +1 -0
- package/MeshBounds.mjs +1 -0
- package/MeshProgress.mjs +1 -0
- package/RegionBounds.mjs +1 -0
- package/Schematic.d.mts +9 -0
- package/Schematic.d.ts +9 -0
- package/Schematic.mjs +30 -0
- package/SdfBounds.mjs +1 -0
- package/SdfNormal.mjs +1 -0
- package/TextureInfo.mjs +1 -0
- package/diplomat-runtime.mjs +19 -14
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
package/BlockPos.mjs
CHANGED
|
@@ -108,6 +108,7 @@ export class BlockPos {
|
|
|
108
108
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
109
109
|
// should handle this when constructing edge arrays.
|
|
110
110
|
static _fromFFI(internalConstructor, ptr) {
|
|
111
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
111
112
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
112
113
|
throw new Error("BlockPos._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
113
114
|
}
|
package/Dimensions.mjs
CHANGED
|
@@ -108,6 +108,7 @@ export class Dimensions {
|
|
|
108
108
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
109
109
|
// should handle this when constructing edge arrays.
|
|
110
110
|
static _fromFFI(internalConstructor, ptr) {
|
|
111
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
111
112
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
112
113
|
throw new Error("Dimensions._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
113
114
|
}
|
package/FieldRange.mjs
CHANGED
|
@@ -89,6 +89,7 @@ export class FieldRange {
|
|
|
89
89
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
90
90
|
// should handle this when constructing edge arrays.
|
|
91
91
|
static _fromFFI(internalConstructor, ptr) {
|
|
92
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
92
93
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
93
94
|
throw new Error("FieldRange._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
94
95
|
}
|
package/ItemScale.mjs
CHANGED
|
@@ -111,6 +111,7 @@ export class ItemScale {
|
|
|
111
111
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
112
112
|
// should handle this when constructing edge arrays.
|
|
113
113
|
static _fromFFI(internalConstructor, ptr) {
|
|
114
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
114
115
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
115
116
|
throw new Error("ItemScale._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
116
117
|
}
|
package/MeshBounds.mjs
CHANGED
|
@@ -153,6 +153,7 @@ export class MeshBounds {
|
|
|
153
153
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
154
154
|
// should handle this when constructing edge arrays.
|
|
155
155
|
static _fromFFI(internalConstructor, ptr) {
|
|
156
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
156
157
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
157
158
|
throw new Error("MeshBounds._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
158
159
|
}
|
package/MeshProgress.mjs
CHANGED
|
@@ -112,6 +112,7 @@ export class MeshProgress {
|
|
|
112
112
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
113
113
|
// should handle this when constructing edge arrays.
|
|
114
114
|
static _fromFFI(internalConstructor, ptr) {
|
|
115
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
115
116
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
116
117
|
throw new Error("MeshProgress._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
117
118
|
}
|
package/RegionBounds.mjs
CHANGED
|
@@ -154,6 +154,7 @@ export class RegionBounds {
|
|
|
154
154
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
155
155
|
// should handle this when constructing edge arrays.
|
|
156
156
|
static _fromFFI(internalConstructor, ptr) {
|
|
157
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
157
158
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
158
159
|
throw new Error("RegionBounds._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
159
160
|
}
|
package/Schematic.d.mts
CHANGED
|
@@ -492,6 +492,15 @@ export class Schematic {
|
|
|
492
492
|
*/
|
|
493
493
|
getChunkBlocksJson(offsetX: number, offsetY: number, offsetZ: number, width: number, height: number, length: number): string;
|
|
494
494
|
|
|
495
|
+
/**
|
|
496
|
+
* Non-air blocks inside a bounded box, retaining block-state properties.
|
|
497
|
+
* Visits only intersecting region cells, not the whole schematic. Bounds
|
|
498
|
+
* and arithmetic are checked; queries may scan at most 1,048,576 cells
|
|
499
|
+
* (including region overlaps) and emit at most 32 MiB of JSON. Renderers
|
|
500
|
+
* should request 16³ sections. Coordinates may be negative.
|
|
501
|
+
*/
|
|
502
|
+
getChunkNonAirBlocksJson(offsetX: number, offsetY: number, offsetZ: number, width: number, height: number, length: number): string;
|
|
503
|
+
|
|
495
504
|
/**
|
|
496
505
|
* Split the schematic into chunks (default bottom-up strategy). Writes a
|
|
497
506
|
* JSON array of `{"chunk_x", "chunk_y", "chunk_z", "blocks": [...]}` where
|
package/Schematic.d.ts
CHANGED
|
@@ -492,6 +492,15 @@ export class Schematic {
|
|
|
492
492
|
*/
|
|
493
493
|
getChunkBlocksJson(offsetX: number, offsetY: number, offsetZ: number, width: number, height: number, length: number): string;
|
|
494
494
|
|
|
495
|
+
/**
|
|
496
|
+
* Non-air blocks inside a bounded box, retaining block-state properties.
|
|
497
|
+
* Visits only intersecting region cells, not the whole schematic. Bounds
|
|
498
|
+
* and arithmetic are checked; queries may scan at most 1,048,576 cells
|
|
499
|
+
* (including region overlaps) and emit at most 32 MiB of JSON. Renderers
|
|
500
|
+
* should request 16³ sections. Coordinates may be negative.
|
|
501
|
+
*/
|
|
502
|
+
getChunkNonAirBlocksJson(offsetX: number, offsetY: number, offsetZ: number, width: number, height: number, length: number): string;
|
|
503
|
+
|
|
495
504
|
/**
|
|
496
505
|
* Split the schematic into chunks (default bottom-up strategy). Writes a
|
|
497
506
|
* JSON array of `{"chunk_x", "chunk_y", "chunk_z", "blocks": [...]}` where
|
package/Schematic.mjs
CHANGED
|
@@ -1929,6 +1929,36 @@ export class Schematic {
|
|
|
1929
1929
|
}
|
|
1930
1930
|
}
|
|
1931
1931
|
|
|
1932
|
+
/**
|
|
1933
|
+
* Non-air blocks inside a bounded box, retaining block-state properties.
|
|
1934
|
+
* Visits only intersecting region cells, not the whole schematic. Bounds
|
|
1935
|
+
* and arithmetic are checked; queries may scan at most 1,048,576 cells
|
|
1936
|
+
* (including region overlaps) and emit at most 32 MiB of JSON. Renderers
|
|
1937
|
+
* should request 16³ sections. Coordinates may be negative.
|
|
1938
|
+
*/
|
|
1939
|
+
getChunkNonAirBlocksJson(offsetX, offsetY, offsetZ, width, height, length) {
|
|
1940
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1941
|
+
|
|
1942
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1943
|
+
|
|
1944
|
+
|
|
1945
|
+
const result = wasm.Schematic_get_chunk_non_air_blocks_json(diplomatReceive.buffer, this.ffiValue, offsetX, offsetY, offsetZ, width, height, length, write.buffer);
|
|
1946
|
+
|
|
1947
|
+
try {
|
|
1948
|
+
if (!diplomatReceive.resultFlag) {
|
|
1949
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1950
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1951
|
+
}
|
|
1952
|
+
return write.readString8();
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
finally {
|
|
1956
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1957
|
+
diplomatReceive.free();
|
|
1958
|
+
write.free();
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1932
1962
|
/**
|
|
1933
1963
|
* Split the schematic into chunks (default bottom-up strategy). Writes a
|
|
1934
1964
|
* JSON array of `{"chunk_x", "chunk_y", "chunk_z", "blocks": [...]}` where
|
package/SdfBounds.mjs
CHANGED
|
@@ -133,6 +133,7 @@ export class SdfBounds {
|
|
|
133
133
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
134
134
|
// should handle this when constructing edge arrays.
|
|
135
135
|
static _fromFFI(internalConstructor, ptr) {
|
|
136
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
136
137
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
137
138
|
throw new Error("SdfBounds._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
138
139
|
}
|
package/SdfNormal.mjs
CHANGED
|
@@ -100,6 +100,7 @@ export class SdfNormal {
|
|
|
100
100
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
101
101
|
// should handle this when constructing edge arrays.
|
|
102
102
|
static _fromFFI(internalConstructor, ptr) {
|
|
103
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
103
104
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
104
105
|
throw new Error("SdfNormal._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
105
106
|
}
|
package/TextureInfo.mjs
CHANGED
|
@@ -125,6 +125,7 @@ export class TextureInfo {
|
|
|
125
125
|
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
126
126
|
// should handle this when constructing edge arrays.
|
|
127
127
|
static _fromFFI(internalConstructor, ptr) {
|
|
128
|
+
ptr >>>= 0; // unsigned wasm32 address; field values retain their signedness.
|
|
128
129
|
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
129
130
|
throw new Error("TextureInfo._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
130
131
|
}
|
package/diplomat-runtime.mjs
CHANGED
|
@@ -8,11 +8,13 @@ export const internalConstructor = Symbol("constructor");
|
|
|
8
8
|
export const exposeConstructor = Symbol("exposeConstructor");
|
|
9
9
|
|
|
10
10
|
export function readString8(wasm, ptr, len) {
|
|
11
|
+
ptr >>>= 0; // wasm32 addresses are unsigned, including above 2 GiB.
|
|
11
12
|
const buf = new Uint8Array(wasm.memory.buffer, ptr, len);
|
|
12
13
|
return (new TextDecoder("utf-8")).decode(buf)
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function readString16(wasm, ptr, len) {
|
|
17
|
+
ptr >>>= 0; // wasm32 addresses are unsigned, including above 2 GiB.
|
|
16
18
|
const buf = new Uint16Array(wasm.memory.buffer, ptr, len);
|
|
17
19
|
return String.fromCharCode.apply(null, buf)
|
|
18
20
|
}
|
|
@@ -48,6 +50,7 @@ export function withDiplomatWrite(wasm, callback) {
|
|
|
48
50
|
* @returns {number} The underlying pointer.
|
|
49
51
|
*/
|
|
50
52
|
export function ptrRead(wasm, ptr) {
|
|
53
|
+
ptr >>>= 0; // wasm32 addresses are unsigned, including above 2 GiB.
|
|
51
54
|
return (new Uint32Array(wasm.memory.buffer, ptr, 1))[0];
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -55,6 +58,7 @@ export function ptrRead(wasm, ptr) {
|
|
|
55
58
|
* Get the flag of a result type.
|
|
56
59
|
*/
|
|
57
60
|
export function resultFlag(wasm, ptr, offset) {
|
|
61
|
+
ptr >>>= 0; // wasm32 addresses are unsigned, including above 2 GiB.
|
|
58
62
|
return (new Uint8Array(wasm.memory.buffer, ptr + offset, 1))[0];
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -62,6 +66,7 @@ export function resultFlag(wasm, ptr, offset) {
|
|
|
62
66
|
* Get the discriminant of a Rust enum.
|
|
63
67
|
*/
|
|
64
68
|
export function enumDiscriminant(wasm, ptr) {
|
|
69
|
+
ptr >>>= 0; // wasm32 addresses are unsigned, including above 2 GiB.
|
|
65
70
|
return (new Int32Array(wasm.memory.buffer, ptr, 1))[0]
|
|
66
71
|
}
|
|
67
72
|
|
|
@@ -83,7 +88,7 @@ export function maybePaddingFields(needsPaddingFields, paddingCount) {
|
|
|
83
88
|
* (which is a `TypedArray` variant like `Uint8Array` or `Int16Array`)
|
|
84
89
|
*/
|
|
85
90
|
export function writeToArrayBuffer(arrayBuffer, offset, value, typedArrayKind) {
|
|
86
|
-
let buffer = new typedArrayKind(arrayBuffer, offset);
|
|
91
|
+
let buffer = new typedArrayKind(arrayBuffer, offset < 0 ? offset >>> 0 : offset);
|
|
87
92
|
buffer[0] = value;
|
|
88
93
|
}
|
|
89
94
|
|
|
@@ -223,7 +228,7 @@ export class DiplomatBuf {
|
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
|
|
226
|
-
const ptr = wasm.diplomat_alloc(utf8Length, 1);
|
|
231
|
+
const ptr = wasm.diplomat_alloc(utf8Length, 1) >>> 0;
|
|
227
232
|
|
|
228
233
|
const result = (new TextEncoder()).encodeInto(string, new Uint8Array(wasm.memory.buffer, ptr, utf8Length));
|
|
229
234
|
console.assert(string.length === result.read && utf8Length === result.written, "UTF-8 write error");
|
|
@@ -233,7 +238,7 @@ export class DiplomatBuf {
|
|
|
233
238
|
|
|
234
239
|
static str16 = (wasm, string) => {
|
|
235
240
|
const byteLength = string.length * 2;
|
|
236
|
-
const ptr = wasm.diplomat_alloc(byteLength, 2);
|
|
241
|
+
const ptr = wasm.diplomat_alloc(byteLength, 2) >>> 0;
|
|
237
242
|
|
|
238
243
|
const destination = new Uint16Array(wasm.memory.buffer, ptr, string.length);
|
|
239
244
|
for (let i = 0; i < string.length; i++) {
|
|
@@ -244,7 +249,7 @@ export class DiplomatBuf {
|
|
|
244
249
|
}
|
|
245
250
|
|
|
246
251
|
static sliceWrapper = (wasm, buf) => {
|
|
247
|
-
const ptr = wasm.diplomat_alloc(8, 4);
|
|
252
|
+
const ptr = wasm.diplomat_alloc(8, 4) >>> 0;
|
|
248
253
|
let dst = new Uint32Array(wasm.memory.buffer, ptr, 2);
|
|
249
254
|
|
|
250
255
|
dst[0] = buf.ptr;
|
|
@@ -262,7 +267,7 @@ export class DiplomatBuf {
|
|
|
262
267
|
4;
|
|
263
268
|
|
|
264
269
|
const byteLength = list.length * elementSize;
|
|
265
|
-
const ptr = wasm.diplomat_alloc(byteLength, elementSize);
|
|
270
|
+
const ptr = wasm.diplomat_alloc(byteLength, elementSize) >>> 0;
|
|
266
271
|
|
|
267
272
|
/**
|
|
268
273
|
* Create an array view of the buffer. This gives us the `set` method which correctly handles untyped values
|
|
@@ -288,15 +293,15 @@ export class DiplomatBuf {
|
|
|
288
293
|
|
|
289
294
|
const byteLength = strings.length * 4 * 2;
|
|
290
295
|
|
|
291
|
-
const ptr = wasm.diplomat_alloc(byteLength, 4);
|
|
296
|
+
const ptr = wasm.diplomat_alloc(byteLength, 4) >>> 0;
|
|
292
297
|
|
|
293
|
-
const destination = new Uint32Array(wasm.memory.buffer, ptr, byteLength);
|
|
294
298
|
|
|
295
299
|
const stringsAlloc = [];
|
|
296
300
|
|
|
297
301
|
for (let i = 0; i < strings.length; i++) {
|
|
298
302
|
stringsAlloc.push(encodeStr(wasm, strings[i]));
|
|
299
303
|
|
|
304
|
+
const destination = new Uint32Array(wasm.memory.buffer, ptr, strings.length * 2);
|
|
300
305
|
destination[2 * i] = stringsAlloc[i].ptr;
|
|
301
306
|
destination[(2 * i) + 1] = stringsAlloc[i].size;
|
|
302
307
|
}
|
|
@@ -310,7 +315,7 @@ export class DiplomatBuf {
|
|
|
310
315
|
}
|
|
311
316
|
|
|
312
317
|
static struct = (wasm, size, align) => {
|
|
313
|
-
const ptr = wasm.diplomat_alloc(size, align);
|
|
318
|
+
const ptr = wasm.diplomat_alloc(size, align) >>> 0;
|
|
314
319
|
|
|
315
320
|
return new DiplomatBuf(ptr, size, () => {
|
|
316
321
|
wasm.diplomat_free(ptr, size, align);
|
|
@@ -325,7 +330,7 @@ export class DiplomatBuf {
|
|
|
325
330
|
free;
|
|
326
331
|
|
|
327
332
|
constructor(ptr, size, free) {
|
|
328
|
-
this.ptr = ptr;
|
|
333
|
+
this.ptr = ptr >>> 0;
|
|
329
334
|
this.size = size;
|
|
330
335
|
this.free = free;
|
|
331
336
|
this.leak = () => { };
|
|
@@ -357,7 +362,7 @@ export class DiplomatWriteBuf {
|
|
|
357
362
|
|
|
358
363
|
constructor(wasm) {
|
|
359
364
|
this.#wasm = wasm;
|
|
360
|
-
this.#buffer = this.#wasm.diplomat_buffer_write_create(0);
|
|
365
|
+
this.#buffer = this.#wasm.diplomat_buffer_write_create(0) >>> 0;
|
|
361
366
|
|
|
362
367
|
this.leak = () => { };
|
|
363
368
|
}
|
|
@@ -409,7 +414,7 @@ export class DiplomatSlice {
|
|
|
409
414
|
constructor(wasm, buffer, bufferType, lifetimeEdges) {
|
|
410
415
|
this.#wasm = wasm;
|
|
411
416
|
|
|
412
|
-
const [ptr, size] = new Uint32Array(this.#wasm.memory.buffer, buffer, 2);
|
|
417
|
+
const [ptr, size] = new Uint32Array(this.#wasm.memory.buffer, buffer >>> 0, 2);
|
|
413
418
|
|
|
414
419
|
this.#buffer = new bufferType(this.#wasm.memory.buffer, ptr, size);
|
|
415
420
|
this.#bufferType = bufferType;
|
|
@@ -432,7 +437,7 @@ export class DiplomatSlice {
|
|
|
432
437
|
|
|
433
438
|
export class DiplomatSlicePrimitive extends DiplomatSlice {
|
|
434
439
|
constructor(wasm, buffer, sliceType, lifetimeEdges) {
|
|
435
|
-
const [ptr, size] = new Uint32Array(wasm.memory.buffer, buffer, 2);
|
|
440
|
+
const [ptr, size] = new Uint32Array(wasm.memory.buffer, buffer >>> 0, 2);
|
|
436
441
|
|
|
437
442
|
let arrayType;
|
|
438
443
|
switch (sliceType) {
|
|
@@ -552,7 +557,7 @@ export class DiplomatReceiveBuf {
|
|
|
552
557
|
|
|
553
558
|
this.#hasResult = hasResult;
|
|
554
559
|
|
|
555
|
-
this.#buffer = this.#wasm.diplomat_alloc(this.#size, this.#align);
|
|
560
|
+
this.#buffer = this.#wasm.diplomat_alloc(this.#size, this.#align) >>> 0;
|
|
556
561
|
|
|
557
562
|
this.leak = () => { };
|
|
558
563
|
}
|
|
@@ -736,7 +741,7 @@ export class FunctionParamAllocator {
|
|
|
736
741
|
|
|
737
742
|
this.#capacity = capacity;
|
|
738
743
|
// FunctionParamAllocator is global, so this will be freed when the webpage closes:
|
|
739
|
-
this.#ptr = wasm.diplomat_alloc(this.#capacity, 1);
|
|
744
|
+
this.#ptr = wasm.diplomat_alloc(this.#capacity, 1) >>> 0;
|
|
740
745
|
}
|
|
741
746
|
|
|
742
747
|
/**
|
package/nucleation.wasm
CHANGED
|
Binary file
|