@wiscale/velesdb-wasm 1.3.1 → 1.5.1

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/velesdb_wasm.js CHANGED
@@ -1,401 +1,186 @@
1
- let wasm;
1
+ /* @ts-self-types="./velesdb_wasm.d.ts" */
2
2
 
3
- function addHeapObject(obj) {
4
- if (heap_next === heap.length) heap.push(heap.length + 1);
5
- const idx = heap_next;
6
- heap_next = heap[idx];
7
-
8
- heap[idx] = obj;
9
- return idx;
10
- }
11
-
12
- function _assertClass(instance, klass) {
13
- if (!(instance instanceof klass)) {
14
- throw new Error(`expected instance of ${klass.name}`);
3
+ /**
4
+ * A graph edge representing a relationship between nodes.
5
+ */
6
+ export class GraphEdge {
7
+ static __wrap(ptr) {
8
+ ptr = ptr >>> 0;
9
+ const obj = Object.create(GraphEdge.prototype);
10
+ obj.__wbg_ptr = ptr;
11
+ GraphEdgeFinalization.register(obj, obj.__wbg_ptr, obj);
12
+ return obj;
15
13
  }
16
- }
17
-
18
- const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
19
- ? { register: () => {}, unregister: () => {} }
20
- : new FinalizationRegistry(state => state.dtor(state.a, state.b));
21
-
22
- function debugString(val) {
23
- // primitive types
24
- const type = typeof val;
25
- if (type == 'number' || type == 'boolean' || val == null) {
26
- return `${val}`;
14
+ __destroy_into_raw() {
15
+ const ptr = this.__wbg_ptr;
16
+ this.__wbg_ptr = 0;
17
+ GraphEdgeFinalization.unregister(this);
18
+ return ptr;
27
19
  }
28
- if (type == 'string') {
29
- return `"${val}"`;
20
+ free() {
21
+ const ptr = this.__destroy_into_raw();
22
+ wasm.__wbg_graphedge_free(ptr, 0);
30
23
  }
31
- if (type == 'symbol') {
32
- const description = val.description;
33
- if (description == null) {
34
- return 'Symbol';
35
- } else {
36
- return `Symbol(${description})`;
37
- }
24
+ /**
25
+ * Returns the edge ID.
26
+ * @returns {bigint}
27
+ */
28
+ get id() {
29
+ const ret = wasm.graphedge_id(this.__wbg_ptr);
30
+ return BigInt.asUintN(64, ret);
38
31
  }
39
- if (type == 'function') {
40
- const name = val.name;
41
- if (typeof name == 'string' && name.length > 0) {
42
- return `Function(${name})`;
43
- } else {
44
- return 'Function';
32
+ /**
33
+ * Returns the edge label (relationship type).
34
+ * @returns {string}
35
+ */
36
+ get label() {
37
+ let deferred1_0;
38
+ let deferred1_1;
39
+ try {
40
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
41
+ wasm.graphedge_label(retptr, this.__wbg_ptr);
42
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
43
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
44
+ deferred1_0 = r0;
45
+ deferred1_1 = r1;
46
+ return getStringFromWasm0(r0, r1);
47
+ } finally {
48
+ wasm.__wbindgen_add_to_stack_pointer(16);
49
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
45
50
  }
46
51
  }
47
- // objects
48
- if (Array.isArray(val)) {
49
- const length = val.length;
50
- let debug = '[';
51
- if (length > 0) {
52
- debug += debugString(val[0]);
53
- }
54
- for(let i = 1; i < length; i++) {
55
- debug += ', ' + debugString(val[i]);
52
+ /**
53
+ * Creates a new graph edge.
54
+ *
55
+ * # Arguments
56
+ *
57
+ * * `id` - Unique identifier for the edge
58
+ * * `source` - Source node ID
59
+ * * `target` - Target node ID
60
+ * * `label` - Relationship type (e.g., "KNOWS", "WROTE")
61
+ * @param {bigint} id
62
+ * @param {bigint} source
63
+ * @param {bigint} target
64
+ * @param {string} label
65
+ */
66
+ constructor(id, source, target, label) {
67
+ try {
68
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
69
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
70
+ const len0 = WASM_VECTOR_LEN;
71
+ wasm.graphedge_new(retptr, id, source, target, ptr0, len0);
72
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
73
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
74
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
75
+ if (r2) {
76
+ throw takeObject(r1);
77
+ }
78
+ this.__wbg_ptr = r0 >>> 0;
79
+ GraphEdgeFinalization.register(this, this.__wbg_ptr, this);
80
+ return this;
81
+ } finally {
82
+ wasm.__wbindgen_add_to_stack_pointer(16);
56
83
  }
57
- debug += ']';
58
- return debug;
59
84
  }
60
- // Test for built-in
61
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
62
- let className;
63
- if (builtInMatches && builtInMatches.length > 1) {
64
- className = builtInMatches[1];
65
- } else {
66
- // Failed to match the standard '[object ClassName]'
67
- return toString.call(val);
85
+ /**
86
+ * Sets a numeric property on the edge.
87
+ * @param {string} key
88
+ * @param {number} value
89
+ */
90
+ set_number_property(key, value) {
91
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
92
+ const len0 = WASM_VECTOR_LEN;
93
+ wasm.graphedge_set_number_property(this.__wbg_ptr, ptr0, len0, value);
68
94
  }
69
- if (className == 'Object') {
70
- // we're a user defined class or Object
71
- // JSON.stringify avoids problems with cycles, and is generally much
72
- // easier than looping through ownProperties of `val`.
73
- try {
74
- return 'Object(' + JSON.stringify(val) + ')';
75
- } catch (_) {
76
- return 'Object';
77
- }
95
+ /**
96
+ * Sets a string property on the edge.
97
+ * @param {string} key
98
+ * @param {string} value
99
+ */
100
+ set_string_property(key, value) {
101
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
102
+ const len0 = WASM_VECTOR_LEN;
103
+ const ptr1 = passStringToWasm0(value, wasm.__wbindgen_export, wasm.__wbindgen_export2);
104
+ const len1 = WASM_VECTOR_LEN;
105
+ wasm.graphedge_set_string_property(this.__wbg_ptr, ptr0, len0, ptr1, len1);
78
106
  }
79
- // errors
80
- if (val instanceof Error) {
81
- return `${val.name}: ${val.message}\n${val.stack}`;
107
+ /**
108
+ * Returns the source node ID.
109
+ * @returns {bigint}
110
+ */
111
+ get source() {
112
+ const ret = wasm.graphedge_source(this.__wbg_ptr);
113
+ return BigInt.asUintN(64, ret);
82
114
  }
83
- // TODO we could test for more things here, like `Set`s and `Map`s.
84
- return className;
85
- }
86
-
87
- function dropObject(idx) {
88
- if (idx < 132) return;
89
- heap[idx] = heap_next;
90
- heap_next = idx;
91
- }
92
-
93
- function getArrayJsValueFromWasm0(ptr, len) {
94
- ptr = ptr >>> 0;
95
- const mem = getDataViewMemory0();
96
- const result = [];
97
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
98
- result.push(takeObject(mem.getUint32(i, true)));
115
+ /**
116
+ * Returns the target node ID.
117
+ * @returns {bigint}
118
+ */
119
+ get target() {
120
+ const ret = wasm.graphedge_target(this.__wbg_ptr);
121
+ return BigInt.asUintN(64, ret);
99
122
  }
100
- return result;
101
- }
102
-
103
- function getArrayU64FromWasm0(ptr, len) {
104
- ptr = ptr >>> 0;
105
- return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
106
- }
107
-
108
- function getArrayU8FromWasm0(ptr, len) {
109
- ptr = ptr >>> 0;
110
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
111
- }
112
-
113
- let cachedBigUint64ArrayMemory0 = null;
114
- function getBigUint64ArrayMemory0() {
115
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
116
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
123
+ /**
124
+ * Converts to JSON for JavaScript interop.
125
+ * @returns {any}
126
+ */
127
+ to_json() {
128
+ try {
129
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
130
+ wasm.graphedge_to_json(retptr, this.__wbg_ptr);
131
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
132
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
133
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
134
+ if (r2) {
135
+ throw takeObject(r1);
136
+ }
137
+ return takeObject(r0);
138
+ } finally {
139
+ wasm.__wbindgen_add_to_stack_pointer(16);
140
+ }
117
141
  }
118
- return cachedBigUint64ArrayMemory0;
119
142
  }
143
+ if (Symbol.dispose) GraphEdge.prototype[Symbol.dispose] = GraphEdge.prototype.free;
120
144
 
121
- let cachedDataViewMemory0 = null;
122
- function getDataViewMemory0() {
123
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
124
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
145
+ /**
146
+ * A graph node for knowledge graph construction.
147
+ */
148
+ export class GraphNode {
149
+ static __wrap(ptr) {
150
+ ptr = ptr >>> 0;
151
+ const obj = Object.create(GraphNode.prototype);
152
+ obj.__wbg_ptr = ptr;
153
+ GraphNodeFinalization.register(obj, obj.__wbg_ptr, obj);
154
+ return obj;
125
155
  }
126
- return cachedDataViewMemory0;
127
- }
128
-
129
- let cachedFloat32ArrayMemory0 = null;
130
- function getFloat32ArrayMemory0() {
131
- if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
132
- cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
133
- }
134
- return cachedFloat32ArrayMemory0;
135
- }
136
-
137
- function getStringFromWasm0(ptr, len) {
138
- ptr = ptr >>> 0;
139
- return decodeText(ptr, len);
140
- }
141
-
142
- let cachedUint8ArrayMemory0 = null;
143
- function getUint8ArrayMemory0() {
144
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
145
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
146
- }
147
- return cachedUint8ArrayMemory0;
148
- }
149
-
150
- function getObject(idx) { return heap[idx]; }
151
-
152
- function handleError(f, args) {
153
- try {
154
- return f.apply(this, args);
155
- } catch (e) {
156
- wasm.__wbindgen_export3(addHeapObject(e));
157
- }
158
- }
159
-
160
- let heap = new Array(128).fill(undefined);
161
- heap.push(undefined, null, true, false);
162
-
163
- let heap_next = heap.length;
164
-
165
- function isLikeNone(x) {
166
- return x === undefined || x === null;
167
- }
168
-
169
- function makeMutClosure(arg0, arg1, dtor, f) {
170
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
171
- const real = (...args) => {
172
-
173
- // First up with a closure we increment the internal reference
174
- // count. This ensures that the Rust closure environment won't
175
- // be deallocated while we're invoking it.
176
- state.cnt++;
177
- const a = state.a;
178
- state.a = 0;
179
- try {
180
- return f(a, state.b, ...args);
181
- } finally {
182
- state.a = a;
183
- real._wbg_cb_unref();
184
- }
185
- };
186
- real._wbg_cb_unref = () => {
187
- if (--state.cnt === 0) {
188
- state.dtor(state.a, state.b);
189
- state.a = 0;
190
- CLOSURE_DTORS.unregister(state);
191
- }
192
- };
193
- CLOSURE_DTORS.register(real, state, state);
194
- return real;
195
- }
196
-
197
- function passArray8ToWasm0(arg, malloc) {
198
- const ptr = malloc(arg.length * 1, 1) >>> 0;
199
- getUint8ArrayMemory0().set(arg, ptr / 1);
200
- WASM_VECTOR_LEN = arg.length;
201
- return ptr;
202
- }
203
-
204
- function passArrayF32ToWasm0(arg, malloc) {
205
- const ptr = malloc(arg.length * 4, 4) >>> 0;
206
- getFloat32ArrayMemory0().set(arg, ptr / 4);
207
- WASM_VECTOR_LEN = arg.length;
208
- return ptr;
209
- }
210
-
211
- function passStringToWasm0(arg, malloc, realloc) {
212
- if (realloc === undefined) {
213
- const buf = cachedTextEncoder.encode(arg);
214
- const ptr = malloc(buf.length, 1) >>> 0;
215
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
216
- WASM_VECTOR_LEN = buf.length;
217
- return ptr;
218
- }
219
-
220
- let len = arg.length;
221
- let ptr = malloc(len, 1) >>> 0;
222
-
223
- const mem = getUint8ArrayMemory0();
224
-
225
- let offset = 0;
226
-
227
- for (; offset < len; offset++) {
228
- const code = arg.charCodeAt(offset);
229
- if (code > 0x7F) break;
230
- mem[ptr + offset] = code;
231
- }
232
- if (offset !== len) {
233
- if (offset !== 0) {
234
- arg = arg.slice(offset);
235
- }
236
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
237
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
238
- const ret = cachedTextEncoder.encodeInto(arg, view);
239
-
240
- offset += ret.written;
241
- ptr = realloc(ptr, len, offset, 1) >>> 0;
242
- }
243
-
244
- WASM_VECTOR_LEN = offset;
245
- return ptr;
246
- }
247
-
248
- function takeObject(idx) {
249
- const ret = getObject(idx);
250
- dropObject(idx);
251
- return ret;
252
- }
253
-
254
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
255
- cachedTextDecoder.decode();
256
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
257
- let numBytesDecoded = 0;
258
- function decodeText(ptr, len) {
259
- numBytesDecoded += len;
260
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
261
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
262
- cachedTextDecoder.decode();
263
- numBytesDecoded = len;
264
- }
265
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
266
- }
267
-
268
- const cachedTextEncoder = new TextEncoder();
269
-
270
- if (!('encodeInto' in cachedTextEncoder)) {
271
- cachedTextEncoder.encodeInto = function (arg, view) {
272
- const buf = cachedTextEncoder.encode(arg);
273
- view.set(buf);
274
- return {
275
- read: arg.length,
276
- written: buf.length
277
- };
278
- }
279
- }
280
-
281
- let WASM_VECTOR_LEN = 0;
282
-
283
- function __wasm_bindgen_func_elem_640(arg0, arg1, arg2) {
284
- wasm.__wasm_bindgen_func_elem_640(arg0, arg1, addHeapObject(arg2));
285
- }
286
-
287
- function __wasm_bindgen_func_elem_198(arg0, arg1, arg2) {
288
- wasm.__wasm_bindgen_func_elem_198(arg0, arg1, addHeapObject(arg2));
289
- }
290
-
291
- function __wasm_bindgen_func_elem_689(arg0, arg1, arg2, arg3) {
292
- wasm.__wasm_bindgen_func_elem_689(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
293
- }
294
-
295
- const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
296
-
297
- const GraphEdgeFinalization = (typeof FinalizationRegistry === 'undefined')
298
- ? { register: () => {}, unregister: () => {} }
299
- : new FinalizationRegistry(ptr => wasm.__wbg_graphedge_free(ptr >>> 0, 1));
300
-
301
- const GraphNodeFinalization = (typeof FinalizationRegistry === 'undefined')
302
- ? { register: () => {}, unregister: () => {} }
303
- : new FinalizationRegistry(ptr => wasm.__wbg_graphnode_free(ptr >>> 0, 1));
304
-
305
- const GraphStoreFinalization = (typeof FinalizationRegistry === 'undefined')
306
- ? { register: () => {}, unregister: () => {} }
307
- : new FinalizationRegistry(ptr => wasm.__wbg_graphstore_free(ptr >>> 0, 1));
308
-
309
- const VectorStoreFinalization = (typeof FinalizationRegistry === 'undefined')
310
- ? { register: () => {}, unregister: () => {} }
311
- : new FinalizationRegistry(ptr => wasm.__wbg_vectorstore_free(ptr >>> 0, 1));
312
-
313
- /**
314
- * A graph edge representing a relationship between nodes.
315
- */
316
- export class GraphEdge {
317
- static __wrap(ptr) {
318
- ptr = ptr >>> 0;
319
- const obj = Object.create(GraphEdge.prototype);
320
- obj.__wbg_ptr = ptr;
321
- GraphEdgeFinalization.register(obj, obj.__wbg_ptr, obj);
322
- return obj;
323
- }
324
- __destroy_into_raw() {
325
- const ptr = this.__wbg_ptr;
326
- this.__wbg_ptr = 0;
327
- GraphEdgeFinalization.unregister(this);
328
- return ptr;
156
+ __destroy_into_raw() {
157
+ const ptr = this.__wbg_ptr;
158
+ this.__wbg_ptr = 0;
159
+ GraphNodeFinalization.unregister(this);
160
+ return ptr;
329
161
  }
330
162
  free() {
331
163
  const ptr = this.__destroy_into_raw();
332
- wasm.__wbg_graphedge_free(ptr, 0);
333
- }
334
- /**
335
- * Sets a numeric property on the edge.
336
- * @param {string} key
337
- * @param {number} value
338
- */
339
- set_number_property(key, value) {
340
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
341
- const len0 = WASM_VECTOR_LEN;
342
- wasm.graphedge_set_number_property(this.__wbg_ptr, ptr0, len0, value);
164
+ wasm.__wbg_graphnode_free(ptr, 0);
343
165
  }
344
166
  /**
345
- * Sets a string property on the edge.
346
- * @param {string} key
347
- * @param {string} value
167
+ * Returns true if this node has a vector embedding.
168
+ * @returns {boolean}
348
169
  */
349
- set_string_property(key, value) {
350
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
351
- const len0 = WASM_VECTOR_LEN;
352
- const ptr1 = passStringToWasm0(value, wasm.__wbindgen_export, wasm.__wbindgen_export2);
353
- const len1 = WASM_VECTOR_LEN;
354
- wasm.graphedge_set_string_property(this.__wbg_ptr, ptr0, len0, ptr1, len1);
170
+ has_vector() {
171
+ const ret = wasm.graphnode_has_vector(this.__wbg_ptr);
172
+ return ret !== 0;
355
173
  }
356
174
  /**
357
- * Returns the edge ID.
175
+ * Returns the node ID.
358
176
  * @returns {bigint}
359
177
  */
360
178
  get id() {
361
- const ret = wasm.graphedge_id(this.__wbg_ptr);
179
+ const ret = wasm.graphnode_id(this.__wbg_ptr);
362
180
  return BigInt.asUintN(64, ret);
363
181
  }
364
182
  /**
365
- * Creates a new graph edge.
366
- *
367
- * # Arguments
368
- *
369
- * * `id` - Unique identifier for the edge
370
- * * `source` - Source node ID
371
- * * `target` - Target node ID
372
- * * `label` - Relationship type (e.g., "KNOWS", "WROTE")
373
- * @param {bigint} id
374
- * @param {bigint} source
375
- * @param {bigint} target
376
- * @param {string} label
377
- */
378
- constructor(id, source, target, label) {
379
- try {
380
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
381
- const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
382
- const len0 = WASM_VECTOR_LEN;
383
- wasm.graphedge_new(retptr, id, source, target, ptr0, len0);
384
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
385
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
386
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
387
- if (r2) {
388
- throw takeObject(r1);
389
- }
390
- this.__wbg_ptr = r0 >>> 0;
391
- GraphEdgeFinalization.register(this, this.__wbg_ptr, this);
392
- return this;
393
- } finally {
394
- wasm.__wbindgen_add_to_stack_pointer(16);
395
- }
396
- }
397
- /**
398
- * Returns the edge label (relationship type).
183
+ * Returns the node label.
399
184
  * @returns {string}
400
185
  */
401
186
  get label() {
@@ -403,7 +188,7 @@ export class GraphEdge {
403
188
  let deferred1_1;
404
189
  try {
405
190
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
406
- wasm.graphedge_label(retptr, this.__wbg_ptr);
191
+ wasm.graphnode_label(retptr, this.__wbg_ptr);
407
192
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
408
193
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
409
194
  deferred1_0 = r0;
@@ -415,80 +200,22 @@ export class GraphEdge {
415
200
  }
416
201
  }
417
202
  /**
418
- * Returns the source node ID.
419
- * @returns {bigint}
420
- */
421
- get source() {
422
- const ret = wasm.graphedge_source(this.__wbg_ptr);
423
- return BigInt.asUintN(64, ret);
424
- }
425
- /**
426
- * Returns the target node ID.
427
- * @returns {bigint}
428
- */
429
- get target() {
430
- const ret = wasm.graphedge_target(this.__wbg_ptr);
431
- return BigInt.asUintN(64, ret);
432
- }
433
- /**
434
- * Converts to JSON for JavaScript interop.
435
- * @returns {any}
436
- */
437
- to_json() {
438
- try {
439
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
440
- wasm.graphedge_to_json(retptr, this.__wbg_ptr);
441
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
442
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
443
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
444
- if (r2) {
445
- throw takeObject(r1);
446
- }
447
- return takeObject(r0);
448
- } finally {
449
- wasm.__wbindgen_add_to_stack_pointer(16);
450
- }
451
- }
452
- }
453
- if (Symbol.dispose) GraphEdge.prototype[Symbol.dispose] = GraphEdge.prototype.free;
454
-
455
- /**
456
- * A graph node for knowledge graph construction.
457
- */
458
- export class GraphNode {
459
- static __wrap(ptr) {
460
- ptr = ptr >>> 0;
461
- const obj = Object.create(GraphNode.prototype);
462
- obj.__wbg_ptr = ptr;
463
- GraphNodeFinalization.register(obj, obj.__wbg_ptr, obj);
464
- return obj;
465
- }
466
- __destroy_into_raw() {
467
- const ptr = this.__wbg_ptr;
468
- this.__wbg_ptr = 0;
469
- GraphNodeFinalization.unregister(this);
470
- return ptr;
471
- }
472
- free() {
473
- const ptr = this.__destroy_into_raw();
474
- wasm.__wbg_graphnode_free(ptr, 0);
475
- }
476
- /**
477
- * Returns true if this node has a vector embedding.
478
- * @returns {boolean}
479
- */
480
- has_vector() {
481
- const ret = wasm.graphnode_has_vector(this.__wbg_ptr);
482
- return ret !== 0;
483
- }
484
- /**
485
- * Sets a vector embedding on the node.
486
- * @param {Float32Array} vector
203
+ * Creates a new graph node.
204
+ *
205
+ * # Arguments
206
+ *
207
+ * * `id` - Unique identifier for the node
208
+ * * `label` - Node type/label (e.g., "Person", "Document")
209
+ * @param {bigint} id
210
+ * @param {string} label
487
211
  */
488
- set_vector(vector) {
489
- const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
212
+ constructor(id, label) {
213
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
490
214
  const len0 = WASM_VECTOR_LEN;
491
- wasm.graphnode_set_vector(this.__wbg_ptr, ptr0, len0);
215
+ const ret = wasm.graphnode_new(id, ptr0, len0);
216
+ this.__wbg_ptr = ret >>> 0;
217
+ GraphNodeFinalization.register(this, this.__wbg_ptr, this);
218
+ return this;
492
219
  }
493
220
  /**
494
221
  * Sets a boolean property on the node.
@@ -523,50 +250,13 @@ export class GraphNode {
523
250
  wasm.graphnode_set_string_property(this.__wbg_ptr, ptr0, len0, ptr1, len1);
524
251
  }
525
252
  /**
526
- * Returns the node ID.
527
- * @returns {bigint}
528
- */
529
- get id() {
530
- const ret = wasm.graphedge_id(this.__wbg_ptr);
531
- return BigInt.asUintN(64, ret);
532
- }
533
- /**
534
- * Creates a new graph node.
535
- *
536
- * # Arguments
537
- *
538
- * * `id` - Unique identifier for the node
539
- * * `label` - Node type/label (e.g., "Person", "Document")
540
- * @param {bigint} id
541
- * @param {string} label
253
+ * Sets a vector embedding on the node.
254
+ * @param {Float32Array} vector
542
255
  */
543
- constructor(id, label) {
544
- const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
256
+ set_vector(vector) {
257
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
545
258
  const len0 = WASM_VECTOR_LEN;
546
- const ret = wasm.graphnode_new(id, ptr0, len0);
547
- this.__wbg_ptr = ret >>> 0;
548
- GraphNodeFinalization.register(this, this.__wbg_ptr, this);
549
- return this;
550
- }
551
- /**
552
- * Returns the node label.
553
- * @returns {string}
554
- */
555
- get label() {
556
- let deferred1_0;
557
- let deferred1_1;
558
- try {
559
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
560
- wasm.graphnode_label(retptr, this.__wbg_ptr);
561
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
562
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
563
- deferred1_0 = r0;
564
- deferred1_1 = r1;
565
- return getStringFromWasm0(r0, r1);
566
- } finally {
567
- wasm.__wbindgen_add_to_stack_pointer(16);
568
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
569
- }
259
+ wasm.graphnode_set_vector(this.__wbg_ptr, ptr0, len0);
570
260
  }
571
261
  /**
572
262
  * Converts to JSON for JavaScript interop.
@@ -591,59 +281,149 @@ export class GraphNode {
591
281
  if (Symbol.dispose) GraphNode.prototype[Symbol.dispose] = GraphNode.prototype.free;
592
282
 
593
283
  /**
594
- * In-memory graph store for browser-based knowledge graphs.
595
- *
596
- * Stores nodes and edges with bidirectional indexing for efficient traversal.
284
+ * `IndexedDB` persistence manager for `GraphStore`.
597
285
  */
598
- export class GraphStore {
286
+ export class GraphPersistence {
599
287
  __destroy_into_raw() {
600
288
  const ptr = this.__wbg_ptr;
601
289
  this.__wbg_ptr = 0;
602
- GraphStoreFinalization.unregister(this);
290
+ GraphPersistenceFinalization.unregister(this);
603
291
  return ptr;
604
292
  }
605
293
  free() {
606
294
  const ptr = this.__destroy_into_raw();
607
- wasm.__wbg_graphstore_free(ptr, 0);
295
+ wasm.__wbg_graphpersistence_free(ptr, 0);
608
296
  }
609
297
  /**
610
- * Returns the number of edges.
611
- * @returns {number}
298
+ * Deletes a saved graph by name.
299
+ *
300
+ * BUG-7 FIX: Also deletes all nodes and edges with the graph prefix.
301
+ * @param {string} graph_name
302
+ * @returns {Promise<void>}
612
303
  */
613
- get edge_count() {
614
- const ret = wasm.graphstore_edge_count(this.__wbg_ptr);
615
- return ret >>> 0;
304
+ delete_graph(graph_name) {
305
+ const ptr0 = passStringToWasm0(graph_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
306
+ const len0 = WASM_VECTOR_LEN;
307
+ const ret = wasm.graphpersistence_delete_graph(this.__wbg_ptr, ptr0, len0);
308
+ return takeObject(ret);
616
309
  }
617
310
  /**
618
- * Returns the number of nodes.
619
- * @returns {number}
311
+ * Gets metadata for a saved graph.
312
+ * @param {string} graph_name
313
+ * @returns {Promise<any>}
620
314
  */
621
- get node_count() {
622
- const ret = wasm.graphstore_node_count(this.__wbg_ptr);
623
- return ret >>> 0;
315
+ get_metadata(graph_name) {
316
+ const ptr0 = passStringToWasm0(graph_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
317
+ const len0 = WASM_VECTOR_LEN;
318
+ const ret = wasm.graphpersistence_get_metadata(this.__wbg_ptr, ptr0, len0);
319
+ return takeObject(ret);
624
320
  }
625
321
  /**
626
- * Gets the degree (number of outgoing edges) of a node.
627
- * @param {bigint} node_id
628
- * @returns {number}
322
+ * Initializes the database connection. Must be called before save/load.
323
+ * @returns {Promise<void>}
629
324
  */
630
- out_degree(node_id) {
631
- const ret = wasm.graphstore_out_degree(this.__wbg_ptr, node_id);
632
- return ret >>> 0;
325
+ init() {
326
+ const ret = wasm.graphpersistence_init(this.__wbg_ptr);
327
+ return takeObject(ret);
633
328
  }
634
329
  /**
635
- * Removes an edge by ID.
636
- * @param {bigint} edge_id
330
+ * Lists all saved graph names.
331
+ * @returns {Promise<Array<any>>}
637
332
  */
638
- remove_edge(edge_id) {
639
- wasm.graphstore_remove_edge(this.__wbg_ptr, edge_id);
333
+ list_graphs() {
334
+ const ret = wasm.graphpersistence_list_graphs(this.__wbg_ptr);
335
+ return takeObject(ret);
640
336
  }
641
337
  /**
642
- * Removes a node and all connected edges.
643
- * @param {bigint} node_id
338
+ * Loads a graph from `IndexedDB` by name.
339
+ *
340
+ * BUG-6 FIX: Only loads nodes/edges with keys prefixed by `{graph_name}:`
341
+ * @param {string} graph_name
342
+ * @returns {Promise<GraphStore>}
644
343
  */
645
- remove_node(node_id) {
646
- wasm.graphstore_remove_node(this.__wbg_ptr, node_id);
344
+ load(graph_name) {
345
+ const ptr0 = passStringToWasm0(graph_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
346
+ const len0 = WASM_VECTOR_LEN;
347
+ const ret = wasm.graphpersistence_load(this.__wbg_ptr, ptr0, len0);
348
+ return takeObject(ret);
349
+ }
350
+ /**
351
+ * Creates a new `GraphPersistence` instance (call `init()` to open database).
352
+ */
353
+ constructor() {
354
+ const ret = wasm.graphpersistence_new();
355
+ this.__wbg_ptr = ret >>> 0;
356
+ GraphPersistenceFinalization.register(this, this.__wbg_ptr, this);
357
+ return this;
358
+ }
359
+ /**
360
+ * Saves a graph to `IndexedDB` with the given name.
361
+ * @param {string} graph_name
362
+ * @param {GraphStore} store
363
+ * @returns {Promise<void>}
364
+ */
365
+ save(graph_name, store) {
366
+ const ptr0 = passStringToWasm0(graph_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
367
+ const len0 = WASM_VECTOR_LEN;
368
+ _assertClass(store, GraphStore);
369
+ const ret = wasm.graphpersistence_save(this.__wbg_ptr, ptr0, len0, store.__wbg_ptr);
370
+ return takeObject(ret);
371
+ }
372
+ }
373
+ if (Symbol.dispose) GraphPersistence.prototype[Symbol.dispose] = GraphPersistence.prototype.free;
374
+
375
+ /**
376
+ * In-memory graph store for browser-based knowledge graphs.
377
+ *
378
+ * Stores nodes and edges with bidirectional indexing for efficient traversal.
379
+ */
380
+ export class GraphStore {
381
+ static __wrap(ptr) {
382
+ ptr = ptr >>> 0;
383
+ const obj = Object.create(GraphStore.prototype);
384
+ obj.__wbg_ptr = ptr;
385
+ GraphStoreFinalization.register(obj, obj.__wbg_ptr, obj);
386
+ return obj;
387
+ }
388
+ __destroy_into_raw() {
389
+ const ptr = this.__wbg_ptr;
390
+ this.__wbg_ptr = 0;
391
+ GraphStoreFinalization.unregister(this);
392
+ return ptr;
393
+ }
394
+ free() {
395
+ const ptr = this.__destroy_into_raw();
396
+ wasm.__wbg_graphstore_free(ptr, 0);
397
+ }
398
+ /**
399
+ * Adds an edge to the graph.
400
+ *
401
+ * Returns an error if an edge with the same ID already exists.
402
+ * @param {GraphEdge} edge
403
+ */
404
+ add_edge(edge) {
405
+ try {
406
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
407
+ _assertClass(edge, GraphEdge);
408
+ var ptr0 = edge.__destroy_into_raw();
409
+ wasm.graphstore_add_edge(retptr, this.__wbg_ptr, ptr0);
410
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
411
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
412
+ if (r1) {
413
+ throw takeObject(r0);
414
+ }
415
+ } finally {
416
+ wasm.__wbindgen_add_to_stack_pointer(16);
417
+ }
418
+ }
419
+ /**
420
+ * Adds a node to the graph.
421
+ * @param {GraphNode} node
422
+ */
423
+ add_node(node) {
424
+ _assertClass(node, GraphNode);
425
+ var ptr0 = node.__destroy_into_raw();
426
+ wasm.graphstore_add_node(this.__wbg_ptr, ptr0);
647
427
  }
648
428
  /**
649
429
  * Performs BFS traversal from a source node.
@@ -677,6 +457,12 @@ export class GraphStore {
677
457
  wasm.__wbindgen_add_to_stack_pointer(16);
678
458
  }
679
459
  }
460
+ /**
461
+ * Clears all nodes and edges.
462
+ */
463
+ clear() {
464
+ wasm.graphstore_clear(this.__wbg_ptr);
465
+ }
680
466
  /**
681
467
  * Performs DFS traversal from a source node.
682
468
  *
@@ -710,58 +496,12 @@ export class GraphStore {
710
496
  }
711
497
  }
712
498
  /**
713
- * Gets incoming edges to a node.
714
- * @param {bigint} node_id
715
- * @returns {GraphEdge[]}
499
+ * Returns the number of edges.
500
+ * @returns {number}
716
501
  */
717
- get_incoming(node_id) {
718
- try {
719
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
720
- wasm.graphstore_get_incoming(retptr, this.__wbg_ptr, node_id);
721
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
722
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
723
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
724
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
725
- return v1;
726
- } finally {
727
- wasm.__wbindgen_add_to_stack_pointer(16);
728
- }
729
- }
730
- /**
731
- * Gets outgoing edges from a node.
732
- * @param {bigint} node_id
733
- * @returns {GraphEdge[]}
734
- */
735
- get_outgoing(node_id) {
736
- try {
737
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
738
- wasm.graphstore_get_outgoing(retptr, this.__wbg_ptr, node_id);
739
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
740
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
741
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
742
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
743
- return v1;
744
- } finally {
745
- wasm.__wbindgen_add_to_stack_pointer(16);
746
- }
747
- }
748
- /**
749
- * Gets neighbors reachable from a node (1-hop).
750
- * @param {bigint} node_id
751
- * @returns {BigUint64Array}
752
- */
753
- get_neighbors(node_id) {
754
- try {
755
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
756
- wasm.graphstore_get_neighbors(retptr, this.__wbg_ptr, node_id);
757
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
758
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
759
- var v1 = getArrayU64FromWasm0(r0, r1).slice();
760
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
761
- return v1;
762
- } finally {
763
- wasm.__wbindgen_add_to_stack_pointer(16);
764
- }
502
+ get edge_count() {
503
+ const ret = wasm.graphstore_edge_count(this.__wbg_ptr);
504
+ return ret >>> 0;
765
505
  }
766
506
  /**
767
507
  * Gets all edge IDs in the graph.
@@ -797,6 +537,15 @@ export class GraphStore {
797
537
  wasm.__wbindgen_add_to_stack_pointer(16);
798
538
  }
799
539
  }
540
+ /**
541
+ * Gets an edge by ID.
542
+ * @param {bigint} id
543
+ * @returns {GraphEdge | undefined}
544
+ */
545
+ get_edge(id) {
546
+ const ret = wasm.graphstore_get_edge(this.__wbg_ptr, id);
547
+ return ret === 0 ? undefined : GraphEdge.__wrap(ret);
548
+ }
800
549
  /**
801
550
  * Gets all edges with a specific label.
802
551
  *
@@ -825,6 +574,51 @@ export class GraphStore {
825
574
  wasm.__wbindgen_add_to_stack_pointer(16);
826
575
  }
827
576
  }
577
+ /**
578
+ * Gets incoming edges to a node.
579
+ * @param {bigint} node_id
580
+ * @returns {GraphEdge[]}
581
+ */
582
+ get_incoming(node_id) {
583
+ try {
584
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
585
+ wasm.graphstore_get_incoming(retptr, this.__wbg_ptr, node_id);
586
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
587
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
588
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
589
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
590
+ return v1;
591
+ } finally {
592
+ wasm.__wbindgen_add_to_stack_pointer(16);
593
+ }
594
+ }
595
+ /**
596
+ * Gets neighbors reachable from a node (1-hop).
597
+ * @param {bigint} node_id
598
+ * @returns {BigUint64Array}
599
+ */
600
+ get_neighbors(node_id) {
601
+ try {
602
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
603
+ wasm.graphstore_get_neighbors(retptr, this.__wbg_ptr, node_id);
604
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
605
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
606
+ var v1 = getArrayU64FromWasm0(r0, r1).slice();
607
+ wasm.__wbindgen_export4(r0, r1 * 8, 8);
608
+ return v1;
609
+ } finally {
610
+ wasm.__wbindgen_add_to_stack_pointer(16);
611
+ }
612
+ }
613
+ /**
614
+ * Gets a node by ID.
615
+ * @param {bigint} id
616
+ * @returns {GraphNode | undefined}
617
+ */
618
+ get_node(id) {
619
+ const ret = wasm.graphstore_get_node(this.__wbg_ptr, id);
620
+ return ret === 0 ? undefined : GraphNode.__wrap(ret);
621
+ }
828
622
  /**
829
623
  * Gets all nodes with a specific label.
830
624
  *
@@ -854,89 +648,44 @@ export class GraphStore {
854
648
  }
855
649
  }
856
650
  /**
857
- * Gets outgoing edges filtered by label.
651
+ * Gets outgoing edges from a node.
858
652
  * @param {bigint} node_id
859
- * @param {string} label
860
653
  * @returns {GraphEdge[]}
861
654
  */
862
- get_outgoing_by_label(node_id, label) {
655
+ get_outgoing(node_id) {
863
656
  try {
864
657
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
865
- const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
866
- const len0 = WASM_VECTOR_LEN;
867
- wasm.graphstore_get_outgoing_by_label(retptr, this.__wbg_ptr, node_id, ptr0, len0);
658
+ wasm.graphstore_get_outgoing(retptr, this.__wbg_ptr, node_id);
868
659
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
869
660
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
870
- var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
661
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
871
662
  wasm.__wbindgen_export4(r0, r1 * 4, 4);
872
- return v2;
663
+ return v1;
873
664
  } finally {
874
665
  wasm.__wbindgen_add_to_stack_pointer(16);
875
666
  }
876
667
  }
877
668
  /**
878
- * Creates a new empty graph store.
879
- */
880
- constructor() {
881
- const ret = wasm.graphstore_new();
882
- this.__wbg_ptr = ret >>> 0;
883
- GraphStoreFinalization.register(this, this.__wbg_ptr, this);
884
- return this;
885
- }
886
- /**
887
- * Clears all nodes and edges.
888
- */
889
- clear() {
890
- wasm.graphstore_clear(this.__wbg_ptr);
891
- }
892
- /**
893
- * Adds an edge to the graph.
894
- *
895
- * Returns an error if an edge with the same ID already exists.
896
- * @param {GraphEdge} edge
669
+ * Gets outgoing edges filtered by label.
670
+ * @param {bigint} node_id
671
+ * @param {string} label
672
+ * @returns {GraphEdge[]}
897
673
  */
898
- add_edge(edge) {
674
+ get_outgoing_by_label(node_id, label) {
899
675
  try {
900
676
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
901
- _assertClass(edge, GraphEdge);
902
- var ptr0 = edge.__destroy_into_raw();
903
- wasm.graphstore_add_edge(retptr, this.__wbg_ptr, ptr0);
677
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
678
+ const len0 = WASM_VECTOR_LEN;
679
+ wasm.graphstore_get_outgoing_by_label(retptr, this.__wbg_ptr, node_id, ptr0, len0);
904
680
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
905
681
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
906
- if (r1) {
907
- throw takeObject(r0);
908
- }
682
+ var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
683
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
684
+ return v2;
909
685
  } finally {
910
686
  wasm.__wbindgen_add_to_stack_pointer(16);
911
687
  }
912
688
  }
913
- /**
914
- * Adds a node to the graph.
915
- * @param {GraphNode} node
916
- */
917
- add_node(node) {
918
- _assertClass(node, GraphNode);
919
- var ptr0 = node.__destroy_into_raw();
920
- wasm.graphstore_add_node(this.__wbg_ptr, ptr0);
921
- }
922
- /**
923
- * Gets an edge by ID.
924
- * @param {bigint} id
925
- * @returns {GraphEdge | undefined}
926
- */
927
- get_edge(id) {
928
- const ret = wasm.graphstore_get_edge(this.__wbg_ptr, id);
929
- return ret === 0 ? undefined : GraphEdge.__wrap(ret);
930
- }
931
- /**
932
- * Gets a node by ID.
933
- * @param {bigint} id
934
- * @returns {GraphNode | undefined}
935
- */
936
- get_node(id) {
937
- const ret = wasm.graphstore_get_node(this.__wbg_ptr, id);
938
- return ret === 0 ? undefined : GraphNode.__wrap(ret);
939
- }
940
689
  /**
941
690
  * Checks if an edge exists.
942
691
  * @param {bigint} id
@@ -964,348 +713,500 @@ export class GraphStore {
964
713
  const ret = wasm.graphstore_in_degree(this.__wbg_ptr, node_id);
965
714
  return ret >>> 0;
966
715
  }
967
- }
968
- if (Symbol.dispose) GraphStore.prototype[Symbol.dispose] = GraphStore.prototype.free;
969
-
970
- /**
971
- * Storage mode for vector quantization.
972
- * @enum {0 | 1 | 2}
973
- */
974
- export const StorageMode = Object.freeze({
975
716
  /**
976
- * Full f32 precision (4 bytes per dimension)
717
+ * Creates a new empty graph store.
977
718
  */
978
- Full: 0, "0": "Full",
719
+ constructor() {
720
+ const ret = wasm.graphstore_new();
721
+ this.__wbg_ptr = ret >>> 0;
722
+ GraphStoreFinalization.register(this, this.__wbg_ptr, this);
723
+ return this;
724
+ }
979
725
  /**
980
- * SQ8: 8-bit scalar quantization (1 byte per dimension, 4x compression)
726
+ * Returns the number of nodes.
727
+ * @returns {number}
981
728
  */
982
- SQ8: 1, "1": "SQ8",
729
+ get node_count() {
730
+ const ret = wasm.graphstore_node_count(this.__wbg_ptr);
731
+ return ret >>> 0;
732
+ }
983
733
  /**
984
- * Binary: 1-bit quantization (1 bit per dimension, 32x compression)
734
+ * Gets the degree (number of outgoing edges) of a node.
735
+ * @param {bigint} node_id
736
+ * @returns {number}
985
737
  */
986
- Binary: 2, "2": "Binary",
987
- });
738
+ out_degree(node_id) {
739
+ const ret = wasm.graphstore_out_degree(this.__wbg_ptr, node_id);
740
+ return ret >>> 0;
741
+ }
742
+ /**
743
+ * Removes an edge by ID.
744
+ * @param {bigint} edge_id
745
+ */
746
+ remove_edge(edge_id) {
747
+ wasm.graphstore_remove_edge(this.__wbg_ptr, edge_id);
748
+ }
749
+ /**
750
+ * Removes a node and all connected edges.
751
+ * @param {bigint} node_id
752
+ */
753
+ remove_node(node_id) {
754
+ wasm.graphstore_remove_node(this.__wbg_ptr, node_id);
755
+ }
756
+ }
757
+ if (Symbol.dispose) GraphStore.prototype[Symbol.dispose] = GraphStore.prototype.free;
988
758
 
989
759
  /**
990
- * A vector store for in-memory vector search.
991
- *
992
- * # Performance
993
- *
994
- * Uses contiguous memory layout for optimal cache locality and fast
995
- * serialization. Vector data is stored in a single buffer rather than
996
- * individual Vec allocations.
997
- *
998
- * # Storage Modes
999
- *
1000
- * - `Full`: f32 precision, best recall
1001
- * - `SQ8`: 4x memory reduction, ~1% recall loss
1002
- * - `Binary`: 32x memory reduction, ~5-10% recall loss
760
+ * Configuration for Web Worker traversal decisions.
1003
761
  */
1004
- export class VectorStore {
762
+ export class GraphWorkerConfig {
1005
763
  static __wrap(ptr) {
1006
764
  ptr = ptr >>> 0;
1007
- const obj = Object.create(VectorStore.prototype);
765
+ const obj = Object.create(GraphWorkerConfig.prototype);
1008
766
  obj.__wbg_ptr = ptr;
1009
- VectorStoreFinalization.register(obj, obj.__wbg_ptr, obj);
767
+ GraphWorkerConfigFinalization.register(obj, obj.__wbg_ptr, obj);
1010
768
  return obj;
1011
769
  }
1012
770
  __destroy_into_raw() {
1013
771
  const ptr = this.__wbg_ptr;
1014
772
  this.__wbg_ptr = 0;
1015
- VectorStoreFinalization.unregister(this);
773
+ GraphWorkerConfigFinalization.unregister(this);
1016
774
  return ptr;
1017
775
  }
1018
776
  free() {
1019
777
  const ptr = this.__destroy_into_raw();
1020
- wasm.__wbg_vectorstore_free(ptr, 0);
778
+ wasm.__wbg_graphworkerconfig_free(ptr, 0);
1021
779
  }
1022
780
  /**
1023
- * Text search on payload fields (substring matching).
1024
- * @param {string} query
1025
- * @param {number} k
1026
- * @param {string | null} [field]
1027
- * @returns {any}
781
+ * Minimum depth to trigger worker offload.
782
+ * @returns {number}
1028
783
  */
1029
- text_search(query, k, field) {
1030
- try {
1031
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1032
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1033
- const len0 = WASM_VECTOR_LEN;
1034
- var ptr1 = isLikeNone(field) ? 0 : passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1035
- var len1 = WASM_VECTOR_LEN;
1036
- wasm.vectorstore_text_search(retptr, this.__wbg_ptr, ptr0, len0, k, ptr1, len1);
1037
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1038
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1039
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1040
- if (r2) {
1041
- throw takeObject(r1);
1042
- }
1043
- return takeObject(r0);
1044
- } finally {
1045
- wasm.__wbindgen_add_to_stack_pointer(16);
1046
- }
784
+ get depth_threshold() {
785
+ const ret = wasm.__wbg_get_graphworkerconfig_depth_threshold(this.__wbg_ptr);
786
+ return ret >>> 0;
1047
787
  }
1048
788
  /**
1049
- * Batch search for multiple vectors. Returns [[[id, score], ...], ...].
1050
- * @param {Float32Array} vectors
1051
- * @param {number} num_vectors
1052
- * @param {number} k
789
+ * Minimum node count to trigger worker offload.
790
+ * @returns {number}
791
+ */
792
+ get node_threshold() {
793
+ const ret = wasm.__wbg_get_graphworkerconfig_node_threshold(this.__wbg_ptr);
794
+ return ret >>> 0;
795
+ }
796
+ /**
797
+ * Progress callback interval in milliseconds.
798
+ * @returns {number}
799
+ */
800
+ get progress_interval_ms() {
801
+ const ret = wasm.__wbg_get_graphworkerconfig_progress_interval_ms(this.__wbg_ptr);
802
+ return ret >>> 0;
803
+ }
804
+ /**
805
+ * Whether to use `SharedArrayBuffer` for result transfer (if available).
806
+ * @returns {boolean}
807
+ */
808
+ get use_shared_buffer() {
809
+ const ret = wasm.__wbg_get_graphworkerconfig_use_shared_buffer(this.__wbg_ptr);
810
+ return ret !== 0;
811
+ }
812
+ /**
813
+ * Creates a configuration optimized for large graphs.
814
+ * @returns {GraphWorkerConfig}
815
+ */
816
+ static for_large_graphs() {
817
+ const ret = wasm.graphworkerconfig_for_large_graphs();
818
+ return GraphWorkerConfig.__wrap(ret);
819
+ }
820
+ /**
821
+ * Creates a configuration optimized for responsive UI.
822
+ * @returns {GraphWorkerConfig}
823
+ */
824
+ static for_responsive_ui() {
825
+ const ret = wasm.graphworkerconfig_for_responsive_ui();
826
+ return GraphWorkerConfig.__wrap(ret);
827
+ }
828
+ /**
829
+ * Creates a new configuration with default values.
830
+ */
831
+ constructor() {
832
+ const ret = wasm.graphworkerconfig_new();
833
+ this.__wbg_ptr = ret >>> 0;
834
+ GraphWorkerConfigFinalization.register(this, this.__wbg_ptr, this);
835
+ return this;
836
+ }
837
+ /**
838
+ * Minimum depth to trigger worker offload.
839
+ * @param {number} arg0
840
+ */
841
+ set depth_threshold(arg0) {
842
+ wasm.__wbg_set_graphworkerconfig_depth_threshold(this.__wbg_ptr, arg0);
843
+ }
844
+ /**
845
+ * Minimum node count to trigger worker offload.
846
+ * @param {number} arg0
847
+ */
848
+ set node_threshold(arg0) {
849
+ wasm.__wbg_set_graphworkerconfig_node_threshold(this.__wbg_ptr, arg0);
850
+ }
851
+ /**
852
+ * Progress callback interval in milliseconds.
853
+ * @param {number} arg0
854
+ */
855
+ set progress_interval_ms(arg0) {
856
+ wasm.__wbg_set_graphworkerconfig_progress_interval_ms(this.__wbg_ptr, arg0);
857
+ }
858
+ /**
859
+ * Whether to use `SharedArrayBuffer` for result transfer (if available).
860
+ * @param {boolean} arg0
861
+ */
862
+ set use_shared_buffer(arg0) {
863
+ wasm.__wbg_set_graphworkerconfig_use_shared_buffer(this.__wbg_ptr, arg0);
864
+ }
865
+ }
866
+ if (Symbol.dispose) GraphWorkerConfig.prototype[Symbol.dispose] = GraphWorkerConfig.prototype.free;
867
+
868
+ /**
869
+ * A parsed `VelesQL` statement with introspection methods.
870
+ */
871
+ export class ParsedQuery {
872
+ static __wrap(ptr) {
873
+ ptr = ptr >>> 0;
874
+ const obj = Object.create(ParsedQuery.prototype);
875
+ obj.__wbg_ptr = ptr;
876
+ ParsedQueryFinalization.register(obj, obj.__wbg_ptr, obj);
877
+ return obj;
878
+ }
879
+ __destroy_into_raw() {
880
+ const ptr = this.__wbg_ptr;
881
+ this.__wbg_ptr = 0;
882
+ ParsedQueryFinalization.unregister(this);
883
+ return ptr;
884
+ }
885
+ free() {
886
+ const ptr = this.__destroy_into_raw();
887
+ wasm.__wbg_parsedquery_free(ptr, 0);
888
+ }
889
+ /**
890
+ * Get the list of selected columns as JSON array.
1053
891
  * @returns {any}
1054
892
  */
1055
- batch_search(vectors, num_vectors, k) {
893
+ get columns() {
894
+ const ret = wasm.parsedquery_columns(this.__wbg_ptr);
895
+ return takeObject(ret);
896
+ }
897
+ /**
898
+ * Get the GROUP BY columns as JSON array.
899
+ * @returns {any}
900
+ */
901
+ get groupBy() {
902
+ const ret = wasm.parsedquery_groupBy(this.__wbg_ptr);
903
+ return takeObject(ret);
904
+ }
905
+ /**
906
+ * Check if DISTINCT modifier is present.
907
+ * @returns {boolean}
908
+ */
909
+ get hasDistinct() {
910
+ const ret = wasm.parsedquery_hasDistinct(this.__wbg_ptr);
911
+ return ret !== 0;
912
+ }
913
+ /**
914
+ * Check if the query uses FUSION (hybrid search).
915
+ * @returns {boolean}
916
+ */
917
+ get hasFusion() {
918
+ const ret = wasm.parsedquery_hasFusion(this.__wbg_ptr);
919
+ return ret !== 0;
920
+ }
921
+ /**
922
+ * Check if the query has a GROUP BY clause.
923
+ * @returns {boolean}
924
+ */
925
+ get hasGroupBy() {
926
+ const ret = wasm.parsedquery_hasGroupBy(this.__wbg_ptr);
927
+ return ret !== 0;
928
+ }
929
+ /**
930
+ * Check if the query has JOINs.
931
+ * @returns {boolean}
932
+ */
933
+ get hasJoins() {
934
+ const ret = wasm.parsedquery_hasJoins(this.__wbg_ptr);
935
+ return ret !== 0;
936
+ }
937
+ /**
938
+ * Check if the query has an ORDER BY clause.
939
+ * @returns {boolean}
940
+ */
941
+ get hasOrderBy() {
942
+ const ret = wasm.parsedquery_hasOrderBy(this.__wbg_ptr);
943
+ return ret !== 0;
944
+ }
945
+ /**
946
+ * Check if the query contains vector search (NEAR clause).
947
+ * @returns {boolean}
948
+ */
949
+ get hasVectorSearch() {
950
+ const ret = wasm.parsedquery_hasVectorSearch(this.__wbg_ptr);
951
+ return ret !== 0;
952
+ }
953
+ /**
954
+ * Check if the query has a WHERE clause.
955
+ * @returns {boolean}
956
+ */
957
+ get hasWhereClause() {
958
+ const ret = wasm.parsedquery_hasWhereClause(this.__wbg_ptr);
959
+ return ret !== 0;
960
+ }
961
+ /**
962
+ * Check if this is a MATCH (graph) query.
963
+ * @returns {boolean}
964
+ */
965
+ get isMatch() {
966
+ const ret = wasm.parsedquery_isMatch(this.__wbg_ptr);
967
+ return ret !== 0;
968
+ }
969
+ /**
970
+ * Check if this is a SELECT query.
971
+ * @returns {boolean}
972
+ */
973
+ get isSelect() {
974
+ const ret = wasm.parsedquery_isSelect(this.__wbg_ptr);
975
+ return ret !== 0;
976
+ }
977
+ /**
978
+ * Check if the query is valid (always true for successfully parsed queries).
979
+ * @returns {boolean}
980
+ */
981
+ get isValid() {
982
+ const ret = wasm.parsedquery_isValid(this.__wbg_ptr);
983
+ return ret !== 0;
984
+ }
985
+ /**
986
+ * Get the number of JOIN clauses.
987
+ * @returns {number}
988
+ */
989
+ get joinCount() {
990
+ const ret = wasm.parsedquery_joinCount(this.__wbg_ptr);
991
+ return ret >>> 0;
992
+ }
993
+ /**
994
+ * Get the LIMIT value if present.
995
+ * @returns {bigint | undefined}
996
+ */
997
+ get limit() {
1056
998
  try {
1057
999
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1058
- const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1059
- const len0 = WASM_VECTOR_LEN;
1060
- wasm.vectorstore_batch_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k);
1000
+ wasm.parsedquery_limit(retptr, this.__wbg_ptr);
1061
1001
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1062
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1063
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1064
- if (r2) {
1065
- throw takeObject(r1);
1066
- }
1067
- return takeObject(r0);
1002
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1003
+ return r0 === 0 ? undefined : BigInt.asUintN(64, r2);
1068
1004
  } finally {
1069
1005
  wasm.__wbindgen_add_to_stack_pointer(16);
1070
1006
  }
1071
1007
  }
1072
1008
  /**
1073
- * Batch insert. Input: `[[id, Float32Array], ...]`.
1074
- * @param {any} batch
1009
+ * Check if the MATCH clause has a WHERE condition.
1010
+ * @returns {boolean}
1075
1011
  */
1076
- insert_batch(batch) {
1012
+ get matchHasWhere() {
1013
+ const ret = wasm.parsedquery_matchHasWhere(this.__wbg_ptr);
1014
+ return ret !== 0;
1015
+ }
1016
+ /**
1017
+ * Get the LIMIT from the MATCH RETURN clause.
1018
+ * @returns {bigint | undefined}
1019
+ */
1020
+ get matchLimit() {
1077
1021
  try {
1078
1022
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1079
- wasm.vectorstore_insert_batch(retptr, this.__wbg_ptr, addHeapObject(batch));
1023
+ wasm.parsedquery_matchLimit(retptr, this.__wbg_ptr);
1080
1024
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1081
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1082
- if (r1) {
1083
- throw takeObject(r0);
1084
- }
1025
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1026
+ return r0 === 0 ? undefined : BigInt.asUintN(64, r2);
1085
1027
  } finally {
1086
1028
  wasm.__wbindgen_add_to_stack_pointer(16);
1087
1029
  }
1088
1030
  }
1089
1031
  /**
1090
- * Returns memory usage estimate in bytes.
1032
+ * Get the number of node patterns in the MATCH clause.
1091
1033
  * @returns {number}
1092
1034
  */
1093
- memory_usage() {
1094
- const ret = wasm.vectorstore_memory_usage(this.__wbg_ptr);
1035
+ get matchNodeCount() {
1036
+ const ret = wasm.parsedquery_matchNodeCount(this.__wbg_ptr);
1095
1037
  return ret >>> 0;
1096
1038
  }
1097
1039
  /**
1098
- * Returns the storage mode.
1099
- * @returns {string}
1040
+ * Get node labels from the MATCH clause as JSON array of arrays.
1041
+ * Each inner array contains the labels for one node pattern.
1042
+ * @returns {any}
1100
1043
  */
1101
- get storage_mode() {
1102
- let deferred1_0;
1103
- let deferred1_1;
1104
- try {
1105
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1106
- wasm.vectorstore_storage_mode(retptr, this.__wbg_ptr);
1107
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1108
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1109
- deferred1_0 = r0;
1110
- deferred1_1 = r1;
1111
- return getStringFromWasm0(r0, r1);
1112
- } finally {
1113
- wasm.__wbindgen_add_to_stack_pointer(16);
1114
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1115
- }
1044
+ get matchNodeLabels() {
1045
+ const ret = wasm.parsedquery_matchNodeLabels(this.__wbg_ptr);
1046
+ return takeObject(ret);
1116
1047
  }
1117
1048
  /**
1118
- * Hybrid search (vector + text). `vector_weight` 0-1 (default 0.5).
1119
- * @param {Float32Array} query_vector
1120
- * @param {string} text_query
1121
- * @param {number} k
1122
- * @param {number | null} [vector_weight]
1049
+ * Get the number of relationship patterns in the MATCH clause.
1050
+ * @returns {number}
1051
+ */
1052
+ get matchRelationshipCount() {
1053
+ const ret = wasm.parsedquery_matchRelationshipCount(this.__wbg_ptr);
1054
+ return ret >>> 0;
1055
+ }
1056
+ /**
1057
+ * Get relationship types from the MATCH clause as JSON array of arrays.
1058
+ * Each inner array contains the types for one relationship pattern.
1123
1059
  * @returns {any}
1124
1060
  */
1125
- hybrid_search(query_vector, text_query, k, vector_weight) {
1126
- try {
1127
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1128
- const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1129
- const len0 = WASM_VECTOR_LEN;
1130
- const ptr1 = passStringToWasm0(text_query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1131
- const len1 = WASM_VECTOR_LEN;
1132
- wasm.vectorstore_hybrid_search(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, k, isLikeNone(vector_weight) ? 0x100000001 : Math.fround(vector_weight));
1133
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1134
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1135
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1136
- if (r2) {
1137
- throw takeObject(r1);
1138
- }
1139
- return takeObject(r0);
1140
- } finally {
1141
- wasm.__wbindgen_add_to_stack_pointer(16);
1142
- }
1061
+ get matchRelationshipTypes() {
1062
+ const ret = wasm.parsedquery_matchRelationshipTypes(this.__wbg_ptr);
1063
+ return takeObject(ret);
1143
1064
  }
1144
1065
  /**
1145
- * Creates store with mode: full (4B/dim), sq8 (4x compression), binary (32x).
1146
- * @param {number} dimension
1147
- * @param {string} metric
1148
- * @param {string} mode
1149
- * @returns {VectorStore}
1066
+ * Get RETURN items from the MATCH clause as JSON array.
1067
+ * @returns {any}
1150
1068
  */
1151
- static new_with_mode(dimension, metric, mode) {
1069
+ get matchReturnItems() {
1070
+ const ret = wasm.parsedquery_matchReturnItems(this.__wbg_ptr);
1071
+ return takeObject(ret);
1072
+ }
1073
+ /**
1074
+ * Get the OFFSET value if present.
1075
+ * @returns {bigint | undefined}
1076
+ */
1077
+ get offset() {
1152
1078
  try {
1153
1079
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1154
- const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1155
- const len0 = WASM_VECTOR_LEN;
1156
- const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1157
- const len1 = WASM_VECTOR_LEN;
1158
- wasm.vectorstore_new_with_mode(retptr, dimension, ptr0, len0, ptr1, len1);
1080
+ wasm.parsedquery_offset(retptr, this.__wbg_ptr);
1159
1081
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1160
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1161
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1162
- if (r2) {
1163
- throw takeObject(r1);
1164
- }
1165
- return VectorStore.__wrap(r0);
1082
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1083
+ return r0 === 0 ? undefined : BigInt.asUintN(64, r2);
1166
1084
  } finally {
1167
1085
  wasm.__wbindgen_add_to_stack_pointer(16);
1168
1086
  }
1169
1087
  }
1170
1088
  /**
1171
- * Creates store with pre-allocated capacity.
1172
- * @param {number} dimension
1173
- * @param {string} metric
1174
- * @param {number} capacity
1175
- * @returns {VectorStore}
1089
+ * Get the ORDER BY columns and directions as JSON array.
1090
+ * @returns {any}
1176
1091
  */
1177
- static with_capacity(dimension, metric, capacity) {
1092
+ get orderBy() {
1093
+ const ret = wasm.parsedquery_orderBy(this.__wbg_ptr);
1094
+ return takeObject(ret);
1095
+ }
1096
+ /**
1097
+ * Get the table name from the FROM clause.
1098
+ * @returns {string | undefined}
1099
+ */
1100
+ get tableName() {
1178
1101
  try {
1179
1102
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1180
- const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1181
- const len0 = WASM_VECTOR_LEN;
1182
- wasm.vectorstore_with_capacity(retptr, dimension, ptr0, len0, capacity);
1103
+ wasm.parsedquery_tableName(retptr, this.__wbg_ptr);
1183
1104
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1184
1105
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1185
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1186
- if (r2) {
1187
- throw takeObject(r1);
1106
+ let v1;
1107
+ if (r0 !== 0) {
1108
+ v1 = getStringFromWasm0(r0, r1).slice();
1109
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1188
1110
  }
1189
- return VectorStore.__wrap(r0);
1111
+ return v1;
1190
1112
  } finally {
1191
1113
  wasm.__wbindgen_add_to_stack_pointer(16);
1192
1114
  }
1193
1115
  }
1194
- /**
1195
- * Deletes `IndexedDB` database.
1196
- * @param {string} db_name
1197
- * @returns {Promise<void>}
1198
- */
1199
- static delete_database(db_name) {
1200
- const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1201
- const len0 = WASM_VECTOR_LEN;
1202
- const ret = wasm.vectorstore_delete_database(ptr0, len0);
1203
- return takeObject(ret);
1116
+ }
1117
+ if (Symbol.dispose) ParsedQuery.prototype[Symbol.dispose] = ParsedQuery.prototype.free;
1118
+
1119
+ /**
1120
+ * Semantic Memory for AI agents in WASM.
1121
+ *
1122
+ * Stores knowledge facts as vectors with similarity search.
1123
+ *
1124
+ * # Example (JavaScript)
1125
+ *
1126
+ * ```javascript
1127
+ * import { SemanticMemory } from 'velesdb-wasm';
1128
+ *
1129
+ * const memory = new SemanticMemory(384);
1130
+ * memory.store(1, "Paris is the capital of France", embedding);
1131
+ * const results = memory.query(queryEmbedding, 5);
1132
+ * ```
1133
+ */
1134
+ export class SemanticMemory {
1135
+ __destroy_into_raw() {
1136
+ const ptr = this.__wbg_ptr;
1137
+ this.__wbg_ptr = 0;
1138
+ SemanticMemoryFinalization.unregister(this);
1139
+ return ptr;
1140
+ }
1141
+ free() {
1142
+ const ptr = this.__destroy_into_raw();
1143
+ wasm.__wbg_semanticmemory_free(ptr, 0);
1204
1144
  }
1205
1145
  /**
1206
- * Exports to binary format for IndexedDB/localStorage.
1207
- * @returns {Uint8Array}
1146
+ * Clears all knowledge facts.
1208
1147
  */
1209
- export_to_bytes() {
1210
- try {
1211
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1212
- wasm.vectorstore_export_to_bytes(retptr, this.__wbg_ptr);
1213
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1214
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1215
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1216
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1217
- if (r3) {
1218
- throw takeObject(r2);
1219
- }
1220
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
1221
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1222
- return v1;
1223
- } finally {
1224
- wasm.__wbindgen_add_to_stack_pointer(16);
1225
- }
1148
+ clear() {
1149
+ wasm.semanticmemory_clear(this.__wbg_ptr);
1226
1150
  }
1227
1151
  /**
1228
- * Returns true if this is a metadata-only store.
1229
- * @returns {boolean}
1152
+ * Returns the embedding dimension.
1153
+ * @returns {number}
1230
1154
  */
1231
- get is_metadata_only() {
1232
- const ret = wasm.vectorstore_is_metadata_only(this.__wbg_ptr);
1233
- return ret !== 0;
1155
+ dimension() {
1156
+ const ret = wasm.semanticmemory_dimension(this.__wbg_ptr);
1157
+ return ret >>> 0;
1234
1158
  }
1235
1159
  /**
1236
- * Imports from binary format.
1237
- * @param {Uint8Array} bytes
1238
- * @returns {VectorStore}
1160
+ * Returns true if no knowledge facts are stored.
1161
+ * @returns {boolean}
1239
1162
  */
1240
- static import_from_bytes(bytes) {
1241
- try {
1242
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1243
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1244
- const len0 = WASM_VECTOR_LEN;
1245
- wasm.vectorstore_import_from_bytes(retptr, ptr0, len0);
1246
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1247
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1248
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1249
- if (r2) {
1250
- throw takeObject(r1);
1251
- }
1252
- return VectorStore.__wrap(r0);
1253
- } finally {
1254
- wasm.__wbindgen_add_to_stack_pointer(16);
1255
- }
1163
+ is_empty() {
1164
+ const ret = wasm.semanticmemory_is_empty(this.__wbg_ptr);
1165
+ return ret !== 0;
1256
1166
  }
1257
1167
  /**
1258
- * Creates a metadata-only store (no vectors, only payloads).
1259
- * @returns {VectorStore}
1168
+ * Returns the number of stored knowledge facts.
1169
+ * @returns {number}
1260
1170
  */
1261
- static new_metadata_only() {
1262
- const ret = wasm.vectorstore_new_metadata_only();
1263
- return VectorStore.__wrap(ret);
1171
+ len() {
1172
+ const ret = wasm.semanticmemory_len(this.__wbg_ptr);
1173
+ return ret >>> 0;
1264
1174
  }
1265
1175
  /**
1266
- * Similarity search with threshold. Operators: >, >=, <, <=, =, !=.
1267
- * @param {Float32Array} query
1268
- * @param {number} threshold
1269
- * @param {string} operator
1270
- * @param {number} k
1271
- * @returns {any}
1176
+ * Creates a new `SemanticMemory` with the given embedding dimension.
1177
+ * @param {number} dimension
1272
1178
  */
1273
- similarity_search(query, threshold, operator, k) {
1179
+ constructor(dimension) {
1274
1180
  try {
1275
1181
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1276
- const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
1277
- const len0 = WASM_VECTOR_LEN;
1278
- const ptr1 = passStringToWasm0(operator, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1279
- const len1 = WASM_VECTOR_LEN;
1280
- wasm.vectorstore_similarity_search(retptr, this.__wbg_ptr, ptr0, len0, threshold, ptr1, len1, k);
1182
+ wasm.semanticmemory_new(retptr, dimension);
1281
1183
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1282
1184
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1283
1185
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1284
1186
  if (r2) {
1285
1187
  throw takeObject(r1);
1286
1188
  }
1287
- return takeObject(r0);
1189
+ this.__wbg_ptr = r0 >>> 0;
1190
+ SemanticMemoryFinalization.register(this, this.__wbg_ptr, this);
1191
+ return this;
1288
1192
  } finally {
1289
1193
  wasm.__wbindgen_add_to_stack_pointer(16);
1290
1194
  }
1291
1195
  }
1292
1196
  /**
1293
- * Multi-query search with fusion. Strategies: average, maximum, rrf.
1294
- * @param {Float32Array} vectors
1295
- * @param {number} num_vectors
1296
- * @param {number} k
1297
- * @param {string} strategy
1298
- * @param {number | null} [rrf_k]
1197
+ * Queries semantic memory by similarity search.
1198
+ *
1199
+ * Returns a JSON array of {id, score, content} objects.
1200
+ * @param {Float32Array} embedding
1201
+ * @param {number} top_k
1299
1202
  * @returns {any}
1300
1203
  */
1301
- multi_query_search(vectors, num_vectors, k, strategy, rrf_k) {
1204
+ query(embedding, top_k) {
1302
1205
  try {
1303
1206
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1304
- const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1207
+ const ptr0 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_export);
1305
1208
  const len0 = WASM_VECTOR_LEN;
1306
- const ptr1 = passStringToWasm0(strategy, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1307
- const len1 = WASM_VECTOR_LEN;
1308
- wasm.vectorstore_multi_query_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k, ptr1, len1, isLikeNone(rrf_k) ? 0x100000001 : (rrf_k) >>> 0);
1209
+ wasm.semanticmemory_query(retptr, this.__wbg_ptr, ptr0, len0, top_k);
1309
1210
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1310
1211
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1311
1212
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1318,41 +1219,86 @@ export class VectorStore {
1318
1219
  }
1319
1220
  }
1320
1221
  /**
1321
- * Searches with metadata filtering. Returns [{id, score, payload}].
1322
- * @param {Float32Array} query
1323
- * @param {number} k
1324
- * @param {any} filter
1325
- * @returns {any}
1222
+ * Removes a knowledge fact by ID.
1223
+ * @param {bigint} id
1224
+ * @returns {boolean}
1326
1225
  */
1327
- search_with_filter(query, k, filter) {
1226
+ remove(id) {
1227
+ const ret = wasm.semanticmemory_remove(this.__wbg_ptr, id);
1228
+ return ret !== 0;
1229
+ }
1230
+ /**
1231
+ * Stores a knowledge fact with its embedding vector.
1232
+ *
1233
+ * # Arguments
1234
+ *
1235
+ * * `id` - Unique identifier for this fact
1236
+ * * `content` - Text content of the knowledge
1237
+ * * `embedding` - Vector representation (`Float32Array`)
1238
+ * @param {bigint} id
1239
+ * @param {string} content
1240
+ * @param {Float32Array} embedding
1241
+ */
1242
+ store(id, content, embedding) {
1328
1243
  try {
1329
1244
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1330
- const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
1245
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1331
1246
  const len0 = WASM_VECTOR_LEN;
1332
- wasm.vectorstore_search_with_filter(retptr, this.__wbg_ptr, ptr0, len0, k, addHeapObject(filter));
1247
+ const ptr1 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_export);
1248
+ const len1 = WASM_VECTOR_LEN;
1249
+ wasm.semanticmemory_store(retptr, this.__wbg_ptr, id, ptr0, len0, ptr1, len1);
1333
1250
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1334
1251
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1335
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1336
- if (r2) {
1337
- throw takeObject(r1);
1252
+ if (r1) {
1253
+ throw takeObject(r0);
1338
1254
  }
1339
- return takeObject(r0);
1340
1255
  } finally {
1341
1256
  wasm.__wbindgen_add_to_stack_pointer(16);
1342
1257
  }
1343
1258
  }
1259
+ }
1260
+ if (Symbol.dispose) SemanticMemory.prototype[Symbol.dispose] = SemanticMemory.prototype.free;
1261
+
1262
+ /**
1263
+ * In-memory sparse inverted index for WASM.
1264
+ *
1265
+ * Uses a `BTreeMap<u32, Vec<(u64, f32)>>` as posting lists.
1266
+ */
1267
+ export class SparseIndex {
1268
+ __destroy_into_raw() {
1269
+ const ptr = this.__wbg_ptr;
1270
+ this.__wbg_ptr = 0;
1271
+ SparseIndexFinalization.unregister(this);
1272
+ return ptr;
1273
+ }
1274
+ free() {
1275
+ const ptr = this.__destroy_into_raw();
1276
+ wasm.__wbg_sparseindex_free(ptr, 0);
1277
+ }
1344
1278
  /**
1345
- * Inserts a vector with ID and optional JSON payload.
1346
- * @param {bigint} id
1347
- * @param {Float32Array} vector
1348
- * @param {any} payload
1279
+ * Returns the number of documents in the index.
1280
+ * @returns {number}
1349
1281
  */
1350
- insert_with_payload(id, vector, payload) {
1282
+ get doc_count() {
1283
+ const ret = wasm.sparseindex_doc_count(this.__wbg_ptr);
1284
+ return ret >>> 0;
1285
+ }
1286
+ /**
1287
+ * Inserts a document with the given sparse vector.
1288
+ *
1289
+ * `indices` and `values` must have the same length.
1290
+ * @param {bigint} doc_id
1291
+ * @param {Uint32Array} indices
1292
+ * @param {Float32Array} values
1293
+ */
1294
+ insert(doc_id, indices, values) {
1351
1295
  try {
1352
1296
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1353
- const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
1297
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
1354
1298
  const len0 = WASM_VECTOR_LEN;
1355
- wasm.vectorstore_insert_with_payload(retptr, this.__wbg_ptr, id, ptr0, len0, addHeapObject(payload));
1299
+ const ptr1 = passArrayF32ToWasm0(values, wasm.__wbindgen_export);
1300
+ const len1 = WASM_VECTOR_LEN;
1301
+ wasm.sparseindex_insert(retptr, this.__wbg_ptr, doc_id, ptr0, len0, ptr1, len1);
1356
1302
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1357
1303
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1358
1304
  if (r1) {
@@ -1363,14 +1309,31 @@ export class VectorStore {
1363
1309
  }
1364
1310
  }
1365
1311
  /**
1366
- * Gets a vector by ID. Returns {id, vector, payload} or null.
1367
- * @param {bigint} id
1312
+ * Creates a new empty sparse index.
1313
+ */
1314
+ constructor() {
1315
+ const ret = wasm.sparseindex_new();
1316
+ this.__wbg_ptr = ret >>> 0;
1317
+ SparseIndexFinalization.register(this, this.__wbg_ptr, this);
1318
+ return this;
1319
+ }
1320
+ /**
1321
+ * Searches the index with the given sparse query vector.
1322
+ *
1323
+ * Returns a JSON array of `{doc_id, score}` objects, sorted by score descending.
1324
+ * @param {Uint32Array} query_indices
1325
+ * @param {Float32Array} query_values
1326
+ * @param {number} k
1368
1327
  * @returns {any}
1369
1328
  */
1370
- get(id) {
1329
+ search(query_indices, query_values, k) {
1371
1330
  try {
1372
1331
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1373
- wasm.vectorstore_get(retptr, this.__wbg_ptr, id);
1332
+ const ptr0 = passArray32ToWasm0(query_indices, wasm.__wbindgen_export);
1333
+ const len0 = WASM_VECTOR_LEN;
1334
+ const ptr1 = passArrayF32ToWasm0(query_values, wasm.__wbindgen_export);
1335
+ const len1 = WASM_VECTOR_LEN;
1336
+ wasm.sparseindex_search(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, k);
1374
1337
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1375
1338
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1376
1339
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1382,107 +1345,303 @@ export class VectorStore {
1382
1345
  wasm.__wbindgen_add_to_stack_pointer(16);
1383
1346
  }
1384
1347
  }
1348
+ }
1349
+ if (Symbol.dispose) SparseIndex.prototype[Symbol.dispose] = SparseIndex.prototype.free;
1350
+
1351
+ /**
1352
+ * Storage mode for vector quantization.
1353
+ * @enum {0 | 1 | 2 | 3}
1354
+ */
1355
+ export const StorageMode = Object.freeze({
1385
1356
  /**
1386
- * Returns the number of vectors in the store.
1357
+ * Full f32 precision (4 bytes per dimension)
1358
+ */
1359
+ Full: 0, "0": "Full",
1360
+ /**
1361
+ * SQ8: 8-bit scalar quantization (1 byte per dimension, 4x compression)
1362
+ */
1363
+ SQ8: 1, "1": "SQ8",
1364
+ /**
1365
+ * Binary: 1-bit quantization (1 bit per dimension, 32x compression)
1366
+ */
1367
+ Binary: 2, "2": "Binary",
1368
+ /**
1369
+ * Product Quantization (currently mapped to SQ8 path in WASM runtime)
1370
+ */
1371
+ ProductQuantization: 3, "3": "ProductQuantization",
1372
+ });
1373
+
1374
+ /**
1375
+ * Progress information for long-running traversals.
1376
+ */
1377
+ export class TraversalProgress {
1378
+ __destroy_into_raw() {
1379
+ const ptr = this.__wbg_ptr;
1380
+ this.__wbg_ptr = 0;
1381
+ TraversalProgressFinalization.unregister(this);
1382
+ return ptr;
1383
+ }
1384
+ free() {
1385
+ const ptr = this.__destroy_into_raw();
1386
+ wasm.__wbg_traversalprogress_free(ptr, 0);
1387
+ }
1388
+ /**
1389
+ * Current traversal depth.
1387
1390
  * @returns {number}
1388
1391
  */
1389
- get len() {
1390
- const ret = wasm.vectorstore_len(this.__wbg_ptr);
1392
+ get current_depth() {
1393
+ const ret = wasm.__wbg_get_traversalprogress_current_depth(this.__wbg_ptr);
1391
1394
  return ret >>> 0;
1392
1395
  }
1393
1396
  /**
1394
- * Creates a new vector store. Metrics: cosine, euclidean, dot, hamming, jaccard.
1395
- * @param {number} dimension
1396
- * @param {string} metric
1397
+ * Estimated total nodes to visit (heuristic).
1398
+ * @returns {number}
1397
1399
  */
1398
- constructor(dimension, metric) {
1399
- try {
1400
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1401
- const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1402
- const len0 = WASM_VECTOR_LEN;
1403
- wasm.vectorstore_new(retptr, dimension, ptr0, len0);
1404
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1405
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1406
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1407
- if (r2) {
1408
- throw takeObject(r1);
1409
- }
1410
- this.__wbg_ptr = r0 >>> 0;
1411
- VectorStoreFinalization.register(this, this.__wbg_ptr, this);
1412
- return this;
1413
- } finally {
1414
- wasm.__wbindgen_add_to_stack_pointer(16);
1415
- }
1400
+ get estimated_total() {
1401
+ const ret = wasm.__wbg_get_traversalprogress_estimated_total(this.__wbg_ptr);
1402
+ return ret >>> 0;
1416
1403
  }
1417
1404
  /**
1418
- * Loads from `IndexedDB`.
1419
- * @param {string} db_name
1420
- * @returns {Promise<VectorStore>}
1405
+ * Whether the traversal was cancelled.
1406
+ * @returns {boolean}
1421
1407
  */
1422
- static load(db_name) {
1423
- const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1424
- const len0 = WASM_VECTOR_LEN;
1425
- const ret = wasm.vectorstore_load(ptr0, len0);
1426
- return takeObject(ret);
1408
+ get is_cancelled() {
1409
+ const ret = wasm.__wbg_get_traversalprogress_is_cancelled(this.__wbg_ptr);
1410
+ return ret !== 0;
1427
1411
  }
1428
1412
  /**
1429
- * Saves to `IndexedDB`.
1430
- * @param {string} db_name
1431
- * @returns {Promise<void>}
1413
+ * Whether the traversal is complete.
1414
+ * @returns {boolean}
1432
1415
  */
1433
- save(db_name) {
1434
- const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1435
- const len0 = WASM_VECTOR_LEN;
1436
- const ret = wasm.vectorstore_save(this.__wbg_ptr, ptr0, len0);
1437
- return takeObject(ret);
1416
+ get is_complete() {
1417
+ const ret = wasm.__wbg_get_traversalprogress_is_complete(this.__wbg_ptr);
1418
+ return ret !== 0;
1438
1419
  }
1439
1420
  /**
1440
- * Clears all vectors from the store.
1421
+ * Number of nodes visited so far.
1422
+ * @returns {number}
1441
1423
  */
1442
- clear() {
1443
- wasm.vectorstore_clear(this.__wbg_ptr);
1424
+ get visited_count() {
1425
+ const ret = wasm.__wbg_get_traversalprogress_visited_count(this.__wbg_ptr);
1426
+ return ret >>> 0;
1444
1427
  }
1445
1428
  /**
1446
- * Inserts a vector with the given ID.
1447
- * @param {bigint} id
1448
- * @param {Float32Array} vector
1429
+ * Current traversal depth.
1430
+ * @param {number} arg0
1449
1431
  */
1450
- insert(id, vector) {
1432
+ set current_depth(arg0) {
1433
+ wasm.__wbg_set_traversalprogress_current_depth(this.__wbg_ptr, arg0);
1434
+ }
1435
+ /**
1436
+ * Estimated total nodes to visit (heuristic).
1437
+ * @param {number} arg0
1438
+ */
1439
+ set estimated_total(arg0) {
1440
+ wasm.__wbg_set_traversalprogress_estimated_total(this.__wbg_ptr, arg0);
1441
+ }
1442
+ /**
1443
+ * Whether the traversal was cancelled.
1444
+ * @param {boolean} arg0
1445
+ */
1446
+ set is_cancelled(arg0) {
1447
+ wasm.__wbg_set_traversalprogress_is_cancelled(this.__wbg_ptr, arg0);
1448
+ }
1449
+ /**
1450
+ * Whether the traversal is complete.
1451
+ * @param {boolean} arg0
1452
+ */
1453
+ set is_complete(arg0) {
1454
+ wasm.__wbg_set_traversalprogress_is_complete(this.__wbg_ptr, arg0);
1455
+ }
1456
+ /**
1457
+ * Number of nodes visited so far.
1458
+ * @param {number} arg0
1459
+ */
1460
+ set visited_count(arg0) {
1461
+ wasm.__wbg_set_traversalprogress_visited_count(this.__wbg_ptr, arg0);
1462
+ }
1463
+ /**
1464
+ * Creates a new progress report.
1465
+ * @param {number} visited
1466
+ * @param {number} estimated
1467
+ * @param {number} depth
1468
+ */
1469
+ constructor(visited, estimated, depth) {
1470
+ const ret = wasm.traversalprogress_new(visited, estimated, depth);
1471
+ this.__wbg_ptr = ret >>> 0;
1472
+ TraversalProgressFinalization.register(this, this.__wbg_ptr, this);
1473
+ return this;
1474
+ }
1475
+ /**
1476
+ * Returns the completion percentage (0-100).
1477
+ * @returns {number}
1478
+ */
1479
+ get percentage() {
1480
+ const ret = wasm.traversalprogress_percentage(this.__wbg_ptr);
1481
+ return ret;
1482
+ }
1483
+ /**
1484
+ * Converts to JSON for postMessage.
1485
+ * @returns {any}
1486
+ */
1487
+ to_json() {
1451
1488
  try {
1452
1489
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1453
- const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
1490
+ wasm.traversalprogress_to_json(retptr, this.__wbg_ptr);
1491
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1492
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1493
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1494
+ if (r2) {
1495
+ throw takeObject(r1);
1496
+ }
1497
+ return takeObject(r0);
1498
+ } finally {
1499
+ wasm.__wbindgen_add_to_stack_pointer(16);
1500
+ }
1501
+ }
1502
+ }
1503
+ if (Symbol.dispose) TraversalProgress.prototype[Symbol.dispose] = TraversalProgress.prototype.free;
1504
+
1505
+ /**
1506
+ * A vector store for in-memory vector search.
1507
+ *
1508
+ * # Performance
1509
+ *
1510
+ * Uses contiguous memory layout for optimal cache locality and fast
1511
+ * serialization. Vector data is stored in a single buffer rather than
1512
+ * individual Vec allocations.
1513
+ *
1514
+ * # Storage Modes
1515
+ *
1516
+ * - `Full`: f32 precision, best recall
1517
+ * - `SQ8`: 4x memory reduction, ~1% recall loss
1518
+ * - `Binary`: 32x memory reduction, ~5-10% recall loss
1519
+ */
1520
+ export class VectorStore {
1521
+ static __wrap(ptr) {
1522
+ ptr = ptr >>> 0;
1523
+ const obj = Object.create(VectorStore.prototype);
1524
+ obj.__wbg_ptr = ptr;
1525
+ VectorStoreFinalization.register(obj, obj.__wbg_ptr, obj);
1526
+ return obj;
1527
+ }
1528
+ __destroy_into_raw() {
1529
+ const ptr = this.__wbg_ptr;
1530
+ this.__wbg_ptr = 0;
1531
+ VectorStoreFinalization.unregister(this);
1532
+ return ptr;
1533
+ }
1534
+ free() {
1535
+ const ptr = this.__destroy_into_raw();
1536
+ wasm.__wbg_vectorstore_free(ptr, 0);
1537
+ }
1538
+ /**
1539
+ * Batch search for multiple vectors. Returns [[[id, score], ...], ...].
1540
+ * @param {Float32Array} vectors
1541
+ * @param {number} num_vectors
1542
+ * @param {number} k
1543
+ * @returns {any}
1544
+ */
1545
+ batch_search(vectors, num_vectors, k) {
1546
+ try {
1547
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1548
+ const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1454
1549
  const len0 = WASM_VECTOR_LEN;
1455
- wasm.vectorstore_insert(retptr, this.__wbg_ptr, id, ptr0, len0);
1550
+ wasm.vectorstore_batch_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k);
1456
1551
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1457
1552
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1458
- if (r1) {
1459
- throw takeObject(r0);
1553
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1554
+ if (r2) {
1555
+ throw takeObject(r1);
1460
1556
  }
1557
+ return takeObject(r0);
1461
1558
  } finally {
1462
1559
  wasm.__wbindgen_add_to_stack_pointer(16);
1463
1560
  }
1464
1561
  }
1465
1562
  /**
1466
- * Removes a vector by ID.
1563
+ * Clears all vectors from the store.
1564
+ */
1565
+ clear() {
1566
+ wasm.vectorstore_clear(this.__wbg_ptr);
1567
+ }
1568
+ /**
1569
+ * Deletes `IndexedDB` database.
1570
+ * @param {string} db_name
1571
+ * @returns {Promise<void>}
1572
+ */
1573
+ static delete_database(db_name) {
1574
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1575
+ const len0 = WASM_VECTOR_LEN;
1576
+ const ret = wasm.vectorstore_delete_database(ptr0, len0);
1577
+ return takeObject(ret);
1578
+ }
1579
+ /**
1580
+ * Returns the vector dimension.
1581
+ * @returns {number}
1582
+ */
1583
+ get dimension() {
1584
+ const ret = wasm.vectorstore_dimension(this.__wbg_ptr);
1585
+ return ret >>> 0;
1586
+ }
1587
+ /**
1588
+ * Exports to binary format for IndexedDB/localStorage.
1589
+ * @returns {Uint8Array}
1590
+ */
1591
+ export_to_bytes() {
1592
+ try {
1593
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1594
+ wasm.vectorstore_export_to_bytes(retptr, this.__wbg_ptr);
1595
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1596
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1597
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1598
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1599
+ if (r3) {
1600
+ throw takeObject(r2);
1601
+ }
1602
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1603
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1604
+ return v1;
1605
+ } finally {
1606
+ wasm.__wbindgen_add_to_stack_pointer(16);
1607
+ }
1608
+ }
1609
+ /**
1610
+ * Gets a vector by ID. Returns {id, vector, payload} or null.
1467
1611
  * @param {bigint} id
1468
- * @returns {boolean}
1612
+ * @returns {any}
1469
1613
  */
1470
- remove(id) {
1471
- const ret = wasm.vectorstore_remove(this.__wbg_ptr, id);
1472
- return ret !== 0;
1614
+ get(id) {
1615
+ try {
1616
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1617
+ wasm.vectorstore_get(retptr, this.__wbg_ptr, id);
1618
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1619
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1620
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1621
+ if (r2) {
1622
+ throw takeObject(r1);
1623
+ }
1624
+ return takeObject(r0);
1625
+ } finally {
1626
+ wasm.__wbindgen_add_to_stack_pointer(16);
1627
+ }
1473
1628
  }
1474
1629
  /**
1475
- * k-NN search. Returns [[id, score], ...].
1476
- * @param {Float32Array} query
1630
+ * Hybrid search (vector + text). `vector_weight` 0-1 (default 0.5).
1631
+ * @param {Float32Array} query_vector
1632
+ * @param {string} text_query
1477
1633
  * @param {number} k
1634
+ * @param {number | null} [vector_weight]
1478
1635
  * @returns {any}
1479
1636
  */
1480
- search(query, k) {
1637
+ hybrid_search(query_vector, text_query, k, vector_weight) {
1481
1638
  try {
1482
1639
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1483
- const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
1640
+ const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1484
1641
  const len0 = WASM_VECTOR_LEN;
1485
- wasm.vectorstore_search(retptr, this.__wbg_ptr, ptr0, len0, k);
1642
+ const ptr1 = passStringToWasm0(text_query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1643
+ const len1 = WASM_VECTOR_LEN;
1644
+ wasm.vectorstore_hybrid_search(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, k, isLikeNone(vector_weight) ? 0x100000001 : Math.fround(vector_weight));
1486
1645
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1487
1646
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1488
1647
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1491,36 +1650,1442 @@ export class VectorStore {
1491
1650
  }
1492
1651
  return takeObject(r0);
1493
1652
  } finally {
1494
- wasm.__wbindgen_add_to_stack_pointer(16);
1653
+ wasm.__wbindgen_add_to_stack_pointer(16);
1654
+ }
1655
+ }
1656
+ /**
1657
+ * Imports from binary format.
1658
+ * @param {Uint8Array} bytes
1659
+ * @returns {VectorStore}
1660
+ */
1661
+ static import_from_bytes(bytes) {
1662
+ try {
1663
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1664
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1665
+ const len0 = WASM_VECTOR_LEN;
1666
+ wasm.vectorstore_import_from_bytes(retptr, ptr0, len0);
1667
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1668
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1669
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1670
+ if (r2) {
1671
+ throw takeObject(r1);
1672
+ }
1673
+ return VectorStore.__wrap(r0);
1674
+ } finally {
1675
+ wasm.__wbindgen_add_to_stack_pointer(16);
1676
+ }
1677
+ }
1678
+ /**
1679
+ * Inserts a vector with the given ID.
1680
+ * @param {bigint} id
1681
+ * @param {Float32Array} vector
1682
+ */
1683
+ insert(id, vector) {
1684
+ try {
1685
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1686
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
1687
+ const len0 = WASM_VECTOR_LEN;
1688
+ wasm.vectorstore_insert(retptr, this.__wbg_ptr, id, ptr0, len0);
1689
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1690
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1691
+ if (r1) {
1692
+ throw takeObject(r0);
1693
+ }
1694
+ } finally {
1695
+ wasm.__wbindgen_add_to_stack_pointer(16);
1696
+ }
1697
+ }
1698
+ /**
1699
+ * Batch insert. Input: `[[id, Float32Array], ...]`.
1700
+ * @param {any} batch
1701
+ */
1702
+ insert_batch(batch) {
1703
+ try {
1704
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1705
+ wasm.vectorstore_insert_batch(retptr, this.__wbg_ptr, addHeapObject(batch));
1706
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1707
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1708
+ if (r1) {
1709
+ throw takeObject(r0);
1710
+ }
1711
+ } finally {
1712
+ wasm.__wbindgen_add_to_stack_pointer(16);
1713
+ }
1714
+ }
1715
+ /**
1716
+ * Inserts a vector with ID and optional JSON payload.
1717
+ * @param {bigint} id
1718
+ * @param {Float32Array} vector
1719
+ * @param {any} payload
1720
+ */
1721
+ insert_with_payload(id, vector, payload) {
1722
+ try {
1723
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1724
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
1725
+ const len0 = WASM_VECTOR_LEN;
1726
+ wasm.vectorstore_insert_with_payload(retptr, this.__wbg_ptr, id, ptr0, len0, addHeapObject(payload));
1727
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1728
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1729
+ if (r1) {
1730
+ throw takeObject(r0);
1731
+ }
1732
+ } finally {
1733
+ wasm.__wbindgen_add_to_stack_pointer(16);
1734
+ }
1735
+ }
1736
+ /**
1737
+ * Returns true if the store is empty.
1738
+ * @returns {boolean}
1739
+ */
1740
+ get is_empty() {
1741
+ const ret = wasm.vectorstore_is_empty(this.__wbg_ptr);
1742
+ return ret !== 0;
1743
+ }
1744
+ /**
1745
+ * Returns true if this is a metadata-only store.
1746
+ * @returns {boolean}
1747
+ */
1748
+ get is_metadata_only() {
1749
+ const ret = wasm.vectorstore_is_metadata_only(this.__wbg_ptr);
1750
+ return ret !== 0;
1751
+ }
1752
+ /**
1753
+ * Returns the number of vectors in the store.
1754
+ * @returns {number}
1755
+ */
1756
+ get len() {
1757
+ const ret = wasm.vectorstore_len(this.__wbg_ptr);
1758
+ return ret >>> 0;
1759
+ }
1760
+ /**
1761
+ * Loads from `IndexedDB`.
1762
+ * @param {string} db_name
1763
+ * @returns {Promise<VectorStore>}
1764
+ */
1765
+ static load(db_name) {
1766
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1767
+ const len0 = WASM_VECTOR_LEN;
1768
+ const ret = wasm.vectorstore_load(ptr0, len0);
1769
+ return takeObject(ret);
1770
+ }
1771
+ /**
1772
+ * Returns memory usage estimate in bytes.
1773
+ * @returns {number}
1774
+ */
1775
+ memory_usage() {
1776
+ const ret = wasm.vectorstore_memory_usage(this.__wbg_ptr);
1777
+ return ret >>> 0;
1778
+ }
1779
+ /**
1780
+ * Multi-query search with fusion. Strategies: average, maximum, rrf.
1781
+ * @param {Float32Array} vectors
1782
+ * @param {number} num_vectors
1783
+ * @param {number} k
1784
+ * @param {string} strategy
1785
+ * @param {number | null} [rrf_k]
1786
+ * @returns {any}
1787
+ */
1788
+ multi_query_search(vectors, num_vectors, k, strategy, rrf_k) {
1789
+ try {
1790
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1791
+ const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1792
+ const len0 = WASM_VECTOR_LEN;
1793
+ const ptr1 = passStringToWasm0(strategy, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1794
+ const len1 = WASM_VECTOR_LEN;
1795
+ wasm.vectorstore_multi_query_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k, ptr1, len1, isLikeNone(rrf_k) ? 0x100000001 : (rrf_k) >>> 0);
1796
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1797
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1798
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1799
+ if (r2) {
1800
+ throw takeObject(r1);
1801
+ }
1802
+ return takeObject(r0);
1803
+ } finally {
1804
+ wasm.__wbindgen_add_to_stack_pointer(16);
1805
+ }
1806
+ }
1807
+ /**
1808
+ * Creates a new vector store. Metrics: cosine, euclidean, dot, hamming, jaccard.
1809
+ * @param {number} dimension
1810
+ * @param {string} metric
1811
+ */
1812
+ constructor(dimension, metric) {
1813
+ try {
1814
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1815
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1816
+ const len0 = WASM_VECTOR_LEN;
1817
+ wasm.vectorstore_new(retptr, dimension, ptr0, len0);
1818
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1819
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1820
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1821
+ if (r2) {
1822
+ throw takeObject(r1);
1823
+ }
1824
+ this.__wbg_ptr = r0 >>> 0;
1825
+ VectorStoreFinalization.register(this, this.__wbg_ptr, this);
1826
+ return this;
1827
+ } finally {
1828
+ wasm.__wbindgen_add_to_stack_pointer(16);
1829
+ }
1830
+ }
1831
+ /**
1832
+ * Creates a metadata-only store (no vectors, only payloads).
1833
+ * @returns {VectorStore}
1834
+ */
1835
+ static new_metadata_only() {
1836
+ const ret = wasm.vectorstore_new_metadata_only();
1837
+ return VectorStore.__wrap(ret);
1838
+ }
1839
+ /**
1840
+ * Creates store with mode: full (4B/dim), sq8 (4x compression), binary (32x).
1841
+ * @param {number} dimension
1842
+ * @param {string} metric
1843
+ * @param {string} mode
1844
+ * @returns {VectorStore}
1845
+ */
1846
+ static new_with_mode(dimension, metric, mode) {
1847
+ try {
1848
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1849
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1850
+ const len0 = WASM_VECTOR_LEN;
1851
+ const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1852
+ const len1 = WASM_VECTOR_LEN;
1853
+ wasm.vectorstore_new_with_mode(retptr, dimension, ptr0, len0, ptr1, len1);
1854
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1855
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1856
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1857
+ if (r2) {
1858
+ throw takeObject(r1);
1859
+ }
1860
+ return VectorStore.__wrap(r0);
1861
+ } finally {
1862
+ wasm.__wbindgen_add_to_stack_pointer(16);
1863
+ }
1864
+ }
1865
+ /**
1866
+ * VelesQL-style query returning multi-model results (EPIC-031 US-009).
1867
+ *
1868
+ * Returns results in `HybridResult` format with `node_id`, `vector_score`,
1869
+ * `graph_score`, `fused_score`, `bindings`, and `column_data`.
1870
+ *
1871
+ * # Arguments
1872
+ * * `query_vector` - Query vector for similarity search
1873
+ * * `k` - Number of results to return
1874
+ *
1875
+ * # Returns
1876
+ * Array of `{nodeId, vectorScore, graphScore, fusedScore, bindings, columnData}`
1877
+ * @param {Float32Array} query_vector
1878
+ * @param {number} k
1879
+ * @returns {any}
1880
+ */
1881
+ query(query_vector, k) {
1882
+ try {
1883
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1884
+ const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1885
+ const len0 = WASM_VECTOR_LEN;
1886
+ wasm.vectorstore_query(retptr, this.__wbg_ptr, ptr0, len0, k);
1887
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1888
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1889
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1890
+ if (r2) {
1891
+ throw takeObject(r1);
1892
+ }
1893
+ return takeObject(r0);
1894
+ } finally {
1895
+ wasm.__wbindgen_add_to_stack_pointer(16);
1896
+ }
1897
+ }
1898
+ /**
1899
+ * Removes a vector by ID.
1900
+ * @param {bigint} id
1901
+ * @returns {boolean}
1902
+ */
1903
+ remove(id) {
1904
+ const ret = wasm.vectorstore_remove(this.__wbg_ptr, id);
1905
+ return ret !== 0;
1906
+ }
1907
+ /**
1908
+ * Pre-allocates memory for additional vectors.
1909
+ * @param {number} additional
1910
+ */
1911
+ reserve(additional) {
1912
+ wasm.vectorstore_reserve(this.__wbg_ptr, additional);
1913
+ }
1914
+ /**
1915
+ * Saves to `IndexedDB`.
1916
+ * @param {string} db_name
1917
+ * @returns {Promise<void>}
1918
+ */
1919
+ save(db_name) {
1920
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1921
+ const len0 = WASM_VECTOR_LEN;
1922
+ const ret = wasm.vectorstore_save(this.__wbg_ptr, ptr0, len0);
1923
+ return takeObject(ret);
1924
+ }
1925
+ /**
1926
+ * k-NN search. Returns [[id, score], ...].
1927
+ * @param {Float32Array} query
1928
+ * @param {number} k
1929
+ * @returns {any}
1930
+ */
1931
+ search(query, k) {
1932
+ try {
1933
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1934
+ const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
1935
+ const len0 = WASM_VECTOR_LEN;
1936
+ wasm.vectorstore_search(retptr, this.__wbg_ptr, ptr0, len0, k);
1937
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1938
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1939
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1940
+ if (r2) {
1941
+ throw takeObject(r1);
1942
+ }
1943
+ return takeObject(r0);
1944
+ } finally {
1945
+ wasm.__wbindgen_add_to_stack_pointer(16);
1946
+ }
1947
+ }
1948
+ /**
1949
+ * Searches with metadata filtering. Returns [{id, score, payload}].
1950
+ * @param {Float32Array} query
1951
+ * @param {number} k
1952
+ * @param {any} filter
1953
+ * @returns {any}
1954
+ */
1955
+ search_with_filter(query, k, filter) {
1956
+ try {
1957
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1958
+ const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
1959
+ const len0 = WASM_VECTOR_LEN;
1960
+ wasm.vectorstore_search_with_filter(retptr, this.__wbg_ptr, ptr0, len0, k, addHeapObject(filter));
1961
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1962
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1963
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1964
+ if (r2) {
1965
+ throw takeObject(r1);
1966
+ }
1967
+ return takeObject(r0);
1968
+ } finally {
1969
+ wasm.__wbindgen_add_to_stack_pointer(16);
1970
+ }
1971
+ }
1972
+ /**
1973
+ * Similarity search with threshold. Operators: >, >=, <, <=, =, !=.
1974
+ * @param {Float32Array} query
1975
+ * @param {number} threshold
1976
+ * @param {string} operator
1977
+ * @param {number} k
1978
+ * @returns {any}
1979
+ */
1980
+ similarity_search(query, threshold, operator, k) {
1981
+ try {
1982
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1983
+ const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
1984
+ const len0 = WASM_VECTOR_LEN;
1985
+ const ptr1 = passStringToWasm0(operator, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1986
+ const len1 = WASM_VECTOR_LEN;
1987
+ wasm.vectorstore_similarity_search(retptr, this.__wbg_ptr, ptr0, len0, threshold, ptr1, len1, k);
1988
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1989
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1990
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1991
+ if (r2) {
1992
+ throw takeObject(r1);
1993
+ }
1994
+ return takeObject(r0);
1995
+ } finally {
1996
+ wasm.__wbindgen_add_to_stack_pointer(16);
1997
+ }
1998
+ }
1999
+ /**
2000
+ * Inserts a sparse vector into the internal sparse index.
2001
+ *
2002
+ * Lazily initializes the sparse index on first call.
2003
+ * @param {bigint} doc_id
2004
+ * @param {Uint32Array} indices
2005
+ * @param {Float32Array} values
2006
+ */
2007
+ sparse_insert(doc_id, indices, values) {
2008
+ try {
2009
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2010
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
2011
+ const len0 = WASM_VECTOR_LEN;
2012
+ const ptr1 = passArrayF32ToWasm0(values, wasm.__wbindgen_export);
2013
+ const len1 = WASM_VECTOR_LEN;
2014
+ wasm.vectorstore_sparse_insert(retptr, this.__wbg_ptr, doc_id, ptr0, len0, ptr1, len1);
2015
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2016
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2017
+ if (r1) {
2018
+ throw takeObject(r0);
2019
+ }
2020
+ } finally {
2021
+ wasm.__wbindgen_add_to_stack_pointer(16);
2022
+ }
2023
+ }
2024
+ /**
2025
+ * Searches the internal sparse index.
2026
+ *
2027
+ * Returns a JSON array of `{doc_id, score}` objects sorted by score descending.
2028
+ * @param {Uint32Array} indices
2029
+ * @param {Float32Array} values
2030
+ * @param {number} k
2031
+ * @returns {any}
2032
+ */
2033
+ sparse_search(indices, values, k) {
2034
+ try {
2035
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2036
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
2037
+ const len0 = WASM_VECTOR_LEN;
2038
+ const ptr1 = passArrayF32ToWasm0(values, wasm.__wbindgen_export);
2039
+ const len1 = WASM_VECTOR_LEN;
2040
+ wasm.vectorstore_sparse_search(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, k);
2041
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2042
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2043
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2044
+ if (r2) {
2045
+ throw takeObject(r1);
2046
+ }
2047
+ return takeObject(r0);
2048
+ } finally {
2049
+ wasm.__wbindgen_add_to_stack_pointer(16);
2050
+ }
2051
+ }
2052
+ /**
2053
+ * Returns the storage mode.
2054
+ * @returns {string}
2055
+ */
2056
+ get storage_mode() {
2057
+ let deferred1_0;
2058
+ let deferred1_1;
2059
+ try {
2060
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2061
+ wasm.vectorstore_storage_mode(retptr, this.__wbg_ptr);
2062
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2063
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2064
+ deferred1_0 = r0;
2065
+ deferred1_1 = r1;
2066
+ return getStringFromWasm0(r0, r1);
2067
+ } finally {
2068
+ wasm.__wbindgen_add_to_stack_pointer(16);
2069
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
2070
+ }
2071
+ }
2072
+ /**
2073
+ * Text search on payload fields (substring matching).
2074
+ * @param {string} query
2075
+ * @param {number} k
2076
+ * @param {string | null} [field]
2077
+ * @returns {any}
2078
+ */
2079
+ text_search(query, k, field) {
2080
+ try {
2081
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2082
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2083
+ const len0 = WASM_VECTOR_LEN;
2084
+ var ptr1 = isLikeNone(field) ? 0 : passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2085
+ var len1 = WASM_VECTOR_LEN;
2086
+ wasm.vectorstore_text_search(retptr, this.__wbg_ptr, ptr0, len0, k, ptr1, len1);
2087
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2088
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2089
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2090
+ if (r2) {
2091
+ throw takeObject(r1);
2092
+ }
2093
+ return takeObject(r0);
2094
+ } finally {
2095
+ wasm.__wbindgen_add_to_stack_pointer(16);
2096
+ }
2097
+ }
2098
+ /**
2099
+ * Creates store with pre-allocated capacity.
2100
+ * @param {number} dimension
2101
+ * @param {string} metric
2102
+ * @param {number} capacity
2103
+ * @returns {VectorStore}
2104
+ */
2105
+ static with_capacity(dimension, metric, capacity) {
2106
+ try {
2107
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2108
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2109
+ const len0 = WASM_VECTOR_LEN;
2110
+ wasm.vectorstore_with_capacity(retptr, dimension, ptr0, len0, capacity);
2111
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2112
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2113
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2114
+ if (r2) {
2115
+ throw takeObject(r1);
2116
+ }
2117
+ return VectorStore.__wrap(r0);
2118
+ } finally {
2119
+ wasm.__wbindgen_add_to_stack_pointer(16);
2120
+ }
2121
+ }
2122
+ }
2123
+ if (Symbol.dispose) VectorStore.prototype[Symbol.dispose] = VectorStore.prototype.free;
2124
+
2125
+ /**
2126
+ * `VelesQL` query parser for browser use.
2127
+ *
2128
+ * # Example (JavaScript)
2129
+ *
2130
+ * ```javascript
2131
+ * import { VelesQL } from 'velesdb-wasm';
2132
+ *
2133
+ * // Parse a query
2134
+ * const parsed = VelesQL.parse("SELECT * FROM docs WHERE category = 'tech' LIMIT 10");
2135
+ * console.log(parsed.tableName); // "docs"
2136
+ * console.log(parsed.isValid); // true
2137
+ *
2138
+ * // Validate without parsing
2139
+ * const valid = VelesQL.isValid("SELECT * FROM docs"); // true
2140
+ * ```
2141
+ */
2142
+ export class VelesQL {
2143
+ __destroy_into_raw() {
2144
+ const ptr = this.__wbg_ptr;
2145
+ this.__wbg_ptr = 0;
2146
+ VelesQLFinalization.unregister(this);
2147
+ return ptr;
2148
+ }
2149
+ free() {
2150
+ const ptr = this.__destroy_into_raw();
2151
+ wasm.__wbg_velesql_free(ptr, 0);
2152
+ }
2153
+ /**
2154
+ * Validate a `VelesQL` query without full parsing.
2155
+ *
2156
+ * This is faster than `parse()` when you only need to check validity.
2157
+ * @param {string} query
2158
+ * @returns {boolean}
2159
+ */
2160
+ static isValid(query) {
2161
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2162
+ const len0 = WASM_VECTOR_LEN;
2163
+ const ret = wasm.velesql_isValid(ptr0, len0);
2164
+ return ret !== 0;
2165
+ }
2166
+ /**
2167
+ * Parse a `VelesQL` query string.
2168
+ *
2169
+ * Returns a `ParsedQuery` object with query introspection methods.
2170
+ * Throws an error if the query has syntax errors.
2171
+ * @param {string} query
2172
+ * @returns {ParsedQuery}
2173
+ */
2174
+ static parse(query) {
2175
+ try {
2176
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2177
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2178
+ const len0 = WASM_VECTOR_LEN;
2179
+ wasm.velesql_parse(retptr, ptr0, len0);
2180
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2181
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2182
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2183
+ if (r2) {
2184
+ throw takeObject(r1);
2185
+ }
2186
+ return ParsedQuery.__wrap(r0);
2187
+ } finally {
2188
+ wasm.__wbindgen_add_to_stack_pointer(16);
2189
+ }
2190
+ }
2191
+ }
2192
+ if (Symbol.dispose) VelesQL.prototype[Symbol.dispose] = VelesQL.prototype.free;
2193
+
2194
+ /**
2195
+ * Estimates the number of nodes that will be visited during traversal.
2196
+ *
2197
+ * Uses a heuristic based on graph density and max depth.
2198
+ * @param {number} node_count
2199
+ * @param {number} edge_count
2200
+ * @param {number} max_depth
2201
+ * @returns {number}
2202
+ */
2203
+ export function estimate_traversal_size(node_count, edge_count, max_depth) {
2204
+ const ret = wasm.estimate_traversal_size(node_count, edge_count, max_depth);
2205
+ return ret >>> 0;
2206
+ }
2207
+
2208
+ /**
2209
+ * Fuses pre-computed dense and sparse search results using Reciprocal Rank Fusion (RRF).
2210
+ *
2211
+ * Both `dense_results` and `sparse_results` should be JSON arrays of `[doc_id, score]` pairs.
2212
+ * Returns a JSON array of `{doc_id, score}` objects, sorted by fused score descending,
2213
+ * truncated to the top `k` entries.
2214
+ * @param {any} dense_results
2215
+ * @param {any} sparse_results
2216
+ * @param {number} rrf_k
2217
+ * @param {number} k
2218
+ * @returns {any}
2219
+ */
2220
+ export function hybrid_search_fuse(dense_results, sparse_results, rrf_k, k) {
2221
+ try {
2222
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2223
+ wasm.hybrid_search_fuse(retptr, addHeapObject(dense_results), addHeapObject(sparse_results), rrf_k, k);
2224
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2225
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2226
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2227
+ if (r2) {
2228
+ throw takeObject(r1);
2229
+ }
2230
+ return takeObject(r0);
2231
+ } finally {
2232
+ wasm.__wbindgen_add_to_stack_pointer(16);
2233
+ }
2234
+ }
2235
+
2236
+ /**
2237
+ * Determines whether a traversal should be offloaded to a Web Worker.
2238
+ *
2239
+ * # Arguments
2240
+ * * `node_count` - Total nodes in the graph
2241
+ * * `max_depth` - Maximum traversal depth requested
2242
+ * * `config` - Optional configuration (uses defaults if None)
2243
+ *
2244
+ * # Returns
2245
+ * `true` if the operation should use a Web Worker
2246
+ * @param {number} node_count
2247
+ * @param {number} max_depth
2248
+ * @param {GraphWorkerConfig | null} [config]
2249
+ * @returns {boolean}
2250
+ */
2251
+ export function should_use_worker(node_count, max_depth, config) {
2252
+ let ptr0 = 0;
2253
+ if (!isLikeNone(config)) {
2254
+ _assertClass(config, GraphWorkerConfig);
2255
+ ptr0 = config.__destroy_into_raw();
2256
+ }
2257
+ const ret = wasm.should_use_worker(node_count, max_depth, ptr0);
2258
+ return ret !== 0;
2259
+ }
2260
+
2261
+ function __wbg_get_imports() {
2262
+ const import0 = {
2263
+ __proto__: null,
2264
+ __wbg_Error_4577686b3a6d9b3a: function(arg0, arg1) {
2265
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2266
+ return addHeapObject(ret);
2267
+ },
2268
+ __wbg_Number_e89e48a2fe1a6355: function(arg0) {
2269
+ const ret = Number(getObject(arg0));
2270
+ return ret;
2271
+ },
2272
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
2273
+ const ret = String(getObject(arg1));
2274
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2275
+ const len1 = WASM_VECTOR_LEN;
2276
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2277
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2278
+ },
2279
+ __wbg___wbindgen_bigint_get_as_i64_578010f8442e0319: function(arg0, arg1) {
2280
+ const v = getObject(arg1);
2281
+ const ret = typeof(v) === 'bigint' ? v : undefined;
2282
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2283
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2284
+ },
2285
+ __wbg___wbindgen_boolean_get_18c4ed9422296fff: function(arg0) {
2286
+ const v = getObject(arg0);
2287
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2288
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2289
+ },
2290
+ __wbg___wbindgen_debug_string_ddde1867f49c2442: function(arg0, arg1) {
2291
+ const ret = debugString(getObject(arg1));
2292
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2293
+ const len1 = WASM_VECTOR_LEN;
2294
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2295
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2296
+ },
2297
+ __wbg___wbindgen_in_1064a108f4d18b9e: function(arg0, arg1) {
2298
+ const ret = getObject(arg0) in getObject(arg1);
2299
+ return ret;
2300
+ },
2301
+ __wbg___wbindgen_is_bigint_a157f0734ca85901: function(arg0) {
2302
+ const ret = typeof(getObject(arg0)) === 'bigint';
2303
+ return ret;
2304
+ },
2305
+ __wbg___wbindgen_is_function_d633e708baf0d146: function(arg0) {
2306
+ const ret = typeof(getObject(arg0)) === 'function';
2307
+ return ret;
2308
+ },
2309
+ __wbg___wbindgen_is_null_a2a19127c13e7126: function(arg0) {
2310
+ const ret = getObject(arg0) === null;
2311
+ return ret;
2312
+ },
2313
+ __wbg___wbindgen_is_object_4b3de556756ee8a8: function(arg0) {
2314
+ const val = getObject(arg0);
2315
+ const ret = typeof(val) === 'object' && val !== null;
2316
+ return ret;
2317
+ },
2318
+ __wbg___wbindgen_is_string_7debe47dc1e045c2: function(arg0) {
2319
+ const ret = typeof(getObject(arg0)) === 'string';
2320
+ return ret;
2321
+ },
2322
+ __wbg___wbindgen_is_undefined_c18285b9fc34cb7d: function(arg0) {
2323
+ const ret = getObject(arg0) === undefined;
2324
+ return ret;
2325
+ },
2326
+ __wbg___wbindgen_jsval_eq_a6afb59d8c5e78d6: function(arg0, arg1) {
2327
+ const ret = getObject(arg0) === getObject(arg1);
2328
+ return ret;
2329
+ },
2330
+ __wbg___wbindgen_jsval_loose_eq_1562ceb9af84e990: function(arg0, arg1) {
2331
+ const ret = getObject(arg0) == getObject(arg1);
2332
+ return ret;
2333
+ },
2334
+ __wbg___wbindgen_number_get_5854912275df1894: function(arg0, arg1) {
2335
+ const obj = getObject(arg1);
2336
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2337
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2338
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2339
+ },
2340
+ __wbg___wbindgen_string_get_3e5751597f39a112: function(arg0, arg1) {
2341
+ const obj = getObject(arg1);
2342
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2343
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2344
+ var len1 = WASM_VECTOR_LEN;
2345
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2346
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2347
+ },
2348
+ __wbg___wbindgen_throw_39bc967c0e5a9b58: function(arg0, arg1) {
2349
+ throw new Error(getStringFromWasm0(arg0, arg1));
2350
+ },
2351
+ __wbg__wbg_cb_unref_b6d832240a919168: function(arg0) {
2352
+ getObject(arg0)._wbg_cb_unref();
2353
+ },
2354
+ __wbg_bound_6f6f52afeaa26de6: function() { return handleError(function (arg0, arg1) {
2355
+ const ret = IDBKeyRange.bound(getObject(arg0), getObject(arg1));
2356
+ return addHeapObject(ret);
2357
+ }, arguments); },
2358
+ __wbg_call_08ad0d89caa7cb79: function() { return handleError(function (arg0, arg1, arg2) {
2359
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2360
+ return addHeapObject(ret);
2361
+ }, arguments); },
2362
+ __wbg_call_73af281463ec8b58: function() { return handleError(function (arg0, arg1) {
2363
+ const ret = getObject(arg0).call(getObject(arg1));
2364
+ return addHeapObject(ret);
2365
+ }, arguments); },
2366
+ __wbg_createObjectStore_bfd875621f13f126: function() { return handleError(function (arg0, arg1, arg2) {
2367
+ const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
2368
+ return addHeapObject(ret);
2369
+ }, arguments); },
2370
+ __wbg_deleteDatabase_14dffbeb78d18245: function() { return handleError(function (arg0, arg1, arg2) {
2371
+ const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
2372
+ return addHeapObject(ret);
2373
+ }, arguments); },
2374
+ __wbg_delete_86cbf50563ab0bd6: function() { return handleError(function (arg0, arg1) {
2375
+ const ret = getObject(arg0).delete(getObject(arg1));
2376
+ return addHeapObject(ret);
2377
+ }, arguments); },
2378
+ __wbg_done_5aad55ec6b1954b1: function(arg0) {
2379
+ const ret = getObject(arg0).done;
2380
+ return ret;
2381
+ },
2382
+ __wbg_entries_28d32ba4cd93f5fc: function(arg0) {
2383
+ const ret = Object.entries(getObject(arg0));
2384
+ return addHeapObject(ret);
2385
+ },
2386
+ __wbg_error_b8445866f700df1c: function(arg0, arg1) {
2387
+ console.error(getObject(arg0), getObject(arg1));
2388
+ },
2389
+ __wbg_getAllKeys_65895da3d083228b: function() { return handleError(function (arg0) {
2390
+ const ret = getObject(arg0).getAllKeys();
2391
+ return addHeapObject(ret);
2392
+ }, arguments); },
2393
+ __wbg_getAll_dbbb20886b9a441e: function() { return handleError(function (arg0, arg1) {
2394
+ const ret = getObject(arg0).getAll(getObject(arg1));
2395
+ return addHeapObject(ret);
2396
+ }, arguments); },
2397
+ __wbg_get_487b8166caa6bea1: function(arg0, arg1, arg2) {
2398
+ const ret = getObject(arg1)[arg2 >>> 0];
2399
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2400
+ var len1 = WASM_VECTOR_LEN;
2401
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2402
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2403
+ },
2404
+ __wbg_get_4920fefd3451364b: function() { return handleError(function (arg0, arg1) {
2405
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2406
+ return addHeapObject(ret);
2407
+ }, arguments); },
2408
+ __wbg_get_791b26b41a7de3d5: function() { return handleError(function (arg0, arg1) {
2409
+ const ret = getObject(arg0).get(getObject(arg1));
2410
+ return addHeapObject(ret);
2411
+ }, arguments); },
2412
+ __wbg_get_f09c3a16f8848381: function(arg0, arg1) {
2413
+ const ret = getObject(arg0)[arg1 >>> 0];
2414
+ return addHeapObject(ret);
2415
+ },
2416
+ __wbg_get_unchecked_3d0f4b91c8eca4f0: function(arg0, arg1) {
2417
+ const ret = getObject(arg0)[arg1 >>> 0];
2418
+ return addHeapObject(ret);
2419
+ },
2420
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
2421
+ const ret = getObject(arg0)[getObject(arg1)];
2422
+ return addHeapObject(ret);
2423
+ },
2424
+ __wbg_graphedge_new: function(arg0) {
2425
+ const ret = GraphEdge.__wrap(arg0);
2426
+ return addHeapObject(ret);
2427
+ },
2428
+ __wbg_graphnode_new: function(arg0) {
2429
+ const ret = GraphNode.__wrap(arg0);
2430
+ return addHeapObject(ret);
2431
+ },
2432
+ __wbg_graphstore_new: function(arg0) {
2433
+ const ret = GraphStore.__wrap(arg0);
2434
+ return addHeapObject(ret);
2435
+ },
2436
+ __wbg_indexedDB_f950945d950fbd5e: function() { return handleError(function (arg0) {
2437
+ const ret = getObject(arg0).indexedDB;
2438
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2439
+ }, arguments); },
2440
+ __wbg_instanceof_ArrayBuffer_15859862b80b732d: function(arg0) {
2441
+ let result;
2442
+ try {
2443
+ result = getObject(arg0) instanceof ArrayBuffer;
2444
+ } catch (_) {
2445
+ result = false;
2446
+ }
2447
+ const ret = result;
2448
+ return ret;
2449
+ },
2450
+ __wbg_instanceof_Map_9df16bf25ceb4ecb: function(arg0) {
2451
+ let result;
2452
+ try {
2453
+ result = getObject(arg0) instanceof Map;
2454
+ } catch (_) {
2455
+ result = false;
2456
+ }
2457
+ const ret = result;
2458
+ return ret;
2459
+ },
2460
+ __wbg_instanceof_Uint8Array_2240b7046ac16f05: function(arg0) {
2461
+ let result;
2462
+ try {
2463
+ result = getObject(arg0) instanceof Uint8Array;
2464
+ } catch (_) {
2465
+ result = false;
2466
+ }
2467
+ const ret = result;
2468
+ return ret;
2469
+ },
2470
+ __wbg_instanceof_Window_4aba49e4d1a12365: function(arg0) {
2471
+ let result;
2472
+ try {
2473
+ result = getObject(arg0) instanceof Window;
2474
+ } catch (_) {
2475
+ result = false;
2476
+ }
2477
+ const ret = result;
2478
+ return ret;
2479
+ },
2480
+ __wbg_isArray_fad08a0d12828686: function(arg0) {
2481
+ const ret = Array.isArray(getObject(arg0));
2482
+ return ret;
2483
+ },
2484
+ __wbg_isSafeInteger_10e4151eb694e42a: function(arg0) {
2485
+ const ret = Number.isSafeInteger(getObject(arg0));
2486
+ return ret;
2487
+ },
2488
+ __wbg_iterator_fc7ad8d33bab9e26: function() {
2489
+ const ret = Symbol.iterator;
2490
+ return addHeapObject(ret);
2491
+ },
2492
+ __wbg_length_5855c1f289dfffc1: function(arg0) {
2493
+ const ret = getObject(arg0).length;
2494
+ return ret;
2495
+ },
2496
+ __wbg_length_a31e05262e09b7f8: function(arg0) {
2497
+ const ret = getObject(arg0).length;
2498
+ return ret;
2499
+ },
2500
+ __wbg_length_fbd9fbbcd74a4420: function(arg0) {
2501
+ const ret = getObject(arg0).length;
2502
+ return ret;
2503
+ },
2504
+ __wbg_new_09959f7b4c92c246: function(arg0) {
2505
+ const ret = new Uint8Array(getObject(arg0));
2506
+ return addHeapObject(ret);
2507
+ },
2508
+ __wbg_new_79ce7968119cfd96: function(arg0, arg1) {
2509
+ try {
2510
+ var state0 = {a: arg0, b: arg1};
2511
+ var cb0 = (arg0, arg1) => {
2512
+ const a = state0.a;
2513
+ state0.a = 0;
2514
+ try {
2515
+ return __wasm_bindgen_func_elem_1327(a, state0.b, arg0, arg1);
2516
+ } finally {
2517
+ state0.a = a;
2518
+ }
2519
+ };
2520
+ const ret = new Promise(cb0);
2521
+ return addHeapObject(ret);
2522
+ } finally {
2523
+ state0.a = state0.b = 0;
2524
+ }
2525
+ },
2526
+ __wbg_new_92df58a8ec3bfb6b: function() {
2527
+ const ret = new Map();
2528
+ return addHeapObject(ret);
2529
+ },
2530
+ __wbg_new_cbee8c0d5c479eac: function() {
2531
+ const ret = new Array();
2532
+ return addHeapObject(ret);
2533
+ },
2534
+ __wbg_new_ed69e637b553a997: function() {
2535
+ const ret = new Object();
2536
+ return addHeapObject(ret);
2537
+ },
2538
+ __wbg_new_from_slice_d7e202fdbee3c396: function(arg0, arg1) {
2539
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2540
+ return addHeapObject(ret);
2541
+ },
2542
+ __wbg_new_typed_8258a0d8488ef2a2: function(arg0, arg1) {
2543
+ try {
2544
+ var state0 = {a: arg0, b: arg1};
2545
+ var cb0 = (arg0, arg1) => {
2546
+ const a = state0.a;
2547
+ state0.a = 0;
2548
+ try {
2549
+ return __wasm_bindgen_func_elem_1327(a, state0.b, arg0, arg1);
2550
+ } finally {
2551
+ state0.a = a;
2552
+ }
2553
+ };
2554
+ const ret = new Promise(cb0);
2555
+ return addHeapObject(ret);
2556
+ } finally {
2557
+ state0.a = state0.b = 0;
2558
+ }
2559
+ },
2560
+ __wbg_next_a5fe6f328f7affc2: function(arg0) {
2561
+ const ret = getObject(arg0).next;
2562
+ return addHeapObject(ret);
2563
+ },
2564
+ __wbg_next_e592122bb4ed4c67: function() { return handleError(function (arg0) {
2565
+ const ret = getObject(arg0).next();
2566
+ return addHeapObject(ret);
2567
+ }, arguments); },
2568
+ __wbg_now_edd718b3004d8631: function() {
2569
+ const ret = Date.now();
2570
+ return ret;
2571
+ },
2572
+ __wbg_objectStoreNames_3645b6da2d1f3852: function(arg0) {
2573
+ const ret = getObject(arg0).objectStoreNames;
2574
+ return addHeapObject(ret);
2575
+ },
2576
+ __wbg_objectStore_3a6b969b917c6262: function() { return handleError(function (arg0, arg1, arg2) {
2577
+ const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
2578
+ return addHeapObject(ret);
2579
+ }, arguments); },
2580
+ __wbg_open_9badd3c8846fbf11: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2581
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
2582
+ return addHeapObject(ret);
2583
+ }, arguments); },
2584
+ __wbg_open_c2bd4b4a6be9d67b: function() { return handleError(function (arg0, arg1, arg2) {
2585
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
2586
+ return addHeapObject(ret);
2587
+ }, arguments); },
2588
+ __wbg_prototypesetcall_f034d444741426c3: function(arg0, arg1, arg2) {
2589
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2590
+ },
2591
+ __wbg_push_a6f9488ffd3fae3b: function(arg0, arg1) {
2592
+ const ret = getObject(arg0).push(getObject(arg1));
2593
+ return ret;
2594
+ },
2595
+ __wbg_put_d86a6833e14a4c3b: function() { return handleError(function (arg0, arg1, arg2) {
2596
+ const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
2597
+ return addHeapObject(ret);
2598
+ }, arguments); },
2599
+ __wbg_queueMicrotask_2c8dfd1056f24fdc: function(arg0) {
2600
+ const ret = getObject(arg0).queueMicrotask;
2601
+ return addHeapObject(ret);
2602
+ },
2603
+ __wbg_queueMicrotask_8985ad63815852e7: function(arg0) {
2604
+ queueMicrotask(getObject(arg0));
2605
+ },
2606
+ __wbg_resolve_5d61e0d10c14730a: function(arg0) {
2607
+ const ret = Promise.resolve(getObject(arg0));
2608
+ return addHeapObject(ret);
2609
+ },
2610
+ __wbg_result_aaba1e6bbc5d42c8: function() { return handleError(function (arg0) {
2611
+ const ret = getObject(arg0).result;
2612
+ return addHeapObject(ret);
2613
+ }, arguments); },
2614
+ __wbg_set_4c81cfb5dc3a333c: function(arg0, arg1, arg2) {
2615
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2616
+ },
2617
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
2618
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2619
+ },
2620
+ __wbg_set_cfc6de03f990decf: function(arg0, arg1, arg2) {
2621
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2622
+ return addHeapObject(ret);
2623
+ },
2624
+ __wbg_set_onerror_8b43a0b08de76f6d: function(arg0, arg1) {
2625
+ getObject(arg0).onerror = getObject(arg1);
2626
+ },
2627
+ __wbg_set_onsuccess_76214f5146684855: function(arg0, arg1) {
2628
+ getObject(arg0).onsuccess = getObject(arg1);
2629
+ },
2630
+ __wbg_set_onupgradeneeded_74f1c8e9dbd2b70c: function(arg0, arg1) {
2631
+ getObject(arg0).onupgradeneeded = getObject(arg1);
2632
+ },
2633
+ __wbg_static_accessor_GLOBAL_THIS_14325d8cca34bb77: function() {
2634
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2635
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2636
+ },
2637
+ __wbg_static_accessor_GLOBAL_f3a1e69f9c5a7e8e: function() {
2638
+ const ret = typeof global === 'undefined' ? null : global;
2639
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2640
+ },
2641
+ __wbg_static_accessor_SELF_50cdb5b517789aca: function() {
2642
+ const ret = typeof self === 'undefined' ? null : self;
2643
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2644
+ },
2645
+ __wbg_static_accessor_WINDOW_d6c4126e4c244380: function() {
2646
+ const ret = typeof window === 'undefined' ? null : window;
2647
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2648
+ },
2649
+ __wbg_then_d4163530723f56f4: function(arg0, arg1, arg2) {
2650
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
2651
+ return addHeapObject(ret);
2652
+ },
2653
+ __wbg_then_f1c954fe00733701: function(arg0, arg1) {
2654
+ const ret = getObject(arg0).then(getObject(arg1));
2655
+ return addHeapObject(ret);
2656
+ },
2657
+ __wbg_transaction_30dda0e59a945fe4: function() { return handleError(function (arg0, arg1, arg2) {
2658
+ const ret = getObject(arg0).transaction(getObject(arg1), __wbindgen_enum_IdbTransactionMode[arg2]);
2659
+ return addHeapObject(ret);
2660
+ }, arguments); },
2661
+ __wbg_transaction_8555c5d00a94c767: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2662
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
2663
+ return addHeapObject(ret);
2664
+ }, arguments); },
2665
+ __wbg_transaction_d40b35a1d301d310: function() { return handleError(function (arg0, arg1) {
2666
+ const ret = getObject(arg0).transaction(getObject(arg1));
2667
+ return addHeapObject(ret);
2668
+ }, arguments); },
2669
+ __wbg_transaction_f90e157c0cdb0001: function() { return handleError(function (arg0, arg1, arg2) {
2670
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2));
2671
+ return addHeapObject(ret);
2672
+ }, arguments); },
2673
+ __wbg_value_667dcb90597486a6: function(arg0) {
2674
+ const ret = getObject(arg0).value;
2675
+ return addHeapObject(ret);
2676
+ },
2677
+ __wbg_vectorstore_new: function(arg0) {
2678
+ const ret = VectorStore.__wrap(arg0);
2679
+ return addHeapObject(ret);
2680
+ },
2681
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2682
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 136, function: Function { arguments: [Externref], shim_idx: 137, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2683
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1295, __wasm_bindgen_func_elem_1296);
2684
+ return addHeapObject(ret);
2685
+ },
2686
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2687
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 9, function: Function { arguments: [NamedExternref("Event")], shim_idx: 10, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2688
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_284, __wasm_bindgen_func_elem_285);
2689
+ return addHeapObject(ret);
2690
+ },
2691
+ __wbindgen_cast_0000000000000003: function(arg0) {
2692
+ // Cast intrinsic for `F64 -> Externref`.
2693
+ const ret = arg0;
2694
+ return addHeapObject(ret);
2695
+ },
2696
+ __wbindgen_cast_0000000000000004: function(arg0) {
2697
+ // Cast intrinsic for `I64 -> Externref`.
2698
+ const ret = arg0;
2699
+ return addHeapObject(ret);
2700
+ },
2701
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
2702
+ // Cast intrinsic for `Ref(String) -> Externref`.
2703
+ const ret = getStringFromWasm0(arg0, arg1);
2704
+ return addHeapObject(ret);
2705
+ },
2706
+ __wbindgen_cast_0000000000000006: function(arg0) {
2707
+ // Cast intrinsic for `U64 -> Externref`.
2708
+ const ret = BigInt.asUintN(64, arg0);
2709
+ return addHeapObject(ret);
2710
+ },
2711
+ __wbindgen_object_clone_ref: function(arg0) {
2712
+ const ret = getObject(arg0);
2713
+ return addHeapObject(ret);
2714
+ },
2715
+ __wbindgen_object_drop_ref: function(arg0) {
2716
+ takeObject(arg0);
2717
+ },
2718
+ };
2719
+ return {
2720
+ __proto__: null,
2721
+ "./velesdb_wasm_bg.js": import0,
2722
+ };
2723
+ }
2724
+
2725
+ function __wasm_bindgen_func_elem_285(arg0, arg1, arg2) {
2726
+ wasm.__wasm_bindgen_func_elem_285(arg0, arg1, addHeapObject(arg2));
2727
+ }
2728
+
2729
+ function __wasm_bindgen_func_elem_1296(arg0, arg1, arg2) {
2730
+ try {
2731
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2732
+ wasm.__wasm_bindgen_func_elem_1296(retptr, arg0, arg1, addHeapObject(arg2));
2733
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2734
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2735
+ if (r1) {
2736
+ throw takeObject(r0);
2737
+ }
2738
+ } finally {
2739
+ wasm.__wbindgen_add_to_stack_pointer(16);
2740
+ }
2741
+ }
2742
+
2743
+ function __wasm_bindgen_func_elem_1327(arg0, arg1, arg2, arg3) {
2744
+ wasm.__wasm_bindgen_func_elem_1327(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2745
+ }
2746
+
2747
+
2748
+ const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
2749
+ const GraphEdgeFinalization = (typeof FinalizationRegistry === 'undefined')
2750
+ ? { register: () => {}, unregister: () => {} }
2751
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphedge_free(ptr >>> 0, 1));
2752
+ const GraphNodeFinalization = (typeof FinalizationRegistry === 'undefined')
2753
+ ? { register: () => {}, unregister: () => {} }
2754
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphnode_free(ptr >>> 0, 1));
2755
+ const GraphPersistenceFinalization = (typeof FinalizationRegistry === 'undefined')
2756
+ ? { register: () => {}, unregister: () => {} }
2757
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphpersistence_free(ptr >>> 0, 1));
2758
+ const GraphStoreFinalization = (typeof FinalizationRegistry === 'undefined')
2759
+ ? { register: () => {}, unregister: () => {} }
2760
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphstore_free(ptr >>> 0, 1));
2761
+ const GraphWorkerConfigFinalization = (typeof FinalizationRegistry === 'undefined')
2762
+ ? { register: () => {}, unregister: () => {} }
2763
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphworkerconfig_free(ptr >>> 0, 1));
2764
+ const ParsedQueryFinalization = (typeof FinalizationRegistry === 'undefined')
2765
+ ? { register: () => {}, unregister: () => {} }
2766
+ : new FinalizationRegistry(ptr => wasm.__wbg_parsedquery_free(ptr >>> 0, 1));
2767
+ const SemanticMemoryFinalization = (typeof FinalizationRegistry === 'undefined')
2768
+ ? { register: () => {}, unregister: () => {} }
2769
+ : new FinalizationRegistry(ptr => wasm.__wbg_semanticmemory_free(ptr >>> 0, 1));
2770
+ const SparseIndexFinalization = (typeof FinalizationRegistry === 'undefined')
2771
+ ? { register: () => {}, unregister: () => {} }
2772
+ : new FinalizationRegistry(ptr => wasm.__wbg_sparseindex_free(ptr >>> 0, 1));
2773
+ const TraversalProgressFinalization = (typeof FinalizationRegistry === 'undefined')
2774
+ ? { register: () => {}, unregister: () => {} }
2775
+ : new FinalizationRegistry(ptr => wasm.__wbg_traversalprogress_free(ptr >>> 0, 1));
2776
+ const VectorStoreFinalization = (typeof FinalizationRegistry === 'undefined')
2777
+ ? { register: () => {}, unregister: () => {} }
2778
+ : new FinalizationRegistry(ptr => wasm.__wbg_vectorstore_free(ptr >>> 0, 1));
2779
+ const VelesQLFinalization = (typeof FinalizationRegistry === 'undefined')
2780
+ ? { register: () => {}, unregister: () => {} }
2781
+ : new FinalizationRegistry(ptr => wasm.__wbg_velesql_free(ptr >>> 0, 1));
2782
+
2783
+ function addHeapObject(obj) {
2784
+ if (heap_next === heap.length) heap.push(heap.length + 1);
2785
+ const idx = heap_next;
2786
+ heap_next = heap[idx];
2787
+
2788
+ heap[idx] = obj;
2789
+ return idx;
2790
+ }
2791
+
2792
+ function _assertClass(instance, klass) {
2793
+ if (!(instance instanceof klass)) {
2794
+ throw new Error(`expected instance of ${klass.name}`);
2795
+ }
2796
+ }
2797
+
2798
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
2799
+ ? { register: () => {}, unregister: () => {} }
2800
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
2801
+
2802
+ function debugString(val) {
2803
+ // primitive types
2804
+ const type = typeof val;
2805
+ if (type == 'number' || type == 'boolean' || val == null) {
2806
+ return `${val}`;
2807
+ }
2808
+ if (type == 'string') {
2809
+ return `"${val}"`;
2810
+ }
2811
+ if (type == 'symbol') {
2812
+ const description = val.description;
2813
+ if (description == null) {
2814
+ return 'Symbol';
2815
+ } else {
2816
+ return `Symbol(${description})`;
2817
+ }
2818
+ }
2819
+ if (type == 'function') {
2820
+ const name = val.name;
2821
+ if (typeof name == 'string' && name.length > 0) {
2822
+ return `Function(${name})`;
2823
+ } else {
2824
+ return 'Function';
2825
+ }
2826
+ }
2827
+ // objects
2828
+ if (Array.isArray(val)) {
2829
+ const length = val.length;
2830
+ let debug = '[';
2831
+ if (length > 0) {
2832
+ debug += debugString(val[0]);
2833
+ }
2834
+ for(let i = 1; i < length; i++) {
2835
+ debug += ', ' + debugString(val[i]);
2836
+ }
2837
+ debug += ']';
2838
+ return debug;
2839
+ }
2840
+ // Test for built-in
2841
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2842
+ let className;
2843
+ if (builtInMatches && builtInMatches.length > 1) {
2844
+ className = builtInMatches[1];
2845
+ } else {
2846
+ // Failed to match the standard '[object ClassName]'
2847
+ return toString.call(val);
2848
+ }
2849
+ if (className == 'Object') {
2850
+ // we're a user defined class or Object
2851
+ // JSON.stringify avoids problems with cycles, and is generally much
2852
+ // easier than looping through ownProperties of `val`.
2853
+ try {
2854
+ return 'Object(' + JSON.stringify(val) + ')';
2855
+ } catch (_) {
2856
+ return 'Object';
2857
+ }
2858
+ }
2859
+ // errors
2860
+ if (val instanceof Error) {
2861
+ return `${val.name}: ${val.message}\n${val.stack}`;
2862
+ }
2863
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2864
+ return className;
2865
+ }
2866
+
2867
+ function dropObject(idx) {
2868
+ if (idx < 1028) return;
2869
+ heap[idx] = heap_next;
2870
+ heap_next = idx;
2871
+ }
2872
+
2873
+ function getArrayJsValueFromWasm0(ptr, len) {
2874
+ ptr = ptr >>> 0;
2875
+ const mem = getDataViewMemory0();
2876
+ const result = [];
2877
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
2878
+ result.push(takeObject(mem.getUint32(i, true)));
2879
+ }
2880
+ return result;
2881
+ }
2882
+
2883
+ function getArrayU64FromWasm0(ptr, len) {
2884
+ ptr = ptr >>> 0;
2885
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
2886
+ }
2887
+
2888
+ function getArrayU8FromWasm0(ptr, len) {
2889
+ ptr = ptr >>> 0;
2890
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2891
+ }
2892
+
2893
+ let cachedBigUint64ArrayMemory0 = null;
2894
+ function getBigUint64ArrayMemory0() {
2895
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
2896
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
2897
+ }
2898
+ return cachedBigUint64ArrayMemory0;
2899
+ }
2900
+
2901
+ let cachedDataViewMemory0 = null;
2902
+ function getDataViewMemory0() {
2903
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2904
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2905
+ }
2906
+ return cachedDataViewMemory0;
2907
+ }
2908
+
2909
+ let cachedFloat32ArrayMemory0 = null;
2910
+ function getFloat32ArrayMemory0() {
2911
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
2912
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
2913
+ }
2914
+ return cachedFloat32ArrayMemory0;
2915
+ }
2916
+
2917
+ function getStringFromWasm0(ptr, len) {
2918
+ ptr = ptr >>> 0;
2919
+ return decodeText(ptr, len);
2920
+ }
2921
+
2922
+ let cachedUint32ArrayMemory0 = null;
2923
+ function getUint32ArrayMemory0() {
2924
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2925
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2926
+ }
2927
+ return cachedUint32ArrayMemory0;
2928
+ }
2929
+
2930
+ let cachedUint8ArrayMemory0 = null;
2931
+ function getUint8ArrayMemory0() {
2932
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2933
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2934
+ }
2935
+ return cachedUint8ArrayMemory0;
2936
+ }
2937
+
2938
+ function getObject(idx) { return heap[idx]; }
2939
+
2940
+ function handleError(f, args) {
2941
+ try {
2942
+ return f.apply(this, args);
2943
+ } catch (e) {
2944
+ wasm.__wbindgen_export3(addHeapObject(e));
2945
+ }
2946
+ }
2947
+
2948
+ let heap = new Array(1024).fill(undefined);
2949
+ heap.push(undefined, null, true, false);
2950
+
2951
+ let heap_next = heap.length;
2952
+
2953
+ function isLikeNone(x) {
2954
+ return x === undefined || x === null;
2955
+ }
2956
+
2957
+ function makeMutClosure(arg0, arg1, dtor, f) {
2958
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
2959
+ const real = (...args) => {
2960
+
2961
+ // First up with a closure we increment the internal reference
2962
+ // count. This ensures that the Rust closure environment won't
2963
+ // be deallocated while we're invoking it.
2964
+ state.cnt++;
2965
+ const a = state.a;
2966
+ state.a = 0;
2967
+ try {
2968
+ return f(a, state.b, ...args);
2969
+ } finally {
2970
+ state.a = a;
2971
+ real._wbg_cb_unref();
2972
+ }
2973
+ };
2974
+ real._wbg_cb_unref = () => {
2975
+ if (--state.cnt === 0) {
2976
+ state.dtor(state.a, state.b);
2977
+ state.a = 0;
2978
+ CLOSURE_DTORS.unregister(state);
1495
2979
  }
2980
+ };
2981
+ CLOSURE_DTORS.register(real, state, state);
2982
+ return real;
2983
+ }
2984
+
2985
+ function passArray32ToWasm0(arg, malloc) {
2986
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
2987
+ getUint32ArrayMemory0().set(arg, ptr / 4);
2988
+ WASM_VECTOR_LEN = arg.length;
2989
+ return ptr;
2990
+ }
2991
+
2992
+ function passArray8ToWasm0(arg, malloc) {
2993
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
2994
+ getUint8ArrayMemory0().set(arg, ptr / 1);
2995
+ WASM_VECTOR_LEN = arg.length;
2996
+ return ptr;
2997
+ }
2998
+
2999
+ function passArrayF32ToWasm0(arg, malloc) {
3000
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
3001
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
3002
+ WASM_VECTOR_LEN = arg.length;
3003
+ return ptr;
3004
+ }
3005
+
3006
+ function passStringToWasm0(arg, malloc, realloc) {
3007
+ if (realloc === undefined) {
3008
+ const buf = cachedTextEncoder.encode(arg);
3009
+ const ptr = malloc(buf.length, 1) >>> 0;
3010
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
3011
+ WASM_VECTOR_LEN = buf.length;
3012
+ return ptr;
1496
3013
  }
1497
- /**
1498
- * Pre-allocates memory for additional vectors.
1499
- * @param {number} additional
1500
- */
1501
- reserve(additional) {
1502
- wasm.vectorstore_reserve(this.__wbg_ptr, additional);
3014
+
3015
+ let len = arg.length;
3016
+ let ptr = malloc(len, 1) >>> 0;
3017
+
3018
+ const mem = getUint8ArrayMemory0();
3019
+
3020
+ let offset = 0;
3021
+
3022
+ for (; offset < len; offset++) {
3023
+ const code = arg.charCodeAt(offset);
3024
+ if (code > 0x7F) break;
3025
+ mem[ptr + offset] = code;
1503
3026
  }
1504
- /**
1505
- * Returns true if the store is empty.
1506
- * @returns {boolean}
1507
- */
1508
- get is_empty() {
1509
- const ret = wasm.vectorstore_is_empty(this.__wbg_ptr);
1510
- return ret !== 0;
3027
+ if (offset !== len) {
3028
+ if (offset !== 0) {
3029
+ arg = arg.slice(offset);
3030
+ }
3031
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
3032
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
3033
+ const ret = cachedTextEncoder.encodeInto(arg, view);
3034
+
3035
+ offset += ret.written;
3036
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1511
3037
  }
1512
- /**
1513
- * Returns the vector dimension.
1514
- * @returns {number}
1515
- */
1516
- get dimension() {
1517
- const ret = wasm.vectorstore_dimension(this.__wbg_ptr);
1518
- return ret >>> 0;
3038
+
3039
+ WASM_VECTOR_LEN = offset;
3040
+ return ptr;
3041
+ }
3042
+
3043
+ function takeObject(idx) {
3044
+ const ret = getObject(idx);
3045
+ dropObject(idx);
3046
+ return ret;
3047
+ }
3048
+
3049
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3050
+ cachedTextDecoder.decode();
3051
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
3052
+ let numBytesDecoded = 0;
3053
+ function decodeText(ptr, len) {
3054
+ numBytesDecoded += len;
3055
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
3056
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3057
+ cachedTextDecoder.decode();
3058
+ numBytesDecoded = len;
1519
3059
  }
3060
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1520
3061
  }
1521
- if (Symbol.dispose) VectorStore.prototype[Symbol.dispose] = VectorStore.prototype.free;
1522
3062
 
1523
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
3063
+ const cachedTextEncoder = new TextEncoder();
3064
+
3065
+ if (!('encodeInto' in cachedTextEncoder)) {
3066
+ cachedTextEncoder.encodeInto = function (arg, view) {
3067
+ const buf = cachedTextEncoder.encode(arg);
3068
+ view.set(buf);
3069
+ return {
3070
+ read: arg.length,
3071
+ written: buf.length
3072
+ };
3073
+ };
3074
+ }
3075
+
3076
+ let WASM_VECTOR_LEN = 0;
3077
+
3078
+ let wasmModule, wasm;
3079
+ function __wbg_finalize_init(instance, module) {
3080
+ wasm = instance.exports;
3081
+ wasmModule = module;
3082
+ cachedBigUint64ArrayMemory0 = null;
3083
+ cachedDataViewMemory0 = null;
3084
+ cachedFloat32ArrayMemory0 = null;
3085
+ cachedUint32ArrayMemory0 = null;
3086
+ cachedUint8ArrayMemory0 = null;
3087
+ return wasm;
3088
+ }
1524
3089
 
1525
3090
  async function __wbg_load(module, imports) {
1526
3091
  if (typeof Response === 'function' && module instanceof Response) {
@@ -1528,14 +3093,12 @@ async function __wbg_load(module, imports) {
1528
3093
  try {
1529
3094
  return await WebAssembly.instantiateStreaming(module, imports);
1530
3095
  } catch (e) {
1531
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
3096
+ const validResponse = module.ok && expectedResponseType(module.type);
1532
3097
 
1533
3098
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1534
3099
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1535
3100
 
1536
- } else {
1537
- throw e;
1538
- }
3101
+ } else { throw e; }
1539
3102
  }
1540
3103
  }
1541
3104
 
@@ -1550,418 +3113,20 @@ async function __wbg_load(module, imports) {
1550
3113
  return instance;
1551
3114
  }
1552
3115
  }
1553
- }
1554
3116
 
1555
- function __wbg_get_imports() {
1556
- const imports = {};
1557
- imports.wbg = {};
1558
- imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
1559
- const ret = Error(getStringFromWasm0(arg0, arg1));
1560
- return addHeapObject(ret);
1561
- };
1562
- imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
1563
- const ret = Number(getObject(arg0));
1564
- return ret;
1565
- };
1566
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
1567
- const ret = String(getObject(arg1));
1568
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1569
- const len1 = WASM_VECTOR_LEN;
1570
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1571
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1572
- };
1573
- imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
1574
- const v = getObject(arg1);
1575
- const ret = typeof(v) === 'bigint' ? v : undefined;
1576
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1577
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1578
- };
1579
- imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
1580
- const v = getObject(arg0);
1581
- const ret = typeof(v) === 'boolean' ? v : undefined;
1582
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1583
- };
1584
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
1585
- const ret = debugString(getObject(arg1));
1586
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1587
- const len1 = WASM_VECTOR_LEN;
1588
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1589
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1590
- };
1591
- imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
1592
- const ret = getObject(arg0) in getObject(arg1);
1593
- return ret;
1594
- };
1595
- imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
1596
- const ret = typeof(getObject(arg0)) === 'bigint';
1597
- return ret;
1598
- };
1599
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
1600
- const ret = typeof(getObject(arg0)) === 'function';
1601
- return ret;
1602
- };
1603
- imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
1604
- const ret = getObject(arg0) === null;
1605
- return ret;
1606
- };
1607
- imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
1608
- const val = getObject(arg0);
1609
- const ret = typeof(val) === 'object' && val !== null;
1610
- return ret;
1611
- };
1612
- imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
1613
- const ret = typeof(getObject(arg0)) === 'string';
1614
- return ret;
1615
- };
1616
- imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
1617
- const ret = getObject(arg0) === undefined;
1618
- return ret;
1619
- };
1620
- imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
1621
- const ret = getObject(arg0) === getObject(arg1);
1622
- return ret;
1623
- };
1624
- imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
1625
- const ret = getObject(arg0) == getObject(arg1);
1626
- return ret;
1627
- };
1628
- imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
1629
- const obj = getObject(arg1);
1630
- const ret = typeof(obj) === 'number' ? obj : undefined;
1631
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1632
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1633
- };
1634
- imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
1635
- const obj = getObject(arg1);
1636
- const ret = typeof(obj) === 'string' ? obj : undefined;
1637
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1638
- var len1 = WASM_VECTOR_LEN;
1639
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1640
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1641
- };
1642
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
1643
- throw new Error(getStringFromWasm0(arg0, arg1));
1644
- };
1645
- imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
1646
- getObject(arg0)._wbg_cb_unref();
1647
- };
1648
- imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
1649
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1650
- return addHeapObject(ret);
1651
- }, arguments) };
1652
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
1653
- const ret = getObject(arg0).call(getObject(arg1));
1654
- return addHeapObject(ret);
1655
- }, arguments) };
1656
- imports.wbg.__wbg_createObjectStore_dba64acfe84d4191 = function() { return handleError(function (arg0, arg1, arg2) {
1657
- const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
1658
- return addHeapObject(ret);
1659
- }, arguments) };
1660
- imports.wbg.__wbg_deleteDatabase_19c91a8e3e6b92cf = function() { return handleError(function (arg0, arg1, arg2) {
1661
- const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
1662
- return addHeapObject(ret);
1663
- }, arguments) };
1664
- imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
1665
- const ret = getObject(arg0).done;
1666
- return ret;
1667
- };
1668
- imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
1669
- const ret = Object.entries(getObject(arg0));
1670
- return addHeapObject(ret);
1671
- };
1672
- imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
1673
- const ret = getObject(arg0)[arg1 >>> 0];
1674
- return addHeapObject(ret);
1675
- };
1676
- imports.wbg.__wbg_get_7d8b665fa88606d5 = function() { return handleError(function (arg0, arg1) {
1677
- const ret = getObject(arg0).get(getObject(arg1));
1678
- return addHeapObject(ret);
1679
- }, arguments) };
1680
- imports.wbg.__wbg_get_985f6dca0ce6b776 = function(arg0, arg1, arg2) {
1681
- const ret = getObject(arg1)[arg2 >>> 0];
1682
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1683
- var len1 = WASM_VECTOR_LEN;
1684
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1685
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1686
- };
1687
- imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
1688
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
1689
- return addHeapObject(ret);
1690
- }, arguments) };
1691
- imports.wbg.__wbg_graphedge_new = function(arg0) {
1692
- const ret = GraphEdge.__wrap(arg0);
1693
- return addHeapObject(ret);
1694
- };
1695
- imports.wbg.__wbg_graphnode_new = function(arg0) {
1696
- const ret = GraphNode.__wrap(arg0);
1697
- return addHeapObject(ret);
1698
- };
1699
- imports.wbg.__wbg_indexedDB_23c232e00a1e28ad = function() { return handleError(function (arg0) {
1700
- const ret = getObject(arg0).indexedDB;
1701
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1702
- }, arguments) };
1703
- imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
1704
- let result;
1705
- try {
1706
- result = getObject(arg0) instanceof ArrayBuffer;
1707
- } catch (_) {
1708
- result = false;
1709
- }
1710
- const ret = result;
1711
- return ret;
1712
- };
1713
- imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
1714
- let result;
1715
- try {
1716
- result = getObject(arg0) instanceof Map;
1717
- } catch (_) {
1718
- result = false;
1719
- }
1720
- const ret = result;
1721
- return ret;
1722
- };
1723
- imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
1724
- let result;
1725
- try {
1726
- result = getObject(arg0) instanceof Uint8Array;
1727
- } catch (_) {
1728
- result = false;
1729
- }
1730
- const ret = result;
1731
- return ret;
1732
- };
1733
- imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) {
1734
- let result;
1735
- try {
1736
- result = getObject(arg0) instanceof Window;
1737
- } catch (_) {
1738
- result = false;
1739
- }
1740
- const ret = result;
1741
- return ret;
1742
- };
1743
- imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
1744
- const ret = Array.isArray(getObject(arg0));
1745
- return ret;
1746
- };
1747
- imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
1748
- const ret = Number.isSafeInteger(getObject(arg0));
1749
- return ret;
1750
- };
1751
- imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
1752
- const ret = Symbol.iterator;
1753
- return addHeapObject(ret);
1754
- };
1755
- imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
1756
- const ret = getObject(arg0).length;
1757
- return ret;
1758
- };
1759
- imports.wbg.__wbg_length_9f7c82a979890e31 = function(arg0) {
1760
- const ret = getObject(arg0).length;
1761
- return ret;
1762
- };
1763
- imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
1764
- const ret = getObject(arg0).length;
1765
- return ret;
1766
- };
1767
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
1768
- const ret = new Object();
1769
- return addHeapObject(ret);
1770
- };
1771
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
1772
- const ret = new Array();
1773
- return addHeapObject(ret);
1774
- };
1775
- imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
1776
- const ret = new Uint8Array(getObject(arg0));
1777
- return addHeapObject(ret);
1778
- };
1779
- imports.wbg.__wbg_new_b546ae120718850e = function() {
1780
- const ret = new Map();
1781
- return addHeapObject(ret);
1782
- };
1783
- imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
1784
- try {
1785
- var state0 = {a: arg0, b: arg1};
1786
- var cb0 = (arg0, arg1) => {
1787
- const a = state0.a;
1788
- state0.a = 0;
1789
- try {
1790
- return __wasm_bindgen_func_elem_689(a, state0.b, arg0, arg1);
1791
- } finally {
1792
- state0.a = a;
1793
- }
1794
- };
1795
- const ret = new Promise(cb0);
1796
- return addHeapObject(ret);
1797
- } finally {
1798
- state0.a = state0.b = 0;
3117
+ function expectedResponseType(type) {
3118
+ switch (type) {
3119
+ case 'basic': case 'cors': case 'default': return true;
1799
3120
  }
1800
- };
1801
- imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
1802
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1803
- return addHeapObject(ret);
1804
- };
1805
- imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
1806
- const ret = new Function(getStringFromWasm0(arg0, arg1));
1807
- return addHeapObject(ret);
1808
- };
1809
- imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
1810
- const ret = getObject(arg0).next;
1811
- return addHeapObject(ret);
1812
- };
1813
- imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
1814
- const ret = getObject(arg0).next();
1815
- return addHeapObject(ret);
1816
- }, arguments) };
1817
- imports.wbg.__wbg_objectStoreNames_90900f9a531513ac = function(arg0) {
1818
- const ret = getObject(arg0).objectStoreNames;
1819
- return addHeapObject(ret);
1820
- };
1821
- imports.wbg.__wbg_objectStore_da9a077b8849dbe9 = function() { return handleError(function (arg0, arg1, arg2) {
1822
- const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
1823
- return addHeapObject(ret);
1824
- }, arguments) };
1825
- imports.wbg.__wbg_open_2a2740c93beabe29 = function() { return handleError(function (arg0, arg1, arg2) {
1826
- const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
1827
- return addHeapObject(ret);
1828
- }, arguments) };
1829
- imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
1830
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1831
- };
1832
- imports.wbg.__wbg_put_d40a68e5a8902a46 = function() { return handleError(function (arg0, arg1, arg2) {
1833
- const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
1834
- return addHeapObject(ret);
1835
- }, arguments) };
1836
- imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
1837
- const ret = getObject(arg0).queueMicrotask;
1838
- return addHeapObject(ret);
1839
- };
1840
- imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
1841
- queueMicrotask(getObject(arg0));
1842
- };
1843
- imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
1844
- const ret = Promise.resolve(getObject(arg0));
1845
- return addHeapObject(ret);
1846
- };
1847
- imports.wbg.__wbg_result_084f962aedb54250 = function() { return handleError(function (arg0) {
1848
- const ret = getObject(arg0).result;
1849
- return addHeapObject(ret);
1850
- }, arguments) };
1851
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
1852
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1853
- };
1854
- imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
1855
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1856
- };
1857
- imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
1858
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
1859
- return addHeapObject(ret);
1860
- };
1861
- imports.wbg.__wbg_set_onerror_08fecec3bdc9d24d = function(arg0, arg1) {
1862
- getObject(arg0).onerror = getObject(arg1);
1863
- };
1864
- imports.wbg.__wbg_set_onsuccess_94332a00452de699 = function(arg0, arg1) {
1865
- getObject(arg0).onsuccess = getObject(arg1);
1866
- };
1867
- imports.wbg.__wbg_set_onupgradeneeded_3dc6e233a6d13fe2 = function(arg0, arg1) {
1868
- getObject(arg0).onupgradeneeded = getObject(arg1);
1869
- };
1870
- imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
1871
- const ret = typeof global === 'undefined' ? null : global;
1872
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1873
- };
1874
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
1875
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
1876
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1877
- };
1878
- imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
1879
- const ret = typeof self === 'undefined' ? null : self;
1880
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1881
- };
1882
- imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
1883
- const ret = typeof window === 'undefined' ? null : window;
1884
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1885
- };
1886
- imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
1887
- const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
1888
- return addHeapObject(ret);
1889
- };
1890
- imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
1891
- const ret = getObject(arg0).then(getObject(arg1));
1892
- return addHeapObject(ret);
1893
- };
1894
- imports.wbg.__wbg_transaction_790ec170b8fbc74b = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1895
- const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
1896
- return addHeapObject(ret);
1897
- }, arguments) };
1898
- imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
1899
- const ret = getObject(arg0).value;
1900
- return addHeapObject(ret);
1901
- };
1902
- imports.wbg.__wbg_vectorstore_new = function(arg0) {
1903
- const ret = VectorStore.__wrap(arg0);
1904
- return addHeapObject(ret);
1905
- };
1906
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1907
- // Cast intrinsic for `Ref(String) -> Externref`.
1908
- const ret = getStringFromWasm0(arg0, arg1);
1909
- return addHeapObject(ret);
1910
- };
1911
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1912
- // Cast intrinsic for `U64 -> Externref`.
1913
- const ret = BigInt.asUintN(64, arg0);
1914
- return addHeapObject(ret);
1915
- };
1916
- imports.wbg.__wbindgen_cast_59e89726c7c5a9af = function(arg0, arg1) {
1917
- // Cast intrinsic for `Closure(Closure { dtor_idx: 8, function: Function { arguments: [NamedExternref("Event")], shim_idx: 9, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1918
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_197, __wasm_bindgen_func_elem_198);
1919
- return addHeapObject(ret);
1920
- };
1921
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1922
- // Cast intrinsic for `I64 -> Externref`.
1923
- const ret = arg0;
1924
- return addHeapObject(ret);
1925
- };
1926
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1927
- // Cast intrinsic for `F64 -> Externref`.
1928
- const ret = arg0;
1929
- return addHeapObject(ret);
1930
- };
1931
- imports.wbg.__wbindgen_cast_eecb66c58f878696 = function(arg0, arg1) {
1932
- // Cast intrinsic for `Closure(Closure { dtor_idx: 67, function: Function { arguments: [Externref], shim_idx: 68, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1933
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_639, __wasm_bindgen_func_elem_640);
1934
- return addHeapObject(ret);
1935
- };
1936
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1937
- const ret = getObject(arg0);
1938
- return addHeapObject(ret);
1939
- };
1940
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1941
- takeObject(arg0);
1942
- };
1943
-
1944
- return imports;
1945
- }
1946
-
1947
- function __wbg_finalize_init(instance, module) {
1948
- wasm = instance.exports;
1949
- __wbg_init.__wbindgen_wasm_module = module;
1950
- cachedBigUint64ArrayMemory0 = null;
1951
- cachedDataViewMemory0 = null;
1952
- cachedFloat32ArrayMemory0 = null;
1953
- cachedUint8ArrayMemory0 = null;
1954
-
1955
-
1956
-
1957
- return wasm;
3121
+ return false;
3122
+ }
1958
3123
  }
1959
3124
 
1960
3125
  function initSync(module) {
1961
3126
  if (wasm !== undefined) return wasm;
1962
3127
 
1963
3128
 
1964
- if (typeof module !== 'undefined') {
3129
+ if (module !== undefined) {
1965
3130
  if (Object.getPrototypeOf(module) === Object.prototype) {
1966
3131
  ({module} = module)
1967
3132
  } else {
@@ -1981,7 +3146,7 @@ async function __wbg_init(module_or_path) {
1981
3146
  if (wasm !== undefined) return wasm;
1982
3147
 
1983
3148
 
1984
- if (typeof module_or_path !== 'undefined') {
3149
+ if (module_or_path !== undefined) {
1985
3150
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1986
3151
  ({module_or_path} = module_or_path)
1987
3152
  } else {
@@ -1989,7 +3154,7 @@ async function __wbg_init(module_or_path) {
1989
3154
  }
1990
3155
  }
1991
3156
 
1992
- if (typeof module_or_path === 'undefined') {
3157
+ if (module_or_path === undefined) {
1993
3158
  module_or_path = new URL('velesdb_wasm_bg.wasm', import.meta.url);
1994
3159
  }
1995
3160
  const imports = __wbg_get_imports();
@@ -2003,5 +3168,4 @@ async function __wbg_init(module_or_path) {
2003
3168
  return __wbg_finalize_init(instance, module);
2004
3169
  }
2005
3170
 
2006
- export { initSync };
2007
- export default __wbg_init;
3171
+ export { initSync, __wbg_init as default };