nucleation 0.2.18 → 0.3.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/Autostack.d.ts +43 -0
- package/Autostack.mjs +134 -0
- package/BlockPos.d.ts +28 -0
- package/BlockPos.mjs +129 -0
- package/BlockState.d.ts +39 -0
- package/BlockState.mjs +134 -0
- package/Brush.d.ts +68 -0
- package/Brush.mjs +220 -0
- package/BuildingTool.d.ts +29 -0
- package/BuildingTool.mjs +74 -0
- package/ChunkMeshResult.d.ts +75 -0
- package/ChunkMeshResult.mjs +253 -0
- package/CircuitBuilder.d.ts +118 -0
- package/CircuitBuilder.mjs +516 -0
- package/DefinitionRegion.d.ts +274 -0
- package/DefinitionRegion.mjs +973 -0
- package/Diff.d.ts +88 -0
- package/Diff.mjs +316 -0
- package/Dimensions.d.ts +28 -0
- package/Dimensions.mjs +129 -0
- package/ExecutionMode.d.ts +42 -0
- package/ExecutionMode.mjs +127 -0
- package/Fingerprint.d.ts +44 -0
- package/Fingerprint.mjs +197 -0
- package/InterpolationSpace.d.ts +25 -0
- package/InterpolationSpace.mjs +73 -0
- package/IoLayout.d.ts +26 -0
- package/IoLayout.mjs +81 -0
- package/IoLayoutBuilder.d.ts +73 -0
- package/IoLayoutBuilder.mjs +315 -0
- package/IoType.d.ts +41 -0
- package/IoType.mjs +125 -0
- package/ItemModelConfig.d.ts +65 -0
- package/ItemModelConfig.mjs +223 -0
- package/ItemModelPackBuilder.d.ts +32 -0
- package/ItemModelPackBuilder.mjs +104 -0
- package/ItemModelResult.d.ts +72 -0
- package/ItemModelResult.mjs +268 -0
- package/ItemScale.d.ts +31 -0
- package/ItemScale.mjs +132 -0
- package/LayoutFunction.d.ts +52 -0
- package/LayoutFunction.mjs +159 -0
- package/MchprsWorld.d.ts +131 -0
- package/MchprsWorld.mjs +423 -0
- package/MeshBounds.d.ts +40 -0
- package/MeshBounds.mjs +180 -0
- package/MeshConfig.d.ts +101 -0
- package/MeshConfig.mjs +306 -0
- package/MeshJob.d.ts +44 -0
- package/MeshJob.mjs +116 -0
- package/MeshPhase.d.ts +38 -0
- package/MeshPhase.mjs +90 -0
- package/MeshProgress.d.ts +32 -0
- package/MeshProgress.mjs +133 -0
- package/MeshResult.d.ts +60 -0
- package/MeshResult.mjs +206 -0
- package/MultiMeshResult.d.ts +50 -0
- package/MultiMeshResult.mjs +166 -0
- package/Nbt.d.ts +50 -0
- package/Nbt.mjs +161 -0
- package/NucleationError.d.ts +36 -0
- package/NucleationError.mjs +104 -0
- package/OutputCondition.d.ts +45 -0
- package/OutputCondition.mjs +129 -0
- package/Palette.d.ts +84 -0
- package/Palette.mjs +269 -0
- package/PaletteBuilder.d.ts +76 -0
- package/PaletteBuilder.mjs +297 -0
- package/README.md +28 -197
- package/RawMeshExport.d.ts +74 -0
- package/RawMeshExport.mjs +243 -0
- package/RedstoneGraph.d.ts +58 -0
- package/RedstoneGraph.mjs +242 -0
- package/RegionBounds.d.ts +41 -0
- package/RegionBounds.mjs +181 -0
- package/RenderConfig.d.ts +66 -0
- package/RenderConfig.mjs +170 -0
- package/Renderer.d.ts +35 -0
- package/Renderer.mjs +139 -0
- package/ResourcePack.d.ts +105 -0
- package/ResourcePack.mjs +447 -0
- package/ResourcePackList.d.ts +32 -0
- package/ResourcePackList.mjs +96 -0
- package/Schematic.d.ts +655 -0
- package/Schematic.mjs +2647 -0
- package/SchematicBuilder.d.ts +103 -0
- package/SchematicBuilder.mjs +401 -0
- package/SchematicRegions.d.ts +93 -0
- package/SchematicRegions.mjs +411 -0
- package/Scripting.d.ts +40 -0
- package/Scripting.mjs +138 -0
- package/Sdf.d.ts +31 -0
- package/Sdf.mjs +107 -0
- package/Shape.d.ts +108 -0
- package/Shape.mjs +336 -0
- package/SortStrategy.d.ts +86 -0
- package/SortStrategy.mjs +272 -0
- package/Store.d.ts +83 -0
- package/Store.mjs +369 -0
- package/StoreIo.d.ts +71 -0
- package/StoreIo.mjs +292 -0
- package/TextureAtlas.d.ts +40 -0
- package/TextureAtlas.mjs +122 -0
- package/TextureInfo.d.ts +34 -0
- package/TextureInfo.mjs +148 -0
- package/TypedCircuitExecutor.d.ts +101 -0
- package/TypedCircuitExecutor.mjs +378 -0
- package/Value.d.ts +73 -0
- package/Value.mjs +275 -0
- package/WorldChunkView.d.ts +63 -0
- package/WorldChunkView.mjs +201 -0
- package/WorldSink.d.ts +50 -0
- package/WorldSink.mjs +177 -0
- package/WorldStream.d.ts +45 -0
- package/WorldStream.mjs +184 -0
- package/diplomat-runtime.d.ts +15 -0
- package/diplomat-runtime.mjs +774 -0
- package/diplomat-wasm.mjs +52 -0
- package/diplomat.config.mjs +6 -0
- package/index.d.ts +117 -0
- package/index.mjs +120 -0
- package/{nucleation_bg.wasm → nucleation.wasm} +0 -0
- package/package.json +19 -41
- package/LICENSE +0 -21
- package/api.js +0 -608
- package/nucleation-cdn-loader.js +0 -15
- package/nucleation-original.js +0 -8383
- package/nucleation.d.ts +0 -2947
- package/nucleation.js +0 -36
package/Renderer.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { RenderConfig } from "./RenderConfig"
|
|
4
|
+
import type { Schematic } from "./Schematic"
|
|
5
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Namespace type for the render entry points (PORTING rule 12).
|
|
11
|
+
*/
|
|
12
|
+
export class Renderer {
|
|
13
|
+
/** @internal */
|
|
14
|
+
get ffiValue(): pointer;
|
|
15
|
+
/** @internal */
|
|
16
|
+
constructor();
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
21
|
+
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
|
22
|
+
*/
|
|
23
|
+
static renderPixelsB64(schematic: Schematic, packZip: Array<number>, config: RenderConfig): string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Render a schematic to PNG bytes, written as base64 (PORTING rule 6).
|
|
27
|
+
* `pack_zip` is a resource-pack zip in memory.
|
|
28
|
+
*/
|
|
29
|
+
static renderPngB64(schematic: Schematic, packZip: Array<number>, config: RenderConfig): string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Render a schematic to a PNG file at `path`.
|
|
33
|
+
*/
|
|
34
|
+
static renderToFile(schematic: Schematic, packZip: Array<number>, config: RenderConfig, path: string): void;
|
|
35
|
+
}
|
package/Renderer.mjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
3
|
+
import { RenderConfig } from "./RenderConfig.mjs"
|
|
4
|
+
import { Schematic } from "./Schematic.mjs"
|
|
5
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
6
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
7
|
+
|
|
8
|
+
const Renderer_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
9
|
+
wasm.Renderer_destroy(ptr);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Namespace type for the render entry points (PORTING rule 12).
|
|
14
|
+
*/
|
|
15
|
+
export class Renderer {
|
|
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("Renderer 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
|
+
Renderer_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
|
+
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
46
|
+
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
|
47
|
+
*/
|
|
48
|
+
static renderPixelsB64(schematic, packZip, config) {
|
|
49
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
50
|
+
|
|
51
|
+
const packZipSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, packZip, "u8")));
|
|
52
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
53
|
+
|
|
54
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
const result = wasm.Renderer_render_pixels_b64(diplomatReceive.buffer, schematic.ffiValue, packZipSlice.ptr, config.ffiValue, write.buffer);
|
|
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 write.readString8();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
finally {
|
|
68
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
69
|
+
functionCleanupArena.free();
|
|
70
|
+
|
|
71
|
+
diplomatReceive.free();
|
|
72
|
+
write.free();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Render a schematic to PNG bytes, written as base64 (PORTING rule 6).
|
|
78
|
+
* `pack_zip` is a resource-pack zip in memory.
|
|
79
|
+
*/
|
|
80
|
+
static renderPngB64(schematic, packZip, config) {
|
|
81
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
82
|
+
|
|
83
|
+
const packZipSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, packZip, "u8")));
|
|
84
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
85
|
+
|
|
86
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
const result = wasm.Renderer_render_png_b64(diplomatReceive.buffer, schematic.ffiValue, packZipSlice.ptr, config.ffiValue, write.buffer);
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
if (!diplomatReceive.resultFlag) {
|
|
93
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
94
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
95
|
+
}
|
|
96
|
+
return write.readString8();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
finally {
|
|
100
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
101
|
+
functionCleanupArena.free();
|
|
102
|
+
|
|
103
|
+
diplomatReceive.free();
|
|
104
|
+
write.free();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Render a schematic to a PNG file at `path`.
|
|
110
|
+
*/
|
|
111
|
+
static renderToFile(schematic, packZip, config, path) {
|
|
112
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
113
|
+
|
|
114
|
+
const packZipSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, packZip, "u8")));
|
|
115
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
116
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const result = wasm.Renderer_render_to_file(diplomatReceive.buffer, schematic.ffiValue, packZipSlice.ptr, config.ffiValue, pathSlice.ptr);
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
if (!diplomatReceive.resultFlag) {
|
|
123
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
124
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
finally {
|
|
129
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
130
|
+
functionCleanupArena.free();
|
|
131
|
+
|
|
132
|
+
diplomatReceive.free();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
constructor(symbol, ptr, selfEdge) {
|
|
137
|
+
return this.#internalConstructor(...arguments)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { ResourcePackList } from "./ResourcePackList"
|
|
4
|
+
import type { TextureInfo } from "./TextureInfo"
|
|
5
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A loaded (possibly merged) Minecraft resource pack.
|
|
11
|
+
* Wraps {@link crate::meshing::ResourcePackSource}.
|
|
12
|
+
*/
|
|
13
|
+
export class ResourcePack {
|
|
14
|
+
/** @internal */
|
|
15
|
+
get ffiValue(): pointer;
|
|
16
|
+
/** @internal */
|
|
17
|
+
constructor();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Load a resource pack from an in-memory ZIP buffer.
|
|
22
|
+
*/
|
|
23
|
+
static fromBytes(data: Array<number>): ResourcePack;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Load and merge multiple resource packs, lowest priority first.
|
|
27
|
+
*/
|
|
28
|
+
static fromList(list: ResourcePackList): ResourcePack;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Number of blockstate definitions in the pack.
|
|
32
|
+
*/
|
|
33
|
+
blockstateCount(): number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Number of model definitions in the pack.
|
|
37
|
+
*/
|
|
38
|
+
modelCount(): number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Number of textures in the pack.
|
|
42
|
+
*/
|
|
43
|
+
textureCount(): number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Namespaces present in the pack, as a JSON array string.
|
|
47
|
+
*/
|
|
48
|
+
namespacesJson(): string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* All blockstate identifiers, as a JSON array string.
|
|
52
|
+
*/
|
|
53
|
+
listBlockstatesJson(): string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* All model identifiers, as a JSON array string.
|
|
57
|
+
*/
|
|
58
|
+
listModelsJson(): string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* All texture identifiers, as a JSON array string.
|
|
62
|
+
*/
|
|
63
|
+
listTexturesJson(): string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The blockstate definition JSON for `name`; `NotFound` if absent.
|
|
67
|
+
*/
|
|
68
|
+
getBlockstateJson(name: string): string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The model definition JSON for `name`; `NotFound` if absent.
|
|
72
|
+
*/
|
|
73
|
+
getModelJson(name: string): string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Texture metadata (size, animation flag, frame count).
|
|
77
|
+
*/
|
|
78
|
+
getTextureInfo(name: string): TextureInfo;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Raw RGBA pixels of a texture, base64-encoded.
|
|
82
|
+
*/
|
|
83
|
+
getTexturePixelsB64(name: string): string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Add (or override) a blockstate definition from a JSON string.
|
|
87
|
+
*/
|
|
88
|
+
addBlockstateJson(name: string, json: string): void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Add (or override) a model definition from a JSON string.
|
|
92
|
+
*/
|
|
93
|
+
addModelJson(name: string, json: string): void;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Add a raw RGBA texture (`pixels` length must be `width * height * 4`).
|
|
97
|
+
*/
|
|
98
|
+
addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
|
|
102
|
+
* works. (Old ABI: `schematic_register_mesh_exporter`.)
|
|
103
|
+
*/
|
|
104
|
+
registerMeshExporter(): void;
|
|
105
|
+
}
|