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/WorldSink.mjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
3
|
+
import { WorldChunkView } from "./WorldChunkView.mjs"
|
|
4
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
5
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
|
+
|
|
7
|
+
const WorldSink_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
8
|
+
wasm.WorldSink_destroy(ptr);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A world writer. `finish` is consuming (PORTING rule 11): the inner sink is
|
|
13
|
+
* held in an `Option` and taken on `finish`; every method afterwards returns
|
|
14
|
+
* `AlreadyConsumed`. Dropping the handle without `finish` abandons the sink.
|
|
15
|
+
*/
|
|
16
|
+
export class WorldSink {
|
|
17
|
+
// Internal ptr reference:
|
|
18
|
+
#ptr = null;
|
|
19
|
+
|
|
20
|
+
// Lifetimes are only to keep dependencies alive.
|
|
21
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
22
|
+
#selfEdge = [];
|
|
23
|
+
|
|
24
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
25
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
26
|
+
console.error("WorldSink is an Opaque type. You cannot call its constructor.");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.#ptr = ptr;
|
|
30
|
+
this.#selfEdge = selfEdge;
|
|
31
|
+
|
|
32
|
+
// Are we being borrowed? If not, we can register.
|
|
33
|
+
if (this.#selfEdge.length === 0) {
|
|
34
|
+
WorldSink_box_destroy_registry.register(this, this.#ptr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/** @internal */
|
|
40
|
+
get ffiValue() {
|
|
41
|
+
return this.#ptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a new world sink that writes fresh chunk data to `dir`.
|
|
47
|
+
* `options_json` is a serialized `WorldExportOptions` (empty string =
|
|
48
|
+
* defaults).
|
|
49
|
+
*/
|
|
50
|
+
static create(dir, optionsJson) {
|
|
51
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
52
|
+
|
|
53
|
+
const dirSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, dir)));
|
|
54
|
+
const optionsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, optionsJson)));
|
|
55
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const result = wasm.WorldSink_create(diplomatReceive.buffer, dirSlice.ptr, optionsJsonSlice.ptr);
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
if (!diplomatReceive.resultFlag) {
|
|
62
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
63
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
64
|
+
}
|
|
65
|
+
return new WorldSink(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
finally {
|
|
69
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
70
|
+
functionCleanupArena.free();
|
|
71
|
+
|
|
72
|
+
diplomatReceive.free();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Open an existing world directory for patching via `put_chunk`.
|
|
78
|
+
*/
|
|
79
|
+
static openExisting(dir) {
|
|
80
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
81
|
+
|
|
82
|
+
const dirSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, dir)));
|
|
83
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
const result = wasm.WorldSink_open_existing(diplomatReceive.buffer, dirSlice.ptr);
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
if (!diplomatReceive.resultFlag) {
|
|
90
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
91
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
92
|
+
}
|
|
93
|
+
return new WorldSink(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
finally {
|
|
97
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
98
|
+
functionCleanupArena.free();
|
|
99
|
+
|
|
100
|
+
diplomatReceive.free();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Write (append) a chunk view into the sink. The view is not consumed.
|
|
106
|
+
*/
|
|
107
|
+
writeChunk(view) {
|
|
108
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
const result = wasm.WorldSink_write_chunk(diplomatReceive.buffer, this.ffiValue, view.ffiValue);
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
if (!diplomatReceive.resultFlag) {
|
|
115
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
116
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
finally {
|
|
121
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
122
|
+
diplomatReceive.free();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Overwrite the chunk at (`view.cx`, `view.cz`) of the sink's world with
|
|
128
|
+
* the supplied view's block data. Only valid on sinks opened with
|
|
129
|
+
* `open_existing`; errors with `Io` on a create-mode sink. The view is
|
|
130
|
+
* not consumed.
|
|
131
|
+
*/
|
|
132
|
+
putChunk(view) {
|
|
133
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
const result = wasm.WorldSink_put_chunk(diplomatReceive.buffer, this.ffiValue, view.ffiValue);
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
if (!diplomatReceive.resultFlag) {
|
|
140
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
141
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
finally {
|
|
146
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
147
|
+
diplomatReceive.free();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Finalise and flush all pending writes. Consuming (PORTING rule 11):
|
|
153
|
+
* afterwards every method on this sink returns `AlreadyConsumed`.
|
|
154
|
+
*/
|
|
155
|
+
finish() {
|
|
156
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
const result = wasm.WorldSink_finish(diplomatReceive.buffer, this.ffiValue);
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
if (!diplomatReceive.resultFlag) {
|
|
163
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
164
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
finally {
|
|
169
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
170
|
+
diplomatReceive.free();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
constructor(symbol, ptr, selfEdge) {
|
|
175
|
+
return this.#internalConstructor(...arguments)
|
|
176
|
+
}
|
|
177
|
+
}
|
package/WorldStream.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { WorldChunkView } from "./WorldChunkView"
|
|
4
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A streaming iterator over the chunks of a world.
|
|
10
|
+
*/
|
|
11
|
+
export class WorldStream {
|
|
12
|
+
/** @internal */
|
|
13
|
+
get ffiValue(): pointer;
|
|
14
|
+
/** @internal */
|
|
15
|
+
constructor();
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Open a streaming iterator over a world directory.
|
|
20
|
+
*/
|
|
21
|
+
static openDir(path: string): WorldStream;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Open a streaming iterator over a world directory, bounded to the given
|
|
25
|
+
* block-coordinate box `[min_x..max_x, min_y..max_y, min_z..max_z]`.
|
|
26
|
+
*/
|
|
27
|
+
static openDirBounded(path: string, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): WorldStream;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Open a streaming iterator from a zip archive in memory.
|
|
31
|
+
*/
|
|
32
|
+
static fromZip(data: Array<number>): WorldStream;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Open a bounded streaming iterator from a zip archive in memory.
|
|
36
|
+
*/
|
|
37
|
+
static fromZipBounded(data: Array<number>, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): WorldStream;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Advance the iterator and return the next chunk view. Errors with
|
|
41
|
+
* `NotFound` at end-of-stream (the old ABI returned NULL). Corrupt
|
|
42
|
+
* chunks are silently skipped, matching the old ABI.
|
|
43
|
+
*/
|
|
44
|
+
next(): WorldChunkView;
|
|
45
|
+
}
|
package/WorldStream.mjs
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
3
|
+
import { WorldChunkView } from "./WorldChunkView.mjs"
|
|
4
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
5
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
|
+
|
|
7
|
+
const WorldStream_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
8
|
+
wasm.WorldStream_destroy(ptr);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A streaming iterator over the chunks of a world.
|
|
13
|
+
*/
|
|
14
|
+
export class WorldStream {
|
|
15
|
+
// Internal ptr reference:
|
|
16
|
+
#ptr = null;
|
|
17
|
+
|
|
18
|
+
// Lifetimes are only to keep dependencies alive.
|
|
19
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
20
|
+
#selfEdge = [];
|
|
21
|
+
|
|
22
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
23
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
24
|
+
console.error("WorldStream is an Opaque type. You cannot call its constructor.");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.#ptr = ptr;
|
|
28
|
+
this.#selfEdge = selfEdge;
|
|
29
|
+
|
|
30
|
+
// Are we being borrowed? If not, we can register.
|
|
31
|
+
if (this.#selfEdge.length === 0) {
|
|
32
|
+
WorldStream_box_destroy_registry.register(this, this.#ptr);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
get ffiValue() {
|
|
39
|
+
return this.#ptr;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Open a streaming iterator over a world directory.
|
|
45
|
+
*/
|
|
46
|
+
static openDir(path) {
|
|
47
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
48
|
+
|
|
49
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
50
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const result = wasm.WorldStream_open_dir(diplomatReceive.buffer, pathSlice.ptr);
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
if (!diplomatReceive.resultFlag) {
|
|
57
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
58
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
59
|
+
}
|
|
60
|
+
return new WorldStream(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
finally {
|
|
64
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
65
|
+
functionCleanupArena.free();
|
|
66
|
+
|
|
67
|
+
diplomatReceive.free();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Open a streaming iterator over a world directory, bounded to the given
|
|
73
|
+
* block-coordinate box `[min_x..max_x, min_y..max_y, min_z..max_z]`.
|
|
74
|
+
*/
|
|
75
|
+
static openDirBounded(path, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
76
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
77
|
+
|
|
78
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
79
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
const result = wasm.WorldStream_open_dir_bounded(diplomatReceive.buffer, pathSlice.ptr, minX, minY, minZ, maxX, maxY, maxZ);
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
if (!diplomatReceive.resultFlag) {
|
|
86
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
87
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
88
|
+
}
|
|
89
|
+
return new WorldStream(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
finally {
|
|
93
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
94
|
+
functionCleanupArena.free();
|
|
95
|
+
|
|
96
|
+
diplomatReceive.free();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Open a streaming iterator from a zip archive in memory.
|
|
102
|
+
*/
|
|
103
|
+
static fromZip(data) {
|
|
104
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
105
|
+
|
|
106
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
107
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const result = wasm.WorldStream_from_zip(diplomatReceive.buffer, dataSlice.ptr);
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
if (!diplomatReceive.resultFlag) {
|
|
114
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
115
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
116
|
+
}
|
|
117
|
+
return new WorldStream(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
finally {
|
|
121
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
122
|
+
functionCleanupArena.free();
|
|
123
|
+
|
|
124
|
+
diplomatReceive.free();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Open a bounded streaming iterator from a zip archive in memory.
|
|
130
|
+
*/
|
|
131
|
+
static fromZipBounded(data, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
132
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
133
|
+
|
|
134
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
135
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
const result = wasm.WorldStream_from_zip_bounded(diplomatReceive.buffer, dataSlice.ptr, minX, minY, minZ, maxX, maxY, maxZ);
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
if (!diplomatReceive.resultFlag) {
|
|
142
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
143
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
144
|
+
}
|
|
145
|
+
return new WorldStream(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
finally {
|
|
149
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
150
|
+
functionCleanupArena.free();
|
|
151
|
+
|
|
152
|
+
diplomatReceive.free();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Advance the iterator and return the next chunk view. Errors with
|
|
158
|
+
* `NotFound` at end-of-stream (the old ABI returned NULL). Corrupt
|
|
159
|
+
* chunks are silently skipped, matching the old ABI.
|
|
160
|
+
*/
|
|
161
|
+
next() {
|
|
162
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
const result = wasm.WorldStream_next(diplomatReceive.buffer, this.ffiValue);
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
if (!diplomatReceive.resultFlag) {
|
|
169
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
170
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
171
|
+
}
|
|
172
|
+
return new WorldChunkView(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
finally {
|
|
176
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
177
|
+
diplomatReceive.free();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
constructor(symbol, ptr, selfEdge) {
|
|
182
|
+
return this.#internalConstructor(...arguments)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// A [codepoint] is a Unicode code point, such as `a`, or `💡`.
|
|
2
|
+
///
|
|
3
|
+
/// The recommended way to obtain a `codepoint` is to create it from a
|
|
4
|
+
/// `String`, which is conceptually a list of `codepoint`s. For example,
|
|
5
|
+
/// `'a'.codePointAt(0)` is equal to the `char` `a`.
|
|
6
|
+
///
|
|
7
|
+
/// JS does not have a character/codepoint literal, so integer literals
|
|
8
|
+
/// need to be used. For example the Unicode code point U+1F4A1, `💡`,
|
|
9
|
+
/// can be represented by `0x1F4A1`. Note that only values in the ranges
|
|
10
|
+
/// `0x0..0xD7FF` and `0xE000..0x10FFFF` (both inclusive) are Unicode
|
|
11
|
+
/// code points, and hence valid `codepoint`s.
|
|
12
|
+
///
|
|
13
|
+
/// A `String` can be constructed from a `codepoint` using `String.fromCodePoint()`.
|
|
14
|
+
export type codepoint = number;
|
|
15
|
+
export type pointer = number;
|