nucleation 0.11.0 → 0.12.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/README.md CHANGED
@@ -62,6 +62,6 @@ available from the main `nucleation` entry point. Each entry owns a separate WAS
62
62
  instance; import only the entry needed by a worker.
63
63
 
64
64
  Use `renderRegionsJson()` for region bounds and palettes, then
65
- `regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of at most
66
- 65,536 cells. Indices use x-fastest, then z, then y order. Call `clearContents()`
65
+ `regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of any
66
+ size (shorter at the end of the region). Indices use x-fastest, then z, then y order. Call `clearContents()`
67
67
  when done to release schematic storage immediately.
package/Schematic.d.mts CHANGED
@@ -68,8 +68,7 @@ export class Schematic {
68
68
  splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
69
69
 
70
70
  /**
71
- * The allocated dimensions (width, height, length) of the schematic's
72
- * bounding box.
71
+ * The dimensions (width, height, length) of the schematic's bounding box.
73
72
  */
74
73
  dimensions(): Dimensions;
75
74
 
@@ -519,17 +518,17 @@ export class Schematic {
519
518
 
520
519
  /**
521
520
  * Storage metadata and full block states for palette-index streaming. Region order
522
- * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. Bounds
523
- * describe allocated storage, never tight bounds. x is fastest, then z, then y.
521
+ * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
522
+ * and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
524
523
  * No block buffer is cloned or serialized here.
525
524
  */
526
525
  renderRegionsJson(): string;
527
526
 
528
527
  /**
529
- * A bounded window of a region's dense palette indices (including air).
530
- * At most 65,536 cells per call; no full-world scan, coordinate tuples, or
531
- * intermediate Rust allocation. JS bindings copy the borrowed slice before
532
- * returning, so callers may mutate the schematic or grow WASM memory safely.
528
+ * Copy a window of a region's palette indices (air included) into `out`:
529
+ * cells `start..start + out.len()` of its bounds, in `render_regions_json`
530
+ * order. Returns the number of cells written (fewer than `out.len()` at the
531
+ * end of the region). No coordinate tuples or intermediate allocation.
533
532
  */
534
533
  regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
535
534
 
@@ -909,8 +908,9 @@ export class Schematic {
909
908
  tightDimensions(): Dimensions;
910
909
 
911
910
  /**
912
- * The allocated dimensions (same as `dimensions`; named for parity with
913
- * the old `schematic_get_allocated_dimensions`).
911
+ * The default region's storage dimensions: its bounds plus growth
912
+ * padding (named for parity with the old
913
+ * `schematic_get_allocated_dimensions`).
914
914
  */
915
915
  allocatedDimensions(): Dimensions;
916
916
 
package/Schematic.d.ts CHANGED
@@ -68,8 +68,7 @@ export class Schematic {
68
68
  splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
69
69
 
70
70
  /**
71
- * The allocated dimensions (width, height, length) of the schematic's
72
- * bounding box.
71
+ * The dimensions (width, height, length) of the schematic's bounding box.
73
72
  */
74
73
  dimensions(): Dimensions;
75
74
 
@@ -519,17 +518,17 @@ export class Schematic {
519
518
 
520
519
  /**
521
520
  * Storage metadata and full block states for palette-index streaming. Region order
522
- * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. Bounds
523
- * describe allocated storage, never tight bounds. x is fastest, then z, then y.
521
+ * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
522
+ * and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
524
523
  * No block buffer is cloned or serialized here.
525
524
  */
526
525
  renderRegionsJson(): string;
527
526
 
528
527
  /**
529
- * A bounded window of a region's dense palette indices (including air).
530
- * At most 65,536 cells per call; no full-world scan, coordinate tuples, or
531
- * intermediate Rust allocation. JS bindings copy the borrowed slice before
532
- * returning, so callers may mutate the schematic or grow WASM memory safely.
528
+ * Copy a window of a region's palette indices (air included) into `out`:
529
+ * cells `start..start + out.len()` of its bounds, in `render_regions_json`
530
+ * order. Returns the number of cells written (fewer than `out.len()` at the
531
+ * end of the region). No coordinate tuples or intermediate allocation.
533
532
  */
534
533
  regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
535
534
 
@@ -909,8 +908,9 @@ export class Schematic {
909
908
  tightDimensions(): Dimensions;
910
909
 
911
910
  /**
912
- * The allocated dimensions (same as `dimensions`; named for parity with
913
- * the old `schematic_get_allocated_dimensions`).
911
+ * The default region's storage dimensions: its bounds plus growth
912
+ * padding (named for parity with the old
913
+ * `schematic_get_allocated_dimensions`).
914
914
  */
915
915
  allocatedDimensions(): Dimensions;
916
916
 
package/Schematic.mjs CHANGED
@@ -217,8 +217,7 @@ export class Schematic {
217
217
  }
218
218
 
219
219
  /**
220
- * The allocated dimensions (width, height, length) of the schematic's
221
- * bounding box.
220
+ * The dimensions (width, height, length) of the schematic's bounding box.
222
221
  */
223
222
  dimensions() {
224
223
  const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
@@ -2010,8 +2009,8 @@ export class Schematic {
2010
2009
 
2011
2010
  /**
2012
2011
  * Storage metadata and full block states for palette-index streaming. Region order
2013
- * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. Bounds
2014
- * describe allocated storage, never tight bounds. x is fastest, then z, then y.
2012
+ * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
2013
+ * and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
2015
2014
  * No block buffer is cloned or serialized here.
2016
2015
  */
2017
2016
  renderRegionsJson() {
@@ -2030,29 +2029,29 @@ export class Schematic {
2030
2029
  }
2031
2030
 
2032
2031
  /**
2033
- * A bounded window of a region's dense palette indices (including air).
2034
- * At most 65,536 cells per call; no full-world scan, coordinate tuples, or
2035
- * intermediate Rust allocation. JS bindings copy the borrowed slice before
2036
- * returning, so callers may mutate the schematic or grow WASM memory safely.
2032
+ * Copy a window of a region's palette indices (air included) into `out`:
2033
+ * cells `start..start + out.len()` of its bounds, in `render_regions_json`
2034
+ * order. Returns the number of cells written (fewer than `out.len()` at the
2035
+ * end of the region). No coordinate tuples or intermediate allocation.
2037
2036
  */
2038
2037
  regionBlockIndices(regionName, start, count) {
2039
2038
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
2040
2039
 
2041
2040
  const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
2042
- const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);
2043
-
2044
- // This lifetime edge depends on lifetimes 'a
2045
- let aEdges = [this];
2041
+ const outBuf = diplomatRuntime.DiplomatBuf.slice(wasm, new Uint32Array(count), "u32");
2042
+ const outSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, outBuf));
2043
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2046
2044
 
2047
2045
 
2048
- const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start, count);
2046
+ const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start, outSlice.ptr);
2049
2047
 
2050
2048
  try {
2051
2049
  if (!diplomatReceive.resultFlag) {
2052
2050
  const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2053
2051
  throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2054
2052
  }
2055
- return new diplomatRuntime.DiplomatSlicePrimitive(wasm, diplomatReceive.buffer, "u32", aEdges).getValue().slice();
2053
+ const written = (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
2054
+ return new Uint32Array(wasm.memory.buffer, outBuf.ptr, written).slice();
2056
2055
  }
2057
2056
 
2058
2057
  finally {
@@ -3552,8 +3551,9 @@ export class Schematic {
3552
3551
  }
3553
3552
 
3554
3553
  /**
3555
- * The allocated dimensions (same as `dimensions`; named for parity with
3556
- * the old `schematic_get_allocated_dimensions`).
3554
+ * The default region's storage dimensions: its bounds plus growth
3555
+ * padding (named for parity with the old
3556
+ * `schematic_get_allocated_dimensions`).
3557
3557
  */
3558
3558
  allocatedDimensions() {
3559
3559
  const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
package/nucleation.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleation",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "A high-performance Minecraft schematic parser and utility library",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
@@ -62,6 +62,6 @@ available from the main `nucleation` entry point. Each entry owns a separate WAS
62
62
  instance; import only the entry needed by a worker.
63
63
 
64
64
  Use `renderRegionsJson()` for region bounds and palettes, then
65
- `regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of at most
66
- 65,536 cells. Indices use x-fastest, then z, then y order. Call `clearContents()`
65
+ `regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of any
66
+ size (shorter at the end of the region). Indices use x-fastest, then z, then y order. Call `clearContents()`
67
67
  when done to release schematic storage immediately.
@@ -68,8 +68,7 @@ export class Schematic {
68
68
  splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
69
69
 
70
70
  /**
71
- * The allocated dimensions (width, height, length) of the schematic's
72
- * bounding box.
71
+ * The dimensions (width, height, length) of the schematic's bounding box.
73
72
  */
74
73
  dimensions(): Dimensions;
75
74
 
@@ -519,17 +518,17 @@ export class Schematic {
519
518
 
520
519
  /**
521
520
  * Storage metadata and full block states for palette-index streaming. Region order
522
- * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. Bounds
523
- * describe allocated storage, never tight bounds. x is fastest, then z, then y.
521
+ * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
522
+ * and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
524
523
  * No block buffer is cloned or serialized here.
525
524
  */
526
525
  renderRegionsJson(): string;
527
526
 
528
527
  /**
529
- * A bounded window of a region's dense palette indices (including air).
530
- * At most 65,536 cells per call; no full-world scan, coordinate tuples, or
531
- * intermediate Rust allocation. JS bindings copy the borrowed slice before
532
- * returning, so callers may mutate the schematic or grow WASM memory safely.
528
+ * Copy a window of a region's palette indices (air included) into `out`:
529
+ * cells `start..start + out.len()` of its bounds, in `render_regions_json`
530
+ * order. Returns the number of cells written (fewer than `out.len()` at the
531
+ * end of the region). No coordinate tuples or intermediate allocation.
533
532
  */
534
533
  regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
535
534
 
@@ -909,8 +908,9 @@ export class Schematic {
909
908
  tightDimensions(): Dimensions;
910
909
 
911
910
  /**
912
- * The allocated dimensions (same as `dimensions`; named for parity with
913
- * the old `schematic_get_allocated_dimensions`).
911
+ * The default region's storage dimensions: its bounds plus growth
912
+ * padding (named for parity with the old
913
+ * `schematic_get_allocated_dimensions`).
914
914
  */
915
915
  allocatedDimensions(): Dimensions;
916
916
 
@@ -68,8 +68,7 @@ export class Schematic {
68
68
  splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
69
69
 
70
70
  /**
71
- * The allocated dimensions (width, height, length) of the schematic's
72
- * bounding box.
71
+ * The dimensions (width, height, length) of the schematic's bounding box.
73
72
  */
74
73
  dimensions(): Dimensions;
75
74
 
@@ -519,17 +518,17 @@ export class Schematic {
519
518
 
520
519
  /**
521
520
  * Storage metadata and full block states for palette-index streaming. Region order
522
- * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. Bounds
523
- * describe allocated storage, never tight bounds. x is fastest, then z, then y.
521
+ * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
522
+ * and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
524
523
  * No block buffer is cloned or serialized here.
525
524
  */
526
525
  renderRegionsJson(): string;
527
526
 
528
527
  /**
529
- * A bounded window of a region's dense palette indices (including air).
530
- * At most 65,536 cells per call; no full-world scan, coordinate tuples, or
531
- * intermediate Rust allocation. JS bindings copy the borrowed slice before
532
- * returning, so callers may mutate the schematic or grow WASM memory safely.
528
+ * Copy a window of a region's palette indices (air included) into `out`:
529
+ * cells `start..start + out.len()` of its bounds, in `render_regions_json`
530
+ * order. Returns the number of cells written (fewer than `out.len()` at the
531
+ * end of the region). No coordinate tuples or intermediate allocation.
533
532
  */
534
533
  regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
535
534
 
@@ -909,8 +908,9 @@ export class Schematic {
909
908
  tightDimensions(): Dimensions;
910
909
 
911
910
  /**
912
- * The allocated dimensions (same as `dimensions`; named for parity with
913
- * the old `schematic_get_allocated_dimensions`).
911
+ * The default region's storage dimensions: its bounds plus growth
912
+ * padding (named for parity with the old
913
+ * `schematic_get_allocated_dimensions`).
914
914
  */
915
915
  allocatedDimensions(): Dimensions;
916
916
 
@@ -217,8 +217,7 @@ export class Schematic {
217
217
  }
218
218
 
219
219
  /**
220
- * The allocated dimensions (width, height, length) of the schematic's
221
- * bounding box.
220
+ * The dimensions (width, height, length) of the schematic's bounding box.
222
221
  */
223
222
  dimensions() {
224
223
  const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
@@ -2010,8 +2009,8 @@ export class Schematic {
2010
2009
 
2011
2010
  /**
2012
2011
  * Storage metadata and full block states for palette-index streaming. Region order
2013
- * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. Bounds
2014
- * describe allocated storage, never tight bounds. x is fastest, then z, then y.
2012
+ * is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
2013
+ * and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
2015
2014
  * No block buffer is cloned or serialized here.
2016
2015
  */
2017
2016
  renderRegionsJson() {
@@ -2030,29 +2029,29 @@ export class Schematic {
2030
2029
  }
2031
2030
 
2032
2031
  /**
2033
- * A bounded window of a region's dense palette indices (including air).
2034
- * At most 65,536 cells per call; no full-world scan, coordinate tuples, or
2035
- * intermediate Rust allocation. JS bindings copy the borrowed slice before
2036
- * returning, so callers may mutate the schematic or grow WASM memory safely.
2032
+ * Copy a window of a region's palette indices (air included) into `out`:
2033
+ * cells `start..start + out.len()` of its bounds, in `render_regions_json`
2034
+ * order. Returns the number of cells written (fewer than `out.len()` at the
2035
+ * end of the region). No coordinate tuples or intermediate allocation.
2037
2036
  */
2038
2037
  regionBlockIndices(regionName, start, count) {
2039
2038
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
2040
2039
 
2041
2040
  const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
2042
- const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);
2043
-
2044
- // This lifetime edge depends on lifetimes 'a
2045
- let aEdges = [this];
2041
+ const outBuf = diplomatRuntime.DiplomatBuf.slice(wasm, new Uint32Array(count), "u32");
2042
+ const outSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, outBuf));
2043
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2046
2044
 
2047
2045
 
2048
- const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start, count);
2046
+ const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start, outSlice.ptr);
2049
2047
 
2050
2048
  try {
2051
2049
  if (!diplomatReceive.resultFlag) {
2052
2050
  const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2053
2051
  throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2054
2052
  }
2055
- return new diplomatRuntime.DiplomatSlicePrimitive(wasm, diplomatReceive.buffer, "u32", aEdges).getValue().slice();
2053
+ const written = (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
2054
+ return new Uint32Array(wasm.memory.buffer, outBuf.ptr, written).slice();
2056
2055
  }
2057
2056
 
2058
2057
  finally {
@@ -3552,8 +3551,9 @@ export class Schematic {
3552
3551
  }
3553
3552
 
3554
3553
  /**
3555
- * The allocated dimensions (same as `dimensions`; named for parity with
3556
- * the old `schematic_get_allocated_dimensions`).
3554
+ * The default region's storage dimensions: its bounds plus growth
3555
+ * padding (named for parity with the old
3556
+ * `schematic_get_allocated_dimensions`).
3557
3557
  */
3558
3558
  allocatedDimensions() {
3559
3559
  const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
Binary file