rvlite 0.2.1 → 0.2.2
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/README.md +62 -0
- package/dist/cli-rvf.d.ts +57 -0
- package/dist/cli-rvf.d.ts.map +1 -0
- package/dist/cli-rvf.js +271 -0
- package/dist/cli-rvf.js.map +1 -0
- package/dist/index.d.ts +351 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2123 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2086 -0
- package/dist/wasm/package.json +2 -3
- package/dist/wasm/rvlite.d.ts +5 -5
- package/dist/wasm/rvlite.js +17 -16
- package/dist/wasm/rvlite_bg.wasm +0 -0
- package/dist/wasm/rvlite_bg.wasm.d.ts +5 -5
- package/package.json +9 -2
package/dist/index.js
ADDED
|
@@ -0,0 +1,2123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// dist/wasm/rvlite.js
|
|
34
|
+
var rvlite_exports = {};
|
|
35
|
+
__export(rvlite_exports, {
|
|
36
|
+
CypherEngine: () => CypherEngine,
|
|
37
|
+
RvLite: () => RvLite,
|
|
38
|
+
RvLiteConfig: () => RvLiteConfig,
|
|
39
|
+
default: () => rvlite_default,
|
|
40
|
+
init: () => init,
|
|
41
|
+
initSync: () => initSync
|
|
42
|
+
});
|
|
43
|
+
function addHeapObject(obj) {
|
|
44
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
45
|
+
const idx = heap_next;
|
|
46
|
+
heap_next = heap[idx];
|
|
47
|
+
heap[idx] = obj;
|
|
48
|
+
return idx;
|
|
49
|
+
}
|
|
50
|
+
function _assertClass(instance, klass) {
|
|
51
|
+
if (!(instance instanceof klass)) {
|
|
52
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function debugString(val) {
|
|
56
|
+
const type = typeof val;
|
|
57
|
+
if (type == "number" || type == "boolean" || val == null) {
|
|
58
|
+
return `${val}`;
|
|
59
|
+
}
|
|
60
|
+
if (type == "string") {
|
|
61
|
+
return `"${val}"`;
|
|
62
|
+
}
|
|
63
|
+
if (type == "symbol") {
|
|
64
|
+
const description = val.description;
|
|
65
|
+
if (description == null) {
|
|
66
|
+
return "Symbol";
|
|
67
|
+
} else {
|
|
68
|
+
return `Symbol(${description})`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (type == "function") {
|
|
72
|
+
const name = val.name;
|
|
73
|
+
if (typeof name == "string" && name.length > 0) {
|
|
74
|
+
return `Function(${name})`;
|
|
75
|
+
} else {
|
|
76
|
+
return "Function";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(val)) {
|
|
80
|
+
const length = val.length;
|
|
81
|
+
let debug = "[";
|
|
82
|
+
if (length > 0) {
|
|
83
|
+
debug += debugString(val[0]);
|
|
84
|
+
}
|
|
85
|
+
for (let i = 1; i < length; i++) {
|
|
86
|
+
debug += ", " + debugString(val[i]);
|
|
87
|
+
}
|
|
88
|
+
debug += "]";
|
|
89
|
+
return debug;
|
|
90
|
+
}
|
|
91
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
92
|
+
let className;
|
|
93
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
94
|
+
className = builtInMatches[1];
|
|
95
|
+
} else {
|
|
96
|
+
return toString.call(val);
|
|
97
|
+
}
|
|
98
|
+
if (className == "Object") {
|
|
99
|
+
try {
|
|
100
|
+
return "Object(" + JSON.stringify(val) + ")";
|
|
101
|
+
} catch (_) {
|
|
102
|
+
return "Object";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (val instanceof Error) {
|
|
106
|
+
return `${val.name}: ${val.message}
|
|
107
|
+
${val.stack}`;
|
|
108
|
+
}
|
|
109
|
+
return className;
|
|
110
|
+
}
|
|
111
|
+
function dropObject(idx) {
|
|
112
|
+
if (idx < 132) return;
|
|
113
|
+
heap[idx] = heap_next;
|
|
114
|
+
heap_next = idx;
|
|
115
|
+
}
|
|
116
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
117
|
+
ptr = ptr >>> 0;
|
|
118
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
119
|
+
}
|
|
120
|
+
function getDataViewMemory0() {
|
|
121
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
122
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
123
|
+
}
|
|
124
|
+
return cachedDataViewMemory0;
|
|
125
|
+
}
|
|
126
|
+
function getFloat32ArrayMemory0() {
|
|
127
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
128
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
129
|
+
}
|
|
130
|
+
return cachedFloat32ArrayMemory0;
|
|
131
|
+
}
|
|
132
|
+
function getStringFromWasm0(ptr, len) {
|
|
133
|
+
ptr = ptr >>> 0;
|
|
134
|
+
return decodeText(ptr, len);
|
|
135
|
+
}
|
|
136
|
+
function getUint8ArrayMemory0() {
|
|
137
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
138
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
139
|
+
}
|
|
140
|
+
return cachedUint8ArrayMemory0;
|
|
141
|
+
}
|
|
142
|
+
function getObject(idx) {
|
|
143
|
+
return heap[idx];
|
|
144
|
+
}
|
|
145
|
+
function handleError(f, args) {
|
|
146
|
+
try {
|
|
147
|
+
return f.apply(this, args);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function isLikeNone(x) {
|
|
153
|
+
return x === void 0 || x === null;
|
|
154
|
+
}
|
|
155
|
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
156
|
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
157
|
+
const real = (...args) => {
|
|
158
|
+
state.cnt++;
|
|
159
|
+
const a = state.a;
|
|
160
|
+
state.a = 0;
|
|
161
|
+
try {
|
|
162
|
+
return f(a, state.b, ...args);
|
|
163
|
+
} finally {
|
|
164
|
+
state.a = a;
|
|
165
|
+
real._wbg_cb_unref();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
real._wbg_cb_unref = () => {
|
|
169
|
+
if (--state.cnt === 0) {
|
|
170
|
+
state.dtor(state.a, state.b);
|
|
171
|
+
state.a = 0;
|
|
172
|
+
CLOSURE_DTORS.unregister(state);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
176
|
+
return real;
|
|
177
|
+
}
|
|
178
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
179
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
180
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
181
|
+
WASM_VECTOR_LEN = arg.length;
|
|
182
|
+
return ptr;
|
|
183
|
+
}
|
|
184
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
185
|
+
if (realloc === void 0) {
|
|
186
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
187
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
188
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
189
|
+
WASM_VECTOR_LEN = buf.length;
|
|
190
|
+
return ptr2;
|
|
191
|
+
}
|
|
192
|
+
let len = arg.length;
|
|
193
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
194
|
+
const mem = getUint8ArrayMemory0();
|
|
195
|
+
let offset = 0;
|
|
196
|
+
for (; offset < len; offset++) {
|
|
197
|
+
const code = arg.charCodeAt(offset);
|
|
198
|
+
if (code > 127) break;
|
|
199
|
+
mem[ptr + offset] = code;
|
|
200
|
+
}
|
|
201
|
+
if (offset !== len) {
|
|
202
|
+
if (offset !== 0) {
|
|
203
|
+
arg = arg.slice(offset);
|
|
204
|
+
}
|
|
205
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
206
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
207
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
208
|
+
offset += ret.written;
|
|
209
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
210
|
+
}
|
|
211
|
+
WASM_VECTOR_LEN = offset;
|
|
212
|
+
return ptr;
|
|
213
|
+
}
|
|
214
|
+
function takeObject(idx) {
|
|
215
|
+
const ret = getObject(idx);
|
|
216
|
+
dropObject(idx);
|
|
217
|
+
return ret;
|
|
218
|
+
}
|
|
219
|
+
function decodeText(ptr, len) {
|
|
220
|
+
numBytesDecoded += len;
|
|
221
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
222
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
223
|
+
cachedTextDecoder.decode();
|
|
224
|
+
numBytesDecoded = len;
|
|
225
|
+
}
|
|
226
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
227
|
+
}
|
|
228
|
+
function __wasm_bindgen_func_elem_1339(arg0, arg1, arg2) {
|
|
229
|
+
wasm.__wasm_bindgen_func_elem_1339(arg0, arg1, addHeapObject(arg2));
|
|
230
|
+
}
|
|
231
|
+
function __wasm_bindgen_func_elem_180(arg0, arg1, arg2) {
|
|
232
|
+
wasm.__wasm_bindgen_func_elem_180(arg0, arg1, addHeapObject(arg2));
|
|
233
|
+
}
|
|
234
|
+
function __wasm_bindgen_func_elem_1385(arg0, arg1, arg2, arg3) {
|
|
235
|
+
wasm.__wasm_bindgen_func_elem_1385(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
236
|
+
}
|
|
237
|
+
function init() {
|
|
238
|
+
wasm.init();
|
|
239
|
+
}
|
|
240
|
+
async function __wbg_load(module2, imports) {
|
|
241
|
+
if (typeof Response === "function" && module2 instanceof Response) {
|
|
242
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
243
|
+
try {
|
|
244
|
+
return await WebAssembly.instantiateStreaming(module2, imports);
|
|
245
|
+
} catch (e) {
|
|
246
|
+
const validResponse = module2.ok && EXPECTED_RESPONSE_TYPES.has(module2.type);
|
|
247
|
+
if (validResponse && module2.headers.get("Content-Type") !== "application/wasm") {
|
|
248
|
+
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);
|
|
249
|
+
} else {
|
|
250
|
+
throw e;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const bytes = await module2.arrayBuffer();
|
|
255
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
256
|
+
} else {
|
|
257
|
+
const instance = await WebAssembly.instantiate(module2, imports);
|
|
258
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
259
|
+
return { instance, module: module2 };
|
|
260
|
+
} else {
|
|
261
|
+
return instance;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function __wbg_get_imports() {
|
|
266
|
+
const imports = {};
|
|
267
|
+
imports.wbg = {};
|
|
268
|
+
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
269
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
270
|
+
return addHeapObject(ret);
|
|
271
|
+
};
|
|
272
|
+
imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
|
|
273
|
+
const ret = Number(getObject(arg0));
|
|
274
|
+
return ret;
|
|
275
|
+
};
|
|
276
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
277
|
+
const ret = String(getObject(arg1));
|
|
278
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
279
|
+
const len1 = WASM_VECTOR_LEN;
|
|
280
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
281
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
282
|
+
};
|
|
283
|
+
imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
|
|
284
|
+
const v = getObject(arg1);
|
|
285
|
+
const ret = typeof v === "bigint" ? v : void 0;
|
|
286
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
287
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
288
|
+
};
|
|
289
|
+
imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
|
|
290
|
+
const v = getObject(arg0);
|
|
291
|
+
const ret = typeof v === "boolean" ? v : void 0;
|
|
292
|
+
return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
|
|
293
|
+
};
|
|
294
|
+
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
295
|
+
const ret = debugString(getObject(arg1));
|
|
296
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
297
|
+
const len1 = WASM_VECTOR_LEN;
|
|
298
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
299
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
300
|
+
};
|
|
301
|
+
imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
|
|
302
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
303
|
+
return ret;
|
|
304
|
+
};
|
|
305
|
+
imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
|
|
306
|
+
const ret = typeof getObject(arg0) === "bigint";
|
|
307
|
+
return ret;
|
|
308
|
+
};
|
|
309
|
+
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
310
|
+
const ret = typeof getObject(arg0) === "function";
|
|
311
|
+
return ret;
|
|
312
|
+
};
|
|
313
|
+
imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
|
|
314
|
+
const ret = getObject(arg0) === null;
|
|
315
|
+
return ret;
|
|
316
|
+
};
|
|
317
|
+
imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
|
|
318
|
+
const val = getObject(arg0);
|
|
319
|
+
const ret = typeof val === "object" && val !== null;
|
|
320
|
+
return ret;
|
|
321
|
+
};
|
|
322
|
+
imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
|
323
|
+
const ret = typeof getObject(arg0) === "string";
|
|
324
|
+
return ret;
|
|
325
|
+
};
|
|
326
|
+
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
327
|
+
const ret = getObject(arg0) === void 0;
|
|
328
|
+
return ret;
|
|
329
|
+
};
|
|
330
|
+
imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
|
|
331
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
332
|
+
return ret;
|
|
333
|
+
};
|
|
334
|
+
imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
|
|
335
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
336
|
+
return ret;
|
|
337
|
+
};
|
|
338
|
+
imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
|
|
339
|
+
const obj = getObject(arg1);
|
|
340
|
+
const ret = typeof obj === "number" ? obj : void 0;
|
|
341
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
342
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
343
|
+
};
|
|
344
|
+
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
345
|
+
const obj = getObject(arg1);
|
|
346
|
+
const ret = typeof obj === "string" ? obj : void 0;
|
|
347
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
348
|
+
var len1 = WASM_VECTOR_LEN;
|
|
349
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
350
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
351
|
+
};
|
|
352
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
353
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
354
|
+
};
|
|
355
|
+
imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
|
|
356
|
+
getObject(arg0)._wbg_cb_unref();
|
|
357
|
+
};
|
|
358
|
+
imports.wbg.__wbg_call_3020136f7a2d6e44 = function() {
|
|
359
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
360
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
361
|
+
return addHeapObject(ret);
|
|
362
|
+
}, arguments);
|
|
363
|
+
};
|
|
364
|
+
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() {
|
|
365
|
+
return handleError(function(arg0, arg1) {
|
|
366
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
367
|
+
return addHeapObject(ret);
|
|
368
|
+
}, arguments);
|
|
369
|
+
};
|
|
370
|
+
imports.wbg.__wbg_clear_0e6ff4790cdabf11 = function() {
|
|
371
|
+
return handleError(function(arg0) {
|
|
372
|
+
const ret = getObject(arg0).clear();
|
|
373
|
+
return addHeapObject(ret);
|
|
374
|
+
}, arguments);
|
|
375
|
+
};
|
|
376
|
+
imports.wbg.__wbg_close_cf7ef4e294ac3858 = function(arg0) {
|
|
377
|
+
getObject(arg0).close();
|
|
378
|
+
};
|
|
379
|
+
imports.wbg.__wbg_contains_de2a27de1ed31877 = function(arg0, arg1, arg2) {
|
|
380
|
+
const ret = getObject(arg0).contains(getStringFromWasm0(arg1, arg2));
|
|
381
|
+
return ret;
|
|
382
|
+
};
|
|
383
|
+
imports.wbg.__wbg_count_5aeeb43c8c540e73 = function() {
|
|
384
|
+
return handleError(function(arg0, arg1) {
|
|
385
|
+
const ret = getObject(arg0).count(getObject(arg1));
|
|
386
|
+
return addHeapObject(ret);
|
|
387
|
+
}, arguments);
|
|
388
|
+
};
|
|
389
|
+
imports.wbg.__wbg_createObjectStore_dba64acfe84d4191 = function() {
|
|
390
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
391
|
+
const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
|
|
392
|
+
return addHeapObject(ret);
|
|
393
|
+
}, arguments);
|
|
394
|
+
};
|
|
395
|
+
imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
|
|
396
|
+
const ret = getObject(arg0).done;
|
|
397
|
+
return ret;
|
|
398
|
+
};
|
|
399
|
+
imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
|
|
400
|
+
const ret = Object.entries(getObject(arg0));
|
|
401
|
+
return addHeapObject(ret);
|
|
402
|
+
};
|
|
403
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
404
|
+
let deferred0_0;
|
|
405
|
+
let deferred0_1;
|
|
406
|
+
try {
|
|
407
|
+
deferred0_0 = arg0;
|
|
408
|
+
deferred0_1 = arg1;
|
|
409
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
410
|
+
} finally {
|
|
411
|
+
wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
415
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
416
|
+
return addHeapObject(ret);
|
|
417
|
+
};
|
|
418
|
+
imports.wbg.__wbg_get_7d8b665fa88606d5 = function() {
|
|
419
|
+
return handleError(function(arg0, arg1) {
|
|
420
|
+
const ret = getObject(arg0).get(getObject(arg1));
|
|
421
|
+
return addHeapObject(ret);
|
|
422
|
+
}, arguments);
|
|
423
|
+
};
|
|
424
|
+
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() {
|
|
425
|
+
return handleError(function(arg0, arg1) {
|
|
426
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
427
|
+
return addHeapObject(ret);
|
|
428
|
+
}, arguments);
|
|
429
|
+
};
|
|
430
|
+
imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
|
|
431
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
432
|
+
return addHeapObject(ret);
|
|
433
|
+
};
|
|
434
|
+
imports.wbg.__wbg_indexedDB_23c232e00a1e28ad = function() {
|
|
435
|
+
return handleError(function(arg0) {
|
|
436
|
+
const ret = getObject(arg0).indexedDB;
|
|
437
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
438
|
+
}, arguments);
|
|
439
|
+
};
|
|
440
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
|
|
441
|
+
let result;
|
|
442
|
+
try {
|
|
443
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
444
|
+
} catch (_) {
|
|
445
|
+
result = false;
|
|
446
|
+
}
|
|
447
|
+
const ret = result;
|
|
448
|
+
return ret;
|
|
449
|
+
};
|
|
450
|
+
imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
|
|
451
|
+
let result;
|
|
452
|
+
try {
|
|
453
|
+
result = getObject(arg0) instanceof Map;
|
|
454
|
+
} catch (_) {
|
|
455
|
+
result = false;
|
|
456
|
+
}
|
|
457
|
+
const ret = result;
|
|
458
|
+
return ret;
|
|
459
|
+
};
|
|
460
|
+
imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
|
|
461
|
+
let result;
|
|
462
|
+
try {
|
|
463
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
464
|
+
} catch (_) {
|
|
465
|
+
result = false;
|
|
466
|
+
}
|
|
467
|
+
const ret = result;
|
|
468
|
+
return ret;
|
|
469
|
+
};
|
|
470
|
+
imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) {
|
|
471
|
+
let result;
|
|
472
|
+
try {
|
|
473
|
+
result = getObject(arg0) instanceof Window;
|
|
474
|
+
} catch (_) {
|
|
475
|
+
result = false;
|
|
476
|
+
}
|
|
477
|
+
const ret = result;
|
|
478
|
+
return ret;
|
|
479
|
+
};
|
|
480
|
+
imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
|
|
481
|
+
const ret = Array.isArray(getObject(arg0));
|
|
482
|
+
return ret;
|
|
483
|
+
};
|
|
484
|
+
imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
|
|
485
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
486
|
+
return ret;
|
|
487
|
+
};
|
|
488
|
+
imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
|
|
489
|
+
const ret = Symbol.iterator;
|
|
490
|
+
return addHeapObject(ret);
|
|
491
|
+
};
|
|
492
|
+
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
493
|
+
const ret = getObject(arg0).length;
|
|
494
|
+
return ret;
|
|
495
|
+
};
|
|
496
|
+
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
497
|
+
const ret = getObject(arg0).length;
|
|
498
|
+
return ret;
|
|
499
|
+
};
|
|
500
|
+
imports.wbg.__wbg_log_1d990106d99dacb7 = function(arg0) {
|
|
501
|
+
console.log(getObject(arg0));
|
|
502
|
+
};
|
|
503
|
+
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
504
|
+
const ret = new Object();
|
|
505
|
+
return addHeapObject(ret);
|
|
506
|
+
};
|
|
507
|
+
imports.wbg.__wbg_new_25f239778d6112b9 = function() {
|
|
508
|
+
const ret = new Array();
|
|
509
|
+
return addHeapObject(ret);
|
|
510
|
+
};
|
|
511
|
+
imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
|
|
512
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
513
|
+
return addHeapObject(ret);
|
|
514
|
+
};
|
|
515
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
516
|
+
const ret = new Error();
|
|
517
|
+
return addHeapObject(ret);
|
|
518
|
+
};
|
|
519
|
+
imports.wbg.__wbg_new_b546ae120718850e = function() {
|
|
520
|
+
const ret = /* @__PURE__ */ new Map();
|
|
521
|
+
return addHeapObject(ret);
|
|
522
|
+
};
|
|
523
|
+
imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
|
|
524
|
+
try {
|
|
525
|
+
var state0 = { a: arg0, b: arg1 };
|
|
526
|
+
var cb0 = (arg02, arg12) => {
|
|
527
|
+
const a = state0.a;
|
|
528
|
+
state0.a = 0;
|
|
529
|
+
try {
|
|
530
|
+
return __wasm_bindgen_func_elem_1385(a, state0.b, arg02, arg12);
|
|
531
|
+
} finally {
|
|
532
|
+
state0.a = a;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
const ret = new Promise(cb0);
|
|
536
|
+
return addHeapObject(ret);
|
|
537
|
+
} finally {
|
|
538
|
+
state0.a = state0.b = 0;
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
542
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
543
|
+
return addHeapObject(ret);
|
|
544
|
+
};
|
|
545
|
+
imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
|
|
546
|
+
const ret = getObject(arg0).next;
|
|
547
|
+
return addHeapObject(ret);
|
|
548
|
+
};
|
|
549
|
+
imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() {
|
|
550
|
+
return handleError(function(arg0) {
|
|
551
|
+
const ret = getObject(arg0).next();
|
|
552
|
+
return addHeapObject(ret);
|
|
553
|
+
}, arguments);
|
|
554
|
+
};
|
|
555
|
+
imports.wbg.__wbg_now_69d776cd24f5215b = function() {
|
|
556
|
+
const ret = Date.now();
|
|
557
|
+
return ret;
|
|
558
|
+
};
|
|
559
|
+
imports.wbg.__wbg_objectStoreNames_90900f9a531513ac = function(arg0) {
|
|
560
|
+
const ret = getObject(arg0).objectStoreNames;
|
|
561
|
+
return addHeapObject(ret);
|
|
562
|
+
};
|
|
563
|
+
imports.wbg.__wbg_objectStore_da9a077b8849dbe9 = function() {
|
|
564
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
565
|
+
const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
|
|
566
|
+
return addHeapObject(ret);
|
|
567
|
+
}, arguments);
|
|
568
|
+
};
|
|
569
|
+
imports.wbg.__wbg_open_0d7b85f4c0a38ffe = function() {
|
|
570
|
+
return handleError(function(arg0, arg1, arg2, arg3) {
|
|
571
|
+
const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
|
|
572
|
+
return addHeapObject(ret);
|
|
573
|
+
}, arguments);
|
|
574
|
+
};
|
|
575
|
+
imports.wbg.__wbg_parse_a09a54cf72639456 = function() {
|
|
576
|
+
return handleError(function(arg0, arg1) {
|
|
577
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
578
|
+
return addHeapObject(ret);
|
|
579
|
+
}, arguments);
|
|
580
|
+
};
|
|
581
|
+
imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
|
582
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
583
|
+
};
|
|
584
|
+
imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
|
|
585
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
586
|
+
return ret;
|
|
587
|
+
};
|
|
588
|
+
imports.wbg.__wbg_put_d40a68e5a8902a46 = function() {
|
|
589
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
590
|
+
const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
|
|
591
|
+
return addHeapObject(ret);
|
|
592
|
+
}, arguments);
|
|
593
|
+
};
|
|
594
|
+
imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
|
|
595
|
+
const ret = getObject(arg0).queueMicrotask;
|
|
596
|
+
return addHeapObject(ret);
|
|
597
|
+
};
|
|
598
|
+
imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
|
|
599
|
+
queueMicrotask(getObject(arg0));
|
|
600
|
+
};
|
|
601
|
+
imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
|
|
602
|
+
const ret = Promise.resolve(getObject(arg0));
|
|
603
|
+
return addHeapObject(ret);
|
|
604
|
+
};
|
|
605
|
+
imports.wbg.__wbg_result_084f962aedb54250 = function() {
|
|
606
|
+
return handleError(function(arg0) {
|
|
607
|
+
const ret = getObject(arg0).result;
|
|
608
|
+
return addHeapObject(ret);
|
|
609
|
+
}, arguments);
|
|
610
|
+
};
|
|
611
|
+
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
612
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
613
|
+
};
|
|
614
|
+
imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
|
|
615
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
616
|
+
};
|
|
617
|
+
imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
|
|
618
|
+
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
|
619
|
+
return addHeapObject(ret);
|
|
620
|
+
};
|
|
621
|
+
imports.wbg.__wbg_set_onerror_08fecec3bdc9d24d = function(arg0, arg1) {
|
|
622
|
+
getObject(arg0).onerror = getObject(arg1);
|
|
623
|
+
};
|
|
624
|
+
imports.wbg.__wbg_set_onsuccess_94332a00452de699 = function(arg0, arg1) {
|
|
625
|
+
getObject(arg0).onsuccess = getObject(arg1);
|
|
626
|
+
};
|
|
627
|
+
imports.wbg.__wbg_set_onupgradeneeded_3dc6e233a6d13fe2 = function(arg0, arg1) {
|
|
628
|
+
getObject(arg0).onupgradeneeded = getObject(arg1);
|
|
629
|
+
};
|
|
630
|
+
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
631
|
+
const ret = getObject(arg1).stack;
|
|
632
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
633
|
+
const len1 = WASM_VECTOR_LEN;
|
|
634
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
635
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
636
|
+
};
|
|
637
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
638
|
+
const ret = typeof global === "undefined" ? null : global;
|
|
639
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
640
|
+
};
|
|
641
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
642
|
+
const ret = typeof globalThis === "undefined" ? null : globalThis;
|
|
643
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
644
|
+
};
|
|
645
|
+
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
646
|
+
const ret = typeof self === "undefined" ? null : self;
|
|
647
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
648
|
+
};
|
|
649
|
+
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
650
|
+
const ret = typeof window === "undefined" ? null : window;
|
|
651
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
652
|
+
};
|
|
653
|
+
imports.wbg.__wbg_target_0e3e05a6263c37a0 = function(arg0) {
|
|
654
|
+
const ret = getObject(arg0).target;
|
|
655
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
656
|
+
};
|
|
657
|
+
imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
|
|
658
|
+
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
|
659
|
+
return addHeapObject(ret);
|
|
660
|
+
};
|
|
661
|
+
imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
|
|
662
|
+
const ret = getObject(arg0).then(getObject(arg1));
|
|
663
|
+
return addHeapObject(ret);
|
|
664
|
+
};
|
|
665
|
+
imports.wbg.__wbg_transaction_257422def49a0094 = function() {
|
|
666
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
667
|
+
const ret = getObject(arg0).transaction(getObject(arg1), __wbindgen_enum_IdbTransactionMode[arg2]);
|
|
668
|
+
return addHeapObject(ret);
|
|
669
|
+
}, arguments);
|
|
670
|
+
};
|
|
671
|
+
imports.wbg.__wbg_transaction_754344c3ae25fdcf = function() {
|
|
672
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
673
|
+
const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2));
|
|
674
|
+
return addHeapObject(ret);
|
|
675
|
+
}, arguments);
|
|
676
|
+
};
|
|
677
|
+
imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
|
|
678
|
+
const ret = getObject(arg0).value;
|
|
679
|
+
return addHeapObject(ret);
|
|
680
|
+
};
|
|
681
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
682
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
683
|
+
return addHeapObject(ret);
|
|
684
|
+
};
|
|
685
|
+
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
686
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
687
|
+
return addHeapObject(ret);
|
|
688
|
+
};
|
|
689
|
+
imports.wbg.__wbindgen_cast_59e89726c7c5a9af = function(arg0, arg1) {
|
|
690
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_179, __wasm_bindgen_func_elem_180);
|
|
691
|
+
return addHeapObject(ret);
|
|
692
|
+
};
|
|
693
|
+
imports.wbg.__wbindgen_cast_8ff99cee1f2c383b = function(arg0, arg1) {
|
|
694
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1338, __wasm_bindgen_func_elem_1339);
|
|
695
|
+
return addHeapObject(ret);
|
|
696
|
+
};
|
|
697
|
+
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
698
|
+
const ret = arg0;
|
|
699
|
+
return addHeapObject(ret);
|
|
700
|
+
};
|
|
701
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
702
|
+
const ret = arg0;
|
|
703
|
+
return addHeapObject(ret);
|
|
704
|
+
};
|
|
705
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
706
|
+
const ret = getObject(arg0);
|
|
707
|
+
return addHeapObject(ret);
|
|
708
|
+
};
|
|
709
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
710
|
+
takeObject(arg0);
|
|
711
|
+
};
|
|
712
|
+
return imports;
|
|
713
|
+
}
|
|
714
|
+
function __wbg_finalize_init(instance, module2) {
|
|
715
|
+
wasm = instance.exports;
|
|
716
|
+
__wbg_init.__wbindgen_wasm_module = module2;
|
|
717
|
+
cachedDataViewMemory0 = null;
|
|
718
|
+
cachedFloat32ArrayMemory0 = null;
|
|
719
|
+
cachedUint8ArrayMemory0 = null;
|
|
720
|
+
wasm.__wbindgen_start();
|
|
721
|
+
return wasm;
|
|
722
|
+
}
|
|
723
|
+
function initSync(module2) {
|
|
724
|
+
if (wasm !== void 0) return wasm;
|
|
725
|
+
if (typeof module2 !== "undefined") {
|
|
726
|
+
if (Object.getPrototypeOf(module2) === Object.prototype) {
|
|
727
|
+
({ module: module2 } = module2);
|
|
728
|
+
} else {
|
|
729
|
+
console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
const imports = __wbg_get_imports();
|
|
733
|
+
if (!(module2 instanceof WebAssembly.Module)) {
|
|
734
|
+
module2 = new WebAssembly.Module(module2);
|
|
735
|
+
}
|
|
736
|
+
const instance = new WebAssembly.Instance(module2, imports);
|
|
737
|
+
return __wbg_finalize_init(instance, module2);
|
|
738
|
+
}
|
|
739
|
+
async function __wbg_init(module_or_path) {
|
|
740
|
+
if (wasm !== void 0) return wasm;
|
|
741
|
+
if (typeof module_or_path !== "undefined") {
|
|
742
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
743
|
+
({ module_or_path } = module_or_path);
|
|
744
|
+
} else {
|
|
745
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (typeof module_or_path === "undefined") {
|
|
749
|
+
module_or_path = new URL("rvlite_bg.wasm", import_meta.url);
|
|
750
|
+
}
|
|
751
|
+
const imports = __wbg_get_imports();
|
|
752
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
753
|
+
module_or_path = fetch(module_or_path);
|
|
754
|
+
}
|
|
755
|
+
const { instance, module: module2 } = await __wbg_load(await module_or_path, imports);
|
|
756
|
+
return __wbg_finalize_init(instance, module2);
|
|
757
|
+
}
|
|
758
|
+
var import_meta, wasm, CLOSURE_DTORS, cachedDataViewMemory0, cachedFloat32ArrayMemory0, cachedUint8ArrayMemory0, heap, heap_next, cachedTextDecoder, MAX_SAFARI_DECODE_BYTES, numBytesDecoded, cachedTextEncoder, WASM_VECTOR_LEN, __wbindgen_enum_IdbTransactionMode, CypherEngineFinalization, RvLiteFinalization, RvLiteConfigFinalization, CypherEngine, RvLite, RvLiteConfig, EXPECTED_RESPONSE_TYPES, rvlite_default;
|
|
759
|
+
var init_rvlite = __esm({
|
|
760
|
+
"dist/wasm/rvlite.js"() {
|
|
761
|
+
"use strict";
|
|
762
|
+
import_meta = {};
|
|
763
|
+
CLOSURE_DTORS = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
764
|
+
}, unregister: () => {
|
|
765
|
+
} } : new FinalizationRegistry((state) => state.dtor(state.a, state.b));
|
|
766
|
+
cachedDataViewMemory0 = null;
|
|
767
|
+
cachedFloat32ArrayMemory0 = null;
|
|
768
|
+
cachedUint8ArrayMemory0 = null;
|
|
769
|
+
heap = new Array(128).fill(void 0);
|
|
770
|
+
heap.push(void 0, null, true, false);
|
|
771
|
+
heap_next = heap.length;
|
|
772
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
773
|
+
cachedTextDecoder.decode();
|
|
774
|
+
MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
775
|
+
numBytesDecoded = 0;
|
|
776
|
+
cachedTextEncoder = new TextEncoder();
|
|
777
|
+
if (!("encodeInto" in cachedTextEncoder)) {
|
|
778
|
+
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
779
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
780
|
+
view.set(buf);
|
|
781
|
+
return {
|
|
782
|
+
read: arg.length,
|
|
783
|
+
written: buf.length
|
|
784
|
+
};
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
WASM_VECTOR_LEN = 0;
|
|
788
|
+
__wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
|
|
789
|
+
CypherEngineFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
790
|
+
}, unregister: () => {
|
|
791
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_cypherengine_free(ptr >>> 0, 1));
|
|
792
|
+
RvLiteFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
793
|
+
}, unregister: () => {
|
|
794
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_rvlite_free(ptr >>> 0, 1));
|
|
795
|
+
RvLiteConfigFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
796
|
+
}, unregister: () => {
|
|
797
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_rvliteconfig_free(ptr >>> 0, 1));
|
|
798
|
+
CypherEngine = class {
|
|
799
|
+
__destroy_into_raw() {
|
|
800
|
+
const ptr = this.__wbg_ptr;
|
|
801
|
+
this.__wbg_ptr = 0;
|
|
802
|
+
CypherEngineFinalization.unregister(this);
|
|
803
|
+
return ptr;
|
|
804
|
+
}
|
|
805
|
+
free() {
|
|
806
|
+
const ptr = this.__destroy_into_raw();
|
|
807
|
+
wasm.__wbg_cypherengine_free(ptr, 0);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Create a new Cypher engine with empty graph
|
|
811
|
+
*/
|
|
812
|
+
constructor() {
|
|
813
|
+
const ret = wasm.cypherengine_new();
|
|
814
|
+
this.__wbg_ptr = ret >>> 0;
|
|
815
|
+
CypherEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
816
|
+
return this;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Clear the graph
|
|
820
|
+
*/
|
|
821
|
+
clear() {
|
|
822
|
+
wasm.cypherengine_clear(this.__wbg_ptr);
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Get graph statistics
|
|
826
|
+
* @returns {any}
|
|
827
|
+
*/
|
|
828
|
+
stats() {
|
|
829
|
+
try {
|
|
830
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
831
|
+
wasm.cypherengine_stats(retptr, this.__wbg_ptr);
|
|
832
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
833
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
834
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
835
|
+
if (r2) {
|
|
836
|
+
throw takeObject(r1);
|
|
837
|
+
}
|
|
838
|
+
return takeObject(r0);
|
|
839
|
+
} finally {
|
|
840
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Execute a Cypher query and return JSON results
|
|
845
|
+
* @param {string} query
|
|
846
|
+
* @returns {any}
|
|
847
|
+
*/
|
|
848
|
+
execute(query) {
|
|
849
|
+
try {
|
|
850
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
851
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
852
|
+
const len0 = WASM_VECTOR_LEN;
|
|
853
|
+
wasm.cypherengine_execute(retptr, this.__wbg_ptr, ptr0, len0);
|
|
854
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
855
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
856
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
857
|
+
if (r2) {
|
|
858
|
+
throw takeObject(r1);
|
|
859
|
+
}
|
|
860
|
+
return takeObject(r0);
|
|
861
|
+
} finally {
|
|
862
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
if (Symbol.dispose) CypherEngine.prototype[Symbol.dispose] = CypherEngine.prototype.free;
|
|
867
|
+
RvLite = class _RvLite {
|
|
868
|
+
static __wrap(ptr) {
|
|
869
|
+
ptr = ptr >>> 0;
|
|
870
|
+
const obj = Object.create(_RvLite.prototype);
|
|
871
|
+
obj.__wbg_ptr = ptr;
|
|
872
|
+
RvLiteFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
873
|
+
return obj;
|
|
874
|
+
}
|
|
875
|
+
__destroy_into_raw() {
|
|
876
|
+
const ptr = this.__wbg_ptr;
|
|
877
|
+
this.__wbg_ptr = 0;
|
|
878
|
+
RvLiteFinalization.unregister(this);
|
|
879
|
+
return ptr;
|
|
880
|
+
}
|
|
881
|
+
free() {
|
|
882
|
+
const ptr = this.__destroy_into_raw();
|
|
883
|
+
wasm.__wbg_rvlite_free(ptr, 0);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Add an RDF triple
|
|
887
|
+
*
|
|
888
|
+
* # Arguments
|
|
889
|
+
* * `subject` - Subject IRI or blank node (e.g., "<http://example.org/s>" or "_:b1")
|
|
890
|
+
* * `predicate` - Predicate IRI (e.g., "<http://example.org/p>")
|
|
891
|
+
* * `object` - Object IRI, blank node, or literal (e.g., "<http://example.org/o>" or '"value"')
|
|
892
|
+
* @param {string} subject
|
|
893
|
+
* @param {string} predicate
|
|
894
|
+
* @param {string} object
|
|
895
|
+
*/
|
|
896
|
+
add_triple(subject, predicate, object) {
|
|
897
|
+
try {
|
|
898
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
899
|
+
const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
900
|
+
const len0 = WASM_VECTOR_LEN;
|
|
901
|
+
const ptr1 = passStringToWasm0(predicate, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
902
|
+
const len1 = WASM_VECTOR_LEN;
|
|
903
|
+
const ptr2 = passStringToWasm0(object, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
904
|
+
const len2 = WASM_VECTOR_LEN;
|
|
905
|
+
wasm.rvlite_add_triple(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
906
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
907
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
908
|
+
if (r1) {
|
|
909
|
+
throw takeObject(r0);
|
|
910
|
+
}
|
|
911
|
+
} finally {
|
|
912
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Get configuration
|
|
917
|
+
* @returns {any}
|
|
918
|
+
*/
|
|
919
|
+
get_config() {
|
|
920
|
+
try {
|
|
921
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
922
|
+
wasm.rvlite_get_config(retptr, this.__wbg_ptr);
|
|
923
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
924
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
925
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
926
|
+
if (r2) {
|
|
927
|
+
throw takeObject(r1);
|
|
928
|
+
}
|
|
929
|
+
return takeObject(r0);
|
|
930
|
+
} finally {
|
|
931
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Export database state as JSON (for manual backup)
|
|
936
|
+
* @returns {any}
|
|
937
|
+
*/
|
|
938
|
+
export_json() {
|
|
939
|
+
try {
|
|
940
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
941
|
+
wasm.rvlite_export_json(retptr, this.__wbg_ptr);
|
|
942
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
943
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
944
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
945
|
+
if (r2) {
|
|
946
|
+
throw takeObject(r1);
|
|
947
|
+
}
|
|
948
|
+
return takeObject(r0);
|
|
949
|
+
} finally {
|
|
950
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Get version string
|
|
955
|
+
* @returns {string}
|
|
956
|
+
*/
|
|
957
|
+
get_version() {
|
|
958
|
+
let deferred1_0;
|
|
959
|
+
let deferred1_1;
|
|
960
|
+
try {
|
|
961
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
962
|
+
wasm.rvlite_get_version(retptr, this.__wbg_ptr);
|
|
963
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
964
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
965
|
+
deferred1_0 = r0;
|
|
966
|
+
deferred1_1 = r1;
|
|
967
|
+
return getStringFromWasm0(r0, r1);
|
|
968
|
+
} finally {
|
|
969
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
970
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Import database state from JSON
|
|
975
|
+
* @param {any} json
|
|
976
|
+
*/
|
|
977
|
+
import_json(json) {
|
|
978
|
+
try {
|
|
979
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
980
|
+
wasm.rvlite_import_json(retptr, this.__wbg_ptr, addHeapObject(json));
|
|
981
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
982
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
983
|
+
if (r1) {
|
|
984
|
+
throw takeObject(r0);
|
|
985
|
+
}
|
|
986
|
+
} finally {
|
|
987
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Clear the Cypher graph
|
|
992
|
+
*/
|
|
993
|
+
cypher_clear() {
|
|
994
|
+
wasm.rvlite_cypher_clear(this.__wbg_ptr);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Get Cypher graph statistics
|
|
998
|
+
* @returns {any}
|
|
999
|
+
*/
|
|
1000
|
+
cypher_stats() {
|
|
1001
|
+
try {
|
|
1002
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1003
|
+
wasm.rvlite_cypher_stats(retptr, this.__wbg_ptr);
|
|
1004
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1005
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1006
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1007
|
+
if (r2) {
|
|
1008
|
+
throw takeObject(r1);
|
|
1009
|
+
}
|
|
1010
|
+
return takeObject(r0);
|
|
1011
|
+
} finally {
|
|
1012
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Get enabled features
|
|
1017
|
+
* @returns {any}
|
|
1018
|
+
*/
|
|
1019
|
+
get_features() {
|
|
1020
|
+
try {
|
|
1021
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1022
|
+
wasm.rvlite_get_features(retptr, this.__wbg_ptr);
|
|
1023
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1024
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1025
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1026
|
+
if (r2) {
|
|
1027
|
+
throw takeObject(r1);
|
|
1028
|
+
}
|
|
1029
|
+
return takeObject(r0);
|
|
1030
|
+
} finally {
|
|
1031
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Initialize IndexedDB storage for persistence
|
|
1036
|
+
* Must be called before save() or load()
|
|
1037
|
+
* @returns {Promise<any>}
|
|
1038
|
+
*/
|
|
1039
|
+
init_storage() {
|
|
1040
|
+
const ret = wasm.rvlite_init_storage(this.__wbg_ptr);
|
|
1041
|
+
return takeObject(ret);
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Get the number of triples in the store
|
|
1045
|
+
* @returns {number}
|
|
1046
|
+
*/
|
|
1047
|
+
triple_count() {
|
|
1048
|
+
const ret = wasm.rvlite_triple_count(this.__wbg_ptr);
|
|
1049
|
+
return ret >>> 0;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Clear saved state from IndexedDB
|
|
1053
|
+
* @returns {Promise<any>}
|
|
1054
|
+
*/
|
|
1055
|
+
static clear_storage() {
|
|
1056
|
+
const ret = wasm.rvlite_clear_storage();
|
|
1057
|
+
return takeObject(ret);
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Clear all triples
|
|
1061
|
+
*/
|
|
1062
|
+
clear_triples() {
|
|
1063
|
+
wasm.rvlite_clear_triples(this.__wbg_ptr);
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Insert a vector with a specific ID
|
|
1067
|
+
* @param {string} id
|
|
1068
|
+
* @param {Float32Array} vector
|
|
1069
|
+
* @param {any} metadata
|
|
1070
|
+
*/
|
|
1071
|
+
insert_with_id(id, vector, metadata) {
|
|
1072
|
+
try {
|
|
1073
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1074
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1075
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1076
|
+
const ptr1 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
|
|
1077
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1078
|
+
wasm.rvlite_insert_with_id(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(metadata));
|
|
1079
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1080
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1081
|
+
if (r1) {
|
|
1082
|
+
throw takeObject(r0);
|
|
1083
|
+
}
|
|
1084
|
+
} finally {
|
|
1085
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Check if saved state exists in IndexedDB
|
|
1090
|
+
* @returns {Promise<any>}
|
|
1091
|
+
*/
|
|
1092
|
+
static has_saved_state() {
|
|
1093
|
+
const ret = wasm.rvlite_has_saved_state();
|
|
1094
|
+
return takeObject(ret);
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Search with metadata filter
|
|
1098
|
+
* @param {Float32Array} query_vector
|
|
1099
|
+
* @param {number} k
|
|
1100
|
+
* @param {any} filter
|
|
1101
|
+
* @returns {any}
|
|
1102
|
+
*/
|
|
1103
|
+
search_with_filter(query_vector, k, filter) {
|
|
1104
|
+
try {
|
|
1105
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1106
|
+
const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
|
|
1107
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1108
|
+
wasm.rvlite_search_with_filter(retptr, this.__wbg_ptr, ptr0, len0, k, addHeapObject(filter));
|
|
1109
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1110
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1111
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1112
|
+
if (r2) {
|
|
1113
|
+
throw takeObject(r1);
|
|
1114
|
+
}
|
|
1115
|
+
return takeObject(r0);
|
|
1116
|
+
} finally {
|
|
1117
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Check if IndexedDB is available in the browser
|
|
1122
|
+
* @returns {boolean}
|
|
1123
|
+
*/
|
|
1124
|
+
static is_storage_available() {
|
|
1125
|
+
const ret = wasm.rvlite_is_storage_available();
|
|
1126
|
+
return ret !== 0;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Get a vector by ID
|
|
1130
|
+
* @param {string} id
|
|
1131
|
+
* @returns {any}
|
|
1132
|
+
*/
|
|
1133
|
+
get(id) {
|
|
1134
|
+
try {
|
|
1135
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1136
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1137
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1138
|
+
wasm.rvlite_get(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1139
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1140
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1141
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1142
|
+
if (r2) {
|
|
1143
|
+
throw takeObject(r1);
|
|
1144
|
+
}
|
|
1145
|
+
return takeObject(r0);
|
|
1146
|
+
} finally {
|
|
1147
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Get the number of vectors in the database
|
|
1152
|
+
* @returns {number}
|
|
1153
|
+
*/
|
|
1154
|
+
len() {
|
|
1155
|
+
try {
|
|
1156
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1157
|
+
wasm.rvlite_len(retptr, this.__wbg_ptr);
|
|
1158
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1159
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1160
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1161
|
+
if (r2) {
|
|
1162
|
+
throw takeObject(r1);
|
|
1163
|
+
}
|
|
1164
|
+
return r0 >>> 0;
|
|
1165
|
+
} finally {
|
|
1166
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Create a new RvLite database
|
|
1171
|
+
* @param {RvLiteConfig} config
|
|
1172
|
+
*/
|
|
1173
|
+
constructor(config) {
|
|
1174
|
+
try {
|
|
1175
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1176
|
+
_assertClass(config, RvLiteConfig);
|
|
1177
|
+
var ptr0 = config.__destroy_into_raw();
|
|
1178
|
+
wasm.rvlite_new(retptr, ptr0);
|
|
1179
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1180
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1181
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1182
|
+
if (r2) {
|
|
1183
|
+
throw takeObject(r1);
|
|
1184
|
+
}
|
|
1185
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
1186
|
+
RvLiteFinalization.register(this, this.__wbg_ptr, this);
|
|
1187
|
+
return this;
|
|
1188
|
+
} finally {
|
|
1189
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Execute SQL query
|
|
1194
|
+
*
|
|
1195
|
+
* Supported syntax:
|
|
1196
|
+
* - CREATE TABLE vectors (id TEXT PRIMARY KEY, vector VECTOR(384))
|
|
1197
|
+
* - SELECT * FROM vectors WHERE id = 'x'
|
|
1198
|
+
* - SELECT id, vector <-> '[...]' AS distance FROM vectors ORDER BY distance LIMIT 10
|
|
1199
|
+
* - INSERT INTO vectors (id, vector) VALUES ('x', '[...]')
|
|
1200
|
+
* - DELETE FROM vectors WHERE id = 'x'
|
|
1201
|
+
* @param {string} query
|
|
1202
|
+
* @returns {any}
|
|
1203
|
+
*/
|
|
1204
|
+
sql(query) {
|
|
1205
|
+
try {
|
|
1206
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1207
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1208
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1209
|
+
wasm.rvlite_sql(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1210
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1211
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1212
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1213
|
+
if (r2) {
|
|
1214
|
+
throw takeObject(r1);
|
|
1215
|
+
}
|
|
1216
|
+
return takeObject(r0);
|
|
1217
|
+
} finally {
|
|
1218
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Load database from IndexedDB
|
|
1223
|
+
* Returns a Promise<RvLite> with the restored database
|
|
1224
|
+
* @param {RvLiteConfig} config
|
|
1225
|
+
* @returns {Promise<any>}
|
|
1226
|
+
*/
|
|
1227
|
+
static load(config) {
|
|
1228
|
+
_assertClass(config, RvLiteConfig);
|
|
1229
|
+
var ptr0 = config.__destroy_into_raw();
|
|
1230
|
+
const ret = wasm.rvlite_load(ptr0);
|
|
1231
|
+
return takeObject(ret);
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Save database state to IndexedDB
|
|
1235
|
+
* Returns a Promise that resolves when save is complete
|
|
1236
|
+
* @returns {Promise<any>}
|
|
1237
|
+
*/
|
|
1238
|
+
save() {
|
|
1239
|
+
const ret = wasm.rvlite_save(this.__wbg_ptr);
|
|
1240
|
+
return takeObject(ret);
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Execute Cypher query
|
|
1244
|
+
*
|
|
1245
|
+
* Supported operations:
|
|
1246
|
+
* - CREATE (n:Label {prop: value})
|
|
1247
|
+
* - MATCH (n:Label) WHERE n.prop = value RETURN n
|
|
1248
|
+
* - CREATE (a)-[r:REL]->(b)
|
|
1249
|
+
* - DELETE n
|
|
1250
|
+
* @param {string} query
|
|
1251
|
+
* @returns {any}
|
|
1252
|
+
*/
|
|
1253
|
+
cypher(query) {
|
|
1254
|
+
try {
|
|
1255
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1256
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1257
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1258
|
+
wasm.rvlite_cypher(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1259
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1260
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1261
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1262
|
+
if (r2) {
|
|
1263
|
+
throw takeObject(r1);
|
|
1264
|
+
}
|
|
1265
|
+
return takeObject(r0);
|
|
1266
|
+
} finally {
|
|
1267
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Delete a vector by ID
|
|
1272
|
+
* @param {string} id
|
|
1273
|
+
* @returns {boolean}
|
|
1274
|
+
*/
|
|
1275
|
+
delete(id) {
|
|
1276
|
+
try {
|
|
1277
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1278
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1279
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1280
|
+
wasm.rvlite_delete(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1281
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1282
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1283
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1284
|
+
if (r2) {
|
|
1285
|
+
throw takeObject(r1);
|
|
1286
|
+
}
|
|
1287
|
+
return r0 !== 0;
|
|
1288
|
+
} finally {
|
|
1289
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Insert a vector with optional metadata
|
|
1294
|
+
* Returns the vector ID
|
|
1295
|
+
* @param {Float32Array} vector
|
|
1296
|
+
* @param {any} metadata
|
|
1297
|
+
* @returns {string}
|
|
1298
|
+
*/
|
|
1299
|
+
insert(vector, metadata) {
|
|
1300
|
+
let deferred3_0;
|
|
1301
|
+
let deferred3_1;
|
|
1302
|
+
try {
|
|
1303
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1304
|
+
const ptr0 = passArrayF32ToWasm0(vector, wasm.__wbindgen_export);
|
|
1305
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1306
|
+
wasm.rvlite_insert(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(metadata));
|
|
1307
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1308
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1309
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1310
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1311
|
+
var ptr2 = r0;
|
|
1312
|
+
var len2 = r1;
|
|
1313
|
+
if (r3) {
|
|
1314
|
+
ptr2 = 0;
|
|
1315
|
+
len2 = 0;
|
|
1316
|
+
throw takeObject(r2);
|
|
1317
|
+
}
|
|
1318
|
+
deferred3_0 = ptr2;
|
|
1319
|
+
deferred3_1 = len2;
|
|
1320
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1321
|
+
} finally {
|
|
1322
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1323
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Search for similar vectors
|
|
1328
|
+
* @param {Float32Array} query_vector
|
|
1329
|
+
* @param {number} k
|
|
1330
|
+
* @returns {any}
|
|
1331
|
+
*/
|
|
1332
|
+
search(query_vector, k) {
|
|
1333
|
+
try {
|
|
1334
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1335
|
+
const ptr0 = passArrayF32ToWasm0(query_vector, wasm.__wbindgen_export);
|
|
1336
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1337
|
+
wasm.rvlite_search(retptr, this.__wbg_ptr, ptr0, len0, k);
|
|
1338
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1339
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1340
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1341
|
+
if (r2) {
|
|
1342
|
+
throw takeObject(r1);
|
|
1343
|
+
}
|
|
1344
|
+
return takeObject(r0);
|
|
1345
|
+
} finally {
|
|
1346
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Execute SPARQL query
|
|
1351
|
+
*
|
|
1352
|
+
* Supported operations:
|
|
1353
|
+
* - SELECT ?s ?p ?o WHERE { ?s ?p ?o }
|
|
1354
|
+
* - SELECT ?s WHERE { ?s <predicate> ?o }
|
|
1355
|
+
* - ASK { ?s ?p ?o }
|
|
1356
|
+
* @param {string} query
|
|
1357
|
+
* @returns {any}
|
|
1358
|
+
*/
|
|
1359
|
+
sparql(query) {
|
|
1360
|
+
try {
|
|
1361
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1362
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1363
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1364
|
+
wasm.rvlite_sparql(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1365
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1366
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1367
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1368
|
+
if (r2) {
|
|
1369
|
+
throw takeObject(r1);
|
|
1370
|
+
}
|
|
1371
|
+
return takeObject(r0);
|
|
1372
|
+
} finally {
|
|
1373
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Create with default configuration (384 dimensions, cosine similarity)
|
|
1378
|
+
* @returns {RvLite}
|
|
1379
|
+
*/
|
|
1380
|
+
static default() {
|
|
1381
|
+
try {
|
|
1382
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1383
|
+
wasm.rvlite_default(retptr);
|
|
1384
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1385
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1386
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1387
|
+
if (r2) {
|
|
1388
|
+
throw takeObject(r1);
|
|
1389
|
+
}
|
|
1390
|
+
return _RvLite.__wrap(r0);
|
|
1391
|
+
} finally {
|
|
1392
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Check if database is empty
|
|
1397
|
+
* @returns {boolean}
|
|
1398
|
+
*/
|
|
1399
|
+
is_empty() {
|
|
1400
|
+
try {
|
|
1401
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1402
|
+
wasm.rvlite_is_empty(retptr, this.__wbg_ptr);
|
|
1403
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1404
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1405
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1406
|
+
if (r2) {
|
|
1407
|
+
throw takeObject(r1);
|
|
1408
|
+
}
|
|
1409
|
+
return r0 !== 0;
|
|
1410
|
+
} finally {
|
|
1411
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Check if database is ready
|
|
1416
|
+
* @returns {boolean}
|
|
1417
|
+
*/
|
|
1418
|
+
is_ready() {
|
|
1419
|
+
const ret = wasm.rvlite_is_ready(this.__wbg_ptr);
|
|
1420
|
+
return ret !== 0;
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
if (Symbol.dispose) RvLite.prototype[Symbol.dispose] = RvLite.prototype.free;
|
|
1424
|
+
RvLiteConfig = class _RvLiteConfig {
|
|
1425
|
+
static __wrap(ptr) {
|
|
1426
|
+
ptr = ptr >>> 0;
|
|
1427
|
+
const obj = Object.create(_RvLiteConfig.prototype);
|
|
1428
|
+
obj.__wbg_ptr = ptr;
|
|
1429
|
+
RvLiteConfigFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1430
|
+
return obj;
|
|
1431
|
+
}
|
|
1432
|
+
__destroy_into_raw() {
|
|
1433
|
+
const ptr = this.__wbg_ptr;
|
|
1434
|
+
this.__wbg_ptr = 0;
|
|
1435
|
+
RvLiteConfigFinalization.unregister(this);
|
|
1436
|
+
return ptr;
|
|
1437
|
+
}
|
|
1438
|
+
free() {
|
|
1439
|
+
const ptr = this.__destroy_into_raw();
|
|
1440
|
+
wasm.__wbg_rvliteconfig_free(ptr, 0);
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Get dimensions
|
|
1444
|
+
* @returns {number}
|
|
1445
|
+
*/
|
|
1446
|
+
get_dimensions() {
|
|
1447
|
+
const ret = wasm.rvliteconfig_get_dimensions(this.__wbg_ptr);
|
|
1448
|
+
return ret >>> 0;
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Get distance metric name
|
|
1452
|
+
* @returns {string}
|
|
1453
|
+
*/
|
|
1454
|
+
get_distance_metric() {
|
|
1455
|
+
let deferred1_0;
|
|
1456
|
+
let deferred1_1;
|
|
1457
|
+
try {
|
|
1458
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1459
|
+
wasm.rvliteconfig_get_distance_metric(retptr, this.__wbg_ptr);
|
|
1460
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1461
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1462
|
+
deferred1_0 = r0;
|
|
1463
|
+
deferred1_1 = r1;
|
|
1464
|
+
return getStringFromWasm0(r0, r1);
|
|
1465
|
+
} finally {
|
|
1466
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1467
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Set distance metric (euclidean, cosine, dotproduct, manhattan)
|
|
1472
|
+
* @param {string} metric
|
|
1473
|
+
* @returns {RvLiteConfig}
|
|
1474
|
+
*/
|
|
1475
|
+
with_distance_metric(metric) {
|
|
1476
|
+
const ptr = this.__destroy_into_raw();
|
|
1477
|
+
const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1478
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1479
|
+
const ret = wasm.rvliteconfig_with_distance_metric(ptr, ptr0, len0);
|
|
1480
|
+
return _RvLiteConfig.__wrap(ret);
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* @param {number} dimensions
|
|
1484
|
+
*/
|
|
1485
|
+
constructor(dimensions) {
|
|
1486
|
+
const ret = wasm.rvliteconfig_new(dimensions);
|
|
1487
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1488
|
+
RvLiteConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
1489
|
+
return this;
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
if (Symbol.dispose) RvLiteConfig.prototype[Symbol.dispose] = RvLiteConfig.prototype.free;
|
|
1493
|
+
EXPECTED_RESPONSE_TYPES = /* @__PURE__ */ new Set(["basic", "cors", "default"]);
|
|
1494
|
+
rvlite_default = __wbg_init;
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
// src/index.ts
|
|
1499
|
+
var index_exports = {};
|
|
1500
|
+
__export(index_exports, {
|
|
1501
|
+
BrowserWriterLease: () => BrowserWriterLease,
|
|
1502
|
+
CypherEngine: () => CypherEngine,
|
|
1503
|
+
RvLite: () => RvLite2,
|
|
1504
|
+
RvLiteConfig: () => RvLiteConfig,
|
|
1505
|
+
SemanticMemory: () => SemanticMemory,
|
|
1506
|
+
bumpMetadataEpoch: () => bumpMetadataEpoch,
|
|
1507
|
+
bumpRvfEpoch: () => bumpRvfEpoch,
|
|
1508
|
+
checkEpochSync: () => checkEpochSync,
|
|
1509
|
+
createAnthropicEmbeddings: () => createAnthropicEmbeddings,
|
|
1510
|
+
createRvLite: () => createRvLite,
|
|
1511
|
+
default: () => index_default,
|
|
1512
|
+
getStorageBackend: () => getStorageBackend,
|
|
1513
|
+
init: () => init,
|
|
1514
|
+
initSync: () => initSync,
|
|
1515
|
+
isRvfAvailable: () => isRvfAvailable,
|
|
1516
|
+
reconcileEpochs: () => reconcileEpochs
|
|
1517
|
+
});
|
|
1518
|
+
module.exports = __toCommonJS(index_exports);
|
|
1519
|
+
init_rvlite();
|
|
1520
|
+
var rvfWasmAvailable = null;
|
|
1521
|
+
function isRvfAvailable() {
|
|
1522
|
+
if (rvfWasmAvailable !== null) return rvfWasmAvailable;
|
|
1523
|
+
try {
|
|
1524
|
+
require.resolve("@ruvector/rvf-wasm");
|
|
1525
|
+
rvfWasmAvailable = true;
|
|
1526
|
+
} catch {
|
|
1527
|
+
rvfWasmAvailable = false;
|
|
1528
|
+
}
|
|
1529
|
+
return rvfWasmAvailable;
|
|
1530
|
+
}
|
|
1531
|
+
function getStorageBackend() {
|
|
1532
|
+
if (isRvfAvailable()) return "rvf";
|
|
1533
|
+
if (typeof indexedDB !== "undefined") return "indexeddb";
|
|
1534
|
+
return "memory";
|
|
1535
|
+
}
|
|
1536
|
+
var RvLite2 = class _RvLite {
|
|
1537
|
+
wasm;
|
|
1538
|
+
config;
|
|
1539
|
+
initialized = false;
|
|
1540
|
+
constructor(config = {}) {
|
|
1541
|
+
this.config = {
|
|
1542
|
+
dimensions: config.dimensions || 384,
|
|
1543
|
+
distanceMetric: config.distanceMetric || "cosine"
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Initialize the WASM module (called automatically on first use)
|
|
1548
|
+
*/
|
|
1549
|
+
async init() {
|
|
1550
|
+
if (this.initialized) return;
|
|
1551
|
+
const wasmModule = await Promise.resolve().then(() => (init_rvlite(), rvlite_exports));
|
|
1552
|
+
await wasmModule.default();
|
|
1553
|
+
this.wasm = new wasmModule.RvLite({
|
|
1554
|
+
dimensions: this.config.dimensions,
|
|
1555
|
+
distance_metric: this.config.distanceMetric
|
|
1556
|
+
});
|
|
1557
|
+
this.initialized = true;
|
|
1558
|
+
}
|
|
1559
|
+
async ensureInit() {
|
|
1560
|
+
if (!this.initialized) {
|
|
1561
|
+
await this.init();
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
// ============ Vector Operations ============
|
|
1565
|
+
/**
|
|
1566
|
+
* Insert a vector with optional metadata
|
|
1567
|
+
*/
|
|
1568
|
+
async insert(vector, metadata) {
|
|
1569
|
+
await this.ensureInit();
|
|
1570
|
+
return this.wasm.insert(vector, metadata || null);
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Insert a vector with a specific ID
|
|
1574
|
+
*/
|
|
1575
|
+
async insertWithId(id, vector, metadata) {
|
|
1576
|
+
await this.ensureInit();
|
|
1577
|
+
this.wasm.insert_with_id(id, vector, metadata || null);
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Search for similar vectors
|
|
1581
|
+
*/
|
|
1582
|
+
async search(query, k = 5) {
|
|
1583
|
+
await this.ensureInit();
|
|
1584
|
+
return this.wasm.search(query, k);
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Get a vector by ID
|
|
1588
|
+
*/
|
|
1589
|
+
async get(id) {
|
|
1590
|
+
await this.ensureInit();
|
|
1591
|
+
return this.wasm.get(id);
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Delete a vector by ID
|
|
1595
|
+
*/
|
|
1596
|
+
async delete(id) {
|
|
1597
|
+
await this.ensureInit();
|
|
1598
|
+
return this.wasm.delete(id);
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* Get the number of vectors
|
|
1602
|
+
*/
|
|
1603
|
+
async len() {
|
|
1604
|
+
await this.ensureInit();
|
|
1605
|
+
return this.wasm.len();
|
|
1606
|
+
}
|
|
1607
|
+
// ============ SQL Operations ============
|
|
1608
|
+
/**
|
|
1609
|
+
* Execute a SQL query
|
|
1610
|
+
*
|
|
1611
|
+
* Supports vector distance operations:
|
|
1612
|
+
* - distance(col, vector) - Calculate distance
|
|
1613
|
+
* - vec_search(col, vector, k) - Find k nearest
|
|
1614
|
+
*/
|
|
1615
|
+
async sql(query) {
|
|
1616
|
+
await this.ensureInit();
|
|
1617
|
+
return this.wasm.sql(query);
|
|
1618
|
+
}
|
|
1619
|
+
// ============ Cypher Operations ============
|
|
1620
|
+
/**
|
|
1621
|
+
* Execute a Cypher graph query
|
|
1622
|
+
*
|
|
1623
|
+
* Supports:
|
|
1624
|
+
* - CREATE (n:Label {props})
|
|
1625
|
+
* - MATCH (n:Label) WHERE ... RETURN n
|
|
1626
|
+
* - CREATE (a)-[:REL]->(b)
|
|
1627
|
+
*/
|
|
1628
|
+
async cypher(query) {
|
|
1629
|
+
await this.ensureInit();
|
|
1630
|
+
return this.wasm.cypher(query);
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Get Cypher graph statistics
|
|
1634
|
+
*/
|
|
1635
|
+
async cypherStats() {
|
|
1636
|
+
await this.ensureInit();
|
|
1637
|
+
return this.wasm.cypher_stats();
|
|
1638
|
+
}
|
|
1639
|
+
// ============ SPARQL Operations ============
|
|
1640
|
+
/**
|
|
1641
|
+
* Execute a SPARQL query
|
|
1642
|
+
*
|
|
1643
|
+
* Supports SELECT, ASK queries over RDF triples
|
|
1644
|
+
*/
|
|
1645
|
+
async sparql(query) {
|
|
1646
|
+
await this.ensureInit();
|
|
1647
|
+
return this.wasm.sparql(query);
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Add an RDF triple
|
|
1651
|
+
*/
|
|
1652
|
+
async addTriple(subject, predicate, object, graph) {
|
|
1653
|
+
await this.ensureInit();
|
|
1654
|
+
this.wasm.add_triple(subject, predicate, object, graph || null);
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Get the number of triples
|
|
1658
|
+
*/
|
|
1659
|
+
async tripleCount() {
|
|
1660
|
+
await this.ensureInit();
|
|
1661
|
+
return this.wasm.triple_count();
|
|
1662
|
+
}
|
|
1663
|
+
// ============ Persistence ============
|
|
1664
|
+
/**
|
|
1665
|
+
* Export database state to JSON
|
|
1666
|
+
*/
|
|
1667
|
+
async exportJson() {
|
|
1668
|
+
await this.ensureInit();
|
|
1669
|
+
return this.wasm.export_json();
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Import database state from JSON
|
|
1673
|
+
*/
|
|
1674
|
+
async importJson(data) {
|
|
1675
|
+
await this.ensureInit();
|
|
1676
|
+
this.wasm.import_json(data);
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Save to IndexedDB (browser only)
|
|
1680
|
+
*/
|
|
1681
|
+
async save() {
|
|
1682
|
+
await this.ensureInit();
|
|
1683
|
+
return this.wasm.save();
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Load from IndexedDB (browser only)
|
|
1687
|
+
*/
|
|
1688
|
+
static async load(config = {}) {
|
|
1689
|
+
const instance = new _RvLite(config);
|
|
1690
|
+
await instance.init();
|
|
1691
|
+
const wasmModule = await Promise.resolve().then(() => (init_rvlite(), rvlite_exports));
|
|
1692
|
+
instance.wasm = await wasmModule.RvLite.load(config);
|
|
1693
|
+
return instance;
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Clear IndexedDB storage (browser only)
|
|
1697
|
+
*/
|
|
1698
|
+
static async clearStorage() {
|
|
1699
|
+
const wasmModule = await Promise.resolve().then(() => (init_rvlite(), rvlite_exports));
|
|
1700
|
+
return wasmModule.RvLite.clear_storage();
|
|
1701
|
+
}
|
|
1702
|
+
// ============ RVF Persistence ============
|
|
1703
|
+
/**
|
|
1704
|
+
* Factory method: create an RvLite instance backed by an RVF file.
|
|
1705
|
+
*
|
|
1706
|
+
* Opens or creates an RVF file at the given path, initialises the WASM
|
|
1707
|
+
* module, and (when available) uses `@ruvector/rvf-wasm` for vector storage.
|
|
1708
|
+
* Falls back to standard WASM + JSON-based RVF if the optional package is
|
|
1709
|
+
* not installed.
|
|
1710
|
+
*
|
|
1711
|
+
* @param config - Standard RvLiteConfig plus a required `rvfPath`.
|
|
1712
|
+
* @returns A fully-initialised RvLite instance with data loaded from the
|
|
1713
|
+
* RVF file (if it already exists).
|
|
1714
|
+
*/
|
|
1715
|
+
static async createWithRvf(config) {
|
|
1716
|
+
const instance = new _RvLite(config);
|
|
1717
|
+
instance.rvfPath = config.rvfPath;
|
|
1718
|
+
try {
|
|
1719
|
+
const rvfWasm = await import("@ruvector/rvf-wasm");
|
|
1720
|
+
instance.rvfModule = rvfWasm;
|
|
1721
|
+
} catch {
|
|
1722
|
+
}
|
|
1723
|
+
await instance.init();
|
|
1724
|
+
if (typeof globalThis.process !== "undefined") {
|
|
1725
|
+
try {
|
|
1726
|
+
const fs = await import("fs");
|
|
1727
|
+
if (fs.existsSync(config.rvfPath)) {
|
|
1728
|
+
await instance.loadFromRvf(config.rvfPath);
|
|
1729
|
+
}
|
|
1730
|
+
} catch {
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
return instance;
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Export the current vector state to an RVF file.
|
|
1737
|
+
*
|
|
1738
|
+
* When `@ruvector/rvf-wasm` is available the export uses the native RVF
|
|
1739
|
+
* binary writer. Otherwise the method falls back to a JSON payload
|
|
1740
|
+
* wrapped with RVF header metadata so the file can be identified as RVF.
|
|
1741
|
+
*
|
|
1742
|
+
* @param filePath - Destination path for the RVF file.
|
|
1743
|
+
*/
|
|
1744
|
+
async saveToRvf(filePath) {
|
|
1745
|
+
await this.ensureInit();
|
|
1746
|
+
const jsonState = await this.exportJson();
|
|
1747
|
+
if (this.rvfModule && typeof this.rvfModule.writeRvf === "function") {
|
|
1748
|
+
await this.rvfModule.writeRvf(filePath, jsonState);
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
const rvfEnvelope = {
|
|
1752
|
+
rvf_version: 1,
|
|
1753
|
+
magic: "RVF1",
|
|
1754
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1755
|
+
dimensions: this.config.dimensions ?? 384,
|
|
1756
|
+
distance_metric: this.config.distanceMetric ?? "cosine",
|
|
1757
|
+
payload: jsonState
|
|
1758
|
+
};
|
|
1759
|
+
if (typeof globalThis.process !== "undefined") {
|
|
1760
|
+
const fs = await import("fs");
|
|
1761
|
+
const path = await import("path");
|
|
1762
|
+
const dir = path.dirname(filePath);
|
|
1763
|
+
if (!fs.existsSync(dir)) {
|
|
1764
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1765
|
+
}
|
|
1766
|
+
fs.writeFileSync(filePath, JSON.stringify(rvfEnvelope, null, 2), "utf-8");
|
|
1767
|
+
} else {
|
|
1768
|
+
throw new Error(
|
|
1769
|
+
"saveToRvf is only supported in Node.js environments. Use exportJson() for browser-side persistence."
|
|
1770
|
+
);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Import vector data from an RVF file.
|
|
1775
|
+
*
|
|
1776
|
+
* Parses the RVF format (either native binary via `@ruvector/rvf-wasm` or
|
|
1777
|
+
* the JSON-based fallback envelope) and loads vectors + metadata into the
|
|
1778
|
+
* current instance.
|
|
1779
|
+
*
|
|
1780
|
+
* @param filePath - Source path of the RVF file to import.
|
|
1781
|
+
*/
|
|
1782
|
+
async loadFromRvf(filePath) {
|
|
1783
|
+
await this.ensureInit();
|
|
1784
|
+
if (this.rvfModule && typeof this.rvfModule.readRvf === "function") {
|
|
1785
|
+
const data = await this.rvfModule.readRvf(filePath);
|
|
1786
|
+
await this.importJson(data);
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
if (typeof globalThis.process !== "undefined") {
|
|
1790
|
+
const fs = await import("fs");
|
|
1791
|
+
if (!fs.existsSync(filePath)) {
|
|
1792
|
+
throw new Error(`RVF file not found: ${filePath}`);
|
|
1793
|
+
}
|
|
1794
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
1795
|
+
const envelope = JSON.parse(raw);
|
|
1796
|
+
if (envelope.magic !== "RVF1") {
|
|
1797
|
+
throw new Error(
|
|
1798
|
+
`Invalid RVF file: expected magic "RVF1", got "${envelope.magic}"`
|
|
1799
|
+
);
|
|
1800
|
+
}
|
|
1801
|
+
await this.importJson(envelope.payload);
|
|
1802
|
+
} else {
|
|
1803
|
+
throw new Error(
|
|
1804
|
+
"loadFromRvf is only supported in Node.js environments. Use importJson() for browser-side persistence."
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
/** @internal handle to optional @ruvector/rvf-wasm module */
|
|
1809
|
+
rvfModule = null;
|
|
1810
|
+
/** @internal path to the RVF backing file (set by createWithRvf) */
|
|
1811
|
+
rvfPath = null;
|
|
1812
|
+
};
|
|
1813
|
+
async function createRvLite(config = {}) {
|
|
1814
|
+
const requestedBackend = config.backend || "auto";
|
|
1815
|
+
const actualBackend = requestedBackend === "auto" ? getStorageBackend() : requestedBackend;
|
|
1816
|
+
if (typeof process !== "undefined" && process.env && process.env.RVLITE_DEBUG) {
|
|
1817
|
+
console.log(`[rvlite] storage backend: ${actualBackend} (requested: ${requestedBackend}, rvf available: ${isRvfAvailable()})`);
|
|
1818
|
+
}
|
|
1819
|
+
const db = new RvLite2(config);
|
|
1820
|
+
await db.init();
|
|
1821
|
+
return db;
|
|
1822
|
+
}
|
|
1823
|
+
function createAnthropicEmbeddings(apiKey) {
|
|
1824
|
+
throw new Error(
|
|
1825
|
+
"Anthropic does not provide embeddings. Use createOpenAIEmbeddings or a custom provider."
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
function sanitizeCypher(value) {
|
|
1829
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/[\x00-\x1f\x7f]/g, "");
|
|
1830
|
+
}
|
|
1831
|
+
function validateRelationType(rel) {
|
|
1832
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(rel)) {
|
|
1833
|
+
throw new Error(`Invalid relation type: ${rel}`);
|
|
1834
|
+
}
|
|
1835
|
+
return rel;
|
|
1836
|
+
}
|
|
1837
|
+
var SemanticMemory = class {
|
|
1838
|
+
db;
|
|
1839
|
+
embedder;
|
|
1840
|
+
constructor(db, embedder) {
|
|
1841
|
+
this.db = db;
|
|
1842
|
+
this.embedder = embedder;
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Store a memory with semantic embedding
|
|
1846
|
+
*/
|
|
1847
|
+
async store(key, content, embedding, metadata) {
|
|
1848
|
+
let vector = embedding;
|
|
1849
|
+
if (!vector && this.embedder) {
|
|
1850
|
+
vector = await this.embedder.embed(content);
|
|
1851
|
+
}
|
|
1852
|
+
if (vector) {
|
|
1853
|
+
await this.db.insertWithId(key, vector, { content, ...metadata });
|
|
1854
|
+
}
|
|
1855
|
+
const safeKey = sanitizeCypher(key);
|
|
1856
|
+
const safeContent = sanitizeCypher(content);
|
|
1857
|
+
await this.db.cypher(
|
|
1858
|
+
`CREATE (m:Memory {key: "${safeKey}", content: "${safeContent}", timestamp: ${Date.now()}})`
|
|
1859
|
+
);
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Query memories by semantic similarity
|
|
1863
|
+
*/
|
|
1864
|
+
async query(queryText, embedding, k = 5) {
|
|
1865
|
+
let vector = embedding;
|
|
1866
|
+
if (!vector && this.embedder) {
|
|
1867
|
+
vector = await this.embedder.embed(queryText);
|
|
1868
|
+
}
|
|
1869
|
+
if (!vector) {
|
|
1870
|
+
throw new Error("No embedding provided and no embedder configured");
|
|
1871
|
+
}
|
|
1872
|
+
return this.db.search(vector, k);
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Add a relationship between memories
|
|
1876
|
+
*/
|
|
1877
|
+
async addRelation(fromKey, relation, toKey) {
|
|
1878
|
+
const safeFrom = sanitizeCypher(fromKey);
|
|
1879
|
+
const safeTo = sanitizeCypher(toKey);
|
|
1880
|
+
const safeRel = validateRelationType(relation);
|
|
1881
|
+
await this.db.cypher(
|
|
1882
|
+
`MATCH (a:Memory {key: "${safeFrom}"}), (b:Memory {key: "${safeTo}"}) CREATE (a)-[:${safeRel}]->(b)`
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Find related memories through graph traversal
|
|
1887
|
+
*/
|
|
1888
|
+
async findRelated(key, depth = 2) {
|
|
1889
|
+
const safeKey = sanitizeCypher(key);
|
|
1890
|
+
const safeDepth = Math.max(1, Math.min(10, Math.floor(depth)));
|
|
1891
|
+
return this.db.cypher(
|
|
1892
|
+
`MATCH (m:Memory {key: "${safeKey}"})-[*1..${safeDepth}]-(related:Memory) RETURN DISTINCT related`
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
var BrowserWriterLease = class _BrowserWriterLease {
|
|
1897
|
+
heartbeatInterval = null;
|
|
1898
|
+
storeId = null;
|
|
1899
|
+
static DB_NAME = "_rvlite_locks";
|
|
1900
|
+
static STORE_NAME = "locks";
|
|
1901
|
+
static HEARTBEAT_MS = 1e4;
|
|
1902
|
+
static DEFAULT_STALE_MS = 3e4;
|
|
1903
|
+
// ---- helpers ----
|
|
1904
|
+
static openDb() {
|
|
1905
|
+
return new Promise((resolve, reject) => {
|
|
1906
|
+
const req = indexedDB.open(_BrowserWriterLease.DB_NAME, 1);
|
|
1907
|
+
req.onupgradeneeded = () => {
|
|
1908
|
+
const db = req.result;
|
|
1909
|
+
if (!db.objectStoreNames.contains(_BrowserWriterLease.STORE_NAME)) {
|
|
1910
|
+
db.createObjectStore(_BrowserWriterLease.STORE_NAME, { keyPath: "id" });
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
req.onsuccess = () => resolve(req.result);
|
|
1914
|
+
req.onerror = () => reject(req.error);
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
static idbPut(db, record) {
|
|
1918
|
+
return new Promise((resolve, reject) => {
|
|
1919
|
+
const tx = db.transaction(_BrowserWriterLease.STORE_NAME, "readwrite");
|
|
1920
|
+
const store = tx.objectStore(_BrowserWriterLease.STORE_NAME);
|
|
1921
|
+
const req = store.put(record);
|
|
1922
|
+
req.onsuccess = () => resolve();
|
|
1923
|
+
req.onerror = () => reject(req.error);
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
static idbGet(db, key) {
|
|
1927
|
+
return new Promise((resolve, reject) => {
|
|
1928
|
+
const tx = db.transaction(_BrowserWriterLease.STORE_NAME, "readonly");
|
|
1929
|
+
const store = tx.objectStore(_BrowserWriterLease.STORE_NAME);
|
|
1930
|
+
const req = store.get(key);
|
|
1931
|
+
req.onsuccess = () => resolve(req.result);
|
|
1932
|
+
req.onerror = () => reject(req.error);
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
static idbDelete(db, key) {
|
|
1936
|
+
return new Promise((resolve, reject) => {
|
|
1937
|
+
const tx = db.transaction(_BrowserWriterLease.STORE_NAME, "readwrite");
|
|
1938
|
+
const store = tx.objectStore(_BrowserWriterLease.STORE_NAME);
|
|
1939
|
+
const req = store.delete(key);
|
|
1940
|
+
req.onsuccess = () => resolve();
|
|
1941
|
+
req.onerror = () => reject(req.error);
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
// ---- public API ----
|
|
1945
|
+
/**
|
|
1946
|
+
* Try to acquire the writer lease for the given store.
|
|
1947
|
+
*
|
|
1948
|
+
* @param storeId - Unique identifier for the rvlite store being locked.
|
|
1949
|
+
* @param timeout - Maximum time in ms to wait for the lease (default 5000).
|
|
1950
|
+
* @returns `true` if the lease was acquired, `false` on timeout.
|
|
1951
|
+
*/
|
|
1952
|
+
async acquire(storeId, timeout = 5e3) {
|
|
1953
|
+
if (typeof indexedDB === "undefined") {
|
|
1954
|
+
throw new Error("BrowserWriterLease requires IndexedDB");
|
|
1955
|
+
}
|
|
1956
|
+
const deadline = Date.now() + timeout;
|
|
1957
|
+
const db = await _BrowserWriterLease.openDb();
|
|
1958
|
+
while (Date.now() < deadline) {
|
|
1959
|
+
const existing = await _BrowserWriterLease.idbGet(db, storeId);
|
|
1960
|
+
if (!existing || await _BrowserWriterLease.isStale(storeId)) {
|
|
1961
|
+
await _BrowserWriterLease.idbPut(db, {
|
|
1962
|
+
id: storeId,
|
|
1963
|
+
holder: this.holderId(),
|
|
1964
|
+
ts: Date.now()
|
|
1965
|
+
});
|
|
1966
|
+
const confirm = await _BrowserWriterLease.idbGet(db, storeId);
|
|
1967
|
+
if (confirm && confirm.holder === this.holderId()) {
|
|
1968
|
+
this.storeId = storeId;
|
|
1969
|
+
this.startHeartbeat(db);
|
|
1970
|
+
this.registerUnloadHandler();
|
|
1971
|
+
db.close();
|
|
1972
|
+
return true;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
1976
|
+
}
|
|
1977
|
+
db.close();
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Release the currently held lease.
|
|
1982
|
+
*/
|
|
1983
|
+
async release() {
|
|
1984
|
+
this.stopHeartbeat();
|
|
1985
|
+
if (this.storeId === null) return;
|
|
1986
|
+
try {
|
|
1987
|
+
const db = await _BrowserWriterLease.openDb();
|
|
1988
|
+
await _BrowserWriterLease.idbDelete(db, this.storeId);
|
|
1989
|
+
db.close();
|
|
1990
|
+
} catch {
|
|
1991
|
+
}
|
|
1992
|
+
this.storeId = null;
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1995
|
+
* Check whether the lease for `storeId` is stale (the holder has stopped
|
|
1996
|
+
* sending heartbeats).
|
|
1997
|
+
*
|
|
1998
|
+
* @param storeId - Store identifier.
|
|
1999
|
+
* @param thresholdMs - Staleness threshold (default 30 000 ms).
|
|
2000
|
+
*/
|
|
2001
|
+
static async isStale(storeId, thresholdMs = _BrowserWriterLease.DEFAULT_STALE_MS) {
|
|
2002
|
+
if (typeof indexedDB === "undefined") return true;
|
|
2003
|
+
const db = await _BrowserWriterLease.openDb();
|
|
2004
|
+
const record = await _BrowserWriterLease.idbGet(db, storeId);
|
|
2005
|
+
db.close();
|
|
2006
|
+
if (!record) return true;
|
|
2007
|
+
return Date.now() - record.ts > thresholdMs;
|
|
2008
|
+
}
|
|
2009
|
+
// ---- private helpers ----
|
|
2010
|
+
_holderId = null;
|
|
2011
|
+
holderId() {
|
|
2012
|
+
if (!this._holderId) {
|
|
2013
|
+
this._holderId = `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
2014
|
+
}
|
|
2015
|
+
return this._holderId;
|
|
2016
|
+
}
|
|
2017
|
+
startHeartbeat(db) {
|
|
2018
|
+
this.stopHeartbeat();
|
|
2019
|
+
const storeId = this.storeId;
|
|
2020
|
+
const holder = this.holderId();
|
|
2021
|
+
const beat = async () => {
|
|
2022
|
+
try {
|
|
2023
|
+
const freshDb = await _BrowserWriterLease.openDb();
|
|
2024
|
+
await _BrowserWriterLease.idbPut(freshDb, {
|
|
2025
|
+
id: storeId,
|
|
2026
|
+
holder,
|
|
2027
|
+
ts: Date.now()
|
|
2028
|
+
});
|
|
2029
|
+
freshDb.close();
|
|
2030
|
+
} catch {
|
|
2031
|
+
}
|
|
2032
|
+
};
|
|
2033
|
+
this.heartbeatInterval = setInterval(
|
|
2034
|
+
beat,
|
|
2035
|
+
_BrowserWriterLease.HEARTBEAT_MS
|
|
2036
|
+
);
|
|
2037
|
+
}
|
|
2038
|
+
stopHeartbeat() {
|
|
2039
|
+
if (this.heartbeatInterval !== null) {
|
|
2040
|
+
clearInterval(this.heartbeatInterval);
|
|
2041
|
+
this.heartbeatInterval = null;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
registerUnloadHandler() {
|
|
2045
|
+
if (typeof globalThis.addEventListener === "function") {
|
|
2046
|
+
const handler = () => {
|
|
2047
|
+
this.stopHeartbeat();
|
|
2048
|
+
};
|
|
2049
|
+
globalThis.addEventListener("beforeunload", handler, { once: true });
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
async function checkEpochSync(db) {
|
|
2054
|
+
const rvfEntry = await db.get("_rvlite_rvf_epoch");
|
|
2055
|
+
const metaEntry = await db.get("_rvlite_metadata_epoch");
|
|
2056
|
+
const rvfEpoch = rvfEntry?.metadata?.epoch ?? 0;
|
|
2057
|
+
const metadataEpoch = metaEntry?.metadata?.epoch ?? 0;
|
|
2058
|
+
let status;
|
|
2059
|
+
if (rvfEpoch === metadataEpoch) {
|
|
2060
|
+
status = "synchronized";
|
|
2061
|
+
} else if (rvfEpoch > metadataEpoch) {
|
|
2062
|
+
status = "rvf_ahead";
|
|
2063
|
+
} else {
|
|
2064
|
+
status = "metadata_ahead";
|
|
2065
|
+
}
|
|
2066
|
+
return { rvfEpoch, metadataEpoch, status };
|
|
2067
|
+
}
|
|
2068
|
+
async function reconcileEpochs(db, state) {
|
|
2069
|
+
if (state.status === "synchronized") return;
|
|
2070
|
+
const targetEpoch = Math.max(state.rvfEpoch, state.metadataEpoch);
|
|
2071
|
+
const dummyVector = [0];
|
|
2072
|
+
try {
|
|
2073
|
+
await db.delete("_rvlite_rvf_epoch");
|
|
2074
|
+
} catch {
|
|
2075
|
+
}
|
|
2076
|
+
try {
|
|
2077
|
+
await db.delete("_rvlite_metadata_epoch");
|
|
2078
|
+
} catch {
|
|
2079
|
+
}
|
|
2080
|
+
await db.insertWithId("_rvlite_rvf_epoch", dummyVector, { epoch: targetEpoch });
|
|
2081
|
+
await db.insertWithId("_rvlite_metadata_epoch", dummyVector, { epoch: targetEpoch });
|
|
2082
|
+
}
|
|
2083
|
+
async function bumpRvfEpoch(db) {
|
|
2084
|
+
const current = await checkEpochSync(db);
|
|
2085
|
+
const next = current.rvfEpoch + 1;
|
|
2086
|
+
const dummyVector = [0];
|
|
2087
|
+
try {
|
|
2088
|
+
await db.delete("_rvlite_rvf_epoch");
|
|
2089
|
+
} catch {
|
|
2090
|
+
}
|
|
2091
|
+
await db.insertWithId("_rvlite_rvf_epoch", dummyVector, { epoch: next });
|
|
2092
|
+
return next;
|
|
2093
|
+
}
|
|
2094
|
+
async function bumpMetadataEpoch(db) {
|
|
2095
|
+
const current = await checkEpochSync(db);
|
|
2096
|
+
const next = current.metadataEpoch + 1;
|
|
2097
|
+
const dummyVector = [0];
|
|
2098
|
+
try {
|
|
2099
|
+
await db.delete("_rvlite_metadata_epoch");
|
|
2100
|
+
} catch {
|
|
2101
|
+
}
|
|
2102
|
+
await db.insertWithId("_rvlite_metadata_epoch", dummyVector, { epoch: next });
|
|
2103
|
+
return next;
|
|
2104
|
+
}
|
|
2105
|
+
var index_default = RvLite2;
|
|
2106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2107
|
+
0 && (module.exports = {
|
|
2108
|
+
BrowserWriterLease,
|
|
2109
|
+
CypherEngine,
|
|
2110
|
+
RvLite,
|
|
2111
|
+
RvLiteConfig,
|
|
2112
|
+
SemanticMemory,
|
|
2113
|
+
bumpMetadataEpoch,
|
|
2114
|
+
bumpRvfEpoch,
|
|
2115
|
+
checkEpochSync,
|
|
2116
|
+
createAnthropicEmbeddings,
|
|
2117
|
+
createRvLite,
|
|
2118
|
+
getStorageBackend,
|
|
2119
|
+
init,
|
|
2120
|
+
initSync,
|
|
2121
|
+
isRvfAvailable,
|
|
2122
|
+
reconcileEpochs
|
|
2123
|
+
});
|