nucleation 0.1.90 → 0.1.93

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.
@@ -1,72 +1,5 @@
1
1
  let wasm;
2
2
 
3
- function debugString(val) {
4
- // primitive types
5
- const type = typeof val;
6
- if (type == 'number' || type == 'boolean' || val == null) {
7
- return `${val}`;
8
- }
9
- if (type == 'string') {
10
- return `"${val}"`;
11
- }
12
- if (type == 'symbol') {
13
- const description = val.description;
14
- if (description == null) {
15
- return 'Symbol';
16
- } else {
17
- return `Symbol(${description})`;
18
- }
19
- }
20
- if (type == 'function') {
21
- const name = val.name;
22
- if (typeof name == 'string' && name.length > 0) {
23
- return `Function(${name})`;
24
- } else {
25
- return 'Function';
26
- }
27
- }
28
- // objects
29
- if (Array.isArray(val)) {
30
- const length = val.length;
31
- let debug = '[';
32
- if (length > 0) {
33
- debug += debugString(val[0]);
34
- }
35
- for(let i = 1; i < length; i++) {
36
- debug += ', ' + debugString(val[i]);
37
- }
38
- debug += ']';
39
- return debug;
40
- }
41
- // Test for built-in
42
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
43
- let className;
44
- if (builtInMatches && builtInMatches.length > 1) {
45
- className = builtInMatches[1];
46
- } else {
47
- // Failed to match the standard '[object ClassName]'
48
- return toString.call(val);
49
- }
50
- if (className == 'Object') {
51
- // we're a user defined class or Object
52
- // JSON.stringify avoids problems with cycles, and is generally much
53
- // easier than looping through ownProperties of `val`.
54
- try {
55
- return 'Object(' + JSON.stringify(val) + ')';
56
- } catch (_) {
57
- return 'Object';
58
- }
59
- }
60
- // errors
61
- if (val instanceof Error) {
62
- return `${val.name}: ${val.message}\n${val.stack}`;
63
- }
64
- // TODO we could test for more things here, like `Set`s and `Map`s.
65
- return className;
66
- }
67
-
68
- let WASM_VECTOR_LEN = 0;
69
-
70
3
  let cachedUint8ArrayMemory0 = null;
71
4
 
72
5
  function getUint8ArrayMemory0() {
@@ -76,6 +9,29 @@ function getUint8ArrayMemory0() {
76
9
  return cachedUint8ArrayMemory0;
77
10
  }
78
11
 
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ let WASM_VECTOR_LEN = 0;
34
+
79
35
  const cachedTextEncoder = new TextEncoder();
80
36
 
81
37
  if (!('encodeInto' in cachedTextEncoder)) {
@@ -137,29 +93,73 @@ function getDataViewMemory0() {
137
93
  return cachedDataViewMemory0;
138
94
  }
139
95
 
140
- function isLikeNone(x) {
141
- return x === undefined || x === null;
142
- }
143
-
144
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
145
-
146
- cachedTextDecoder.decode();
147
-
148
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
149
- let numBytesDecoded = 0;
150
- function decodeText(ptr, len) {
151
- numBytesDecoded += len;
152
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
153
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
154
- cachedTextDecoder.decode();
155
- numBytesDecoded = len;
96
+ function debugString(val) {
97
+ // primitive types
98
+ const type = typeof val;
99
+ if (type == 'number' || type == 'boolean' || val == null) {
100
+ return `${val}`;
156
101
  }
157
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
102
+ if (type == 'string') {
103
+ return `"${val}"`;
104
+ }
105
+ if (type == 'symbol') {
106
+ const description = val.description;
107
+ if (description == null) {
108
+ return 'Symbol';
109
+ } else {
110
+ return `Symbol(${description})`;
111
+ }
112
+ }
113
+ if (type == 'function') {
114
+ const name = val.name;
115
+ if (typeof name == 'string' && name.length > 0) {
116
+ return `Function(${name})`;
117
+ } else {
118
+ return 'Function';
119
+ }
120
+ }
121
+ // objects
122
+ if (Array.isArray(val)) {
123
+ const length = val.length;
124
+ let debug = '[';
125
+ if (length > 0) {
126
+ debug += debugString(val[0]);
127
+ }
128
+ for(let i = 1; i < length; i++) {
129
+ debug += ', ' + debugString(val[i]);
130
+ }
131
+ debug += ']';
132
+ return debug;
133
+ }
134
+ // Test for built-in
135
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
136
+ let className;
137
+ if (builtInMatches && builtInMatches.length > 1) {
138
+ className = builtInMatches[1];
139
+ } else {
140
+ // Failed to match the standard '[object ClassName]'
141
+ return toString.call(val);
142
+ }
143
+ if (className == 'Object') {
144
+ // we're a user defined class or Object
145
+ // JSON.stringify avoids problems with cycles, and is generally much
146
+ // easier than looping through ownProperties of `val`.
147
+ try {
148
+ return 'Object(' + JSON.stringify(val) + ')';
149
+ } catch (_) {
150
+ return 'Object';
151
+ }
152
+ }
153
+ // errors
154
+ if (val instanceof Error) {
155
+ return `${val.name}: ${val.message}\n${val.stack}`;
156
+ }
157
+ // TODO we could test for more things here, like `Set`s and `Map`s.
158
+ return className;
158
159
  }
159
160
 
160
- function getStringFromWasm0(ptr, len) {
161
- ptr = ptr >>> 0;
162
- return decodeText(ptr, len);
161
+ function isLikeNone(x) {
162
+ return x === undefined || x === null;
163
163
  }
164
164
 
165
165
  function addToExternrefTable0(obj) {
@@ -243,10 +243,6 @@ export function debug_schematic(schematic) {
243
243
  }
244
244
  }
245
245
 
246
- export function start() {
247
- wasm.start();
248
- }
249
-
250
246
  /**
251
247
  * @param {SchematicWrapper} schematic
252
248
  * @returns {string}
@@ -265,6 +261,10 @@ export function debug_json_schematic(schematic) {
265
261
  }
266
262
  }
267
263
 
264
+ export function start() {
265
+ wasm.start();
266
+ }
267
+
268
268
  const BlockPositionFinalization = (typeof FinalizationRegistry === 'undefined')
269
269
  ? { register: () => {}, unregister: () => {} }
270
270
  : new FinalizationRegistry(ptr => wasm.__wbg_blockposition_free(ptr >>> 0, 1));
@@ -772,6 +772,15 @@ export class SchematicWrapper {
772
772
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
773
773
  return v1;
774
774
  }
775
+ /**
776
+ * Extract all sign text from the schematic
777
+ * Returns a JavaScript array of objects: [{pos: [x,y,z], text: "..."}]
778
+ * @returns {any}
779
+ */
780
+ extractSigns() {
781
+ const ret = wasm.schematicwrapper_extractSigns(this.__wbg_ptr);
782
+ return ret;
783
+ }
775
784
  /**
776
785
  * Flip a specific region along the X axis
777
786
  * @param {string} region_name
@@ -829,6 +838,19 @@ export class SchematicWrapper {
829
838
  const ret = wasm.schematicwrapper_chunks_indices(this.__wbg_ptr, chunk_width, chunk_height, chunk_length);
830
839
  return ret;
831
840
  }
841
+ /**
842
+ * Compile Insign annotations from the schematic's signs
843
+ * Returns a JavaScript object with compiled region metadata
844
+ * This returns raw Insign data - interpretation is up to the consumer
845
+ * @returns {any}
846
+ */
847
+ compileInsign() {
848
+ const ret = wasm.schematicwrapper_compileInsign(this.__wbg_ptr);
849
+ if (ret[2]) {
850
+ throw takeFromExternrefTable0(ret[1]);
851
+ }
852
+ return takeFromExternrefTable0(ret[0]);
853
+ }
832
854
  /**
833
855
  * @param {Uint8Array} data
834
856
  */
@@ -985,6 +1007,21 @@ export class SchematicWrapper {
985
1007
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
986
1008
  return v1;
987
1009
  }
1010
+ /**
1011
+ * @param {number} x
1012
+ * @param {number} y
1013
+ * @param {number} z
1014
+ * @param {string} block_name
1015
+ * @param {any} nbt_data
1016
+ */
1017
+ setBlockWithNbt(x, y, z, block_name, nbt_data) {
1018
+ const ptr0 = passStringToWasm0(block_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1019
+ const len0 = WASM_VECTOR_LEN;
1020
+ const ret = wasm.schematicwrapper_setBlockWithNbt(this.__wbg_ptr, x, y, z, ptr0, len0, nbt_data);
1021
+ if (ret[1]) {
1022
+ throw takeFromExternrefTable0(ret[0]);
1023
+ }
1024
+ }
988
1025
  /**
989
1026
  * @param {number} chunk_width
990
1027
  * @param {number} chunk_height
@@ -1415,6 +1452,17 @@ async function __wbg_load(module, imports) {
1415
1452
  function __wbg_get_imports() {
1416
1453
  const imports = {};
1417
1454
  imports.wbg = {};
1455
+ imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
1456
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1457
+ return ret;
1458
+ };
1459
+ imports.wbg.__wbg_String_fed4d24b68977888 = function(arg0, arg1) {
1460
+ const ret = String(arg1);
1461
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1462
+ const len1 = WASM_VECTOR_LEN;
1463
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1464
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1465
+ };
1418
1466
  imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
1419
1467
  const ret = debugString(arg1);
1420
1468
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -1426,6 +1474,10 @@ function __wbg_get_imports() {
1426
1474
  const ret = arg0 === null;
1427
1475
  return ret;
1428
1476
  };
1477
+ imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
1478
+ const ret = typeof(arg0) === 'string';
1479
+ return ret;
1480
+ };
1429
1481
  imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
1430
1482
  const ret = arg0 === undefined;
1431
1483
  return ret;
@@ -1481,6 +1533,10 @@ function __wbg_get_imports() {
1481
1533
  const ret = new Object();
1482
1534
  return ret;
1483
1535
  };
1536
+ imports.wbg.__wbg_new_68651c719dcda04e = function() {
1537
+ const ret = new Map();
1538
+ return ret;
1539
+ };
1484
1540
  imports.wbg.__wbg_new_e17d9f43105b08be = function() {
1485
1541
  const ret = new Array();
1486
1542
  return ret;
@@ -1497,6 +1553,16 @@ function __wbg_get_imports() {
1497
1553
  const ret = arg0.push(arg1);
1498
1554
  return ret;
1499
1555
  };
1556
+ imports.wbg.__wbg_set_3fda3bac07393de4 = function(arg0, arg1, arg2) {
1557
+ arg0[arg1] = arg2;
1558
+ };
1559
+ imports.wbg.__wbg_set_907fb406c34a251d = function(arg0, arg1, arg2) {
1560
+ const ret = arg0.set(arg1, arg2);
1561
+ return ret;
1562
+ };
1563
+ imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
1564
+ arg0[arg1 >>> 0] = arg2;
1565
+ };
1500
1566
  imports.wbg.__wbg_set_c2abbebe8b9ebee1 = function() { return handleError(function (arg0, arg1, arg2) {
1501
1567
  const ret = Reflect.set(arg0, arg1, arg2);
1502
1568
  return ret;
@@ -1509,6 +1575,16 @@ function __wbg_get_imports() {
1509
1575
  const ret = getStringFromWasm0(arg0, arg1);
1510
1576
  return ret;
1511
1577
  };
1578
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1579
+ // Cast intrinsic for `U64 -> Externref`.
1580
+ const ret = BigInt.asUintN(64, arg0);
1581
+ return ret;
1582
+ };
1583
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1584
+ // Cast intrinsic for `I64 -> Externref`.
1585
+ const ret = arg0;
1586
+ return ret;
1587
+ };
1512
1588
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1513
1589
  // Cast intrinsic for `F64 -> Externref`.
1514
1590
  const ret = arg0;
package/nucleation.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export function debug_schematic(schematic: SchematicWrapper): string;
4
- export function start(): void;
5
4
  export function debug_json_schematic(schematic: SchematicWrapper): string;
5
+ export function start(): void;
6
6
  export class BlockPosition {
7
7
  free(): void;
8
8
  [Symbol.dispose](): void;
@@ -125,6 +125,11 @@ export class SchematicWrapper {
125
125
  get_palette(): any;
126
126
  to_litematic(): Uint8Array;
127
127
  to_schematic(): Uint8Array;
128
+ /**
129
+ * Extract all sign text from the schematic
130
+ * Returns a JavaScript array of objects: [{pos: [x,y,z], text: "..."}]
131
+ */
132
+ extractSigns(): any;
128
133
  /**
129
134
  * Flip a specific region along the X axis
130
135
  */
@@ -147,6 +152,12 @@ export class SchematicWrapper {
147
152
  * Returns array of: { chunk_x, chunk_y, chunk_z, blocks: [[x,y,z,palette_index],...] }
148
153
  */
149
154
  chunks_indices(chunk_width: number, chunk_height: number, chunk_length: number): Array<any>;
155
+ /**
156
+ * Compile Insign annotations from the schematic's signs
157
+ * Returns a JavaScript object with compiled region metadata
158
+ * This returns raw Insign data - interpretation is up to the consumer
159
+ */
160
+ compileInsign(): any;
150
161
  from_litematic(data: Uint8Array): void;
151
162
  from_schematic(data: Uint8Array): void;
152
163
  get_dimensions(): Int32Array;
@@ -177,6 +188,7 @@ export class SchematicWrapper {
177
188
  get_bounding_box(): any;
178
189
  get_chunk_blocks(offset_x: number, offset_y: number, offset_z: number, width: number, height: number, length: number): Array<any>;
179
190
  get_region_names(): string[];
191
+ setBlockWithNbt(x: number, y: number, z: number, block_name: string, nbt_data: any): void;
180
192
  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>;
181
193
  /**
182
194
  * Get the tight bounding box max coordinates [x, y, z]
@@ -281,6 +293,14 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
281
293
 
282
294
  export interface InitOutput {
283
295
  readonly memory: WebAssembly.Memory;
296
+ readonly __wbg_blockposition_free: (a: number, b: number) => void;
297
+ readonly __wbg_get_blockposition_x: (a: number) => number;
298
+ readonly __wbg_get_blockposition_y: (a: number) => number;
299
+ readonly __wbg_get_blockposition_z: (a: number) => number;
300
+ readonly __wbg_set_blockposition_x: (a: number, b: number) => void;
301
+ readonly __wbg_set_blockposition_y: (a: number, b: number) => void;
302
+ readonly __wbg_set_blockposition_z: (a: number, b: number) => void;
303
+ readonly blockposition_new: (a: number, b: number, c: number) => number;
284
304
  readonly __wbg_blockstatewrapper_free: (a: number, b: number) => void;
285
305
  readonly __wbg_lazychunkiterator_free: (a: number, b: number) => void;
286
306
  readonly __wbg_mchprsworldwrapper_free: (a: number, b: number) => void;
@@ -322,9 +342,11 @@ export interface InitOutput {
322
342
  readonly schematicwrapper_chunks_indices: (a: number, b: number, c: number, d: number) => any;
323
343
  readonly schematicwrapper_chunks_indices_with_strategy: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
324
344
  readonly schematicwrapper_chunks_with_strategy: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
345
+ readonly schematicwrapper_compileInsign: (a: number) => [number, number, number];
325
346
  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];
326
347
  readonly schematicwrapper_create_lazy_chunk_iterator: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
327
348
  readonly schematicwrapper_debug_info: (a: number) => [number, number];
349
+ readonly schematicwrapper_extractSigns: (a: number) => any;
328
350
  readonly schematicwrapper_flip_region_x: (a: number, b: number, c: number) => [number, number];
329
351
  readonly schematicwrapper_flip_region_y: (a: number, b: number, c: number) => [number, number];
330
352
  readonly schematicwrapper_flip_region_z: (a: number, b: number, c: number) => [number, number];
@@ -364,6 +386,7 @@ export interface InitOutput {
364
386
  readonly schematicwrapper_rotate_x: (a: number, b: number) => void;
365
387
  readonly schematicwrapper_rotate_y: (a: number, b: number) => void;
366
388
  readonly schematicwrapper_rotate_z: (a: number, b: number) => void;
389
+ readonly schematicwrapper_setBlockWithNbt: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number];
367
390
  readonly schematicwrapper_set_block: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
368
391
  readonly schematicwrapper_set_block_with_properties: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number];
369
392
  readonly schematicwrapper_to_litematic: (a: number) => [number, number, number, number];
@@ -379,14 +402,6 @@ export interface InitOutput {
379
402
  readonly schematicwrapper_create_simulation_world_with_options: (a: number, b: number) => [number, number, number];
380
403
  readonly schematicwrapper_create_simulation_world: (a: number) => [number, number, number];
381
404
  readonly start: () => void;
382
- readonly __wbg_blockposition_free: (a: number, b: number) => void;
383
- readonly __wbg_get_blockposition_x: (a: number) => number;
384
- readonly __wbg_get_blockposition_y: (a: number) => number;
385
- readonly __wbg_get_blockposition_z: (a: number) => number;
386
- readonly __wbg_set_blockposition_x: (a: number, b: number) => void;
387
- readonly __wbg_set_blockposition_y: (a: number, b: number) => void;
388
- readonly __wbg_set_blockposition_z: (a: number, b: number) => void;
389
- readonly blockposition_new: (a: number, b: number, c: number) => number;
390
405
  readonly __wbindgen_malloc: (a: number, b: number) => number;
391
406
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
392
407
  readonly __wbindgen_exn_store: (a: number) => void;
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.90",
8
+ "version": "0.1.93",
9
9
  "license": "AGPL-3.0-only",
10
10
  "repository": {
11
11
  "type": "git",