@wiscale/velesdb-wasm 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1107 @@
1
+ let wasm;
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
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
13
+ ? { register: () => {}, unregister: () => {} }
14
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
15
+
16
+ function debugString(val) {
17
+ // primitive types
18
+ const type = typeof val;
19
+ if (type == 'number' || type == 'boolean' || val == null) {
20
+ return `${val}`;
21
+ }
22
+ if (type == 'string') {
23
+ return `"${val}"`;
24
+ }
25
+ if (type == 'symbol') {
26
+ const description = val.description;
27
+ if (description == null) {
28
+ return 'Symbol';
29
+ } else {
30
+ return `Symbol(${description})`;
31
+ }
32
+ }
33
+ if (type == 'function') {
34
+ const name = val.name;
35
+ if (typeof name == 'string' && name.length > 0) {
36
+ return `Function(${name})`;
37
+ } else {
38
+ return 'Function';
39
+ }
40
+ }
41
+ // objects
42
+ if (Array.isArray(val)) {
43
+ const length = val.length;
44
+ let debug = '[';
45
+ if (length > 0) {
46
+ debug += debugString(val[0]);
47
+ }
48
+ for(let i = 1; i < length; i++) {
49
+ debug += ', ' + debugString(val[i]);
50
+ }
51
+ debug += ']';
52
+ return debug;
53
+ }
54
+ // Test for built-in
55
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
56
+ let className;
57
+ if (builtInMatches && builtInMatches.length > 1) {
58
+ className = builtInMatches[1];
59
+ } else {
60
+ // Failed to match the standard '[object ClassName]'
61
+ return toString.call(val);
62
+ }
63
+ if (className == 'Object') {
64
+ // we're a user defined class or Object
65
+ // JSON.stringify avoids problems with cycles, and is generally much
66
+ // easier than looping through ownProperties of `val`.
67
+ try {
68
+ return 'Object(' + JSON.stringify(val) + ')';
69
+ } catch (_) {
70
+ return 'Object';
71
+ }
72
+ }
73
+ // errors
74
+ if (val instanceof Error) {
75
+ return `${val.name}: ${val.message}\n${val.stack}`;
76
+ }
77
+ // TODO we could test for more things here, like `Set`s and `Map`s.
78
+ return className;
79
+ }
80
+
81
+ function dropObject(idx) {
82
+ if (idx < 132) return;
83
+ heap[idx] = heap_next;
84
+ heap_next = idx;
85
+ }
86
+
87
+ function getArrayU8FromWasm0(ptr, len) {
88
+ ptr = ptr >>> 0;
89
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
90
+ }
91
+
92
+ let cachedDataViewMemory0 = null;
93
+ function getDataViewMemory0() {
94
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
95
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
96
+ }
97
+ return cachedDataViewMemory0;
98
+ }
99
+
100
+ let cachedFloat32ArrayMemory0 = null;
101
+ function getFloat32ArrayMemory0() {
102
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
103
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
104
+ }
105
+ return cachedFloat32ArrayMemory0;
106
+ }
107
+
108
+ function getStringFromWasm0(ptr, len) {
109
+ ptr = ptr >>> 0;
110
+ return decodeText(ptr, len);
111
+ }
112
+
113
+ let cachedUint8ArrayMemory0 = null;
114
+ function getUint8ArrayMemory0() {
115
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
116
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
117
+ }
118
+ return cachedUint8ArrayMemory0;
119
+ }
120
+
121
+ function getObject(idx) { return heap[idx]; }
122
+
123
+ function handleError(f, args) {
124
+ try {
125
+ return f.apply(this, args);
126
+ } catch (e) {
127
+ wasm.__wbindgen_export3(addHeapObject(e));
128
+ }
129
+ }
130
+
131
+ let heap = new Array(128).fill(undefined);
132
+ heap.push(undefined, null, true, false);
133
+
134
+ let heap_next = heap.length;
135
+
136
+ function isLikeNone(x) {
137
+ return x === undefined || x === null;
138
+ }
139
+
140
+ function makeMutClosure(arg0, arg1, dtor, f) {
141
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
142
+ const real = (...args) => {
143
+
144
+ // First up with a closure we increment the internal reference
145
+ // count. This ensures that the Rust closure environment won't
146
+ // be deallocated while we're invoking it.
147
+ state.cnt++;
148
+ const a = state.a;
149
+ state.a = 0;
150
+ try {
151
+ return f(a, state.b, ...args);
152
+ } finally {
153
+ state.a = a;
154
+ real._wbg_cb_unref();
155
+ }
156
+ };
157
+ real._wbg_cb_unref = () => {
158
+ if (--state.cnt === 0) {
159
+ state.dtor(state.a, state.b);
160
+ state.a = 0;
161
+ CLOSURE_DTORS.unregister(state);
162
+ }
163
+ };
164
+ CLOSURE_DTORS.register(real, state, state);
165
+ return real;
166
+ }
167
+
168
+ function passArray8ToWasm0(arg, malloc) {
169
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
170
+ getUint8ArrayMemory0().set(arg, ptr / 1);
171
+ WASM_VECTOR_LEN = arg.length;
172
+ return ptr;
173
+ }
174
+
175
+ function passArrayF32ToWasm0(arg, malloc) {
176
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
177
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
178
+ WASM_VECTOR_LEN = arg.length;
179
+ return ptr;
180
+ }
181
+
182
+ function passStringToWasm0(arg, malloc, realloc) {
183
+ if (realloc === undefined) {
184
+ const buf = cachedTextEncoder.encode(arg);
185
+ const ptr = malloc(buf.length, 1) >>> 0;
186
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
187
+ WASM_VECTOR_LEN = buf.length;
188
+ return ptr;
189
+ }
190
+
191
+ let len = arg.length;
192
+ let ptr = malloc(len, 1) >>> 0;
193
+
194
+ const mem = getUint8ArrayMemory0();
195
+
196
+ let offset = 0;
197
+
198
+ for (; offset < len; offset++) {
199
+ const code = arg.charCodeAt(offset);
200
+ if (code > 0x7F) break;
201
+ mem[ptr + offset] = code;
202
+ }
203
+ if (offset !== len) {
204
+ if (offset !== 0) {
205
+ arg = arg.slice(offset);
206
+ }
207
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
208
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
209
+ const ret = cachedTextEncoder.encodeInto(arg, view);
210
+
211
+ offset += ret.written;
212
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
213
+ }
214
+
215
+ WASM_VECTOR_LEN = offset;
216
+ return ptr;
217
+ }
218
+
219
+ function takeObject(idx) {
220
+ const ret = getObject(idx);
221
+ dropObject(idx);
222
+ return ret;
223
+ }
224
+
225
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
226
+ cachedTextDecoder.decode();
227
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
228
+ let numBytesDecoded = 0;
229
+ function decodeText(ptr, len) {
230
+ numBytesDecoded += len;
231
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
232
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
233
+ cachedTextDecoder.decode();
234
+ numBytesDecoded = len;
235
+ }
236
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
237
+ }
238
+
239
+ const cachedTextEncoder = new TextEncoder();
240
+
241
+ if (!('encodeInto' in cachedTextEncoder)) {
242
+ cachedTextEncoder.encodeInto = function (arg, view) {
243
+ const buf = cachedTextEncoder.encode(arg);
244
+ view.set(buf);
245
+ return {
246
+ read: arg.length,
247
+ written: buf.length
248
+ };
249
+ }
250
+ }
251
+
252
+ let WASM_VECTOR_LEN = 0;
253
+
254
+ function __wasm_bindgen_func_elem_382(arg0, arg1, arg2) {
255
+ wasm.__wasm_bindgen_func_elem_382(arg0, arg1, addHeapObject(arg2));
256
+ }
257
+
258
+ function __wasm_bindgen_func_elem_93(arg0, arg1, arg2) {
259
+ wasm.__wasm_bindgen_func_elem_93(arg0, arg1, addHeapObject(arg2));
260
+ }
261
+
262
+ function __wasm_bindgen_func_elem_429(arg0, arg1, arg2, arg3) {
263
+ wasm.__wasm_bindgen_func_elem_429(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
264
+ }
265
+
266
+ const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
267
+
268
+ const VectorStoreFinalization = (typeof FinalizationRegistry === 'undefined')
269
+ ? { register: () => {}, unregister: () => {} }
270
+ : new FinalizationRegistry(ptr => wasm.__wbg_vectorstore_free(ptr >>> 0, 1));
271
+
272
+ /**
273
+ * A vector store for in-memory vector search.
274
+ *
275
+ * # Performance
276
+ *
277
+ * Uses contiguous memory layout for optimal cache locality and fast
278
+ * serialization. Vector data is stored in a single buffer rather than
279
+ * individual Vec allocations.
280
+ */
281
+ export class VectorStore {
282
+ static __wrap(ptr) {
283
+ ptr = ptr >>> 0;
284
+ const obj = Object.create(VectorStore.prototype);
285
+ obj.__wbg_ptr = ptr;
286
+ VectorStoreFinalization.register(obj, obj.__wbg_ptr, obj);
287
+ return obj;
288
+ }
289
+ __destroy_into_raw() {
290
+ const ptr = this.__wbg_ptr;
291
+ this.__wbg_ptr = 0;
292
+ VectorStoreFinalization.unregister(this);
293
+ return ptr;
294
+ }
295
+ free() {
296
+ const ptr = this.__destroy_into_raw();
297
+ wasm.__wbg_vectorstore_free(ptr, 0);
298
+ }
299
+ /**
300
+ * Inserts multiple vectors in a single batch operation.
301
+ *
302
+ * This is significantly faster than calling `insert()` multiple times
303
+ * because it pre-allocates memory and reduces per-call overhead.
304
+ *
305
+ * # Arguments
306
+ *
307
+ * * `batch` - JavaScript array of `[id, Float32Array]` pairs
308
+ *
309
+ * # Errors
310
+ *
311
+ * Returns an error if any vector dimension doesn't match store dimension.
312
+ * @param {any} batch
313
+ */
314
+ insert_batch(batch) {
315
+ try {
316
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
317
+ wasm.vectorstore_insert_batch(retptr, this.__wbg_ptr, addHeapObject(batch));
318
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
319
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
320
+ if (r1) {
321
+ throw takeObject(r0);
322
+ }
323
+ } finally {
324
+ wasm.__wbindgen_add_to_stack_pointer(16);
325
+ }
326
+ }
327
+ /**
328
+ * Returns memory usage estimate in bytes.
329
+ * @returns {number}
330
+ */
331
+ memory_usage() {
332
+ const ret = wasm.vectorstore_memory_usage(this.__wbg_ptr);
333
+ return ret >>> 0;
334
+ }
335
+ /**
336
+ * Creates a new vector store with pre-allocated capacity.
337
+ *
338
+ * This is more efficient when you know the approximate number of vectors
339
+ * you'll be inserting, as it avoids repeated memory allocations.
340
+ *
341
+ * # Arguments
342
+ *
343
+ * * `dimension` - Vector dimension
344
+ * * `metric` - Distance metric: "cosine", "euclidean", or "dot"
345
+ * * `capacity` - Number of vectors to pre-allocate space for
346
+ *
347
+ * # Errors
348
+ *
349
+ * Returns an error if the metric is not recognized.
350
+ * @param {number} dimension
351
+ * @param {string} metric
352
+ * @param {number} capacity
353
+ * @returns {VectorStore}
354
+ */
355
+ static with_capacity(dimension, metric, capacity) {
356
+ try {
357
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
358
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
359
+ const len0 = WASM_VECTOR_LEN;
360
+ wasm.vectorstore_with_capacity(retptr, dimension, ptr0, len0, capacity);
361
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
362
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
363
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
364
+ if (r2) {
365
+ throw takeObject(r1);
366
+ }
367
+ return VectorStore.__wrap(r0);
368
+ } finally {
369
+ wasm.__wbindgen_add_to_stack_pointer(16);
370
+ }
371
+ }
372
+ /**
373
+ * Deletes the `IndexedDB` database.
374
+ *
375
+ * Use this to clear all persisted data.
376
+ *
377
+ * # Arguments
378
+ *
379
+ * * `db_name` - Name of the `IndexedDB` database to delete
380
+ *
381
+ * # Errors
382
+ *
383
+ * Returns an error if the deletion fails.
384
+ * @param {string} db_name
385
+ * @returns {Promise<void>}
386
+ */
387
+ static delete_database(db_name) {
388
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
389
+ const len0 = WASM_VECTOR_LEN;
390
+ const ret = wasm.vectorstore_delete_database(ptr0, len0);
391
+ return takeObject(ret);
392
+ }
393
+ /**
394
+ * Exports the vector store to a binary format.
395
+ *
396
+ * The binary format contains:
397
+ * - Header: dimension (u32), metric (u8), count (u64)
398
+ * - For each vector: id (u64), data (f32 array)
399
+ *
400
+ * Use this to persist data to `IndexedDB` or `localStorage`.
401
+ *
402
+ * # Errors
403
+ *
404
+ * This function currently does not return errors but uses `Result`
405
+ * for future extensibility.
406
+ *
407
+ * # Performance
408
+ *
409
+ * Perf: Pre-allocates exact buffer size to avoid reallocations.
410
+ * Throughput: ~1600 MB/s on 10k vectors (768D)
411
+ * @returns {Uint8Array}
412
+ */
413
+ export_to_bytes() {
414
+ try {
415
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
416
+ wasm.vectorstore_export_to_bytes(retptr, this.__wbg_ptr);
417
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
418
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
419
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
420
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
421
+ if (r3) {
422
+ throw takeObject(r2);
423
+ }
424
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
425
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
426
+ return v1;
427
+ } finally {
428
+ wasm.__wbindgen_add_to_stack_pointer(16);
429
+ }
430
+ }
431
+ /**
432
+ * Imports a vector store from binary format.
433
+ *
434
+ * Use this to restore data from `IndexedDB` or `localStorage`.
435
+ *
436
+ * # Errors
437
+ *
438
+ * Returns an error if:
439
+ * - The data is too short or corrupted
440
+ * - The magic number is invalid
441
+ * - The version is unsupported
442
+ * - The metric byte is invalid
443
+ * @param {Uint8Array} bytes
444
+ * @returns {VectorStore}
445
+ */
446
+ static import_from_bytes(bytes) {
447
+ try {
448
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
449
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
450
+ const len0 = WASM_VECTOR_LEN;
451
+ wasm.vectorstore_import_from_bytes(retptr, ptr0, len0);
452
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
453
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
454
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
455
+ if (r2) {
456
+ throw takeObject(r1);
457
+ }
458
+ return VectorStore.__wrap(r0);
459
+ } finally {
460
+ wasm.__wbindgen_add_to_stack_pointer(16);
461
+ }
462
+ }
463
+ /**
464
+ * Returns the number of vectors in the store.
465
+ * @returns {number}
466
+ */
467
+ get len() {
468
+ const ret = wasm.vectorstore_len(this.__wbg_ptr);
469
+ return ret >>> 0;
470
+ }
471
+ /**
472
+ * Creates a new vector store with the specified dimension and distance metric.
473
+ *
474
+ * # Arguments
475
+ *
476
+ * * `dimension` - Vector dimension (e.g., 768 for BERT, 1536 for GPT)
477
+ * * `metric` - Distance metric: "cosine", "euclidean", or "dot"
478
+ *
479
+ * # Errors
480
+ *
481
+ * Returns an error if the metric is not recognized.
482
+ * @param {number} dimension
483
+ * @param {string} metric
484
+ */
485
+ constructor(dimension, metric) {
486
+ try {
487
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
488
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
489
+ const len0 = WASM_VECTOR_LEN;
490
+ wasm.vectorstore_new(retptr, dimension, ptr0, len0);
491
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
492
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
493
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
494
+ if (r2) {
495
+ throw takeObject(r1);
496
+ }
497
+ this.__wbg_ptr = r0 >>> 0;
498
+ VectorStoreFinalization.register(this, this.__wbg_ptr, this);
499
+ return this;
500
+ } finally {
501
+ wasm.__wbindgen_add_to_stack_pointer(16);
502
+ }
503
+ }
504
+ /**
505
+ * Loads a vector store from `IndexedDB`.
506
+ *
507
+ * This method restores all vectors from the browser's `IndexedDB`.
508
+ *
509
+ * # Arguments
510
+ *
511
+ * * `db_name` - Name of the `IndexedDB` database
512
+ *
513
+ * # Errors
514
+ *
515
+ * Returns an error if the database doesn't exist or is corrupted.
516
+ *
517
+ * # Example
518
+ *
519
+ * ```javascript
520
+ * const store = await VectorStore.load("my-vectors");
521
+ * console.log(store.len); // Number of restored vectors
522
+ * ```
523
+ * @param {string} db_name
524
+ * @returns {Promise<VectorStore>}
525
+ */
526
+ static load(db_name) {
527
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
528
+ const len0 = WASM_VECTOR_LEN;
529
+ const ret = wasm.vectorstore_load(ptr0, len0);
530
+ return takeObject(ret);
531
+ }
532
+ /**
533
+ * Saves the vector store to `IndexedDB`.
534
+ *
535
+ * This method persists all vectors to the browser's `IndexedDB`,
536
+ * enabling offline-first applications.
537
+ *
538
+ * # Arguments
539
+ *
540
+ * * `db_name` - Name of the `IndexedDB` database
541
+ *
542
+ * # Errors
543
+ *
544
+ * Returns an error if `IndexedDB` is not available or the save fails.
545
+ *
546
+ * # Example
547
+ *
548
+ * ```javascript
549
+ * const store = new VectorStore(768, "cosine");
550
+ * store.insert(1n, vector1);
551
+ * await store.save("my-vectors");
552
+ * ```
553
+ * @param {string} db_name
554
+ * @returns {Promise<void>}
555
+ */
556
+ save(db_name) {
557
+ const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
558
+ const len0 = WASM_VECTOR_LEN;
559
+ const ret = wasm.vectorstore_save(this.__wbg_ptr, ptr0, len0);
560
+ return takeObject(ret);
561
+ }
562
+ /**
563
+ * Clears all vectors from the store.
564
+ */
565
+ clear() {
566
+ wasm.vectorstore_clear(this.__wbg_ptr);
567
+ }
568
+ /**
569
+ * Inserts a vector with the given ID.
570
+ *
571
+ * # Arguments
572
+ *
573
+ * * `id` - Unique identifier for the vector
574
+ * * `vector` - `Float32Array` of the vector data
575
+ *
576
+ * # Errors
577
+ *
578
+ * Returns an error if vector dimension doesn't match store dimension.
579
+ * @param {bigint} id
580
+ * @param {Float32Array} vector
581
+ */
582
+ insert(id, vector) {
583
+ try {
584
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
585
+ const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
586
+ const len0 = WASM_VECTOR_LEN;
587
+ wasm.vectorstore_insert(retptr, this.__wbg_ptr, id, ptr0, len0);
588
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
589
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
590
+ if (r1) {
591
+ throw takeObject(r0);
592
+ }
593
+ } finally {
594
+ wasm.__wbindgen_add_to_stack_pointer(16);
595
+ }
596
+ }
597
+ /**
598
+ * Removes a vector by ID.
599
+ * @param {bigint} id
600
+ * @returns {boolean}
601
+ */
602
+ remove(id) {
603
+ const ret = wasm.vectorstore_remove(this.__wbg_ptr, id);
604
+ return ret !== 0;
605
+ }
606
+ /**
607
+ * Searches for the k nearest neighbors to the query vector.
608
+ *
609
+ * # Arguments
610
+ *
611
+ * * `query` - Query vector as `Float32Array`
612
+ * * `k` - Number of results to return
613
+ *
614
+ * # Returns
615
+ *
616
+ * Array of [id, score] pairs sorted by relevance.
617
+ *
618
+ * # Errors
619
+ *
620
+ * Returns an error if query dimension doesn't match store dimension.
621
+ * @param {Float32Array} query
622
+ * @param {number} k
623
+ * @returns {any}
624
+ */
625
+ search(query, k) {
626
+ try {
627
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
628
+ const ptr0 = passArrayF32ToWasm0(query, wasm.__wbindgen_export);
629
+ const len0 = WASM_VECTOR_LEN;
630
+ wasm.vectorstore_search(retptr, this.__wbg_ptr, ptr0, len0, k);
631
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
632
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
633
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
634
+ if (r2) {
635
+ throw takeObject(r1);
636
+ }
637
+ return takeObject(r0);
638
+ } finally {
639
+ wasm.__wbindgen_add_to_stack_pointer(16);
640
+ }
641
+ }
642
+ /**
643
+ * Pre-allocates memory for the specified number of additional vectors.
644
+ *
645
+ * Call this before bulk insertions to avoid repeated allocations.
646
+ *
647
+ * # Arguments
648
+ *
649
+ * * `additional` - Number of additional vectors to reserve space for
650
+ * @param {number} additional
651
+ */
652
+ reserve(additional) {
653
+ wasm.vectorstore_reserve(this.__wbg_ptr, additional);
654
+ }
655
+ /**
656
+ * Returns true if the store is empty.
657
+ * @returns {boolean}
658
+ */
659
+ get is_empty() {
660
+ const ret = wasm.vectorstore_is_empty(this.__wbg_ptr);
661
+ return ret !== 0;
662
+ }
663
+ /**
664
+ * Returns the vector dimension.
665
+ * @returns {number}
666
+ */
667
+ get dimension() {
668
+ const ret = wasm.vectorstore_dimension(this.__wbg_ptr);
669
+ return ret >>> 0;
670
+ }
671
+ }
672
+ if (Symbol.dispose) VectorStore.prototype[Symbol.dispose] = VectorStore.prototype.free;
673
+
674
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
675
+
676
+ async function __wbg_load(module, imports) {
677
+ if (typeof Response === 'function' && module instanceof Response) {
678
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
679
+ try {
680
+ return await WebAssembly.instantiateStreaming(module, imports);
681
+ } catch (e) {
682
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
683
+
684
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
685
+ 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);
686
+
687
+ } else {
688
+ throw e;
689
+ }
690
+ }
691
+ }
692
+
693
+ const bytes = await module.arrayBuffer();
694
+ return await WebAssembly.instantiate(bytes, imports);
695
+ } else {
696
+ const instance = await WebAssembly.instantiate(module, imports);
697
+
698
+ if (instance instanceof WebAssembly.Instance) {
699
+ return { instance, module };
700
+ } else {
701
+ return instance;
702
+ }
703
+ }
704
+ }
705
+
706
+ function __wbg_get_imports() {
707
+ const imports = {};
708
+ imports.wbg = {};
709
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
710
+ const ret = Error(getStringFromWasm0(arg0, arg1));
711
+ return addHeapObject(ret);
712
+ };
713
+ imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
714
+ const ret = Number(getObject(arg0));
715
+ return ret;
716
+ };
717
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
718
+ const ret = String(getObject(arg1));
719
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
720
+ const len1 = WASM_VECTOR_LEN;
721
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
722
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
723
+ };
724
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
725
+ const v = getObject(arg1);
726
+ const ret = typeof(v) === 'bigint' ? v : undefined;
727
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
728
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
729
+ };
730
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
731
+ const v = getObject(arg0);
732
+ const ret = typeof(v) === 'boolean' ? v : undefined;
733
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
734
+ };
735
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
736
+ const ret = debugString(getObject(arg1));
737
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
738
+ const len1 = WASM_VECTOR_LEN;
739
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
740
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
741
+ };
742
+ imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
743
+ const ret = typeof(getObject(arg0)) === 'bigint';
744
+ return ret;
745
+ };
746
+ imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
747
+ const ret = typeof(getObject(arg0)) === 'function';
748
+ return ret;
749
+ };
750
+ imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
751
+ const ret = getObject(arg0) === null;
752
+ return ret;
753
+ };
754
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
755
+ const val = getObject(arg0);
756
+ const ret = typeof(val) === 'object' && val !== null;
757
+ return ret;
758
+ };
759
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
760
+ const ret = getObject(arg0) === undefined;
761
+ return ret;
762
+ };
763
+ imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
764
+ const ret = getObject(arg0) === getObject(arg1);
765
+ return ret;
766
+ };
767
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
768
+ const ret = getObject(arg0) == getObject(arg1);
769
+ return ret;
770
+ };
771
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
772
+ const obj = getObject(arg1);
773
+ const ret = typeof(obj) === 'number' ? obj : undefined;
774
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
775
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
776
+ };
777
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
778
+ const obj = getObject(arg1);
779
+ const ret = typeof(obj) === 'string' ? obj : undefined;
780
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
781
+ var len1 = WASM_VECTOR_LEN;
782
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
783
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
784
+ };
785
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
786
+ throw new Error(getStringFromWasm0(arg0, arg1));
787
+ };
788
+ imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
789
+ getObject(arg0)._wbg_cb_unref();
790
+ };
791
+ imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
792
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
793
+ return addHeapObject(ret);
794
+ }, arguments) };
795
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
796
+ const ret = getObject(arg0).call(getObject(arg1));
797
+ return addHeapObject(ret);
798
+ }, arguments) };
799
+ imports.wbg.__wbg_createObjectStore_dba64acfe84d4191 = function() { return handleError(function (arg0, arg1, arg2) {
800
+ const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
801
+ return addHeapObject(ret);
802
+ }, arguments) };
803
+ imports.wbg.__wbg_deleteDatabase_19c91a8e3e6b92cf = function() { return handleError(function (arg0, arg1, arg2) {
804
+ const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
805
+ return addHeapObject(ret);
806
+ }, arguments) };
807
+ imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
808
+ const ret = getObject(arg0).done;
809
+ return ret;
810
+ };
811
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
812
+ const ret = getObject(arg0)[arg1 >>> 0];
813
+ return addHeapObject(ret);
814
+ };
815
+ imports.wbg.__wbg_get_7d8b665fa88606d5 = function() { return handleError(function (arg0, arg1) {
816
+ const ret = getObject(arg0).get(getObject(arg1));
817
+ return addHeapObject(ret);
818
+ }, arguments) };
819
+ imports.wbg.__wbg_get_985f6dca0ce6b776 = function(arg0, arg1, arg2) {
820
+ const ret = getObject(arg1)[arg2 >>> 0];
821
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
822
+ var len1 = WASM_VECTOR_LEN;
823
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
824
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
825
+ };
826
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
827
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
828
+ return addHeapObject(ret);
829
+ }, arguments) };
830
+ imports.wbg.__wbg_indexedDB_23c232e00a1e28ad = function() { return handleError(function (arg0) {
831
+ const ret = getObject(arg0).indexedDB;
832
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
833
+ }, arguments) };
834
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
835
+ let result;
836
+ try {
837
+ result = getObject(arg0) instanceof ArrayBuffer;
838
+ } catch (_) {
839
+ result = false;
840
+ }
841
+ const ret = result;
842
+ return ret;
843
+ };
844
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
845
+ let result;
846
+ try {
847
+ result = getObject(arg0) instanceof Uint8Array;
848
+ } catch (_) {
849
+ result = false;
850
+ }
851
+ const ret = result;
852
+ return ret;
853
+ };
854
+ imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) {
855
+ let result;
856
+ try {
857
+ result = getObject(arg0) instanceof Window;
858
+ } catch (_) {
859
+ result = false;
860
+ }
861
+ const ret = result;
862
+ return ret;
863
+ };
864
+ imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
865
+ const ret = Array.isArray(getObject(arg0));
866
+ return ret;
867
+ };
868
+ imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
869
+ const ret = Number.isSafeInteger(getObject(arg0));
870
+ return ret;
871
+ };
872
+ imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
873
+ const ret = Symbol.iterator;
874
+ return addHeapObject(ret);
875
+ };
876
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
877
+ const ret = getObject(arg0).length;
878
+ return ret;
879
+ };
880
+ imports.wbg.__wbg_length_9f7c82a979890e31 = function(arg0) {
881
+ const ret = getObject(arg0).length;
882
+ return ret;
883
+ };
884
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
885
+ const ret = getObject(arg0).length;
886
+ return ret;
887
+ };
888
+ imports.wbg.__wbg_new_25f239778d6112b9 = function() {
889
+ const ret = new Array();
890
+ return addHeapObject(ret);
891
+ };
892
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
893
+ const ret = new Uint8Array(getObject(arg0));
894
+ return addHeapObject(ret);
895
+ };
896
+ imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
897
+ try {
898
+ var state0 = {a: arg0, b: arg1};
899
+ var cb0 = (arg0, arg1) => {
900
+ const a = state0.a;
901
+ state0.a = 0;
902
+ try {
903
+ return __wasm_bindgen_func_elem_429(a, state0.b, arg0, arg1);
904
+ } finally {
905
+ state0.a = a;
906
+ }
907
+ };
908
+ const ret = new Promise(cb0);
909
+ return addHeapObject(ret);
910
+ } finally {
911
+ state0.a = state0.b = 0;
912
+ }
913
+ };
914
+ imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
915
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
916
+ return addHeapObject(ret);
917
+ };
918
+ imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
919
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
920
+ return addHeapObject(ret);
921
+ };
922
+ imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
923
+ const ret = getObject(arg0).next;
924
+ return addHeapObject(ret);
925
+ };
926
+ imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
927
+ const ret = getObject(arg0).next();
928
+ return addHeapObject(ret);
929
+ }, arguments) };
930
+ imports.wbg.__wbg_objectStoreNames_90900f9a531513ac = function(arg0) {
931
+ const ret = getObject(arg0).objectStoreNames;
932
+ return addHeapObject(ret);
933
+ };
934
+ imports.wbg.__wbg_objectStore_da9a077b8849dbe9 = function() { return handleError(function (arg0, arg1, arg2) {
935
+ const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
936
+ return addHeapObject(ret);
937
+ }, arguments) };
938
+ imports.wbg.__wbg_open_2a2740c93beabe29 = function() { return handleError(function (arg0, arg1, arg2) {
939
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
940
+ return addHeapObject(ret);
941
+ }, arguments) };
942
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
943
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
944
+ };
945
+ imports.wbg.__wbg_put_d40a68e5a8902a46 = function() { return handleError(function (arg0, arg1, arg2) {
946
+ const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
947
+ return addHeapObject(ret);
948
+ }, arguments) };
949
+ imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
950
+ const ret = getObject(arg0).queueMicrotask;
951
+ return addHeapObject(ret);
952
+ };
953
+ imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
954
+ queueMicrotask(getObject(arg0));
955
+ };
956
+ imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
957
+ const ret = Promise.resolve(getObject(arg0));
958
+ return addHeapObject(ret);
959
+ };
960
+ imports.wbg.__wbg_result_084f962aedb54250 = function() { return handleError(function (arg0) {
961
+ const ret = getObject(arg0).result;
962
+ return addHeapObject(ret);
963
+ }, arguments) };
964
+ imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
965
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
966
+ };
967
+ imports.wbg.__wbg_set_onerror_08fecec3bdc9d24d = function(arg0, arg1) {
968
+ getObject(arg0).onerror = getObject(arg1);
969
+ };
970
+ imports.wbg.__wbg_set_onsuccess_94332a00452de699 = function(arg0, arg1) {
971
+ getObject(arg0).onsuccess = getObject(arg1);
972
+ };
973
+ imports.wbg.__wbg_set_onupgradeneeded_3dc6e233a6d13fe2 = function(arg0, arg1) {
974
+ getObject(arg0).onupgradeneeded = getObject(arg1);
975
+ };
976
+ imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
977
+ const ret = typeof global === 'undefined' ? null : global;
978
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
979
+ };
980
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
981
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
982
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
983
+ };
984
+ imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
985
+ const ret = typeof self === 'undefined' ? null : self;
986
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
987
+ };
988
+ imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
989
+ const ret = typeof window === 'undefined' ? null : window;
990
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
991
+ };
992
+ imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
993
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
994
+ return addHeapObject(ret);
995
+ };
996
+ imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
997
+ const ret = getObject(arg0).then(getObject(arg1));
998
+ return addHeapObject(ret);
999
+ };
1000
+ imports.wbg.__wbg_transaction_790ec170b8fbc74b = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1001
+ const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
1002
+ return addHeapObject(ret);
1003
+ }, arguments) };
1004
+ imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
1005
+ const ret = getObject(arg0).value;
1006
+ return addHeapObject(ret);
1007
+ };
1008
+ imports.wbg.__wbg_vectorstore_new = function(arg0) {
1009
+ const ret = VectorStore.__wrap(arg0);
1010
+ return addHeapObject(ret);
1011
+ };
1012
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1013
+ // Cast intrinsic for `Ref(String) -> Externref`.
1014
+ const ret = getStringFromWasm0(arg0, arg1);
1015
+ return addHeapObject(ret);
1016
+ };
1017
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1018
+ // Cast intrinsic for `U64 -> Externref`.
1019
+ const ret = BigInt.asUintN(64, arg0);
1020
+ return addHeapObject(ret);
1021
+ };
1022
+ imports.wbg.__wbindgen_cast_5672704bc77a612c = function(arg0, arg1) {
1023
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 44, function: Function { arguments: [Externref], shim_idx: 45, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1024
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_381, __wasm_bindgen_func_elem_382);
1025
+ return addHeapObject(ret);
1026
+ };
1027
+ imports.wbg.__wbindgen_cast_9cdd8d1a79740578 = function(arg0, arg1) {
1028
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 6, function: Function { arguments: [NamedExternref("Event")], shim_idx: 7, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1029
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_92, __wasm_bindgen_func_elem_93);
1030
+ return addHeapObject(ret);
1031
+ };
1032
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1033
+ // Cast intrinsic for `F64 -> Externref`.
1034
+ const ret = arg0;
1035
+ return addHeapObject(ret);
1036
+ };
1037
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1038
+ const ret = getObject(arg0);
1039
+ return addHeapObject(ret);
1040
+ };
1041
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1042
+ takeObject(arg0);
1043
+ };
1044
+
1045
+ return imports;
1046
+ }
1047
+
1048
+ function __wbg_finalize_init(instance, module) {
1049
+ wasm = instance.exports;
1050
+ __wbg_init.__wbindgen_wasm_module = module;
1051
+ cachedDataViewMemory0 = null;
1052
+ cachedFloat32ArrayMemory0 = null;
1053
+ cachedUint8ArrayMemory0 = null;
1054
+
1055
+
1056
+
1057
+ return wasm;
1058
+ }
1059
+
1060
+ function initSync(module) {
1061
+ if (wasm !== undefined) return wasm;
1062
+
1063
+
1064
+ if (typeof module !== 'undefined') {
1065
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1066
+ ({module} = module)
1067
+ } else {
1068
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1069
+ }
1070
+ }
1071
+
1072
+ const imports = __wbg_get_imports();
1073
+ if (!(module instanceof WebAssembly.Module)) {
1074
+ module = new WebAssembly.Module(module);
1075
+ }
1076
+ const instance = new WebAssembly.Instance(module, imports);
1077
+ return __wbg_finalize_init(instance, module);
1078
+ }
1079
+
1080
+ async function __wbg_init(module_or_path) {
1081
+ if (wasm !== undefined) return wasm;
1082
+
1083
+
1084
+ if (typeof module_or_path !== 'undefined') {
1085
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1086
+ ({module_or_path} = module_or_path)
1087
+ } else {
1088
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1089
+ }
1090
+ }
1091
+
1092
+ if (typeof module_or_path === 'undefined') {
1093
+ module_or_path = new URL('velesdb_wasm_bg.wasm', import.meta.url);
1094
+ }
1095
+ const imports = __wbg_get_imports();
1096
+
1097
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1098
+ module_or_path = fetch(module_or_path);
1099
+ }
1100
+
1101
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1102
+
1103
+ return __wbg_finalize_init(instance, module);
1104
+ }
1105
+
1106
+ export { initSync };
1107
+ export default __wbg_init;