alpathfinder 0.4.7 → 0.5.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/alpathfinder.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
- import type { GData, MapKey } from "typed-adventureland";
4
+ import type { GData, ItemKey, MapKey } from "typed-adventureland";
5
5
 
6
6
  export interface PathNode {
7
7
  map: MapKey;
@@ -9,6 +9,13 @@ export interface PathNode {
9
9
  y: number;
10
10
  method: "move" | "town" | "door" | "transport" | "enter" | "leave" | "unknown";
11
11
  spawn?: number;
12
+ key?: ItemKey;
13
+ }
14
+
15
+ export interface SafeWalkPoint {
16
+ map: MapKey;
17
+ x: number;
18
+ y: number;
12
19
  }
13
20
 
14
21
  export function addCheatPath(
@@ -38,6 +45,14 @@ y_to: number,
38
45
  speed?: number,
39
46
  ): PathNode[] | null;
40
47
 
48
+ export function getSafeWalkTo(
49
+ map: MapKey,
50
+ x_from: number,
51
+ y_from: number,
52
+ x_to: number,
53
+ y_to: number,
54
+ ): SafeWalkPoint | null;
55
+
41
56
  export function isWalkable(map: MapKey, x: number, y: number): boolean;
42
57
 
43
58
  export function prepare(g: GData, exclude_maps?: MapKey[]): void;
package/alpathfinder.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * @param {number} y2
9
9
  */
10
10
  function addCheatPath(map, x1, y1, x2, y2) {
11
- const ptr0 = passStringToWasm0(map, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
11
+ const ptr0 = passStringToWasm0(map, wasm.__wbindgen_export, wasm.__wbindgen_export2);
12
12
  const len0 = WASM_VECTOR_LEN;
13
13
  wasm.addCheatPath(ptr0, len0, x1, y1, x2, y2);
14
14
  }
@@ -23,7 +23,7 @@ exports.addCheatPath = addCheatPath;
23
23
  * @returns {boolean}
24
24
  */
25
25
  function canWalkPath(map_name, x1, y1, x2, y2) {
26
- const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
26
+ const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
27
27
  const len0 = WASM_VECTOR_LEN;
28
28
  const ret = wasm.canWalkPath(ptr0, len0, x1, y1, x2, y2);
29
29
  return ret !== 0;
@@ -46,15 +46,31 @@ exports.clear = clear;
46
46
  * @returns {any}
47
47
  */
48
48
  function getPath(map_from_name, x_from, y_from, map_to_name, x_to, y_to, speed) {
49
- const ptr0 = passStringToWasm0(map_from_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
+ const ptr0 = passStringToWasm0(map_from_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
50
50
  const len0 = WASM_VECTOR_LEN;
51
- const ptr1 = passStringToWasm0(map_to_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
51
+ const ptr1 = passStringToWasm0(map_to_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
52
52
  const len1 = WASM_VECTOR_LEN;
53
53
  const ret = wasm.getPath(ptr0, len0, x_from, y_from, ptr1, len1, x_to, y_to, isLikeNone(speed) ? Number.MAX_SAFE_INTEGER : Math.fround(speed));
54
- return ret;
54
+ return takeObject(ret);
55
55
  }
56
56
  exports.getPath = getPath;
57
57
 
58
+ /**
59
+ * @param {string} map_name
60
+ * @param {number} x_from
61
+ * @param {number} y_from
62
+ * @param {number} x_to
63
+ * @param {number} y_to
64
+ * @returns {any}
65
+ */
66
+ function getSafeWalkTo(map_name, x_from, y_from, x_to, y_to) {
67
+ const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
68
+ const len0 = WASM_VECTOR_LEN;
69
+ const ret = wasm.getSafeWalkTo(ptr0, len0, x_from, y_from, x_to, y_to);
70
+ return takeObject(ret);
71
+ }
72
+ exports.getSafeWalkTo = getSafeWalkTo;
73
+
58
74
  /**
59
75
  * @param {string} map_name
60
76
  * @param {number} x
@@ -62,7 +78,7 @@ exports.getPath = getPath;
62
78
  * @returns {boolean}
63
79
  */
64
80
  function isWalkable(map_name, x, y) {
65
- const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
81
+ const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
66
82
  const len0 = WASM_VECTOR_LEN;
67
83
  const ret = wasm.isWalkable(ptr0, len0, x, y);
68
84
  return ret !== 0;
@@ -74,7 +90,7 @@ exports.isWalkable = isWalkable;
74
90
  * @param {any | null} [exclude_maps]
75
91
  */
76
92
  function prepare(g_js, exclude_maps) {
77
- wasm.prepare(g_js, isLikeNone(exclude_maps) ? 0 : addToExternrefTable0(exclude_maps));
93
+ wasm.prepare(addHeapObject(g_js), isLikeNone(exclude_maps) ? 0 : addHeapObject(exclude_maps));
78
94
  }
79
95
  exports.prepare = prepare;
80
96
  function __wbg_get_imports() {
@@ -82,69 +98,69 @@ function __wbg_get_imports() {
82
98
  __proto__: null,
83
99
  __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
84
100
  const ret = Error(getStringFromWasm0(arg0, arg1));
85
- return ret;
101
+ return addHeapObject(ret);
86
102
  },
87
103
  __wbg_Number_9a4e0ecb0fa16705: function(arg0) {
88
- const ret = Number(arg0);
104
+ const ret = Number(getObject(arg0));
89
105
  return ret;
90
106
  },
91
107
  __wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f: function(arg0, arg1) {
92
- const v = arg1;
108
+ const v = getObject(arg1);
93
109
  const ret = typeof(v) === 'bigint' ? v : undefined;
94
110
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
95
111
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
96
112
  },
97
113
  __wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
98
- const v = arg0;
114
+ const v = getObject(arg0);
99
115
  const ret = typeof(v) === 'boolean' ? v : undefined;
100
116
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
101
117
  },
102
118
  __wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
103
- const ret = debugString(arg1);
104
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119
+ const ret = debugString(getObject(arg1));
120
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
105
121
  const len1 = WASM_VECTOR_LEN;
106
122
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
107
123
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
108
124
  },
109
125
  __wbg___wbindgen_in_aca499c5de7ff5e5: function(arg0, arg1) {
110
- const ret = arg0 in arg1;
126
+ const ret = getObject(arg0) in getObject(arg1);
111
127
  return ret;
112
128
  },
113
129
  __wbg___wbindgen_is_bigint_2f76dc55065b4273: function(arg0) {
114
- const ret = typeof(arg0) === 'bigint';
130
+ const ret = typeof(getObject(arg0)) === 'bigint';
115
131
  return ret;
116
132
  },
117
133
  __wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
118
- const ret = typeof(arg0) === 'function';
134
+ const ret = typeof(getObject(arg0)) === 'function';
119
135
  return ret;
120
136
  },
121
137
  __wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
122
- const val = arg0;
138
+ const val = getObject(arg0);
123
139
  const ret = typeof(val) === 'object' && val !== null;
124
140
  return ret;
125
141
  },
126
142
  __wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
127
- const ret = arg0 === undefined;
143
+ const ret = getObject(arg0) === undefined;
128
144
  return ret;
129
145
  },
130
146
  __wbg___wbindgen_jsval_eq_e659fcf7b0e32763: function(arg0, arg1) {
131
- const ret = arg0 === arg1;
147
+ const ret = getObject(arg0) === getObject(arg1);
132
148
  return ret;
133
149
  },
134
150
  __wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
135
- const ret = arg0 == arg1;
151
+ const ret = getObject(arg0) == getObject(arg1);
136
152
  return ret;
137
153
  },
138
154
  __wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
139
- const obj = arg1;
155
+ const obj = getObject(arg1);
140
156
  const ret = typeof(obj) === 'number' ? obj : undefined;
141
157
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
142
158
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
143
159
  },
144
160
  __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
145
- const obj = arg1;
161
+ const obj = getObject(arg1);
146
162
  const ret = typeof(obj) === 'string' ? obj : undefined;
147
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
163
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
148
164
  var len1 = WASM_VECTOR_LEN;
149
165
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
150
166
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
@@ -153,37 +169,37 @@ function __wbg_get_imports() {
153
169
  throw new Error(getStringFromWasm0(arg0, arg1));
154
170
  },
155
171
  __wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) {
156
- const ret = arg0.call(arg1);
157
- return ret;
172
+ const ret = getObject(arg0).call(getObject(arg1));
173
+ return addHeapObject(ret);
158
174
  }, arguments); },
159
175
  __wbg_done_89b2b13e91a60321: function(arg0) {
160
- const ret = arg0.done;
176
+ const ret = getObject(arg0).done;
161
177
  return ret;
162
178
  },
163
179
  __wbg_entries_015dc610cd81ede0: function(arg0) {
164
- const ret = Object.entries(arg0);
165
- return ret;
180
+ const ret = Object.entries(getObject(arg0));
181
+ return addHeapObject(ret);
166
182
  },
167
183
  __wbg_get_507a50627bffa49b: function(arg0, arg1) {
168
- const ret = arg0[arg1 >>> 0];
169
- return ret;
184
+ const ret = getObject(arg0)[arg1 >>> 0];
185
+ return addHeapObject(ret);
170
186
  },
171
187
  __wbg_get_c7eb1f358a7654df: function() { return handleError(function (arg0, arg1) {
172
- const ret = Reflect.get(arg0, arg1);
173
- return ret;
188
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
189
+ return addHeapObject(ret);
174
190
  }, arguments); },
175
191
  __wbg_get_unchecked_6e0ad6d2a41b06f6: function(arg0, arg1) {
176
- const ret = arg0[arg1 >>> 0];
177
- return ret;
192
+ const ret = getObject(arg0)[arg1 >>> 0];
193
+ return addHeapObject(ret);
178
194
  },
179
195
  __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
180
- const ret = arg0[arg1];
181
- return ret;
196
+ const ret = getObject(arg0)[getObject(arg1)];
197
+ return addHeapObject(ret);
182
198
  },
183
199
  __wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
184
200
  let result;
185
201
  try {
186
- result = arg0 instanceof ArrayBuffer;
202
+ result = getObject(arg0) instanceof ArrayBuffer;
187
203
  } catch (_) {
188
204
  result = false;
189
205
  }
@@ -193,7 +209,7 @@ function __wbg_get_imports() {
193
209
  __wbg_instanceof_Map_e5b5e3db98422fcc: function(arg0) {
194
210
  let result;
195
211
  try {
196
- result = arg0 instanceof Map;
212
+ result = getObject(arg0) instanceof Map;
197
213
  } catch (_) {
198
214
  result = false;
199
215
  }
@@ -203,7 +219,7 @@ function __wbg_get_imports() {
203
219
  __wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
204
220
  let result;
205
221
  try {
206
- result = arg0 instanceof Uint8Array;
222
+ result = getObject(arg0) instanceof Uint8Array;
207
223
  } catch (_) {
208
224
  result = false;
209
225
  }
@@ -211,86 +227,84 @@ function __wbg_get_imports() {
211
227
  return ret;
212
228
  },
213
229
  __wbg_isArray_0677c962b281d01a: function(arg0) {
214
- const ret = Array.isArray(arg0);
230
+ const ret = Array.isArray(getObject(arg0));
215
231
  return ret;
216
232
  },
217
233
  __wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
218
- const ret = Number.isSafeInteger(arg0);
234
+ const ret = Number.isSafeInteger(getObject(arg0));
219
235
  return ret;
220
236
  },
221
237
  __wbg_iterator_6f722e4a93058b71: function() {
222
238
  const ret = Symbol.iterator;
223
- return ret;
239
+ return addHeapObject(ret);
224
240
  },
225
241
  __wbg_length_1f0964f4a5e2c6d8: function(arg0) {
226
- const ret = arg0.length;
242
+ const ret = getObject(arg0).length;
227
243
  return ret;
228
244
  },
229
245
  __wbg_length_370319915dc99107: function(arg0) {
230
- const ret = arg0.length;
246
+ const ret = getObject(arg0).length;
231
247
  return ret;
232
248
  },
233
249
  __wbg_new_32b398fb48b6d94a: function() {
234
250
  const ret = new Array();
235
- return ret;
251
+ return addHeapObject(ret);
236
252
  },
237
253
  __wbg_new_cd45aabdf6073e84: function(arg0) {
238
- const ret = new Uint8Array(arg0);
239
- return ret;
254
+ const ret = new Uint8Array(getObject(arg0));
255
+ return addHeapObject(ret);
240
256
  },
241
257
  __wbg_new_da52cf8fe3429cb2: function() {
242
258
  const ret = new Object();
243
- return ret;
259
+ return addHeapObject(ret);
244
260
  },
245
261
  __wbg_next_6dbf2c0ac8cde20f: function(arg0) {
246
- const ret = arg0.next;
247
- return ret;
262
+ const ret = getObject(arg0).next;
263
+ return addHeapObject(ret);
248
264
  },
249
265
  __wbg_next_71f2aa1cb3d1e37e: function() { return handleError(function (arg0) {
250
- const ret = arg0.next();
251
- return ret;
266
+ const ret = getObject(arg0).next();
267
+ return addHeapObject(ret);
252
268
  }, arguments); },
253
269
  __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
254
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
270
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
255
271
  },
256
272
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
257
- arg0[arg1] = arg2;
273
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
258
274
  },
259
275
  __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
260
- arg0[arg1 >>> 0] = arg2;
276
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
261
277
  },
262
278
  __wbg_value_a5d5488a9589444a: function(arg0) {
263
- const ret = arg0.value;
264
- return ret;
279
+ const ret = getObject(arg0).value;
280
+ return addHeapObject(ret);
265
281
  },
266
282
  __wbindgen_cast_0000000000000001: function(arg0) {
267
283
  // Cast intrinsic for `F64 -> Externref`.
268
284
  const ret = arg0;
269
- return ret;
285
+ return addHeapObject(ret);
270
286
  },
271
287
  __wbindgen_cast_0000000000000002: function(arg0) {
272
288
  // Cast intrinsic for `I64 -> Externref`.
273
289
  const ret = arg0;
274
- return ret;
290
+ return addHeapObject(ret);
275
291
  },
276
292
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
277
293
  // Cast intrinsic for `Ref(String) -> Externref`.
278
294
  const ret = getStringFromWasm0(arg0, arg1);
279
- return ret;
295
+ return addHeapObject(ret);
280
296
  },
281
297
  __wbindgen_cast_0000000000000004: function(arg0) {
282
298
  // Cast intrinsic for `U64 -> Externref`.
283
299
  const ret = BigInt.asUintN(64, arg0);
284
- return ret;
300
+ return addHeapObject(ret);
285
301
  },
286
- __wbindgen_init_externref_table: function() {
287
- const table = wasm.__wbindgen_externrefs;
288
- const offset = table.grow(4);
289
- table.set(0, undefined);
290
- table.set(offset + 0, undefined);
291
- table.set(offset + 1, null);
292
- table.set(offset + 2, true);
293
- table.set(offset + 3, false);
302
+ __wbindgen_object_clone_ref: function(arg0) {
303
+ const ret = getObject(arg0);
304
+ return addHeapObject(ret);
305
+ },
306
+ __wbindgen_object_drop_ref: function(arg0) {
307
+ takeObject(arg0);
294
308
  },
295
309
  };
296
310
  return {
@@ -299,9 +313,12 @@ function __wbg_get_imports() {
299
313
  };
300
314
  }
301
315
 
302
- function addToExternrefTable0(obj) {
303
- const idx = wasm.__externref_table_alloc();
304
- wasm.__wbindgen_externrefs.set(idx, obj);
316
+ function addHeapObject(obj) {
317
+ if (heap_next === heap.length) heap.push(heap.length + 1);
318
+ const idx = heap_next;
319
+ heap_next = heap[idx];
320
+
321
+ heap[idx] = obj;
305
322
  return idx;
306
323
  }
307
324
 
@@ -370,6 +387,12 @@ function debugString(val) {
370
387
  return className;
371
388
  }
372
389
 
390
+ function dropObject(idx) {
391
+ if (idx < 1028) return;
392
+ heap[idx] = heap_next;
393
+ heap_next = idx;
394
+ }
395
+
373
396
  function getArrayU8FromWasm0(ptr, len) {
374
397
  ptr = ptr >>> 0;
375
398
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -395,15 +418,21 @@ function getUint8ArrayMemory0() {
395
418
  return cachedUint8ArrayMemory0;
396
419
  }
397
420
 
421
+ function getObject(idx) { return heap[idx]; }
422
+
398
423
  function handleError(f, args) {
399
424
  try {
400
425
  return f.apply(this, args);
401
426
  } catch (e) {
402
- const idx = addToExternrefTable0(e);
403
- wasm.__wbindgen_exn_store(idx);
427
+ wasm.__wbindgen_export3(addHeapObject(e));
404
428
  }
405
429
  }
406
430
 
431
+ let heap = new Array(1024).fill(undefined);
432
+ heap.push(undefined, null, true, false);
433
+
434
+ let heap_next = heap.length;
435
+
407
436
  function isLikeNone(x) {
408
437
  return x === undefined || x === null;
409
438
  }
@@ -445,6 +474,12 @@ function passStringToWasm0(arg, malloc, realloc) {
445
474
  return ptr;
446
475
  }
447
476
 
477
+ function takeObject(idx) {
478
+ const ret = getObject(idx);
479
+ dropObject(idx);
480
+ return ret;
481
+ }
482
+
448
483
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
449
484
  cachedTextDecoder.decode();
450
485
  function decodeText(ptr, len) {
@@ -471,4 +506,3 @@ const wasmBytes = require('fs').readFileSync(wasmPath);
471
506
  const wasmModule = new WebAssembly.Module(wasmBytes);
472
507
  let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
473
508
  let wasm = wasmInstance.exports;
474
- wasm.__wbindgen_start();
Binary file
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Kent Rasmussen <hyprkookeez@gmail.com>"
5
5
  ],
6
- "version": "0.4.7",
6
+ "version": "0.5.0",
7
7
  "files": [
8
8
  "alpathfinder_bg.wasm",
9
9
  "alpathfinder.js",