@wiscale/velesdb-wasm 1.4.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,425 +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_265(arg0, arg1, arg2) {
284
- wasm.__wasm_bindgen_func_elem_265(arg0, arg1, addHeapObject(arg2));
285
- }
286
-
287
- function __wasm_bindgen_func_elem_1176(arg0, arg1, arg2) {
288
- wasm.__wasm_bindgen_func_elem_1176(arg0, arg1, addHeapObject(arg2));
289
- }
290
-
291
- function __wasm_bindgen_func_elem_1217(arg0, arg1, arg2, arg3) {
292
- wasm.__wasm_bindgen_func_elem_1217(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 GraphPersistenceFinalization = (typeof FinalizationRegistry === 'undefined')
306
- ? { register: () => {}, unregister: () => {} }
307
- : new FinalizationRegistry(ptr => wasm.__wbg_graphpersistence_free(ptr >>> 0, 1));
308
-
309
- const GraphStoreFinalization = (typeof FinalizationRegistry === 'undefined')
310
- ? { register: () => {}, unregister: () => {} }
311
- : new FinalizationRegistry(ptr => wasm.__wbg_graphstore_free(ptr >>> 0, 1));
312
-
313
- const GraphWorkerConfigFinalization = (typeof FinalizationRegistry === 'undefined')
314
- ? { register: () => {}, unregister: () => {} }
315
- : new FinalizationRegistry(ptr => wasm.__wbg_graphworkerconfig_free(ptr >>> 0, 1));
316
-
317
- const ParsedQueryFinalization = (typeof FinalizationRegistry === 'undefined')
318
- ? { register: () => {}, unregister: () => {} }
319
- : new FinalizationRegistry(ptr => wasm.__wbg_parsedquery_free(ptr >>> 0, 1));
320
-
321
- const SemanticMemoryFinalization = (typeof FinalizationRegistry === 'undefined')
322
- ? { register: () => {}, unregister: () => {} }
323
- : new FinalizationRegistry(ptr => wasm.__wbg_semanticmemory_free(ptr >>> 0, 1));
324
-
325
- const TraversalProgressFinalization = (typeof FinalizationRegistry === 'undefined')
326
- ? { register: () => {}, unregister: () => {} }
327
- : new FinalizationRegistry(ptr => wasm.__wbg_traversalprogress_free(ptr >>> 0, 1));
328
-
329
- const VectorStoreFinalization = (typeof FinalizationRegistry === 'undefined')
330
- ? { register: () => {}, unregister: () => {} }
331
- : new FinalizationRegistry(ptr => wasm.__wbg_vectorstore_free(ptr >>> 0, 1));
332
-
333
- const VelesQLFinalization = (typeof FinalizationRegistry === 'undefined')
334
- ? { register: () => {}, unregister: () => {} }
335
- : new FinalizationRegistry(ptr => wasm.__wbg_velesql_free(ptr >>> 0, 1));
336
-
337
- /**
338
- * A graph edge representing a relationship between nodes.
339
- */
340
- export class GraphEdge {
341
- static __wrap(ptr) {
342
- ptr = ptr >>> 0;
343
- const obj = Object.create(GraphEdge.prototype);
344
- obj.__wbg_ptr = ptr;
345
- GraphEdgeFinalization.register(obj, obj.__wbg_ptr, obj);
346
- return obj;
347
- }
348
- __destroy_into_raw() {
349
- const ptr = this.__wbg_ptr;
350
- this.__wbg_ptr = 0;
351
- GraphEdgeFinalization.unregister(this);
352
- return ptr;
156
+ __destroy_into_raw() {
157
+ const ptr = this.__wbg_ptr;
158
+ this.__wbg_ptr = 0;
159
+ GraphNodeFinalization.unregister(this);
160
+ return ptr;
353
161
  }
354
162
  free() {
355
163
  const ptr = this.__destroy_into_raw();
356
- wasm.__wbg_graphedge_free(ptr, 0);
357
- }
358
- /**
359
- * Sets a numeric property on the edge.
360
- * @param {string} key
361
- * @param {number} value
362
- */
363
- set_number_property(key, value) {
364
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
365
- const len0 = WASM_VECTOR_LEN;
366
- wasm.graphedge_set_number_property(this.__wbg_ptr, ptr0, len0, value);
164
+ wasm.__wbg_graphnode_free(ptr, 0);
367
165
  }
368
166
  /**
369
- * Sets a string property on the edge.
370
- * @param {string} key
371
- * @param {string} value
167
+ * Returns true if this node has a vector embedding.
168
+ * @returns {boolean}
372
169
  */
373
- set_string_property(key, value) {
374
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
375
- const len0 = WASM_VECTOR_LEN;
376
- const ptr1 = passStringToWasm0(value, wasm.__wbindgen_export, wasm.__wbindgen_export2);
377
- const len1 = WASM_VECTOR_LEN;
378
- 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;
379
173
  }
380
174
  /**
381
- * Returns the edge ID.
175
+ * Returns the node ID.
382
176
  * @returns {bigint}
383
177
  */
384
178
  get id() {
385
- const ret = wasm.graphedge_id(this.__wbg_ptr);
179
+ const ret = wasm.graphnode_id(this.__wbg_ptr);
386
180
  return BigInt.asUintN(64, ret);
387
181
  }
388
182
  /**
389
- * Creates a new graph edge.
390
- *
391
- * # Arguments
392
- *
393
- * * `id` - Unique identifier for the edge
394
- * * `source` - Source node ID
395
- * * `target` - Target node ID
396
- * * `label` - Relationship type (e.g., "KNOWS", "WROTE")
397
- * @param {bigint} id
398
- * @param {bigint} source
399
- * @param {bigint} target
400
- * @param {string} label
401
- */
402
- constructor(id, source, target, label) {
403
- try {
404
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
405
- const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
406
- const len0 = WASM_VECTOR_LEN;
407
- wasm.graphedge_new(retptr, id, source, target, ptr0, len0);
408
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
409
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
410
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
411
- if (r2) {
412
- throw takeObject(r1);
413
- }
414
- this.__wbg_ptr = r0 >>> 0;
415
- GraphEdgeFinalization.register(this, this.__wbg_ptr, this);
416
- return this;
417
- } finally {
418
- wasm.__wbindgen_add_to_stack_pointer(16);
419
- }
420
- }
421
- /**
422
- * Returns the edge label (relationship type).
183
+ * Returns the node label.
423
184
  * @returns {string}
424
185
  */
425
186
  get label() {
@@ -427,7 +188,7 @@ export class GraphEdge {
427
188
  let deferred1_1;
428
189
  try {
429
190
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
430
- wasm.graphedge_label(retptr, this.__wbg_ptr);
191
+ wasm.graphnode_label(retptr, this.__wbg_ptr);
431
192
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
432
193
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
433
194
  deferred1_0 = r0;
@@ -439,80 +200,22 @@ export class GraphEdge {
439
200
  }
440
201
  }
441
202
  /**
442
- * Returns the source node ID.
443
- * @returns {bigint}
444
- */
445
- get source() {
446
- const ret = wasm.graphedge_source(this.__wbg_ptr);
447
- return BigInt.asUintN(64, ret);
448
- }
449
- /**
450
- * Returns the target node ID.
451
- * @returns {bigint}
452
- */
453
- get target() {
454
- const ret = wasm.graphedge_target(this.__wbg_ptr);
455
- return BigInt.asUintN(64, ret);
456
- }
457
- /**
458
- * Converts to JSON for JavaScript interop.
459
- * @returns {any}
460
- */
461
- to_json() {
462
- try {
463
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
464
- wasm.graphedge_to_json(retptr, this.__wbg_ptr);
465
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
466
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
467
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
468
- if (r2) {
469
- throw takeObject(r1);
470
- }
471
- return takeObject(r0);
472
- } finally {
473
- wasm.__wbindgen_add_to_stack_pointer(16);
474
- }
475
- }
476
- }
477
- if (Symbol.dispose) GraphEdge.prototype[Symbol.dispose] = GraphEdge.prototype.free;
478
-
479
- /**
480
- * A graph node for knowledge graph construction.
481
- */
482
- export class GraphNode {
483
- static __wrap(ptr) {
484
- ptr = ptr >>> 0;
485
- const obj = Object.create(GraphNode.prototype);
486
- obj.__wbg_ptr = ptr;
487
- GraphNodeFinalization.register(obj, obj.__wbg_ptr, obj);
488
- return obj;
489
- }
490
- __destroy_into_raw() {
491
- const ptr = this.__wbg_ptr;
492
- this.__wbg_ptr = 0;
493
- GraphNodeFinalization.unregister(this);
494
- return ptr;
495
- }
496
- free() {
497
- const ptr = this.__destroy_into_raw();
498
- wasm.__wbg_graphnode_free(ptr, 0);
499
- }
500
- /**
501
- * Returns true if this node has a vector embedding.
502
- * @returns {boolean}
503
- */
504
- has_vector() {
505
- const ret = wasm.graphnode_has_vector(this.__wbg_ptr);
506
- return ret !== 0;
507
- }
508
- /**
509
- * Sets a vector embedding on the node.
510
- * @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
511
211
  */
512
- set_vector(vector) {
513
- const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
212
+ constructor(id, label) {
213
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
514
214
  const len0 = WASM_VECTOR_LEN;
515
- 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;
516
219
  }
517
220
  /**
518
221
  * Sets a boolean property on the node.
@@ -547,50 +250,13 @@ export class GraphNode {
547
250
  wasm.graphnode_set_string_property(this.__wbg_ptr, ptr0, len0, ptr1, len1);
548
251
  }
549
252
  /**
550
- * Returns the node ID.
551
- * @returns {bigint}
552
- */
553
- get id() {
554
- const ret = wasm.graphedge_id(this.__wbg_ptr);
555
- return BigInt.asUintN(64, ret);
556
- }
557
- /**
558
- * Creates a new graph node.
559
- *
560
- * # Arguments
561
- *
562
- * * `id` - Unique identifier for the node
563
- * * `label` - Node type/label (e.g., "Person", "Document")
564
- * @param {bigint} id
565
- * @param {string} label
253
+ * Sets a vector embedding on the node.
254
+ * @param {Float32Array} vector
566
255
  */
567
- constructor(id, label) {
568
- const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
256
+ set_vector(vector) {
257
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
569
258
  const len0 = WASM_VECTOR_LEN;
570
- const ret = wasm.graphnode_new(id, ptr0, len0);
571
- this.__wbg_ptr = ret >>> 0;
572
- GraphNodeFinalization.register(this, this.__wbg_ptr, this);
573
- return this;
574
- }
575
- /**
576
- * Returns the node label.
577
- * @returns {string}
578
- */
579
- get label() {
580
- let deferred1_0;
581
- let deferred1_1;
582
- try {
583
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
584
- wasm.graphnode_label(retptr, this.__wbg_ptr);
585
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
586
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
587
- deferred1_0 = r0;
588
- deferred1_1 = r1;
589
- return getStringFromWasm0(r0, r1);
590
- } finally {
591
- wasm.__wbindgen_add_to_stack_pointer(16);
592
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
593
- }
259
+ wasm.graphnode_set_vector(this.__wbg_ptr, ptr0, len0);
594
260
  }
595
261
  /**
596
262
  * Converts to JSON for JavaScript interop.
@@ -628,14 +294,6 @@ export class GraphPersistence {
628
294
  const ptr = this.__destroy_into_raw();
629
295
  wasm.__wbg_graphpersistence_free(ptr, 0);
630
296
  }
631
- /**
632
- * Lists all saved graph names.
633
- * @returns {Promise<Array<any>>}
634
- */
635
- list_graphs() {
636
- const ret = wasm.graphpersistence_list_graphs(this.__wbg_ptr);
637
- return takeObject(ret);
638
- }
639
297
  /**
640
298
  * Deletes a saved graph by name.
641
299
  *
@@ -660,15 +318,6 @@ export class GraphPersistence {
660
318
  const ret = wasm.graphpersistence_get_metadata(this.__wbg_ptr, ptr0, len0);
661
319
  return takeObject(ret);
662
320
  }
663
- /**
664
- * Creates a new `GraphPersistence` instance (call `init()` to open database).
665
- */
666
- constructor() {
667
- const ret = wasm.graphpersistence_new();
668
- this.__wbg_ptr = ret >>> 0;
669
- GraphPersistenceFinalization.register(this, this.__wbg_ptr, this);
670
- return this;
671
- }
672
321
  /**
673
322
  * Initializes the database connection. Must be called before save/load.
674
323
  * @returns {Promise<void>}
@@ -677,6 +326,14 @@ export class GraphPersistence {
677
326
  const ret = wasm.graphpersistence_init(this.__wbg_ptr);
678
327
  return takeObject(ret);
679
328
  }
329
+ /**
330
+ * Lists all saved graph names.
331
+ * @returns {Promise<Array<any>>}
332
+ */
333
+ list_graphs() {
334
+ const ret = wasm.graphpersistence_list_graphs(this.__wbg_ptr);
335
+ return takeObject(ret);
336
+ }
680
337
  /**
681
338
  * Loads a graph from `IndexedDB` by name.
682
339
  *
@@ -690,6 +347,15 @@ export class GraphPersistence {
690
347
  const ret = wasm.graphpersistence_load(this.__wbg_ptr, ptr0, len0);
691
348
  return takeObject(ret);
692
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
+ }
693
359
  /**
694
360
  * Saves a graph to `IndexedDB` with the given name.
695
361
  * @param {string} graph_name
@@ -730,43 +396,34 @@ export class GraphStore {
730
396
  wasm.__wbg_graphstore_free(ptr, 0);
731
397
  }
732
398
  /**
733
- * Returns the number of edges.
734
- * @returns {number}
735
- */
736
- get edge_count() {
737
- const ret = wasm.graphstore_edge_count(this.__wbg_ptr);
738
- return ret >>> 0;
739
- }
740
- /**
741
- * Returns the number of nodes.
742
- * @returns {number}
743
- */
744
- get node_count() {
745
- const ret = wasm.graphstore_node_count(this.__wbg_ptr);
746
- return ret >>> 0;
747
- }
748
- /**
749
- * Gets the degree (number of outgoing edges) of a node.
750
- * @param {bigint} node_id
751
- * @returns {number}
752
- */
753
- out_degree(node_id) {
754
- const ret = wasm.graphstore_out_degree(this.__wbg_ptr, node_id);
755
- return ret >>> 0;
756
- }
757
- /**
758
- * Removes an edge by ID.
759
- * @param {bigint} edge_id
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
760
403
  */
761
- remove_edge(edge_id) {
762
- wasm.graphstore_remove_edge(this.__wbg_ptr, edge_id);
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
+ }
763
418
  }
764
419
  /**
765
- * Removes a node and all connected edges.
766
- * @param {bigint} node_id
420
+ * Adds a node to the graph.
421
+ * @param {GraphNode} node
767
422
  */
768
- remove_node(node_id) {
769
- wasm.graphstore_remove_node(this.__wbg_ptr, node_id);
423
+ add_node(node) {
424
+ _assertClass(node, GraphNode);
425
+ var ptr0 = node.__destroy_into_raw();
426
+ wasm.graphstore_add_node(this.__wbg_ptr, ptr0);
770
427
  }
771
428
  /**
772
429
  * Performs BFS traversal from a source node.
@@ -800,6 +457,12 @@ export class GraphStore {
800
457
  wasm.__wbindgen_add_to_stack_pointer(16);
801
458
  }
802
459
  }
460
+ /**
461
+ * Clears all nodes and edges.
462
+ */
463
+ clear() {
464
+ wasm.graphstore_clear(this.__wbg_ptr);
465
+ }
803
466
  /**
804
467
  * Performs DFS traversal from a source node.
805
468
  *
@@ -833,58 +496,12 @@ export class GraphStore {
833
496
  }
834
497
  }
835
498
  /**
836
- * Gets incoming edges to a node.
837
- * @param {bigint} node_id
838
- * @returns {GraphEdge[]}
839
- */
840
- get_incoming(node_id) {
841
- try {
842
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
843
- wasm.graphstore_get_incoming(retptr, this.__wbg_ptr, node_id);
844
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
845
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
846
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
847
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
848
- return v1;
849
- } finally {
850
- wasm.__wbindgen_add_to_stack_pointer(16);
851
- }
852
- }
853
- /**
854
- * Gets outgoing edges from a node.
855
- * @param {bigint} node_id
856
- * @returns {GraphEdge[]}
857
- */
858
- get_outgoing(node_id) {
859
- try {
860
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
861
- wasm.graphstore_get_outgoing(retptr, this.__wbg_ptr, node_id);
862
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
863
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
864
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
865
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
866
- return v1;
867
- } finally {
868
- wasm.__wbindgen_add_to_stack_pointer(16);
869
- }
870
- }
871
- /**
872
- * Gets neighbors reachable from a node (1-hop).
873
- * @param {bigint} node_id
874
- * @returns {BigUint64Array}
499
+ * Returns the number of edges.
500
+ * @returns {number}
875
501
  */
876
- get_neighbors(node_id) {
877
- try {
878
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
879
- wasm.graphstore_get_neighbors(retptr, this.__wbg_ptr, node_id);
880
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
881
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
882
- var v1 = getArrayU64FromWasm0(r0, r1).slice();
883
- wasm.__wbindgen_export4(r0, r1 * 8, 8);
884
- return v1;
885
- } finally {
886
- wasm.__wbindgen_add_to_stack_pointer(16);
887
- }
502
+ get edge_count() {
503
+ const ret = wasm.graphstore_edge_count(this.__wbg_ptr);
504
+ return ret >>> 0;
888
505
  }
889
506
  /**
890
507
  * Gets all edge IDs in the graph.
@@ -920,6 +537,15 @@ export class GraphStore {
920
537
  wasm.__wbindgen_add_to_stack_pointer(16);
921
538
  }
922
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
+ }
923
549
  /**
924
550
  * Gets all edges with a specific label.
925
551
  *
@@ -948,6 +574,51 @@ export class GraphStore {
948
574
  wasm.__wbindgen_add_to_stack_pointer(16);
949
575
  }
950
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
+ }
951
622
  /**
952
623
  * Gets all nodes with a specific label.
953
624
  *
@@ -977,89 +648,44 @@ export class GraphStore {
977
648
  }
978
649
  }
979
650
  /**
980
- * Gets outgoing edges filtered by label.
651
+ * Gets outgoing edges from a node.
981
652
  * @param {bigint} node_id
982
- * @param {string} label
983
653
  * @returns {GraphEdge[]}
984
654
  */
985
- get_outgoing_by_label(node_id, label) {
655
+ get_outgoing(node_id) {
986
656
  try {
987
657
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
988
- const ptr0 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
989
- const len0 = WASM_VECTOR_LEN;
990
- 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);
991
659
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
992
660
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
993
- var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
661
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
994
662
  wasm.__wbindgen_export4(r0, r1 * 4, 4);
995
- return v2;
663
+ return v1;
996
664
  } finally {
997
665
  wasm.__wbindgen_add_to_stack_pointer(16);
998
666
  }
999
667
  }
1000
668
  /**
1001
- * Creates a new empty graph store.
1002
- */
1003
- constructor() {
1004
- const ret = wasm.graphstore_new();
1005
- this.__wbg_ptr = ret >>> 0;
1006
- GraphStoreFinalization.register(this, this.__wbg_ptr, this);
1007
- return this;
1008
- }
1009
- /**
1010
- * Clears all nodes and edges.
1011
- */
1012
- clear() {
1013
- wasm.graphstore_clear(this.__wbg_ptr);
1014
- }
1015
- /**
1016
- * Adds an edge to the graph.
1017
- *
1018
- * Returns an error if an edge with the same ID already exists.
1019
- * @param {GraphEdge} edge
669
+ * Gets outgoing edges filtered by label.
670
+ * @param {bigint} node_id
671
+ * @param {string} label
672
+ * @returns {GraphEdge[]}
1020
673
  */
1021
- add_edge(edge) {
674
+ get_outgoing_by_label(node_id, label) {
1022
675
  try {
1023
676
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1024
- _assertClass(edge, GraphEdge);
1025
- var ptr0 = edge.__destroy_into_raw();
1026
- 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);
1027
680
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1028
681
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1029
- if (r1) {
1030
- throw takeObject(r0);
1031
- }
682
+ var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
683
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
684
+ return v2;
1032
685
  } finally {
1033
686
  wasm.__wbindgen_add_to_stack_pointer(16);
1034
687
  }
1035
688
  }
1036
- /**
1037
- * Adds a node to the graph.
1038
- * @param {GraphNode} node
1039
- */
1040
- add_node(node) {
1041
- _assertClass(node, GraphNode);
1042
- var ptr0 = node.__destroy_into_raw();
1043
- wasm.graphstore_add_node(this.__wbg_ptr, ptr0);
1044
- }
1045
- /**
1046
- * Gets an edge by ID.
1047
- * @param {bigint} id
1048
- * @returns {GraphEdge | undefined}
1049
- */
1050
- get_edge(id) {
1051
- const ret = wasm.graphstore_get_edge(this.__wbg_ptr, id);
1052
- return ret === 0 ? undefined : GraphEdge.__wrap(ret);
1053
- }
1054
- /**
1055
- * Gets a node by ID.
1056
- * @param {bigint} id
1057
- * @returns {GraphNode | undefined}
1058
- */
1059
- get_node(id) {
1060
- const ret = wasm.graphstore_get_node(this.__wbg_ptr, id);
1061
- return ret === 0 ? undefined : GraphNode.__wrap(ret);
1062
- }
1063
689
  /**
1064
690
  * Checks if an edge exists.
1065
691
  * @param {bigint} id
@@ -1087,6 +713,46 @@ export class GraphStore {
1087
713
  const ret = wasm.graphstore_in_degree(this.__wbg_ptr, node_id);
1088
714
  return ret >>> 0;
1089
715
  }
716
+ /**
717
+ * Creates a new empty graph store.
718
+ */
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
+ }
725
+ /**
726
+ * Returns the number of nodes.
727
+ * @returns {number}
728
+ */
729
+ get node_count() {
730
+ const ret = wasm.graphstore_node_count(this.__wbg_ptr);
731
+ return ret >>> 0;
732
+ }
733
+ /**
734
+ * Gets the degree (number of outgoing edges) of a node.
735
+ * @param {bigint} node_id
736
+ * @returns {number}
737
+ */
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
+ }
1090
756
  }
1091
757
  if (Symbol.dispose) GraphStore.prototype[Symbol.dispose] = GraphStore.prototype.free;
1092
758
 
@@ -1111,6 +777,38 @@ export class GraphWorkerConfig {
1111
777
  const ptr = this.__destroy_into_raw();
1112
778
  wasm.__wbg_graphworkerconfig_free(ptr, 0);
1113
779
  }
780
+ /**
781
+ * Minimum depth to trigger worker offload.
782
+ * @returns {number}
783
+ */
784
+ get depth_threshold() {
785
+ const ret = wasm.__wbg_get_graphworkerconfig_depth_threshold(this.__wbg_ptr);
786
+ return ret >>> 0;
787
+ }
788
+ /**
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
+ }
1114
812
  /**
1115
813
  * Creates a configuration optimized for large graphs.
1116
814
  * @returns {GraphWorkerConfig}
@@ -1136,29 +834,6 @@ export class GraphWorkerConfig {
1136
834
  GraphWorkerConfigFinalization.register(this, this.__wbg_ptr, this);
1137
835
  return this;
1138
836
  }
1139
- /**
1140
- * Minimum node count to trigger worker offload.
1141
- * @returns {number}
1142
- */
1143
- get node_threshold() {
1144
- const ret = wasm.__wbg_get_graphworkerconfig_node_threshold(this.__wbg_ptr);
1145
- return ret >>> 0;
1146
- }
1147
- /**
1148
- * Minimum node count to trigger worker offload.
1149
- * @param {number} arg0
1150
- */
1151
- set node_threshold(arg0) {
1152
- wasm.__wbg_set_graphworkerconfig_node_threshold(this.__wbg_ptr, arg0);
1153
- }
1154
- /**
1155
- * Minimum depth to trigger worker offload.
1156
- * @returns {number}
1157
- */
1158
- get depth_threshold() {
1159
- const ret = wasm.__wbg_get_graphworkerconfig_depth_threshold(this.__wbg_ptr);
1160
- return ret >>> 0;
1161
- }
1162
837
  /**
1163
838
  * Minimum depth to trigger worker offload.
1164
839
  * @param {number} arg0
@@ -1167,12 +842,11 @@ export class GraphWorkerConfig {
1167
842
  wasm.__wbg_set_graphworkerconfig_depth_threshold(this.__wbg_ptr, arg0);
1168
843
  }
1169
844
  /**
1170
- * Progress callback interval in milliseconds.
1171
- * @returns {number}
845
+ * Minimum node count to trigger worker offload.
846
+ * @param {number} arg0
1172
847
  */
1173
- get progress_interval_ms() {
1174
- const ret = wasm.__wbg_get_graphworkerconfig_progress_interval_ms(this.__wbg_ptr);
1175
- return ret >>> 0;
848
+ set node_threshold(arg0) {
849
+ wasm.__wbg_set_graphworkerconfig_node_threshold(this.__wbg_ptr, arg0);
1176
850
  }
1177
851
  /**
1178
852
  * Progress callback interval in milliseconds.
@@ -1181,14 +855,6 @@ export class GraphWorkerConfig {
1181
855
  set progress_interval_ms(arg0) {
1182
856
  wasm.__wbg_set_graphworkerconfig_progress_interval_ms(this.__wbg_ptr, arg0);
1183
857
  }
1184
- /**
1185
- * Whether to use `SharedArrayBuffer` for result transfer (if available).
1186
- * @returns {boolean}
1187
- */
1188
- get use_shared_buffer() {
1189
- const ret = wasm.__wbg_get_graphworkerconfig_use_shared_buffer(this.__wbg_ptr);
1190
- return ret !== 0;
1191
- }
1192
858
  /**
1193
859
  * Whether to use `SharedArrayBuffer` for result transfer (if available).
1194
860
  * @param {boolean} arg0
@@ -1221,55 +887,20 @@ export class ParsedQuery {
1221
887
  wasm.__wbg_parsedquery_free(ptr, 0);
1222
888
  }
1223
889
  /**
1224
- * Check if the query uses FUSION (hybrid search).
1225
- * @returns {boolean}
1226
- */
1227
- get hasFusion() {
1228
- const ret = wasm.parsedquery_hasFusion(this.__wbg_ptr);
1229
- return ret !== 0;
1230
- }
1231
- /**
1232
- * Get the number of JOIN clauses.
1233
- * @returns {number}
1234
- */
1235
- get joinCount() {
1236
- const ret = wasm.parsedquery_joinCount(this.__wbg_ptr);
1237
- return ret >>> 0;
1238
- }
1239
- /**
1240
- * Get the table name from the FROM clause.
1241
- * @returns {string | undefined}
890
+ * Get the list of selected columns as JSON array.
891
+ * @returns {any}
1242
892
  */
1243
- get tableName() {
1244
- try {
1245
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1246
- wasm.parsedquery_tableName(retptr, this.__wbg_ptr);
1247
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1248
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1249
- let v1;
1250
- if (r0 !== 0) {
1251
- v1 = getStringFromWasm0(r0, r1).slice();
1252
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1253
- }
1254
- return v1;
1255
- } finally {
1256
- wasm.__wbindgen_add_to_stack_pointer(16);
1257
- }
893
+ get columns() {
894
+ const ret = wasm.parsedquery_columns(this.__wbg_ptr);
895
+ return takeObject(ret);
1258
896
  }
1259
897
  /**
1260
- * Get the LIMIT from the MATCH RETURN clause.
1261
- * @returns {bigint | undefined}
898
+ * Get the GROUP BY columns as JSON array.
899
+ * @returns {any}
1262
900
  */
1263
- get matchLimit() {
1264
- try {
1265
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1266
- wasm.parsedquery_matchLimit(retptr, this.__wbg_ptr);
1267
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1268
- var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1269
- return r0 === 0 ? undefined : BigInt.asUintN(64, r2);
1270
- } finally {
1271
- wasm.__wbindgen_add_to_stack_pointer(16);
1272
- }
901
+ get groupBy() {
902
+ const ret = wasm.parsedquery_groupBy(this.__wbg_ptr);
903
+ return takeObject(ret);
1273
904
  }
1274
905
  /**
1275
906
  * Check if DISTINCT modifier is present.
@@ -1279,6 +910,14 @@ export class ParsedQuery {
1279
910
  const ret = wasm.parsedquery_hasDistinct(this.__wbg_ptr);
1280
911
  return ret !== 0;
1281
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
+ }
1282
921
  /**
1283
922
  * Check if the query has a GROUP BY clause.
1284
923
  * @returns {boolean}
@@ -1287,6 +926,14 @@ export class ParsedQuery {
1287
926
  const ret = wasm.parsedquery_hasGroupBy(this.__wbg_ptr);
1288
927
  return ret !== 0;
1289
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
+ }
1290
937
  /**
1291
938
  * Check if the query has an ORDER BY clause.
1292
939
  * @returns {boolean}
@@ -1296,11 +943,11 @@ export class ParsedQuery {
1296
943
  return ret !== 0;
1297
944
  }
1298
945
  /**
1299
- * Check if the MATCH clause has a WHERE condition.
946
+ * Check if the query contains vector search (NEAR clause).
1300
947
  * @returns {boolean}
1301
948
  */
1302
- get matchHasWhere() {
1303
- const ret = wasm.parsedquery_matchHasWhere(this.__wbg_ptr);
949
+ get hasVectorSearch() {
950
+ const ret = wasm.parsedquery_hasVectorSearch(this.__wbg_ptr);
1304
951
  return ret !== 0;
1305
952
  }
1306
953
  /**
@@ -1312,55 +959,37 @@ export class ParsedQuery {
1312
959
  return ret !== 0;
1313
960
  }
1314
961
  /**
1315
- * Get the number of node patterns in the MATCH clause.
1316
- * @returns {number}
1317
- */
1318
- get matchNodeCount() {
1319
- const ret = wasm.parsedquery_matchNodeCount(this.__wbg_ptr);
1320
- return ret >>> 0;
1321
- }
1322
- /**
1323
- * Check if the query contains vector search (NEAR clause).
962
+ * Check if this is a MATCH (graph) query.
1324
963
  * @returns {boolean}
1325
964
  */
1326
- get hasVectorSearch() {
1327
- const ret = wasm.parsedquery_hasVectorSearch(this.__wbg_ptr);
965
+ get isMatch() {
966
+ const ret = wasm.parsedquery_isMatch(this.__wbg_ptr);
1328
967
  return ret !== 0;
1329
968
  }
1330
969
  /**
1331
- * Get node labels from the MATCH clause as JSON array of arrays.
1332
- * Each inner array contains the labels for one node pattern.
1333
- * @returns {any}
970
+ * Check if this is a SELECT query.
971
+ * @returns {boolean}
1334
972
  */
1335
- get matchNodeLabels() {
1336
- const ret = wasm.parsedquery_matchNodeLabels(this.__wbg_ptr);
1337
- return takeObject(ret);
973
+ get isSelect() {
974
+ const ret = wasm.parsedquery_isSelect(this.__wbg_ptr);
975
+ return ret !== 0;
1338
976
  }
1339
977
  /**
1340
- * Get RETURN items from the MATCH clause as JSON array.
1341
- * @returns {any}
978
+ * Check if the query is valid (always true for successfully parsed queries).
979
+ * @returns {boolean}
1342
980
  */
1343
- get matchReturnItems() {
1344
- const ret = wasm.parsedquery_matchReturnItems(this.__wbg_ptr);
1345
- return takeObject(ret);
981
+ get isValid() {
982
+ const ret = wasm.parsedquery_isValid(this.__wbg_ptr);
983
+ return ret !== 0;
1346
984
  }
1347
985
  /**
1348
- * Get the number of relationship patterns in the MATCH clause.
986
+ * Get the number of JOIN clauses.
1349
987
  * @returns {number}
1350
988
  */
1351
- get matchRelationshipCount() {
1352
- const ret = wasm.parsedquery_matchRelationshipCount(this.__wbg_ptr);
989
+ get joinCount() {
990
+ const ret = wasm.parsedquery_joinCount(this.__wbg_ptr);
1353
991
  return ret >>> 0;
1354
992
  }
1355
- /**
1356
- * Get relationship types from the MATCH clause as JSON array of arrays.
1357
- * Each inner array contains the types for one relationship pattern.
1358
- * @returns {any}
1359
- */
1360
- get matchRelationshipTypes() {
1361
- const ret = wasm.parsedquery_matchRelationshipTypes(this.__wbg_ptr);
1362
- return takeObject(ret);
1363
- }
1364
993
  /**
1365
994
  * Get the LIMIT value if present.
1366
995
  * @returns {bigint | undefined}
@@ -1377,13 +1006,21 @@ export class ParsedQuery {
1377
1006
  }
1378
1007
  }
1379
1008
  /**
1380
- * Get the OFFSET value if present.
1009
+ * Check if the MATCH clause has a WHERE condition.
1010
+ * @returns {boolean}
1011
+ */
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.
1381
1018
  * @returns {bigint | undefined}
1382
1019
  */
1383
- get offset() {
1020
+ get matchLimit() {
1384
1021
  try {
1385
1022
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1386
- wasm.parsedquery_offset(retptr, this.__wbg_ptr);
1023
+ wasm.parsedquery_matchLimit(retptr, this.__wbg_ptr);
1387
1024
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1388
1025
  var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1389
1026
  return r0 === 0 ? undefined : BigInt.asUintN(64, r2);
@@ -1392,36 +1029,61 @@ export class ParsedQuery {
1392
1029
  }
1393
1030
  }
1394
1031
  /**
1395
- * Get the list of selected columns as JSON array.
1032
+ * Get the number of node patterns in the MATCH clause.
1033
+ * @returns {number}
1034
+ */
1035
+ get matchNodeCount() {
1036
+ const ret = wasm.parsedquery_matchNodeCount(this.__wbg_ptr);
1037
+ return ret >>> 0;
1038
+ }
1039
+ /**
1040
+ * Get node labels from the MATCH clause as JSON array of arrays.
1041
+ * Each inner array contains the labels for one node pattern.
1396
1042
  * @returns {any}
1397
1043
  */
1398
- get columns() {
1399
- const ret = wasm.parsedquery_columns(this.__wbg_ptr);
1044
+ get matchNodeLabels() {
1045
+ const ret = wasm.parsedquery_matchNodeLabels(this.__wbg_ptr);
1400
1046
  return takeObject(ret);
1401
1047
  }
1402
1048
  /**
1403
- * Get the GROUP BY columns as JSON array.
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.
1404
1059
  * @returns {any}
1405
1060
  */
1406
- get groupBy() {
1407
- const ret = wasm.parsedquery_groupBy(this.__wbg_ptr);
1061
+ get matchRelationshipTypes() {
1062
+ const ret = wasm.parsedquery_matchRelationshipTypes(this.__wbg_ptr);
1408
1063
  return takeObject(ret);
1409
1064
  }
1410
1065
  /**
1411
- * Check if this is a MATCH (graph) query.
1412
- * @returns {boolean}
1066
+ * Get RETURN items from the MATCH clause as JSON array.
1067
+ * @returns {any}
1413
1068
  */
1414
- get isMatch() {
1415
- const ret = wasm.parsedquery_isMatch(this.__wbg_ptr);
1416
- return ret !== 0;
1069
+ get matchReturnItems() {
1070
+ const ret = wasm.parsedquery_matchReturnItems(this.__wbg_ptr);
1071
+ return takeObject(ret);
1417
1072
  }
1418
1073
  /**
1419
- * Check if the query is valid (always true for successfully parsed queries).
1420
- * @returns {boolean}
1074
+ * Get the OFFSET value if present.
1075
+ * @returns {bigint | undefined}
1421
1076
  */
1422
- get isValid() {
1423
- const ret = wasm.parsedquery_isValid(this.__wbg_ptr);
1424
- return ret !== 0;
1077
+ get offset() {
1078
+ try {
1079
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1080
+ wasm.parsedquery_offset(retptr, this.__wbg_ptr);
1081
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1082
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1083
+ return r0 === 0 ? undefined : BigInt.asUintN(64, r2);
1084
+ } finally {
1085
+ wasm.__wbindgen_add_to_stack_pointer(16);
1086
+ }
1425
1087
  }
1426
1088
  /**
1427
1089
  * Get the ORDER BY columns and directions as JSON array.
@@ -1432,20 +1094,24 @@ export class ParsedQuery {
1432
1094
  return takeObject(ret);
1433
1095
  }
1434
1096
  /**
1435
- * Check if the query has JOINs.
1436
- * @returns {boolean}
1437
- */
1438
- get hasJoins() {
1439
- const ret = wasm.parsedquery_hasJoins(this.__wbg_ptr);
1440
- return ret !== 0;
1441
- }
1442
- /**
1443
- * Check if this is a SELECT query.
1444
- * @returns {boolean}
1097
+ * Get the table name from the FROM clause.
1098
+ * @returns {string | undefined}
1445
1099
  */
1446
- get isSelect() {
1447
- const ret = wasm.parsedquery_isSelect(this.__wbg_ptr);
1448
- return ret !== 0;
1100
+ get tableName() {
1101
+ try {
1102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1103
+ wasm.parsedquery_tableName(retptr, this.__wbg_ptr);
1104
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1105
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1106
+ let v1;
1107
+ if (r0 !== 0) {
1108
+ v1 = getStringFromWasm0(r0, r1).slice();
1109
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1110
+ }
1111
+ return v1;
1112
+ } finally {
1113
+ wasm.__wbindgen_add_to_stack_pointer(16);
1114
+ }
1449
1115
  }
1450
1116
  }
1451
1117
  if (Symbol.dispose) ParsedQuery.prototype[Symbol.dispose] = ParsedQuery.prototype.free;
@@ -1476,12 +1142,34 @@ export class SemanticMemory {
1476
1142
  const ptr = this.__destroy_into_raw();
1477
1143
  wasm.__wbg_semanticmemory_free(ptr, 0);
1478
1144
  }
1145
+ /**
1146
+ * Clears all knowledge facts.
1147
+ */
1148
+ clear() {
1149
+ wasm.semanticmemory_clear(this.__wbg_ptr);
1150
+ }
1151
+ /**
1152
+ * Returns the embedding dimension.
1153
+ * @returns {number}
1154
+ */
1155
+ dimension() {
1156
+ const ret = wasm.semanticmemory_dimension(this.__wbg_ptr);
1157
+ return ret >>> 0;
1158
+ }
1159
+ /**
1160
+ * Returns true if no knowledge facts are stored.
1161
+ * @returns {boolean}
1162
+ */
1163
+ is_empty() {
1164
+ const ret = wasm.semanticmemory_is_empty(this.__wbg_ptr);
1165
+ return ret !== 0;
1166
+ }
1479
1167
  /**
1480
1168
  * Returns the number of stored knowledge facts.
1481
1169
  * @returns {number}
1482
1170
  */
1483
1171
  len() {
1484
- const ret = wasm.graphstore_node_count(this.__wbg_ptr);
1172
+ const ret = wasm.semanticmemory_len(this.__wbg_ptr);
1485
1173
  return ret >>> 0;
1486
1174
  }
1487
1175
  /**
@@ -1505,12 +1193,6 @@ export class SemanticMemory {
1505
1193
  wasm.__wbindgen_add_to_stack_pointer(16);
1506
1194
  }
1507
1195
  }
1508
- /**
1509
- * Clears all knowledge facts.
1510
- */
1511
- clear() {
1512
- wasm.semanticmemory_clear(this.__wbg_ptr);
1513
- }
1514
1196
  /**
1515
1197
  * Queries semantic memory by similarity search.
1516
1198
  *
@@ -1536,6 +1218,15 @@ export class SemanticMemory {
1536
1218
  wasm.__wbindgen_add_to_stack_pointer(16);
1537
1219
  }
1538
1220
  }
1221
+ /**
1222
+ * Removes a knowledge fact by ID.
1223
+ * @param {bigint} id
1224
+ * @returns {boolean}
1225
+ */
1226
+ remove(id) {
1227
+ const ret = wasm.semanticmemory_remove(this.__wbg_ptr, id);
1228
+ return ret !== 0;
1229
+ }
1539
1230
  /**
1540
1231
  * Stores a knowledge fact with its embedding vector.
1541
1232
  *
@@ -1565,37 +1256,101 @@ export class SemanticMemory {
1565
1256
  wasm.__wbindgen_add_to_stack_pointer(16);
1566
1257
  }
1567
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
+ }
1568
1278
  /**
1569
- * Removes a knowledge fact by ID.
1570
- * @param {bigint} id
1571
- * @returns {boolean}
1279
+ * Returns the number of documents in the index.
1280
+ * @returns {number}
1572
1281
  */
1573
- remove(id) {
1574
- const ret = wasm.semanticmemory_remove(this.__wbg_ptr, id);
1575
- return ret !== 0;
1282
+ get doc_count() {
1283
+ const ret = wasm.sparseindex_doc_count(this.__wbg_ptr);
1284
+ return ret >>> 0;
1576
1285
  }
1577
1286
  /**
1578
- * Returns true if no knowledge facts are stored.
1579
- * @returns {boolean}
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
1580
1293
  */
1581
- is_empty() {
1582
- const ret = wasm.semanticmemory_is_empty(this.__wbg_ptr);
1583
- return ret !== 0;
1294
+ insert(doc_id, indices, values) {
1295
+ try {
1296
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1297
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
1298
+ const len0 = WASM_VECTOR_LEN;
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);
1302
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1303
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1304
+ if (r1) {
1305
+ throw takeObject(r0);
1306
+ }
1307
+ } finally {
1308
+ wasm.__wbindgen_add_to_stack_pointer(16);
1309
+ }
1584
1310
  }
1585
1311
  /**
1586
- * Returns the embedding dimension.
1587
- * @returns {number}
1312
+ * Creates a new empty sparse index.
1588
1313
  */
1589
- dimension() {
1590
- const ret = wasm.semanticmemory_dimension(this.__wbg_ptr);
1591
- return ret >>> 0;
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
1327
+ * @returns {any}
1328
+ */
1329
+ search(query_indices, query_values, k) {
1330
+ try {
1331
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
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);
1337
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1338
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1339
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1340
+ if (r2) {
1341
+ throw takeObject(r1);
1342
+ }
1343
+ return takeObject(r0);
1344
+ } finally {
1345
+ wasm.__wbindgen_add_to_stack_pointer(16);
1346
+ }
1592
1347
  }
1593
1348
  }
1594
- if (Symbol.dispose) SemanticMemory.prototype[Symbol.dispose] = SemanticMemory.prototype.free;
1349
+ if (Symbol.dispose) SparseIndex.prototype[Symbol.dispose] = SparseIndex.prototype.free;
1595
1350
 
1596
1351
  /**
1597
1352
  * Storage mode for vector quantization.
1598
- * @enum {0 | 1 | 2}
1353
+ * @enum {0 | 1 | 2 | 3}
1599
1354
  */
1600
1355
  export const StorageMode = Object.freeze({
1601
1356
  /**
@@ -1610,6 +1365,10 @@ export const StorageMode = Object.freeze({
1610
1365
  * Binary: 1-bit quantization (1 bit per dimension, 32x compression)
1611
1366
  */
1612
1367
  Binary: 2, "2": "Binary",
1368
+ /**
1369
+ * Product Quantization (currently mapped to SQ8 path in WASM runtime)
1370
+ */
1371
+ ProductQuantization: 3, "3": "ProductQuantization",
1613
1372
  });
1614
1373
 
1615
1374
  /**
@@ -1627,118 +1386,118 @@ export class TraversalProgress {
1627
1386
  wasm.__wbg_traversalprogress_free(ptr, 0);
1628
1387
  }
1629
1388
  /**
1630
- * Returns the completion percentage (0-100).
1389
+ * Current traversal depth.
1631
1390
  * @returns {number}
1632
1391
  */
1633
- get percentage() {
1634
- const ret = wasm.traversalprogress_percentage(this.__wbg_ptr);
1635
- return ret;
1392
+ get current_depth() {
1393
+ const ret = wasm.__wbg_get_traversalprogress_current_depth(this.__wbg_ptr);
1394
+ return ret >>> 0;
1636
1395
  }
1637
1396
  /**
1638
- * Creates a new progress report.
1639
- * @param {number} visited
1640
- * @param {number} estimated
1641
- * @param {number} depth
1397
+ * Estimated total nodes to visit (heuristic).
1398
+ * @returns {number}
1642
1399
  */
1643
- constructor(visited, estimated, depth) {
1644
- const ret = wasm.traversalprogress_new(visited, estimated, depth);
1645
- this.__wbg_ptr = ret >>> 0;
1646
- TraversalProgressFinalization.register(this, this.__wbg_ptr, this);
1647
- return this;
1400
+ get estimated_total() {
1401
+ const ret = wasm.__wbg_get_traversalprogress_estimated_total(this.__wbg_ptr);
1402
+ return ret >>> 0;
1648
1403
  }
1649
1404
  /**
1650
- * Converts to JSON for postMessage.
1651
- * @returns {any}
1405
+ * Whether the traversal was cancelled.
1406
+ * @returns {boolean}
1652
1407
  */
1653
- to_json() {
1654
- try {
1655
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1656
- wasm.traversalprogress_to_json(retptr, this.__wbg_ptr);
1657
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1658
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1659
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1660
- if (r2) {
1661
- throw takeObject(r1);
1662
- }
1663
- return takeObject(r0);
1664
- } finally {
1665
- wasm.__wbindgen_add_to_stack_pointer(16);
1666
- }
1408
+ get is_cancelled() {
1409
+ const ret = wasm.__wbg_get_traversalprogress_is_cancelled(this.__wbg_ptr);
1410
+ return ret !== 0;
1411
+ }
1412
+ /**
1413
+ * Whether the traversal is complete.
1414
+ * @returns {boolean}
1415
+ */
1416
+ get is_complete() {
1417
+ const ret = wasm.__wbg_get_traversalprogress_is_complete(this.__wbg_ptr);
1418
+ return ret !== 0;
1667
1419
  }
1668
1420
  /**
1669
1421
  * Number of nodes visited so far.
1670
1422
  * @returns {number}
1671
1423
  */
1672
1424
  get visited_count() {
1673
- const ret = wasm.__wbg_get_graphworkerconfig_node_threshold(this.__wbg_ptr);
1425
+ const ret = wasm.__wbg_get_traversalprogress_visited_count(this.__wbg_ptr);
1674
1426
  return ret >>> 0;
1675
1427
  }
1676
1428
  /**
1677
- * Number of nodes visited so far.
1429
+ * Current traversal depth.
1678
1430
  * @param {number} arg0
1679
1431
  */
1680
- set visited_count(arg0) {
1681
- wasm.__wbg_set_graphworkerconfig_node_threshold(this.__wbg_ptr, arg0);
1682
- }
1683
- /**
1684
- * Estimated total nodes to visit (heuristic).
1685
- * @returns {number}
1686
- */
1687
- get estimated_total() {
1688
- const ret = wasm.__wbg_get_graphworkerconfig_depth_threshold(this.__wbg_ptr);
1689
- return ret >>> 0;
1432
+ set current_depth(arg0) {
1433
+ wasm.__wbg_set_traversalprogress_current_depth(this.__wbg_ptr, arg0);
1690
1434
  }
1691
1435
  /**
1692
1436
  * Estimated total nodes to visit (heuristic).
1693
1437
  * @param {number} arg0
1694
1438
  */
1695
1439
  set estimated_total(arg0) {
1696
- wasm.__wbg_set_graphworkerconfig_depth_threshold(this.__wbg_ptr, arg0);
1440
+ wasm.__wbg_set_traversalprogress_estimated_total(this.__wbg_ptr, arg0);
1697
1441
  }
1698
1442
  /**
1699
- * Current traversal depth.
1700
- * @returns {number}
1443
+ * Whether the traversal was cancelled.
1444
+ * @param {boolean} arg0
1701
1445
  */
1702
- get current_depth() {
1703
- const ret = wasm.__wbg_get_graphworkerconfig_progress_interval_ms(this.__wbg_ptr);
1704
- return ret >>> 0;
1446
+ set is_cancelled(arg0) {
1447
+ wasm.__wbg_set_traversalprogress_is_cancelled(this.__wbg_ptr, arg0);
1705
1448
  }
1706
1449
  /**
1707
- * Current traversal depth.
1708
- * @param {number} arg0
1450
+ * Whether the traversal is complete.
1451
+ * @param {boolean} arg0
1709
1452
  */
1710
- set current_depth(arg0) {
1711
- wasm.__wbg_set_graphworkerconfig_progress_interval_ms(this.__wbg_ptr, arg0);
1453
+ set is_complete(arg0) {
1454
+ wasm.__wbg_set_traversalprogress_is_complete(this.__wbg_ptr, arg0);
1712
1455
  }
1713
1456
  /**
1714
- * Whether the traversal is complete.
1715
- * @returns {boolean}
1457
+ * Number of nodes visited so far.
1458
+ * @param {number} arg0
1716
1459
  */
1717
- get is_complete() {
1718
- const ret = wasm.__wbg_get_graphworkerconfig_use_shared_buffer(this.__wbg_ptr);
1719
- return ret !== 0;
1460
+ set visited_count(arg0) {
1461
+ wasm.__wbg_set_traversalprogress_visited_count(this.__wbg_ptr, arg0);
1720
1462
  }
1721
1463
  /**
1722
- * Whether the traversal is complete.
1723
- * @param {boolean} arg0
1464
+ * Creates a new progress report.
1465
+ * @param {number} visited
1466
+ * @param {number} estimated
1467
+ * @param {number} depth
1724
1468
  */
1725
- set is_complete(arg0) {
1726
- wasm.__wbg_set_graphworkerconfig_use_shared_buffer(this.__wbg_ptr, arg0);
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;
1727
1474
  }
1728
1475
  /**
1729
- * Whether the traversal was cancelled.
1730
- * @returns {boolean}
1476
+ * Returns the completion percentage (0-100).
1477
+ * @returns {number}
1731
1478
  */
1732
- get is_cancelled() {
1733
- const ret = wasm.__wbg_get_traversalprogress_is_cancelled(this.__wbg_ptr);
1734
- return ret !== 0;
1479
+ get percentage() {
1480
+ const ret = wasm.traversalprogress_percentage(this.__wbg_ptr);
1481
+ return ret;
1735
1482
  }
1736
1483
  /**
1737
- * Whether the traversal was cancelled.
1738
- * @param {boolean} arg0
1484
+ * Converts to JSON for postMessage.
1485
+ * @returns {any}
1739
1486
  */
1740
- set is_cancelled(arg0) {
1741
- wasm.__wbg_set_traversalprogress_is_cancelled(this.__wbg_ptr, arg0);
1487
+ to_json() {
1488
+ try {
1489
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
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
+ }
1742
1501
  }
1743
1502
  }
1744
1503
  if (Symbol.dispose) TraversalProgress.prototype[Symbol.dispose] = TraversalProgress.prototype.free;
@@ -1777,20 +1536,18 @@ export class VectorStore {
1777
1536
  wasm.__wbg_vectorstore_free(ptr, 0);
1778
1537
  }
1779
1538
  /**
1780
- * Text search on payload fields (substring matching).
1781
- * @param {string} query
1539
+ * Batch search for multiple vectors. Returns [[[id, score], ...], ...].
1540
+ * @param {Float32Array} vectors
1541
+ * @param {number} num_vectors
1782
1542
  * @param {number} k
1783
- * @param {string | null} [field]
1784
1543
  * @returns {any}
1785
1544
  */
1786
- text_search(query, k, field) {
1545
+ batch_search(vectors, num_vectors, k) {
1787
1546
  try {
1788
1547
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1789
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1548
+ const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1790
1549
  const len0 = WASM_VECTOR_LEN;
1791
- var ptr1 = isLikeNone(field) ? 0 : passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1792
- var len1 = WASM_VECTOR_LEN;
1793
- wasm.vectorstore_text_search(retptr, this.__wbg_ptr, ptr0, len0, k, ptr1, len1);
1550
+ wasm.vectorstore_batch_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k);
1794
1551
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1795
1552
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1796
1553
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1803,18 +1560,88 @@ export class VectorStore {
1803
1560
  }
1804
1561
  }
1805
1562
  /**
1806
- * Batch search for multiple vectors. Returns [[[id, score], ...], ...].
1807
- * @param {Float32Array} vectors
1808
- * @param {number} num_vectors
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.
1611
+ * @param {bigint} id
1612
+ * @returns {any}
1613
+ */
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
+ }
1628
+ }
1629
+ /**
1630
+ * Hybrid search (vector + text). `vector_weight` 0-1 (default 0.5).
1631
+ * @param {Float32Array} query_vector
1632
+ * @param {string} text_query
1809
1633
  * @param {number} k
1634
+ * @param {number | null} [vector_weight]
1810
1635
  * @returns {any}
1811
1636
  */
1812
- batch_search(vectors, num_vectors, k) {
1637
+ hybrid_search(query_vector, text_query, k, vector_weight) {
1813
1638
  try {
1814
1639
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1815
- const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1640
+ const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1816
1641
  const len0 = WASM_VECTOR_LEN;
1817
- wasm.vectorstore_batch_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, 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));
1818
1645
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1819
1646
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1820
1647
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1826,6 +1653,48 @@ export class VectorStore {
1826
1653
  wasm.__wbindgen_add_to_stack_pointer(16);
1827
1654
  }
1828
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
+ }
1829
1698
  /**
1830
1699
  * Batch insert. Input: `[[id, Float32Array], ...]`.
1831
1700
  * @param {any} batch
@@ -1843,6 +1712,62 @@ export class VectorStore {
1843
1712
  wasm.__wbindgen_add_to_stack_pointer(16);
1844
1713
  }
1845
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
+ }
1846
1771
  /**
1847
1772
  * Returns memory usage estimate in bytes.
1848
1773
  * @returns {number}
@@ -1852,52 +1777,65 @@ export class VectorStore {
1852
1777
  return ret >>> 0;
1853
1778
  }
1854
1779
  /**
1855
- * Returns the storage mode.
1856
- * @returns {string}
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}
1857
1787
  */
1858
- get storage_mode() {
1859
- let deferred1_0;
1860
- let deferred1_1;
1788
+ multi_query_search(vectors, num_vectors, k, strategy, rrf_k) {
1861
1789
  try {
1862
1790
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1863
- wasm.vectorstore_storage_mode(retptr, this.__wbg_ptr);
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);
1864
1796
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1865
1797
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1866
- deferred1_0 = r0;
1867
- deferred1_1 = r1;
1868
- return getStringFromWasm0(r0, r1);
1798
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1799
+ if (r2) {
1800
+ throw takeObject(r1);
1801
+ }
1802
+ return takeObject(r0);
1869
1803
  } finally {
1870
1804
  wasm.__wbindgen_add_to_stack_pointer(16);
1871
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1872
1805
  }
1873
1806
  }
1874
- /**
1875
- * Hybrid search (vector + text). `vector_weight` 0-1 (default 0.5).
1876
- * @param {Float32Array} query_vector
1877
- * @param {string} text_query
1878
- * @param {number} k
1879
- * @param {number | null} [vector_weight]
1880
- * @returns {any}
1807
+ /**
1808
+ * Creates a new vector store. Metrics: cosine, euclidean, dot, hamming, jaccard.
1809
+ * @param {number} dimension
1810
+ * @param {string} metric
1881
1811
  */
1882
- hybrid_search(query_vector, text_query, k, vector_weight) {
1812
+ constructor(dimension, metric) {
1883
1813
  try {
1884
1814
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1885
- const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1815
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1886
1816
  const len0 = WASM_VECTOR_LEN;
1887
- const ptr1 = passStringToWasm0(text_query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1888
- const len1 = WASM_VECTOR_LEN;
1889
- wasm.vectorstore_hybrid_search(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, k, isLikeNone(vector_weight) ? 0x100000001 : Math.fround(vector_weight));
1817
+ wasm.vectorstore_new(retptr, dimension, ptr0, len0);
1890
1818
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1891
1819
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1892
1820
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1893
1821
  if (r2) {
1894
1822
  throw takeObject(r1);
1895
1823
  }
1896
- return takeObject(r0);
1824
+ this.__wbg_ptr = r0 >>> 0;
1825
+ VectorStoreFinalization.register(this, this.__wbg_ptr, this);
1826
+ return this;
1897
1827
  } finally {
1898
1828
  wasm.__wbindgen_add_to_stack_pointer(16);
1899
1829
  }
1900
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
+ }
1901
1839
  /**
1902
1840
  * Creates store with mode: full (4B/dim), sq8 (4x compression), binary (32x).
1903
1841
  * @param {number} dimension
@@ -1925,100 +1863,112 @@ export class VectorStore {
1925
1863
  }
1926
1864
  }
1927
1865
  /**
1928
- * Creates store with pre-allocated capacity.
1929
- * @param {number} dimension
1930
- * @param {string} metric
1931
- * @param {number} capacity
1932
- * @returns {VectorStore}
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}
1933
1880
  */
1934
- static with_capacity(dimension, metric, capacity) {
1881
+ query(query_vector, k) {
1935
1882
  try {
1936
1883
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1937
- const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1884
+ const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1938
1885
  const len0 = WASM_VECTOR_LEN;
1939
- wasm.vectorstore_with_capacity(retptr, dimension, ptr0, len0, capacity);
1886
+ wasm.vectorstore_query(retptr, this.__wbg_ptr, ptr0, len0, k);
1940
1887
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1941
1888
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1942
1889
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1943
1890
  if (r2) {
1944
1891
  throw takeObject(r1);
1945
1892
  }
1946
- return VectorStore.__wrap(r0);
1893
+ return takeObject(r0);
1947
1894
  } finally {
1948
1895
  wasm.__wbindgen_add_to_stack_pointer(16);
1949
1896
  }
1950
1897
  }
1951
1898
  /**
1952
- * Deletes `IndexedDB` database.
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`.
1953
1916
  * @param {string} db_name
1954
1917
  * @returns {Promise<void>}
1955
1918
  */
1956
- static delete_database(db_name) {
1919
+ save(db_name) {
1957
1920
  const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1958
1921
  const len0 = WASM_VECTOR_LEN;
1959
- const ret = wasm.vectorstore_delete_database(ptr0, len0);
1922
+ const ret = wasm.vectorstore_save(this.__wbg_ptr, ptr0, len0);
1960
1923
  return takeObject(ret);
1961
1924
  }
1962
1925
  /**
1963
- * Exports to binary format for IndexedDB/localStorage.
1964
- * @returns {Uint8Array}
1926
+ * k-NN search. Returns [[id, score], ...].
1927
+ * @param {Float32Array} query
1928
+ * @param {number} k
1929
+ * @returns {any}
1965
1930
  */
1966
- export_to_bytes() {
1931
+ search(query, k) {
1967
1932
  try {
1968
1933
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1969
- wasm.vectorstore_export_to_bytes(retptr, this.__wbg_ptr);
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);
1970
1937
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1971
1938
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1972
1939
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1973
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1974
- if (r3) {
1975
- throw takeObject(r2);
1940
+ if (r2) {
1941
+ throw takeObject(r1);
1976
1942
  }
1977
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
1978
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1979
- return v1;
1943
+ return takeObject(r0);
1980
1944
  } finally {
1981
1945
  wasm.__wbindgen_add_to_stack_pointer(16);
1982
1946
  }
1983
1947
  }
1984
1948
  /**
1985
- * Returns true if this is a metadata-only store.
1986
- * @returns {boolean}
1987
- */
1988
- get is_metadata_only() {
1989
- const ret = wasm.vectorstore_is_metadata_only(this.__wbg_ptr);
1990
- return ret !== 0;
1991
- }
1992
- /**
1993
- * Imports from binary format.
1994
- * @param {Uint8Array} bytes
1995
- * @returns {VectorStore}
1949
+ * Searches with metadata filtering. Returns [{id, score, payload}].
1950
+ * @param {Float32Array} query
1951
+ * @param {number} k
1952
+ * @param {any} filter
1953
+ * @returns {any}
1996
1954
  */
1997
- static import_from_bytes(bytes) {
1955
+ search_with_filter(query, k, filter) {
1998
1956
  try {
1999
1957
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2000
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1958
+ const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
2001
1959
  const len0 = WASM_VECTOR_LEN;
2002
- wasm.vectorstore_import_from_bytes(retptr, ptr0, len0);
1960
+ wasm.vectorstore_search_with_filter(retptr, this.__wbg_ptr, ptr0, len0, k, addHeapObject(filter));
2003
1961
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2004
1962
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2005
1963
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2006
1964
  if (r2) {
2007
1965
  throw takeObject(r1);
2008
1966
  }
2009
- return VectorStore.__wrap(r0);
1967
+ return takeObject(r0);
2010
1968
  } finally {
2011
1969
  wasm.__wbindgen_add_to_stack_pointer(16);
2012
1970
  }
2013
1971
  }
2014
- /**
2015
- * Creates a metadata-only store (no vectors, only payloads).
2016
- * @returns {VectorStore}
2017
- */
2018
- static new_metadata_only() {
2019
- const ret = wasm.vectorstore_new_metadata_only();
2020
- return VectorStore.__wrap(ret);
2021
- }
2022
1972
  /**
2023
1973
  * Similarity search with threshold. Operators: >, >=, <, <=, =, !=.
2024
1974
  * @param {Float32Array} query
@@ -2047,46 +1997,47 @@ export class VectorStore {
2047
1997
  }
2048
1998
  }
2049
1999
  /**
2050
- * Multi-query search with fusion. Strategies: average, maximum, rrf.
2051
- * @param {Float32Array} vectors
2052
- * @param {number} num_vectors
2053
- * @param {number} k
2054
- * @param {string} strategy
2055
- * @param {number | null} [rrf_k]
2056
- * @returns {any}
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
2057
2006
  */
2058
- multi_query_search(vectors, num_vectors, k, strategy, rrf_k) {
2007
+ sparse_insert(doc_id, indices, values) {
2059
2008
  try {
2060
2009
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2061
- const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
2010
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
2062
2011
  const len0 = WASM_VECTOR_LEN;
2063
- const ptr1 = passStringToWasm0(strategy, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2012
+ const ptr1 = passArrayF32ToWasm0(values, wasm.__wbindgen_export);
2064
2013
  const len1 = WASM_VECTOR_LEN;
2065
- wasm.vectorstore_multi_query_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k, ptr1, len1, isLikeNone(rrf_k) ? 0x100000001 : (rrf_k) >>> 0);
2014
+ wasm.vectorstore_sparse_insert(retptr, this.__wbg_ptr, doc_id, ptr0, len0, ptr1, len1);
2066
2015
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2067
2016
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2068
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2069
- if (r2) {
2070
- throw takeObject(r1);
2017
+ if (r1) {
2018
+ throw takeObject(r0);
2071
2019
  }
2072
- return takeObject(r0);
2073
2020
  } finally {
2074
2021
  wasm.__wbindgen_add_to_stack_pointer(16);
2075
2022
  }
2076
2023
  }
2077
2024
  /**
2078
- * Searches with metadata filtering. Returns [{id, score, payload}].
2079
- * @param {Float32Array} query
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
2080
2030
  * @param {number} k
2081
- * @param {any} filter
2082
2031
  * @returns {any}
2083
2032
  */
2084
- search_with_filter(query, k, filter) {
2033
+ sparse_search(indices, values, k) {
2085
2034
  try {
2086
2035
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2087
- const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
2036
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
2088
2037
  const len0 = WASM_VECTOR_LEN;
2089
- wasm.vectorstore_search_with_filter(retptr, this.__wbg_ptr, ptr0, len0, k, addHeapObject(filter));
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);
2090
2041
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2091
2042
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2092
2043
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2099,35 +2050,40 @@ export class VectorStore {
2099
2050
  }
2100
2051
  }
2101
2052
  /**
2102
- * Inserts a vector with ID and optional JSON payload.
2103
- * @param {bigint} id
2104
- * @param {Float32Array} vector
2105
- * @param {any} payload
2053
+ * Returns the storage mode.
2054
+ * @returns {string}
2106
2055
  */
2107
- insert_with_payload(id, vector, payload) {
2056
+ get storage_mode() {
2057
+ let deferred1_0;
2058
+ let deferred1_1;
2108
2059
  try {
2109
2060
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2110
- const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
2111
- const len0 = WASM_VECTOR_LEN;
2112
- wasm.vectorstore_insert_with_payload(retptr, this.__wbg_ptr, id, ptr0, len0, addHeapObject(payload));
2061
+ wasm.vectorstore_storage_mode(retptr, this.__wbg_ptr);
2113
2062
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2114
2063
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2115
- if (r1) {
2116
- throw takeObject(r0);
2117
- }
2064
+ deferred1_0 = r0;
2065
+ deferred1_1 = r1;
2066
+ return getStringFromWasm0(r0, r1);
2118
2067
  } finally {
2119
2068
  wasm.__wbindgen_add_to_stack_pointer(16);
2069
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
2120
2070
  }
2121
2071
  }
2122
2072
  /**
2123
- * Gets a vector by ID. Returns {id, vector, payload} or null.
2124
- * @param {bigint} id
2073
+ * Text search on payload fields (substring matching).
2074
+ * @param {string} query
2075
+ * @param {number} k
2076
+ * @param {string | null} [field]
2125
2077
  * @returns {any}
2126
2078
  */
2127
- get(id) {
2079
+ text_search(query, k, field) {
2128
2080
  try {
2129
2081
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2130
- wasm.vectorstore_get(retptr, this.__wbg_ptr, id);
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);
2131
2087
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2132
2088
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2133
2089
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2140,285 +2096,996 @@ export class VectorStore {
2140
2096
  }
2141
2097
  }
2142
2098
  /**
2143
- * Returns the number of vectors in the store.
2144
- * @returns {number}
2145
- */
2146
- get len() {
2147
- const ret = wasm.vectorstore_len(this.__wbg_ptr);
2148
- return ret >>> 0;
2149
- }
2150
- /**
2151
- * Creates a new vector store. Metrics: cosine, euclidean, dot, hamming, jaccard.
2099
+ * Creates store with pre-allocated capacity.
2152
2100
  * @param {number} dimension
2153
2101
  * @param {string} metric
2102
+ * @param {number} capacity
2103
+ * @returns {VectorStore}
2154
2104
  */
2155
- constructor(dimension, metric) {
2105
+ static with_capacity(dimension, metric, capacity) {
2156
2106
  try {
2157
2107
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2158
2108
  const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2159
2109
  const len0 = WASM_VECTOR_LEN;
2160
- wasm.vectorstore_new(retptr, dimension, ptr0, len0);
2110
+ wasm.vectorstore_with_capacity(retptr, dimension, ptr0, len0, capacity);
2161
2111
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2162
2112
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2163
2113
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2164
2114
  if (r2) {
2165
2115
  throw takeObject(r1);
2166
2116
  }
2167
- this.__wbg_ptr = r0 >>> 0;
2168
- VectorStoreFinalization.register(this, this.__wbg_ptr, this);
2169
- return this;
2117
+ return VectorStore.__wrap(r0);
2170
2118
  } finally {
2171
2119
  wasm.__wbindgen_add_to_stack_pointer(16);
2172
2120
  }
2173
2121
  }
2174
- /**
2175
- * Loads from `IndexedDB`.
2176
- * @param {string} db_name
2177
- * @returns {Promise<VectorStore>}
2178
- */
2179
- static load(db_name) {
2180
- const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2181
- const len0 = WASM_VECTOR_LEN;
2182
- const ret = wasm.vectorstore_load(ptr0, len0);
2183
- return takeObject(ret);
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;
2184
2148
  }
2185
- /**
2186
- * Saves to `IndexedDB`.
2187
- * @param {string} db_name
2188
- * @returns {Promise<void>}
2189
- */
2190
- save(db_name) {
2191
- const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2192
- const len0 = WASM_VECTOR_LEN;
2193
- const ret = wasm.vectorstore_save(this.__wbg_ptr, ptr0, len0);
2194
- return takeObject(ret);
2149
+ free() {
2150
+ const ptr = this.__destroy_into_raw();
2151
+ wasm.__wbg_velesql_free(ptr, 0);
2195
2152
  }
2196
2153
  /**
2197
- * Clears all vectors from the store.
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}
2198
2159
  */
2199
- clear() {
2200
- wasm.vectorstore_clear(this.__wbg_ptr);
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;
2201
2165
  }
2202
2166
  /**
2203
- * VelesQL-style query returning multi-model results (EPIC-031 US-009).
2204
- *
2205
- * Returns results in `HybridResult` format with `node_id`, `vector_score`,
2206
- * `graph_score`, `fused_score`, `bindings`, and `column_data`.
2207
- *
2208
- * # Arguments
2209
- * * `query_vector` - Query vector for similarity search
2210
- * * `k` - Number of results to return
2167
+ * Parse a `VelesQL` query string.
2211
2168
  *
2212
- * # Returns
2213
- * Array of `{nodeId, vectorScore, graphScore, fusedScore, bindings, columnData}`
2214
- * @param {Float32Array} query_vector
2215
- * @param {number} k
2216
- * @returns {any}
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}
2217
2173
  */
2218
- query(query_vector, k) {
2174
+ static parse(query) {
2219
2175
  try {
2220
2176
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2221
- const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
2177
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2222
2178
  const len0 = WASM_VECTOR_LEN;
2223
- wasm.vectorstore_query(retptr, this.__wbg_ptr, ptr0, len0, k);
2179
+ wasm.velesql_parse(retptr, ptr0, len0);
2224
2180
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2225
2181
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2226
2182
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2227
2183
  if (r2) {
2228
2184
  throw takeObject(r1);
2229
2185
  }
2230
- return takeObject(r0);
2186
+ return ParsedQuery.__wrap(r0);
2231
2187
  } finally {
2232
2188
  wasm.__wbindgen_add_to_stack_pointer(16);
2233
2189
  }
2234
2190
  }
2235
- /**
2236
- * Inserts a vector with the given ID.
2237
- * @param {bigint} id
2238
- * @param {Float32Array} vector
2239
- */
2240
- insert(id, vector) {
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`.
2241
2853
  try {
2242
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2243
- const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
2244
- const len0 = WASM_VECTOR_LEN;
2245
- wasm.vectorstore_insert(retptr, this.__wbg_ptr, id, ptr0, len0);
2246
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2247
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2248
- if (r1) {
2249
- throw takeObject(r0);
2250
- }
2251
- } finally {
2252
- wasm.__wbindgen_add_to_stack_pointer(16);
2854
+ return 'Object(' + JSON.stringify(val) + ')';
2855
+ } catch (_) {
2856
+ return 'Object';
2253
2857
  }
2254
2858
  }
2255
- /**
2256
- * Removes a vector by ID.
2257
- * @param {bigint} id
2258
- * @returns {boolean}
2259
- */
2260
- remove(id) {
2261
- const ret = wasm.vectorstore_remove(this.__wbg_ptr, id);
2262
- return ret !== 0;
2859
+ // errors
2860
+ if (val instanceof Error) {
2861
+ return `${val.name}: ${val.message}\n${val.stack}`;
2263
2862
  }
2264
- /**
2265
- * k-NN search. Returns [[id, score], ...].
2266
- * @param {Float32Array} query
2267
- * @param {number} k
2268
- * @returns {any}
2269
- */
2270
- search(query, k) {
2271
- try {
2272
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2273
- const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
2274
- const len0 = WASM_VECTOR_LEN;
2275
- wasm.vectorstore_search(retptr, this.__wbg_ptr, ptr0, len0, k);
2276
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2277
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2278
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2279
- if (r2) {
2280
- throw takeObject(r1);
2281
- }
2282
- return takeObject(r0);
2283
- } finally {
2284
- wasm.__wbindgen_add_to_stack_pointer(16);
2285
- }
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)));
2286
2879
  }
2287
- /**
2288
- * Pre-allocates memory for additional vectors.
2289
- * @param {number} additional
2290
- */
2291
- reserve(additional) {
2292
- wasm.vectorstore_reserve(this.__wbg_ptr, additional);
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);
2293
2897
  }
2294
- /**
2295
- * Returns true if the store is empty.
2296
- * @returns {boolean}
2297
- */
2298
- get is_empty() {
2299
- const ret = wasm.vectorstore_is_empty(this.__wbg_ptr);
2300
- return ret !== 0;
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);
2301
2905
  }
2302
- /**
2303
- * Returns the vector dimension.
2304
- * @returns {number}
2305
- */
2306
- get dimension() {
2307
- const ret = wasm.vectorstore_dimension(this.__wbg_ptr);
2308
- return ret >>> 0;
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);
2309
2913
  }
2914
+ return cachedFloat32ArrayMemory0;
2310
2915
  }
2311
- if (Symbol.dispose) VectorStore.prototype[Symbol.dispose] = VectorStore.prototype.free;
2312
2916
 
2313
- /**
2314
- * `VelesQL` query parser for browser use.
2315
- *
2316
- * # Example (JavaScript)
2317
- *
2318
- * ```javascript
2319
- * import { VelesQL } from 'velesdb-wasm';
2320
- *
2321
- * // Parse a query
2322
- * const parsed = VelesQL.parse("SELECT * FROM docs WHERE category = 'tech' LIMIT 10");
2323
- * console.log(parsed.tableName); // "docs"
2324
- * console.log(parsed.isValid); // true
2325
- *
2326
- * // Validate without parsing
2327
- * const valid = VelesQL.isValid("SELECT * FROM docs"); // true
2328
- * ```
2329
- */
2330
- export class VelesQL {
2331
- __destroy_into_raw() {
2332
- const ptr = this.__wbg_ptr;
2333
- this.__wbg_ptr = 0;
2334
- VelesQLFinalization.unregister(this);
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);
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;
2335
3012
  return ptr;
2336
3013
  }
2337
- free() {
2338
- const ptr = this.__destroy_into_raw();
2339
- wasm.__wbg_velesql_free(ptr, 0);
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;
2340
3026
  }
2341
- /**
2342
- * Parse a `VelesQL` query string.
2343
- *
2344
- * Returns a `ParsedQuery` object with query introspection methods.
2345
- * Throws an error if the query has syntax errors.
2346
- * @param {string} query
2347
- * @returns {ParsedQuery}
2348
- */
2349
- static parse(query) {
2350
- try {
2351
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2352
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2353
- const len0 = WASM_VECTOR_LEN;
2354
- wasm.velesql_parse(retptr, ptr0, len0);
2355
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2356
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2357
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2358
- if (r2) {
2359
- throw takeObject(r1);
2360
- }
2361
- return ParsedQuery.__wrap(r0);
2362
- } finally {
2363
- wasm.__wbindgen_add_to_stack_pointer(16);
3027
+ if (offset !== len) {
3028
+ if (offset !== 0) {
3029
+ arg = arg.slice(offset);
2364
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;
2365
3037
  }
2366
- /**
2367
- * Validate a `VelesQL` query without full parsing.
2368
- *
2369
- * This is faster than `parse()` when you only need to check validity.
2370
- * @param {string} query
2371
- * @returns {boolean}
2372
- */
2373
- static isValid(query) {
2374
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2375
- const len0 = WASM_VECTOR_LEN;
2376
- const ret = wasm.velesql_isValid(ptr0, len0);
2377
- return ret !== 0;
2378
- }
3038
+
3039
+ WASM_VECTOR_LEN = offset;
3040
+ return ptr;
2379
3041
  }
2380
- if (Symbol.dispose) VelesQL.prototype[Symbol.dispose] = VelesQL.prototype.free;
2381
3042
 
2382
- /**
2383
- * Estimates the number of nodes that will be visited during traversal.
2384
- *
2385
- * Uses a heuristic based on graph density and max depth.
2386
- * @param {number} node_count
2387
- * @param {number} edge_count
2388
- * @param {number} max_depth
2389
- * @returns {number}
2390
- */
2391
- export function estimate_traversal_size(node_count, edge_count, max_depth) {
2392
- const ret = wasm.estimate_traversal_size(node_count, edge_count, max_depth);
2393
- return ret >>> 0;
3043
+ function takeObject(idx) {
3044
+ const ret = getObject(idx);
3045
+ dropObject(idx);
3046
+ return ret;
2394
3047
  }
2395
3048
 
2396
- /**
2397
- * Determines whether a traversal should be offloaded to a Web Worker.
2398
- *
2399
- * # Arguments
2400
- * * `node_count` - Total nodes in the graph
2401
- * * `max_depth` - Maximum traversal depth requested
2402
- * * `config` - Optional configuration (uses defaults if None)
2403
- *
2404
- * # Returns
2405
- * `true` if the operation should use a Web Worker
2406
- * @param {number} node_count
2407
- * @param {number} max_depth
2408
- * @param {GraphWorkerConfig | null} [config]
2409
- * @returns {boolean}
2410
- */
2411
- export function should_use_worker(node_count, max_depth, config) {
2412
- let ptr0 = 0;
2413
- if (!isLikeNone(config)) {
2414
- _assertClass(config, GraphWorkerConfig);
2415
- ptr0 = config.__destroy_into_raw();
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;
2416
3059
  }
2417
- const ret = wasm.should_use_worker(node_count, max_depth, ptr0);
2418
- return ret !== 0;
3060
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
3061
+ }
3062
+
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
+ };
2419
3074
  }
2420
3075
 
2421
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
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
+ }
2422
3089
 
2423
3090
  async function __wbg_load(module, imports) {
2424
3091
  if (typeof Response === 'function' && module instanceof Response) {
@@ -2426,14 +3093,12 @@ async function __wbg_load(module, imports) {
2426
3093
  try {
2427
3094
  return await WebAssembly.instantiateStreaming(module, imports);
2428
3095
  } catch (e) {
2429
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
3096
+ const validResponse = module.ok && expectedResponseType(module.type);
2430
3097
 
2431
3098
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2432
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);
2433
3100
 
2434
- } else {
2435
- throw e;
2436
- }
3101
+ } else { throw e; }
2437
3102
  }
2438
3103
  }
2439
3104
 
@@ -2448,466 +3113,20 @@ async function __wbg_load(module, imports) {
2448
3113
  return instance;
2449
3114
  }
2450
3115
  }
2451
- }
2452
3116
 
2453
- function __wbg_get_imports() {
2454
- const imports = {};
2455
- imports.wbg = {};
2456
- imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
2457
- const ret = Error(getStringFromWasm0(arg0, arg1));
2458
- return addHeapObject(ret);
2459
- };
2460
- imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
2461
- const ret = Number(getObject(arg0));
2462
- return ret;
2463
- };
2464
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
2465
- const ret = String(getObject(arg1));
2466
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2467
- const len1 = WASM_VECTOR_LEN;
2468
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2469
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2470
- };
2471
- imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
2472
- const v = getObject(arg1);
2473
- const ret = typeof(v) === 'bigint' ? v : undefined;
2474
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2475
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2476
- };
2477
- imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
2478
- const v = getObject(arg0);
2479
- const ret = typeof(v) === 'boolean' ? v : undefined;
2480
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2481
- };
2482
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
2483
- const ret = debugString(getObject(arg1));
2484
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2485
- const len1 = WASM_VECTOR_LEN;
2486
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2487
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2488
- };
2489
- imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
2490
- const ret = getObject(arg0) in getObject(arg1);
2491
- return ret;
2492
- };
2493
- imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
2494
- const ret = typeof(getObject(arg0)) === 'bigint';
2495
- return ret;
2496
- };
2497
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
2498
- const ret = typeof(getObject(arg0)) === 'function';
2499
- return ret;
2500
- };
2501
- imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
2502
- const ret = getObject(arg0) === null;
2503
- return ret;
2504
- };
2505
- imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
2506
- const val = getObject(arg0);
2507
- const ret = typeof(val) === 'object' && val !== null;
2508
- return ret;
2509
- };
2510
- imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
2511
- const ret = typeof(getObject(arg0)) === 'string';
2512
- return ret;
2513
- };
2514
- imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
2515
- const ret = getObject(arg0) === undefined;
2516
- return ret;
2517
- };
2518
- imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
2519
- const ret = getObject(arg0) === getObject(arg1);
2520
- return ret;
2521
- };
2522
- imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
2523
- const ret = getObject(arg0) == getObject(arg1);
2524
- return ret;
2525
- };
2526
- imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
2527
- const obj = getObject(arg1);
2528
- const ret = typeof(obj) === 'number' ? obj : undefined;
2529
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2530
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2531
- };
2532
- imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
2533
- const obj = getObject(arg1);
2534
- const ret = typeof(obj) === 'string' ? obj : undefined;
2535
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2536
- var len1 = WASM_VECTOR_LEN;
2537
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2538
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2539
- };
2540
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
2541
- throw new Error(getStringFromWasm0(arg0, arg1));
2542
- };
2543
- imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
2544
- getObject(arg0)._wbg_cb_unref();
2545
- };
2546
- imports.wbg.__wbg_bound_dd83af44245de95e = function() { return handleError(function (arg0, arg1) {
2547
- const ret = IDBKeyRange.bound(getObject(arg0), getObject(arg1));
2548
- return addHeapObject(ret);
2549
- }, arguments) };
2550
- imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
2551
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2552
- return addHeapObject(ret);
2553
- }, arguments) };
2554
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
2555
- const ret = getObject(arg0).call(getObject(arg1));
2556
- return addHeapObject(ret);
2557
- }, arguments) };
2558
- imports.wbg.__wbg_createObjectStore_dba64acfe84d4191 = function() { return handleError(function (arg0, arg1, arg2) {
2559
- const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
2560
- return addHeapObject(ret);
2561
- }, arguments) };
2562
- imports.wbg.__wbg_deleteDatabase_19c91a8e3e6b92cf = function() { return handleError(function (arg0, arg1, arg2) {
2563
- const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
2564
- return addHeapObject(ret);
2565
- }, arguments) };
2566
- imports.wbg.__wbg_delete_a8cf58aab29e18d2 = function() { return handleError(function (arg0, arg1) {
2567
- const ret = getObject(arg0).delete(getObject(arg1));
2568
- return addHeapObject(ret);
2569
- }, arguments) };
2570
- imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
2571
- const ret = getObject(arg0).done;
2572
- return ret;
2573
- };
2574
- imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
2575
- const ret = Object.entries(getObject(arg0));
2576
- return addHeapObject(ret);
2577
- };
2578
- imports.wbg.__wbg_getAllKeys_925405ffbd671e86 = function() { return handleError(function (arg0) {
2579
- const ret = getObject(arg0).getAllKeys();
2580
- return addHeapObject(ret);
2581
- }, arguments) };
2582
- imports.wbg.__wbg_getAll_48e288420773a079 = function() { return handleError(function (arg0, arg1) {
2583
- const ret = getObject(arg0).getAll(getObject(arg1));
2584
- return addHeapObject(ret);
2585
- }, arguments) };
2586
- imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
2587
- const ret = getObject(arg0)[arg1 >>> 0];
2588
- return addHeapObject(ret);
2589
- };
2590
- imports.wbg.__wbg_get_7d8b665fa88606d5 = function() { return handleError(function (arg0, arg1) {
2591
- const ret = getObject(arg0).get(getObject(arg1));
2592
- return addHeapObject(ret);
2593
- }, arguments) };
2594
- imports.wbg.__wbg_get_985f6dca0ce6b776 = function(arg0, arg1, arg2) {
2595
- const ret = getObject(arg1)[arg2 >>> 0];
2596
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2597
- var len1 = WASM_VECTOR_LEN;
2598
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2599
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2600
- };
2601
- imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
2602
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
2603
- return addHeapObject(ret);
2604
- }, arguments) };
2605
- imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
2606
- const ret = getObject(arg0)[getObject(arg1)];
2607
- return addHeapObject(ret);
2608
- };
2609
- imports.wbg.__wbg_graphedge_new = function(arg0) {
2610
- const ret = GraphEdge.__wrap(arg0);
2611
- return addHeapObject(ret);
2612
- };
2613
- imports.wbg.__wbg_graphnode_new = function(arg0) {
2614
- const ret = GraphNode.__wrap(arg0);
2615
- return addHeapObject(ret);
2616
- };
2617
- imports.wbg.__wbg_graphstore_new = function(arg0) {
2618
- const ret = GraphStore.__wrap(arg0);
2619
- return addHeapObject(ret);
2620
- };
2621
- imports.wbg.__wbg_indexedDB_23c232e00a1e28ad = function() { return handleError(function (arg0) {
2622
- const ret = getObject(arg0).indexedDB;
2623
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
2624
- }, arguments) };
2625
- imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
2626
- let result;
2627
- try {
2628
- result = getObject(arg0) instanceof ArrayBuffer;
2629
- } catch (_) {
2630
- result = false;
2631
- }
2632
- const ret = result;
2633
- return ret;
2634
- };
2635
- imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
2636
- let result;
2637
- try {
2638
- result = getObject(arg0) instanceof Map;
2639
- } catch (_) {
2640
- result = false;
2641
- }
2642
- const ret = result;
2643
- return ret;
2644
- };
2645
- imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
2646
- let result;
2647
- try {
2648
- result = getObject(arg0) instanceof Uint8Array;
2649
- } catch (_) {
2650
- result = false;
2651
- }
2652
- const ret = result;
2653
- return ret;
2654
- };
2655
- imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) {
2656
- let result;
2657
- try {
2658
- result = getObject(arg0) instanceof Window;
2659
- } catch (_) {
2660
- result = false;
2661
- }
2662
- const ret = result;
2663
- return ret;
2664
- };
2665
- imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
2666
- const ret = Array.isArray(getObject(arg0));
2667
- return ret;
2668
- };
2669
- imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
2670
- const ret = Number.isSafeInteger(getObject(arg0));
2671
- return ret;
2672
- };
2673
- imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
2674
- const ret = Symbol.iterator;
2675
- return addHeapObject(ret);
2676
- };
2677
- imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
2678
- const ret = getObject(arg0).length;
2679
- return ret;
2680
- };
2681
- imports.wbg.__wbg_length_9f7c82a979890e31 = function(arg0) {
2682
- const ret = getObject(arg0).length;
2683
- return ret;
2684
- };
2685
- imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
2686
- const ret = getObject(arg0).length;
2687
- return ret;
2688
- };
2689
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
2690
- const ret = new Object();
2691
- return addHeapObject(ret);
2692
- };
2693
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
2694
- const ret = new Array();
2695
- return addHeapObject(ret);
2696
- };
2697
- imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
2698
- const ret = new Uint8Array(getObject(arg0));
2699
- return addHeapObject(ret);
2700
- };
2701
- imports.wbg.__wbg_new_b546ae120718850e = function() {
2702
- const ret = new Map();
2703
- return addHeapObject(ret);
2704
- };
2705
- imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
2706
- try {
2707
- var state0 = {a: arg0, b: arg1};
2708
- var cb0 = (arg0, arg1) => {
2709
- const a = state0.a;
2710
- state0.a = 0;
2711
- try {
2712
- return __wasm_bindgen_func_elem_1217(a, state0.b, arg0, arg1);
2713
- } finally {
2714
- state0.a = a;
2715
- }
2716
- };
2717
- const ret = new Promise(cb0);
2718
- return addHeapObject(ret);
2719
- } finally {
2720
- state0.a = state0.b = 0;
3117
+ function expectedResponseType(type) {
3118
+ switch (type) {
3119
+ case 'basic': case 'cors': case 'default': return true;
2721
3120
  }
2722
- };
2723
- imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
2724
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2725
- return addHeapObject(ret);
2726
- };
2727
- imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
2728
- const ret = new Function(getStringFromWasm0(arg0, arg1));
2729
- return addHeapObject(ret);
2730
- };
2731
- imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
2732
- const ret = getObject(arg0).next;
2733
- return addHeapObject(ret);
2734
- };
2735
- imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
2736
- const ret = getObject(arg0).next();
2737
- return addHeapObject(ret);
2738
- }, arguments) };
2739
- imports.wbg.__wbg_now_69d776cd24f5215b = function() {
2740
- const ret = Date.now();
2741
- return ret;
2742
- };
2743
- imports.wbg.__wbg_objectStoreNames_90900f9a531513ac = function(arg0) {
2744
- const ret = getObject(arg0).objectStoreNames;
2745
- return addHeapObject(ret);
2746
- };
2747
- imports.wbg.__wbg_objectStore_da9a077b8849dbe9 = function() { return handleError(function (arg0, arg1, arg2) {
2748
- const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
2749
- return addHeapObject(ret);
2750
- }, arguments) };
2751
- imports.wbg.__wbg_open_0d7b85f4c0a38ffe = function() { return handleError(function (arg0, arg1, arg2, arg3) {
2752
- const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
2753
- return addHeapObject(ret);
2754
- }, arguments) };
2755
- imports.wbg.__wbg_open_2a2740c93beabe29 = function() { return handleError(function (arg0, arg1, arg2) {
2756
- const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
2757
- return addHeapObject(ret);
2758
- }, arguments) };
2759
- imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
2760
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2761
- };
2762
- imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
2763
- const ret = getObject(arg0).push(getObject(arg1));
2764
- return ret;
2765
- };
2766
- imports.wbg.__wbg_put_d40a68e5a8902a46 = function() { return handleError(function (arg0, arg1, arg2) {
2767
- const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
2768
- return addHeapObject(ret);
2769
- }, arguments) };
2770
- imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
2771
- const ret = getObject(arg0).queueMicrotask;
2772
- return addHeapObject(ret);
2773
- };
2774
- imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
2775
- queueMicrotask(getObject(arg0));
2776
- };
2777
- imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
2778
- const ret = Promise.resolve(getObject(arg0));
2779
- return addHeapObject(ret);
2780
- };
2781
- imports.wbg.__wbg_result_084f962aedb54250 = function() { return handleError(function (arg0) {
2782
- const ret = getObject(arg0).result;
2783
- return addHeapObject(ret);
2784
- }, arguments) };
2785
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
2786
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2787
- };
2788
- imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
2789
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2790
- };
2791
- imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
2792
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2793
- return addHeapObject(ret);
2794
- };
2795
- imports.wbg.__wbg_set_onerror_08fecec3bdc9d24d = function(arg0, arg1) {
2796
- getObject(arg0).onerror = getObject(arg1);
2797
- };
2798
- imports.wbg.__wbg_set_onsuccess_94332a00452de699 = function(arg0, arg1) {
2799
- getObject(arg0).onsuccess = getObject(arg1);
2800
- };
2801
- imports.wbg.__wbg_set_onupgradeneeded_3dc6e233a6d13fe2 = function(arg0, arg1) {
2802
- getObject(arg0).onupgradeneeded = getObject(arg1);
2803
- };
2804
- imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
2805
- const ret = typeof global === 'undefined' ? null : global;
2806
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
2807
- };
2808
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
2809
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
2810
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
2811
- };
2812
- imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
2813
- const ret = typeof self === 'undefined' ? null : self;
2814
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
2815
- };
2816
- imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
2817
- const ret = typeof window === 'undefined' ? null : window;
2818
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
2819
- };
2820
- imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
2821
- const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
2822
- return addHeapObject(ret);
2823
- };
2824
- imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
2825
- const ret = getObject(arg0).then(getObject(arg1));
2826
- return addHeapObject(ret);
2827
- };
2828
- imports.wbg.__wbg_transaction_257422def49a0094 = function() { return handleError(function (arg0, arg1, arg2) {
2829
- const ret = getObject(arg0).transaction(getObject(arg1), __wbindgen_enum_IdbTransactionMode[arg2]);
2830
- return addHeapObject(ret);
2831
- }, arguments) };
2832
- imports.wbg.__wbg_transaction_754344c3ae25fdcf = function() { return handleError(function (arg0, arg1, arg2) {
2833
- const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2));
2834
- return addHeapObject(ret);
2835
- }, arguments) };
2836
- imports.wbg.__wbg_transaction_790ec170b8fbc74b = function() { return handleError(function (arg0, arg1, arg2, arg3) {
2837
- const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
2838
- return addHeapObject(ret);
2839
- }, arguments) };
2840
- imports.wbg.__wbg_transaction_f32b8e1d5f304f61 = function() { return handleError(function (arg0, arg1) {
2841
- const ret = getObject(arg0).transaction(getObject(arg1));
2842
- return addHeapObject(ret);
2843
- }, arguments) };
2844
- imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
2845
- const ret = getObject(arg0).value;
2846
- return addHeapObject(ret);
2847
- };
2848
- imports.wbg.__wbg_vectorstore_new = function(arg0) {
2849
- const ret = VectorStore.__wrap(arg0);
2850
- return addHeapObject(ret);
2851
- };
2852
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
2853
- // Cast intrinsic for `Ref(String) -> Externref`.
2854
- const ret = getStringFromWasm0(arg0, arg1);
2855
- return addHeapObject(ret);
2856
- };
2857
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
2858
- // Cast intrinsic for `U64 -> Externref`.
2859
- const ret = BigInt.asUintN(64, arg0);
2860
- return addHeapObject(ret);
2861
- };
2862
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
2863
- // Cast intrinsic for `I64 -> Externref`.
2864
- const ret = arg0;
2865
- return addHeapObject(ret);
2866
- };
2867
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
2868
- // Cast intrinsic for `F64 -> Externref`.
2869
- const ret = arg0;
2870
- return addHeapObject(ret);
2871
- };
2872
- imports.wbg.__wbindgen_cast_f1c9170db27db6a8 = function(arg0, arg1) {
2873
- // Cast intrinsic for `Closure(Closure { dtor_idx: 125, function: Function { arguments: [Externref], shim_idx: 126, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2874
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1175, __wasm_bindgen_func_elem_1176);
2875
- return addHeapObject(ret);
2876
- };
2877
- imports.wbg.__wbindgen_cast_fdfac116b4bf22c8 = function(arg0, arg1) {
2878
- // 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`.
2879
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_264, __wasm_bindgen_func_elem_265);
2880
- return addHeapObject(ret);
2881
- };
2882
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
2883
- const ret = getObject(arg0);
2884
- return addHeapObject(ret);
2885
- };
2886
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
2887
- takeObject(arg0);
2888
- };
2889
-
2890
- return imports;
2891
- }
2892
-
2893
- function __wbg_finalize_init(instance, module) {
2894
- wasm = instance.exports;
2895
- __wbg_init.__wbindgen_wasm_module = module;
2896
- cachedBigUint64ArrayMemory0 = null;
2897
- cachedDataViewMemory0 = null;
2898
- cachedFloat32ArrayMemory0 = null;
2899
- cachedUint8ArrayMemory0 = null;
2900
-
2901
-
2902
-
2903
- return wasm;
3121
+ return false;
3122
+ }
2904
3123
  }
2905
3124
 
2906
3125
  function initSync(module) {
2907
3126
  if (wasm !== undefined) return wasm;
2908
3127
 
2909
3128
 
2910
- if (typeof module !== 'undefined') {
3129
+ if (module !== undefined) {
2911
3130
  if (Object.getPrototypeOf(module) === Object.prototype) {
2912
3131
  ({module} = module)
2913
3132
  } else {
@@ -2927,7 +3146,7 @@ async function __wbg_init(module_or_path) {
2927
3146
  if (wasm !== undefined) return wasm;
2928
3147
 
2929
3148
 
2930
- if (typeof module_or_path !== 'undefined') {
3149
+ if (module_or_path !== undefined) {
2931
3150
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2932
3151
  ({module_or_path} = module_or_path)
2933
3152
  } else {
@@ -2935,7 +3154,7 @@ async function __wbg_init(module_or_path) {
2935
3154
  }
2936
3155
  }
2937
3156
 
2938
- if (typeof module_or_path === 'undefined') {
3157
+ if (module_or_path === undefined) {
2939
3158
  module_or_path = new URL('velesdb_wasm_bg.wasm', import.meta.url);
2940
3159
  }
2941
3160
  const imports = __wbg_get_imports();
@@ -2949,5 +3168,4 @@ async function __wbg_init(module_or_path) {
2949
3168
  return __wbg_finalize_init(instance, module);
2950
3169
  }
2951
3170
 
2952
- export { initSync };
2953
- export default __wbg_init;
3171
+ export { initSync, __wbg_init as default };