@citadeldb/wasm 0.2.2 → 0.2.4
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/citadel_wasm.d.ts +44 -0
- package/citadel_wasm.js +638 -6
- package/citadel_wasm_bg.wasm +0 -0
- package/package.json +4 -5
- package/citadel_wasm_bg.js +0 -542
package/citadel_wasm.d.ts
CHANGED
|
@@ -57,3 +57,47 @@ export class CitadelDb {
|
|
|
57
57
|
*/
|
|
58
58
|
tablePut(table: string, key: Uint8Array, value: Uint8Array): void;
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
62
|
+
|
|
63
|
+
export interface InitOutput {
|
|
64
|
+
readonly memory: WebAssembly.Memory;
|
|
65
|
+
readonly __wbg_citadeldb_free: (a: number, b: number) => void;
|
|
66
|
+
readonly citadeldb_delete: (a: number, b: number, c: number, d: number) => void;
|
|
67
|
+
readonly citadeldb_execute: (a: number, b: number, c: number, d: number) => void;
|
|
68
|
+
readonly citadeldb_executeBatch: (a: number, b: number, c: number, d: number) => void;
|
|
69
|
+
readonly citadeldb_get: (a: number, b: number, c: number, d: number) => void;
|
|
70
|
+
readonly citadeldb_new: (a: number, b: number, c: number) => void;
|
|
71
|
+
readonly citadeldb_put: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
72
|
+
readonly citadeldb_query: (a: number, b: number, c: number, d: number) => void;
|
|
73
|
+
readonly citadeldb_stats: (a: number, b: number) => void;
|
|
74
|
+
readonly citadeldb_tableDelete: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
75
|
+
readonly citadeldb_tableGet: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
76
|
+
readonly citadeldb_tablePut: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
77
|
+
readonly __wbindgen_export: (a: number) => void;
|
|
78
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
79
|
+
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
80
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
87
|
+
* a precompiled `WebAssembly.Module`.
|
|
88
|
+
*
|
|
89
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
90
|
+
*
|
|
91
|
+
* @returns {InitOutput}
|
|
92
|
+
*/
|
|
93
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
97
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
98
|
+
*
|
|
99
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
100
|
+
*
|
|
101
|
+
* @returns {Promise<InitOutput>}
|
|
102
|
+
*/
|
|
103
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/citadel_wasm.js
CHANGED
|
@@ -1,9 +1,641 @@
|
|
|
1
1
|
/* @ts-self-types="./citadel_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export class CitadelDb {
|
|
4
|
+
__destroy_into_raw() {
|
|
5
|
+
const ptr = this.__wbg_ptr;
|
|
6
|
+
this.__wbg_ptr = 0;
|
|
7
|
+
CitadelDbFinalization.unregister(this);
|
|
8
|
+
return ptr;
|
|
9
|
+
}
|
|
10
|
+
free() {
|
|
11
|
+
const ptr = this.__destroy_into_raw();
|
|
12
|
+
wasm.__wbg_citadeldb_free(ptr, 0);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Delete a key from the default table.
|
|
16
|
+
* Returns true if the key existed.
|
|
17
|
+
* @param {Uint8Array} key
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
delete(key) {
|
|
21
|
+
try {
|
|
22
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
23
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
24
|
+
const len0 = WASM_VECTOR_LEN;
|
|
25
|
+
wasm.citadeldb_delete(retptr, this.__wbg_ptr, ptr0, len0);
|
|
26
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
27
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
28
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
29
|
+
if (r2) {
|
|
30
|
+
throw takeObject(r1);
|
|
31
|
+
}
|
|
32
|
+
return r0 !== 0;
|
|
33
|
+
} finally {
|
|
34
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Execute a SQL statement (DDL or DML).
|
|
39
|
+
* Returns the number of rows affected.
|
|
40
|
+
* @param {string} sql
|
|
41
|
+
* @returns {number}
|
|
42
|
+
*/
|
|
43
|
+
execute(sql) {
|
|
44
|
+
try {
|
|
45
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
46
|
+
const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
47
|
+
const len0 = WASM_VECTOR_LEN;
|
|
48
|
+
wasm.citadeldb_execute(retptr, this.__wbg_ptr, ptr0, len0);
|
|
49
|
+
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
50
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
51
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
52
|
+
if (r3) {
|
|
53
|
+
throw takeObject(r2);
|
|
54
|
+
}
|
|
55
|
+
return r0;
|
|
56
|
+
} finally {
|
|
57
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Execute multiple SQL statements separated by semicolons.
|
|
62
|
+
* @param {string} sql
|
|
63
|
+
*/
|
|
64
|
+
executeBatch(sql) {
|
|
65
|
+
try {
|
|
66
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
67
|
+
const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
68
|
+
const len0 = WASM_VECTOR_LEN;
|
|
69
|
+
wasm.citadeldb_executeBatch(retptr, this.__wbg_ptr, ptr0, len0);
|
|
70
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
71
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
72
|
+
if (r1) {
|
|
73
|
+
throw takeObject(r0);
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get a value by key from the default table.
|
|
81
|
+
* Returns null if not found.
|
|
82
|
+
* @param {Uint8Array} key
|
|
83
|
+
* @returns {any}
|
|
84
|
+
*/
|
|
85
|
+
get(key) {
|
|
86
|
+
try {
|
|
87
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
88
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
89
|
+
const len0 = WASM_VECTOR_LEN;
|
|
90
|
+
wasm.citadeldb_get(retptr, this.__wbg_ptr, ptr0, len0);
|
|
91
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
92
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
93
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
94
|
+
if (r2) {
|
|
95
|
+
throw takeObject(r1);
|
|
96
|
+
}
|
|
97
|
+
return takeObject(r0);
|
|
98
|
+
} finally {
|
|
99
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a new in-memory encrypted database.
|
|
104
|
+
* @param {string} passphrase
|
|
105
|
+
*/
|
|
106
|
+
constructor(passphrase) {
|
|
107
|
+
try {
|
|
108
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
109
|
+
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
110
|
+
const len0 = WASM_VECTOR_LEN;
|
|
111
|
+
wasm.citadeldb_new(retptr, ptr0, len0);
|
|
112
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
113
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
114
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
115
|
+
if (r2) {
|
|
116
|
+
throw takeObject(r1);
|
|
117
|
+
}
|
|
118
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
119
|
+
CitadelDbFinalization.register(this, this.__wbg_ptr, this);
|
|
120
|
+
return this;
|
|
121
|
+
} finally {
|
|
122
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Put a key-value pair into the default table.
|
|
127
|
+
* @param {Uint8Array} key
|
|
128
|
+
* @param {Uint8Array} value
|
|
129
|
+
*/
|
|
130
|
+
put(key, value) {
|
|
131
|
+
try {
|
|
132
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
133
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
134
|
+
const len0 = WASM_VECTOR_LEN;
|
|
135
|
+
const ptr1 = passArray8ToWasm0(value, wasm.__wbindgen_export2);
|
|
136
|
+
const len1 = WASM_VECTOR_LEN;
|
|
137
|
+
wasm.citadeldb_put(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
138
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
139
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
140
|
+
if (r1) {
|
|
141
|
+
throw takeObject(r0);
|
|
142
|
+
}
|
|
143
|
+
} finally {
|
|
144
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Execute a SQL query and return results as a JS object.
|
|
149
|
+
*
|
|
150
|
+
* Returns `{ columns: string[], rows: any[][] }`.
|
|
151
|
+
* @param {string} sql
|
|
152
|
+
* @returns {any}
|
|
153
|
+
*/
|
|
154
|
+
query(sql) {
|
|
155
|
+
try {
|
|
156
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
157
|
+
const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
158
|
+
const len0 = WASM_VECTOR_LEN;
|
|
159
|
+
wasm.citadeldb_query(retptr, this.__wbg_ptr, ptr0, len0);
|
|
160
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
161
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
162
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
163
|
+
if (r2) {
|
|
164
|
+
throw takeObject(r1);
|
|
165
|
+
}
|
|
166
|
+
return takeObject(r0);
|
|
167
|
+
} finally {
|
|
168
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get database statistics.
|
|
173
|
+
* Returns `{ entryCount: number, totalPages: number, treeDepth: number }`.
|
|
174
|
+
* @returns {any}
|
|
175
|
+
*/
|
|
176
|
+
stats() {
|
|
177
|
+
try {
|
|
178
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
179
|
+
wasm.citadeldb_stats(retptr, this.__wbg_ptr);
|
|
180
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
181
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
182
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
183
|
+
if (r2) {
|
|
184
|
+
throw takeObject(r1);
|
|
185
|
+
}
|
|
186
|
+
return takeObject(r0);
|
|
187
|
+
} finally {
|
|
188
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Delete a key from a named table.
|
|
193
|
+
* Returns true if the key existed.
|
|
194
|
+
* @param {string} table
|
|
195
|
+
* @param {Uint8Array} key
|
|
196
|
+
* @returns {boolean}
|
|
197
|
+
*/
|
|
198
|
+
tableDelete(table, key) {
|
|
199
|
+
try {
|
|
200
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
201
|
+
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
202
|
+
const len0 = WASM_VECTOR_LEN;
|
|
203
|
+
const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
204
|
+
const len1 = WASM_VECTOR_LEN;
|
|
205
|
+
wasm.citadeldb_tableDelete(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
206
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
207
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
208
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
209
|
+
if (r2) {
|
|
210
|
+
throw takeObject(r1);
|
|
211
|
+
}
|
|
212
|
+
return r0 !== 0;
|
|
213
|
+
} finally {
|
|
214
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get a value by key from a named table.
|
|
219
|
+
* Returns null if not found.
|
|
220
|
+
* @param {string} table
|
|
221
|
+
* @param {Uint8Array} key
|
|
222
|
+
* @returns {any}
|
|
223
|
+
*/
|
|
224
|
+
tableGet(table, key) {
|
|
225
|
+
try {
|
|
226
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
227
|
+
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
228
|
+
const len0 = WASM_VECTOR_LEN;
|
|
229
|
+
const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
230
|
+
const len1 = WASM_VECTOR_LEN;
|
|
231
|
+
wasm.citadeldb_tableGet(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
232
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
233
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
234
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
235
|
+
if (r2) {
|
|
236
|
+
throw takeObject(r1);
|
|
237
|
+
}
|
|
238
|
+
return takeObject(r0);
|
|
239
|
+
} finally {
|
|
240
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Put a key-value pair into a named table.
|
|
245
|
+
* @param {string} table
|
|
246
|
+
* @param {Uint8Array} key
|
|
247
|
+
* @param {Uint8Array} value
|
|
248
|
+
*/
|
|
249
|
+
tablePut(table, key, value) {
|
|
250
|
+
try {
|
|
251
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
252
|
+
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
253
|
+
const len0 = WASM_VECTOR_LEN;
|
|
254
|
+
const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
255
|
+
const len1 = WASM_VECTOR_LEN;
|
|
256
|
+
const ptr2 = passArray8ToWasm0(value, wasm.__wbindgen_export2);
|
|
257
|
+
const len2 = WASM_VECTOR_LEN;
|
|
258
|
+
wasm.citadeldb_tablePut(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
259
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
260
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
261
|
+
if (r1) {
|
|
262
|
+
throw takeObject(r0);
|
|
263
|
+
}
|
|
264
|
+
} finally {
|
|
265
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (Symbol.dispose) CitadelDb.prototype[Symbol.dispose] = CitadelDb.prototype.free;
|
|
6
270
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
271
|
+
function __wbg_get_imports() {
|
|
272
|
+
const import0 = {
|
|
273
|
+
__proto__: null,
|
|
274
|
+
__wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
|
|
275
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
276
|
+
return ret;
|
|
277
|
+
},
|
|
278
|
+
__wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
|
|
279
|
+
const val = getObject(arg0);
|
|
280
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
281
|
+
return ret;
|
|
282
|
+
},
|
|
283
|
+
__wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
|
|
284
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
285
|
+
return ret;
|
|
286
|
+
},
|
|
287
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
288
|
+
const ret = getObject(arg0) === undefined;
|
|
289
|
+
return ret;
|
|
290
|
+
},
|
|
291
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
292
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
293
|
+
},
|
|
294
|
+
__wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
|
|
295
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
296
|
+
return addHeapObject(ret);
|
|
297
|
+
}, arguments); },
|
|
298
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
299
|
+
const ret = getObject(arg0).crypto;
|
|
300
|
+
return addHeapObject(ret);
|
|
301
|
+
},
|
|
302
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
303
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
304
|
+
}, arguments); },
|
|
305
|
+
__wbg_length_ea16607d7b61445b: function(arg0) {
|
|
306
|
+
const ret = getObject(arg0).length;
|
|
307
|
+
return ret;
|
|
308
|
+
},
|
|
309
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
310
|
+
const ret = getObject(arg0).msCrypto;
|
|
311
|
+
return addHeapObject(ret);
|
|
312
|
+
},
|
|
313
|
+
__wbg_new_a70fbab9066b301f: function() {
|
|
314
|
+
const ret = new Array();
|
|
315
|
+
return addHeapObject(ret);
|
|
316
|
+
},
|
|
317
|
+
__wbg_new_ab79df5bd7c26067: function() {
|
|
318
|
+
const ret = new Object();
|
|
319
|
+
return addHeapObject(ret);
|
|
320
|
+
},
|
|
321
|
+
__wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
|
|
322
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
323
|
+
return addHeapObject(ret);
|
|
324
|
+
},
|
|
325
|
+
__wbg_new_with_length_825018a1616e9e55: function(arg0) {
|
|
326
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
327
|
+
return addHeapObject(ret);
|
|
328
|
+
},
|
|
329
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
330
|
+
const ret = getObject(arg0).node;
|
|
331
|
+
return addHeapObject(ret);
|
|
332
|
+
},
|
|
333
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
334
|
+
const ret = getObject(arg0).process;
|
|
335
|
+
return addHeapObject(ret);
|
|
336
|
+
},
|
|
337
|
+
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
338
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
339
|
+
},
|
|
340
|
+
__wbg_push_e87b0e732085a946: function(arg0, arg1) {
|
|
341
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
342
|
+
return ret;
|
|
343
|
+
},
|
|
344
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
345
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
346
|
+
}, arguments); },
|
|
347
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
348
|
+
const ret = module.require;
|
|
349
|
+
return addHeapObject(ret);
|
|
350
|
+
}, arguments); },
|
|
351
|
+
__wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
|
|
352
|
+
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
353
|
+
return ret;
|
|
354
|
+
}, arguments); },
|
|
355
|
+
__wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
|
|
356
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
357
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
358
|
+
},
|
|
359
|
+
__wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
|
|
360
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
361
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
362
|
+
},
|
|
363
|
+
__wbg_static_accessor_SELF_f207c857566db248: function() {
|
|
364
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
365
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
366
|
+
},
|
|
367
|
+
__wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
|
|
368
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
369
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
370
|
+
},
|
|
371
|
+
__wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
|
|
372
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
373
|
+
return addHeapObject(ret);
|
|
374
|
+
},
|
|
375
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
376
|
+
const ret = getObject(arg0).versions;
|
|
377
|
+
return addHeapObject(ret);
|
|
378
|
+
},
|
|
379
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
380
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
381
|
+
const ret = arg0;
|
|
382
|
+
return addHeapObject(ret);
|
|
383
|
+
},
|
|
384
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
385
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
386
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
387
|
+
return addHeapObject(ret);
|
|
388
|
+
},
|
|
389
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
390
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
391
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
392
|
+
return addHeapObject(ret);
|
|
393
|
+
},
|
|
394
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
395
|
+
const ret = getObject(arg0);
|
|
396
|
+
return addHeapObject(ret);
|
|
397
|
+
},
|
|
398
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
399
|
+
takeObject(arg0);
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
return {
|
|
403
|
+
__proto__: null,
|
|
404
|
+
"./citadel_wasm_bg.js": import0,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const CitadelDbFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
409
|
+
? { register: () => {}, unregister: () => {} }
|
|
410
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_citadeldb_free(ptr >>> 0, 1));
|
|
411
|
+
|
|
412
|
+
function addHeapObject(obj) {
|
|
413
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
414
|
+
const idx = heap_next;
|
|
415
|
+
heap_next = heap[idx];
|
|
416
|
+
|
|
417
|
+
heap[idx] = obj;
|
|
418
|
+
return idx;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function dropObject(idx) {
|
|
422
|
+
if (idx < 1028) return;
|
|
423
|
+
heap[idx] = heap_next;
|
|
424
|
+
heap_next = idx;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
428
|
+
ptr = ptr >>> 0;
|
|
429
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
let cachedDataViewMemory0 = null;
|
|
433
|
+
function getDataViewMemory0() {
|
|
434
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
435
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
436
|
+
}
|
|
437
|
+
return cachedDataViewMemory0;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function getStringFromWasm0(ptr, len) {
|
|
441
|
+
ptr = ptr >>> 0;
|
|
442
|
+
return decodeText(ptr, len);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let cachedUint8ArrayMemory0 = null;
|
|
446
|
+
function getUint8ArrayMemory0() {
|
|
447
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
448
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
449
|
+
}
|
|
450
|
+
return cachedUint8ArrayMemory0;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function getObject(idx) { return heap[idx]; }
|
|
454
|
+
|
|
455
|
+
function handleError(f, args) {
|
|
456
|
+
try {
|
|
457
|
+
return f.apply(this, args);
|
|
458
|
+
} catch (e) {
|
|
459
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
let heap = new Array(1024).fill(undefined);
|
|
464
|
+
heap.push(undefined, null, true, false);
|
|
465
|
+
|
|
466
|
+
let heap_next = heap.length;
|
|
467
|
+
|
|
468
|
+
function isLikeNone(x) {
|
|
469
|
+
return x === undefined || x === null;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
473
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
474
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
475
|
+
WASM_VECTOR_LEN = arg.length;
|
|
476
|
+
return ptr;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
480
|
+
if (realloc === undefined) {
|
|
481
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
482
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
483
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
484
|
+
WASM_VECTOR_LEN = buf.length;
|
|
485
|
+
return ptr;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
let len = arg.length;
|
|
489
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
490
|
+
|
|
491
|
+
const mem = getUint8ArrayMemory0();
|
|
492
|
+
|
|
493
|
+
let offset = 0;
|
|
494
|
+
|
|
495
|
+
for (; offset < len; offset++) {
|
|
496
|
+
const code = arg.charCodeAt(offset);
|
|
497
|
+
if (code > 0x7F) break;
|
|
498
|
+
mem[ptr + offset] = code;
|
|
499
|
+
}
|
|
500
|
+
if (offset !== len) {
|
|
501
|
+
if (offset !== 0) {
|
|
502
|
+
arg = arg.slice(offset);
|
|
503
|
+
}
|
|
504
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
505
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
506
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
507
|
+
|
|
508
|
+
offset += ret.written;
|
|
509
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
WASM_VECTOR_LEN = offset;
|
|
513
|
+
return ptr;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function takeObject(idx) {
|
|
517
|
+
const ret = getObject(idx);
|
|
518
|
+
dropObject(idx);
|
|
519
|
+
return ret;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
523
|
+
cachedTextDecoder.decode();
|
|
524
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
525
|
+
let numBytesDecoded = 0;
|
|
526
|
+
function decodeText(ptr, len) {
|
|
527
|
+
numBytesDecoded += len;
|
|
528
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
529
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
530
|
+
cachedTextDecoder.decode();
|
|
531
|
+
numBytesDecoded = len;
|
|
532
|
+
}
|
|
533
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const cachedTextEncoder = new TextEncoder();
|
|
537
|
+
|
|
538
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
539
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
540
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
541
|
+
view.set(buf);
|
|
542
|
+
return {
|
|
543
|
+
read: arg.length,
|
|
544
|
+
written: buf.length
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
let WASM_VECTOR_LEN = 0;
|
|
550
|
+
|
|
551
|
+
let wasmModule, wasm;
|
|
552
|
+
function __wbg_finalize_init(instance, module) {
|
|
553
|
+
wasm = instance.exports;
|
|
554
|
+
wasmModule = module;
|
|
555
|
+
cachedDataViewMemory0 = null;
|
|
556
|
+
cachedUint8ArrayMemory0 = null;
|
|
557
|
+
return wasm;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
async function __wbg_load(module, imports) {
|
|
561
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
562
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
563
|
+
try {
|
|
564
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
565
|
+
} catch (e) {
|
|
566
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
567
|
+
|
|
568
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
569
|
+
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);
|
|
570
|
+
|
|
571
|
+
} else { throw e; }
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const bytes = await module.arrayBuffer();
|
|
576
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
577
|
+
} else {
|
|
578
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
579
|
+
|
|
580
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
581
|
+
return { instance, module };
|
|
582
|
+
} else {
|
|
583
|
+
return instance;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function expectedResponseType(type) {
|
|
588
|
+
switch (type) {
|
|
589
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
590
|
+
}
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function initSync(module) {
|
|
596
|
+
if (wasm !== undefined) return wasm;
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
if (module !== undefined) {
|
|
600
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
601
|
+
({module} = module)
|
|
602
|
+
} else {
|
|
603
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const imports = __wbg_get_imports();
|
|
608
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
609
|
+
module = new WebAssembly.Module(module);
|
|
610
|
+
}
|
|
611
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
612
|
+
return __wbg_finalize_init(instance, module);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
async function __wbg_init(module_or_path) {
|
|
616
|
+
if (wasm !== undefined) return wasm;
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
if (module_or_path !== undefined) {
|
|
620
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
621
|
+
({module_or_path} = module_or_path)
|
|
622
|
+
} else {
|
|
623
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (module_or_path === undefined) {
|
|
628
|
+
module_or_path = new URL('citadel_wasm_bg.wasm', import.meta.url);
|
|
629
|
+
}
|
|
630
|
+
const imports = __wbg_get_imports();
|
|
631
|
+
|
|
632
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
633
|
+
module_or_path = fetch(module_or_path);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
637
|
+
|
|
638
|
+
return __wbg_finalize_init(instance, module);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export { initSync, __wbg_init as default };
|
package/citadel_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
"name": "@citadeldb/wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WASM bindings for Citadel encrypted database",
|
|
5
|
-
"version": "0.2.
|
|
6
|
-
"keywords": ["database", "
|
|
5
|
+
"version": "0.2.4",
|
|
6
|
+
"keywords": ["database", "embedded-database", "encryption", "encrypted-database", "sql", "wasm", "webassembly"],
|
|
7
7
|
"homepage": "https://citadeldb.dev",
|
|
8
|
-
"repository": {"type": "git", "url": "https://github.com/yp3y5akh0v/citadel"},
|
|
8
|
+
"repository": {"type": "git", "url": "git+https://github.com/yp3y5akh0v/citadel.git"},
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"files": [
|
|
11
11
|
"citadel_wasm_bg.wasm",
|
|
12
12
|
"citadel_wasm.js",
|
|
13
|
-
"citadel_wasm_bg.js",
|
|
14
13
|
"citadel_wasm.d.ts",
|
|
15
14
|
"LICENSE-APACHE",
|
|
16
15
|
"LICENSE-MIT"
|
|
@@ -21,4 +20,4 @@
|
|
|
21
20
|
"./citadel_wasm.js",
|
|
22
21
|
"./snippets/*"
|
|
23
22
|
]
|
|
24
|
-
}
|
|
23
|
+
}
|
package/citadel_wasm_bg.js
DELETED
|
@@ -1,542 +0,0 @@
|
|
|
1
|
-
export class CitadelDb {
|
|
2
|
-
__destroy_into_raw() {
|
|
3
|
-
const ptr = this.__wbg_ptr;
|
|
4
|
-
this.__wbg_ptr = 0;
|
|
5
|
-
CitadelDbFinalization.unregister(this);
|
|
6
|
-
return ptr;
|
|
7
|
-
}
|
|
8
|
-
free() {
|
|
9
|
-
const ptr = this.__destroy_into_raw();
|
|
10
|
-
wasm.__wbg_citadeldb_free(ptr, 0);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Delete a key from the default table.
|
|
14
|
-
* Returns true if the key existed.
|
|
15
|
-
* @param {Uint8Array} key
|
|
16
|
-
* @returns {boolean}
|
|
17
|
-
*/
|
|
18
|
-
delete(key) {
|
|
19
|
-
try {
|
|
20
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
21
|
-
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
22
|
-
const len0 = WASM_VECTOR_LEN;
|
|
23
|
-
wasm.citadeldb_delete(retptr, this.__wbg_ptr, ptr0, len0);
|
|
24
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
25
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
26
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
27
|
-
if (r2) {
|
|
28
|
-
throw takeObject(r1);
|
|
29
|
-
}
|
|
30
|
-
return r0 !== 0;
|
|
31
|
-
} finally {
|
|
32
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Execute a SQL statement (DDL or DML).
|
|
37
|
-
* Returns the number of rows affected.
|
|
38
|
-
* @param {string} sql
|
|
39
|
-
* @returns {number}
|
|
40
|
-
*/
|
|
41
|
-
execute(sql) {
|
|
42
|
-
try {
|
|
43
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
44
|
-
const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
45
|
-
const len0 = WASM_VECTOR_LEN;
|
|
46
|
-
wasm.citadeldb_execute(retptr, this.__wbg_ptr, ptr0, len0);
|
|
47
|
-
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
48
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
49
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
50
|
-
if (r3) {
|
|
51
|
-
throw takeObject(r2);
|
|
52
|
-
}
|
|
53
|
-
return r0;
|
|
54
|
-
} finally {
|
|
55
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Execute multiple SQL statements separated by semicolons.
|
|
60
|
-
* @param {string} sql
|
|
61
|
-
*/
|
|
62
|
-
executeBatch(sql) {
|
|
63
|
-
try {
|
|
64
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
65
|
-
const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
66
|
-
const len0 = WASM_VECTOR_LEN;
|
|
67
|
-
wasm.citadeldb_executeBatch(retptr, this.__wbg_ptr, ptr0, len0);
|
|
68
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
69
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
70
|
-
if (r1) {
|
|
71
|
-
throw takeObject(r0);
|
|
72
|
-
}
|
|
73
|
-
} finally {
|
|
74
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get a value by key from the default table.
|
|
79
|
-
* Returns null if not found.
|
|
80
|
-
* @param {Uint8Array} key
|
|
81
|
-
* @returns {any}
|
|
82
|
-
*/
|
|
83
|
-
get(key) {
|
|
84
|
-
try {
|
|
85
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
86
|
-
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
87
|
-
const len0 = WASM_VECTOR_LEN;
|
|
88
|
-
wasm.citadeldb_get(retptr, this.__wbg_ptr, ptr0, len0);
|
|
89
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
90
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
91
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
92
|
-
if (r2) {
|
|
93
|
-
throw takeObject(r1);
|
|
94
|
-
}
|
|
95
|
-
return takeObject(r0);
|
|
96
|
-
} finally {
|
|
97
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Create a new in-memory encrypted database.
|
|
102
|
-
* @param {string} passphrase
|
|
103
|
-
*/
|
|
104
|
-
constructor(passphrase) {
|
|
105
|
-
try {
|
|
106
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
107
|
-
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
108
|
-
const len0 = WASM_VECTOR_LEN;
|
|
109
|
-
wasm.citadeldb_new(retptr, ptr0, len0);
|
|
110
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
111
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
112
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
113
|
-
if (r2) {
|
|
114
|
-
throw takeObject(r1);
|
|
115
|
-
}
|
|
116
|
-
this.__wbg_ptr = r0 >>> 0;
|
|
117
|
-
CitadelDbFinalization.register(this, this.__wbg_ptr, this);
|
|
118
|
-
return this;
|
|
119
|
-
} finally {
|
|
120
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Put a key-value pair into the default table.
|
|
125
|
-
* @param {Uint8Array} key
|
|
126
|
-
* @param {Uint8Array} value
|
|
127
|
-
*/
|
|
128
|
-
put(key, value) {
|
|
129
|
-
try {
|
|
130
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
131
|
-
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
132
|
-
const len0 = WASM_VECTOR_LEN;
|
|
133
|
-
const ptr1 = passArray8ToWasm0(value, wasm.__wbindgen_export2);
|
|
134
|
-
const len1 = WASM_VECTOR_LEN;
|
|
135
|
-
wasm.citadeldb_put(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
136
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
137
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
138
|
-
if (r1) {
|
|
139
|
-
throw takeObject(r0);
|
|
140
|
-
}
|
|
141
|
-
} finally {
|
|
142
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Execute a SQL query and return results as a JS object.
|
|
147
|
-
*
|
|
148
|
-
* Returns `{ columns: string[], rows: any[][] }`.
|
|
149
|
-
* @param {string} sql
|
|
150
|
-
* @returns {any}
|
|
151
|
-
*/
|
|
152
|
-
query(sql) {
|
|
153
|
-
try {
|
|
154
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
155
|
-
const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
156
|
-
const len0 = WASM_VECTOR_LEN;
|
|
157
|
-
wasm.citadeldb_query(retptr, this.__wbg_ptr, ptr0, len0);
|
|
158
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
159
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
160
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
161
|
-
if (r2) {
|
|
162
|
-
throw takeObject(r1);
|
|
163
|
-
}
|
|
164
|
-
return takeObject(r0);
|
|
165
|
-
} finally {
|
|
166
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Get database statistics.
|
|
171
|
-
* Returns `{ entryCount: number, totalPages: number, treeDepth: number }`.
|
|
172
|
-
* @returns {any}
|
|
173
|
-
*/
|
|
174
|
-
stats() {
|
|
175
|
-
try {
|
|
176
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
177
|
-
wasm.citadeldb_stats(retptr, this.__wbg_ptr);
|
|
178
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
179
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
180
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
181
|
-
if (r2) {
|
|
182
|
-
throw takeObject(r1);
|
|
183
|
-
}
|
|
184
|
-
return takeObject(r0);
|
|
185
|
-
} finally {
|
|
186
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Delete a key from a named table.
|
|
191
|
-
* Returns true if the key existed.
|
|
192
|
-
* @param {string} table
|
|
193
|
-
* @param {Uint8Array} key
|
|
194
|
-
* @returns {boolean}
|
|
195
|
-
*/
|
|
196
|
-
tableDelete(table, key) {
|
|
197
|
-
try {
|
|
198
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
199
|
-
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
200
|
-
const len0 = WASM_VECTOR_LEN;
|
|
201
|
-
const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
202
|
-
const len1 = WASM_VECTOR_LEN;
|
|
203
|
-
wasm.citadeldb_tableDelete(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
204
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
205
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
206
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
207
|
-
if (r2) {
|
|
208
|
-
throw takeObject(r1);
|
|
209
|
-
}
|
|
210
|
-
return r0 !== 0;
|
|
211
|
-
} finally {
|
|
212
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Get a value by key from a named table.
|
|
217
|
-
* Returns null if not found.
|
|
218
|
-
* @param {string} table
|
|
219
|
-
* @param {Uint8Array} key
|
|
220
|
-
* @returns {any}
|
|
221
|
-
*/
|
|
222
|
-
tableGet(table, key) {
|
|
223
|
-
try {
|
|
224
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
225
|
-
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
226
|
-
const len0 = WASM_VECTOR_LEN;
|
|
227
|
-
const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
228
|
-
const len1 = WASM_VECTOR_LEN;
|
|
229
|
-
wasm.citadeldb_tableGet(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
230
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
231
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
232
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
233
|
-
if (r2) {
|
|
234
|
-
throw takeObject(r1);
|
|
235
|
-
}
|
|
236
|
-
return takeObject(r0);
|
|
237
|
-
} finally {
|
|
238
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Put a key-value pair into a named table.
|
|
243
|
-
* @param {string} table
|
|
244
|
-
* @param {Uint8Array} key
|
|
245
|
-
* @param {Uint8Array} value
|
|
246
|
-
*/
|
|
247
|
-
tablePut(table, key, value) {
|
|
248
|
-
try {
|
|
249
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
250
|
-
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
251
|
-
const len0 = WASM_VECTOR_LEN;
|
|
252
|
-
const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_export2);
|
|
253
|
-
const len1 = WASM_VECTOR_LEN;
|
|
254
|
-
const ptr2 = passArray8ToWasm0(value, wasm.__wbindgen_export2);
|
|
255
|
-
const len2 = WASM_VECTOR_LEN;
|
|
256
|
-
wasm.citadeldb_tablePut(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
257
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
258
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
259
|
-
if (r1) {
|
|
260
|
-
throw takeObject(r0);
|
|
261
|
-
}
|
|
262
|
-
} finally {
|
|
263
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (Symbol.dispose) CitadelDb.prototype[Symbol.dispose] = CitadelDb.prototype.free;
|
|
268
|
-
export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
|
|
269
|
-
const ret = typeof(getObject(arg0)) === 'function';
|
|
270
|
-
return ret;
|
|
271
|
-
}
|
|
272
|
-
export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
|
|
273
|
-
const val = getObject(arg0);
|
|
274
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
275
|
-
return ret;
|
|
276
|
-
}
|
|
277
|
-
export function __wbg___wbindgen_is_string_7ef6b97b02428fae(arg0) {
|
|
278
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
279
|
-
return ret;
|
|
280
|
-
}
|
|
281
|
-
export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
|
|
282
|
-
const ret = getObject(arg0) === undefined;
|
|
283
|
-
return ret;
|
|
284
|
-
}
|
|
285
|
-
export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
|
|
286
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
287
|
-
}
|
|
288
|
-
export function __wbg_call_2d781c1f4d5c0ef8() { return handleError(function (arg0, arg1, arg2) {
|
|
289
|
-
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
290
|
-
return addHeapObject(ret);
|
|
291
|
-
}, arguments); }
|
|
292
|
-
export function __wbg_crypto_38df2bab126b63dc(arg0) {
|
|
293
|
-
const ret = getObject(arg0).crypto;
|
|
294
|
-
return addHeapObject(ret);
|
|
295
|
-
}
|
|
296
|
-
export function __wbg_getRandomValues_c44a50d8cfdaebeb() { return handleError(function (arg0, arg1) {
|
|
297
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
|
298
|
-
}, arguments); }
|
|
299
|
-
export function __wbg_length_ea16607d7b61445b(arg0) {
|
|
300
|
-
const ret = getObject(arg0).length;
|
|
301
|
-
return ret;
|
|
302
|
-
}
|
|
303
|
-
export function __wbg_msCrypto_bd5a034af96bcba6(arg0) {
|
|
304
|
-
const ret = getObject(arg0).msCrypto;
|
|
305
|
-
return addHeapObject(ret);
|
|
306
|
-
}
|
|
307
|
-
export function __wbg_new_a70fbab9066b301f() {
|
|
308
|
-
const ret = new Array();
|
|
309
|
-
return addHeapObject(ret);
|
|
310
|
-
}
|
|
311
|
-
export function __wbg_new_ab79df5bd7c26067() {
|
|
312
|
-
const ret = new Object();
|
|
313
|
-
return addHeapObject(ret);
|
|
314
|
-
}
|
|
315
|
-
export function __wbg_new_from_slice_22da9388ac046e50(arg0, arg1) {
|
|
316
|
-
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
317
|
-
return addHeapObject(ret);
|
|
318
|
-
}
|
|
319
|
-
export function __wbg_new_with_length_825018a1616e9e55(arg0) {
|
|
320
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
321
|
-
return addHeapObject(ret);
|
|
322
|
-
}
|
|
323
|
-
export function __wbg_node_84ea875411254db1(arg0) {
|
|
324
|
-
const ret = getObject(arg0).node;
|
|
325
|
-
return addHeapObject(ret);
|
|
326
|
-
}
|
|
327
|
-
export function __wbg_process_44c7a14e11e9f69e(arg0) {
|
|
328
|
-
const ret = getObject(arg0).process;
|
|
329
|
-
return addHeapObject(ret);
|
|
330
|
-
}
|
|
331
|
-
export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
|
|
332
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
333
|
-
}
|
|
334
|
-
export function __wbg_push_e87b0e732085a946(arg0, arg1) {
|
|
335
|
-
const ret = getObject(arg0).push(getObject(arg1));
|
|
336
|
-
return ret;
|
|
337
|
-
}
|
|
338
|
-
export function __wbg_randomFillSync_6c25eac9869eb53c() { return handleError(function (arg0, arg1) {
|
|
339
|
-
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
340
|
-
}, arguments); }
|
|
341
|
-
export function __wbg_require_b4edbdcf3e2a1ef0() { return handleError(function () {
|
|
342
|
-
const ret = module.require;
|
|
343
|
-
return addHeapObject(ret);
|
|
344
|
-
}, arguments); }
|
|
345
|
-
export function __wbg_set_7eaa4f96924fd6b3() { return handleError(function (arg0, arg1, arg2) {
|
|
346
|
-
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
347
|
-
return ret;
|
|
348
|
-
}, arguments); }
|
|
349
|
-
export function __wbg_static_accessor_GLOBAL_8adb955bd33fac2f() {
|
|
350
|
-
const ret = typeof global === 'undefined' ? null : global;
|
|
351
|
-
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
352
|
-
}
|
|
353
|
-
export function __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913() {
|
|
354
|
-
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
355
|
-
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
356
|
-
}
|
|
357
|
-
export function __wbg_static_accessor_SELF_f207c857566db248() {
|
|
358
|
-
const ret = typeof self === 'undefined' ? null : self;
|
|
359
|
-
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
360
|
-
}
|
|
361
|
-
export function __wbg_static_accessor_WINDOW_bb9f1ba69d61b386() {
|
|
362
|
-
const ret = typeof window === 'undefined' ? null : window;
|
|
363
|
-
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
364
|
-
}
|
|
365
|
-
export function __wbg_subarray_a068d24e39478a8a(arg0, arg1, arg2) {
|
|
366
|
-
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
367
|
-
return addHeapObject(ret);
|
|
368
|
-
}
|
|
369
|
-
export function __wbg_versions_276b2795b1c6a219(arg0) {
|
|
370
|
-
const ret = getObject(arg0).versions;
|
|
371
|
-
return addHeapObject(ret);
|
|
372
|
-
}
|
|
373
|
-
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
374
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
375
|
-
const ret = arg0;
|
|
376
|
-
return addHeapObject(ret);
|
|
377
|
-
}
|
|
378
|
-
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
379
|
-
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
380
|
-
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
381
|
-
return addHeapObject(ret);
|
|
382
|
-
}
|
|
383
|
-
export function __wbindgen_cast_0000000000000003(arg0, arg1) {
|
|
384
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
385
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
386
|
-
return addHeapObject(ret);
|
|
387
|
-
}
|
|
388
|
-
export function __wbindgen_object_clone_ref(arg0) {
|
|
389
|
-
const ret = getObject(arg0);
|
|
390
|
-
return addHeapObject(ret);
|
|
391
|
-
}
|
|
392
|
-
export function __wbindgen_object_drop_ref(arg0) {
|
|
393
|
-
takeObject(arg0);
|
|
394
|
-
}
|
|
395
|
-
const CitadelDbFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
396
|
-
? { register: () => {}, unregister: () => {} }
|
|
397
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_citadeldb_free(ptr >>> 0, 1));
|
|
398
|
-
|
|
399
|
-
function addHeapObject(obj) {
|
|
400
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
401
|
-
const idx = heap_next;
|
|
402
|
-
heap_next = heap[idx];
|
|
403
|
-
|
|
404
|
-
heap[idx] = obj;
|
|
405
|
-
return idx;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function dropObject(idx) {
|
|
409
|
-
if (idx < 1028) return;
|
|
410
|
-
heap[idx] = heap_next;
|
|
411
|
-
heap_next = idx;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
415
|
-
ptr = ptr >>> 0;
|
|
416
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
let cachedDataViewMemory0 = null;
|
|
420
|
-
function getDataViewMemory0() {
|
|
421
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
422
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
423
|
-
}
|
|
424
|
-
return cachedDataViewMemory0;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
function getStringFromWasm0(ptr, len) {
|
|
428
|
-
ptr = ptr >>> 0;
|
|
429
|
-
return decodeText(ptr, len);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
let cachedUint8ArrayMemory0 = null;
|
|
433
|
-
function getUint8ArrayMemory0() {
|
|
434
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
435
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
436
|
-
}
|
|
437
|
-
return cachedUint8ArrayMemory0;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
function getObject(idx) { return heap[idx]; }
|
|
441
|
-
|
|
442
|
-
function handleError(f, args) {
|
|
443
|
-
try {
|
|
444
|
-
return f.apply(this, args);
|
|
445
|
-
} catch (e) {
|
|
446
|
-
wasm.__wbindgen_export(addHeapObject(e));
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
let heap = new Array(1024).fill(undefined);
|
|
451
|
-
heap.push(undefined, null, true, false);
|
|
452
|
-
|
|
453
|
-
let heap_next = heap.length;
|
|
454
|
-
|
|
455
|
-
function isLikeNone(x) {
|
|
456
|
-
return x === undefined || x === null;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
460
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
461
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
462
|
-
WASM_VECTOR_LEN = arg.length;
|
|
463
|
-
return ptr;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
467
|
-
if (realloc === undefined) {
|
|
468
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
469
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
470
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
471
|
-
WASM_VECTOR_LEN = buf.length;
|
|
472
|
-
return ptr;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
let len = arg.length;
|
|
476
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
477
|
-
|
|
478
|
-
const mem = getUint8ArrayMemory0();
|
|
479
|
-
|
|
480
|
-
let offset = 0;
|
|
481
|
-
|
|
482
|
-
for (; offset < len; offset++) {
|
|
483
|
-
const code = arg.charCodeAt(offset);
|
|
484
|
-
if (code > 0x7F) break;
|
|
485
|
-
mem[ptr + offset] = code;
|
|
486
|
-
}
|
|
487
|
-
if (offset !== len) {
|
|
488
|
-
if (offset !== 0) {
|
|
489
|
-
arg = arg.slice(offset);
|
|
490
|
-
}
|
|
491
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
492
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
493
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
494
|
-
|
|
495
|
-
offset += ret.written;
|
|
496
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
WASM_VECTOR_LEN = offset;
|
|
500
|
-
return ptr;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function takeObject(idx) {
|
|
504
|
-
const ret = getObject(idx);
|
|
505
|
-
dropObject(idx);
|
|
506
|
-
return ret;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
510
|
-
cachedTextDecoder.decode();
|
|
511
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
512
|
-
let numBytesDecoded = 0;
|
|
513
|
-
function decodeText(ptr, len) {
|
|
514
|
-
numBytesDecoded += len;
|
|
515
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
516
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
517
|
-
cachedTextDecoder.decode();
|
|
518
|
-
numBytesDecoded = len;
|
|
519
|
-
}
|
|
520
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
const cachedTextEncoder = new TextEncoder();
|
|
524
|
-
|
|
525
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
526
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
527
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
528
|
-
view.set(buf);
|
|
529
|
-
return {
|
|
530
|
-
read: arg.length,
|
|
531
|
-
written: buf.length
|
|
532
|
-
};
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
let WASM_VECTOR_LEN = 0;
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
let wasm;
|
|
540
|
-
export function __wbg_set_wasm(val) {
|
|
541
|
-
wasm = val;
|
|
542
|
-
}
|