lucivy-wasm 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -60
- package/js/lucivy-worker.js +363 -0
- package/js/lucivy.d.ts +92 -0
- package/js/lucivy.js +133 -0
- package/package.json +22 -14
- package/pkg/lucivy.js +2 -0
- package/pkg/lucivy.wasm +0 -0
- package/LICENSE +0 -22
- package/lucivy_wasm.d.ts +0 -121
- package/lucivy_wasm.js +0 -685
- package/lucivy_wasm_bg.wasm +0 -0
- package/lucivy_wasm_bg.wasm.d.ts +0 -29
- package/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js +0 -107
package/lucivy_wasm.js
DELETED
|
@@ -1,685 +0,0 @@
|
|
|
1
|
-
/* @ts-self-types="./lucivy_wasm.d.ts" */
|
|
2
|
-
|
|
3
|
-
export class Index {
|
|
4
|
-
static __wrap(ptr) {
|
|
5
|
-
ptr = ptr >>> 0;
|
|
6
|
-
const obj = Object.create(Index.prototype);
|
|
7
|
-
obj.__wbg_ptr = ptr;
|
|
8
|
-
IndexFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
9
|
-
return obj;
|
|
10
|
-
}
|
|
11
|
-
__destroy_into_raw() {
|
|
12
|
-
const ptr = this.__wbg_ptr;
|
|
13
|
-
this.__wbg_ptr = 0;
|
|
14
|
-
IndexFinalization.unregister(this);
|
|
15
|
-
return ptr;
|
|
16
|
-
}
|
|
17
|
-
free() {
|
|
18
|
-
const ptr = this.__destroy_into_raw();
|
|
19
|
-
wasm.__wbg_index_free(ptr, 0);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @param {number} doc_id
|
|
23
|
-
* @param {string} fields_json
|
|
24
|
-
*/
|
|
25
|
-
add(doc_id, fields_json) {
|
|
26
|
-
const ptr0 = passStringToWasm0(fields_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
27
|
-
const len0 = WASM_VECTOR_LEN;
|
|
28
|
-
const ret = wasm.index_add(this.__wbg_ptr, doc_id, ptr0, len0);
|
|
29
|
-
if (ret[1]) {
|
|
30
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @param {string} docs_json
|
|
35
|
-
*/
|
|
36
|
-
addMany(docs_json) {
|
|
37
|
-
const ptr0 = passStringToWasm0(docs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
-
const len0 = WASM_VECTOR_LEN;
|
|
39
|
-
const ret = wasm.index_addMany(this.__wbg_ptr, ptr0, len0);
|
|
40
|
-
if (ret[1]) {
|
|
41
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Commit changes to the in-memory directory.
|
|
46
|
-
* After this, call `exportDirtyFiles()` to get files to persist to OPFS.
|
|
47
|
-
*/
|
|
48
|
-
commit() {
|
|
49
|
-
const ret = wasm.index_commit(this.__wbg_ptr);
|
|
50
|
-
if (ret[1]) {
|
|
51
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Create a new index.
|
|
56
|
-
* `fields_json`: JSON array of field definitions.
|
|
57
|
-
* `stemmer`: language string ("english", "french", ...) or empty.
|
|
58
|
-
* Returns an Index. Caller should then call `export_all_files()` to persist to OPFS.
|
|
59
|
-
* @param {string} path
|
|
60
|
-
* @param {string} fields_json
|
|
61
|
-
* @param {string} stemmer
|
|
62
|
-
*/
|
|
63
|
-
constructor(path, fields_json, stemmer) {
|
|
64
|
-
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
65
|
-
const len0 = WASM_VECTOR_LEN;
|
|
66
|
-
const ptr1 = passStringToWasm0(fields_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
67
|
-
const len1 = WASM_VECTOR_LEN;
|
|
68
|
-
const ptr2 = passStringToWasm0(stemmer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
69
|
-
const len2 = WASM_VECTOR_LEN;
|
|
70
|
-
const ret = wasm.index_create(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
71
|
-
if (ret[2]) {
|
|
72
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
73
|
-
}
|
|
74
|
-
this.__wbg_ptr = ret[0] >>> 0;
|
|
75
|
-
IndexFinalization.register(this, this.__wbg_ptr, this);
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Export ALL files (for initial persist after create).
|
|
80
|
-
* Returns: `[[path, Uint8Array], ...]`
|
|
81
|
-
* @returns {any}
|
|
82
|
-
*/
|
|
83
|
-
exportAllFiles() {
|
|
84
|
-
const ret = wasm.index_exportAllFiles(this.__wbg_ptr);
|
|
85
|
-
if (ret[2]) {
|
|
86
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
87
|
-
}
|
|
88
|
-
return takeFromExternrefTable0(ret[0]);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Export dirty files (modified + deleted) since last export.
|
|
92
|
-
* Returns a JS object: `{ modified: [[path, Uint8Array], ...], deleted: [path, ...] }`
|
|
93
|
-
* The JS side writes modified files to OPFS and removes deleted ones.
|
|
94
|
-
* @returns {any}
|
|
95
|
-
*/
|
|
96
|
-
exportDirtyFiles() {
|
|
97
|
-
const ret = wasm.index_exportDirtyFiles(this.__wbg_ptr);
|
|
98
|
-
if (ret[2]) {
|
|
99
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
100
|
-
}
|
|
101
|
-
return takeFromExternrefTable0(ret[0]);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Export the index as a LUCE snapshot blob.
|
|
105
|
-
* The index must have no uncommitted changes (call `commit()` first).
|
|
106
|
-
* Returns a `Uint8Array`.
|
|
107
|
-
* @returns {Uint8Array}
|
|
108
|
-
*/
|
|
109
|
-
exportSnapshot() {
|
|
110
|
-
const ret = wasm.index_exportSnapshot(this.__wbg_ptr);
|
|
111
|
-
if (ret[3]) {
|
|
112
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
113
|
-
}
|
|
114
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
115
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
116
|
-
return v1;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Import a LUCE snapshot blob and return a new Index.
|
|
120
|
-
* `data`: the LUCE blob as `Uint8Array`.
|
|
121
|
-
* `path`: the logical path for the imported index.
|
|
122
|
-
* @param {Uint8Array} data
|
|
123
|
-
* @param {string} path
|
|
124
|
-
* @returns {Index}
|
|
125
|
-
*/
|
|
126
|
-
static importSnapshot(data, path) {
|
|
127
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
128
|
-
const len0 = WASM_VECTOR_LEN;
|
|
129
|
-
const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
-
const len1 = WASM_VECTOR_LEN;
|
|
131
|
-
const ret = wasm.index_importSnapshot(ptr0, len0, ptr1, len1);
|
|
132
|
-
if (ret[2]) {
|
|
133
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
134
|
-
}
|
|
135
|
-
return Index.__wrap(ret[0]);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* @returns {number}
|
|
139
|
-
*/
|
|
140
|
-
get numDocs() {
|
|
141
|
-
const ret = wasm.index_numDocs(this.__wbg_ptr);
|
|
142
|
-
return ret >>> 0;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Open an existing index from files previously read from OPFS.
|
|
146
|
-
* `files`: JS Map of filename → Uint8Array.
|
|
147
|
-
* The JS side reads all files from OPFS and passes them here.
|
|
148
|
-
* @param {string} path
|
|
149
|
-
* @param {Map<any, any>} files
|
|
150
|
-
* @returns {Index}
|
|
151
|
-
*/
|
|
152
|
-
static open(path, files) {
|
|
153
|
-
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
-
const len0 = WASM_VECTOR_LEN;
|
|
155
|
-
const ret = wasm.index_open(ptr0, len0, files);
|
|
156
|
-
if (ret[2]) {
|
|
157
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
158
|
-
}
|
|
159
|
-
return Index.__wrap(ret[0]);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* @returns {string}
|
|
163
|
-
*/
|
|
164
|
-
get path() {
|
|
165
|
-
let deferred1_0;
|
|
166
|
-
let deferred1_1;
|
|
167
|
-
try {
|
|
168
|
-
const ret = wasm.index_path(this.__wbg_ptr);
|
|
169
|
-
deferred1_0 = ret[0];
|
|
170
|
-
deferred1_1 = ret[1];
|
|
171
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
172
|
-
} finally {
|
|
173
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* @param {number} doc_id
|
|
178
|
-
*/
|
|
179
|
-
remove(doc_id) {
|
|
180
|
-
const ret = wasm.index_remove(this.__wbg_ptr, doc_id);
|
|
181
|
-
if (ret[1]) {
|
|
182
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
rollback() {
|
|
186
|
-
const ret = wasm.index_rollback(this.__wbg_ptr);
|
|
187
|
-
if (ret[1]) {
|
|
188
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* @returns {string}
|
|
193
|
-
*/
|
|
194
|
-
get schemaJson() {
|
|
195
|
-
let deferred1_0;
|
|
196
|
-
let deferred1_1;
|
|
197
|
-
try {
|
|
198
|
-
const ret = wasm.index_schemaJson(this.__wbg_ptr);
|
|
199
|
-
deferred1_0 = ret[0];
|
|
200
|
-
deferred1_1 = ret[1];
|
|
201
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
202
|
-
} finally {
|
|
203
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Search the index.
|
|
208
|
-
* `query_json`: a JSON string (contains_split on all text fields) or a query object.
|
|
209
|
-
* Returns JSON: `[{docId, score, highlights?}, ...]`
|
|
210
|
-
* @param {string} query_json
|
|
211
|
-
* @param {number} limit
|
|
212
|
-
* @param {boolean | null} [highlights]
|
|
213
|
-
* @returns {string}
|
|
214
|
-
*/
|
|
215
|
-
search(query_json, limit, highlights) {
|
|
216
|
-
let deferred3_0;
|
|
217
|
-
let deferred3_1;
|
|
218
|
-
try {
|
|
219
|
-
const ptr0 = passStringToWasm0(query_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
220
|
-
const len0 = WASM_VECTOR_LEN;
|
|
221
|
-
const ret = wasm.index_search(this.__wbg_ptr, ptr0, len0, limit, isLikeNone(highlights) ? 0xFFFFFF : highlights ? 1 : 0);
|
|
222
|
-
var ptr2 = ret[0];
|
|
223
|
-
var len2 = ret[1];
|
|
224
|
-
if (ret[3]) {
|
|
225
|
-
ptr2 = 0; len2 = 0;
|
|
226
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
227
|
-
}
|
|
228
|
-
deferred3_0 = ptr2;
|
|
229
|
-
deferred3_1 = len2;
|
|
230
|
-
return getStringFromWasm0(ptr2, len2);
|
|
231
|
-
} finally {
|
|
232
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Search with allowed_ids filter.
|
|
237
|
-
* `allowed_ids`: JS array of u32 doc IDs.
|
|
238
|
-
* @param {string} query_json
|
|
239
|
-
* @param {number} limit
|
|
240
|
-
* @param {Uint32Array} allowed_ids
|
|
241
|
-
* @param {boolean | null} [highlights]
|
|
242
|
-
* @returns {string}
|
|
243
|
-
*/
|
|
244
|
-
searchFiltered(query_json, limit, allowed_ids, highlights) {
|
|
245
|
-
let deferred4_0;
|
|
246
|
-
let deferred4_1;
|
|
247
|
-
try {
|
|
248
|
-
const ptr0 = passStringToWasm0(query_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
249
|
-
const len0 = WASM_VECTOR_LEN;
|
|
250
|
-
const ptr1 = passArray32ToWasm0(allowed_ids, wasm.__wbindgen_malloc);
|
|
251
|
-
const len1 = WASM_VECTOR_LEN;
|
|
252
|
-
const ret = wasm.index_searchFiltered(this.__wbg_ptr, ptr0, len0, limit, ptr1, len1, isLikeNone(highlights) ? 0xFFFFFF : highlights ? 1 : 0);
|
|
253
|
-
var ptr3 = ret[0];
|
|
254
|
-
var len3 = ret[1];
|
|
255
|
-
if (ret[3]) {
|
|
256
|
-
ptr3 = 0; len3 = 0;
|
|
257
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
258
|
-
}
|
|
259
|
-
deferred4_0 = ptr3;
|
|
260
|
-
deferred4_1 = len3;
|
|
261
|
-
return getStringFromWasm0(ptr3, len3);
|
|
262
|
-
} finally {
|
|
263
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* @param {number} doc_id
|
|
268
|
-
* @param {string} fields_json
|
|
269
|
-
*/
|
|
270
|
-
update(doc_id, fields_json) {
|
|
271
|
-
const ptr0 = passStringToWasm0(fields_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
272
|
-
const len0 = WASM_VECTOR_LEN;
|
|
273
|
-
const ret = wasm.index_update(this.__wbg_ptr, doc_id, ptr0, len0);
|
|
274
|
-
if (ret[1]) {
|
|
275
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (Symbol.dispose) Index.prototype[Symbol.dispose] = Index.prototype.free;
|
|
280
|
-
|
|
281
|
-
function __wbg_get_imports() {
|
|
282
|
-
const import0 = {
|
|
283
|
-
__proto__: null,
|
|
284
|
-
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
285
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
286
|
-
return ret;
|
|
287
|
-
},
|
|
288
|
-
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
289
|
-
const ret = debugString(arg1);
|
|
290
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
-
const len1 = WASM_VECTOR_LEN;
|
|
292
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
293
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
294
|
-
},
|
|
295
|
-
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
296
|
-
const obj = arg1;
|
|
297
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
298
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
299
|
-
var len1 = WASM_VECTOR_LEN;
|
|
300
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
301
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
302
|
-
},
|
|
303
|
-
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
304
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
305
|
-
},
|
|
306
|
-
__wbg_done_57b39ecd9addfe81: function(arg0) {
|
|
307
|
-
const ret = arg0.done;
|
|
308
|
-
return ret;
|
|
309
|
-
},
|
|
310
|
-
__wbg_entries_200a450561fa274f: function(arg0) {
|
|
311
|
-
const ret = arg0.entries();
|
|
312
|
-
return ret;
|
|
313
|
-
},
|
|
314
|
-
__wbg_from_bddd64e7d5ff6941: function(arg0) {
|
|
315
|
-
const ret = Array.from(arg0);
|
|
316
|
-
return ret;
|
|
317
|
-
},
|
|
318
|
-
__wbg_getRandomValues_9c5c1b115e142bb8: function() { return handleError(function (arg0, arg1) {
|
|
319
|
-
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
320
|
-
}, arguments); },
|
|
321
|
-
__wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
|
|
322
|
-
const ret = arg0[arg1 >>> 0];
|
|
323
|
-
return ret;
|
|
324
|
-
},
|
|
325
|
-
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
326
|
-
const ret = arg0.length;
|
|
327
|
-
return ret;
|
|
328
|
-
},
|
|
329
|
-
__wbg_new_361308b2356cecd0: function() {
|
|
330
|
-
const ret = new Object();
|
|
331
|
-
return ret;
|
|
332
|
-
},
|
|
333
|
-
__wbg_new_3eb36ae241fe6f44: function() {
|
|
334
|
-
const ret = new Array();
|
|
335
|
-
return ret;
|
|
336
|
-
},
|
|
337
|
-
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
338
|
-
const ret = new Uint8Array(arg0);
|
|
339
|
-
return ret;
|
|
340
|
-
},
|
|
341
|
-
__wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
|
|
342
|
-
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
343
|
-
return ret;
|
|
344
|
-
},
|
|
345
|
-
__wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
|
|
346
|
-
const ret = arg0.next();
|
|
347
|
-
return ret;
|
|
348
|
-
}, arguments); },
|
|
349
|
-
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
350
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
351
|
-
},
|
|
352
|
-
__wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
|
|
353
|
-
const ret = arg0.push(arg1);
|
|
354
|
-
return ret;
|
|
355
|
-
},
|
|
356
|
-
__wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
|
|
357
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
358
|
-
return ret;
|
|
359
|
-
}, arguments); },
|
|
360
|
-
__wbg_value_0546255b415e96c1: function(arg0) {
|
|
361
|
-
const ret = arg0.value;
|
|
362
|
-
return ret;
|
|
363
|
-
},
|
|
364
|
-
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
365
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
366
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
367
|
-
return ret;
|
|
368
|
-
},
|
|
369
|
-
__wbindgen_init_externref_table: function() {
|
|
370
|
-
const table = wasm.__wbindgen_externrefs;
|
|
371
|
-
const offset = table.grow(4);
|
|
372
|
-
table.set(0, undefined);
|
|
373
|
-
table.set(offset + 0, undefined);
|
|
374
|
-
table.set(offset + 1, null);
|
|
375
|
-
table.set(offset + 2, true);
|
|
376
|
-
table.set(offset + 3, false);
|
|
377
|
-
},
|
|
378
|
-
};
|
|
379
|
-
return {
|
|
380
|
-
__proto__: null,
|
|
381
|
-
"./lucivy_wasm_bg.js": import0,
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
const IndexFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
386
|
-
? { register: () => {}, unregister: () => {} }
|
|
387
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_index_free(ptr >>> 0, 1));
|
|
388
|
-
|
|
389
|
-
function addToExternrefTable0(obj) {
|
|
390
|
-
const idx = wasm.__externref_table_alloc();
|
|
391
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
392
|
-
return idx;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function debugString(val) {
|
|
396
|
-
// primitive types
|
|
397
|
-
const type = typeof val;
|
|
398
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
399
|
-
return `${val}`;
|
|
400
|
-
}
|
|
401
|
-
if (type == 'string') {
|
|
402
|
-
return `"${val}"`;
|
|
403
|
-
}
|
|
404
|
-
if (type == 'symbol') {
|
|
405
|
-
const description = val.description;
|
|
406
|
-
if (description == null) {
|
|
407
|
-
return 'Symbol';
|
|
408
|
-
} else {
|
|
409
|
-
return `Symbol(${description})`;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
if (type == 'function') {
|
|
413
|
-
const name = val.name;
|
|
414
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
415
|
-
return `Function(${name})`;
|
|
416
|
-
} else {
|
|
417
|
-
return 'Function';
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
// objects
|
|
421
|
-
if (Array.isArray(val)) {
|
|
422
|
-
const length = val.length;
|
|
423
|
-
let debug = '[';
|
|
424
|
-
if (length > 0) {
|
|
425
|
-
debug += debugString(val[0]);
|
|
426
|
-
}
|
|
427
|
-
for(let i = 1; i < length; i++) {
|
|
428
|
-
debug += ', ' + debugString(val[i]);
|
|
429
|
-
}
|
|
430
|
-
debug += ']';
|
|
431
|
-
return debug;
|
|
432
|
-
}
|
|
433
|
-
// Test for built-in
|
|
434
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
435
|
-
let className;
|
|
436
|
-
if (builtInMatches && builtInMatches.length > 1) {
|
|
437
|
-
className = builtInMatches[1];
|
|
438
|
-
} else {
|
|
439
|
-
// Failed to match the standard '[object ClassName]'
|
|
440
|
-
return toString.call(val);
|
|
441
|
-
}
|
|
442
|
-
if (className == 'Object') {
|
|
443
|
-
// we're a user defined class or Object
|
|
444
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
445
|
-
// easier than looping through ownProperties of `val`.
|
|
446
|
-
try {
|
|
447
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
448
|
-
} catch (_) {
|
|
449
|
-
return 'Object';
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
// errors
|
|
453
|
-
if (val instanceof Error) {
|
|
454
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
455
|
-
}
|
|
456
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
457
|
-
return className;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
461
|
-
ptr = ptr >>> 0;
|
|
462
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
let cachedDataViewMemory0 = null;
|
|
466
|
-
function getDataViewMemory0() {
|
|
467
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
468
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
469
|
-
}
|
|
470
|
-
return cachedDataViewMemory0;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function getStringFromWasm0(ptr, len) {
|
|
474
|
-
ptr = ptr >>> 0;
|
|
475
|
-
return decodeText(ptr, len);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
let cachedUint32ArrayMemory0 = null;
|
|
479
|
-
function getUint32ArrayMemory0() {
|
|
480
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
481
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
482
|
-
}
|
|
483
|
-
return cachedUint32ArrayMemory0;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
let cachedUint8ArrayMemory0 = null;
|
|
487
|
-
function getUint8ArrayMemory0() {
|
|
488
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
489
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
490
|
-
}
|
|
491
|
-
return cachedUint8ArrayMemory0;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function handleError(f, args) {
|
|
495
|
-
try {
|
|
496
|
-
return f.apply(this, args);
|
|
497
|
-
} catch (e) {
|
|
498
|
-
const idx = addToExternrefTable0(e);
|
|
499
|
-
wasm.__wbindgen_exn_store(idx);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function isLikeNone(x) {
|
|
504
|
-
return x === undefined || x === null;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
508
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
509
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
510
|
-
WASM_VECTOR_LEN = arg.length;
|
|
511
|
-
return ptr;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
515
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
516
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
517
|
-
WASM_VECTOR_LEN = arg.length;
|
|
518
|
-
return ptr;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
522
|
-
if (realloc === undefined) {
|
|
523
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
524
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
525
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
526
|
-
WASM_VECTOR_LEN = buf.length;
|
|
527
|
-
return ptr;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
let len = arg.length;
|
|
531
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
532
|
-
|
|
533
|
-
const mem = getUint8ArrayMemory0();
|
|
534
|
-
|
|
535
|
-
let offset = 0;
|
|
536
|
-
|
|
537
|
-
for (; offset < len; offset++) {
|
|
538
|
-
const code = arg.charCodeAt(offset);
|
|
539
|
-
if (code > 0x7F) break;
|
|
540
|
-
mem[ptr + offset] = code;
|
|
541
|
-
}
|
|
542
|
-
if (offset !== len) {
|
|
543
|
-
if (offset !== 0) {
|
|
544
|
-
arg = arg.slice(offset);
|
|
545
|
-
}
|
|
546
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
547
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
548
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
549
|
-
|
|
550
|
-
offset += ret.written;
|
|
551
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
WASM_VECTOR_LEN = offset;
|
|
555
|
-
return ptr;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function takeFromExternrefTable0(idx) {
|
|
559
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
560
|
-
wasm.__externref_table_dealloc(idx);
|
|
561
|
-
return value;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
565
|
-
cachedTextDecoder.decode();
|
|
566
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
567
|
-
let numBytesDecoded = 0;
|
|
568
|
-
function decodeText(ptr, len) {
|
|
569
|
-
numBytesDecoded += len;
|
|
570
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
571
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
572
|
-
cachedTextDecoder.decode();
|
|
573
|
-
numBytesDecoded = len;
|
|
574
|
-
}
|
|
575
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
const cachedTextEncoder = new TextEncoder();
|
|
579
|
-
|
|
580
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
581
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
582
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
583
|
-
view.set(buf);
|
|
584
|
-
return {
|
|
585
|
-
read: arg.length,
|
|
586
|
-
written: buf.length
|
|
587
|
-
};
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
let WASM_VECTOR_LEN = 0;
|
|
592
|
-
|
|
593
|
-
let wasmModule, wasm;
|
|
594
|
-
function __wbg_finalize_init(instance, module) {
|
|
595
|
-
wasm = instance.exports;
|
|
596
|
-
wasmModule = module;
|
|
597
|
-
cachedDataViewMemory0 = null;
|
|
598
|
-
cachedUint32ArrayMemory0 = null;
|
|
599
|
-
cachedUint8ArrayMemory0 = null;
|
|
600
|
-
wasm.__wbindgen_start();
|
|
601
|
-
return wasm;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
async function __wbg_load(module, imports) {
|
|
605
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
606
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
607
|
-
try {
|
|
608
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
609
|
-
} catch (e) {
|
|
610
|
-
const validResponse = module.ok && expectedResponseType(module.type);
|
|
611
|
-
|
|
612
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
613
|
-
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);
|
|
614
|
-
|
|
615
|
-
} else { throw e; }
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
const bytes = await module.arrayBuffer();
|
|
620
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
621
|
-
} else {
|
|
622
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
623
|
-
|
|
624
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
625
|
-
return { instance, module };
|
|
626
|
-
} else {
|
|
627
|
-
return instance;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
function expectedResponseType(type) {
|
|
632
|
-
switch (type) {
|
|
633
|
-
case 'basic': case 'cors': case 'default': return true;
|
|
634
|
-
}
|
|
635
|
-
return false;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
function initSync(module) {
|
|
640
|
-
if (wasm !== undefined) return wasm;
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
if (module !== undefined) {
|
|
644
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
645
|
-
({module} = module)
|
|
646
|
-
} else {
|
|
647
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
const imports = __wbg_get_imports();
|
|
652
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
653
|
-
module = new WebAssembly.Module(module);
|
|
654
|
-
}
|
|
655
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
656
|
-
return __wbg_finalize_init(instance, module);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
async function __wbg_init(module_or_path) {
|
|
660
|
-
if (wasm !== undefined) return wasm;
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (module_or_path !== undefined) {
|
|
664
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
665
|
-
({module_or_path} = module_or_path)
|
|
666
|
-
} else {
|
|
667
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
if (module_or_path === undefined) {
|
|
672
|
-
module_or_path = new URL('lucivy_wasm_bg.wasm', import.meta.url);
|
|
673
|
-
}
|
|
674
|
-
const imports = __wbg_get_imports();
|
|
675
|
-
|
|
676
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
677
|
-
module_or_path = fetch(module_or_path);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
681
|
-
|
|
682
|
-
return __wbg_finalize_init(instance, module);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
export { initSync, __wbg_init as default };
|
package/lucivy_wasm_bg.wasm
DELETED
|
Binary file
|