alpathfinder 0.2.8 → 0.2.9

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 CHANGED
@@ -2,18 +2,53 @@
2
2
 
3
3
  A Rust/WASM Pathfinder for Adventure.Land.
4
4
 
5
- This project is a work in progress. It currently doesn't work.
5
+ ## Usage
6
6
 
7
- ## Build
7
+ 1. Run `npm i alpathfinder` to install.
8
+ 2. Import the pathfinder
8
9
 
9
- 1. Run `wasm-pack build` to build.
10
- 2. Add the following lines to `package.json`:
10
+ ```js
11
+ import * as ALPathfinder from "alpathfinder";
12
+ ```
13
+
14
+ 3. Prepare the pathfinder with values from `G` and an optional list of maps you wish to ignore.
15
+
16
+ ```js
17
+ const ignoreMaps = [
18
+ "abtesting",
19
+ "bank_b", // NOTE: Don't ignore if you have access
20
+ "bank_u", // NOTE: Don't ignore if you have access
21
+ "cgallery",
22
+ "d2",
23
+ "d_e",
24
+ "duelland",
25
+ "shellsisland",
26
+ "ship0",
27
+ "test",
28
+ "old_bank",
29
+ "old_main",
30
+ "original_main",
31
+ "resort",
32
+ "resort_e",
33
+ ];
34
+ ALPathfinder.prepare(parent.G, ignoreMaps);
35
+ ```
36
+
37
+ 4. Use the pathfinder
11
38
 
12
39
  ```js
13
- "main": "alpathfinder.js",
14
- "type": "module",
40
+ ALPathfinder.canWalkPath(character.map, character.x, character.y, 123, 456)
41
+ const path = ALPathfinder.getPath(character.map, character.x, character.y, "spookytown", 0, 0, character.speed);
42
+ pathfinder.isWalkable("main", 200, 20)
15
43
  ```
16
44
 
17
- ## Use Locally
45
+ ## Development
46
+
47
+ ### Build
48
+
49
+ 1. Run `wasm-pack build` to build.
50
+ 2. Add `typed-adventureland` as a dependency
51
+
52
+ ### Test
18
53
 
19
- 1. In the node project you want to use the pathfinder, run `npm install alpathfinder@file:../path/to/alpathfinder`.
54
+ 1. After building, install the package by referencing the `pkg` directory that was built `npm i ../path/to/alpathfinder/pkg`.
package/alpathfinder.d.ts CHANGED
@@ -1,10 +1,36 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
- export function canWalkPath(map_name: string, x1: number, y1: number, x2: number, y2: number): boolean;
4
+ import type { GData, MapKey } from "typed-adventureland";
5
5
 
6
- export function getPath(map_from_name: string, x_from: number, y_from: number, map_to_name: string, x_to: number, y_to: number, speed?: number | null): any;
6
+ export interface PathNode {
7
+ map: MapKey;
8
+ x: number;
9
+ y: number;
10
+ method: "move" | "town" | "door" | "transport" | "enter" | "unknown";
11
+ spawn?: number;
12
+ }
7
13
 
8
- export function isWalkable(map_name: string, x_i: number, y_i: number): boolean;
14
+ export function canWalkPath(
15
+ map: MapKey,
16
+ x_from: number,
17
+ y_from: number,
18
+ x_to: number,
19
+ y_to: number,
20
+ ): boolean;
21
+
22
+ export function getPath(
23
+ map_from: MapKey,
24
+ x_from: number,
25
+ y_from: number,
26
+ map_to: MapKey,
27
+ x_to: number,
28
+ y_to: number,
29
+ /** How fast your character can walk. Setting this to a very high number can also reduce the number of town warps. */
30
+ speed?: number,
31
+ ): PathNode[] | null;
32
+
33
+ export function isWalkable(map: MapKey, x: number, y: number): boolean;
34
+
35
+ export function prepare(g: GData, exclude_maps?: MapKey[]): void;
9
36
 
10
- export function prepare(g_js: any, exclude_maps?: any | null): void;
package/alpathfinder.js CHANGED
@@ -1,456 +1,5 @@
1
- /* @ts-self-types="./alpathfinder.d.ts" */
2
-
3
- /**
4
- * @param {string} map_name
5
- * @param {number} x1
6
- * @param {number} y1
7
- * @param {number} x2
8
- * @param {number} y2
9
- * @returns {boolean}
10
- */
11
- function canWalkPath(map_name, x1, y1, x2, y2) {
12
- const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
13
- const len0 = WASM_VECTOR_LEN;
14
- const ret = wasm.canWalkPath(ptr0, len0, x1, y1, x2, y2);
15
- return ret !== 0;
16
- }
17
- exports.canWalkPath = canWalkPath;
18
-
19
- /**
20
- * @param {string} map_from_name
21
- * @param {number} x_from
22
- * @param {number} y_from
23
- * @param {string} map_to_name
24
- * @param {number} x_to
25
- * @param {number} y_to
26
- * @param {number | null} [speed]
27
- * @returns {any}
28
- */
29
- function getPath(map_from_name, x_from, y_from, map_to_name, x_to, y_to, speed) {
30
- const ptr0 = passStringToWasm0(map_from_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
31
- const len0 = WASM_VECTOR_LEN;
32
- const ptr1 = passStringToWasm0(map_to_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
33
- const len1 = WASM_VECTOR_LEN;
34
- const ret = wasm.getPath(ptr0, len0, x_from, y_from, ptr1, len1, x_to, y_to, isLikeNone(speed) ? 0x100000001 : Math.fround(speed));
35
- return ret;
36
- }
37
- exports.getPath = getPath;
38
-
39
- /**
40
- * @param {string} map_name
41
- * @param {number} x_i
42
- * @param {number} y_i
43
- * @returns {boolean}
44
- */
45
- function isWalkable(map_name, x_i, y_i) {
46
- const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
47
- const len0 = WASM_VECTOR_LEN;
48
- const ret = wasm.isWalkable(ptr0, len0, x_i, y_i);
49
- return ret !== 0;
50
- }
51
- exports.isWalkable = isWalkable;
52
-
53
- /**
54
- * @param {any} g_js
55
- * @param {any | null} [exclude_maps]
56
- */
57
- function prepare(g_js, exclude_maps) {
58
- wasm.prepare(g_js, isLikeNone(exclude_maps) ? 0 : addToExternrefTable0(exclude_maps));
59
- }
60
- exports.prepare = prepare;
61
-
62
- function __wbg_get_imports() {
63
- const import0 = {
64
- __proto__: null,
65
- __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
66
- const ret = Error(getStringFromWasm0(arg0, arg1));
67
- return ret;
68
- },
69
- __wbg_Number_04624de7d0e8332d: function(arg0) {
70
- const ret = Number(arg0);
71
- return ret;
72
- },
73
- __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
74
- const v = arg1;
75
- const ret = typeof(v) === 'bigint' ? v : undefined;
76
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
77
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
78
- },
79
- __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
80
- const v = arg0;
81
- const ret = typeof(v) === 'boolean' ? v : undefined;
82
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
83
- },
84
- __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
85
- const ret = debugString(arg1);
86
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
87
- const len1 = WASM_VECTOR_LEN;
88
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
89
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
90
- },
91
- __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
92
- const ret = arg0 in arg1;
93
- return ret;
94
- },
95
- __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
96
- const ret = typeof(arg0) === 'bigint';
97
- return ret;
98
- },
99
- __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
100
- const ret = typeof(arg0) === 'function';
101
- return ret;
102
- },
103
- __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
104
- const val = arg0;
105
- const ret = typeof(val) === 'object' && val !== null;
106
- return ret;
107
- },
108
- __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
109
- const ret = arg0 === undefined;
110
- return ret;
111
- },
112
- __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
113
- const ret = arg0 === arg1;
114
- return ret;
115
- },
116
- __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
117
- const ret = arg0 == arg1;
118
- return ret;
119
- },
120
- __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
121
- const obj = arg1;
122
- const ret = typeof(obj) === 'number' ? obj : undefined;
123
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
124
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
125
- },
126
- __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
127
- const obj = arg1;
128
- const ret = typeof(obj) === 'string' ? obj : undefined;
129
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
130
- var len1 = WASM_VECTOR_LEN;
131
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
132
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
133
- },
134
- __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
135
- throw new Error(getStringFromWasm0(arg0, arg1));
136
- },
137
- __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
138
- const ret = arg0.call(arg1);
139
- return ret;
140
- }, arguments); },
141
- __wbg_done_57b39ecd9addfe81: function(arg0) {
142
- const ret = arg0.done;
143
- return ret;
144
- },
145
- __wbg_entries_58c7934c745daac7: function(arg0) {
146
- const ret = Object.entries(arg0);
147
- return ret;
148
- },
149
- __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
150
- const ret = arg0[arg1 >>> 0];
151
- return ret;
152
- },
153
- __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
154
- const ret = Reflect.get(arg0, arg1);
155
- return ret;
156
- }, arguments); },
157
- __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
158
- const ret = arg0[arg1];
159
- return ret;
160
- },
161
- __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
162
- let result;
163
- try {
164
- result = arg0 instanceof ArrayBuffer;
165
- } catch (_) {
166
- result = false;
167
- }
168
- const ret = result;
169
- return ret;
170
- },
171
- __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
172
- let result;
173
- try {
174
- result = arg0 instanceof Map;
175
- } catch (_) {
176
- result = false;
177
- }
178
- const ret = result;
179
- return ret;
180
- },
181
- __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
182
- let result;
183
- try {
184
- result = arg0 instanceof Uint8Array;
185
- } catch (_) {
186
- result = false;
187
- }
188
- const ret = result;
189
- return ret;
190
- },
191
- __wbg_isArray_d314bb98fcf08331: function(arg0) {
192
- const ret = Array.isArray(arg0);
193
- return ret;
194
- },
195
- __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
196
- const ret = Number.isSafeInteger(arg0);
197
- return ret;
198
- },
199
- __wbg_iterator_6ff6560ca1568e55: function() {
200
- const ret = Symbol.iterator;
201
- return ret;
202
- },
203
- __wbg_length_32ed9a279acd054c: function(arg0) {
204
- const ret = arg0.length;
205
- return ret;
206
- },
207
- __wbg_length_35a7bace40f36eac: function(arg0) {
208
- const ret = arg0.length;
209
- return ret;
210
- },
211
- __wbg_new_361308b2356cecd0: function() {
212
- const ret = new Object();
213
- return ret;
214
- },
215
- __wbg_new_3eb36ae241fe6f44: function() {
216
- const ret = new Array();
217
- return ret;
218
- },
219
- __wbg_new_dd2b680c8bf6ae29: function(arg0) {
220
- const ret = new Uint8Array(arg0);
221
- return ret;
222
- },
223
- __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
224
- const ret = arg0.next();
225
- return ret;
226
- }, arguments); },
227
- __wbg_next_418f80d8f5303233: function(arg0) {
228
- const ret = arg0.next;
229
- return ret;
230
- },
231
- __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
232
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
233
- },
234
- __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
235
- arg0[arg1] = arg2;
236
- },
237
- __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
238
- arg0[arg1 >>> 0] = arg2;
239
- },
240
- __wbg_value_0546255b415e96c1: function(arg0) {
241
- const ret = arg0.value;
242
- return ret;
243
- },
244
- __wbindgen_cast_0000000000000001: function(arg0) {
245
- // Cast intrinsic for `F64 -> Externref`.
246
- const ret = arg0;
247
- return ret;
248
- },
249
- __wbindgen_cast_0000000000000002: function(arg0) {
250
- // Cast intrinsic for `I64 -> Externref`.
251
- const ret = arg0;
252
- return ret;
253
- },
254
- __wbindgen_cast_0000000000000003: function(arg0, arg1) {
255
- // Cast intrinsic for `Ref(String) -> Externref`.
256
- const ret = getStringFromWasm0(arg0, arg1);
257
- return ret;
258
- },
259
- __wbindgen_cast_0000000000000004: function(arg0) {
260
- // Cast intrinsic for `U64 -> Externref`.
261
- const ret = BigInt.asUintN(64, arg0);
262
- return ret;
263
- },
264
- __wbindgen_init_externref_table: function() {
265
- const table = wasm.__wbindgen_externrefs;
266
- const offset = table.grow(4);
267
- table.set(0, undefined);
268
- table.set(offset + 0, undefined);
269
- table.set(offset + 1, null);
270
- table.set(offset + 2, true);
271
- table.set(offset + 3, false);
272
- },
273
- __wbindgen_object_is_undefined: function(arg0) {
274
- const ret = arg0 === undefined;
275
- return ret;
276
- },
277
- };
278
- return {
279
- __proto__: null,
280
- "./alpathfinder_bg.js": import0,
281
- };
282
- }
283
-
284
- function addToExternrefTable0(obj) {
285
- const idx = wasm.__externref_table_alloc();
286
- wasm.__wbindgen_externrefs.set(idx, obj);
287
- return idx;
288
- }
289
-
290
- function debugString(val) {
291
- // primitive types
292
- const type = typeof val;
293
- if (type == 'number' || type == 'boolean' || val == null) {
294
- return `${val}`;
295
- }
296
- if (type == 'string') {
297
- return `"${val}"`;
298
- }
299
- if (type == 'symbol') {
300
- const description = val.description;
301
- if (description == null) {
302
- return 'Symbol';
303
- } else {
304
- return `Symbol(${description})`;
305
- }
306
- }
307
- if (type == 'function') {
308
- const name = val.name;
309
- if (typeof name == 'string' && name.length > 0) {
310
- return `Function(${name})`;
311
- } else {
312
- return 'Function';
313
- }
314
- }
315
- // objects
316
- if (Array.isArray(val)) {
317
- const length = val.length;
318
- let debug = '[';
319
- if (length > 0) {
320
- debug += debugString(val[0]);
321
- }
322
- for(let i = 1; i < length; i++) {
323
- debug += ', ' + debugString(val[i]);
324
- }
325
- debug += ']';
326
- return debug;
327
- }
328
- // Test for built-in
329
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
330
- let className;
331
- if (builtInMatches && builtInMatches.length > 1) {
332
- className = builtInMatches[1];
333
- } else {
334
- // Failed to match the standard '[object ClassName]'
335
- return toString.call(val);
336
- }
337
- if (className == 'Object') {
338
- // we're a user defined class or Object
339
- // JSON.stringify avoids problems with cycles, and is generally much
340
- // easier than looping through ownProperties of `val`.
341
- try {
342
- return 'Object(' + JSON.stringify(val) + ')';
343
- } catch (_) {
344
- return 'Object';
345
- }
346
- }
347
- // errors
348
- if (val instanceof Error) {
349
- return `${val.name}: ${val.message}\n${val.stack}`;
350
- }
351
- // TODO we could test for more things here, like `Set`s and `Map`s.
352
- return className;
353
- }
354
-
355
- function getArrayU8FromWasm0(ptr, len) {
356
- ptr = ptr >>> 0;
357
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
358
- }
359
-
360
- let cachedDataViewMemory0 = null;
361
- function getDataViewMemory0() {
362
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
363
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
364
- }
365
- return cachedDataViewMemory0;
366
- }
367
-
368
- function getStringFromWasm0(ptr, len) {
369
- ptr = ptr >>> 0;
370
- return decodeText(ptr, len);
371
- }
372
-
373
- let cachedUint8ArrayMemory0 = null;
374
- function getUint8ArrayMemory0() {
375
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
376
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
377
- }
378
- return cachedUint8ArrayMemory0;
379
- }
380
-
381
- function handleError(f, args) {
382
- try {
383
- return f.apply(this, args);
384
- } catch (e) {
385
- const idx = addToExternrefTable0(e);
386
- wasm.__wbindgen_exn_store(idx);
387
- }
388
- }
389
-
390
- function isLikeNone(x) {
391
- return x === undefined || x === null;
392
- }
393
-
394
- function passStringToWasm0(arg, malloc, realloc) {
395
- if (realloc === undefined) {
396
- const buf = cachedTextEncoder.encode(arg);
397
- const ptr = malloc(buf.length, 1) >>> 0;
398
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
399
- WASM_VECTOR_LEN = buf.length;
400
- return ptr;
401
- }
402
-
403
- let len = arg.length;
404
- let ptr = malloc(len, 1) >>> 0;
405
-
406
- const mem = getUint8ArrayMemory0();
407
-
408
- let offset = 0;
409
-
410
- for (; offset < len; offset++) {
411
- const code = arg.charCodeAt(offset);
412
- if (code > 0x7F) break;
413
- mem[ptr + offset] = code;
414
- }
415
- if (offset !== len) {
416
- if (offset !== 0) {
417
- arg = arg.slice(offset);
418
- }
419
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
420
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
421
- const ret = cachedTextEncoder.encodeInto(arg, view);
422
-
423
- offset += ret.written;
424
- ptr = realloc(ptr, len, offset, 1) >>> 0;
425
- }
426
-
427
- WASM_VECTOR_LEN = offset;
428
- return ptr;
429
- }
430
-
431
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
432
- cachedTextDecoder.decode();
433
- function decodeText(ptr, len) {
434
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
435
- }
436
-
437
- const cachedTextEncoder = new TextEncoder();
438
-
439
- if (!('encodeInto' in cachedTextEncoder)) {
440
- cachedTextEncoder.encodeInto = function (arg, view) {
441
- const buf = cachedTextEncoder.encode(arg);
442
- view.set(buf);
443
- return {
444
- read: arg.length,
445
- written: buf.length
446
- };
447
- };
448
- }
449
-
450
- let WASM_VECTOR_LEN = 0;
451
-
452
- const wasmPath = `${__dirname}/alpathfinder_bg.wasm`;
453
- const wasmBytes = require('fs').readFileSync(wasmPath);
454
- const wasmModule = new WebAssembly.Module(wasmBytes);
455
- const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
1
+ import * as wasm from "./alpathfinder_bg.wasm";
2
+ export * from "./alpathfinder_bg.js";
3
+ import { __wbg_set_wasm } from "./alpathfinder_bg.js";
4
+ __wbg_set_wasm(wasm);
456
5
  wasm.__wbindgen_start();
@@ -0,0 +1,499 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
+
18
+ cachedTextDecoder.decode();
19
+
20
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
21
+ let numBytesDecoded = 0;
22
+ function decodeText(ptr, len) {
23
+ numBytesDecoded += len;
24
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
25
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+ cachedTextDecoder.decode();
27
+ numBytesDecoded = len;
28
+ }
29
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
30
+ }
31
+
32
+ function getStringFromWasm0(ptr, len) {
33
+ ptr = ptr >>> 0;
34
+ return decodeText(ptr, len);
35
+ }
36
+
37
+ function isLikeNone(x) {
38
+ return x === undefined || x === null;
39
+ }
40
+
41
+ let cachedDataViewMemory0 = null;
42
+
43
+ function getDataViewMemory0() {
44
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
45
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
46
+ }
47
+ return cachedDataViewMemory0;
48
+ }
49
+
50
+ function debugString(val) {
51
+ // primitive types
52
+ const type = typeof val;
53
+ if (type == 'number' || type == 'boolean' || val == null) {
54
+ return `${val}`;
55
+ }
56
+ if (type == 'string') {
57
+ return `"${val}"`;
58
+ }
59
+ if (type == 'symbol') {
60
+ const description = val.description;
61
+ if (description == null) {
62
+ return 'Symbol';
63
+ } else {
64
+ return `Symbol(${description})`;
65
+ }
66
+ }
67
+ if (type == 'function') {
68
+ const name = val.name;
69
+ if (typeof name == 'string' && name.length > 0) {
70
+ return `Function(${name})`;
71
+ } else {
72
+ return 'Function';
73
+ }
74
+ }
75
+ // objects
76
+ if (Array.isArray(val)) {
77
+ const length = val.length;
78
+ let debug = '[';
79
+ if (length > 0) {
80
+ debug += debugString(val[0]);
81
+ }
82
+ for(let i = 1; i < length; i++) {
83
+ debug += ', ' + debugString(val[i]);
84
+ }
85
+ debug += ']';
86
+ return debug;
87
+ }
88
+ // Test for built-in
89
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
90
+ let className;
91
+ if (builtInMatches && builtInMatches.length > 1) {
92
+ className = builtInMatches[1];
93
+ } else {
94
+ // Failed to match the standard '[object ClassName]'
95
+ return toString.call(val);
96
+ }
97
+ if (className == 'Object') {
98
+ // we're a user defined class or Object
99
+ // JSON.stringify avoids problems with cycles, and is generally much
100
+ // easier than looping through ownProperties of `val`.
101
+ try {
102
+ return 'Object(' + JSON.stringify(val) + ')';
103
+ } catch (_) {
104
+ return 'Object';
105
+ }
106
+ }
107
+ // errors
108
+ if (val instanceof Error) {
109
+ return `${val.name}: ${val.message}\n${val.stack}`;
110
+ }
111
+ // TODO we could test for more things here, like `Set`s and `Map`s.
112
+ return className;
113
+ }
114
+
115
+ let WASM_VECTOR_LEN = 0;
116
+
117
+ const cachedTextEncoder = new TextEncoder();
118
+
119
+ if (!('encodeInto' in cachedTextEncoder)) {
120
+ cachedTextEncoder.encodeInto = function (arg, view) {
121
+ const buf = cachedTextEncoder.encode(arg);
122
+ view.set(buf);
123
+ return {
124
+ read: arg.length,
125
+ written: buf.length
126
+ };
127
+ }
128
+ }
129
+
130
+ function passStringToWasm0(arg, malloc, realloc) {
131
+
132
+ if (realloc === undefined) {
133
+ const buf = cachedTextEncoder.encode(arg);
134
+ const ptr = malloc(buf.length, 1) >>> 0;
135
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
136
+ WASM_VECTOR_LEN = buf.length;
137
+ return ptr;
138
+ }
139
+
140
+ let len = arg.length;
141
+ let ptr = malloc(len, 1) >>> 0;
142
+
143
+ const mem = getUint8ArrayMemory0();
144
+
145
+ let offset = 0;
146
+
147
+ for (; offset < len; offset++) {
148
+ const code = arg.charCodeAt(offset);
149
+ if (code > 0x7F) break;
150
+ mem[ptr + offset] = code;
151
+ }
152
+
153
+ if (offset !== len) {
154
+ if (offset !== 0) {
155
+ arg = arg.slice(offset);
156
+ }
157
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
158
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
159
+ const ret = cachedTextEncoder.encodeInto(arg, view);
160
+
161
+ offset += ret.written;
162
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
163
+ }
164
+
165
+ WASM_VECTOR_LEN = offset;
166
+ return ptr;
167
+ }
168
+
169
+ function addToExternrefTable0(obj) {
170
+ const idx = wasm.__externref_table_alloc();
171
+ wasm.__wbindgen_externrefs.set(idx, obj);
172
+ return idx;
173
+ }
174
+
175
+ function handleError(f, args) {
176
+ try {
177
+ return f.apply(this, args);
178
+ } catch (e) {
179
+ const idx = addToExternrefTable0(e);
180
+ wasm.__wbindgen_exn_store(idx);
181
+ }
182
+ }
183
+
184
+ function getArrayU8FromWasm0(ptr, len) {
185
+ ptr = ptr >>> 0;
186
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
187
+ }
188
+ /**
189
+ * @param {any} g_js
190
+ * @param {any | null} [exclude_maps]
191
+ */
192
+ export function prepare(g_js, exclude_maps) {
193
+ wasm.prepare(g_js, isLikeNone(exclude_maps) ? 0 : addToExternrefTable0(exclude_maps));
194
+ }
195
+
196
+ /**
197
+ * @param {string} map_name
198
+ * @param {number} x1
199
+ * @param {number} y1
200
+ * @param {number} x2
201
+ * @param {number} y2
202
+ * @returns {boolean}
203
+ */
204
+ export function canWalkPath(map_name, x1, y1, x2, y2) {
205
+ const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
206
+ const len0 = WASM_VECTOR_LEN;
207
+ const ret = wasm.canWalkPath(ptr0, len0, x1, y1, x2, y2);
208
+ return ret !== 0;
209
+ }
210
+
211
+ /**
212
+ * @param {string} map_from_name
213
+ * @param {number} x_from
214
+ * @param {number} y_from
215
+ * @param {string} map_to_name
216
+ * @param {number} x_to
217
+ * @param {number} y_to
218
+ * @param {number | null} [speed]
219
+ * @returns {any}
220
+ */
221
+ export function getPath(map_from_name, x_from, y_from, map_to_name, x_to, y_to, speed) {
222
+ const ptr0 = passStringToWasm0(map_from_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
223
+ const len0 = WASM_VECTOR_LEN;
224
+ const ptr1 = passStringToWasm0(map_to_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
225
+ const len1 = WASM_VECTOR_LEN;
226
+ const ret = wasm.getPath(ptr0, len0, x_from, y_from, ptr1, len1, x_to, y_to, isLikeNone(speed) ? 0x100000001 : Math.fround(speed));
227
+ return ret;
228
+ }
229
+
230
+ /**
231
+ * @param {string} map_name
232
+ * @param {number} x_i
233
+ * @param {number} y_i
234
+ * @returns {boolean}
235
+ */
236
+ export function isWalkable(map_name, x_i, y_i) {
237
+ const ptr0 = passStringToWasm0(map_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
238
+ const len0 = WASM_VECTOR_LEN;
239
+ const ret = wasm.isWalkable(ptr0, len0, x_i, y_i);
240
+ return ret !== 0;
241
+ }
242
+
243
+ export function __wbg_Error_e83987f665cf5504(arg0, arg1) {
244
+ const ret = Error(getStringFromWasm0(arg0, arg1));
245
+ return ret;
246
+ };
247
+
248
+ export function __wbg_Number_bb48ca12f395cd08(arg0) {
249
+ const ret = Number(arg0);
250
+ return ret;
251
+ };
252
+
253
+ export function __wbg___wbindgen_bigint_get_as_i64_f3ebc5a755000afd(arg0, arg1) {
254
+ const v = arg1;
255
+ const ret = typeof(v) === 'bigint' ? v : undefined;
256
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
257
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
258
+ };
259
+
260
+ export function __wbg___wbindgen_boolean_get_6d5a1ee65bab5f68(arg0) {
261
+ const v = arg0;
262
+ const ret = typeof(v) === 'boolean' ? v : undefined;
263
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
264
+ };
265
+
266
+ export function __wbg___wbindgen_debug_string_df47ffb5e35e6763(arg0, arg1) {
267
+ const ret = debugString(arg1);
268
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
269
+ const len1 = WASM_VECTOR_LEN;
270
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
271
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
272
+ };
273
+
274
+ export function __wbg___wbindgen_in_bb933bd9e1b3bc0f(arg0, arg1) {
275
+ const ret = arg0 in arg1;
276
+ return ret;
277
+ };
278
+
279
+ export function __wbg___wbindgen_is_bigint_cb320707dcd35f0b(arg0) {
280
+ const ret = typeof(arg0) === 'bigint';
281
+ return ret;
282
+ };
283
+
284
+ export function __wbg___wbindgen_is_function_ee8a6c5833c90377(arg0) {
285
+ const ret = typeof(arg0) === 'function';
286
+ return ret;
287
+ };
288
+
289
+ export function __wbg___wbindgen_is_object_c818261d21f283a4(arg0) {
290
+ const val = arg0;
291
+ const ret = typeof(val) === 'object' && val !== null;
292
+ return ret;
293
+ };
294
+
295
+ export function __wbg___wbindgen_is_undefined_2d472862bd29a478(arg0) {
296
+ const ret = arg0 === undefined;
297
+ return ret;
298
+ };
299
+
300
+ export function __wbg___wbindgen_jsval_eq_6b13ab83478b1c50(arg0, arg1) {
301
+ const ret = arg0 === arg1;
302
+ return ret;
303
+ };
304
+
305
+ export function __wbg___wbindgen_jsval_loose_eq_b664b38a2f582147(arg0, arg1) {
306
+ const ret = arg0 == arg1;
307
+ return ret;
308
+ };
309
+
310
+ export function __wbg___wbindgen_number_get_a20bf9b85341449d(arg0, arg1) {
311
+ const obj = arg1;
312
+ const ret = typeof(obj) === 'number' ? obj : undefined;
313
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
314
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
315
+ };
316
+
317
+ export function __wbg___wbindgen_string_get_e4f06c90489ad01b(arg0, arg1) {
318
+ const obj = arg1;
319
+ const ret = typeof(obj) === 'string' ? obj : undefined;
320
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
321
+ var len1 = WASM_VECTOR_LEN;
322
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
323
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
324
+ };
325
+
326
+ export function __wbg___wbindgen_throw_b855445ff6a94295(arg0, arg1) {
327
+ throw new Error(getStringFromWasm0(arg0, arg1));
328
+ };
329
+
330
+ export function __wbg_call_e762c39fa8ea36bf() { return handleError(function (arg0, arg1) {
331
+ const ret = arg0.call(arg1);
332
+ return ret;
333
+ }, arguments) };
334
+
335
+ export function __wbg_done_2042aa2670fb1db1(arg0) {
336
+ const ret = arg0.done;
337
+ return ret;
338
+ };
339
+
340
+ export function __wbg_entries_e171b586f8f6bdbf(arg0) {
341
+ const ret = Object.entries(arg0);
342
+ return ret;
343
+ };
344
+
345
+ export function __wbg_get_7bed016f185add81(arg0, arg1) {
346
+ const ret = arg0[arg1 >>> 0];
347
+ return ret;
348
+ };
349
+
350
+ export function __wbg_get_efcb449f58ec27c2() { return handleError(function (arg0, arg1) {
351
+ const ret = Reflect.get(arg0, arg1);
352
+ return ret;
353
+ }, arguments) };
354
+
355
+ export function __wbg_get_with_ref_key_1dc361bd10053bfe(arg0, arg1) {
356
+ const ret = arg0[arg1];
357
+ return ret;
358
+ };
359
+
360
+ export function __wbg_instanceof_ArrayBuffer_70beb1189ca63b38(arg0) {
361
+ let result;
362
+ try {
363
+ result = arg0 instanceof ArrayBuffer;
364
+ } catch (_) {
365
+ result = false;
366
+ }
367
+ const ret = result;
368
+ return ret;
369
+ };
370
+
371
+ export function __wbg_instanceof_Map_8579b5e2ab5437c7(arg0) {
372
+ let result;
373
+ try {
374
+ result = arg0 instanceof Map;
375
+ } catch (_) {
376
+ result = false;
377
+ }
378
+ const ret = result;
379
+ return ret;
380
+ };
381
+
382
+ export function __wbg_instanceof_Uint8Array_20c8e73002f7af98(arg0) {
383
+ let result;
384
+ try {
385
+ result = arg0 instanceof Uint8Array;
386
+ } catch (_) {
387
+ result = false;
388
+ }
389
+ const ret = result;
390
+ return ret;
391
+ };
392
+
393
+ export function __wbg_isArray_96e0af9891d0945d(arg0) {
394
+ const ret = Array.isArray(arg0);
395
+ return ret;
396
+ };
397
+
398
+ export function __wbg_isSafeInteger_d216eda7911dde36(arg0) {
399
+ const ret = Number.isSafeInteger(arg0);
400
+ return ret;
401
+ };
402
+
403
+ export function __wbg_iterator_e5822695327a3c39() {
404
+ const ret = Symbol.iterator;
405
+ return ret;
406
+ };
407
+
408
+ export function __wbg_length_69bca3cb64fc8748(arg0) {
409
+ const ret = arg0.length;
410
+ return ret;
411
+ };
412
+
413
+ export function __wbg_length_cdd215e10d9dd507(arg0) {
414
+ const ret = arg0.length;
415
+ return ret;
416
+ };
417
+
418
+ export function __wbg_new_1acc0b6eea89d040() {
419
+ const ret = new Object();
420
+ return ret;
421
+ };
422
+
423
+ export function __wbg_new_5a79be3ab53b8aa5(arg0) {
424
+ const ret = new Uint8Array(arg0);
425
+ return ret;
426
+ };
427
+
428
+ export function __wbg_new_e17d9f43105b08be() {
429
+ const ret = new Array();
430
+ return ret;
431
+ };
432
+
433
+ export function __wbg_next_020810e0ae8ebcb0() { return handleError(function (arg0) {
434
+ const ret = arg0.next();
435
+ return ret;
436
+ }, arguments) };
437
+
438
+ export function __wbg_next_2c826fe5dfec6b6a(arg0) {
439
+ const ret = arg0.next;
440
+ return ret;
441
+ };
442
+
443
+ export function __wbg_prototypesetcall_2a6620b6922694b2(arg0, arg1, arg2) {
444
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
445
+ };
446
+
447
+ export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
448
+ arg0[arg1] = arg2;
449
+ };
450
+
451
+ export function __wbg_set_c213c871859d6500(arg0, arg1, arg2) {
452
+ arg0[arg1 >>> 0] = arg2;
453
+ };
454
+
455
+ export function __wbg_value_692627309814bb8c(arg0) {
456
+ const ret = arg0.value;
457
+ return ret;
458
+ };
459
+
460
+ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
461
+ // Cast intrinsic for `Ref(String) -> Externref`.
462
+ const ret = getStringFromWasm0(arg0, arg1);
463
+ return ret;
464
+ };
465
+
466
+ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
467
+ // Cast intrinsic for `U64 -> Externref`.
468
+ const ret = BigInt.asUintN(64, arg0);
469
+ return ret;
470
+ };
471
+
472
+ export function __wbindgen_cast_9ae0607507abb057(arg0) {
473
+ // Cast intrinsic for `I64 -> Externref`.
474
+ const ret = arg0;
475
+ return ret;
476
+ };
477
+
478
+ export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
479
+ // Cast intrinsic for `F64 -> Externref`.
480
+ const ret = arg0;
481
+ return ret;
482
+ };
483
+
484
+ export function __wbindgen_init_externref_table() {
485
+ const table = wasm.__wbindgen_externrefs;
486
+ const offset = table.grow(4);
487
+ table.set(0, undefined);
488
+ table.set(offset + 0, undefined);
489
+ table.set(offset + 1, null);
490
+ table.set(offset + 2, true);
491
+ table.set(offset + 3, false);
492
+ ;
493
+ };
494
+
495
+ export function __wbindgen_object_is_undefined(arg0) {
496
+ const ret = arg0 === undefined;
497
+ return ret;
498
+ };
499
+
Binary file
package/package.json CHANGED
@@ -1,14 +1,23 @@
1
1
  {
2
2
  "name": "alpathfinder",
3
+ "type": "module",
3
4
  "collaborators": [
4
5
  "Kent Rasmussen <hyprkookeez@gmail.com>"
5
6
  ],
6
- "version": "0.2.8",
7
+ "version": "0.2.9",
7
8
  "files": [
8
9
  "alpathfinder_bg.wasm",
9
10
  "alpathfinder.js",
11
+ "alpathfinder_bg.js",
10
12
  "alpathfinder.d.ts"
11
13
  ],
12
14
  "main": "alpathfinder.js",
13
- "types": "alpathfinder.d.ts"
15
+ "types": "alpathfinder.d.ts",
16
+ "sideEffects": [
17
+ "./alpathfinder.js",
18
+ "./snippets/*"
19
+ ],
20
+ "dependencies": {
21
+ "typed-adventureland": "^0.0.54"
22
+ }
14
23
  }