rbush-rs 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,19 +1,27 @@
1
1
  {
2
2
  "name": "rbush-rs",
3
- "version": "1.0.2",
4
- "description": "High-performance RBush port in WebAssembly (Rust)",
5
- "main": "rbush.js",
6
- "module": "rbush.js",
7
- "type": "module",
8
- "files": [
9
- "rbush.js",
10
- "pkg/"
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Preetham <ppmpreetham1@gmail.com>"
11
6
  ],
12
- "scripts": {
13
- "build": "wasm-pack build --target bundler",
14
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
7
+ "description": "High-performance RBush port in WebAssembly",
8
+ "version": "1.0.4",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/ppmpreetham/rbush-rs"
15
13
  },
16
- "devDependencies": {
17
- "jest": "^30.2.0"
18
- }
14
+ "files": [
15
+ "rbush_rs_bg.wasm",
16
+ "rbush_rs.js",
17
+ "rbush_rs_bg.js",
18
+ "rbush_rs.d.ts",
19
+ "rbush.js"
20
+ ],
21
+ "main": "rbush.js",
22
+ "types": "rbush_rs.d.ts",
23
+ "sideEffects": [
24
+ "./rbush_rs.js",
25
+ "./snippets/*"
26
+ ]
19
27
  }
package/rbush_rs.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class RBush {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ all(): Array<any>;
8
+ clear(): void;
9
+ collides(bbox_js: any): boolean;
10
+ fromJSON(data: any): void;
11
+ insert(item: any): void;
12
+ load(data: Array<any>): void;
13
+ loadHybrid(fast_coords: Float64Array, items: Array<any>): void;
14
+ constructor(max_entries?: number | null);
15
+ remove(item: any): void;
16
+ search(bbox_js: any): Array<any>;
17
+ toJSON(): any;
18
+ }
package/rbush_rs.js ADDED
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./rbush_rs.d.ts" */
2
+
3
+ import * as wasm from "./rbush_rs_bg.wasm";
4
+ import { __wbg_set_wasm } from "./rbush_rs_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ RBush
9
+ } from "./rbush_rs_bg.js";
package/rbush_rs_bg.js ADDED
@@ -0,0 +1,245 @@
1
+ export class RBush {
2
+ __destroy_into_raw() {
3
+ const ptr = this.__wbg_ptr;
4
+ this.__wbg_ptr = 0;
5
+ RBushFinalization.unregister(this);
6
+ return ptr;
7
+ }
8
+ free() {
9
+ const ptr = this.__destroy_into_raw();
10
+ wasm.__wbg_rbush_free(ptr, 0);
11
+ }
12
+ /**
13
+ * @returns {Array<any>}
14
+ */
15
+ all() {
16
+ const ret = wasm.rbush_all(this.__wbg_ptr);
17
+ return ret;
18
+ }
19
+ clear() {
20
+ wasm.rbush_clear(this.__wbg_ptr);
21
+ }
22
+ /**
23
+ * @param {any} bbox_js
24
+ * @returns {boolean}
25
+ */
26
+ collides(bbox_js) {
27
+ const ret = wasm.rbush_collides(this.__wbg_ptr, bbox_js);
28
+ return ret !== 0;
29
+ }
30
+ /**
31
+ * @param {any} data
32
+ */
33
+ fromJSON(data) {
34
+ wasm.rbush_fromJSON(this.__wbg_ptr, data);
35
+ }
36
+ /**
37
+ * @param {any} item
38
+ */
39
+ insert(item) {
40
+ wasm.rbush_insert(this.__wbg_ptr, item);
41
+ }
42
+ /**
43
+ * @param {Array<any>} data
44
+ */
45
+ load(data) {
46
+ wasm.rbush_load(this.__wbg_ptr, data);
47
+ }
48
+ /**
49
+ * @param {Float64Array} fast_coords
50
+ * @param {Array<any>} items
51
+ */
52
+ loadHybrid(fast_coords, items) {
53
+ const ptr0 = passArrayF64ToWasm0(fast_coords, wasm.__wbindgen_malloc);
54
+ const len0 = WASM_VECTOR_LEN;
55
+ wasm.rbush_loadHybrid(this.__wbg_ptr, ptr0, len0, items);
56
+ }
57
+ /**
58
+ * @param {number | null} [max_entries]
59
+ */
60
+ constructor(max_entries) {
61
+ const ret = wasm.rbush_new(isLikeNone(max_entries) ? 0x100000001 : (max_entries) >>> 0);
62
+ this.__wbg_ptr = ret >>> 0;
63
+ RBushFinalization.register(this, this.__wbg_ptr, this);
64
+ return this;
65
+ }
66
+ /**
67
+ * @param {any} item
68
+ */
69
+ remove(item) {
70
+ wasm.rbush_remove(this.__wbg_ptr, item);
71
+ }
72
+ /**
73
+ * @param {any} bbox_js
74
+ * @returns {Array<any>}
75
+ */
76
+ search(bbox_js) {
77
+ const ret = wasm.rbush_search(this.__wbg_ptr, bbox_js);
78
+ return ret;
79
+ }
80
+ /**
81
+ * @returns {any}
82
+ */
83
+ toJSON() {
84
+ const ret = wasm.rbush_toJSON(this.__wbg_ptr);
85
+ return ret;
86
+ }
87
+ }
88
+ if (Symbol.dispose) RBush.prototype[Symbol.dispose] = RBush.prototype.free;
89
+ export function __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25(arg0) {
90
+ const v = arg0;
91
+ const ret = typeof(v) === 'boolean' ? v : undefined;
92
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
93
+ }
94
+ export function __wbg___wbindgen_is_null_ac34f5003991759a(arg0) {
95
+ const ret = arg0 === null;
96
+ return ret;
97
+ }
98
+ export function __wbg___wbindgen_is_undefined_9e4d92534c42d778(arg0) {
99
+ const ret = arg0 === undefined;
100
+ return ret;
101
+ }
102
+ export function __wbg___wbindgen_jsval_eq_11888390b0186270(arg0, arg1) {
103
+ const ret = arg0 === arg1;
104
+ return ret;
105
+ }
106
+ export function __wbg___wbindgen_number_get_8ff4255516ccad3e(arg0, arg1) {
107
+ const obj = arg1;
108
+ const ret = typeof(obj) === 'number' ? obj : undefined;
109
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
110
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
111
+ }
112
+ export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
113
+ throw new Error(getStringFromWasm0(arg0, arg1));
114
+ }
115
+ export function __wbg_get_9b94d73e6221f75c(arg0, arg1) {
116
+ const ret = arg0[arg1 >>> 0];
117
+ return ret;
118
+ }
119
+ export function __wbg_get_b3ed3ad4be2bc8ac() { return handleError(function (arg0, arg1) {
120
+ const ret = Reflect.get(arg0, arg1);
121
+ return ret;
122
+ }, arguments); }
123
+ export function __wbg_isArray_d314bb98fcf08331(arg0) {
124
+ const ret = Array.isArray(arg0);
125
+ return ret;
126
+ }
127
+ export function __wbg_length_35a7bace40f36eac(arg0) {
128
+ const ret = arg0.length;
129
+ return ret;
130
+ }
131
+ export function __wbg_new_361308b2356cecd0() {
132
+ const ret = new Object();
133
+ return ret;
134
+ }
135
+ export function __wbg_new_3eb36ae241fe6f44() {
136
+ const ret = new Array();
137
+ return ret;
138
+ }
139
+ export function __wbg_push_8ffdcb2063340ba5(arg0, arg1) {
140
+ const ret = arg0.push(arg1);
141
+ return ret;
142
+ }
143
+ export function __wbg_set_6cb8631f80447a67() { return handleError(function (arg0, arg1, arg2) {
144
+ const ret = Reflect.set(arg0, arg1, arg2);
145
+ return ret;
146
+ }, arguments); }
147
+ export function __wbindgen_cast_0000000000000001(arg0) {
148
+ // Cast intrinsic for `F64 -> Externref`.
149
+ const ret = arg0;
150
+ return ret;
151
+ }
152
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
153
+ // Cast intrinsic for `Ref(String) -> Externref`.
154
+ const ret = getStringFromWasm0(arg0, arg1);
155
+ return ret;
156
+ }
157
+ export function __wbindgen_init_externref_table() {
158
+ const table = wasm.__wbindgen_externrefs;
159
+ const offset = table.grow(4);
160
+ table.set(0, undefined);
161
+ table.set(offset + 0, undefined);
162
+ table.set(offset + 1, null);
163
+ table.set(offset + 2, true);
164
+ table.set(offset + 3, false);
165
+ }
166
+ const RBushFinalization = (typeof FinalizationRegistry === 'undefined')
167
+ ? { register: () => {}, unregister: () => {} }
168
+ : new FinalizationRegistry(ptr => wasm.__wbg_rbush_free(ptr >>> 0, 1));
169
+
170
+ function addToExternrefTable0(obj) {
171
+ const idx = wasm.__externref_table_alloc();
172
+ wasm.__wbindgen_externrefs.set(idx, obj);
173
+ return idx;
174
+ }
175
+
176
+ let cachedDataViewMemory0 = null;
177
+ function getDataViewMemory0() {
178
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
179
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
180
+ }
181
+ return cachedDataViewMemory0;
182
+ }
183
+
184
+ let cachedFloat64ArrayMemory0 = null;
185
+ function getFloat64ArrayMemory0() {
186
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
187
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
188
+ }
189
+ return cachedFloat64ArrayMemory0;
190
+ }
191
+
192
+ function getStringFromWasm0(ptr, len) {
193
+ ptr = ptr >>> 0;
194
+ return decodeText(ptr, len);
195
+ }
196
+
197
+ let cachedUint8ArrayMemory0 = null;
198
+ function getUint8ArrayMemory0() {
199
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
200
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
201
+ }
202
+ return cachedUint8ArrayMemory0;
203
+ }
204
+
205
+ function handleError(f, args) {
206
+ try {
207
+ return f.apply(this, args);
208
+ } catch (e) {
209
+ const idx = addToExternrefTable0(e);
210
+ wasm.__wbindgen_exn_store(idx);
211
+ }
212
+ }
213
+
214
+ function isLikeNone(x) {
215
+ return x === undefined || x === null;
216
+ }
217
+
218
+ function passArrayF64ToWasm0(arg, malloc) {
219
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
220
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
221
+ WASM_VECTOR_LEN = arg.length;
222
+ return ptr;
223
+ }
224
+
225
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
226
+ cachedTextDecoder.decode();
227
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
228
+ let numBytesDecoded = 0;
229
+ function decodeText(ptr, len) {
230
+ numBytesDecoded += len;
231
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
232
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
233
+ cachedTextDecoder.decode();
234
+ numBytesDecoded = len;
235
+ }
236
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
237
+ }
238
+
239
+ let WASM_VECTOR_LEN = 0;
240
+
241
+
242
+ let wasm;
243
+ export function __wbg_set_wasm(val) {
244
+ wasm = val;
245
+ }
Binary file