@reifydb/wasm 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.
@@ -0,0 +1,46 @@
1
+ import { WasmDB as WasmDB$1 } from '../wasm/reifydb_webassembly';
2
+ export { TypeValuePair, Value, decode } from '@reifydb/core';
3
+
4
+ /**
5
+ * Recursively transforms raw WASM output into decoded Value instances.
6
+ *
7
+ * The WASM engine returns typed values as `{type, value}` pairs.
8
+ * This function walks the result tree and decodes each pair using `@reifydb/core`'s `decode()`.
9
+ */
10
+ declare function transformToValueInstances(result: unknown): unknown;
11
+ /**
12
+ * High-level wrapper around the raw WASM database engine.
13
+ *
14
+ * Provides typed methods for admin, command, and query operations,
15
+ * automatically decoding WASM type-value pairs into Value instances.
16
+ */
17
+ declare class WasmDB {
18
+ private db;
19
+ constructor(db: WasmDB$1);
20
+ admin(rql: string): unknown;
21
+ adminWithParams(rql: string, params: unknown): unknown;
22
+ command(rql: string): unknown;
23
+ commandWithParams(rql: string, params: unknown): unknown;
24
+ query(rql: string): unknown;
25
+ queryWithParams(rql: string, params: unknown): unknown;
26
+ free(): void;
27
+ }
28
+ /**
29
+ * Creates a new WasmDB instance by dynamically importing the WASM module.
30
+ *
31
+ * The dynamic import ensures the WASM glue code is not bundled by tsup
32
+ * and is instead resolved by the consumer's bundler (Vite, webpack, etc.).
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * import { createWasmDB } from '@reifydb/wasm';
37
+ *
38
+ * const db = await createWasmDB();
39
+ * db.admin('CREATE NAMESPACE demo');
40
+ * const results = db.query('FROM demo.users');
41
+ * db.free();
42
+ * ```
43
+ */
44
+ declare function createWasmDB(): Promise<WasmDB>;
45
+
46
+ export { WasmDB, createWasmDB, transformToValueInstances };
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ // src/index.ts
2
+ import { decode } from "@reifydb/core";
3
+ import { decode as decode2 } from "@reifydb/core";
4
+ function transformToValueInstances(result) {
5
+ if (result === null || result === void 0) return result;
6
+ if (typeof result !== "object") return result;
7
+ if (Array.isArray(result)) {
8
+ return result.map(transformToValueInstances);
9
+ }
10
+ const obj = result;
11
+ if ("type" in obj && "value" in obj && Object.keys(obj).length === 2) {
12
+ return decode(obj);
13
+ }
14
+ const transformed = {};
15
+ for (const [key, value] of Object.entries(obj)) {
16
+ transformed[key] = transformToValueInstances(value);
17
+ }
18
+ return transformed;
19
+ }
20
+ var WasmDB = class {
21
+ db;
22
+ constructor(db) {
23
+ this.db = db;
24
+ }
25
+ admin(rql) {
26
+ return transformToValueInstances(this.db.admin(rql));
27
+ }
28
+ adminWithParams(rql, params) {
29
+ return transformToValueInstances(this.db.adminWithParams(rql, params));
30
+ }
31
+ command(rql) {
32
+ return transformToValueInstances(this.db.command(rql));
33
+ }
34
+ commandWithParams(rql, params) {
35
+ return transformToValueInstances(this.db.commandWithParams(rql, params));
36
+ }
37
+ query(rql) {
38
+ return transformToValueInstances(this.db.query(rql));
39
+ }
40
+ queryWithParams(rql, params) {
41
+ return transformToValueInstances(this.db.queryWithParams(rql, params));
42
+ }
43
+ free() {
44
+ this.db.free();
45
+ }
46
+ };
47
+ async function createWasmDB() {
48
+ const mod = await import("../wasm/reifydb_webassembly.js");
49
+ return new WasmDB(new mod.WasmDB());
50
+ }
51
+ export {
52
+ WasmDB,
53
+ createWasmDB,
54
+ decode2 as decode,
55
+ transformToValueInstances
56
+ };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (c) 2025 ReifyDB\n\nimport { decode, type TypeValuePair } from '@reifydb/core';\nimport type { WasmDB as RawWasmDB } from '../wasm/reifydb_webassembly';\n\nexport { decode } from '@reifydb/core';\nexport type { TypeValuePair, Value } from '@reifydb/core';\n\n/**\n * Recursively transforms raw WASM output into decoded Value instances.\n *\n * The WASM engine returns typed values as `{type, value}` pairs.\n * This function walks the result tree and decodes each pair using `@reifydb/core`'s `decode()`.\n */\nexport function transformToValueInstances(result: unknown): unknown {\n if (result === null || result === undefined) return result;\n if (typeof result !== 'object') return result;\n if (Array.isArray(result)) {\n return result.map(transformToValueInstances);\n }\n const obj = result as Record<string, unknown>;\n if ('type' in obj && 'value' in obj && Object.keys(obj).length === 2) {\n return decode(obj as unknown as TypeValuePair);\n }\n const transformed: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n transformed[key] = transformToValueInstances(value);\n }\n return transformed;\n}\n\n/**\n * High-level wrapper around the raw WASM database engine.\n *\n * Provides typed methods for admin, command, and query operations,\n * automatically decoding WASM type-value pairs into Value instances.\n */\nexport class WasmDB {\n private db: RawWasmDB;\n\n constructor(db: RawWasmDB) {\n this.db = db;\n }\n\n admin(rql: string): unknown {\n return transformToValueInstances(this.db.admin(rql));\n }\n\n adminWithParams(rql: string, params: unknown): unknown {\n return transformToValueInstances(this.db.adminWithParams(rql, params));\n }\n\n command(rql: string): unknown {\n return transformToValueInstances(this.db.command(rql));\n }\n\n commandWithParams(rql: string, params: unknown): unknown {\n return transformToValueInstances(this.db.commandWithParams(rql, params));\n }\n\n query(rql: string): unknown {\n return transformToValueInstances(this.db.query(rql));\n }\n\n queryWithParams(rql: string, params: unknown): unknown {\n return transformToValueInstances(this.db.queryWithParams(rql, params));\n }\n\n free(): void {\n this.db.free();\n }\n}\n\n/**\n * Creates a new WasmDB instance by dynamically importing the WASM module.\n *\n * The dynamic import ensures the WASM glue code is not bundled by tsup\n * and is instead resolved by the consumer's bundler (Vite, webpack, etc.).\n *\n * @example\n * ```typescript\n * import { createWasmDB } from '@reifydb/wasm';\n *\n * const db = await createWasmDB();\n * db.admin('CREATE NAMESPACE demo');\n * const results = db.query('FROM demo.users');\n * db.free();\n * ```\n */\nexport async function createWasmDB(): Promise<WasmDB> {\n const mod = await import('../wasm/reifydb_webassembly.js');\n return new WasmDB(new mod.WasmDB());\n}\n"],"mappings":";AAGA,SAAS,cAAkC;AAG3C,SAAS,UAAAA,eAAc;AAShB,SAAS,0BAA0B,QAA0B;AAClE,MAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AACpD,MAAI,OAAO,WAAW,SAAU,QAAO;AACvC,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,WAAO,OAAO,IAAI,yBAAyB;AAAA,EAC7C;AACA,QAAM,MAAM;AACZ,MAAI,UAAU,OAAO,WAAW,OAAO,OAAO,KAAK,GAAG,EAAE,WAAW,GAAG;AACpE,WAAO,OAAO,GAA+B;AAAA,EAC/C;AACA,QAAM,cAAuC,CAAC;AAC9C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,gBAAY,GAAG,IAAI,0BAA0B,KAAK;AAAA,EACpD;AACA,SAAO;AACT;AAQO,IAAM,SAAN,MAAa;AAAA,EACV;AAAA,EAER,YAAY,IAAe;AACzB,SAAK,KAAK;AAAA,EACZ;AAAA,EAEA,MAAM,KAAsB;AAC1B,WAAO,0BAA0B,KAAK,GAAG,MAAM,GAAG,CAAC;AAAA,EACrD;AAAA,EAEA,gBAAgB,KAAa,QAA0B;AACrD,WAAO,0BAA0B,KAAK,GAAG,gBAAgB,KAAK,MAAM,CAAC;AAAA,EACvE;AAAA,EAEA,QAAQ,KAAsB;AAC5B,WAAO,0BAA0B,KAAK,GAAG,QAAQ,GAAG,CAAC;AAAA,EACvD;AAAA,EAEA,kBAAkB,KAAa,QAA0B;AACvD,WAAO,0BAA0B,KAAK,GAAG,kBAAkB,KAAK,MAAM,CAAC;AAAA,EACzE;AAAA,EAEA,MAAM,KAAsB;AAC1B,WAAO,0BAA0B,KAAK,GAAG,MAAM,GAAG,CAAC;AAAA,EACrD;AAAA,EAEA,gBAAgB,KAAa,QAA0B;AACrD,WAAO,0BAA0B,KAAK,GAAG,gBAAgB,KAAK,MAAM,CAAC;AAAA,EACvE;AAAA,EAEA,OAAa;AACX,SAAK,GAAG,KAAK;AAAA,EACf;AACF;AAkBA,eAAsB,eAAgC;AACpD,QAAM,MAAM,MAAM,OAAO,gCAAgC;AACzD,SAAO,IAAI,OAAO,IAAI,IAAI,OAAO,CAAC;AACpC;","names":["decode"]}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@reifydb/wasm",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "dependencies": {
8
+ "@reifydb/core": "0.3.0"
9
+ },
10
+ "devDependencies": {
11
+ "@types/node": "^24.0.10",
12
+ "tsup": "^8.5.0",
13
+ "typescript": "^5.8.3",
14
+ "vitest": "^2.1.8"
15
+ },
16
+ "engines": {
17
+ "node": ">=16.0.0"
18
+ },
19
+ "keywords": [
20
+ "reifydb",
21
+ "database",
22
+ "wasm",
23
+ "webassembly",
24
+ "typescript"
25
+ ],
26
+ "files": [
27
+ "dist/",
28
+ "wasm/",
29
+ "package.json"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "license": "AGPL-3.0-or-later",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/reifydb/reifydb.git",
38
+ "directory": "pkg/typescript/wasm"
39
+ },
40
+ "homepage": "https://github.com/reifydb/reifydb#readme",
41
+ "bugs": {
42
+ "url": "https://github.com/reifydb/reifydb/issues"
43
+ },
44
+ "scripts": {
45
+ "copy-wasm": "cp -r ../../webassembly/dist/bundler/ wasm/",
46
+ "prebuild": "pnpm copy-wasm",
47
+ "build": "tsup src/index.ts --dts --format esm --sourcemap",
48
+ "test": "pnpm test:unit",
49
+ "test:unit": "vitest run --config vitest.config.ts",
50
+ "test:unit:watch": "vitest --config vitest.config.ts",
51
+ "publish:npm": "pnpm publish --access public"
52
+ }
53
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "reifydb-webassembly",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Dominique Chuo <dominique@reifydb.com>"
6
+ ],
7
+ "description": "WebAssembly bindings for ReifyDB query engine",
8
+ "version": "0.3.0",
9
+ "license": "AGPL-3.0-or-later",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/reifydb/reifydb"
13
+ },
14
+ "files": [
15
+ "reifydb_webassembly_bg.wasm",
16
+ "reifydb_webassembly.js",
17
+ "reifydb_webassembly_bg.js",
18
+ "reifydb_webassembly.d.ts"
19
+ ],
20
+ "main": "reifydb_webassembly.js",
21
+ "types": "reifydb_webassembly.d.ts",
22
+ "sideEffects": [
23
+ "./reifydb_webassembly.js",
24
+ "./snippets/*"
25
+ ]
26
+ }
@@ -0,0 +1,99 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * JavaScript-compatible error wrapper
6
+ */
7
+ export class JsError {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * Get the error message
13
+ */
14
+ readonly message: string;
15
+ }
16
+
17
+ /**
18
+ * WebAssembly ReifyDB Engine
19
+ *
20
+ * Provides an in-memory query engine that runs entirely in the browser.
21
+ * All data is stored in memory and lost when the page is closed.
22
+ */
23
+ export class WasmDB {
24
+ free(): void;
25
+ [Symbol.dispose](): void;
26
+ /**
27
+ * Execute an admin operation (DDL + DML + Query) and return results
28
+ *
29
+ * Admin operations include CREATE, ALTER, INSERT, UPDATE, DELETE, etc.
30
+ *
31
+ * # Example
32
+ *
33
+ * ```javascript
34
+ * await db.admin("CREATE NAMESPACE demo");
35
+ * await db.admin(`
36
+ * CREATE TABLE demo.users {
37
+ * id: int4,
38
+ * name: utf8
39
+ * }
40
+ * `);
41
+ * ```
42
+ */
43
+ admin(rql: string): any;
44
+ /**
45
+ * Execute admin with JSON parameters
46
+ */
47
+ adminWithParams(rql: string, params_js: any): any;
48
+ /**
49
+ * Execute a command (DML) and return results
50
+ *
51
+ * Commands include INSERT, UPDATE, DELETE, etc.
52
+ * For DDL operations (CREATE, ALTER), use `admin()` instead.
53
+ */
54
+ command(rql: string): any;
55
+ /**
56
+ * Execute command with JSON parameters
57
+ */
58
+ commandWithParams(rql: string, params_js: any): any;
59
+ /**
60
+ * Create a new in-memory ReifyDB engine
61
+ *
62
+ * # Example
63
+ *
64
+ * ```javascript
65
+ * import init, { WasmDB } from './pkg/reifydb_engine_wasm.js';
66
+ *
67
+ * await init();
68
+ * const db = new WasmDB();
69
+ * ```
70
+ */
71
+ constructor();
72
+ /**
73
+ * Execute a query and return results as JavaScript objects
74
+ *
75
+ * # Example
76
+ *
77
+ * ```javascript
78
+ * const results = await db.query(`
79
+ * FROM [{ name: "Alice", age: 30 }]
80
+ * FILTER age > 25
81
+ * `);
82
+ * console.log(results); // [{ name: "Alice", age: 30 }]
83
+ * ```
84
+ */
85
+ query(rql: string): any;
86
+ /**
87
+ * Execute query with JSON parameters
88
+ *
89
+ * # Example
90
+ *
91
+ * ```javascript
92
+ * const results = await db.queryWithParams(
93
+ * "FROM users FILTER age > $min_age",
94
+ * { min_age: 25 }
95
+ * );
96
+ * ```
97
+ */
98
+ queryWithParams(rql: string, params_js: any): any;
99
+ }
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./reifydb_webassembly.d.ts" */
2
+
3
+ import * as wasm from "./reifydb_webassembly_bg.wasm";
4
+ import { __wbg_set_wasm } from "./reifydb_webassembly_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ JsError, WasmDB
9
+ } from "./reifydb_webassembly_bg.js";
@@ -0,0 +1,591 @@
1
+ /**
2
+ * JavaScript-compatible error wrapper
3
+ */
4
+ export class JsError {
5
+ __destroy_into_raw() {
6
+ const ptr = this.__wbg_ptr;
7
+ this.__wbg_ptr = 0;
8
+ JsErrorFinalization.unregister(this);
9
+ return ptr;
10
+ }
11
+ free() {
12
+ const ptr = this.__destroy_into_raw();
13
+ wasm.__wbg_jserror_free(ptr, 0);
14
+ }
15
+ /**
16
+ * Get the error message
17
+ * @returns {string}
18
+ */
19
+ get message() {
20
+ let deferred1_0;
21
+ let deferred1_1;
22
+ try {
23
+ const ret = wasm.jserror_message(this.__wbg_ptr);
24
+ deferred1_0 = ret[0];
25
+ deferred1_1 = ret[1];
26
+ return getStringFromWasm0(ret[0], ret[1]);
27
+ } finally {
28
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
29
+ }
30
+ }
31
+ }
32
+ if (Symbol.dispose) JsError.prototype[Symbol.dispose] = JsError.prototype.free;
33
+
34
+ /**
35
+ * WebAssembly ReifyDB Engine
36
+ *
37
+ * Provides an in-memory query engine that runs entirely in the browser.
38
+ * All data is stored in memory and lost when the page is closed.
39
+ */
40
+ export class WasmDB {
41
+ __destroy_into_raw() {
42
+ const ptr = this.__wbg_ptr;
43
+ this.__wbg_ptr = 0;
44
+ WasmDBFinalization.unregister(this);
45
+ return ptr;
46
+ }
47
+ free() {
48
+ const ptr = this.__destroy_into_raw();
49
+ wasm.__wbg_wasmdb_free(ptr, 0);
50
+ }
51
+ /**
52
+ * Execute an admin operation (DDL + DML + Query) and return results
53
+ *
54
+ * Admin operations include CREATE, ALTER, INSERT, UPDATE, DELETE, etc.
55
+ *
56
+ * # Example
57
+ *
58
+ * ```javascript
59
+ * await db.admin("CREATE NAMESPACE demo");
60
+ * await db.admin(`
61
+ * CREATE TABLE demo.users {
62
+ * id: int4,
63
+ * name: utf8
64
+ * }
65
+ * `);
66
+ * ```
67
+ * @param {string} rql
68
+ * @returns {any}
69
+ */
70
+ admin(rql) {
71
+ const ptr0 = passStringToWasm0(rql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ret = wasm.wasmdb_admin(this.__wbg_ptr, ptr0, len0);
74
+ if (ret[2]) {
75
+ throw takeFromExternrefTable0(ret[1]);
76
+ }
77
+ return takeFromExternrefTable0(ret[0]);
78
+ }
79
+ /**
80
+ * Execute admin with JSON parameters
81
+ * @param {string} rql
82
+ * @param {any} params_js
83
+ * @returns {any}
84
+ */
85
+ adminWithParams(rql, params_js) {
86
+ const ptr0 = passStringToWasm0(rql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
87
+ const len0 = WASM_VECTOR_LEN;
88
+ const ret = wasm.wasmdb_adminWithParams(this.__wbg_ptr, ptr0, len0, params_js);
89
+ if (ret[2]) {
90
+ throw takeFromExternrefTable0(ret[1]);
91
+ }
92
+ return takeFromExternrefTable0(ret[0]);
93
+ }
94
+ /**
95
+ * Execute a command (DML) and return results
96
+ *
97
+ * Commands include INSERT, UPDATE, DELETE, etc.
98
+ * For DDL operations (CREATE, ALTER), use `admin()` instead.
99
+ * @param {string} rql
100
+ * @returns {any}
101
+ */
102
+ command(rql) {
103
+ const ptr0 = passStringToWasm0(rql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ const ret = wasm.wasmdb_command(this.__wbg_ptr, ptr0, len0);
106
+ if (ret[2]) {
107
+ throw takeFromExternrefTable0(ret[1]);
108
+ }
109
+ return takeFromExternrefTable0(ret[0]);
110
+ }
111
+ /**
112
+ * Execute command with JSON parameters
113
+ * @param {string} rql
114
+ * @param {any} params_js
115
+ * @returns {any}
116
+ */
117
+ commandWithParams(rql, params_js) {
118
+ const ptr0 = passStringToWasm0(rql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119
+ const len0 = WASM_VECTOR_LEN;
120
+ const ret = wasm.wasmdb_commandWithParams(this.__wbg_ptr, ptr0, len0, params_js);
121
+ if (ret[2]) {
122
+ throw takeFromExternrefTable0(ret[1]);
123
+ }
124
+ return takeFromExternrefTable0(ret[0]);
125
+ }
126
+ /**
127
+ * Create a new in-memory ReifyDB engine
128
+ *
129
+ * # Example
130
+ *
131
+ * ```javascript
132
+ * import init, { WasmDB } from './pkg/reifydb_engine_wasm.js';
133
+ *
134
+ * await init();
135
+ * const db = new WasmDB();
136
+ * ```
137
+ */
138
+ constructor() {
139
+ const ret = wasm.wasmdb_new();
140
+ if (ret[2]) {
141
+ throw takeFromExternrefTable0(ret[1]);
142
+ }
143
+ this.__wbg_ptr = ret[0] >>> 0;
144
+ WasmDBFinalization.register(this, this.__wbg_ptr, this);
145
+ return this;
146
+ }
147
+ /**
148
+ * Execute a query and return results as JavaScript objects
149
+ *
150
+ * # Example
151
+ *
152
+ * ```javascript
153
+ * const results = await db.query(`
154
+ * FROM [{ name: "Alice", age: 30 }]
155
+ * FILTER age > 25
156
+ * `);
157
+ * console.log(results); // [{ name: "Alice", age: 30 }]
158
+ * ```
159
+ * @param {string} rql
160
+ * @returns {any}
161
+ */
162
+ query(rql) {
163
+ const ptr0 = passStringToWasm0(rql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
164
+ const len0 = WASM_VECTOR_LEN;
165
+ const ret = wasm.wasmdb_query(this.__wbg_ptr, ptr0, len0);
166
+ if (ret[2]) {
167
+ throw takeFromExternrefTable0(ret[1]);
168
+ }
169
+ return takeFromExternrefTable0(ret[0]);
170
+ }
171
+ /**
172
+ * Execute query with JSON parameters
173
+ *
174
+ * # Example
175
+ *
176
+ * ```javascript
177
+ * const results = await db.queryWithParams(
178
+ * "FROM users FILTER age > $min_age",
179
+ * { min_age: 25 }
180
+ * );
181
+ * ```
182
+ * @param {string} rql
183
+ * @param {any} params_js
184
+ * @returns {any}
185
+ */
186
+ queryWithParams(rql, params_js) {
187
+ const ptr0 = passStringToWasm0(rql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
188
+ const len0 = WASM_VECTOR_LEN;
189
+ const ret = wasm.wasmdb_queryWithParams(this.__wbg_ptr, ptr0, len0, params_js);
190
+ if (ret[2]) {
191
+ throw takeFromExternrefTable0(ret[1]);
192
+ }
193
+ return takeFromExternrefTable0(ret[0]);
194
+ }
195
+ }
196
+ if (Symbol.dispose) WasmDB.prototype[Symbol.dispose] = WasmDB.prototype.free;
197
+ export function __wbg___wbindgen_debug_string_0bc8482c6e3508ae(arg0, arg1) {
198
+ const ret = debugString(arg1);
199
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
200
+ const len1 = WASM_VECTOR_LEN;
201
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
202
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
203
+ }
204
+ export function __wbg___wbindgen_is_null_ac34f5003991759a(arg0) {
205
+ const ret = arg0 === null;
206
+ return ret;
207
+ }
208
+ export function __wbg___wbindgen_is_undefined_9e4d92534c42d778(arg0) {
209
+ const ret = arg0 === undefined;
210
+ return ret;
211
+ }
212
+ export function __wbg___wbindgen_string_get_72fb696202c56729(arg0, arg1) {
213
+ const obj = arg1;
214
+ const ret = typeof(obj) === 'string' ? obj : undefined;
215
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
216
+ var len1 = WASM_VECTOR_LEN;
217
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
218
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
219
+ }
220
+ export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
221
+ throw new Error(getStringFromWasm0(arg0, arg1));
222
+ }
223
+ export function __wbg_call_389efe28435a9388() { return handleError(function (arg0, arg1) {
224
+ const ret = arg0.call(arg1);
225
+ return ret;
226
+ }, arguments); }
227
+ export function __wbg_clearInterval_c75df0651e74fbb8(arg0, arg1) {
228
+ arg0.clearInterval(arg1);
229
+ }
230
+ export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
231
+ let deferred0_0;
232
+ let deferred0_1;
233
+ try {
234
+ deferred0_0 = arg0;
235
+ deferred0_1 = arg1;
236
+ console.error(getStringFromWasm0(arg0, arg1));
237
+ } finally {
238
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
239
+ }
240
+ }
241
+ export function __wbg_getRandomValues_2a91986308c74a93() { return handleError(function (arg0, arg1) {
242
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
243
+ }, arguments); }
244
+ export function __wbg_getRandomValues_9b655bdd369112f2() { return handleError(function (arg0, arg1) {
245
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
246
+ }, arguments); }
247
+ export function __wbg_instanceof_Window_ed49b2db8df90359(arg0) {
248
+ let result;
249
+ try {
250
+ result = arg0 instanceof Window;
251
+ } catch (_) {
252
+ result = false;
253
+ }
254
+ const ret = result;
255
+ return ret;
256
+ }
257
+ export function __wbg_length_32ed9a279acd054c(arg0) {
258
+ const ret = arg0.length;
259
+ return ret;
260
+ }
261
+ export function __wbg_log_6b5ca2e6124b2808(arg0) {
262
+ console.log(arg0);
263
+ }
264
+ export function __wbg_new_361308b2356cecd0() {
265
+ const ret = new Object();
266
+ return ret;
267
+ }
268
+ export function __wbg_new_3eb36ae241fe6f44() {
269
+ const ret = new Array();
270
+ return ret;
271
+ }
272
+ export function __wbg_new_8a6f238a6ece86ea() {
273
+ const ret = new Error();
274
+ return ret;
275
+ }
276
+ export function __wbg_new_no_args_1c7c842f08d00ebb(arg0, arg1) {
277
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
278
+ return ret;
279
+ }
280
+ export function __wbg_new_with_length_a2c39cbe88fd8ff1(arg0) {
281
+ const ret = new Uint8Array(arg0 >>> 0);
282
+ return ret;
283
+ }
284
+ export function __wbg_now_37839916ec63896b() { return handleError(function () {
285
+ const ret = Date.now();
286
+ return ret;
287
+ }, arguments); }
288
+ export function __wbg_now_a3af9a2f4bbaa4d1() {
289
+ const ret = Date.now();
290
+ return ret;
291
+ }
292
+ export function __wbg_push_8ffdcb2063340ba5(arg0, arg1) {
293
+ const ret = arg0.push(arg1);
294
+ return ret;
295
+ }
296
+ export function __wbg_setInterval_612728cce80dfecf() { return handleError(function (arg0, arg1, arg2) {
297
+ const ret = arg0.setInterval(arg1, arg2);
298
+ return ret;
299
+ }, arguments); }
300
+ export function __wbg_setTimeout_eff32631ea138533() { return handleError(function (arg0, arg1, arg2) {
301
+ const ret = arg0.setTimeout(arg1, arg2);
302
+ return ret;
303
+ }, arguments); }
304
+ export function __wbg_set_6cb8631f80447a67() { return handleError(function (arg0, arg1, arg2) {
305
+ const ret = Reflect.set(arg0, arg1, arg2);
306
+ return ret;
307
+ }, arguments); }
308
+ export function __wbg_set_cc56eefd2dd91957(arg0, arg1, arg2) {
309
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
310
+ }
311
+ export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
312
+ const ret = arg1.stack;
313
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
314
+ const len1 = WASM_VECTOR_LEN;
315
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
316
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
317
+ }
318
+ export function __wbg_static_accessor_GLOBAL_12837167ad935116() {
319
+ const ret = typeof global === 'undefined' ? null : global;
320
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
321
+ }
322
+ export function __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f() {
323
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
324
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
325
+ }
326
+ export function __wbg_static_accessor_SELF_a621d3dfbb60d0ce() {
327
+ const ret = typeof self === 'undefined' ? null : self;
328
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
329
+ }
330
+ export function __wbg_static_accessor_WINDOW_f8727f0cf888e0bd() {
331
+ const ret = typeof window === 'undefined' ? null : window;
332
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
333
+ }
334
+ export function __wbg_stringify_8d1cc6ff383e8bae() { return handleError(function (arg0) {
335
+ const ret = JSON.stringify(arg0);
336
+ return ret;
337
+ }, arguments); }
338
+ export function __wbindgen_cast_0000000000000001(arg0, arg1) {
339
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3180, function: Function { arguments: [], shim_idx: 3181, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
340
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hb496c74d4b5d2fe7, wasm_bindgen__convert__closures_____invoke__hb278d5bbbfdc8d45);
341
+ return ret;
342
+ }
343
+ export function __wbindgen_cast_0000000000000002(arg0) {
344
+ // Cast intrinsic for `F64 -> Externref`.
345
+ const ret = arg0;
346
+ return ret;
347
+ }
348
+ export function __wbindgen_cast_0000000000000003(arg0, arg1) {
349
+ // Cast intrinsic for `Ref(String) -> Externref`.
350
+ const ret = getStringFromWasm0(arg0, arg1);
351
+ return ret;
352
+ }
353
+ export function __wbindgen_init_externref_table() {
354
+ const table = wasm.__wbindgen_externrefs;
355
+ const offset = table.grow(4);
356
+ table.set(0, undefined);
357
+ table.set(offset + 0, undefined);
358
+ table.set(offset + 1, null);
359
+ table.set(offset + 2, true);
360
+ table.set(offset + 3, false);
361
+ }
362
+ function wasm_bindgen__convert__closures_____invoke__hb278d5bbbfdc8d45(arg0, arg1) {
363
+ wasm.wasm_bindgen__convert__closures_____invoke__hb278d5bbbfdc8d45(arg0, arg1);
364
+ }
365
+
366
+ const JsErrorFinalization = (typeof FinalizationRegistry === 'undefined')
367
+ ? { register: () => {}, unregister: () => {} }
368
+ : new FinalizationRegistry(ptr => wasm.__wbg_jserror_free(ptr >>> 0, 1));
369
+ const WasmDBFinalization = (typeof FinalizationRegistry === 'undefined')
370
+ ? { register: () => {}, unregister: () => {} }
371
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmdb_free(ptr >>> 0, 1));
372
+
373
+ function addToExternrefTable0(obj) {
374
+ const idx = wasm.__externref_table_alloc();
375
+ wasm.__wbindgen_externrefs.set(idx, obj);
376
+ return idx;
377
+ }
378
+
379
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
380
+ ? { register: () => {}, unregister: () => {} }
381
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
382
+
383
+ function debugString(val) {
384
+ // primitive types
385
+ const type = typeof val;
386
+ if (type == 'number' || type == 'boolean' || val == null) {
387
+ return `${val}`;
388
+ }
389
+ if (type == 'string') {
390
+ return `"${val}"`;
391
+ }
392
+ if (type == 'symbol') {
393
+ const description = val.description;
394
+ if (description == null) {
395
+ return 'Symbol';
396
+ } else {
397
+ return `Symbol(${description})`;
398
+ }
399
+ }
400
+ if (type == 'function') {
401
+ const name = val.name;
402
+ if (typeof name == 'string' && name.length > 0) {
403
+ return `Function(${name})`;
404
+ } else {
405
+ return 'Function';
406
+ }
407
+ }
408
+ // objects
409
+ if (Array.isArray(val)) {
410
+ const length = val.length;
411
+ let debug = '[';
412
+ if (length > 0) {
413
+ debug += debugString(val[0]);
414
+ }
415
+ for(let i = 1; i < length; i++) {
416
+ debug += ', ' + debugString(val[i]);
417
+ }
418
+ debug += ']';
419
+ return debug;
420
+ }
421
+ // Test for built-in
422
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
423
+ let className;
424
+ if (builtInMatches && builtInMatches.length > 1) {
425
+ className = builtInMatches[1];
426
+ } else {
427
+ // Failed to match the standard '[object ClassName]'
428
+ return toString.call(val);
429
+ }
430
+ if (className == 'Object') {
431
+ // we're a user defined class or Object
432
+ // JSON.stringify avoids problems with cycles, and is generally much
433
+ // easier than looping through ownProperties of `val`.
434
+ try {
435
+ return 'Object(' + JSON.stringify(val) + ')';
436
+ } catch (_) {
437
+ return 'Object';
438
+ }
439
+ }
440
+ // errors
441
+ if (val instanceof Error) {
442
+ return `${val.name}: ${val.message}\n${val.stack}`;
443
+ }
444
+ // TODO we could test for more things here, like `Set`s and `Map`s.
445
+ return className;
446
+ }
447
+
448
+ function getArrayU8FromWasm0(ptr, len) {
449
+ ptr = ptr >>> 0;
450
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
451
+ }
452
+
453
+ let cachedDataViewMemory0 = null;
454
+ function getDataViewMemory0() {
455
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
456
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
457
+ }
458
+ return cachedDataViewMemory0;
459
+ }
460
+
461
+ function getStringFromWasm0(ptr, len) {
462
+ ptr = ptr >>> 0;
463
+ return decodeText(ptr, len);
464
+ }
465
+
466
+ let cachedUint8ArrayMemory0 = null;
467
+ function getUint8ArrayMemory0() {
468
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
469
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
470
+ }
471
+ return cachedUint8ArrayMemory0;
472
+ }
473
+
474
+ function handleError(f, args) {
475
+ try {
476
+ return f.apply(this, args);
477
+ } catch (e) {
478
+ const idx = addToExternrefTable0(e);
479
+ wasm.__wbindgen_exn_store(idx);
480
+ }
481
+ }
482
+
483
+ function isLikeNone(x) {
484
+ return x === undefined || x === null;
485
+ }
486
+
487
+ function makeMutClosure(arg0, arg1, dtor, f) {
488
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
489
+ const real = (...args) => {
490
+
491
+ // First up with a closure we increment the internal reference
492
+ // count. This ensures that the Rust closure environment won't
493
+ // be deallocated while we're invoking it.
494
+ state.cnt++;
495
+ const a = state.a;
496
+ state.a = 0;
497
+ try {
498
+ return f(a, state.b, ...args);
499
+ } finally {
500
+ state.a = a;
501
+ real._wbg_cb_unref();
502
+ }
503
+ };
504
+ real._wbg_cb_unref = () => {
505
+ if (--state.cnt === 0) {
506
+ state.dtor(state.a, state.b);
507
+ state.a = 0;
508
+ CLOSURE_DTORS.unregister(state);
509
+ }
510
+ };
511
+ CLOSURE_DTORS.register(real, state, state);
512
+ return real;
513
+ }
514
+
515
+ function passStringToWasm0(arg, malloc, realloc) {
516
+ if (realloc === undefined) {
517
+ const buf = cachedTextEncoder.encode(arg);
518
+ const ptr = malloc(buf.length, 1) >>> 0;
519
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
520
+ WASM_VECTOR_LEN = buf.length;
521
+ return ptr;
522
+ }
523
+
524
+ let len = arg.length;
525
+ let ptr = malloc(len, 1) >>> 0;
526
+
527
+ const mem = getUint8ArrayMemory0();
528
+
529
+ let offset = 0;
530
+
531
+ for (; offset < len; offset++) {
532
+ const code = arg.charCodeAt(offset);
533
+ if (code > 0x7F) break;
534
+ mem[ptr + offset] = code;
535
+ }
536
+ if (offset !== len) {
537
+ if (offset !== 0) {
538
+ arg = arg.slice(offset);
539
+ }
540
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
541
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
542
+ const ret = cachedTextEncoder.encodeInto(arg, view);
543
+
544
+ offset += ret.written;
545
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
546
+ }
547
+
548
+ WASM_VECTOR_LEN = offset;
549
+ return ptr;
550
+ }
551
+
552
+ function takeFromExternrefTable0(idx) {
553
+ const value = wasm.__wbindgen_externrefs.get(idx);
554
+ wasm.__externref_table_dealloc(idx);
555
+ return value;
556
+ }
557
+
558
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
559
+ cachedTextDecoder.decode();
560
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
561
+ let numBytesDecoded = 0;
562
+ function decodeText(ptr, len) {
563
+ numBytesDecoded += len;
564
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
565
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
566
+ cachedTextDecoder.decode();
567
+ numBytesDecoded = len;
568
+ }
569
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
570
+ }
571
+
572
+ const cachedTextEncoder = new TextEncoder();
573
+
574
+ if (!('encodeInto' in cachedTextEncoder)) {
575
+ cachedTextEncoder.encodeInto = function (arg, view) {
576
+ const buf = cachedTextEncoder.encode(arg);
577
+ view.set(buf);
578
+ return {
579
+ read: arg.length,
580
+ written: buf.length
581
+ };
582
+ };
583
+ }
584
+
585
+ let WASM_VECTOR_LEN = 0;
586
+
587
+
588
+ let wasm;
589
+ export function __wbg_set_wasm(val) {
590
+ wasm = val;
591
+ }
Binary file
@@ -0,0 +1,39 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_wasmdb_free: (a: number, b: number) => void;
5
+ export const wasmdb_admin: (a: number, b: number, c: number) => [number, number, number];
6
+ export const wasmdb_adminWithParams: (a: number, b: number, c: number, d: any) => [number, number, number];
7
+ export const wasmdb_command: (a: number, b: number, c: number) => [number, number, number];
8
+ export const wasmdb_commandWithParams: (a: number, b: number, c: number, d: any) => [number, number, number];
9
+ export const wasmdb_new: () => [number, number, number];
10
+ export const wasmdb_query: (a: number, b: number, c: number) => [number, number, number];
11
+ export const wasmdb_queryWithParams: (a: number, b: number, c: number, d: any) => [number, number, number];
12
+ export const __wbg_jserror_free: (a: number, b: number) => void;
13
+ export const jserror_message: (a: number) => [number, number];
14
+ export const host_alloc: (a: number) => number;
15
+ export const host_free: (a: number, b: number) => void;
16
+ export const host_realloc: (a: number, b: number, c: number) => number;
17
+ export const host_log_message: (a: bigint, b: number, c: number, d: number) => void;
18
+ export const test_alloc: (a: number) => number;
19
+ export const test_free: (a: number, b: number) => void;
20
+ export const test_log_message: (a: bigint, b: number, c: number, d: number) => void;
21
+ export const test_realloc: (a: number, b: number, c: number) => number;
22
+ export const test_state_clear: (a: bigint, b: number) => number;
23
+ export const test_state_get: (a: bigint, b: number, c: number, d: number, e: number) => number;
24
+ export const test_state_iterator_free: (a: number) => void;
25
+ export const test_state_iterator_next: (a: number, b: number, c: number) => number;
26
+ export const test_state_prefix: (a: bigint, b: number, c: number, d: number, e: number) => number;
27
+ export const test_state_range: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
28
+ export const test_state_remove: (a: bigint, b: number, c: number, d: number) => number;
29
+ export const test_state_set: (a: bigint, b: number, c: number, d: number, e: number, f: number) => number;
30
+ export const wasm_bindgen__closure__destroy__hb496c74d4b5d2fe7: (a: number, b: number) => void;
31
+ export const wasm_bindgen__convert__closures_____invoke__hb278d5bbbfdc8d45: (a: number, b: number) => void;
32
+ export const __wbindgen_malloc: (a: number, b: number) => number;
33
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
34
+ export const __wbindgen_exn_store: (a: number) => void;
35
+ export const __externref_table_alloc: () => number;
36
+ export const __wbindgen_externrefs: WebAssembly.Table;
37
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
38
+ export const __externref_table_dealloc: (a: number) => void;
39
+ export const __wbindgen_start: () => void;