nucleation 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Renderer.d.mts CHANGED
@@ -17,6 +17,14 @@ export class Renderer {
17
17
  constructor();
18
18
 
19
19
 
20
+ /**
21
+ * Why the last render on this thread failed, in words; empty after
22
+ * a successful render. A render that is refused because a resource
23
+ * limit is too small for the software Vulkan driver says which limit
24
+ * and how much it needs.
25
+ */
26
+ static lastErrorDetail(): string;
27
+
20
28
  /**
21
29
  * Render a schematic to raw RGBA pixel bytes, written as base64
22
30
  * (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
package/Renderer.d.ts CHANGED
@@ -17,6 +17,14 @@ export class Renderer {
17
17
  constructor();
18
18
 
19
19
 
20
+ /**
21
+ * Why the last render on this thread failed, in words; empty after
22
+ * a successful render. A render that is refused because a resource
23
+ * limit is too small for the software Vulkan driver says which limit
24
+ * and how much it needs.
25
+ */
26
+ static lastErrorDetail(): string;
27
+
20
28
  /**
21
29
  * Render a schematic to raw RGBA pixel bytes, written as base64
22
30
  * (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
package/Renderer.mjs CHANGED
@@ -42,6 +42,27 @@ export class Renderer {
42
42
  }
43
43
 
44
44
 
45
+ /**
46
+ * Why the last render on this thread failed, in words; empty after
47
+ * a successful render. A render that is refused because a resource
48
+ * limit is too small for the software Vulkan driver says which limit
49
+ * and how much it needs.
50
+ */
51
+ static lastErrorDetail() {
52
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
53
+
54
+ wasm.Renderer_last_error_detail(write.buffer);
55
+
56
+ try {
57
+ return write.readString8();
58
+ }
59
+
60
+ finally {
61
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
62
+ write.free();
63
+ }
64
+ }
65
+
45
66
  /**
46
67
  * Render a schematic to raw RGBA pixel bytes, written as base64
47
68
  * (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
@@ -1,6 +1,7 @@
1
1
  // generated by diplomat-tool
2
2
  import type { NucleationError } from "./NucleationError.mjs"
3
3
  import type { ResourcePackList } from "./ResourcePackList.mjs"
4
+ import type { Schematic } from "./Schematic.mjs"
4
5
  import type { TextureInfo } from "./TextureInfo.mjs"
5
6
  import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
6
7
 
@@ -97,6 +98,23 @@ export class ResourcePack {
97
98
  */
98
99
  addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
99
100
 
101
+ /**
102
+ * Skin URLs the player heads in `schematic` need, as a sorted JSON
103
+ * array string. Nucleation never downloads skins: fetch each URL and
104
+ * pass the PNG to `add_player_skin`. Heads whose skin is not
105
+ * registered render with vanilla's default skin for their owner.
106
+ */
107
+ static playerSkinUrlsJson(schematic: Schematic): string;
108
+
109
+ /**
110
+ * Register a downloaded player skin: `url_or_hash` is a URL from
111
+ * `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
112
+ * legacy 64x32) skin image. Writes the texture's resource location,
113
+ * `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
114
+ * or the PNG is not a skin.
115
+ */
116
+ addPlayerSkin(urlOrHash: string, png: Array<number>): string;
117
+
100
118
  /**
101
119
  * Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
102
120
  * works. (Old ABI: `schematic_register_mesh_exporter`.)
package/ResourcePack.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // generated by diplomat-tool
2
2
  import type { NucleationError } from "./NucleationError.mjs"
3
3
  import type { ResourcePackList } from "./ResourcePackList.mjs"
4
+ import type { Schematic } from "./Schematic.mjs"
4
5
  import type { TextureInfo } from "./TextureInfo.mjs"
5
6
  import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
6
7
 
@@ -97,6 +98,23 @@ export class ResourcePack {
97
98
  */
98
99
  addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
99
100
 
101
+ /**
102
+ * Skin URLs the player heads in `schematic` need, as a sorted JSON
103
+ * array string. Nucleation never downloads skins: fetch each URL and
104
+ * pass the PNG to `add_player_skin`. Heads whose skin is not
105
+ * registered render with vanilla's default skin for their owner.
106
+ */
107
+ static playerSkinUrlsJson(schematic: Schematic): string;
108
+
109
+ /**
110
+ * Register a downloaded player skin: `url_or_hash` is a URL from
111
+ * `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
112
+ * legacy 64x32) skin image. Writes the texture's resource location,
113
+ * `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
114
+ * or the PNG is not a skin.
115
+ */
116
+ addPlayerSkin(urlOrHash: string, png: Array<number>): string;
117
+
100
118
  /**
101
119
  * Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
102
120
  * works. (Old ABI: `schematic_register_mesh_exporter`.)
package/ResourcePack.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // generated by diplomat-tool
2
2
  import { NucleationError } from "./NucleationError.mjs"
3
3
  import { ResourcePackList } from "./ResourcePackList.mjs"
4
+ import { Schematic } from "./Schematic.mjs"
4
5
  import { TextureInfo } from "./TextureInfo.mjs"
5
6
  import wasm from "./diplomat-wasm.mjs";
6
7
  import * as diplomatRuntime from "./diplomat-runtime.mjs";
@@ -418,6 +419,63 @@ export class ResourcePack {
418
419
  }
419
420
  }
420
421
 
422
+ /**
423
+ * Skin URLs the player heads in `schematic` need, as a sorted JSON
424
+ * array string. Nucleation never downloads skins: fetch each URL and
425
+ * pass the PNG to `add_player_skin`. Heads whose skin is not
426
+ * registered render with vanilla's default skin for their owner.
427
+ */
428
+ static playerSkinUrlsJson(schematic) {
429
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
430
+
431
+ wasm.ResourcePack_player_skin_urls_json(schematic.ffiValue, write.buffer);
432
+
433
+ try {
434
+ return write.readString8();
435
+ }
436
+
437
+ finally {
438
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
439
+ write.free();
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Register a downloaded player skin: `url_or_hash` is a URL from
445
+ * `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
446
+ * legacy 64x32) skin image. Writes the texture's resource location,
447
+ * `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
448
+ * or the PNG is not a skin.
449
+ */
450
+ addPlayerSkin(urlOrHash, png) {
451
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
452
+
453
+ const urlOrHashSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, urlOrHash)));
454
+ const pngSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, png, "u8")));
455
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
456
+
457
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
458
+
459
+
460
+ const result = wasm.ResourcePack_add_player_skin(diplomatReceive.buffer, this.ffiValue, urlOrHashSlice.ptr, pngSlice.ptr, write.buffer);
461
+
462
+ try {
463
+ if (!diplomatReceive.resultFlag) {
464
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
465
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
466
+ }
467
+ return write.readString8();
468
+ }
469
+
470
+ finally {
471
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
472
+ functionCleanupArena.free();
473
+
474
+ diplomatReceive.free();
475
+ write.free();
476
+ }
477
+ }
478
+
421
479
  /**
422
480
  * Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
423
481
  * works. (Old ABI: `schematic_register_mesh_exporter`.)
package/nucleation.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleation",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "A high-performance Minecraft schematic parser and utility library",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
@@ -17,6 +17,14 @@ export class Renderer {
17
17
  constructor();
18
18
 
19
19
 
20
+ /**
21
+ * Why the last render on this thread failed, in words; empty after
22
+ * a successful render. A render that is refused because a resource
23
+ * limit is too small for the software Vulkan driver says which limit
24
+ * and how much it needs.
25
+ */
26
+ static lastErrorDetail(): string;
27
+
20
28
  /**
21
29
  * Render a schematic to raw RGBA pixel bytes, written as base64
22
30
  * (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
@@ -17,6 +17,14 @@ export class Renderer {
17
17
  constructor();
18
18
 
19
19
 
20
+ /**
21
+ * Why the last render on this thread failed, in words; empty after
22
+ * a successful render. A render that is refused because a resource
23
+ * limit is too small for the software Vulkan driver says which limit
24
+ * and how much it needs.
25
+ */
26
+ static lastErrorDetail(): string;
27
+
20
28
  /**
21
29
  * Render a schematic to raw RGBA pixel bytes, written as base64
22
30
  * (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
@@ -42,6 +42,27 @@ export class Renderer {
42
42
  }
43
43
 
44
44
 
45
+ /**
46
+ * Why the last render on this thread failed, in words; empty after
47
+ * a successful render. A render that is refused because a resource
48
+ * limit is too small for the software Vulkan driver says which limit
49
+ * and how much it needs.
50
+ */
51
+ static lastErrorDetail() {
52
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
53
+
54
+ wasm.Renderer_last_error_detail(write.buffer);
55
+
56
+ try {
57
+ return write.readString8();
58
+ }
59
+
60
+ finally {
61
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
62
+ write.free();
63
+ }
64
+ }
65
+
45
66
  /**
46
67
  * Render a schematic to raw RGBA pixel bytes, written as base64
47
68
  * (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
@@ -1,6 +1,7 @@
1
1
  // generated by diplomat-tool
2
2
  import type { NucleationError } from "./NucleationError.mjs"
3
3
  import type { ResourcePackList } from "./ResourcePackList.mjs"
4
+ import type { Schematic } from "./Schematic.mjs"
4
5
  import type { TextureInfo } from "./TextureInfo.mjs"
5
6
  import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
6
7
 
@@ -97,6 +98,23 @@ export class ResourcePack {
97
98
  */
98
99
  addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
99
100
 
101
+ /**
102
+ * Skin URLs the player heads in `schematic` need, as a sorted JSON
103
+ * array string. Nucleation never downloads skins: fetch each URL and
104
+ * pass the PNG to `add_player_skin`. Heads whose skin is not
105
+ * registered render with vanilla's default skin for their owner.
106
+ */
107
+ static playerSkinUrlsJson(schematic: Schematic): string;
108
+
109
+ /**
110
+ * Register a downloaded player skin: `url_or_hash` is a URL from
111
+ * `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
112
+ * legacy 64x32) skin image. Writes the texture's resource location,
113
+ * `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
114
+ * or the PNG is not a skin.
115
+ */
116
+ addPlayerSkin(urlOrHash: string, png: Array<number>): string;
117
+
100
118
  /**
101
119
  * Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
102
120
  * works. (Old ABI: `schematic_register_mesh_exporter`.)
@@ -1,6 +1,7 @@
1
1
  // generated by diplomat-tool
2
2
  import type { NucleationError } from "./NucleationError.mjs"
3
3
  import type { ResourcePackList } from "./ResourcePackList.mjs"
4
+ import type { Schematic } from "./Schematic.mjs"
4
5
  import type { TextureInfo } from "./TextureInfo.mjs"
5
6
  import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
6
7
 
@@ -97,6 +98,23 @@ export class ResourcePack {
97
98
  */
98
99
  addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
99
100
 
101
+ /**
102
+ * Skin URLs the player heads in `schematic` need, as a sorted JSON
103
+ * array string. Nucleation never downloads skins: fetch each URL and
104
+ * pass the PNG to `add_player_skin`. Heads whose skin is not
105
+ * registered render with vanilla's default skin for their owner.
106
+ */
107
+ static playerSkinUrlsJson(schematic: Schematic): string;
108
+
109
+ /**
110
+ * Register a downloaded player skin: `url_or_hash` is a URL from
111
+ * `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
112
+ * legacy 64x32) skin image. Writes the texture's resource location,
113
+ * `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
114
+ * or the PNG is not a skin.
115
+ */
116
+ addPlayerSkin(urlOrHash: string, png: Array<number>): string;
117
+
100
118
  /**
101
119
  * Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
102
120
  * works. (Old ABI: `schematic_register_mesh_exporter`.)
@@ -1,6 +1,7 @@
1
1
  // generated by diplomat-tool
2
2
  import { NucleationError } from "./NucleationError.mjs"
3
3
  import { ResourcePackList } from "./ResourcePackList.mjs"
4
+ import { Schematic } from "./Schematic.mjs"
4
5
  import { TextureInfo } from "./TextureInfo.mjs"
5
6
  import wasm from "./diplomat-wasm.mjs";
6
7
  import * as diplomatRuntime from "./diplomat-runtime.mjs";
@@ -418,6 +419,63 @@ export class ResourcePack {
418
419
  }
419
420
  }
420
421
 
422
+ /**
423
+ * Skin URLs the player heads in `schematic` need, as a sorted JSON
424
+ * array string. Nucleation never downloads skins: fetch each URL and
425
+ * pass the PNG to `add_player_skin`. Heads whose skin is not
426
+ * registered render with vanilla's default skin for their owner.
427
+ */
428
+ static playerSkinUrlsJson(schematic) {
429
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
430
+
431
+ wasm.ResourcePack_player_skin_urls_json(schematic.ffiValue, write.buffer);
432
+
433
+ try {
434
+ return write.readString8();
435
+ }
436
+
437
+ finally {
438
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
439
+ write.free();
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Register a downloaded player skin: `url_or_hash` is a URL from
445
+ * `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
446
+ * legacy 64x32) skin image. Writes the texture's resource location,
447
+ * `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
448
+ * or the PNG is not a skin.
449
+ */
450
+ addPlayerSkin(urlOrHash, png) {
451
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
452
+
453
+ const urlOrHashSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, urlOrHash)));
454
+ const pngSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, png, "u8")));
455
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
456
+
457
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
458
+
459
+
460
+ const result = wasm.ResourcePack_add_player_skin(diplomatReceive.buffer, this.ffiValue, urlOrHashSlice.ptr, pngSlice.ptr, write.buffer);
461
+
462
+ try {
463
+ if (!diplomatReceive.resultFlag) {
464
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
465
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
466
+ }
467
+ return write.readString8();
468
+ }
469
+
470
+ finally {
471
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
472
+ functionCleanupArena.free();
473
+
474
+ diplomatReceive.free();
475
+ write.free();
476
+ }
477
+ }
478
+
421
479
  /**
422
480
  * Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
423
481
  * works. (Old ABI: `schematic_register_mesh_exporter`.)
Binary file