nucleation 0.10.16 → 0.10.19
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/Schematic.d.mts +52 -0
- package/Schematic.d.ts +52 -0
- package/Schematic.mjs +101 -0
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
package/Schematic.d.mts
CHANGED
|
@@ -418,6 +418,11 @@ export class Schematic {
|
|
|
418
418
|
* Air cells are materialized too — on a large sparse build this
|
|
419
419
|
* dump is `volume()`-sized and can exhaust wasm memory; renderers
|
|
420
420
|
* and analyzers want `get_non_air_blocks_json`.
|
|
421
|
+
*
|
|
422
|
+
* Prefer `get_non_air_blocks_json` for a block list,
|
|
423
|
+
* `count_blocks_json` for a material tally and
|
|
424
|
+
* `non_air_blocks_packed_b64` for bulk transfer. This method is
|
|
425
|
+
* kept for compatibility and is the wrong tool at any real size.
|
|
421
426
|
*/
|
|
422
427
|
getAllBlocksJson(): string;
|
|
423
428
|
|
|
@@ -434,6 +439,53 @@ export class Schematic {
|
|
|
434
439
|
*/
|
|
435
440
|
getNonAirBlocksJson(): string;
|
|
436
441
|
|
|
442
|
+
/**
|
|
443
|
+
* Non-air blocks tallied by id: `{"minecraft:stone": 123, ...}`.
|
|
444
|
+
* One pass, no per block allocation, so a caller that only wants a
|
|
445
|
+
* material list never has to pull `get_non_air_blocks_json`. "Air"
|
|
446
|
+
* covers `minecraft:air`, `cave_air` and `void_air` alike.
|
|
447
|
+
*/
|
|
448
|
+
countBlocksJson(): string;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Apply a `{"from id": "to id"}` map in place and return how many
|
|
452
|
+
* blocks changed. Keys match on block id only, ignoring block
|
|
453
|
+
* states; values may carry states (`minecraft:oak_stairs[facing=north]`),
|
|
454
|
+
* but not NBT: `parse_block_string` only returns a `BlockState`, so
|
|
455
|
+
* any `{...}` payload on a `to` value is silently dropped rather
|
|
456
|
+
* than copied onto the replaced block.
|
|
457
|
+
* A block whose id is not a key is left alone, and so is one that
|
|
458
|
+
* already equals its target: the count is the number of blocks
|
|
459
|
+
* actually changed, so a map that rewrites stone to stone returns 0.
|
|
460
|
+
* Errors with `Parse` on malformed JSON or an unparseable target id.
|
|
461
|
+
*/
|
|
462
|
+
replaceBlocksJson(mapJson: string): bigint;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Every non-air block as a compact binary blob, base64 encoded
|
|
466
|
+
* (`DiplomatWrite` is UTF-8 only, see `to_litematic_b64`). Little
|
|
467
|
+
* endian throughout:
|
|
468
|
+
*
|
|
469
|
+
* ```text
|
|
470
|
+
* u32 count
|
|
471
|
+
* count * { i32 x, i32 y, i32 z, u16 palette_index }
|
|
472
|
+
* u32 palette_json_len
|
|
473
|
+
* u8[palette_json_len] ["minecraft:stone", ...]
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
476
|
+
* Palette indices are assigned in first-seen order, so the same
|
|
477
|
+
* schematic always packs identically. About seven times smaller
|
|
478
|
+
* than `get_non_air_blocks_json` and free of per block JSON
|
|
479
|
+
* parsing on the far side.
|
|
480
|
+
*
|
|
481
|
+
* Palette indices are `u16`, so at most 65,535 distinct non-air
|
|
482
|
+
* block states can be addressed. A schematic with more than that
|
|
483
|
+
* writes **an empty string**, not a truncated palette: callers must
|
|
484
|
+
* treat an empty result as "too many distinct states, fall back to
|
|
485
|
+
* `get_non_air_blocks_json`". No real build has that many.
|
|
486
|
+
*/
|
|
487
|
+
nonAirBlocksPackedB64(): string;
|
|
488
|
+
|
|
437
489
|
/**
|
|
438
490
|
* All blocks within a sub-region (chunk) of the schematic, as the same
|
|
439
491
|
* JSON array shape as `get_all_blocks_json`.
|
package/Schematic.d.ts
CHANGED
|
@@ -418,6 +418,11 @@ export class Schematic {
|
|
|
418
418
|
* Air cells are materialized too — on a large sparse build this
|
|
419
419
|
* dump is `volume()`-sized and can exhaust wasm memory; renderers
|
|
420
420
|
* and analyzers want `get_non_air_blocks_json`.
|
|
421
|
+
*
|
|
422
|
+
* Prefer `get_non_air_blocks_json` for a block list,
|
|
423
|
+
* `count_blocks_json` for a material tally and
|
|
424
|
+
* `non_air_blocks_packed_b64` for bulk transfer. This method is
|
|
425
|
+
* kept for compatibility and is the wrong tool at any real size.
|
|
421
426
|
*/
|
|
422
427
|
getAllBlocksJson(): string;
|
|
423
428
|
|
|
@@ -434,6 +439,53 @@ export class Schematic {
|
|
|
434
439
|
*/
|
|
435
440
|
getNonAirBlocksJson(): string;
|
|
436
441
|
|
|
442
|
+
/**
|
|
443
|
+
* Non-air blocks tallied by id: `{"minecraft:stone": 123, ...}`.
|
|
444
|
+
* One pass, no per block allocation, so a caller that only wants a
|
|
445
|
+
* material list never has to pull `get_non_air_blocks_json`. "Air"
|
|
446
|
+
* covers `minecraft:air`, `cave_air` and `void_air` alike.
|
|
447
|
+
*/
|
|
448
|
+
countBlocksJson(): string;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Apply a `{"from id": "to id"}` map in place and return how many
|
|
452
|
+
* blocks changed. Keys match on block id only, ignoring block
|
|
453
|
+
* states; values may carry states (`minecraft:oak_stairs[facing=north]`),
|
|
454
|
+
* but not NBT: `parse_block_string` only returns a `BlockState`, so
|
|
455
|
+
* any `{...}` payload on a `to` value is silently dropped rather
|
|
456
|
+
* than copied onto the replaced block.
|
|
457
|
+
* A block whose id is not a key is left alone, and so is one that
|
|
458
|
+
* already equals its target: the count is the number of blocks
|
|
459
|
+
* actually changed, so a map that rewrites stone to stone returns 0.
|
|
460
|
+
* Errors with `Parse` on malformed JSON or an unparseable target id.
|
|
461
|
+
*/
|
|
462
|
+
replaceBlocksJson(mapJson: string): bigint;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Every non-air block as a compact binary blob, base64 encoded
|
|
466
|
+
* (`DiplomatWrite` is UTF-8 only, see `to_litematic_b64`). Little
|
|
467
|
+
* endian throughout:
|
|
468
|
+
*
|
|
469
|
+
* ```text
|
|
470
|
+
* u32 count
|
|
471
|
+
* count * { i32 x, i32 y, i32 z, u16 palette_index }
|
|
472
|
+
* u32 palette_json_len
|
|
473
|
+
* u8[palette_json_len] ["minecraft:stone", ...]
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
476
|
+
* Palette indices are assigned in first-seen order, so the same
|
|
477
|
+
* schematic always packs identically. About seven times smaller
|
|
478
|
+
* than `get_non_air_blocks_json` and free of per block JSON
|
|
479
|
+
* parsing on the far side.
|
|
480
|
+
*
|
|
481
|
+
* Palette indices are `u16`, so at most 65,535 distinct non-air
|
|
482
|
+
* block states can be addressed. A schematic with more than that
|
|
483
|
+
* writes **an empty string**, not a truncated palette: callers must
|
|
484
|
+
* treat an empty result as "too many distinct states, fall back to
|
|
485
|
+
* `get_non_air_blocks_json`". No real build has that many.
|
|
486
|
+
*/
|
|
487
|
+
nonAirBlocksPackedB64(): string;
|
|
488
|
+
|
|
437
489
|
/**
|
|
438
490
|
* All blocks within a sub-region (chunk) of the schematic, as the same
|
|
439
491
|
* JSON array shape as `get_all_blocks_json`.
|
package/Schematic.mjs
CHANGED
|
@@ -1741,6 +1741,11 @@ export class Schematic {
|
|
|
1741
1741
|
* Air cells are materialized too — on a large sparse build this
|
|
1742
1742
|
* dump is `volume()`-sized and can exhaust wasm memory; renderers
|
|
1743
1743
|
* and analyzers want `get_non_air_blocks_json`.
|
|
1744
|
+
*
|
|
1745
|
+
* Prefer `get_non_air_blocks_json` for a block list,
|
|
1746
|
+
* `count_blocks_json` for a material tally and
|
|
1747
|
+
* `non_air_blocks_packed_b64` for bulk transfer. This method is
|
|
1748
|
+
* kept for compatibility and is the wrong tool at any real size.
|
|
1744
1749
|
*/
|
|
1745
1750
|
getAllBlocksJson() {
|
|
1746
1751
|
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
@@ -1809,6 +1814,102 @@ export class Schematic {
|
|
|
1809
1814
|
}
|
|
1810
1815
|
}
|
|
1811
1816
|
|
|
1817
|
+
/**
|
|
1818
|
+
* Non-air blocks tallied by id: `{"minecraft:stone": 123, ...}`.
|
|
1819
|
+
* One pass, no per block allocation, so a caller that only wants a
|
|
1820
|
+
* material list never has to pull `get_non_air_blocks_json`. "Air"
|
|
1821
|
+
* covers `minecraft:air`, `cave_air` and `void_air` alike.
|
|
1822
|
+
*/
|
|
1823
|
+
countBlocksJson() {
|
|
1824
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1825
|
+
|
|
1826
|
+
wasm.Schematic_count_blocks_json(this.ffiValue, write.buffer);
|
|
1827
|
+
|
|
1828
|
+
try {
|
|
1829
|
+
return write.readString8();
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
finally {
|
|
1833
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1834
|
+
write.free();
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
/**
|
|
1839
|
+
* Apply a `{"from id": "to id"}` map in place and return how many
|
|
1840
|
+
* blocks changed. Keys match on block id only, ignoring block
|
|
1841
|
+
* states; values may carry states (`minecraft:oak_stairs[facing=north]`),
|
|
1842
|
+
* but not NBT: `parse_block_string` only returns a `BlockState`, so
|
|
1843
|
+
* any `{...}` payload on a `to` value is silently dropped rather
|
|
1844
|
+
* than copied onto the replaced block.
|
|
1845
|
+
* A block whose id is not a key is left alone, and so is one that
|
|
1846
|
+
* already equals its target: the count is the number of blocks
|
|
1847
|
+
* actually changed, so a map that rewrites stone to stone returns 0.
|
|
1848
|
+
* Errors with `Parse` on malformed JSON or an unparseable target id.
|
|
1849
|
+
*/
|
|
1850
|
+
replaceBlocksJson(mapJson) {
|
|
1851
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1852
|
+
|
|
1853
|
+
const mapJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, mapJson)));
|
|
1854
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 8, true);
|
|
1855
|
+
|
|
1856
|
+
|
|
1857
|
+
const result = wasm.Schematic_replace_blocks_json(diplomatReceive.buffer, this.ffiValue, mapJsonSlice.ptr);
|
|
1858
|
+
|
|
1859
|
+
try {
|
|
1860
|
+
if (!diplomatReceive.resultFlag) {
|
|
1861
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1862
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1863
|
+
}
|
|
1864
|
+
return (new BigUint64Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
finally {
|
|
1868
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1869
|
+
functionCleanupArena.free();
|
|
1870
|
+
|
|
1871
|
+
diplomatReceive.free();
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
/**
|
|
1876
|
+
* Every non-air block as a compact binary blob, base64 encoded
|
|
1877
|
+
* (`DiplomatWrite` is UTF-8 only, see `to_litematic_b64`). Little
|
|
1878
|
+
* endian throughout:
|
|
1879
|
+
*
|
|
1880
|
+
* ```text
|
|
1881
|
+
* u32 count
|
|
1882
|
+
* count * { i32 x, i32 y, i32 z, u16 palette_index }
|
|
1883
|
+
* u32 palette_json_len
|
|
1884
|
+
* u8[palette_json_len] ["minecraft:stone", ...]
|
|
1885
|
+
* ```
|
|
1886
|
+
*
|
|
1887
|
+
* Palette indices are assigned in first-seen order, so the same
|
|
1888
|
+
* schematic always packs identically. About seven times smaller
|
|
1889
|
+
* than `get_non_air_blocks_json` and free of per block JSON
|
|
1890
|
+
* parsing on the far side.
|
|
1891
|
+
*
|
|
1892
|
+
* Palette indices are `u16`, so at most 65,535 distinct non-air
|
|
1893
|
+
* block states can be addressed. A schematic with more than that
|
|
1894
|
+
* writes **an empty string**, not a truncated palette: callers must
|
|
1895
|
+
* treat an empty result as "too many distinct states, fall back to
|
|
1896
|
+
* `get_non_air_blocks_json`". No real build has that many.
|
|
1897
|
+
*/
|
|
1898
|
+
nonAirBlocksPackedB64() {
|
|
1899
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1900
|
+
|
|
1901
|
+
wasm.Schematic_non_air_blocks_packed_b64(this.ffiValue, write.buffer);
|
|
1902
|
+
|
|
1903
|
+
try {
|
|
1904
|
+
return write.readString8();
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
finally {
|
|
1908
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1909
|
+
write.free();
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1812
1913
|
/**
|
|
1813
1914
|
* All blocks within a sub-region (chunk) of the schematic, as the same
|
|
1814
1915
|
* JSON array shape as `get_all_blocks_json`.
|
package/nucleation.wasm
CHANGED
|
Binary file
|