@tsukilabs/nil-continent 0.1.41 → 0.2.0

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # nil-continent
2
+
3
+ See: https://github.com/tsukilabs/nil
@@ -3,23 +3,27 @@
3
3
 
4
4
  /* tslint:disable */
5
5
  /* eslint-disable */
6
+
6
7
  export class Continent {
7
- free(): void;
8
- set_center(x: number, y: number): void;
9
- set_cell_size(size: number): void;
10
- coords_byte_length(): number;
11
- set_container_size(width: number, height: number): void;
12
- update_coords_within(): number;
13
- constructor();
14
- center(): Coord;
15
- max_cols(): number;
16
- max_rows(): number;
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ center(): Coord;
11
+ coords_byte_length(): number;
12
+ max_cols(): number;
13
+ max_rows(): number;
14
+ constructor();
15
+ set_cell_size(size: number): void;
16
+ set_center(x: number, y: number): void;
17
+ set_container_size(width: number, height: number): void;
18
+ update_coords_within(): number;
17
19
  }
20
+
18
21
  export class Coord {
19
- free(): void;
20
- x(): number;
21
- y(): number;
22
- constructor(x: number, y: number);
23
- static type_size(): number;
22
+ free(): void;
23
+ [Symbol.dispose](): void;
24
+ constructor(x: number, y: number);
25
+ static type_size(): number;
26
+ x(): number;
27
+ y(): number;
24
28
  }
25
-
29
+
package/nil_continent.js CHANGED
@@ -1,9 +1,13 @@
1
1
  // Copyright (C) Call of Nil contributors
2
2
  // SPDX-License-Identifier: AGPL-3.0-only
3
3
 
4
+ /* @ts-self-types="./nil_continent.d.ts" */
5
+
4
6
  import * as wasm from "./nil_continent_bg.wasm";
5
- export * from "./nil_continent_bg.js";
6
7
  import { __wbg_set_wasm } from "./nil_continent_bg.js";
7
8
  __wbg_set_wasm(wasm);
8
9
  wasm.__wbindgen_start();
9
-
10
+ export {
11
+ Continent, Coord
12
+ } from "./nil_continent_bg.js";
13
+
@@ -1,61 +1,23 @@
1
1
  // Copyright (C) Call of Nil contributors
2
2
  // SPDX-License-Identifier: AGPL-3.0-only
3
3
 
4
- let wasm;
5
- export function __wbg_set_wasm(val) {
6
- wasm = val;
7
- }
8
-
9
-
10
- const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
11
-
12
- let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
-
14
- cachedTextDecoder.decode();
15
-
16
- let cachedUint8ArrayMemory0 = null;
17
-
18
- function getUint8ArrayMemory0() {
19
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
20
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
21
- }
22
- return cachedUint8ArrayMemory0;
23
- }
24
-
25
- function getStringFromWasm0(ptr, len) {
26
- ptr = ptr >>> 0;
27
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
28
- }
29
-
30
- const ContinentFinalization = (typeof FinalizationRegistry === 'undefined')
31
- ? { register: () => {}, unregister: () => {} }
32
- : new FinalizationRegistry(ptr => wasm.__wbg_continent_free(ptr >>> 0, 1));
33
-
34
4
  export class Continent {
35
-
36
5
  __destroy_into_raw() {
37
6
  const ptr = this.__wbg_ptr;
38
7
  this.__wbg_ptr = 0;
39
8
  ContinentFinalization.unregister(this);
40
9
  return ptr;
41
10
  }
42
-
43
11
  free() {
44
12
  const ptr = this.__destroy_into_raw();
45
13
  wasm.__wbg_continent_free(ptr, 0);
46
14
  }
47
15
  /**
48
- * @param {number} x
49
- * @param {number} y
50
- */
51
- set_center(x, y) {
52
- wasm.continent_set_center(this.__wbg_ptr, x, y);
53
- }
54
- /**
55
- * @param {number} size
16
+ * @returns {Coord}
56
17
  */
57
- set_cell_size(size) {
58
- wasm.continent_set_cell_size(this.__wbg_ptr, size);
18
+ center() {
19
+ const ret = wasm.continent_center(this.__wbg_ptr);
20
+ return Coord.__wrap(ret);
59
21
  }
60
22
  /**
61
23
  * @returns {number}
@@ -65,17 +27,17 @@ export class Continent {
65
27
  return ret >>> 0;
66
28
  }
67
29
  /**
68
- * @param {number} width
69
- * @param {number} height
30
+ * @returns {number}
70
31
  */
71
- set_container_size(width, height) {
72
- wasm.continent_set_container_size(this.__wbg_ptr, width, height);
32
+ max_cols() {
33
+ const ret = wasm.continent_max_cols(this.__wbg_ptr);
34
+ return ret >>> 0;
73
35
  }
74
36
  /**
75
37
  * @returns {number}
76
38
  */
77
- update_coords_within() {
78
- const ret = wasm.continent_update_coords_within(this.__wbg_ptr);
39
+ max_rows() {
40
+ const ret = wasm.continent_max_rows(this.__wbg_ptr);
79
41
  return ret >>> 0;
80
42
  }
81
43
  constructor() {
@@ -85,34 +47,36 @@ export class Continent {
85
47
  return this;
86
48
  }
87
49
  /**
88
- * @returns {Coord}
50
+ * @param {number} size
89
51
  */
90
- center() {
91
- const ret = wasm.continent_center(this.__wbg_ptr);
92
- return Coord.__wrap(ret);
52
+ set_cell_size(size) {
53
+ wasm.continent_set_cell_size(this.__wbg_ptr, size);
93
54
  }
94
55
  /**
95
- * @returns {number}
56
+ * @param {number} x
57
+ * @param {number} y
96
58
  */
97
- max_cols() {
98
- const ret = wasm.continent_max_cols(this.__wbg_ptr);
99
- return ret >>> 0;
59
+ set_center(x, y) {
60
+ wasm.continent_set_center(this.__wbg_ptr, x, y);
61
+ }
62
+ /**
63
+ * @param {number} width
64
+ * @param {number} height
65
+ */
66
+ set_container_size(width, height) {
67
+ wasm.continent_set_container_size(this.__wbg_ptr, width, height);
100
68
  }
101
69
  /**
102
70
  * @returns {number}
103
71
  */
104
- max_rows() {
105
- const ret = wasm.continent_max_rows(this.__wbg_ptr);
72
+ update_coords_within() {
73
+ const ret = wasm.continent_update_coords_within(this.__wbg_ptr);
106
74
  return ret >>> 0;
107
75
  }
108
76
  }
109
-
110
- const CoordFinalization = (typeof FinalizationRegistry === 'undefined')
111
- ? { register: () => {}, unregister: () => {} }
112
- : new FinalizationRegistry(ptr => wasm.__wbg_coord_free(ptr >>> 0, 1));
77
+ if (Symbol.dispose) Continent.prototype[Symbol.dispose] = Continent.prototype.free;
113
78
 
114
79
  export class Coord {
115
-
116
80
  static __wrap(ptr) {
117
81
  ptr = ptr >>> 0;
118
82
  const obj = Object.create(Coord.prototype);
@@ -120,32 +84,16 @@ export class Coord {
120
84
  CoordFinalization.register(obj, obj.__wbg_ptr, obj);
121
85
  return obj;
122
86
  }
123
-
124
87
  __destroy_into_raw() {
125
88
  const ptr = this.__wbg_ptr;
126
89
  this.__wbg_ptr = 0;
127
90
  CoordFinalization.unregister(this);
128
91
  return ptr;
129
92
  }
130
-
131
93
  free() {
132
94
  const ptr = this.__destroy_into_raw();
133
95
  wasm.__wbg_coord_free(ptr, 0);
134
96
  }
135
- /**
136
- * @returns {number}
137
- */
138
- x() {
139
- const ret = wasm.coord_x(this.__wbg_ptr);
140
- return ret;
141
- }
142
- /**
143
- * @returns {number}
144
- */
145
- y() {
146
- const ret = wasm.coord_y(this.__wbg_ptr);
147
- return ret;
148
- }
149
97
  /**
150
98
  * @param {number} x
151
99
  * @param {number} y
@@ -163,21 +111,71 @@ export class Coord {
163
111
  const ret = wasm.coord_type_size();
164
112
  return ret >>> 0;
165
113
  }
114
+ /**
115
+ * @returns {number}
116
+ */
117
+ x() {
118
+ const ret = wasm.coord_x(this.__wbg_ptr);
119
+ return ret;
120
+ }
121
+ /**
122
+ * @returns {number}
123
+ */
124
+ y() {
125
+ const ret = wasm.coord_y(this.__wbg_ptr);
126
+ return ret;
127
+ }
128
+ }
129
+ if (Symbol.dispose) Coord.prototype[Symbol.dispose] = Coord.prototype.free;
130
+ export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
131
+ throw new Error(getStringFromWasm0(arg0, arg1));
166
132
  }
167
-
168
133
  export function __wbindgen_init_externref_table() {
169
- const table = wasm.__wbindgen_export_0;
134
+ const table = wasm.__wbindgen_externrefs;
170
135
  const offset = table.grow(4);
171
136
  table.set(0, undefined);
172
137
  table.set(offset + 0, undefined);
173
138
  table.set(offset + 1, null);
174
139
  table.set(offset + 2, true);
175
140
  table.set(offset + 3, false);
176
- ;
177
- };
141
+ }
142
+ const ContinentFinalization = (typeof FinalizationRegistry === 'undefined')
143
+ ? { register: () => {}, unregister: () => {} }
144
+ : new FinalizationRegistry(ptr => wasm.__wbg_continent_free(ptr >>> 0, 1));
145
+ const CoordFinalization = (typeof FinalizationRegistry === 'undefined')
146
+ ? { register: () => {}, unregister: () => {} }
147
+ : new FinalizationRegistry(ptr => wasm.__wbg_coord_free(ptr >>> 0, 1));
178
148
 
179
- export function __wbindgen_throw(arg0, arg1) {
180
- throw new Error(getStringFromWasm0(arg0, arg1));
181
- };
149
+ function getStringFromWasm0(ptr, len) {
150
+ ptr = ptr >>> 0;
151
+ return decodeText(ptr, len);
152
+ }
153
+
154
+ let cachedUint8ArrayMemory0 = null;
155
+ function getUint8ArrayMemory0() {
156
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
157
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
158
+ }
159
+ return cachedUint8ArrayMemory0;
160
+ }
161
+
162
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
163
+ cachedTextDecoder.decode();
164
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
165
+ let numBytesDecoded = 0;
166
+ function decodeText(ptr, len) {
167
+ numBytesDecoded += len;
168
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
169
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
170
+ cachedTextDecoder.decode();
171
+ numBytesDecoded = len;
172
+ }
173
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
174
+ }
175
+
176
+
177
+ let wasm;
178
+ export function __wbg_set_wasm(val) {
179
+ wasm = val;
180
+ }
182
181
 
183
-
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Andrew Ferreira <andrew.shien2@gmail.com>",
6
6
  "Danilo Soares <danilofs18@gmail.com>"
7
7
  ],
8
- "version": "0.1.41",
8
+ "version": "0.2.0",
9
9
  "license": "AGPL-3.0-only",
10
10
  "repository": {
11
11
  "type": "git",