pathfinding3d 0.1.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,109 @@
1
+ # pathfinding3d
2
+
3
+ [简体中文](README.zh-CN.md)
4
+
5
+ One of the fastest JavaScript 3D pathfinding libraries. `pathfinding3d` implements its core algorithms in Rust and compiles them to WebAssembly, bringing near-native 3D NavMesh pathfinding performance to browsers and Node.js.
6
+
7
+ It is not a Three.js-only plugin. It is a general-purpose WASM 3D pathfinding engine. As long as your JavaScript 3D engine can provide mesh vertex and index data, it can use this library to build navigation zones, query groups, and search paths.
8
+
9
+ ## Highlights
10
+
11
+ - Extreme performance: the core pathfinding pipeline is implemented with Rust + WebAssembly, delivering roughly 10x the performance of `three-pathfinding-3d`.
12
+ - Engine agnostic: not limited to Three.js. It works with Babylon.js, PlayCanvas, Cesium, custom WebGL/WebGPU engines, and any JavaScript 3D scene.
13
+ - Built for 3D NavMesh workflows: create zones from triangle mesh data, then generate smooth paths with groups, nodes, A*, and funnel channels.
14
+ - Low JavaScript overhead: path results are written into a preallocated `Float32Array`, reducing object allocation and GC pressure.
15
+ - Frontend and server ready: packaged with `wasm-pack` for Web, Electron, Node.js, and other JavaScript environments.
16
+
17
+ ## Use Cases
18
+
19
+ - Character navigation in large 3D scenes
20
+ - Web games, digital twins, simulations, editors, and visualization projects
21
+ - Multi-engine projects that need reusable pathfinding without being tied to Three.js
22
+ - Projects that need faster path queries than `three-pathfinding-3d`
23
+
24
+ ## Build
25
+
26
+ Install Rust and `wasm-pack` first:
27
+
28
+ ```bash
29
+ cargo install wasm-pack
30
+ ```
31
+
32
+ Build the WebAssembly npm package:
33
+
34
+ ```bash
35
+ wasm-pack build --release
36
+ ```
37
+
38
+ The generated package will be written to `pkg/` and can be imported directly from JavaScript or TypeScript projects.
39
+
40
+ ## Quick Start
41
+
42
+ ```js
43
+ import init, { PathfindingWasm } from "./pkg/pathfinding3d.js";
44
+
45
+ await init();
46
+
47
+ const pathfinding = new PathfindingWasm();
48
+
49
+ // positions: [x, y, z, x, y, z, ...]
50
+ // indices: [a, b, c, a, b, c, ...]
51
+ pathfinding.create_zone(
52
+ "level-1",
53
+ positions,
54
+ indices,
55
+ 0.0001
56
+ );
57
+
58
+ const groupId = pathfinding.get_group(
59
+ "level-1",
60
+ start.x,
61
+ start.y,
62
+ start.z,
63
+ true
64
+ );
65
+
66
+ const output = new Float32Array(1024 * 3);
67
+ const pointCount = pathfinding.find_path(
68
+ "level-1",
69
+ groupId,
70
+ start.x,
71
+ start.y,
72
+ start.z,
73
+ target.x,
74
+ target.y,
75
+ target.z,
76
+ output
77
+ );
78
+
79
+ const path = [];
80
+ for (let i = 0; i < pointCount; i += 1) {
81
+ path.push({
82
+ x: output[i * 3],
83
+ y: output[i * 3 + 1],
84
+ z: output[i * 3 + 2],
85
+ });
86
+ }
87
+ ```
88
+
89
+ ## API Overview
90
+
91
+ - `create_zone(zoneId, positions, indices, tolerance)`: creates a pathfinding zone from triangle mesh data.
92
+ - `create_zone_handle(positions, indices, tolerance)`: creates a zone and returns a numeric handle.
93
+ - `get_group(zoneId, x, y, z, checkPolygon)`: finds the group containing or nearest to a position.
94
+ - `get_closest_node_id(zoneId, groupId, x, y, z, checkPolygon)`: finds the closest navigation node.
95
+ - `find_path(zoneId, groupId, startX, startY, startZ, targetX, targetY, targetZ, output)`: computes a path and writes it into a `Float32Array`.
96
+ - `group_count(zoneId)`, `group_node_count(zoneId, groupId)`, `group_node_ids(zoneId, groupId)`, `group_node_centers(zoneId, groupId)`: reads zone and group metadata.
97
+
98
+ ## Why It Is Not Tied to Three.js
99
+
100
+ Three.js is only one rendering engine. A pathfinding algorithm needs navigation mesh data, not a specific renderer object model. `pathfinding3d` accepts generic `positions` and `indices` arrays, so any 3D engine can convert its mesh data and pass it in.
101
+
102
+ This means you can use it with Three.js, Babylon.js, PlayCanvas, Cesium, or a custom engine while keeping the same high-performance pathfinding logic.
103
+
104
+ ## License
105
+
106
+ Licensed under either of:
107
+
108
+ - Apache License, Version 2.0, see [LICENSE_APACHE](LICENSE_APACHE)
109
+ - MIT license, see [LICENSE_MIT](LICENSE_MIT)
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "pathfinding3d",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "yangjun <526838933@qq.com>"
6
+ ],
7
+ "version": "0.1.0",
8
+ "files": [
9
+ "pathfinding3d_bg.wasm",
10
+ "pathfinding3d.js",
11
+ "pathfinding3d_bg.js",
12
+ "pathfinding3d.d.ts",
13
+ "package.json"
14
+ ],
15
+ "main": "pathfinding3d.js",
16
+ "types": "pathfinding3d.d.ts",
17
+ "sideEffects": [
18
+ "./pathfinding3d.js",
19
+ "./snippets/*"
20
+ ]
21
+ }
@@ -0,0 +1,20 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class PathfindingWasm {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ create_zone(zone_id: string, positions: Float32Array, indices: Uint32Array, tolerance: number): void;
8
+ create_zone_handle(positions: Float32Array, indices: Uint32Array, tolerance: number): number;
9
+ find_path(zone_id: string, group_id: number, start_x: number, start_y: number, start_z: number, target_x: number, target_y: number, target_z: number, output: Float32Array): number;
10
+ get_closest_node_id(zone_id: string, group_id: number, x: number, y: number, z: number, check_polygon: boolean): number | undefined;
11
+ get_group(zone_id: string, x: number, y: number, z: number, check_polygon: boolean): number | undefined;
12
+ get_group_by_handle(zone_handle: number, x: number, y: number, z: number, check_polygon: boolean): number | undefined;
13
+ group_count(zone_id: string): number | undefined;
14
+ group_count_by_handle(zone_handle: number): number | undefined;
15
+ group_node_centers(zone_id: string, group_id: number): Float64Array | undefined;
16
+ group_node_count(zone_id: string, group_id: number): number | undefined;
17
+ group_node_ids(zone_id: string, group_id: number): Uint32Array | undefined;
18
+ constructor();
19
+ node_center(zone_id: string, group_id: number, node_id: number): Float64Array | undefined;
20
+ }
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./pathfinding3d.d.ts" */
2
+ import * as wasm from "./pathfinding3d_bg.wasm";
3
+ import { __wbg_set_wasm } from "./pathfinding3d_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ PathfindingWasm
9
+ } from "./pathfinding3d_bg.js";
@@ -0,0 +1,388 @@
1
+ export class PathfindingWasm {
2
+ __destroy_into_raw() {
3
+ const ptr = this.__wbg_ptr;
4
+ this.__wbg_ptr = 0;
5
+ PathfindingWasmFinalization.unregister(this);
6
+ return ptr;
7
+ }
8
+ free() {
9
+ const ptr = this.__destroy_into_raw();
10
+ wasm.__wbg_pathfindingwasm_free(ptr, 0);
11
+ }
12
+ /**
13
+ * @param {string} zone_id
14
+ * @param {Float32Array} positions
15
+ * @param {Uint32Array} indices
16
+ * @param {number} tolerance
17
+ */
18
+ create_zone(zone_id, positions, indices, tolerance) {
19
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
20
+ const len0 = WASM_VECTOR_LEN;
21
+ const ptr1 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
22
+ const len1 = WASM_VECTOR_LEN;
23
+ const ptr2 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
24
+ const len2 = WASM_VECTOR_LEN;
25
+ const ret = wasm.pathfindingwasm_create_zone(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, tolerance);
26
+ if (ret[1]) {
27
+ throw takeFromExternrefTable0(ret[0]);
28
+ }
29
+ }
30
+ /**
31
+ * @param {Float32Array} positions
32
+ * @param {Uint32Array} indices
33
+ * @param {number} tolerance
34
+ * @returns {number}
35
+ */
36
+ create_zone_handle(positions, indices, tolerance) {
37
+ const ptr0 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
40
+ const len1 = WASM_VECTOR_LEN;
41
+ const ret = wasm.pathfindingwasm_create_zone_handle(this.__wbg_ptr, ptr0, len0, ptr1, len1, tolerance);
42
+ if (ret[2]) {
43
+ throw takeFromExternrefTable0(ret[1]);
44
+ }
45
+ return ret[0] >>> 0;
46
+ }
47
+ /**
48
+ * @param {string} zone_id
49
+ * @param {number} group_id
50
+ * @param {number} start_x
51
+ * @param {number} start_y
52
+ * @param {number} start_z
53
+ * @param {number} target_x
54
+ * @param {number} target_y
55
+ * @param {number} target_z
56
+ * @param {Float32Array} output
57
+ * @returns {number}
58
+ */
59
+ find_path(zone_id, group_id, start_x, start_y, start_z, target_x, target_y, target_z, output) {
60
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
61
+ const len0 = WASM_VECTOR_LEN;
62
+ const ret = wasm.pathfindingwasm_find_path(this.__wbg_ptr, ptr0, len0, group_id, start_x, start_y, start_z, target_x, target_y, target_z, output);
63
+ return ret;
64
+ }
65
+ /**
66
+ * @param {string} zone_id
67
+ * @param {number} group_id
68
+ * @param {number} x
69
+ * @param {number} y
70
+ * @param {number} z
71
+ * @param {boolean} check_polygon
72
+ * @returns {number | undefined}
73
+ */
74
+ get_closest_node_id(zone_id, group_id, x, y, z, check_polygon) {
75
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
76
+ const len0 = WASM_VECTOR_LEN;
77
+ const ret = wasm.pathfindingwasm_get_closest_node_id(this.__wbg_ptr, ptr0, len0, group_id, x, y, z, check_polygon);
78
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
79
+ }
80
+ /**
81
+ * @param {string} zone_id
82
+ * @param {number} x
83
+ * @param {number} y
84
+ * @param {number} z
85
+ * @param {boolean} check_polygon
86
+ * @returns {number | undefined}
87
+ */
88
+ get_group(zone_id, x, y, z, check_polygon) {
89
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
90
+ const len0 = WASM_VECTOR_LEN;
91
+ const ret = wasm.pathfindingwasm_get_group(this.__wbg_ptr, ptr0, len0, x, y, z, check_polygon);
92
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
93
+ }
94
+ /**
95
+ * @param {number} zone_handle
96
+ * @param {number} x
97
+ * @param {number} y
98
+ * @param {number} z
99
+ * @param {boolean} check_polygon
100
+ * @returns {number | undefined}
101
+ */
102
+ get_group_by_handle(zone_handle, x, y, z, check_polygon) {
103
+ const ret = wasm.pathfindingwasm_get_group_by_handle(this.__wbg_ptr, zone_handle, x, y, z, check_polygon);
104
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
105
+ }
106
+ /**
107
+ * @param {string} zone_id
108
+ * @returns {number | undefined}
109
+ */
110
+ group_count(zone_id) {
111
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
+ const len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.pathfindingwasm_group_count(this.__wbg_ptr, ptr0, len0);
114
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
115
+ }
116
+ /**
117
+ * @param {number} zone_handle
118
+ * @returns {number | undefined}
119
+ */
120
+ group_count_by_handle(zone_handle) {
121
+ const ret = wasm.pathfindingwasm_group_count_by_handle(this.__wbg_ptr, zone_handle);
122
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
123
+ }
124
+ /**
125
+ * @param {string} zone_id
126
+ * @param {number} group_id
127
+ * @returns {Float64Array | undefined}
128
+ */
129
+ group_node_centers(zone_id, group_id) {
130
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ const ret = wasm.pathfindingwasm_group_node_centers(this.__wbg_ptr, ptr0, len0, group_id);
133
+ return ret;
134
+ }
135
+ /**
136
+ * @param {string} zone_id
137
+ * @param {number} group_id
138
+ * @returns {number | undefined}
139
+ */
140
+ group_node_count(zone_id, group_id) {
141
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
142
+ const len0 = WASM_VECTOR_LEN;
143
+ const ret = wasm.pathfindingwasm_group_node_count(this.__wbg_ptr, ptr0, len0, group_id);
144
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
145
+ }
146
+ /**
147
+ * @param {string} zone_id
148
+ * @param {number} group_id
149
+ * @returns {Uint32Array | undefined}
150
+ */
151
+ group_node_ids(zone_id, group_id) {
152
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
153
+ const len0 = WASM_VECTOR_LEN;
154
+ const ret = wasm.pathfindingwasm_group_node_ids(this.__wbg_ptr, ptr0, len0, group_id);
155
+ return ret;
156
+ }
157
+ constructor() {
158
+ const ret = wasm.pathfindingwasm_new();
159
+ this.__wbg_ptr = ret;
160
+ PathfindingWasmFinalization.register(this, this.__wbg_ptr, this);
161
+ return this;
162
+ }
163
+ /**
164
+ * @param {string} zone_id
165
+ * @param {number} group_id
166
+ * @param {number} node_id
167
+ * @returns {Float64Array | undefined}
168
+ */
169
+ node_center(zone_id, group_id, node_id) {
170
+ const ptr0 = passStringToWasm0(zone_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
171
+ const len0 = WASM_VECTOR_LEN;
172
+ const ret = wasm.pathfindingwasm_node_center(this.__wbg_ptr, ptr0, len0, group_id, node_id);
173
+ return ret;
174
+ }
175
+ }
176
+ if (Symbol.dispose) PathfindingWasm.prototype[Symbol.dispose] = PathfindingWasm.prototype.free;
177
+ export function __wbg___wbindgen_throw_9c75d47bf9e7731e(arg0, arg1) {
178
+ throw new Error(getStringFromWasm0(arg0, arg1));
179
+ }
180
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
181
+ let deferred0_0;
182
+ let deferred0_1;
183
+ try {
184
+ deferred0_0 = arg0;
185
+ deferred0_1 = arg1;
186
+ console.error(getStringFromWasm0(arg0, arg1));
187
+ } finally {
188
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
189
+ }
190
+ }
191
+ export function __wbg_length_5693120f2a64a00d(arg0) {
192
+ const ret = arg0.length;
193
+ return ret;
194
+ }
195
+ export function __wbg_new_227d7c05414eb861() {
196
+ const ret = new Error();
197
+ return ret;
198
+ }
199
+ export function __wbg_new_from_slice_3ca7c4e9a43341b6(arg0, arg1) {
200
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
201
+ return ret;
202
+ }
203
+ export function __wbg_new_from_slice_823acd363b3844cf(arg0, arg1) {
204
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
205
+ return ret;
206
+ }
207
+ export function __wbg_set_15b3678c712ded6b(arg0, arg1, arg2) {
208
+ arg0.set(getArrayF32FromWasm0(arg1, arg2));
209
+ }
210
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
211
+ const ret = arg1.stack;
212
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
213
+ const len1 = WASM_VECTOR_LEN;
214
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
215
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
216
+ }
217
+ export function __wbg_subarray_2a79e7a5db50bc18(arg0, arg1, arg2) {
218
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
219
+ return ret;
220
+ }
221
+ export function __wbindgen_cast_0000000000000001(arg0, arg1) {
222
+ // Cast intrinsic for `Ref(String) -> Externref`.
223
+ const ret = getStringFromWasm0(arg0, arg1);
224
+ return ret;
225
+ }
226
+ export function __wbindgen_init_externref_table() {
227
+ const table = wasm.__wbindgen_externrefs;
228
+ const offset = table.grow(4);
229
+ table.set(0, undefined);
230
+ table.set(offset + 0, undefined);
231
+ table.set(offset + 1, null);
232
+ table.set(offset + 2, true);
233
+ table.set(offset + 3, false);
234
+ }
235
+ const PathfindingWasmFinalization = (typeof FinalizationRegistry === 'undefined')
236
+ ? { register: () => {}, unregister: () => {} }
237
+ : new FinalizationRegistry(ptr => wasm.__wbg_pathfindingwasm_free(ptr, 1));
238
+
239
+ function getArrayF32FromWasm0(ptr, len) {
240
+ ptr = ptr >>> 0;
241
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
242
+ }
243
+
244
+ function getArrayF64FromWasm0(ptr, len) {
245
+ ptr = ptr >>> 0;
246
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
247
+ }
248
+
249
+ function getArrayU32FromWasm0(ptr, len) {
250
+ ptr = ptr >>> 0;
251
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
252
+ }
253
+
254
+ let cachedDataViewMemory0 = null;
255
+ function getDataViewMemory0() {
256
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
257
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
258
+ }
259
+ return cachedDataViewMemory0;
260
+ }
261
+
262
+ let cachedFloat32ArrayMemory0 = null;
263
+ function getFloat32ArrayMemory0() {
264
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
265
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
266
+ }
267
+ return cachedFloat32ArrayMemory0;
268
+ }
269
+
270
+ let cachedFloat64ArrayMemory0 = null;
271
+ function getFloat64ArrayMemory0() {
272
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
273
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
274
+ }
275
+ return cachedFloat64ArrayMemory0;
276
+ }
277
+
278
+ function getStringFromWasm0(ptr, len) {
279
+ return decodeText(ptr >>> 0, len);
280
+ }
281
+
282
+ let cachedUint32ArrayMemory0 = null;
283
+ function getUint32ArrayMemory0() {
284
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
285
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
286
+ }
287
+ return cachedUint32ArrayMemory0;
288
+ }
289
+
290
+ let cachedUint8ArrayMemory0 = null;
291
+ function getUint8ArrayMemory0() {
292
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
293
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
294
+ }
295
+ return cachedUint8ArrayMemory0;
296
+ }
297
+
298
+ function passArray32ToWasm0(arg, malloc) {
299
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
300
+ getUint32ArrayMemory0().set(arg, ptr / 4);
301
+ WASM_VECTOR_LEN = arg.length;
302
+ return ptr;
303
+ }
304
+
305
+ function passArrayF32ToWasm0(arg, malloc) {
306
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
307
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
308
+ WASM_VECTOR_LEN = arg.length;
309
+ return ptr;
310
+ }
311
+
312
+ function passStringToWasm0(arg, malloc, realloc) {
313
+ if (realloc === undefined) {
314
+ const buf = cachedTextEncoder.encode(arg);
315
+ const ptr = malloc(buf.length, 1) >>> 0;
316
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
317
+ WASM_VECTOR_LEN = buf.length;
318
+ return ptr;
319
+ }
320
+
321
+ let len = arg.length;
322
+ let ptr = malloc(len, 1) >>> 0;
323
+
324
+ const mem = getUint8ArrayMemory0();
325
+
326
+ let offset = 0;
327
+
328
+ for (; offset < len; offset++) {
329
+ const code = arg.charCodeAt(offset);
330
+ if (code > 0x7F) break;
331
+ mem[ptr + offset] = code;
332
+ }
333
+ if (offset !== len) {
334
+ if (offset !== 0) {
335
+ arg = arg.slice(offset);
336
+ }
337
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
338
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
339
+ const ret = cachedTextEncoder.encodeInto(arg, view);
340
+
341
+ offset += ret.written;
342
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
343
+ }
344
+
345
+ WASM_VECTOR_LEN = offset;
346
+ return ptr;
347
+ }
348
+
349
+ function takeFromExternrefTable0(idx) {
350
+ const value = wasm.__wbindgen_externrefs.get(idx);
351
+ wasm.__externref_table_dealloc(idx);
352
+ return value;
353
+ }
354
+
355
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
356
+ cachedTextDecoder.decode();
357
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
358
+ let numBytesDecoded = 0;
359
+ function decodeText(ptr, len) {
360
+ numBytesDecoded += len;
361
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
362
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
363
+ cachedTextDecoder.decode();
364
+ numBytesDecoded = len;
365
+ }
366
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
367
+ }
368
+
369
+ const cachedTextEncoder = new TextEncoder();
370
+
371
+ if (!('encodeInto' in cachedTextEncoder)) {
372
+ cachedTextEncoder.encodeInto = function (arg, view) {
373
+ const buf = cachedTextEncoder.encode(arg);
374
+ view.set(buf);
375
+ return {
376
+ read: arg.length,
377
+ written: buf.length
378
+ };
379
+ };
380
+ }
381
+
382
+ let WASM_VECTOR_LEN = 0;
383
+
384
+
385
+ let wasm;
386
+ export function __wbg_set_wasm(val) {
387
+ wasm = val;
388
+ }
Binary file