@wiscale/velesdb-wasm 1.4.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
 
@@ -1101,15 +767,47 @@ export class GraphWorkerConfig {
1101
767
  GraphWorkerConfigFinalization.register(obj, obj.__wbg_ptr, obj);
1102
768
  return obj;
1103
769
  }
1104
- __destroy_into_raw() {
1105
- const ptr = this.__wbg_ptr;
1106
- this.__wbg_ptr = 0;
1107
- GraphWorkerConfigFinalization.unregister(this);
1108
- return ptr;
770
+ __destroy_into_raw() {
771
+ const ptr = this.__wbg_ptr;
772
+ this.__wbg_ptr = 0;
773
+ GraphWorkerConfigFinalization.unregister(this);
774
+ return ptr;
775
+ }
776
+ free() {
777
+ const ptr = this.__destroy_into_raw();
778
+ wasm.__wbg_graphworkerconfig_free(ptr, 0);
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;
1109
803
  }
1110
- free() {
1111
- const ptr = this.__destroy_into_raw();
1112
- wasm.__wbg_graphworkerconfig_free(ptr, 0);
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;
1113
811
  }
1114
812
  /**
1115
813
  * Creates a configuration optimized for large graphs.
@@ -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,12 @@ 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 — **WASM limitation**: PQ requires `rayon`/`persistence`
1370
+ * which are unavailable in WASM. This variant uses the SQ8 codepath as a
1371
+ * fallback. For true PQ, use the native `velesdb-core` crate.
1372
+ */
1373
+ ProductQuantization: 3, "3": "ProductQuantization",
1613
1374
  });
1614
1375
 
1615
1376
  /**
@@ -1627,118 +1388,118 @@ export class TraversalProgress {
1627
1388
  wasm.__wbg_traversalprogress_free(ptr, 0);
1628
1389
  }
1629
1390
  /**
1630
- * Returns the completion percentage (0-100).
1391
+ * Current traversal depth.
1631
1392
  * @returns {number}
1632
1393
  */
1633
- get percentage() {
1634
- const ret = wasm.traversalprogress_percentage(this.__wbg_ptr);
1635
- return ret;
1394
+ get current_depth() {
1395
+ const ret = wasm.__wbg_get_traversalprogress_current_depth(this.__wbg_ptr);
1396
+ return ret >>> 0;
1636
1397
  }
1637
1398
  /**
1638
- * Creates a new progress report.
1639
- * @param {number} visited
1640
- * @param {number} estimated
1641
- * @param {number} depth
1399
+ * Estimated total nodes to visit (heuristic).
1400
+ * @returns {number}
1642
1401
  */
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;
1402
+ get estimated_total() {
1403
+ const ret = wasm.__wbg_get_traversalprogress_estimated_total(this.__wbg_ptr);
1404
+ return ret >>> 0;
1648
1405
  }
1649
1406
  /**
1650
- * Converts to JSON for postMessage.
1651
- * @returns {any}
1407
+ * Whether the traversal was cancelled.
1408
+ * @returns {boolean}
1652
1409
  */
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
- }
1410
+ get is_cancelled() {
1411
+ const ret = wasm.__wbg_get_traversalprogress_is_cancelled(this.__wbg_ptr);
1412
+ return ret !== 0;
1413
+ }
1414
+ /**
1415
+ * Whether the traversal is complete.
1416
+ * @returns {boolean}
1417
+ */
1418
+ get is_complete() {
1419
+ const ret = wasm.__wbg_get_traversalprogress_is_complete(this.__wbg_ptr);
1420
+ return ret !== 0;
1667
1421
  }
1668
1422
  /**
1669
1423
  * Number of nodes visited so far.
1670
1424
  * @returns {number}
1671
1425
  */
1672
1426
  get visited_count() {
1673
- const ret = wasm.__wbg_get_graphworkerconfig_node_threshold(this.__wbg_ptr);
1427
+ const ret = wasm.__wbg_get_traversalprogress_visited_count(this.__wbg_ptr);
1674
1428
  return ret >>> 0;
1675
1429
  }
1676
1430
  /**
1677
- * Number of nodes visited so far.
1431
+ * Current traversal depth.
1678
1432
  * @param {number} arg0
1679
1433
  */
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;
1434
+ set current_depth(arg0) {
1435
+ wasm.__wbg_set_traversalprogress_current_depth(this.__wbg_ptr, arg0);
1690
1436
  }
1691
1437
  /**
1692
1438
  * Estimated total nodes to visit (heuristic).
1693
1439
  * @param {number} arg0
1694
1440
  */
1695
1441
  set estimated_total(arg0) {
1696
- wasm.__wbg_set_graphworkerconfig_depth_threshold(this.__wbg_ptr, arg0);
1442
+ wasm.__wbg_set_traversalprogress_estimated_total(this.__wbg_ptr, arg0);
1697
1443
  }
1698
1444
  /**
1699
- * Current traversal depth.
1700
- * @returns {number}
1445
+ * Whether the traversal was cancelled.
1446
+ * @param {boolean} arg0
1701
1447
  */
1702
- get current_depth() {
1703
- const ret = wasm.__wbg_get_graphworkerconfig_progress_interval_ms(this.__wbg_ptr);
1704
- return ret >>> 0;
1448
+ set is_cancelled(arg0) {
1449
+ wasm.__wbg_set_traversalprogress_is_cancelled(this.__wbg_ptr, arg0);
1705
1450
  }
1706
1451
  /**
1707
- * Current traversal depth.
1708
- * @param {number} arg0
1452
+ * Whether the traversal is complete.
1453
+ * @param {boolean} arg0
1709
1454
  */
1710
- set current_depth(arg0) {
1711
- wasm.__wbg_set_graphworkerconfig_progress_interval_ms(this.__wbg_ptr, arg0);
1455
+ set is_complete(arg0) {
1456
+ wasm.__wbg_set_traversalprogress_is_complete(this.__wbg_ptr, arg0);
1712
1457
  }
1713
1458
  /**
1714
- * Whether the traversal is complete.
1715
- * @returns {boolean}
1459
+ * Number of nodes visited so far.
1460
+ * @param {number} arg0
1716
1461
  */
1717
- get is_complete() {
1718
- const ret = wasm.__wbg_get_graphworkerconfig_use_shared_buffer(this.__wbg_ptr);
1719
- return ret !== 0;
1462
+ set visited_count(arg0) {
1463
+ wasm.__wbg_set_traversalprogress_visited_count(this.__wbg_ptr, arg0);
1720
1464
  }
1721
1465
  /**
1722
- * Whether the traversal is complete.
1723
- * @param {boolean} arg0
1466
+ * Creates a new progress report.
1467
+ * @param {number} visited
1468
+ * @param {number} estimated
1469
+ * @param {number} depth
1724
1470
  */
1725
- set is_complete(arg0) {
1726
- wasm.__wbg_set_graphworkerconfig_use_shared_buffer(this.__wbg_ptr, arg0);
1471
+ constructor(visited, estimated, depth) {
1472
+ const ret = wasm.traversalprogress_new(visited, estimated, depth);
1473
+ this.__wbg_ptr = ret >>> 0;
1474
+ TraversalProgressFinalization.register(this, this.__wbg_ptr, this);
1475
+ return this;
1727
1476
  }
1728
1477
  /**
1729
- * Whether the traversal was cancelled.
1730
- * @returns {boolean}
1731
- */
1732
- get is_cancelled() {
1733
- const ret = wasm.__wbg_get_traversalprogress_is_cancelled(this.__wbg_ptr);
1734
- return ret !== 0;
1478
+ * Returns the completion percentage (0-100).
1479
+ * @returns {number}
1480
+ */
1481
+ get percentage() {
1482
+ const ret = wasm.traversalprogress_percentage(this.__wbg_ptr);
1483
+ return ret;
1735
1484
  }
1736
1485
  /**
1737
- * Whether the traversal was cancelled.
1738
- * @param {boolean} arg0
1486
+ * Converts to JSON for postMessage.
1487
+ * @returns {any}
1739
1488
  */
1740
- set is_cancelled(arg0) {
1741
- wasm.__wbg_set_traversalprogress_is_cancelled(this.__wbg_ptr, arg0);
1489
+ to_json() {
1490
+ try {
1491
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1492
+ wasm.traversalprogress_to_json(retptr, this.__wbg_ptr);
1493
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1494
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1495
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1496
+ if (r2) {
1497
+ throw takeObject(r1);
1498
+ }
1499
+ return takeObject(r0);
1500
+ } finally {
1501
+ wasm.__wbindgen_add_to_stack_pointer(16);
1502
+ }
1742
1503
  }
1743
1504
  }
1744
1505
  if (Symbol.dispose) TraversalProgress.prototype[Symbol.dispose] = TraversalProgress.prototype.free;
@@ -1777,20 +1538,18 @@ export class VectorStore {
1777
1538
  wasm.__wbg_vectorstore_free(ptr, 0);
1778
1539
  }
1779
1540
  /**
1780
- * Text search on payload fields (substring matching).
1781
- * @param {string} query
1541
+ * Batch search for multiple vectors. Returns [[[id, score], ...], ...].
1542
+ * @param {Float32Array} vectors
1543
+ * @param {number} num_vectors
1782
1544
  * @param {number} k
1783
- * @param {string | null} [field]
1784
1545
  * @returns {any}
1785
1546
  */
1786
- text_search(query, k, field) {
1547
+ batch_search(vectors, num_vectors, k) {
1787
1548
  try {
1788
1549
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1789
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1550
+ const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1790
1551
  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);
1552
+ wasm.vectorstore_batch_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k);
1794
1553
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1795
1554
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1796
1555
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1803,18 +1562,99 @@ export class VectorStore {
1803
1562
  }
1804
1563
  }
1805
1564
  /**
1806
- * Batch search for multiple vectors. Returns [[[id, score], ...], ...].
1807
- * @param {Float32Array} vectors
1808
- * @param {number} num_vectors
1565
+ * Clears all vectors from the store.
1566
+ */
1567
+ clear() {
1568
+ wasm.vectorstore_clear(this.__wbg_ptr);
1569
+ }
1570
+ /**
1571
+ * Deletes `IndexedDB` database.
1572
+ * @param {string} db_name
1573
+ * @returns {Promise<void>}
1574
+ */
1575
+ static delete_database(db_name) {
1576
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1577
+ const len0 = WASM_VECTOR_LEN;
1578
+ const ret = wasm.vectorstore_delete_database(ptr0, len0);
1579
+ return takeObject(ret);
1580
+ }
1581
+ /**
1582
+ * Returns the vector dimension.
1583
+ * @returns {number}
1584
+ */
1585
+ get dimension() {
1586
+ const ret = wasm.vectorstore_dimension(this.__wbg_ptr);
1587
+ return ret >>> 0;
1588
+ }
1589
+ /**
1590
+ * Exports to binary format for IndexedDB/localStorage.
1591
+ * @returns {Uint8Array}
1592
+ */
1593
+ export_to_bytes() {
1594
+ try {
1595
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1596
+ wasm.vectorstore_export_to_bytes(retptr, this.__wbg_ptr);
1597
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1598
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1599
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1600
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1601
+ if (r3) {
1602
+ throw takeObject(r2);
1603
+ }
1604
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1605
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1606
+ return v1;
1607
+ } finally {
1608
+ wasm.__wbindgen_add_to_stack_pointer(16);
1609
+ }
1610
+ }
1611
+ /**
1612
+ * Gets a vector by ID. Returns {id, vector, payload} or null.
1613
+ * @param {bigint} id
1614
+ * @returns {any}
1615
+ */
1616
+ get(id) {
1617
+ try {
1618
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1619
+ wasm.vectorstore_get(retptr, this.__wbg_ptr, id);
1620
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1621
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1622
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1623
+ if (r2) {
1624
+ throw takeObject(r1);
1625
+ }
1626
+ return takeObject(r0);
1627
+ } finally {
1628
+ wasm.__wbindgen_add_to_stack_pointer(16);
1629
+ }
1630
+ }
1631
+ /**
1632
+ * Hybrid search (vector + text). `vector_weight` 0-1 (default 0.5).
1633
+ *
1634
+ * For `Full` storage mode, this computes per-vector distance and text
1635
+ * matching in a single pass. For quantized modes (`SQ8`, `Binary`,
1636
+ * `ProductQuantization`), a decomposed approach is used: vector scores
1637
+ * are obtained via the quantization-aware `compute_scores` path, text
1638
+ * matches are evaluated independently on payloads, and the two result
1639
+ * sets are fused with the requested weight. Quantized vector scores are
1640
+ * approximate, so recall may differ slightly from `Full` mode.
1641
+ *
1642
+ * Returns `[{id, score, payload}, ...]` sorted by combined score
1643
+ * descending, truncated to `k` results.
1644
+ * @param {Float32Array} query_vector
1645
+ * @param {string} text_query
1809
1646
  * @param {number} k
1647
+ * @param {number | null} [vector_weight]
1810
1648
  * @returns {any}
1811
1649
  */
1812
- batch_search(vectors, num_vectors, k) {
1650
+ hybrid_search(query_vector, text_query, k, vector_weight) {
1813
1651
  try {
1814
1652
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1815
- const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1653
+ const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1816
1654
  const len0 = WASM_VECTOR_LEN;
1817
- wasm.vectorstore_batch_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k);
1655
+ const ptr1 = passStringToWasm0(text_query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1656
+ const len1 = WASM_VECTOR_LEN;
1657
+ wasm.vectorstore_hybrid_search(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, k, isLikeNone(vector_weight) ? 0x100000001 : Math.fround(vector_weight));
1818
1658
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1819
1659
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1820
1660
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1826,6 +1666,48 @@ export class VectorStore {
1826
1666
  wasm.__wbindgen_add_to_stack_pointer(16);
1827
1667
  }
1828
1668
  }
1669
+ /**
1670
+ * Imports from binary format.
1671
+ * @param {Uint8Array} bytes
1672
+ * @returns {VectorStore}
1673
+ */
1674
+ static import_from_bytes(bytes) {
1675
+ try {
1676
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1677
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1678
+ const len0 = WASM_VECTOR_LEN;
1679
+ wasm.vectorstore_import_from_bytes(retptr, ptr0, len0);
1680
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1681
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1682
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1683
+ if (r2) {
1684
+ throw takeObject(r1);
1685
+ }
1686
+ return VectorStore.__wrap(r0);
1687
+ } finally {
1688
+ wasm.__wbindgen_add_to_stack_pointer(16);
1689
+ }
1690
+ }
1691
+ /**
1692
+ * Inserts a vector with the given ID.
1693
+ * @param {bigint} id
1694
+ * @param {Float32Array} vector
1695
+ */
1696
+ insert(id, vector) {
1697
+ try {
1698
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1699
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
1700
+ const len0 = WASM_VECTOR_LEN;
1701
+ wasm.vectorstore_insert(retptr, this.__wbg_ptr, id, ptr0, len0);
1702
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1703
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1704
+ if (r1) {
1705
+ throw takeObject(r0);
1706
+ }
1707
+ } finally {
1708
+ wasm.__wbindgen_add_to_stack_pointer(16);
1709
+ }
1710
+ }
1829
1711
  /**
1830
1712
  * Batch insert. Input: `[[id, Float32Array], ...]`.
1831
1713
  * @param {any} batch
@@ -1843,6 +1725,62 @@ export class VectorStore {
1843
1725
  wasm.__wbindgen_add_to_stack_pointer(16);
1844
1726
  }
1845
1727
  }
1728
+ /**
1729
+ * Inserts a vector with ID and optional JSON payload.
1730
+ * @param {bigint} id
1731
+ * @param {Float32Array} vector
1732
+ * @param {any} payload
1733
+ */
1734
+ insert_with_payload(id, vector, payload) {
1735
+ try {
1736
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1737
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
1738
+ const len0 = WASM_VECTOR_LEN;
1739
+ wasm.vectorstore_insert_with_payload(retptr, this.__wbg_ptr, id, ptr0, len0, addHeapObject(payload));
1740
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1741
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1742
+ if (r1) {
1743
+ throw takeObject(r0);
1744
+ }
1745
+ } finally {
1746
+ wasm.__wbindgen_add_to_stack_pointer(16);
1747
+ }
1748
+ }
1749
+ /**
1750
+ * Returns true if the store is empty.
1751
+ * @returns {boolean}
1752
+ */
1753
+ get is_empty() {
1754
+ const ret = wasm.vectorstore_is_empty(this.__wbg_ptr);
1755
+ return ret !== 0;
1756
+ }
1757
+ /**
1758
+ * Returns true if this is a metadata-only store.
1759
+ * @returns {boolean}
1760
+ */
1761
+ get is_metadata_only() {
1762
+ const ret = wasm.vectorstore_is_metadata_only(this.__wbg_ptr);
1763
+ return ret !== 0;
1764
+ }
1765
+ /**
1766
+ * Returns the number of vectors in the store.
1767
+ * @returns {number}
1768
+ */
1769
+ get len() {
1770
+ const ret = wasm.vectorstore_len(this.__wbg_ptr);
1771
+ return ret >>> 0;
1772
+ }
1773
+ /**
1774
+ * Loads from `IndexedDB`.
1775
+ * @param {string} db_name
1776
+ * @returns {Promise<VectorStore>}
1777
+ */
1778
+ static load(db_name) {
1779
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1780
+ const len0 = WASM_VECTOR_LEN;
1781
+ const ret = wasm.vectorstore_load(ptr0, len0);
1782
+ return takeObject(ret);
1783
+ }
1846
1784
  /**
1847
1785
  * Returns memory usage estimate in bytes.
1848
1786
  * @returns {number}
@@ -1852,52 +1790,65 @@ export class VectorStore {
1852
1790
  return ret >>> 0;
1853
1791
  }
1854
1792
  /**
1855
- * Returns the storage mode.
1856
- * @returns {string}
1793
+ * Multi-query search with fusion. Strategies: average, maximum, rrf.
1794
+ * @param {Float32Array} vectors
1795
+ * @param {number} num_vectors
1796
+ * @param {number} k
1797
+ * @param {string} strategy
1798
+ * @param {number | null} [rrf_k]
1799
+ * @returns {any}
1857
1800
  */
1858
- get storage_mode() {
1859
- let deferred1_0;
1860
- let deferred1_1;
1801
+ multi_query_search(vectors, num_vectors, k, strategy, rrf_k) {
1861
1802
  try {
1862
1803
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1863
- wasm.vectorstore_storage_mode(retptr, this.__wbg_ptr);
1804
+ const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
1805
+ const len0 = WASM_VECTOR_LEN;
1806
+ const ptr1 = passStringToWasm0(strategy, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1807
+ const len1 = WASM_VECTOR_LEN;
1808
+ wasm.vectorstore_multi_query_search(retptr, this.__wbg_ptr, ptr0, len0, num_vectors, k, ptr1, len1, isLikeNone(rrf_k) ? 0x100000001 : (rrf_k) >>> 0);
1864
1809
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1865
1810
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1866
- deferred1_0 = r0;
1867
- deferred1_1 = r1;
1868
- return getStringFromWasm0(r0, r1);
1811
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1812
+ if (r2) {
1813
+ throw takeObject(r1);
1814
+ }
1815
+ return takeObject(r0);
1869
1816
  } finally {
1870
1817
  wasm.__wbindgen_add_to_stack_pointer(16);
1871
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1872
1818
  }
1873
1819
  }
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}
1820
+ /**
1821
+ * Creates a new vector store. Metrics: cosine, euclidean, dot, hamming, jaccard.
1822
+ * @param {number} dimension
1823
+ * @param {string} metric
1881
1824
  */
1882
- hybrid_search(query_vector, text_query, k, vector_weight) {
1825
+ constructor(dimension, metric) {
1883
1826
  try {
1884
1827
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1885
- const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1828
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1886
1829
  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));
1830
+ wasm.vectorstore_new(retptr, dimension, ptr0, len0);
1890
1831
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1891
1832
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1892
1833
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1893
1834
  if (r2) {
1894
1835
  throw takeObject(r1);
1895
1836
  }
1896
- return takeObject(r0);
1837
+ this.__wbg_ptr = r0 >>> 0;
1838
+ VectorStoreFinalization.register(this, this.__wbg_ptr, this);
1839
+ return this;
1897
1840
  } finally {
1898
1841
  wasm.__wbindgen_add_to_stack_pointer(16);
1899
1842
  }
1900
1843
  }
1844
+ /**
1845
+ * Creates a metadata-only store (no vectors, only payloads).
1846
+ * @returns {VectorStore}
1847
+ */
1848
+ static new_metadata_only() {
1849
+ const ret = wasm.vectorstore_new_metadata_only();
1850
+ return VectorStore.__wrap(ret);
1851
+ }
1901
1852
  /**
1902
1853
  * Creates store with mode: full (4B/dim), sq8 (4x compression), binary (32x).
1903
1854
  * @param {number} dimension
@@ -1925,100 +1876,112 @@ export class VectorStore {
1925
1876
  }
1926
1877
  }
1927
1878
  /**
1928
- * Creates store with pre-allocated capacity.
1929
- * @param {number} dimension
1930
- * @param {string} metric
1931
- * @param {number} capacity
1932
- * @returns {VectorStore}
1879
+ * VelesQL-style query returning multi-model results (EPIC-031 US-009).
1880
+ *
1881
+ * Returns results in `HybridResult` format with `node_id`, `vector_score`,
1882
+ * `graph_score`, `fused_score`, `bindings`, and `column_data`.
1883
+ *
1884
+ * # Arguments
1885
+ * * `query_vector` - Query vector for similarity search
1886
+ * * `k` - Number of results to return
1887
+ *
1888
+ * # Returns
1889
+ * Array of `{nodeId, vectorScore, graphScore, fusedScore, bindings, columnData}`
1890
+ * @param {Float32Array} query_vector
1891
+ * @param {number} k
1892
+ * @returns {any}
1933
1893
  */
1934
- static with_capacity(dimension, metric, capacity) {
1894
+ query(query_vector, k) {
1935
1895
  try {
1936
1896
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1937
- const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1897
+ const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
1938
1898
  const len0 = WASM_VECTOR_LEN;
1939
- wasm.vectorstore_with_capacity(retptr, dimension, ptr0, len0, capacity);
1899
+ wasm.vectorstore_query(retptr, this.__wbg_ptr, ptr0, len0, k);
1940
1900
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1941
1901
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1942
1902
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1943
1903
  if (r2) {
1944
1904
  throw takeObject(r1);
1945
1905
  }
1946
- return VectorStore.__wrap(r0);
1906
+ return takeObject(r0);
1947
1907
  } finally {
1948
1908
  wasm.__wbindgen_add_to_stack_pointer(16);
1949
1909
  }
1950
1910
  }
1951
1911
  /**
1952
- * Deletes `IndexedDB` database.
1912
+ * Removes a vector by ID.
1913
+ * @param {bigint} id
1914
+ * @returns {boolean}
1915
+ */
1916
+ remove(id) {
1917
+ const ret = wasm.vectorstore_remove(this.__wbg_ptr, id);
1918
+ return ret !== 0;
1919
+ }
1920
+ /**
1921
+ * Pre-allocates memory for additional vectors.
1922
+ * @param {number} additional
1923
+ */
1924
+ reserve(additional) {
1925
+ wasm.vectorstore_reserve(this.__wbg_ptr, additional);
1926
+ }
1927
+ /**
1928
+ * Saves to `IndexedDB`.
1953
1929
  * @param {string} db_name
1954
1930
  * @returns {Promise<void>}
1955
1931
  */
1956
- static delete_database(db_name) {
1932
+ save(db_name) {
1957
1933
  const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1958
1934
  const len0 = WASM_VECTOR_LEN;
1959
- const ret = wasm.vectorstore_delete_database(ptr0, len0);
1935
+ const ret = wasm.vectorstore_save(this.__wbg_ptr, ptr0, len0);
1960
1936
  return takeObject(ret);
1961
1937
  }
1962
1938
  /**
1963
- * Exports to binary format for IndexedDB/localStorage.
1964
- * @returns {Uint8Array}
1939
+ * k-NN search. Returns [[id, score], ...].
1940
+ * @param {Float32Array} query
1941
+ * @param {number} k
1942
+ * @returns {any}
1965
1943
  */
1966
- export_to_bytes() {
1944
+ search(query, k) {
1967
1945
  try {
1968
1946
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1969
- wasm.vectorstore_export_to_bytes(retptr, this.__wbg_ptr);
1947
+ const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
1948
+ const len0 = WASM_VECTOR_LEN;
1949
+ wasm.vectorstore_search(retptr, this.__wbg_ptr, ptr0, len0, k);
1970
1950
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1971
1951
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1972
1952
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1973
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1974
- if (r3) {
1975
- throw takeObject(r2);
1953
+ if (r2) {
1954
+ throw takeObject(r1);
1976
1955
  }
1977
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
1978
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1979
- return v1;
1956
+ return takeObject(r0);
1980
1957
  } finally {
1981
1958
  wasm.__wbindgen_add_to_stack_pointer(16);
1982
1959
  }
1983
1960
  }
1984
1961
  /**
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}
1962
+ * Searches with metadata filtering. Returns [{id, score, payload}].
1963
+ * @param {Float32Array} query
1964
+ * @param {number} k
1965
+ * @param {any} filter
1966
+ * @returns {any}
1996
1967
  */
1997
- static import_from_bytes(bytes) {
1968
+ search_with_filter(query, k, filter) {
1998
1969
  try {
1999
1970
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2000
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
1971
+ const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
2001
1972
  const len0 = WASM_VECTOR_LEN;
2002
- wasm.vectorstore_import_from_bytes(retptr, ptr0, len0);
1973
+ wasm.vectorstore_search_with_filter(retptr, this.__wbg_ptr, ptr0, len0, k, addHeapObject(filter));
2003
1974
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2004
1975
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2005
1976
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2006
1977
  if (r2) {
2007
1978
  throw takeObject(r1);
2008
1979
  }
2009
- return VectorStore.__wrap(r0);
1980
+ return takeObject(r0);
2010
1981
  } finally {
2011
1982
  wasm.__wbindgen_add_to_stack_pointer(16);
2012
1983
  }
2013
1984
  }
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
1985
  /**
2023
1986
  * Similarity search with threshold. Operators: >, >=, <, <=, =, !=.
2024
1987
  * @param {Float32Array} query
@@ -2047,46 +2010,47 @@ export class VectorStore {
2047
2010
  }
2048
2011
  }
2049
2012
  /**
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}
2013
+ * Inserts a sparse vector into the internal sparse index.
2014
+ *
2015
+ * Lazily initializes the sparse index on first call.
2016
+ * @param {bigint} doc_id
2017
+ * @param {Uint32Array} indices
2018
+ * @param {Float32Array} values
2057
2019
  */
2058
- multi_query_search(vectors, num_vectors, k, strategy, rrf_k) {
2020
+ sparse_insert(doc_id, indices, values) {
2059
2021
  try {
2060
2022
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2061
- const ptr0 = passArrayF32ToWasm0(vectors, wasm.__wbindgen_export);
2023
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
2062
2024
  const len0 = WASM_VECTOR_LEN;
2063
- const ptr1 = passStringToWasm0(strategy, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2025
+ const ptr1 = passArrayF32ToWasm0(values, wasm.__wbindgen_export);
2064
2026
  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);
2027
+ wasm.vectorstore_sparse_insert(retptr, this.__wbg_ptr, doc_id, ptr0, len0, ptr1, len1);
2066
2028
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2067
2029
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2068
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2069
- if (r2) {
2070
- throw takeObject(r1);
2030
+ if (r1) {
2031
+ throw takeObject(r0);
2071
2032
  }
2072
- return takeObject(r0);
2073
2033
  } finally {
2074
2034
  wasm.__wbindgen_add_to_stack_pointer(16);
2075
2035
  }
2076
2036
  }
2077
2037
  /**
2078
- * Searches with metadata filtering. Returns [{id, score, payload}].
2079
- * @param {Float32Array} query
2038
+ * Searches the internal sparse index.
2039
+ *
2040
+ * Returns a JSON array of `{doc_id, score}` objects sorted by score descending.
2041
+ * @param {Uint32Array} indices
2042
+ * @param {Float32Array} values
2080
2043
  * @param {number} k
2081
- * @param {any} filter
2082
2044
  * @returns {any}
2083
2045
  */
2084
- search_with_filter(query, k, filter) {
2046
+ sparse_search(indices, values, k) {
2085
2047
  try {
2086
2048
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2087
- const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
2049
+ const ptr0 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
2088
2050
  const len0 = WASM_VECTOR_LEN;
2089
- wasm.vectorstore_search_with_filter(retptr, this.__wbg_ptr, ptr0, len0, k, addHeapObject(filter));
2051
+ const ptr1 = passArrayF32ToWasm0(values, wasm.__wbindgen_export);
2052
+ const len1 = WASM_VECTOR_LEN;
2053
+ wasm.vectorstore_sparse_search(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, k);
2090
2054
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2091
2055
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2092
2056
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2099,35 +2063,40 @@ export class VectorStore {
2099
2063
  }
2100
2064
  }
2101
2065
  /**
2102
- * Inserts a vector with ID and optional JSON payload.
2103
- * @param {bigint} id
2104
- * @param {Float32Array} vector
2105
- * @param {any} payload
2066
+ * Returns the storage mode.
2067
+ * @returns {string}
2106
2068
  */
2107
- insert_with_payload(id, vector, payload) {
2069
+ get storage_mode() {
2070
+ let deferred1_0;
2071
+ let deferred1_1;
2108
2072
  try {
2109
2073
  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));
2074
+ wasm.vectorstore_storage_mode(retptr, this.__wbg_ptr);
2113
2075
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2114
2076
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2115
- if (r1) {
2116
- throw takeObject(r0);
2117
- }
2077
+ deferred1_0 = r0;
2078
+ deferred1_1 = r1;
2079
+ return getStringFromWasm0(r0, r1);
2118
2080
  } finally {
2119
2081
  wasm.__wbindgen_add_to_stack_pointer(16);
2082
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
2120
2083
  }
2121
2084
  }
2122
2085
  /**
2123
- * Gets a vector by ID. Returns {id, vector, payload} or null.
2124
- * @param {bigint} id
2086
+ * Text search on payload fields (substring matching).
2087
+ * @param {string} query
2088
+ * @param {number} k
2089
+ * @param {string | null} [field]
2125
2090
  * @returns {any}
2126
2091
  */
2127
- get(id) {
2092
+ text_search(query, k, field) {
2128
2093
  try {
2129
2094
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2130
- wasm.vectorstore_get(retptr, this.__wbg_ptr, id);
2095
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2096
+ const len0 = WASM_VECTOR_LEN;
2097
+ var ptr1 = isLikeNone(field) ? 0 : passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2098
+ var len1 = WASM_VECTOR_LEN;
2099
+ wasm.vectorstore_text_search(retptr, this.__wbg_ptr, ptr0, len0, k, ptr1, len1);
2131
2100
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2132
2101
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2133
2102
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2140,285 +2109,996 @@ export class VectorStore {
2140
2109
  }
2141
2110
  }
2142
2111
  /**
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.
2112
+ * Creates store with pre-allocated capacity.
2152
2113
  * @param {number} dimension
2153
2114
  * @param {string} metric
2115
+ * @param {number} capacity
2116
+ * @returns {VectorStore}
2154
2117
  */
2155
- constructor(dimension, metric) {
2118
+ static with_capacity(dimension, metric, capacity) {
2156
2119
  try {
2157
2120
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2158
2121
  const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2159
2122
  const len0 = WASM_VECTOR_LEN;
2160
- wasm.vectorstore_new(retptr, dimension, ptr0, len0);
2123
+ wasm.vectorstore_with_capacity(retptr, dimension, ptr0, len0, capacity);
2161
2124
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2162
2125
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2163
2126
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2164
2127
  if (r2) {
2165
2128
  throw takeObject(r1);
2166
2129
  }
2167
- this.__wbg_ptr = r0 >>> 0;
2168
- VectorStoreFinalization.register(this, this.__wbg_ptr, this);
2169
- return this;
2130
+ return VectorStore.__wrap(r0);
2170
2131
  } finally {
2171
2132
  wasm.__wbindgen_add_to_stack_pointer(16);
2172
2133
  }
2173
2134
  }
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);
2135
+ }
2136
+ if (Symbol.dispose) VectorStore.prototype[Symbol.dispose] = VectorStore.prototype.free;
2137
+
2138
+ /**
2139
+ * `VelesQL` query parser for browser use.
2140
+ *
2141
+ * # Example (JavaScript)
2142
+ *
2143
+ * ```javascript
2144
+ * import { VelesQL } from 'velesdb-wasm';
2145
+ *
2146
+ * // Parse a query
2147
+ * const parsed = VelesQL.parse("SELECT * FROM docs WHERE category = 'tech' LIMIT 10");
2148
+ * console.log(parsed.tableName); // "docs"
2149
+ * console.log(parsed.isValid); // true
2150
+ *
2151
+ * // Validate without parsing
2152
+ * const valid = VelesQL.isValid("SELECT * FROM docs"); // true
2153
+ * ```
2154
+ */
2155
+ export class VelesQL {
2156
+ __destroy_into_raw() {
2157
+ const ptr = this.__wbg_ptr;
2158
+ this.__wbg_ptr = 0;
2159
+ VelesQLFinalization.unregister(this);
2160
+ return ptr;
2184
2161
  }
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);
2162
+ free() {
2163
+ const ptr = this.__destroy_into_raw();
2164
+ wasm.__wbg_velesql_free(ptr, 0);
2195
2165
  }
2196
2166
  /**
2197
- * Clears all vectors from the store.
2167
+ * Validate a `VelesQL` query without full parsing.
2168
+ *
2169
+ * This is faster than `parse()` when you only need to check validity.
2170
+ * @param {string} query
2171
+ * @returns {boolean}
2198
2172
  */
2199
- clear() {
2200
- wasm.vectorstore_clear(this.__wbg_ptr);
2173
+ static isValid(query) {
2174
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2175
+ const len0 = WASM_VECTOR_LEN;
2176
+ const ret = wasm.velesql_isValid(ptr0, len0);
2177
+ return ret !== 0;
2201
2178
  }
2202
2179
  /**
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
2180
+ * Parse a `VelesQL` query string.
2211
2181
  *
2212
- * # Returns
2213
- * Array of `{nodeId, vectorScore, graphScore, fusedScore, bindings, columnData}`
2214
- * @param {Float32Array} query_vector
2215
- * @param {number} k
2216
- * @returns {any}
2182
+ * Returns a `ParsedQuery` object with query introspection methods.
2183
+ * Throws an error if the query has syntax errors.
2184
+ * @param {string} query
2185
+ * @returns {ParsedQuery}
2217
2186
  */
2218
- query(query_vector, k) {
2187
+ static parse(query) {
2219
2188
  try {
2220
2189
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2221
- const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
2190
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2222
2191
  const len0 = WASM_VECTOR_LEN;
2223
- wasm.vectorstore_query(retptr, this.__wbg_ptr, ptr0, len0, k);
2192
+ wasm.velesql_parse(retptr, ptr0, len0);
2224
2193
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2225
2194
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2226
2195
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2227
2196
  if (r2) {
2228
2197
  throw takeObject(r1);
2229
2198
  }
2230
- return takeObject(r0);
2199
+ return ParsedQuery.__wrap(r0);
2231
2200
  } finally {
2232
2201
  wasm.__wbindgen_add_to_stack_pointer(16);
2233
2202
  }
2234
2203
  }
2235
- /**
2236
- * Inserts a vector with the given ID.
2237
- * @param {bigint} id
2238
- * @param {Float32Array} vector
2239
- */
2240
- insert(id, vector) {
2204
+ }
2205
+ if (Symbol.dispose) VelesQL.prototype[Symbol.dispose] = VelesQL.prototype.free;
2206
+
2207
+ /**
2208
+ * Estimates the number of nodes that will be visited during traversal.
2209
+ *
2210
+ * Uses a heuristic based on graph density and max depth.
2211
+ * @param {number} node_count
2212
+ * @param {number} edge_count
2213
+ * @param {number} max_depth
2214
+ * @returns {number}
2215
+ */
2216
+ export function estimate_traversal_size(node_count, edge_count, max_depth) {
2217
+ const ret = wasm.estimate_traversal_size(node_count, edge_count, max_depth);
2218
+ return ret >>> 0;
2219
+ }
2220
+
2221
+ /**
2222
+ * Fuses pre-computed dense and sparse search results using Reciprocal Rank Fusion (RRF).
2223
+ *
2224
+ * Both `dense_results` and `sparse_results` should be JSON arrays of `[doc_id, score]` pairs.
2225
+ * Returns a JSON array of `{doc_id, score}` objects, sorted by fused score descending,
2226
+ * truncated to the top `k` entries.
2227
+ * @param {any} dense_results
2228
+ * @param {any} sparse_results
2229
+ * @param {number} rrf_k
2230
+ * @param {number} k
2231
+ * @returns {any}
2232
+ */
2233
+ export function hybrid_search_fuse(dense_results, sparse_results, rrf_k, k) {
2234
+ try {
2235
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2236
+ wasm.hybrid_search_fuse(retptr, addHeapObject(dense_results), addHeapObject(sparse_results), rrf_k, k);
2237
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2238
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2239
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2240
+ if (r2) {
2241
+ throw takeObject(r1);
2242
+ }
2243
+ return takeObject(r0);
2244
+ } finally {
2245
+ wasm.__wbindgen_add_to_stack_pointer(16);
2246
+ }
2247
+ }
2248
+
2249
+ /**
2250
+ * Determines whether a traversal should be offloaded to a Web Worker.
2251
+ *
2252
+ * # Arguments
2253
+ * * `node_count` - Total nodes in the graph
2254
+ * * `max_depth` - Maximum traversal depth requested
2255
+ * * `config` - Optional configuration (uses defaults if None)
2256
+ *
2257
+ * # Returns
2258
+ * `true` if the operation should use a Web Worker
2259
+ * @param {number} node_count
2260
+ * @param {number} max_depth
2261
+ * @param {GraphWorkerConfig | null} [config]
2262
+ * @returns {boolean}
2263
+ */
2264
+ export function should_use_worker(node_count, max_depth, config) {
2265
+ let ptr0 = 0;
2266
+ if (!isLikeNone(config)) {
2267
+ _assertClass(config, GraphWorkerConfig);
2268
+ ptr0 = config.__destroy_into_raw();
2269
+ }
2270
+ const ret = wasm.should_use_worker(node_count, max_depth, ptr0);
2271
+ return ret !== 0;
2272
+ }
2273
+
2274
+ function __wbg_get_imports() {
2275
+ const import0 = {
2276
+ __proto__: null,
2277
+ __wbg_Error_4577686b3a6d9b3a: function(arg0, arg1) {
2278
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2279
+ return addHeapObject(ret);
2280
+ },
2281
+ __wbg_Number_e89e48a2fe1a6355: function(arg0) {
2282
+ const ret = Number(getObject(arg0));
2283
+ return ret;
2284
+ },
2285
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
2286
+ const ret = String(getObject(arg1));
2287
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2288
+ const len1 = WASM_VECTOR_LEN;
2289
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2290
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2291
+ },
2292
+ __wbg___wbindgen_bigint_get_as_i64_578010f8442e0319: function(arg0, arg1) {
2293
+ const v = getObject(arg1);
2294
+ const ret = typeof(v) === 'bigint' ? v : undefined;
2295
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2296
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2297
+ },
2298
+ __wbg___wbindgen_boolean_get_18c4ed9422296fff: function(arg0) {
2299
+ const v = getObject(arg0);
2300
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2301
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2302
+ },
2303
+ __wbg___wbindgen_debug_string_ddde1867f49c2442: function(arg0, arg1) {
2304
+ const ret = debugString(getObject(arg1));
2305
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2306
+ const len1 = WASM_VECTOR_LEN;
2307
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2308
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2309
+ },
2310
+ __wbg___wbindgen_in_1064a108f4d18b9e: function(arg0, arg1) {
2311
+ const ret = getObject(arg0) in getObject(arg1);
2312
+ return ret;
2313
+ },
2314
+ __wbg___wbindgen_is_bigint_a157f0734ca85901: function(arg0) {
2315
+ const ret = typeof(getObject(arg0)) === 'bigint';
2316
+ return ret;
2317
+ },
2318
+ __wbg___wbindgen_is_function_d633e708baf0d146: function(arg0) {
2319
+ const ret = typeof(getObject(arg0)) === 'function';
2320
+ return ret;
2321
+ },
2322
+ __wbg___wbindgen_is_null_a2a19127c13e7126: function(arg0) {
2323
+ const ret = getObject(arg0) === null;
2324
+ return ret;
2325
+ },
2326
+ __wbg___wbindgen_is_object_4b3de556756ee8a8: function(arg0) {
2327
+ const val = getObject(arg0);
2328
+ const ret = typeof(val) === 'object' && val !== null;
2329
+ return ret;
2330
+ },
2331
+ __wbg___wbindgen_is_string_7debe47dc1e045c2: function(arg0) {
2332
+ const ret = typeof(getObject(arg0)) === 'string';
2333
+ return ret;
2334
+ },
2335
+ __wbg___wbindgen_is_undefined_c18285b9fc34cb7d: function(arg0) {
2336
+ const ret = getObject(arg0) === undefined;
2337
+ return ret;
2338
+ },
2339
+ __wbg___wbindgen_jsval_eq_a6afb59d8c5e78d6: function(arg0, arg1) {
2340
+ const ret = getObject(arg0) === getObject(arg1);
2341
+ return ret;
2342
+ },
2343
+ __wbg___wbindgen_jsval_loose_eq_1562ceb9af84e990: function(arg0, arg1) {
2344
+ const ret = getObject(arg0) == getObject(arg1);
2345
+ return ret;
2346
+ },
2347
+ __wbg___wbindgen_number_get_5854912275df1894: function(arg0, arg1) {
2348
+ const obj = getObject(arg1);
2349
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2350
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2351
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2352
+ },
2353
+ __wbg___wbindgen_string_get_3e5751597f39a112: function(arg0, arg1) {
2354
+ const obj = getObject(arg1);
2355
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2356
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2357
+ var len1 = WASM_VECTOR_LEN;
2358
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2359
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2360
+ },
2361
+ __wbg___wbindgen_throw_39bc967c0e5a9b58: function(arg0, arg1) {
2362
+ throw new Error(getStringFromWasm0(arg0, arg1));
2363
+ },
2364
+ __wbg__wbg_cb_unref_b6d832240a919168: function(arg0) {
2365
+ getObject(arg0)._wbg_cb_unref();
2366
+ },
2367
+ __wbg_bound_6f6f52afeaa26de6: function() { return handleError(function (arg0, arg1) {
2368
+ const ret = IDBKeyRange.bound(getObject(arg0), getObject(arg1));
2369
+ return addHeapObject(ret);
2370
+ }, arguments); },
2371
+ __wbg_call_08ad0d89caa7cb79: function() { return handleError(function (arg0, arg1, arg2) {
2372
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2373
+ return addHeapObject(ret);
2374
+ }, arguments); },
2375
+ __wbg_call_73af281463ec8b58: function() { return handleError(function (arg0, arg1) {
2376
+ const ret = getObject(arg0).call(getObject(arg1));
2377
+ return addHeapObject(ret);
2378
+ }, arguments); },
2379
+ __wbg_createObjectStore_bfd875621f13f126: function() { return handleError(function (arg0, arg1, arg2) {
2380
+ const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
2381
+ return addHeapObject(ret);
2382
+ }, arguments); },
2383
+ __wbg_deleteDatabase_14dffbeb78d18245: function() { return handleError(function (arg0, arg1, arg2) {
2384
+ const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
2385
+ return addHeapObject(ret);
2386
+ }, arguments); },
2387
+ __wbg_delete_86cbf50563ab0bd6: function() { return handleError(function (arg0, arg1) {
2388
+ const ret = getObject(arg0).delete(getObject(arg1));
2389
+ return addHeapObject(ret);
2390
+ }, arguments); },
2391
+ __wbg_done_5aad55ec6b1954b1: function(arg0) {
2392
+ const ret = getObject(arg0).done;
2393
+ return ret;
2394
+ },
2395
+ __wbg_entries_28d32ba4cd93f5fc: function(arg0) {
2396
+ const ret = Object.entries(getObject(arg0));
2397
+ return addHeapObject(ret);
2398
+ },
2399
+ __wbg_error_b8445866f700df1c: function(arg0, arg1) {
2400
+ console.error(getObject(arg0), getObject(arg1));
2401
+ },
2402
+ __wbg_getAllKeys_65895da3d083228b: function() { return handleError(function (arg0) {
2403
+ const ret = getObject(arg0).getAllKeys();
2404
+ return addHeapObject(ret);
2405
+ }, arguments); },
2406
+ __wbg_getAll_dbbb20886b9a441e: function() { return handleError(function (arg0, arg1) {
2407
+ const ret = getObject(arg0).getAll(getObject(arg1));
2408
+ return addHeapObject(ret);
2409
+ }, arguments); },
2410
+ __wbg_get_487b8166caa6bea1: function(arg0, arg1, arg2) {
2411
+ const ret = getObject(arg1)[arg2 >>> 0];
2412
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2413
+ var len1 = WASM_VECTOR_LEN;
2414
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2415
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2416
+ },
2417
+ __wbg_get_4920fefd3451364b: function() { return handleError(function (arg0, arg1) {
2418
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2419
+ return addHeapObject(ret);
2420
+ }, arguments); },
2421
+ __wbg_get_791b26b41a7de3d5: function() { return handleError(function (arg0, arg1) {
2422
+ const ret = getObject(arg0).get(getObject(arg1));
2423
+ return addHeapObject(ret);
2424
+ }, arguments); },
2425
+ __wbg_get_f09c3a16f8848381: function(arg0, arg1) {
2426
+ const ret = getObject(arg0)[arg1 >>> 0];
2427
+ return addHeapObject(ret);
2428
+ },
2429
+ __wbg_get_unchecked_3d0f4b91c8eca4f0: function(arg0, arg1) {
2430
+ const ret = getObject(arg0)[arg1 >>> 0];
2431
+ return addHeapObject(ret);
2432
+ },
2433
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
2434
+ const ret = getObject(arg0)[getObject(arg1)];
2435
+ return addHeapObject(ret);
2436
+ },
2437
+ __wbg_graphedge_new: function(arg0) {
2438
+ const ret = GraphEdge.__wrap(arg0);
2439
+ return addHeapObject(ret);
2440
+ },
2441
+ __wbg_graphnode_new: function(arg0) {
2442
+ const ret = GraphNode.__wrap(arg0);
2443
+ return addHeapObject(ret);
2444
+ },
2445
+ __wbg_graphstore_new: function(arg0) {
2446
+ const ret = GraphStore.__wrap(arg0);
2447
+ return addHeapObject(ret);
2448
+ },
2449
+ __wbg_indexedDB_f950945d950fbd5e: function() { return handleError(function (arg0) {
2450
+ const ret = getObject(arg0).indexedDB;
2451
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2452
+ }, arguments); },
2453
+ __wbg_instanceof_ArrayBuffer_15859862b80b732d: function(arg0) {
2454
+ let result;
2455
+ try {
2456
+ result = getObject(arg0) instanceof ArrayBuffer;
2457
+ } catch (_) {
2458
+ result = false;
2459
+ }
2460
+ const ret = result;
2461
+ return ret;
2462
+ },
2463
+ __wbg_instanceof_Map_9df16bf25ceb4ecb: function(arg0) {
2464
+ let result;
2465
+ try {
2466
+ result = getObject(arg0) instanceof Map;
2467
+ } catch (_) {
2468
+ result = false;
2469
+ }
2470
+ const ret = result;
2471
+ return ret;
2472
+ },
2473
+ __wbg_instanceof_Uint8Array_2240b7046ac16f05: function(arg0) {
2474
+ let result;
2475
+ try {
2476
+ result = getObject(arg0) instanceof Uint8Array;
2477
+ } catch (_) {
2478
+ result = false;
2479
+ }
2480
+ const ret = result;
2481
+ return ret;
2482
+ },
2483
+ __wbg_instanceof_Window_4aba49e4d1a12365: function(arg0) {
2484
+ let result;
2485
+ try {
2486
+ result = getObject(arg0) instanceof Window;
2487
+ } catch (_) {
2488
+ result = false;
2489
+ }
2490
+ const ret = result;
2491
+ return ret;
2492
+ },
2493
+ __wbg_isArray_fad08a0d12828686: function(arg0) {
2494
+ const ret = Array.isArray(getObject(arg0));
2495
+ return ret;
2496
+ },
2497
+ __wbg_isSafeInteger_10e4151eb694e42a: function(arg0) {
2498
+ const ret = Number.isSafeInteger(getObject(arg0));
2499
+ return ret;
2500
+ },
2501
+ __wbg_iterator_fc7ad8d33bab9e26: function() {
2502
+ const ret = Symbol.iterator;
2503
+ return addHeapObject(ret);
2504
+ },
2505
+ __wbg_length_5855c1f289dfffc1: function(arg0) {
2506
+ const ret = getObject(arg0).length;
2507
+ return ret;
2508
+ },
2509
+ __wbg_length_a31e05262e09b7f8: function(arg0) {
2510
+ const ret = getObject(arg0).length;
2511
+ return ret;
2512
+ },
2513
+ __wbg_length_fbd9fbbcd74a4420: function(arg0) {
2514
+ const ret = getObject(arg0).length;
2515
+ return ret;
2516
+ },
2517
+ __wbg_new_09959f7b4c92c246: function(arg0) {
2518
+ const ret = new Uint8Array(getObject(arg0));
2519
+ return addHeapObject(ret);
2520
+ },
2521
+ __wbg_new_79ce7968119cfd96: function(arg0, arg1) {
2522
+ try {
2523
+ var state0 = {a: arg0, b: arg1};
2524
+ var cb0 = (arg0, arg1) => {
2525
+ const a = state0.a;
2526
+ state0.a = 0;
2527
+ try {
2528
+ return __wasm_bindgen_func_elem_1364(a, state0.b, arg0, arg1);
2529
+ } finally {
2530
+ state0.a = a;
2531
+ }
2532
+ };
2533
+ const ret = new Promise(cb0);
2534
+ return addHeapObject(ret);
2535
+ } finally {
2536
+ state0.a = state0.b = 0;
2537
+ }
2538
+ },
2539
+ __wbg_new_92df58a8ec3bfb6b: function() {
2540
+ const ret = new Map();
2541
+ return addHeapObject(ret);
2542
+ },
2543
+ __wbg_new_cbee8c0d5c479eac: function() {
2544
+ const ret = new Array();
2545
+ return addHeapObject(ret);
2546
+ },
2547
+ __wbg_new_ed69e637b553a997: function() {
2548
+ const ret = new Object();
2549
+ return addHeapObject(ret);
2550
+ },
2551
+ __wbg_new_from_slice_d7e202fdbee3c396: function(arg0, arg1) {
2552
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2553
+ return addHeapObject(ret);
2554
+ },
2555
+ __wbg_new_typed_8258a0d8488ef2a2: function(arg0, arg1) {
2556
+ try {
2557
+ var state0 = {a: arg0, b: arg1};
2558
+ var cb0 = (arg0, arg1) => {
2559
+ const a = state0.a;
2560
+ state0.a = 0;
2561
+ try {
2562
+ return __wasm_bindgen_func_elem_1364(a, state0.b, arg0, arg1);
2563
+ } finally {
2564
+ state0.a = a;
2565
+ }
2566
+ };
2567
+ const ret = new Promise(cb0);
2568
+ return addHeapObject(ret);
2569
+ } finally {
2570
+ state0.a = state0.b = 0;
2571
+ }
2572
+ },
2573
+ __wbg_next_a5fe6f328f7affc2: function(arg0) {
2574
+ const ret = getObject(arg0).next;
2575
+ return addHeapObject(ret);
2576
+ },
2577
+ __wbg_next_e592122bb4ed4c67: function() { return handleError(function (arg0) {
2578
+ const ret = getObject(arg0).next();
2579
+ return addHeapObject(ret);
2580
+ }, arguments); },
2581
+ __wbg_now_edd718b3004d8631: function() {
2582
+ const ret = Date.now();
2583
+ return ret;
2584
+ },
2585
+ __wbg_objectStoreNames_3645b6da2d1f3852: function(arg0) {
2586
+ const ret = getObject(arg0).objectStoreNames;
2587
+ return addHeapObject(ret);
2588
+ },
2589
+ __wbg_objectStore_3a6b969b917c6262: function() { return handleError(function (arg0, arg1, arg2) {
2590
+ const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
2591
+ return addHeapObject(ret);
2592
+ }, arguments); },
2593
+ __wbg_open_9badd3c8846fbf11: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2594
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
2595
+ return addHeapObject(ret);
2596
+ }, arguments); },
2597
+ __wbg_open_c2bd4b4a6be9d67b: function() { return handleError(function (arg0, arg1, arg2) {
2598
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
2599
+ return addHeapObject(ret);
2600
+ }, arguments); },
2601
+ __wbg_prototypesetcall_f034d444741426c3: function(arg0, arg1, arg2) {
2602
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2603
+ },
2604
+ __wbg_push_a6f9488ffd3fae3b: function(arg0, arg1) {
2605
+ const ret = getObject(arg0).push(getObject(arg1));
2606
+ return ret;
2607
+ },
2608
+ __wbg_put_d86a6833e14a4c3b: function() { return handleError(function (arg0, arg1, arg2) {
2609
+ const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
2610
+ return addHeapObject(ret);
2611
+ }, arguments); },
2612
+ __wbg_queueMicrotask_2c8dfd1056f24fdc: function(arg0) {
2613
+ const ret = getObject(arg0).queueMicrotask;
2614
+ return addHeapObject(ret);
2615
+ },
2616
+ __wbg_queueMicrotask_8985ad63815852e7: function(arg0) {
2617
+ queueMicrotask(getObject(arg0));
2618
+ },
2619
+ __wbg_resolve_5d61e0d10c14730a: function(arg0) {
2620
+ const ret = Promise.resolve(getObject(arg0));
2621
+ return addHeapObject(ret);
2622
+ },
2623
+ __wbg_result_aaba1e6bbc5d42c8: function() { return handleError(function (arg0) {
2624
+ const ret = getObject(arg0).result;
2625
+ return addHeapObject(ret);
2626
+ }, arguments); },
2627
+ __wbg_set_4c81cfb5dc3a333c: function(arg0, arg1, arg2) {
2628
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2629
+ },
2630
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
2631
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2632
+ },
2633
+ __wbg_set_cfc6de03f990decf: function(arg0, arg1, arg2) {
2634
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2635
+ return addHeapObject(ret);
2636
+ },
2637
+ __wbg_set_onerror_8b43a0b08de76f6d: function(arg0, arg1) {
2638
+ getObject(arg0).onerror = getObject(arg1);
2639
+ },
2640
+ __wbg_set_onsuccess_76214f5146684855: function(arg0, arg1) {
2641
+ getObject(arg0).onsuccess = getObject(arg1);
2642
+ },
2643
+ __wbg_set_onupgradeneeded_74f1c8e9dbd2b70c: function(arg0, arg1) {
2644
+ getObject(arg0).onupgradeneeded = getObject(arg1);
2645
+ },
2646
+ __wbg_static_accessor_GLOBAL_THIS_14325d8cca34bb77: function() {
2647
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2648
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2649
+ },
2650
+ __wbg_static_accessor_GLOBAL_f3a1e69f9c5a7e8e: function() {
2651
+ const ret = typeof global === 'undefined' ? null : global;
2652
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2653
+ },
2654
+ __wbg_static_accessor_SELF_50cdb5b517789aca: function() {
2655
+ const ret = typeof self === 'undefined' ? null : self;
2656
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2657
+ },
2658
+ __wbg_static_accessor_WINDOW_d6c4126e4c244380: function() {
2659
+ const ret = typeof window === 'undefined' ? null : window;
2660
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2661
+ },
2662
+ __wbg_then_d4163530723f56f4: function(arg0, arg1, arg2) {
2663
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
2664
+ return addHeapObject(ret);
2665
+ },
2666
+ __wbg_then_f1c954fe00733701: function(arg0, arg1) {
2667
+ const ret = getObject(arg0).then(getObject(arg1));
2668
+ return addHeapObject(ret);
2669
+ },
2670
+ __wbg_transaction_30dda0e59a945fe4: function() { return handleError(function (arg0, arg1, arg2) {
2671
+ const ret = getObject(arg0).transaction(getObject(arg1), __wbindgen_enum_IdbTransactionMode[arg2]);
2672
+ return addHeapObject(ret);
2673
+ }, arguments); },
2674
+ __wbg_transaction_8555c5d00a94c767: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2675
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
2676
+ return addHeapObject(ret);
2677
+ }, arguments); },
2678
+ __wbg_transaction_d40b35a1d301d310: function() { return handleError(function (arg0, arg1) {
2679
+ const ret = getObject(arg0).transaction(getObject(arg1));
2680
+ return addHeapObject(ret);
2681
+ }, arguments); },
2682
+ __wbg_transaction_f90e157c0cdb0001: function() { return handleError(function (arg0, arg1, arg2) {
2683
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2));
2684
+ return addHeapObject(ret);
2685
+ }, arguments); },
2686
+ __wbg_value_667dcb90597486a6: function(arg0) {
2687
+ const ret = getObject(arg0).value;
2688
+ return addHeapObject(ret);
2689
+ },
2690
+ __wbg_vectorstore_new: function(arg0) {
2691
+ const ret = VectorStore.__wrap(arg0);
2692
+ return addHeapObject(ret);
2693
+ },
2694
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2695
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 138, function: Function { arguments: [Externref], shim_idx: 139, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2696
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1318, __wasm_bindgen_func_elem_1319);
2697
+ return addHeapObject(ret);
2698
+ },
2699
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2700
+ // 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`.
2701
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_289, __wasm_bindgen_func_elem_290);
2702
+ return addHeapObject(ret);
2703
+ },
2704
+ __wbindgen_cast_0000000000000003: function(arg0) {
2705
+ // Cast intrinsic for `F64 -> Externref`.
2706
+ const ret = arg0;
2707
+ return addHeapObject(ret);
2708
+ },
2709
+ __wbindgen_cast_0000000000000004: function(arg0) {
2710
+ // Cast intrinsic for `I64 -> Externref`.
2711
+ const ret = arg0;
2712
+ return addHeapObject(ret);
2713
+ },
2714
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
2715
+ // Cast intrinsic for `Ref(String) -> Externref`.
2716
+ const ret = getStringFromWasm0(arg0, arg1);
2717
+ return addHeapObject(ret);
2718
+ },
2719
+ __wbindgen_cast_0000000000000006: function(arg0) {
2720
+ // Cast intrinsic for `U64 -> Externref`.
2721
+ const ret = BigInt.asUintN(64, arg0);
2722
+ return addHeapObject(ret);
2723
+ },
2724
+ __wbindgen_object_clone_ref: function(arg0) {
2725
+ const ret = getObject(arg0);
2726
+ return addHeapObject(ret);
2727
+ },
2728
+ __wbindgen_object_drop_ref: function(arg0) {
2729
+ takeObject(arg0);
2730
+ },
2731
+ };
2732
+ return {
2733
+ __proto__: null,
2734
+ "./velesdb_wasm_bg.js": import0,
2735
+ };
2736
+ }
2737
+
2738
+ function __wasm_bindgen_func_elem_290(arg0, arg1, arg2) {
2739
+ wasm.__wasm_bindgen_func_elem_290(arg0, arg1, addHeapObject(arg2));
2740
+ }
2741
+
2742
+ function __wasm_bindgen_func_elem_1319(arg0, arg1, arg2) {
2743
+ try {
2744
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2745
+ wasm.__wasm_bindgen_func_elem_1319(retptr, arg0, arg1, addHeapObject(arg2));
2746
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2747
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2748
+ if (r1) {
2749
+ throw takeObject(r0);
2750
+ }
2751
+ } finally {
2752
+ wasm.__wbindgen_add_to_stack_pointer(16);
2753
+ }
2754
+ }
2755
+
2756
+ function __wasm_bindgen_func_elem_1364(arg0, arg1, arg2, arg3) {
2757
+ wasm.__wasm_bindgen_func_elem_1364(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2758
+ }
2759
+
2760
+
2761
+ const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
2762
+ const GraphEdgeFinalization = (typeof FinalizationRegistry === 'undefined')
2763
+ ? { register: () => {}, unregister: () => {} }
2764
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphedge_free(ptr >>> 0, 1));
2765
+ const GraphNodeFinalization = (typeof FinalizationRegistry === 'undefined')
2766
+ ? { register: () => {}, unregister: () => {} }
2767
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphnode_free(ptr >>> 0, 1));
2768
+ const GraphPersistenceFinalization = (typeof FinalizationRegistry === 'undefined')
2769
+ ? { register: () => {}, unregister: () => {} }
2770
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphpersistence_free(ptr >>> 0, 1));
2771
+ const GraphStoreFinalization = (typeof FinalizationRegistry === 'undefined')
2772
+ ? { register: () => {}, unregister: () => {} }
2773
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphstore_free(ptr >>> 0, 1));
2774
+ const GraphWorkerConfigFinalization = (typeof FinalizationRegistry === 'undefined')
2775
+ ? { register: () => {}, unregister: () => {} }
2776
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphworkerconfig_free(ptr >>> 0, 1));
2777
+ const ParsedQueryFinalization = (typeof FinalizationRegistry === 'undefined')
2778
+ ? { register: () => {}, unregister: () => {} }
2779
+ : new FinalizationRegistry(ptr => wasm.__wbg_parsedquery_free(ptr >>> 0, 1));
2780
+ const SemanticMemoryFinalization = (typeof FinalizationRegistry === 'undefined')
2781
+ ? { register: () => {}, unregister: () => {} }
2782
+ : new FinalizationRegistry(ptr => wasm.__wbg_semanticmemory_free(ptr >>> 0, 1));
2783
+ const SparseIndexFinalization = (typeof FinalizationRegistry === 'undefined')
2784
+ ? { register: () => {}, unregister: () => {} }
2785
+ : new FinalizationRegistry(ptr => wasm.__wbg_sparseindex_free(ptr >>> 0, 1));
2786
+ const TraversalProgressFinalization = (typeof FinalizationRegistry === 'undefined')
2787
+ ? { register: () => {}, unregister: () => {} }
2788
+ : new FinalizationRegistry(ptr => wasm.__wbg_traversalprogress_free(ptr >>> 0, 1));
2789
+ const VectorStoreFinalization = (typeof FinalizationRegistry === 'undefined')
2790
+ ? { register: () => {}, unregister: () => {} }
2791
+ : new FinalizationRegistry(ptr => wasm.__wbg_vectorstore_free(ptr >>> 0, 1));
2792
+ const VelesQLFinalization = (typeof FinalizationRegistry === 'undefined')
2793
+ ? { register: () => {}, unregister: () => {} }
2794
+ : new FinalizationRegistry(ptr => wasm.__wbg_velesql_free(ptr >>> 0, 1));
2795
+
2796
+ function addHeapObject(obj) {
2797
+ if (heap_next === heap.length) heap.push(heap.length + 1);
2798
+ const idx = heap_next;
2799
+ heap_next = heap[idx];
2800
+
2801
+ heap[idx] = obj;
2802
+ return idx;
2803
+ }
2804
+
2805
+ function _assertClass(instance, klass) {
2806
+ if (!(instance instanceof klass)) {
2807
+ throw new Error(`expected instance of ${klass.name}`);
2808
+ }
2809
+ }
2810
+
2811
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
2812
+ ? { register: () => {}, unregister: () => {} }
2813
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
2814
+
2815
+ function debugString(val) {
2816
+ // primitive types
2817
+ const type = typeof val;
2818
+ if (type == 'number' || type == 'boolean' || val == null) {
2819
+ return `${val}`;
2820
+ }
2821
+ if (type == 'string') {
2822
+ return `"${val}"`;
2823
+ }
2824
+ if (type == 'symbol') {
2825
+ const description = val.description;
2826
+ if (description == null) {
2827
+ return 'Symbol';
2828
+ } else {
2829
+ return `Symbol(${description})`;
2830
+ }
2831
+ }
2832
+ if (type == 'function') {
2833
+ const name = val.name;
2834
+ if (typeof name == 'string' && name.length > 0) {
2835
+ return `Function(${name})`;
2836
+ } else {
2837
+ return 'Function';
2838
+ }
2839
+ }
2840
+ // objects
2841
+ if (Array.isArray(val)) {
2842
+ const length = val.length;
2843
+ let debug = '[';
2844
+ if (length > 0) {
2845
+ debug += debugString(val[0]);
2846
+ }
2847
+ for(let i = 1; i < length; i++) {
2848
+ debug += ', ' + debugString(val[i]);
2849
+ }
2850
+ debug += ']';
2851
+ return debug;
2852
+ }
2853
+ // Test for built-in
2854
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2855
+ let className;
2856
+ if (builtInMatches && builtInMatches.length > 1) {
2857
+ className = builtInMatches[1];
2858
+ } else {
2859
+ // Failed to match the standard '[object ClassName]'
2860
+ return toString.call(val);
2861
+ }
2862
+ if (className == 'Object') {
2863
+ // we're a user defined class or Object
2864
+ // JSON.stringify avoids problems with cycles, and is generally much
2865
+ // easier than looping through ownProperties of `val`.
2241
2866
  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);
2867
+ return 'Object(' + JSON.stringify(val) + ')';
2868
+ } catch (_) {
2869
+ return 'Object';
2253
2870
  }
2254
2871
  }
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;
2872
+ // errors
2873
+ if (val instanceof Error) {
2874
+ return `${val.name}: ${val.message}\n${val.stack}`;
2263
2875
  }
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
- }
2876
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2877
+ return className;
2878
+ }
2879
+
2880
+ function dropObject(idx) {
2881
+ if (idx < 1028) return;
2882
+ heap[idx] = heap_next;
2883
+ heap_next = idx;
2884
+ }
2885
+
2886
+ function getArrayJsValueFromWasm0(ptr, len) {
2887
+ ptr = ptr >>> 0;
2888
+ const mem = getDataViewMemory0();
2889
+ const result = [];
2890
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
2891
+ result.push(takeObject(mem.getUint32(i, true)));
2286
2892
  }
2287
- /**
2288
- * Pre-allocates memory for additional vectors.
2289
- * @param {number} additional
2290
- */
2291
- reserve(additional) {
2292
- wasm.vectorstore_reserve(this.__wbg_ptr, additional);
2893
+ return result;
2894
+ }
2895
+
2896
+ function getArrayU64FromWasm0(ptr, len) {
2897
+ ptr = ptr >>> 0;
2898
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
2899
+ }
2900
+
2901
+ function getArrayU8FromWasm0(ptr, len) {
2902
+ ptr = ptr >>> 0;
2903
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2904
+ }
2905
+
2906
+ let cachedBigUint64ArrayMemory0 = null;
2907
+ function getBigUint64ArrayMemory0() {
2908
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
2909
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
2293
2910
  }
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;
2911
+ return cachedBigUint64ArrayMemory0;
2912
+ }
2913
+
2914
+ let cachedDataViewMemory0 = null;
2915
+ function getDataViewMemory0() {
2916
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2917
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2301
2918
  }
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;
2919
+ return cachedDataViewMemory0;
2920
+ }
2921
+
2922
+ let cachedFloat32ArrayMemory0 = null;
2923
+ function getFloat32ArrayMemory0() {
2924
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
2925
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
2309
2926
  }
2927
+ return cachedFloat32ArrayMemory0;
2310
2928
  }
2311
- if (Symbol.dispose) VectorStore.prototype[Symbol.dispose] = VectorStore.prototype.free;
2312
2929
 
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);
2930
+ function getStringFromWasm0(ptr, len) {
2931
+ ptr = ptr >>> 0;
2932
+ return decodeText(ptr, len);
2933
+ }
2934
+
2935
+ let cachedUint32ArrayMemory0 = null;
2936
+ function getUint32ArrayMemory0() {
2937
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2938
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2939
+ }
2940
+ return cachedUint32ArrayMemory0;
2941
+ }
2942
+
2943
+ let cachedUint8ArrayMemory0 = null;
2944
+ function getUint8ArrayMemory0() {
2945
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2946
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2947
+ }
2948
+ return cachedUint8ArrayMemory0;
2949
+ }
2950
+
2951
+ function getObject(idx) { return heap[idx]; }
2952
+
2953
+ function handleError(f, args) {
2954
+ try {
2955
+ return f.apply(this, args);
2956
+ } catch (e) {
2957
+ wasm.__wbindgen_export3(addHeapObject(e));
2958
+ }
2959
+ }
2960
+
2961
+ let heap = new Array(1024).fill(undefined);
2962
+ heap.push(undefined, null, true, false);
2963
+
2964
+ let heap_next = heap.length;
2965
+
2966
+ function isLikeNone(x) {
2967
+ return x === undefined || x === null;
2968
+ }
2969
+
2970
+ function makeMutClosure(arg0, arg1, dtor, f) {
2971
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
2972
+ const real = (...args) => {
2973
+
2974
+ // First up with a closure we increment the internal reference
2975
+ // count. This ensures that the Rust closure environment won't
2976
+ // be deallocated while we're invoking it.
2977
+ state.cnt++;
2978
+ const a = state.a;
2979
+ state.a = 0;
2980
+ try {
2981
+ return f(a, state.b, ...args);
2982
+ } finally {
2983
+ state.a = a;
2984
+ real._wbg_cb_unref();
2985
+ }
2986
+ };
2987
+ real._wbg_cb_unref = () => {
2988
+ if (--state.cnt === 0) {
2989
+ state.dtor(state.a, state.b);
2990
+ state.a = 0;
2991
+ CLOSURE_DTORS.unregister(state);
2992
+ }
2993
+ };
2994
+ CLOSURE_DTORS.register(real, state, state);
2995
+ return real;
2996
+ }
2997
+
2998
+ function passArray32ToWasm0(arg, malloc) {
2999
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
3000
+ getUint32ArrayMemory0().set(arg, ptr / 4);
3001
+ WASM_VECTOR_LEN = arg.length;
3002
+ return ptr;
3003
+ }
3004
+
3005
+ function passArray8ToWasm0(arg, malloc) {
3006
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
3007
+ getUint8ArrayMemory0().set(arg, ptr / 1);
3008
+ WASM_VECTOR_LEN = arg.length;
3009
+ return ptr;
3010
+ }
3011
+
3012
+ function passArrayF32ToWasm0(arg, malloc) {
3013
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
3014
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
3015
+ WASM_VECTOR_LEN = arg.length;
3016
+ return ptr;
3017
+ }
3018
+
3019
+ function passStringToWasm0(arg, malloc, realloc) {
3020
+ if (realloc === undefined) {
3021
+ const buf = cachedTextEncoder.encode(arg);
3022
+ const ptr = malloc(buf.length, 1) >>> 0;
3023
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
3024
+ WASM_VECTOR_LEN = buf.length;
2335
3025
  return ptr;
2336
3026
  }
2337
- free() {
2338
- const ptr = this.__destroy_into_raw();
2339
- wasm.__wbg_velesql_free(ptr, 0);
3027
+
3028
+ let len = arg.length;
3029
+ let ptr = malloc(len, 1) >>> 0;
3030
+
3031
+ const mem = getUint8ArrayMemory0();
3032
+
3033
+ let offset = 0;
3034
+
3035
+ for (; offset < len; offset++) {
3036
+ const code = arg.charCodeAt(offset);
3037
+ if (code > 0x7F) break;
3038
+ mem[ptr + offset] = code;
2340
3039
  }
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);
3040
+ if (offset !== len) {
3041
+ if (offset !== 0) {
3042
+ arg = arg.slice(offset);
2364
3043
  }
3044
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
3045
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
3046
+ const ret = cachedTextEncoder.encodeInto(arg, view);
3047
+
3048
+ offset += ret.written;
3049
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2365
3050
  }
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
- }
3051
+
3052
+ WASM_VECTOR_LEN = offset;
3053
+ return ptr;
2379
3054
  }
2380
- if (Symbol.dispose) VelesQL.prototype[Symbol.dispose] = VelesQL.prototype.free;
2381
3055
 
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;
3056
+ function takeObject(idx) {
3057
+ const ret = getObject(idx);
3058
+ dropObject(idx);
3059
+ return ret;
2394
3060
  }
2395
3061
 
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();
3062
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3063
+ cachedTextDecoder.decode();
3064
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
3065
+ let numBytesDecoded = 0;
3066
+ function decodeText(ptr, len) {
3067
+ numBytesDecoded += len;
3068
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
3069
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3070
+ cachedTextDecoder.decode();
3071
+ numBytesDecoded = len;
2416
3072
  }
2417
- const ret = wasm.should_use_worker(node_count, max_depth, ptr0);
2418
- return ret !== 0;
3073
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
3074
+ }
3075
+
3076
+ const cachedTextEncoder = new TextEncoder();
3077
+
3078
+ if (!('encodeInto' in cachedTextEncoder)) {
3079
+ cachedTextEncoder.encodeInto = function (arg, view) {
3080
+ const buf = cachedTextEncoder.encode(arg);
3081
+ view.set(buf);
3082
+ return {
3083
+ read: arg.length,
3084
+ written: buf.length
3085
+ };
3086
+ };
2419
3087
  }
2420
3088
 
2421
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
3089
+ let WASM_VECTOR_LEN = 0;
3090
+
3091
+ let wasmModule, wasm;
3092
+ function __wbg_finalize_init(instance, module) {
3093
+ wasm = instance.exports;
3094
+ wasmModule = module;
3095
+ cachedBigUint64ArrayMemory0 = null;
3096
+ cachedDataViewMemory0 = null;
3097
+ cachedFloat32ArrayMemory0 = null;
3098
+ cachedUint32ArrayMemory0 = null;
3099
+ cachedUint8ArrayMemory0 = null;
3100
+ return wasm;
3101
+ }
2422
3102
 
2423
3103
  async function __wbg_load(module, imports) {
2424
3104
  if (typeof Response === 'function' && module instanceof Response) {
@@ -2426,14 +3106,12 @@ async function __wbg_load(module, imports) {
2426
3106
  try {
2427
3107
  return await WebAssembly.instantiateStreaming(module, imports);
2428
3108
  } catch (e) {
2429
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
3109
+ const validResponse = module.ok && expectedResponseType(module.type);
2430
3110
 
2431
3111
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2432
3112
  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
3113
 
2434
- } else {
2435
- throw e;
2436
- }
3114
+ } else { throw e; }
2437
3115
  }
2438
3116
  }
2439
3117
 
@@ -2448,466 +3126,20 @@ async function __wbg_load(module, imports) {
2448
3126
  return instance;
2449
3127
  }
2450
3128
  }
2451
- }
2452
3129
 
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;
3130
+ function expectedResponseType(type) {
3131
+ switch (type) {
3132
+ case 'basic': case 'cors': case 'default': return true;
2721
3133
  }
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;
3134
+ return false;
3135
+ }
2904
3136
  }
2905
3137
 
2906
3138
  function initSync(module) {
2907
3139
  if (wasm !== undefined) return wasm;
2908
3140
 
2909
3141
 
2910
- if (typeof module !== 'undefined') {
3142
+ if (module !== undefined) {
2911
3143
  if (Object.getPrototypeOf(module) === Object.prototype) {
2912
3144
  ({module} = module)
2913
3145
  } else {
@@ -2927,7 +3159,7 @@ async function __wbg_init(module_or_path) {
2927
3159
  if (wasm !== undefined) return wasm;
2928
3160
 
2929
3161
 
2930
- if (typeof module_or_path !== 'undefined') {
3162
+ if (module_or_path !== undefined) {
2931
3163
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2932
3164
  ({module_or_path} = module_or_path)
2933
3165
  } else {
@@ -2935,7 +3167,7 @@ async function __wbg_init(module_or_path) {
2935
3167
  }
2936
3168
  }
2937
3169
 
2938
- if (typeof module_or_path === 'undefined') {
3170
+ if (module_or_path === undefined) {
2939
3171
  module_or_path = new URL('velesdb_wasm_bg.wasm', import.meta.url);
2940
3172
  }
2941
3173
  const imports = __wbg_get_imports();
@@ -2949,5 +3181,4 @@ async function __wbg_init(module_or_path) {
2949
3181
  return __wbg_finalize_init(instance, module);
2950
3182
  }
2951
3183
 
2952
- export { initSync };
2953
- export default __wbg_init;
3184
+ export { initSync, __wbg_init as default };