@minigraf/browser 1.0.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 +87 -0
- package/minigraf.d.ts +107 -0
- package/minigraf.js +757 -0
- package/minigraf_bg.wasm +0 -0
- package/minigraf_bg.wasm.d.ts +18 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @minigraf/browser
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@minigraf/browser)
|
|
4
|
+
[](https://github.com/project-minigraf/minigraf#license)
|
|
5
|
+
|
|
6
|
+
> Embedded bi-temporal graph database for the browser — Datalog queries, time travel, IndexedDB persistence
|
|
7
|
+
|
|
8
|
+
Minigraf in the browser: zero configuration, persistent graph storage backed by IndexedDB, Datalog queries with recursive rules and time travel. One API, no server required.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @minigraf/browser
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
import init, { BrowserDb } from '@minigraf/browser';
|
|
20
|
+
await init();
|
|
21
|
+
|
|
22
|
+
// Persistent database (survives page reloads — backed by IndexedDB)
|
|
23
|
+
const db = await BrowserDb.open('my-graph');
|
|
24
|
+
|
|
25
|
+
// In-memory database (ephemeral / testing)
|
|
26
|
+
const mem = BrowserDb.openInMemory();
|
|
27
|
+
|
|
28
|
+
// Transact facts
|
|
29
|
+
const r = JSON.parse(await db.execute(
|
|
30
|
+
'(transact [[:alice :person/name "Alice"] [:alice :person/age 30]])'
|
|
31
|
+
));
|
|
32
|
+
// { "transacted": 1 }
|
|
33
|
+
|
|
34
|
+
// Query with Datalog
|
|
35
|
+
const q = JSON.parse(await db.execute(
|
|
36
|
+
'(query [:find ?name ?age :where [?e :person/name ?name] [?e :person/age ?age]])'
|
|
37
|
+
));
|
|
38
|
+
// { "variables": ["?name", "?age"], "results": [["Alice", 30]] }
|
|
39
|
+
|
|
40
|
+
// Time travel — state as of transaction 1
|
|
41
|
+
const snap = JSON.parse(await db.execute(
|
|
42
|
+
'(query [:find ?age :as-of 1 :where [:alice :person/age ?age]])'
|
|
43
|
+
));
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Response shapes
|
|
47
|
+
|
|
48
|
+
| Command | JSON |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `transact` | `{"transacted": <tx_count>}` |
|
|
51
|
+
| `retract` | `{"retracted": <tx_count>}` |
|
|
52
|
+
| `query` | `{"variables": [...], "results": [[...]]}` |
|
|
53
|
+
| `rule` | `{"ok": true}` |
|
|
54
|
+
|
|
55
|
+
## Export / import
|
|
56
|
+
|
|
57
|
+
The `.graph` binary format is byte-identical between browser and native builds. Export a snapshot or load a native-generated file:
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
// Export (Uint8Array — byte-identical to a native .graph file)
|
|
61
|
+
const bytes = db.exportGraph();
|
|
62
|
+
|
|
63
|
+
// Import a native .graph file (must be checkpointed — no pending WAL)
|
|
64
|
+
const file = document.querySelector('input[type=file]').files[0];
|
|
65
|
+
await db.importGraph(new Uint8Array(await file.arrayBuffer()));
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Constraints
|
|
69
|
+
|
|
70
|
+
- Requires a browser environment with IndexedDB. Not compatible with Node.js — use the [`minigraf` npm package](https://www.npmjs.com/package/minigraf) for Node.js instead.
|
|
71
|
+
- Single-threaded. Runs on the main thread or in a Web Worker; no shared state across workers.
|
|
72
|
+
|
|
73
|
+
## wasm-pack clobbering note (for maintainers)
|
|
74
|
+
|
|
75
|
+
`wasm-pack build` may overwrite this file. If it does, `wasm-release.yml` must copy the canonical
|
|
76
|
+
README from a stable source (e.g. a root-level `minigraf-wasm.README.md`) into the build output
|
|
77
|
+
directory before `npm publish`. Verify this on first release after any `wasm-pack` version upgrade.
|
|
78
|
+
|
|
79
|
+
## Links
|
|
80
|
+
|
|
81
|
+
- [Full browser integration guide](https://github.com/project-minigraf/minigraf/wiki/Use-Cases#wasm--browser)
|
|
82
|
+
- [Repository](https://github.com/project-minigraf/minigraf)
|
|
83
|
+
- [Datalog Reference](https://github.com/project-minigraf/minigraf/wiki/Datalog-Reference)
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT OR Apache-2.0
|
package/minigraf.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Browser-only Minigraf database handle backed by IndexedDB.
|
|
6
|
+
*
|
|
7
|
+
* All public methods return `Promise`s. Use `await` in JavaScript.
|
|
8
|
+
*
|
|
9
|
+
* **Not compatible with Node.js.** Use `@minigraf/node` for server-side use.
|
|
10
|
+
*/
|
|
11
|
+
export class BrowserDb {
|
|
12
|
+
private constructor();
|
|
13
|
+
free(): void;
|
|
14
|
+
[Symbol.dispose](): void;
|
|
15
|
+
/**
|
|
16
|
+
* Flush all dirty pages to IndexedDB.
|
|
17
|
+
*
|
|
18
|
+
* Write-through means individual `execute()` calls already flush dirty pages,
|
|
19
|
+
* so `checkpoint()` is only needed after `import_graph()` or explicit bulk ops.
|
|
20
|
+
* No-op for in-memory databases.
|
|
21
|
+
*/
|
|
22
|
+
checkpoint(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Execute a Datalog command string and return a JSON-encoded result.
|
|
25
|
+
*
|
|
26
|
+
* Returns a `Promise<string>` in JavaScript. The JSON shape is:
|
|
27
|
+
* - Query: `{"variables": [...], "results": [[...], ...]}`
|
|
28
|
+
* - Transact: `{"transacted": <tx_id>}`
|
|
29
|
+
* - Retract: `{"retracted": <tx_id>}`
|
|
30
|
+
* - Rule: `{"ok": true}`
|
|
31
|
+
*/
|
|
32
|
+
execute(datalog: string): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Serialise the current database to a portable `.graph` blob.
|
|
35
|
+
*
|
|
36
|
+
* The blob is byte-for-bit compatible with native `.graph` files opened by
|
|
37
|
+
* `Minigraf::open()`. Pages are always in ascending `page_id` order.
|
|
38
|
+
*
|
|
39
|
+
* Call `checkpoint()` on native before importing a file here to ensure
|
|
40
|
+
* no WAL entries are missing from the main file.
|
|
41
|
+
*/
|
|
42
|
+
exportGraph(): Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
* Replace the current database with a `.graph` blob.
|
|
45
|
+
*
|
|
46
|
+
* The blob must be a checkpointed native `.graph` file (no pending WAL sidecar).
|
|
47
|
+
* All existing data is overwritten. After import, the new data is immediately
|
|
48
|
+
* queryable and all dirty pages are flushed to IndexedDB.
|
|
49
|
+
*/
|
|
50
|
+
importGraph(data: Uint8Array): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Open or create a database backed by IndexedDB.
|
|
53
|
+
*
|
|
54
|
+
* `db_name` is used as both the IndexedDB database name and object store name.
|
|
55
|
+
* Called as `await BrowserDb.open("mydb")` — NOT `new BrowserDb()`.
|
|
56
|
+
*/
|
|
57
|
+
static open(db_name: string): Promise<BrowserDb>;
|
|
58
|
+
/**
|
|
59
|
+
* Open an in-memory database (no IndexedDB — for testing only).
|
|
60
|
+
*
|
|
61
|
+
* Data is lost when the page is closed. Use `BrowserDb.open()` for persistence.
|
|
62
|
+
*/
|
|
63
|
+
static openInMemory(): BrowserDb;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
67
|
+
|
|
68
|
+
export interface InitOutput {
|
|
69
|
+
readonly memory: WebAssembly.Memory;
|
|
70
|
+
readonly __wbg_browserdb_free: (a: number, b: number) => void;
|
|
71
|
+
readonly browserdb_checkpoint: (a: number) => number;
|
|
72
|
+
readonly browserdb_execute: (a: number, b: number, c: number) => number;
|
|
73
|
+
readonly browserdb_exportGraph: (a: number, b: number) => void;
|
|
74
|
+
readonly browserdb_importGraph: (a: number, b: number) => number;
|
|
75
|
+
readonly browserdb_open: (a: number, b: number) => number;
|
|
76
|
+
readonly browserdb_openInMemory: (a: number) => void;
|
|
77
|
+
readonly __wasm_bindgen_func_elem_2769: (a: number, b: number, c: number, d: number) => void;
|
|
78
|
+
readonly __wasm_bindgen_func_elem_2781: (a: number, b: number, c: number, d: number) => void;
|
|
79
|
+
readonly __wasm_bindgen_func_elem_658: (a: number, b: number, c: number) => void;
|
|
80
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
81
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
82
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
83
|
+
readonly __wbindgen_export4: (a: number, b: number) => void;
|
|
84
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
91
|
+
* a precompiled `WebAssembly.Module`.
|
|
92
|
+
*
|
|
93
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
94
|
+
*
|
|
95
|
+
* @returns {InitOutput}
|
|
96
|
+
*/
|
|
97
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
101
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
102
|
+
*
|
|
103
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
104
|
+
*
|
|
105
|
+
* @returns {Promise<InitOutput>}
|
|
106
|
+
*/
|
|
107
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/minigraf.js
ADDED
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
/* @ts-self-types="./minigraf.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Browser-only Minigraf database handle backed by IndexedDB.
|
|
5
|
+
*
|
|
6
|
+
* All public methods return `Promise`s. Use `await` in JavaScript.
|
|
7
|
+
*
|
|
8
|
+
* **Not compatible with Node.js.** Use `@minigraf/node` for server-side use.
|
|
9
|
+
*/
|
|
10
|
+
export class BrowserDb {
|
|
11
|
+
static __wrap(ptr) {
|
|
12
|
+
ptr = ptr >>> 0;
|
|
13
|
+
const obj = Object.create(BrowserDb.prototype);
|
|
14
|
+
obj.__wbg_ptr = ptr;
|
|
15
|
+
BrowserDbFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
__destroy_into_raw() {
|
|
19
|
+
const ptr = this.__wbg_ptr;
|
|
20
|
+
this.__wbg_ptr = 0;
|
|
21
|
+
BrowserDbFinalization.unregister(this);
|
|
22
|
+
return ptr;
|
|
23
|
+
}
|
|
24
|
+
free() {
|
|
25
|
+
const ptr = this.__destroy_into_raw();
|
|
26
|
+
wasm.__wbg_browserdb_free(ptr, 0);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Flush all dirty pages to IndexedDB.
|
|
30
|
+
*
|
|
31
|
+
* Write-through means individual `execute()` calls already flush dirty pages,
|
|
32
|
+
* so `checkpoint()` is only needed after `import_graph()` or explicit bulk ops.
|
|
33
|
+
* No-op for in-memory databases.
|
|
34
|
+
* @returns {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
checkpoint() {
|
|
37
|
+
const ret = wasm.browserdb_checkpoint(this.__wbg_ptr);
|
|
38
|
+
return takeObject(ret);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Execute a Datalog command string and return a JSON-encoded result.
|
|
42
|
+
*
|
|
43
|
+
* Returns a `Promise<string>` in JavaScript. The JSON shape is:
|
|
44
|
+
* - Query: `{"variables": [...], "results": [[...], ...]}`
|
|
45
|
+
* - Transact: `{"transacted": <tx_id>}`
|
|
46
|
+
* - Retract: `{"retracted": <tx_id>}`
|
|
47
|
+
* - Rule: `{"ok": true}`
|
|
48
|
+
* @param {string} datalog
|
|
49
|
+
* @returns {Promise<string>}
|
|
50
|
+
*/
|
|
51
|
+
execute(datalog) {
|
|
52
|
+
const ptr0 = passStringToWasm0(datalog, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
53
|
+
const len0 = WASM_VECTOR_LEN;
|
|
54
|
+
const ret = wasm.browserdb_execute(this.__wbg_ptr, ptr0, len0);
|
|
55
|
+
return takeObject(ret);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Serialise the current database to a portable `.graph` blob.
|
|
59
|
+
*
|
|
60
|
+
* The blob is byte-for-bit compatible with native `.graph` files opened by
|
|
61
|
+
* `Minigraf::open()`. Pages are always in ascending `page_id` order.
|
|
62
|
+
*
|
|
63
|
+
* Call `checkpoint()` on native before importing a file here to ensure
|
|
64
|
+
* no WAL entries are missing from the main file.
|
|
65
|
+
* @returns {Uint8Array}
|
|
66
|
+
*/
|
|
67
|
+
exportGraph() {
|
|
68
|
+
try {
|
|
69
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
70
|
+
wasm.browserdb_exportGraph(retptr, this.__wbg_ptr);
|
|
71
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
72
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
73
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
74
|
+
if (r2) {
|
|
75
|
+
throw takeObject(r1);
|
|
76
|
+
}
|
|
77
|
+
return takeObject(r0);
|
|
78
|
+
} finally {
|
|
79
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Replace the current database with a `.graph` blob.
|
|
84
|
+
*
|
|
85
|
+
* The blob must be a checkpointed native `.graph` file (no pending WAL sidecar).
|
|
86
|
+
* All existing data is overwritten. After import, the new data is immediately
|
|
87
|
+
* queryable and all dirty pages are flushed to IndexedDB.
|
|
88
|
+
* @param {Uint8Array} data
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
*/
|
|
91
|
+
importGraph(data) {
|
|
92
|
+
const ret = wasm.browserdb_importGraph(this.__wbg_ptr, addHeapObject(data));
|
|
93
|
+
return takeObject(ret);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Open or create a database backed by IndexedDB.
|
|
97
|
+
*
|
|
98
|
+
* `db_name` is used as both the IndexedDB database name and object store name.
|
|
99
|
+
* Called as `await BrowserDb.open("mydb")` — NOT `new BrowserDb()`.
|
|
100
|
+
* @param {string} db_name
|
|
101
|
+
* @returns {Promise<BrowserDb>}
|
|
102
|
+
*/
|
|
103
|
+
static open(db_name) {
|
|
104
|
+
const ptr0 = passStringToWasm0(db_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
105
|
+
const len0 = WASM_VECTOR_LEN;
|
|
106
|
+
const ret = wasm.browserdb_open(ptr0, len0);
|
|
107
|
+
return takeObject(ret);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Open an in-memory database (no IndexedDB — for testing only).
|
|
111
|
+
*
|
|
112
|
+
* Data is lost when the page is closed. Use `BrowserDb.open()` for persistence.
|
|
113
|
+
* @returns {BrowserDb}
|
|
114
|
+
*/
|
|
115
|
+
static openInMemory() {
|
|
116
|
+
try {
|
|
117
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
118
|
+
wasm.browserdb_openInMemory(retptr);
|
|
119
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
120
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
121
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
122
|
+
if (r2) {
|
|
123
|
+
throw takeObject(r1);
|
|
124
|
+
}
|
|
125
|
+
return BrowserDb.__wrap(r0);
|
|
126
|
+
} finally {
|
|
127
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (Symbol.dispose) BrowserDb.prototype[Symbol.dispose] = BrowserDb.prototype.free;
|
|
132
|
+
|
|
133
|
+
function __wbg_get_imports() {
|
|
134
|
+
const import0 = {
|
|
135
|
+
__proto__: null,
|
|
136
|
+
__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
|
|
137
|
+
const ret = debugString(getObject(arg1));
|
|
138
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
139
|
+
const len1 = WASM_VECTOR_LEN;
|
|
140
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
141
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
142
|
+
},
|
|
143
|
+
__wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
|
|
144
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
145
|
+
return ret;
|
|
146
|
+
},
|
|
147
|
+
__wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
|
|
148
|
+
const ret = getObject(arg0) === undefined;
|
|
149
|
+
return ret;
|
|
150
|
+
},
|
|
151
|
+
__wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
|
|
152
|
+
const obj = getObject(arg1);
|
|
153
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
154
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
155
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
156
|
+
},
|
|
157
|
+
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
158
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
159
|
+
},
|
|
160
|
+
__wbg__wbg_cb_unref_3c3b4f651835fbcb: function(arg0) {
|
|
161
|
+
getObject(arg0)._wbg_cb_unref();
|
|
162
|
+
},
|
|
163
|
+
__wbg_browserdb_new: function(arg0) {
|
|
164
|
+
const ret = BrowserDb.__wrap(arg0);
|
|
165
|
+
return addHeapObject(ret);
|
|
166
|
+
},
|
|
167
|
+
__wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
|
|
168
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
169
|
+
return addHeapObject(ret);
|
|
170
|
+
}, arguments); },
|
|
171
|
+
__wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
|
|
172
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
173
|
+
return addHeapObject(ret);
|
|
174
|
+
}, arguments); },
|
|
175
|
+
__wbg_contains_04f0b15b3b6b3f6f: function(arg0, arg1, arg2) {
|
|
176
|
+
const ret = getObject(arg0).contains(getStringFromWasm0(arg1, arg2));
|
|
177
|
+
return ret;
|
|
178
|
+
},
|
|
179
|
+
__wbg_createObjectStore_11c03f9eac3c3672: function() { return handleError(function (arg0, arg1, arg2) {
|
|
180
|
+
const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2));
|
|
181
|
+
return addHeapObject(ret);
|
|
182
|
+
}, arguments); },
|
|
183
|
+
__wbg_getAllKeys_122dfa5978e6ca9a: function() { return handleError(function (arg0) {
|
|
184
|
+
const ret = getObject(arg0).getAllKeys();
|
|
185
|
+
return addHeapObject(ret);
|
|
186
|
+
}, arguments); },
|
|
187
|
+
__wbg_getAll_19e833a015c08d39: function() { return handleError(function (arg0) {
|
|
188
|
+
const ret = getObject(arg0).getAll();
|
|
189
|
+
return addHeapObject(ret);
|
|
190
|
+
}, arguments); },
|
|
191
|
+
__wbg_get_4848e350b40afc16: function(arg0, arg1) {
|
|
192
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
193
|
+
return addHeapObject(ret);
|
|
194
|
+
},
|
|
195
|
+
__wbg_indexedDB_af74cb6df65fa636: function() { return handleError(function (arg0) {
|
|
196
|
+
const ret = getObject(arg0).indexedDB;
|
|
197
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
198
|
+
}, arguments); },
|
|
199
|
+
__wbg_instanceof_IdbDatabase_0af111edb4be95f4: function(arg0) {
|
|
200
|
+
let result;
|
|
201
|
+
try {
|
|
202
|
+
result = getObject(arg0) instanceof IDBDatabase;
|
|
203
|
+
} catch (_) {
|
|
204
|
+
result = false;
|
|
205
|
+
}
|
|
206
|
+
const ret = result;
|
|
207
|
+
return ret;
|
|
208
|
+
},
|
|
209
|
+
__wbg_instanceof_IdbOpenDbRequest_92df356941adf31e: function(arg0) {
|
|
210
|
+
let result;
|
|
211
|
+
try {
|
|
212
|
+
result = getObject(arg0) instanceof IDBOpenDBRequest;
|
|
213
|
+
} catch (_) {
|
|
214
|
+
result = false;
|
|
215
|
+
}
|
|
216
|
+
const ret = result;
|
|
217
|
+
return ret;
|
|
218
|
+
},
|
|
219
|
+
__wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
|
|
220
|
+
let result;
|
|
221
|
+
try {
|
|
222
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
223
|
+
} catch (_) {
|
|
224
|
+
result = false;
|
|
225
|
+
}
|
|
226
|
+
const ret = result;
|
|
227
|
+
return ret;
|
|
228
|
+
},
|
|
229
|
+
__wbg_instanceof_Window_c0fee4c064502536: function(arg0) {
|
|
230
|
+
let result;
|
|
231
|
+
try {
|
|
232
|
+
result = getObject(arg0) instanceof Window;
|
|
233
|
+
} catch (_) {
|
|
234
|
+
result = false;
|
|
235
|
+
}
|
|
236
|
+
const ret = result;
|
|
237
|
+
return ret;
|
|
238
|
+
},
|
|
239
|
+
__wbg_isArray_db61795ad004c139: function(arg0) {
|
|
240
|
+
const ret = Array.isArray(getObject(arg0));
|
|
241
|
+
return ret;
|
|
242
|
+
},
|
|
243
|
+
__wbg_length_0c32cb8543c8e4c8: function(arg0) {
|
|
244
|
+
const ret = getObject(arg0).length;
|
|
245
|
+
return ret;
|
|
246
|
+
},
|
|
247
|
+
__wbg_length_6e821edde497a532: function(arg0) {
|
|
248
|
+
const ret = getObject(arg0).length;
|
|
249
|
+
return ret;
|
|
250
|
+
},
|
|
251
|
+
__wbg_new_40792555590ec35c: function(arg0, arg1) {
|
|
252
|
+
try {
|
|
253
|
+
var state0 = {a: arg0, b: arg1};
|
|
254
|
+
var cb0 = (arg0, arg1) => {
|
|
255
|
+
const a = state0.a;
|
|
256
|
+
state0.a = 0;
|
|
257
|
+
try {
|
|
258
|
+
return __wasm_bindgen_func_elem_2781(a, state0.b, arg0, arg1);
|
|
259
|
+
} finally {
|
|
260
|
+
state0.a = a;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const ret = new Promise(cb0);
|
|
264
|
+
return addHeapObject(ret);
|
|
265
|
+
} finally {
|
|
266
|
+
state0.a = 0;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
__wbg_new_from_slice_2580ff33d0d10520: function(arg0, arg1) {
|
|
270
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
271
|
+
return addHeapObject(ret);
|
|
272
|
+
},
|
|
273
|
+
__wbg_new_typed_14d7cc391ce53d2c: function(arg0, arg1) {
|
|
274
|
+
try {
|
|
275
|
+
var state0 = {a: arg0, b: arg1};
|
|
276
|
+
var cb0 = (arg0, arg1) => {
|
|
277
|
+
const a = state0.a;
|
|
278
|
+
state0.a = 0;
|
|
279
|
+
try {
|
|
280
|
+
return __wasm_bindgen_func_elem_2781(a, state0.b, arg0, arg1);
|
|
281
|
+
} finally {
|
|
282
|
+
state0.a = a;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const ret = new Promise(cb0);
|
|
286
|
+
return addHeapObject(ret);
|
|
287
|
+
} finally {
|
|
288
|
+
state0.a = 0;
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
__wbg_now_88621c9c9a4f3ffc: function() {
|
|
292
|
+
const ret = Date.now();
|
|
293
|
+
return ret;
|
|
294
|
+
},
|
|
295
|
+
__wbg_objectStoreNames_990d8e55c661828b: function(arg0) {
|
|
296
|
+
const ret = getObject(arg0).objectStoreNames;
|
|
297
|
+
return addHeapObject(ret);
|
|
298
|
+
},
|
|
299
|
+
__wbg_objectStore_3d4cade4416cd432: function() { return handleError(function (arg0, arg1, arg2) {
|
|
300
|
+
const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
|
|
301
|
+
return addHeapObject(ret);
|
|
302
|
+
}, arguments); },
|
|
303
|
+
__wbg_open_ac04ec9d75d0eeaf: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
304
|
+
const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
|
|
305
|
+
return addHeapObject(ret);
|
|
306
|
+
}, arguments); },
|
|
307
|
+
__wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
|
|
308
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
309
|
+
},
|
|
310
|
+
__wbg_put_4485a4012273f7ef: function() { return handleError(function (arg0, arg1, arg2) {
|
|
311
|
+
const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
|
|
312
|
+
return addHeapObject(ret);
|
|
313
|
+
}, arguments); },
|
|
314
|
+
__wbg_queueMicrotask_abaf92f0bd4e80a4: function(arg0) {
|
|
315
|
+
const ret = getObject(arg0).queueMicrotask;
|
|
316
|
+
return addHeapObject(ret);
|
|
317
|
+
},
|
|
318
|
+
__wbg_queueMicrotask_df5a6dac26d818f3: function(arg0) {
|
|
319
|
+
queueMicrotask(getObject(arg0));
|
|
320
|
+
},
|
|
321
|
+
__wbg_resolve_0a79de24e9d2267b: function(arg0) {
|
|
322
|
+
const ret = Promise.resolve(getObject(arg0));
|
|
323
|
+
return addHeapObject(ret);
|
|
324
|
+
},
|
|
325
|
+
__wbg_result_452c1006fc727317: function() { return handleError(function (arg0) {
|
|
326
|
+
const ret = getObject(arg0).result;
|
|
327
|
+
return addHeapObject(ret);
|
|
328
|
+
}, arguments); },
|
|
329
|
+
__wbg_set_oncomplete_20fb27150b4ee0d4: function(arg0, arg1) {
|
|
330
|
+
getObject(arg0).oncomplete = getObject(arg1);
|
|
331
|
+
},
|
|
332
|
+
__wbg_set_onerror_2b7dfa4e6dea4159: function(arg0, arg1) {
|
|
333
|
+
getObject(arg0).onerror = getObject(arg1);
|
|
334
|
+
},
|
|
335
|
+
__wbg_set_onerror_3c4b5087146b11b6: function(arg0, arg1) {
|
|
336
|
+
getObject(arg0).onerror = getObject(arg1);
|
|
337
|
+
},
|
|
338
|
+
__wbg_set_onsuccess_f7e5b5cbed5008b1: function(arg0, arg1) {
|
|
339
|
+
getObject(arg0).onsuccess = getObject(arg1);
|
|
340
|
+
},
|
|
341
|
+
__wbg_set_onupgradeneeded_d7e8e03a1999bf5d: function(arg0, arg1) {
|
|
342
|
+
getObject(arg0).onupgradeneeded = getObject(arg1);
|
|
343
|
+
},
|
|
344
|
+
__wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: function() {
|
|
345
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
346
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
347
|
+
},
|
|
348
|
+
__wbg_static_accessor_GLOBAL_f2e0f995a21329ff: function() {
|
|
349
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
350
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
351
|
+
},
|
|
352
|
+
__wbg_static_accessor_SELF_24f78b6d23f286ea: function() {
|
|
353
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
354
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
355
|
+
},
|
|
356
|
+
__wbg_static_accessor_WINDOW_59fd959c540fe405: function() {
|
|
357
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
358
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
359
|
+
},
|
|
360
|
+
__wbg_target_732d56b173b7e87c: function(arg0) {
|
|
361
|
+
const ret = getObject(arg0).target;
|
|
362
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
363
|
+
},
|
|
364
|
+
__wbg_then_00eed3ac0b8e82cb: function(arg0, arg1, arg2) {
|
|
365
|
+
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
|
366
|
+
return addHeapObject(ret);
|
|
367
|
+
},
|
|
368
|
+
__wbg_then_a0c8db0381c8994c: function(arg0, arg1) {
|
|
369
|
+
const ret = getObject(arg0).then(getObject(arg1));
|
|
370
|
+
return addHeapObject(ret);
|
|
371
|
+
},
|
|
372
|
+
__wbg_transaction_f909284bfed41115: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
373
|
+
const ret = getObject(arg0).transaction(getStringFromWasm0(arg1, arg2), __wbindgen_enum_IdbTransactionMode[arg3]);
|
|
374
|
+
return addHeapObject(ret);
|
|
375
|
+
}, arguments); },
|
|
376
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
377
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 237, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
378
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2769);
|
|
379
|
+
return addHeapObject(ret);
|
|
380
|
+
},
|
|
381
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
382
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
383
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_658);
|
|
384
|
+
return addHeapObject(ret);
|
|
385
|
+
},
|
|
386
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
387
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
388
|
+
const ret = arg0;
|
|
389
|
+
return addHeapObject(ret);
|
|
390
|
+
},
|
|
391
|
+
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
392
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
393
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
394
|
+
return addHeapObject(ret);
|
|
395
|
+
},
|
|
396
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
397
|
+
const ret = getObject(arg0);
|
|
398
|
+
return addHeapObject(ret);
|
|
399
|
+
},
|
|
400
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
401
|
+
takeObject(arg0);
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
return {
|
|
405
|
+
__proto__: null,
|
|
406
|
+
"./minigraf_bg.js": import0,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function __wasm_bindgen_func_elem_658(arg0, arg1, arg2) {
|
|
411
|
+
wasm.__wasm_bindgen_func_elem_658(arg0, arg1, addHeapObject(arg2));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function __wasm_bindgen_func_elem_2769(arg0, arg1, arg2) {
|
|
415
|
+
try {
|
|
416
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
417
|
+
wasm.__wasm_bindgen_func_elem_2769(retptr, arg0, arg1, addHeapObject(arg2));
|
|
418
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
419
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
420
|
+
if (r1) {
|
|
421
|
+
throw takeObject(r0);
|
|
422
|
+
}
|
|
423
|
+
} finally {
|
|
424
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function __wasm_bindgen_func_elem_2781(arg0, arg1, arg2, arg3) {
|
|
429
|
+
wasm.__wasm_bindgen_func_elem_2781(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
|
|
434
|
+
const BrowserDbFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
435
|
+
? { register: () => {}, unregister: () => {} }
|
|
436
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_browserdb_free(ptr >>> 0, 1));
|
|
437
|
+
|
|
438
|
+
function addHeapObject(obj) {
|
|
439
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
440
|
+
const idx = heap_next;
|
|
441
|
+
heap_next = heap[idx];
|
|
442
|
+
|
|
443
|
+
heap[idx] = obj;
|
|
444
|
+
return idx;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
448
|
+
? { register: () => {}, unregister: () => {} }
|
|
449
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_export4(state.a, state.b));
|
|
450
|
+
|
|
451
|
+
function debugString(val) {
|
|
452
|
+
// primitive types
|
|
453
|
+
const type = typeof val;
|
|
454
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
455
|
+
return `${val}`;
|
|
456
|
+
}
|
|
457
|
+
if (type == 'string') {
|
|
458
|
+
return `"${val}"`;
|
|
459
|
+
}
|
|
460
|
+
if (type == 'symbol') {
|
|
461
|
+
const description = val.description;
|
|
462
|
+
if (description == null) {
|
|
463
|
+
return 'Symbol';
|
|
464
|
+
} else {
|
|
465
|
+
return `Symbol(${description})`;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (type == 'function') {
|
|
469
|
+
const name = val.name;
|
|
470
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
471
|
+
return `Function(${name})`;
|
|
472
|
+
} else {
|
|
473
|
+
return 'Function';
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
// objects
|
|
477
|
+
if (Array.isArray(val)) {
|
|
478
|
+
const length = val.length;
|
|
479
|
+
let debug = '[';
|
|
480
|
+
if (length > 0) {
|
|
481
|
+
debug += debugString(val[0]);
|
|
482
|
+
}
|
|
483
|
+
for(let i = 1; i < length; i++) {
|
|
484
|
+
debug += ', ' + debugString(val[i]);
|
|
485
|
+
}
|
|
486
|
+
debug += ']';
|
|
487
|
+
return debug;
|
|
488
|
+
}
|
|
489
|
+
// Test for built-in
|
|
490
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
491
|
+
let className;
|
|
492
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
493
|
+
className = builtInMatches[1];
|
|
494
|
+
} else {
|
|
495
|
+
// Failed to match the standard '[object ClassName]'
|
|
496
|
+
return toString.call(val);
|
|
497
|
+
}
|
|
498
|
+
if (className == 'Object') {
|
|
499
|
+
// we're a user defined class or Object
|
|
500
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
501
|
+
// easier than looping through ownProperties of `val`.
|
|
502
|
+
try {
|
|
503
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
504
|
+
} catch (_) {
|
|
505
|
+
return 'Object';
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
// errors
|
|
509
|
+
if (val instanceof Error) {
|
|
510
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
511
|
+
}
|
|
512
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
513
|
+
return className;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function dropObject(idx) {
|
|
517
|
+
if (idx < 1028) return;
|
|
518
|
+
heap[idx] = heap_next;
|
|
519
|
+
heap_next = idx;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
523
|
+
ptr = ptr >>> 0;
|
|
524
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
let cachedDataViewMemory0 = null;
|
|
528
|
+
function getDataViewMemory0() {
|
|
529
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
530
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
531
|
+
}
|
|
532
|
+
return cachedDataViewMemory0;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function getStringFromWasm0(ptr, len) {
|
|
536
|
+
ptr = ptr >>> 0;
|
|
537
|
+
return decodeText(ptr, len);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
let cachedUint8ArrayMemory0 = null;
|
|
541
|
+
function getUint8ArrayMemory0() {
|
|
542
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
543
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
544
|
+
}
|
|
545
|
+
return cachedUint8ArrayMemory0;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function getObject(idx) { return heap[idx]; }
|
|
549
|
+
|
|
550
|
+
function handleError(f, args) {
|
|
551
|
+
try {
|
|
552
|
+
return f.apply(this, args);
|
|
553
|
+
} catch (e) {
|
|
554
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
let heap = new Array(1024).fill(undefined);
|
|
559
|
+
heap.push(undefined, null, true, false);
|
|
560
|
+
|
|
561
|
+
let heap_next = heap.length;
|
|
562
|
+
|
|
563
|
+
function isLikeNone(x) {
|
|
564
|
+
return x === undefined || x === null;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function makeMutClosure(arg0, arg1, f) {
|
|
568
|
+
const state = { a: arg0, b: arg1, cnt: 1 };
|
|
569
|
+
const real = (...args) => {
|
|
570
|
+
|
|
571
|
+
// First up with a closure we increment the internal reference
|
|
572
|
+
// count. This ensures that the Rust closure environment won't
|
|
573
|
+
// be deallocated while we're invoking it.
|
|
574
|
+
state.cnt++;
|
|
575
|
+
const a = state.a;
|
|
576
|
+
state.a = 0;
|
|
577
|
+
try {
|
|
578
|
+
return f(a, state.b, ...args);
|
|
579
|
+
} finally {
|
|
580
|
+
state.a = a;
|
|
581
|
+
real._wbg_cb_unref();
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
real._wbg_cb_unref = () => {
|
|
585
|
+
if (--state.cnt === 0) {
|
|
586
|
+
wasm.__wbindgen_export4(state.a, state.b);
|
|
587
|
+
state.a = 0;
|
|
588
|
+
CLOSURE_DTORS.unregister(state);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
592
|
+
return real;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
596
|
+
if (realloc === undefined) {
|
|
597
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
598
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
599
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
600
|
+
WASM_VECTOR_LEN = buf.length;
|
|
601
|
+
return ptr;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
let len = arg.length;
|
|
605
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
606
|
+
|
|
607
|
+
const mem = getUint8ArrayMemory0();
|
|
608
|
+
|
|
609
|
+
let offset = 0;
|
|
610
|
+
|
|
611
|
+
for (; offset < len; offset++) {
|
|
612
|
+
const code = arg.charCodeAt(offset);
|
|
613
|
+
if (code > 0x7F) break;
|
|
614
|
+
mem[ptr + offset] = code;
|
|
615
|
+
}
|
|
616
|
+
if (offset !== len) {
|
|
617
|
+
if (offset !== 0) {
|
|
618
|
+
arg = arg.slice(offset);
|
|
619
|
+
}
|
|
620
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
621
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
622
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
623
|
+
|
|
624
|
+
offset += ret.written;
|
|
625
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
WASM_VECTOR_LEN = offset;
|
|
629
|
+
return ptr;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function takeObject(idx) {
|
|
633
|
+
const ret = getObject(idx);
|
|
634
|
+
dropObject(idx);
|
|
635
|
+
return ret;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
639
|
+
cachedTextDecoder.decode();
|
|
640
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
641
|
+
let numBytesDecoded = 0;
|
|
642
|
+
function decodeText(ptr, len) {
|
|
643
|
+
numBytesDecoded += len;
|
|
644
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
645
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
646
|
+
cachedTextDecoder.decode();
|
|
647
|
+
numBytesDecoded = len;
|
|
648
|
+
}
|
|
649
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
const cachedTextEncoder = new TextEncoder();
|
|
653
|
+
|
|
654
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
655
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
656
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
657
|
+
view.set(buf);
|
|
658
|
+
return {
|
|
659
|
+
read: arg.length,
|
|
660
|
+
written: buf.length
|
|
661
|
+
};
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
let WASM_VECTOR_LEN = 0;
|
|
666
|
+
|
|
667
|
+
let wasmModule, wasm;
|
|
668
|
+
function __wbg_finalize_init(instance, module) {
|
|
669
|
+
wasm = instance.exports;
|
|
670
|
+
wasmModule = module;
|
|
671
|
+
cachedDataViewMemory0 = null;
|
|
672
|
+
cachedUint8ArrayMemory0 = null;
|
|
673
|
+
return wasm;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
async function __wbg_load(module, imports) {
|
|
677
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
678
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
679
|
+
try {
|
|
680
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
681
|
+
} catch (e) {
|
|
682
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
683
|
+
|
|
684
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
685
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
686
|
+
|
|
687
|
+
} else { throw e; }
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
const bytes = await module.arrayBuffer();
|
|
692
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
693
|
+
} else {
|
|
694
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
695
|
+
|
|
696
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
697
|
+
return { instance, module };
|
|
698
|
+
} else {
|
|
699
|
+
return instance;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function expectedResponseType(type) {
|
|
704
|
+
switch (type) {
|
|
705
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
706
|
+
}
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function initSync(module) {
|
|
712
|
+
if (wasm !== undefined) return wasm;
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
if (module !== undefined) {
|
|
716
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
717
|
+
({module} = module)
|
|
718
|
+
} else {
|
|
719
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const imports = __wbg_get_imports();
|
|
724
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
725
|
+
module = new WebAssembly.Module(module);
|
|
726
|
+
}
|
|
727
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
728
|
+
return __wbg_finalize_init(instance, module);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
async function __wbg_init(module_or_path) {
|
|
732
|
+
if (wasm !== undefined) return wasm;
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
if (module_or_path !== undefined) {
|
|
736
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
737
|
+
({module_or_path} = module_or_path)
|
|
738
|
+
} else {
|
|
739
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
if (module_or_path === undefined) {
|
|
744
|
+
module_or_path = new URL('minigraf_bg.wasm', import.meta.url);
|
|
745
|
+
}
|
|
746
|
+
const imports = __wbg_get_imports();
|
|
747
|
+
|
|
748
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
749
|
+
module_or_path = fetch(module_or_path);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
753
|
+
|
|
754
|
+
return __wbg_finalize_init(instance, module);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
export { initSync, __wbg_init as default };
|
package/minigraf_bg.wasm
ADDED
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_browserdb_free: (a: number, b: number) => void;
|
|
5
|
+
export const browserdb_checkpoint: (a: number) => number;
|
|
6
|
+
export const browserdb_execute: (a: number, b: number, c: number) => number;
|
|
7
|
+
export const browserdb_exportGraph: (a: number, b: number) => void;
|
|
8
|
+
export const browserdb_importGraph: (a: number, b: number) => number;
|
|
9
|
+
export const browserdb_open: (a: number, b: number) => number;
|
|
10
|
+
export const browserdb_openInMemory: (a: number) => void;
|
|
11
|
+
export const __wasm_bindgen_func_elem_2769: (a: number, b: number, c: number, d: number) => void;
|
|
12
|
+
export const __wasm_bindgen_func_elem_2781: (a: number, b: number, c: number, d: number) => void;
|
|
13
|
+
export const __wasm_bindgen_func_elem_658: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
15
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
16
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
17
|
+
export const __wbindgen_export4: (a: number, b: number) => void;
|
|
18
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@minigraf/browser",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Aditya Mukhopadhyay"
|
|
6
|
+
],
|
|
7
|
+
"description": "Zero-config, single-file, embedded graph database with bi-temporal Datalog queries",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"license": "MIT OR Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/project-minigraf/minigraf"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"minigraf_bg.wasm",
|
|
16
|
+
"minigraf_bg.wasm.d.ts",
|
|
17
|
+
"minigraf.js",
|
|
18
|
+
"minigraf.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"main": "minigraf.js",
|
|
21
|
+
"types": "minigraf.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./snippets/*"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"graph",
|
|
27
|
+
"datalog",
|
|
28
|
+
"bitemporal",
|
|
29
|
+
"embedded",
|
|
30
|
+
"database"
|
|
31
|
+
]
|
|
32
|
+
}
|