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