nucleation 0.1.18 → 0.1.20
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/nucleation-cdn-loader.js +11 -30
- package/{nucleation_bg.js → nucleation-original.js} +206 -125
- package/nucleation.d.ts +123 -4
- package/nucleation.js +35 -5
- package/nucleation_bg.wasm +0 -0
- package/package.json +3 -4
package/nucleation-cdn-loader.js
CHANGED
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// This loader is for use in a browser via <script type="module"> from a CDN.
|
|
2
|
+
// It ensures that the .wasm file is loaded from the correct relative path.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// Import the real init function and all the classes from the original module.
|
|
5
|
+
import init, * as wasm from './nucleation-original.js';
|
|
5
6
|
|
|
6
|
-
// The
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (typeof bgModule.__wbg_set_wasm !== 'function') {
|
|
12
|
-
throw new Error("Missing __wbg_set_wasm in ./nucleation_bg.js");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let input = wasmPathOrModule;
|
|
16
|
-
if (input === undefined) {
|
|
17
|
-
input = new URL('./nucleation_bg.wasm', import.meta.url);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const importsObject = { './nucleation_bg.js': bgModule };
|
|
21
|
-
const { instance } = await WebAssembly.instantiateStreaming(fetch(input), importsObject);
|
|
22
|
-
|
|
23
|
-
bgModule.__wbg_set_wasm(instance.exports);
|
|
24
|
-
initialized = true;
|
|
25
|
-
|
|
26
|
-
// Return all the exports from the bg module
|
|
27
|
-
return { ...bgModule };
|
|
7
|
+
// The default export is a new initializer function for CDN use.
|
|
8
|
+
// It calls the real 'init' but provides the URL to the .wasm file.
|
|
9
|
+
export default async function() {
|
|
10
|
+
const wasmUrl = new URL('./nucleation_bg.wasm', import.meta.url);
|
|
11
|
+
await init(wasmUrl);
|
|
28
12
|
}
|
|
29
13
|
|
|
30
|
-
// Re-export the named
|
|
31
|
-
|
|
32
|
-
// This works because after init() is called, these exports become "live".
|
|
33
|
-
export * from './nucleation_bg.js';
|
|
34
|
-
export default init;
|
|
14
|
+
// Re-export all the named classes (SchematicWrapper, etc.).
|
|
15
|
+
export * from './nucleation-original.js';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
let wasm;
|
|
2
|
-
export function __wbg_set_wasm(val) {
|
|
3
|
-
wasm = val;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
2
|
|
|
7
3
|
function addToExternrefTable0(obj) {
|
|
8
4
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -95,9 +91,7 @@ function getUint8ArrayMemory0() {
|
|
|
95
91
|
return cachedUint8ArrayMemory0;
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
94
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
101
95
|
|
|
102
96
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
103
97
|
? function (arg, view) {
|
|
@@ -164,11 +158,9 @@ function isLikeNone(x) {
|
|
|
164
158
|
return x === undefined || x === null;
|
|
165
159
|
}
|
|
166
160
|
|
|
167
|
-
const
|
|
161
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
168
162
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
cachedTextDecoder.decode();
|
|
163
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
172
164
|
|
|
173
165
|
function getStringFromWasm0(ptr, len) {
|
|
174
166
|
ptr = ptr >>> 0;
|
|
@@ -695,120 +687,209 @@ export class SchematicWrapper {
|
|
|
695
687
|
}
|
|
696
688
|
}
|
|
697
689
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
690
|
+
async function __wbg_load(module, imports) {
|
|
691
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
692
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
693
|
+
try {
|
|
694
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
702
695
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
};
|
|
696
|
+
} catch (e) {
|
|
697
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
698
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
707
699
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
};
|
|
700
|
+
} else {
|
|
701
|
+
throw e;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
const bytes = await module.arrayBuffer();
|
|
707
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
708
|
+
|
|
709
|
+
} else {
|
|
710
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
711
|
+
|
|
712
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
713
|
+
return { instance, module };
|
|
714
|
+
|
|
715
|
+
} else {
|
|
716
|
+
return instance;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function __wbg_get_imports() {
|
|
722
|
+
const imports = {};
|
|
723
|
+
imports.wbg = {};
|
|
724
|
+
imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
|
|
725
|
+
const ret = Reflect.get(arg0, arg1);
|
|
726
|
+
return ret;
|
|
727
|
+
}, arguments) };
|
|
728
|
+
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
729
|
+
const ret = arg0[arg1 >>> 0];
|
|
730
|
+
return ret;
|
|
731
|
+
};
|
|
732
|
+
imports.wbg.__wbg_instanceof_Object_7f2dcef8f78644a4 = function(arg0) {
|
|
733
|
+
let result;
|
|
734
|
+
try {
|
|
735
|
+
result = arg0 instanceof Object;
|
|
736
|
+
} catch (_) {
|
|
737
|
+
result = false;
|
|
738
|
+
}
|
|
739
|
+
const ret = result;
|
|
740
|
+
return ret;
|
|
741
|
+
};
|
|
742
|
+
imports.wbg.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
|
|
743
|
+
const ret = Array.isArray(arg0);
|
|
744
|
+
return ret;
|
|
745
|
+
};
|
|
746
|
+
imports.wbg.__wbg_keys_5c77a08ddc2fb8a6 = function(arg0) {
|
|
747
|
+
const ret = Object.keys(arg0);
|
|
748
|
+
return ret;
|
|
749
|
+
};
|
|
750
|
+
imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
751
|
+
const ret = arg0.length;
|
|
752
|
+
return ret;
|
|
753
|
+
};
|
|
754
|
+
imports.wbg.__wbg_log_c222819a41e063d3 = function(arg0) {
|
|
755
|
+
console.log(arg0);
|
|
756
|
+
};
|
|
757
|
+
imports.wbg.__wbg_new_405e22f390576ce2 = function() {
|
|
758
|
+
const ret = new Object();
|
|
759
|
+
return ret;
|
|
760
|
+
};
|
|
761
|
+
imports.wbg.__wbg_new_78feb108b6472713 = function() {
|
|
762
|
+
const ret = new Array();
|
|
763
|
+
return ret;
|
|
764
|
+
};
|
|
765
|
+
imports.wbg.__wbg_now_807e54c39636c349 = function() {
|
|
766
|
+
const ret = Date.now();
|
|
767
|
+
return ret;
|
|
768
|
+
};
|
|
769
|
+
imports.wbg.__wbg_push_737cfc8c1432c2c6 = function(arg0, arg1) {
|
|
770
|
+
const ret = arg0.push(arg1);
|
|
771
|
+
return ret;
|
|
772
|
+
};
|
|
773
|
+
imports.wbg.__wbg_set_bb8cecf6a62b9f46 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
774
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
775
|
+
return ret;
|
|
776
|
+
}, arguments) };
|
|
777
|
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
778
|
+
const ret = debugString(arg1);
|
|
779
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
780
|
+
const len1 = WASM_VECTOR_LEN;
|
|
781
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
782
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
783
|
+
};
|
|
784
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
785
|
+
const table = wasm.__wbindgen_export_2;
|
|
786
|
+
const offset = table.grow(4);
|
|
787
|
+
table.set(0, undefined);
|
|
788
|
+
table.set(offset + 0, undefined);
|
|
789
|
+
table.set(offset + 1, null);
|
|
790
|
+
table.set(offset + 2, true);
|
|
791
|
+
table.set(offset + 3, false);
|
|
792
|
+
;
|
|
793
|
+
};
|
|
794
|
+
imports.wbg.__wbindgen_is_null = function(arg0) {
|
|
795
|
+
const ret = arg0 === null;
|
|
796
|
+
return ret;
|
|
797
|
+
};
|
|
798
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
799
|
+
const ret = arg0 === undefined;
|
|
800
|
+
return ret;
|
|
801
|
+
};
|
|
802
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
803
|
+
const ret = arg0;
|
|
804
|
+
return ret;
|
|
805
|
+
};
|
|
806
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
807
|
+
const obj = arg1;
|
|
808
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
809
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
810
|
+
var len1 = WASM_VECTOR_LEN;
|
|
811
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
812
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
813
|
+
};
|
|
814
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
815
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
816
|
+
return ret;
|
|
817
|
+
};
|
|
818
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
819
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
return imports;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function __wbg_init_memory(imports, memory) {
|
|
826
|
+
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function __wbg_finalize_init(instance, module) {
|
|
830
|
+
wasm = instance.exports;
|
|
831
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
832
|
+
cachedDataViewMemory0 = null;
|
|
833
|
+
cachedInt32ArrayMemory0 = null;
|
|
834
|
+
cachedUint8ArrayMemory0 = null;
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
wasm.__wbindgen_start();
|
|
838
|
+
return wasm;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function initSync(module) {
|
|
842
|
+
if (wasm !== undefined) return wasm;
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
if (typeof module !== 'undefined') {
|
|
846
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
847
|
+
({module} = module)
|
|
848
|
+
} else {
|
|
849
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
const imports = __wbg_get_imports();
|
|
854
|
+
|
|
855
|
+
__wbg_init_memory(imports);
|
|
856
|
+
|
|
857
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
858
|
+
module = new WebAssembly.Module(module);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
862
|
+
|
|
863
|
+
return __wbg_finalize_init(instance, module);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
async function __wbg_init(module_or_path) {
|
|
867
|
+
if (wasm !== undefined) return wasm;
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
if (typeof module_or_path !== 'undefined') {
|
|
871
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
872
|
+
({module_or_path} = module_or_path)
|
|
873
|
+
} else {
|
|
874
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
if (typeof module_or_path === 'undefined') {
|
|
879
|
+
module_or_path = new URL('nucleation_bg.wasm', import.meta.url);
|
|
880
|
+
}
|
|
881
|
+
const imports = __wbg_get_imports();
|
|
882
|
+
|
|
883
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
884
|
+
module_or_path = fetch(module_or_path);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
__wbg_init_memory(imports);
|
|
888
|
+
|
|
889
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
890
|
+
|
|
891
|
+
return __wbg_finalize_init(instance, module);
|
|
892
|
+
}
|
|
814
893
|
|
|
894
|
+
export { initSync };
|
|
895
|
+
export default __wbg_init;
|
package/nucleation.d.ts
CHANGED
|
@@ -1,4 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function start(): void;
|
|
4
|
+
export function debug_schematic(schematic: SchematicWrapper): string;
|
|
5
|
+
export function debug_json_schematic(schematic: SchematicWrapper): string;
|
|
6
|
+
export class BlockPosition {
|
|
7
|
+
free(): void;
|
|
8
|
+
constructor(x: number, y: number, z: number);
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
z: number;
|
|
12
|
+
}
|
|
13
|
+
export class BlockStateWrapper {
|
|
14
|
+
free(): void;
|
|
15
|
+
constructor(name: string);
|
|
16
|
+
with_property(key: string, value: string): void;
|
|
17
|
+
name(): string;
|
|
18
|
+
properties(): any;
|
|
19
|
+
}
|
|
20
|
+
export class SchematicWrapper {
|
|
21
|
+
free(): void;
|
|
22
|
+
constructor();
|
|
23
|
+
from_data(data: Uint8Array): void;
|
|
24
|
+
from_litematic(data: Uint8Array): void;
|
|
25
|
+
to_litematic(): Uint8Array;
|
|
26
|
+
from_schematic(data: Uint8Array): void;
|
|
27
|
+
to_schematic(): Uint8Array;
|
|
28
|
+
set_block(x: number, y: number, z: number, block_name: string): void;
|
|
29
|
+
set_block_from_string(x: number, y: number, z: number, block_string: string): void;
|
|
30
|
+
copy_region(from_schematic: SchematicWrapper, min_x: number, min_y: number, min_z: number, max_x: number, max_y: number, max_z: number, target_x: number, target_y: number, target_z: number, excluded_blocks: any): void;
|
|
31
|
+
set_block_with_properties(x: number, y: number, z: number, block_name: string, properties: any): void;
|
|
32
|
+
get_block(x: number, y: number, z: number): string | undefined;
|
|
33
|
+
get_block_with_properties(x: number, y: number, z: number): BlockStateWrapper | undefined;
|
|
34
|
+
get_block_entity(x: number, y: number, z: number): any;
|
|
35
|
+
get_all_block_entities(): any;
|
|
36
|
+
print_schematic(): string;
|
|
37
|
+
debug_info(): string;
|
|
38
|
+
get_dimensions(): Int32Array;
|
|
39
|
+
get_block_count(): number;
|
|
40
|
+
get_volume(): number;
|
|
41
|
+
get_region_names(): string[];
|
|
42
|
+
blocks(): Array<any>;
|
|
43
|
+
chunks(chunk_width: number, chunk_height: number, chunk_length: number): Array<any>;
|
|
44
|
+
chunks_with_strategy(chunk_width: number, chunk_height: number, chunk_length: number, strategy: string, camera_x: number, camera_y: number, camera_z: number): Array<any>;
|
|
45
|
+
get_chunk_blocks(offset_x: number, offset_y: number, offset_z: number, width: number, height: number, length: number): Array<any>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
49
|
+
|
|
50
|
+
export interface InitOutput {
|
|
51
|
+
readonly memory: WebAssembly.Memory;
|
|
52
|
+
readonly __wbg_schematicwrapper_free: (a: number, b: number) => void;
|
|
53
|
+
readonly __wbg_blockstatewrapper_free: (a: number, b: number) => void;
|
|
54
|
+
readonly schematicwrapper_new: () => number;
|
|
55
|
+
readonly schematicwrapper_from_data: (a: number, b: number, c: number) => [number, number];
|
|
56
|
+
readonly schematicwrapper_from_litematic: (a: number, b: number, c: number) => [number, number];
|
|
57
|
+
readonly schematicwrapper_to_litematic: (a: number) => [number, number, number, number];
|
|
58
|
+
readonly schematicwrapper_from_schematic: (a: number, b: number, c: number) => [number, number];
|
|
59
|
+
readonly schematicwrapper_to_schematic: (a: number) => [number, number, number, number];
|
|
60
|
+
readonly schematicwrapper_set_block: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
61
|
+
readonly schematicwrapper_set_block_from_string: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
62
|
+
readonly schematicwrapper_copy_region: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: any) => [number, number];
|
|
63
|
+
readonly schematicwrapper_set_block_with_properties: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number];
|
|
64
|
+
readonly schematicwrapper_get_block: (a: number, b: number, c: number, d: number) => [number, number];
|
|
65
|
+
readonly schematicwrapper_get_block_with_properties: (a: number, b: number, c: number, d: number) => number;
|
|
66
|
+
readonly schematicwrapper_get_block_entity: (a: number, b: number, c: number, d: number) => any;
|
|
67
|
+
readonly schematicwrapper_get_all_block_entities: (a: number) => any;
|
|
68
|
+
readonly schematicwrapper_print_schematic: (a: number) => [number, number];
|
|
69
|
+
readonly schematicwrapper_debug_info: (a: number) => [number, number];
|
|
70
|
+
readonly schematicwrapper_get_dimensions: (a: number) => [number, number];
|
|
71
|
+
readonly schematicwrapper_get_block_count: (a: number) => number;
|
|
72
|
+
readonly schematicwrapper_get_volume: (a: number) => number;
|
|
73
|
+
readonly schematicwrapper_get_region_names: (a: number) => [number, number];
|
|
74
|
+
readonly schematicwrapper_blocks: (a: number) => any;
|
|
75
|
+
readonly schematicwrapper_chunks: (a: number, b: number, c: number, d: number) => any;
|
|
76
|
+
readonly schematicwrapper_chunks_with_strategy: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
|
|
77
|
+
readonly schematicwrapper_get_chunk_blocks: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
78
|
+
readonly blockstatewrapper_new: (a: number, b: number) => number;
|
|
79
|
+
readonly blockstatewrapper_with_property: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
80
|
+
readonly blockstatewrapper_name: (a: number) => [number, number];
|
|
81
|
+
readonly blockstatewrapper_properties: (a: number) => any;
|
|
82
|
+
readonly debug_schematic: (a: number) => [number, number];
|
|
83
|
+
readonly debug_json_schematic: (a: number) => [number, number];
|
|
84
|
+
readonly start: () => void;
|
|
85
|
+
readonly __wbg_blockposition_free: (a: number, b: number) => void;
|
|
86
|
+
readonly __wbg_get_blockposition_x: (a: number) => number;
|
|
87
|
+
readonly __wbg_set_blockposition_x: (a: number, b: number) => void;
|
|
88
|
+
readonly __wbg_get_blockposition_y: (a: number) => number;
|
|
89
|
+
readonly __wbg_set_blockposition_y: (a: number, b: number) => void;
|
|
90
|
+
readonly __wbg_get_blockposition_z: (a: number) => number;
|
|
91
|
+
readonly __wbg_set_blockposition_z: (a: number, b: number) => void;
|
|
92
|
+
readonly blockposition_new: (a: number, b: number, c: number) => number;
|
|
93
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
94
|
+
readonly __externref_table_alloc: () => number;
|
|
95
|
+
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
96
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
97
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
98
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
99
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
100
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
101
|
+
readonly __wbindgen_start: () => void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
105
|
+
/**
|
|
106
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
107
|
+
* a precompiled `WebAssembly.Module`.
|
|
108
|
+
*
|
|
109
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
110
|
+
*
|
|
111
|
+
* @returns {InitOutput}
|
|
112
|
+
*/
|
|
113
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
117
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
118
|
+
*
|
|
119
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
120
|
+
*
|
|
121
|
+
* @returns {Promise<InitOutput>}
|
|
122
|
+
*/
|
|
123
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/nucleation.js
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
// Universal WASM initializer that works in both Node.js and browsers
|
|
2
|
+
import init_wasm from './nucleation-original.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export default async function init(input) {
|
|
5
|
+
// If input is provided, use it directly (manual override)
|
|
6
|
+
if (input !== undefined) {
|
|
7
|
+
return await init_wasm(input);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Auto-detect environment
|
|
11
|
+
const isNode = typeof process !== 'undefined' && process.versions?.node;
|
|
12
|
+
|
|
13
|
+
if (isNode) {
|
|
14
|
+
// Node.js: read the WASM file directly
|
|
15
|
+
try {
|
|
16
|
+
const fs = await import('fs');
|
|
17
|
+
const path = await import('path');
|
|
18
|
+
const url = await import('url');
|
|
19
|
+
|
|
20
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
21
|
+
const wasmPath = path.join(__dirname, 'nucleation_bg.wasm');
|
|
22
|
+
const wasmBytes = fs.readFileSync(wasmPath);
|
|
23
|
+
|
|
24
|
+
return await init_wasm(wasmBytes);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.warn('Failed to load WASM in Node.js, trying default init:', error.message);
|
|
27
|
+
return await init_wasm();
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
// Browser: use default fetch behavior
|
|
31
|
+
return await init_wasm();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Re-export everything from the original module
|
|
36
|
+
export * from './nucleation-original.js';
|
package/nucleation_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"Nano nano@schem.at"
|
|
6
6
|
],
|
|
7
7
|
"description": "A high-performance Minecraft schematic parser and utility library",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.20",
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"nucleation.js",
|
|
16
|
-
"
|
|
17
|
-
"nucleation_bg.js",
|
|
16
|
+
"nucleation-original.js",
|
|
18
17
|
"nucleation.d.ts",
|
|
18
|
+
"nucleation_bg.wasm",
|
|
19
19
|
"nucleation_bg.d.ts",
|
|
20
20
|
"nucleation-cdn-loader.js",
|
|
21
21
|
"README.md"
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"main": "./nucleation.js",
|
|
24
24
|
"types": "./nucleation.d.ts",
|
|
25
25
|
"sideEffects": [
|
|
26
|
-
"./nucleation.js",
|
|
27
26
|
"./snippets/*"
|
|
28
27
|
],
|
|
29
28
|
"keywords": [
|