@grafeo-db/wasm-lite 0.5.18 → 0.5.20
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/grafeo_wasm.d.ts +76 -0
- package/grafeo_wasm_bg.js +975 -0
- package/grafeo_wasm_bg.wasm +0 -0
- package/grafeo_wasm_bg.wasm.d.ts +3 -0
- package/package.json +2 -1
package/grafeo_wasm.d.ts
CHANGED
|
@@ -97,6 +97,67 @@ export class Database {
|
|
|
97
97
|
* ```
|
|
98
98
|
*/
|
|
99
99
|
exportSnapshot(): Uint8Array;
|
|
100
|
+
/**
|
|
101
|
+
* Batch-imports LPG (Labeled Property Graph) data from a structured object.
|
|
102
|
+
*
|
|
103
|
+
* Nodes are created first, then edges. Edge `source`/`target` fields are
|
|
104
|
+
* zero-based indexes into the `nodes` array, so you can reference newly
|
|
105
|
+
* created nodes without knowing their database IDs.
|
|
106
|
+
*
|
|
107
|
+
* Returns `{ nodes: number, edges: number }` with the counts of created
|
|
108
|
+
* entities.
|
|
109
|
+
*
|
|
110
|
+
* ```js
|
|
111
|
+
* const result = db.importLpg({
|
|
112
|
+
* nodes: [
|
|
113
|
+
* { labels: ["Person"], properties: { name: "Alix", age: 30 } },
|
|
114
|
+
* { labels: ["Person"], properties: { name: "Gus", age: 25 } },
|
|
115
|
+
* ],
|
|
116
|
+
* edges: [
|
|
117
|
+
* { source: 0, target: 1, type: "KNOWS", properties: { since: 2020 } }
|
|
118
|
+
* ]
|
|
119
|
+
* });
|
|
120
|
+
* // { nodes: 2, edges: 1 }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
importLpg(data: any): any;
|
|
124
|
+
/**
|
|
125
|
+
* Bulk-imports rows (array of objects) as nodes or edges.
|
|
126
|
+
*
|
|
127
|
+
* This is the WASM equivalent of Python's `import_df()`: each object
|
|
128
|
+
* in the array becomes a node or edge, with object keys as property names.
|
|
129
|
+
*
|
|
130
|
+
* **Node import** (`mode: "nodes"`): requires `label` (string or string[]).
|
|
131
|
+
* All object keys become node properties.
|
|
132
|
+
*
|
|
133
|
+
* **Edge import** (`mode: "edges"`): requires `edgeType`. The `source`
|
|
134
|
+
* and `target` keys in each object must contain integer node IDs.
|
|
135
|
+
* Remaining keys become edge properties. Override column names with
|
|
136
|
+
* the `source` and `target` options (default `"source"` / `"target"`).
|
|
137
|
+
*
|
|
138
|
+
* Returns the number of created entities.
|
|
139
|
+
*
|
|
140
|
+
* ```js
|
|
141
|
+
* // Import nodes
|
|
142
|
+
* const count = db.importRows(
|
|
143
|
+
* [{ name: "Alix", age: 30 }, { name: "Gus", age: 25 }],
|
|
144
|
+
* { mode: "nodes", label: "Person" }
|
|
145
|
+
* );
|
|
146
|
+
*
|
|
147
|
+
* // Import edges
|
|
148
|
+
* const edgeCount = db.importRows(
|
|
149
|
+
* [{ source: 0, target: 1, since: 2020 }],
|
|
150
|
+
* { mode: "edges", edgeType: "KNOWS" }
|
|
151
|
+
* );
|
|
152
|
+
*
|
|
153
|
+
* // Custom source/target column names
|
|
154
|
+
* const edgeCount2 = db.importRows(
|
|
155
|
+
* [{ from: 0, to: 1 }],
|
|
156
|
+
* { mode: "edges", edgeType: "KNOWS", source: "from", target: "to" }
|
|
157
|
+
* );
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
importRows(rows: any, options: any): number;
|
|
100
161
|
/**
|
|
101
162
|
* Creates a database from a binary snapshot.
|
|
102
163
|
*
|
|
@@ -107,6 +168,21 @@ export class Database {
|
|
|
107
168
|
* ```
|
|
108
169
|
*/
|
|
109
170
|
static importSnapshot(data: Uint8Array): Database;
|
|
171
|
+
/**
|
|
172
|
+
* Returns a hierarchical memory usage breakdown.
|
|
173
|
+
*
|
|
174
|
+
* The returned object mirrors the engine's `MemoryUsage` struct with
|
|
175
|
+
* `totalBytes`, `store`, `indexes`, `mvcc`, `caches`, `stringPool`,
|
|
176
|
+
* and `bufferManager` sections.
|
|
177
|
+
*
|
|
178
|
+
* ```js
|
|
179
|
+
* const usage = db.memoryUsage();
|
|
180
|
+
* console.log(`Total: ${usage.total_bytes} bytes`);
|
|
181
|
+
* console.log(`Store: ${usage.store.total_bytes} bytes`);
|
|
182
|
+
* console.log(`Indexes: ${usage.indexes.total_bytes} bytes`);
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
memoryUsage(): any;
|
|
110
186
|
/**
|
|
111
187
|
* Creates a new in-memory database.
|
|
112
188
|
*/
|
|
@@ -0,0 +1,975 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Grafeo graph database instance running in WebAssembly.
|
|
3
|
+
*
|
|
4
|
+
* All data is held in memory within the WASM heap. For persistence,
|
|
5
|
+
* use `exportSnapshot()` / `importSnapshot()` with IndexedDB or
|
|
6
|
+
* the higher-level `@grafeo-db/web` package.
|
|
7
|
+
*/
|
|
8
|
+
export class Database {
|
|
9
|
+
static __wrap(ptr) {
|
|
10
|
+
ptr = ptr >>> 0;
|
|
11
|
+
const obj = Object.create(Database.prototype);
|
|
12
|
+
obj.__wbg_ptr = ptr;
|
|
13
|
+
DatabaseFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
__destroy_into_raw() {
|
|
17
|
+
const ptr = this.__wbg_ptr;
|
|
18
|
+
this.__wbg_ptr = 0;
|
|
19
|
+
DatabaseFinalization.unregister(this);
|
|
20
|
+
return ptr;
|
|
21
|
+
}
|
|
22
|
+
free() {
|
|
23
|
+
const ptr = this.__destroy_into_raw();
|
|
24
|
+
wasm.__wbg_database_free(ptr, 0);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the number of edges in the database.
|
|
28
|
+
* @returns {number}
|
|
29
|
+
*/
|
|
30
|
+
edgeCount() {
|
|
31
|
+
const ret = wasm.database_edgeCount(this.__wbg_ptr);
|
|
32
|
+
return ret >>> 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Executes a GQL query and returns results as an array of objects.
|
|
36
|
+
*
|
|
37
|
+
* Each row becomes a JavaScript object with column names as keys.
|
|
38
|
+
*
|
|
39
|
+
* ```js
|
|
40
|
+
* const results = db.execute("MATCH (p:Person) RETURN p.name, p.age");
|
|
41
|
+
* // [{name: "Alix", age: 30}, {name: "Gus", age: 25}]
|
|
42
|
+
* ```
|
|
43
|
+
* @param {string} query
|
|
44
|
+
* @returns {any}
|
|
45
|
+
*/
|
|
46
|
+
execute(query) {
|
|
47
|
+
try {
|
|
48
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
49
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
50
|
+
const len0 = WASM_VECTOR_LEN;
|
|
51
|
+
wasm.database_execute(retptr, this.__wbg_ptr, ptr0, len0);
|
|
52
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
53
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
54
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
55
|
+
if (r2) {
|
|
56
|
+
throw takeObject(r1);
|
|
57
|
+
}
|
|
58
|
+
return takeObject(r0);
|
|
59
|
+
} finally {
|
|
60
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Executes a GQL query and returns raw columns, rows, and metadata.
|
|
65
|
+
*
|
|
66
|
+
* Returns `{ columns: string[], rows: any[][], executionTimeMs?: number }`.
|
|
67
|
+
* @param {string} query
|
|
68
|
+
* @returns {any}
|
|
69
|
+
*/
|
|
70
|
+
executeRaw(query) {
|
|
71
|
+
try {
|
|
72
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
73
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
74
|
+
const len0 = WASM_VECTOR_LEN;
|
|
75
|
+
wasm.database_executeRaw(retptr, this.__wbg_ptr, ptr0, len0);
|
|
76
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
77
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
78
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
79
|
+
if (r2) {
|
|
80
|
+
throw takeObject(r1);
|
|
81
|
+
}
|
|
82
|
+
return takeObject(r0);
|
|
83
|
+
} finally {
|
|
84
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Executes a query in a specific language and returns raw columns, rows, and metadata.
|
|
89
|
+
*
|
|
90
|
+
* Returns `{ columns: string[], rows: any[][], executionTimeMs?: number }`.
|
|
91
|
+
*
|
|
92
|
+
* ```js
|
|
93
|
+
* const raw = db.executeRawWithLanguage("MATCH (p:Person) RETURN p.name", "cypher");
|
|
94
|
+
* // { columns: ["p.name"], rows: [["Alix"], ["Gus"]], executionTimeMs: 0.5 }
|
|
95
|
+
* ```
|
|
96
|
+
* @param {string} query
|
|
97
|
+
* @param {string} language
|
|
98
|
+
* @returns {any}
|
|
99
|
+
*/
|
|
100
|
+
executeRawWithLanguage(query, language) {
|
|
101
|
+
try {
|
|
102
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
103
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
104
|
+
const len0 = WASM_VECTOR_LEN;
|
|
105
|
+
const ptr1 = passStringToWasm0(language, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
106
|
+
const len1 = WASM_VECTOR_LEN;
|
|
107
|
+
wasm.database_executeRawWithLanguage(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
108
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
109
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
110
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
111
|
+
if (r2) {
|
|
112
|
+
throw takeObject(r1);
|
|
113
|
+
}
|
|
114
|
+
return takeObject(r0);
|
|
115
|
+
} finally {
|
|
116
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Executes a query using a specific query language.
|
|
121
|
+
*
|
|
122
|
+
* Supported languages: `"gql"`, `"cypher"`, `"sparql"`, `"gremlin"`, `"graphql"`, `"graphql-rdf"`, `"sql"`.
|
|
123
|
+
* Languages require their corresponding feature flag to be enabled.
|
|
124
|
+
*
|
|
125
|
+
* ```js
|
|
126
|
+
* const results = db.executeWithLanguage(
|
|
127
|
+
* "MATCH (p:Person) RETURN p.name",
|
|
128
|
+
* "cypher"
|
|
129
|
+
* );
|
|
130
|
+
* ```
|
|
131
|
+
* @param {string} query
|
|
132
|
+
* @param {string} language
|
|
133
|
+
* @returns {any}
|
|
134
|
+
*/
|
|
135
|
+
executeWithLanguage(query, language) {
|
|
136
|
+
try {
|
|
137
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
138
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
139
|
+
const len0 = WASM_VECTOR_LEN;
|
|
140
|
+
const ptr1 = passStringToWasm0(language, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
141
|
+
const len1 = WASM_VECTOR_LEN;
|
|
142
|
+
wasm.database_executeWithLanguage(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
143
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
144
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
145
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
146
|
+
if (r2) {
|
|
147
|
+
throw takeObject(r1);
|
|
148
|
+
}
|
|
149
|
+
return takeObject(r0);
|
|
150
|
+
} finally {
|
|
151
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Executes a query using a specific language with parameters.
|
|
156
|
+
*
|
|
157
|
+
* Combines language selection with parameterised queries.
|
|
158
|
+
*
|
|
159
|
+
* ```js
|
|
160
|
+
* const results = db.executeWithLanguageAndParams(
|
|
161
|
+
* "MATCH (p:Person {name: $name}) RETURN p.name",
|
|
162
|
+
* "cypher",
|
|
163
|
+
* { name: "Alix" }
|
|
164
|
+
* );
|
|
165
|
+
* ```
|
|
166
|
+
* @param {string} query
|
|
167
|
+
* @param {string} language
|
|
168
|
+
* @param {any} params
|
|
169
|
+
* @returns {any}
|
|
170
|
+
*/
|
|
171
|
+
executeWithLanguageAndParams(query, language, params) {
|
|
172
|
+
try {
|
|
173
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
174
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
175
|
+
const len0 = WASM_VECTOR_LEN;
|
|
176
|
+
const ptr1 = passStringToWasm0(language, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
177
|
+
const len1 = WASM_VECTOR_LEN;
|
|
178
|
+
wasm.database_executeWithLanguageAndParams(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(params));
|
|
179
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
180
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
181
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
182
|
+
if (r2) {
|
|
183
|
+
throw takeObject(r1);
|
|
184
|
+
}
|
|
185
|
+
return takeObject(r0);
|
|
186
|
+
} finally {
|
|
187
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Executes a GQL query with parameters and returns results as an array of objects.
|
|
192
|
+
*
|
|
193
|
+
* Parameters are passed as a JavaScript object with string keys.
|
|
194
|
+
* Use `$name` syntax in the query to reference parameters.
|
|
195
|
+
*
|
|
196
|
+
* ```js
|
|
197
|
+
* const results = db.executeWithParams(
|
|
198
|
+
* "MATCH (p:Person {name: $name}) RETURN p.name, p.age",
|
|
199
|
+
* { name: "Alix" }
|
|
200
|
+
* );
|
|
201
|
+
* ```
|
|
202
|
+
* @param {string} query
|
|
203
|
+
* @param {any} params
|
|
204
|
+
* @returns {any}
|
|
205
|
+
*/
|
|
206
|
+
executeWithParams(query, params) {
|
|
207
|
+
try {
|
|
208
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
209
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
210
|
+
const len0 = WASM_VECTOR_LEN;
|
|
211
|
+
wasm.database_executeWithParams(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(params));
|
|
212
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
213
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
214
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
215
|
+
if (r2) {
|
|
216
|
+
throw takeObject(r1);
|
|
217
|
+
}
|
|
218
|
+
return takeObject(r0);
|
|
219
|
+
} finally {
|
|
220
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Exports the database to a binary snapshot.
|
|
225
|
+
*
|
|
226
|
+
* Returns a `Uint8Array` that can be stored in IndexedDB, localStorage,
|
|
227
|
+
* or sent over the network. Restore with `Database.importSnapshot()`.
|
|
228
|
+
*
|
|
229
|
+
* ```js
|
|
230
|
+
* const bytes = db.exportSnapshot();
|
|
231
|
+
* // Store in IndexedDB, download as file, etc.
|
|
232
|
+
* ```
|
|
233
|
+
* @returns {Uint8Array}
|
|
234
|
+
*/
|
|
235
|
+
exportSnapshot() {
|
|
236
|
+
try {
|
|
237
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
238
|
+
wasm.database_exportSnapshot(retptr, this.__wbg_ptr);
|
|
239
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
240
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
241
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
242
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
243
|
+
if (r3) {
|
|
244
|
+
throw takeObject(r2);
|
|
245
|
+
}
|
|
246
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
247
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
248
|
+
return v1;
|
|
249
|
+
} finally {
|
|
250
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Batch-imports LPG (Labeled Property Graph) data from a structured object.
|
|
255
|
+
*
|
|
256
|
+
* Nodes are created first, then edges. Edge `source`/`target` fields are
|
|
257
|
+
* zero-based indexes into the `nodes` array, so you can reference newly
|
|
258
|
+
* created nodes without knowing their database IDs.
|
|
259
|
+
*
|
|
260
|
+
* Returns `{ nodes: number, edges: number }` with the counts of created
|
|
261
|
+
* entities.
|
|
262
|
+
*
|
|
263
|
+
* ```js
|
|
264
|
+
* const result = db.importLpg({
|
|
265
|
+
* nodes: [
|
|
266
|
+
* { labels: ["Person"], properties: { name: "Alix", age: 30 } },
|
|
267
|
+
* { labels: ["Person"], properties: { name: "Gus", age: 25 } },
|
|
268
|
+
* ],
|
|
269
|
+
* edges: [
|
|
270
|
+
* { source: 0, target: 1, type: "KNOWS", properties: { since: 2020 } }
|
|
271
|
+
* ]
|
|
272
|
+
* });
|
|
273
|
+
* // { nodes: 2, edges: 1 }
|
|
274
|
+
* ```
|
|
275
|
+
* @param {any} data
|
|
276
|
+
* @returns {any}
|
|
277
|
+
*/
|
|
278
|
+
importLpg(data) {
|
|
279
|
+
try {
|
|
280
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
281
|
+
wasm.database_importLpg(retptr, this.__wbg_ptr, addHeapObject(data));
|
|
282
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
283
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
284
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
285
|
+
if (r2) {
|
|
286
|
+
throw takeObject(r1);
|
|
287
|
+
}
|
|
288
|
+
return takeObject(r0);
|
|
289
|
+
} finally {
|
|
290
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Bulk-imports rows (array of objects) as nodes or edges.
|
|
295
|
+
*
|
|
296
|
+
* This is the WASM equivalent of Python's `import_df()`: each object
|
|
297
|
+
* in the array becomes a node or edge, with object keys as property names.
|
|
298
|
+
*
|
|
299
|
+
* **Node import** (`mode: "nodes"`): requires `label` (string or string[]).
|
|
300
|
+
* All object keys become node properties.
|
|
301
|
+
*
|
|
302
|
+
* **Edge import** (`mode: "edges"`): requires `edgeType`. The `source`
|
|
303
|
+
* and `target` keys in each object must contain integer node IDs.
|
|
304
|
+
* Remaining keys become edge properties. Override column names with
|
|
305
|
+
* the `source` and `target` options (default `"source"` / `"target"`).
|
|
306
|
+
*
|
|
307
|
+
* Returns the number of created entities.
|
|
308
|
+
*
|
|
309
|
+
* ```js
|
|
310
|
+
* // Import nodes
|
|
311
|
+
* const count = db.importRows(
|
|
312
|
+
* [{ name: "Alix", age: 30 }, { name: "Gus", age: 25 }],
|
|
313
|
+
* { mode: "nodes", label: "Person" }
|
|
314
|
+
* );
|
|
315
|
+
*
|
|
316
|
+
* // Import edges
|
|
317
|
+
* const edgeCount = db.importRows(
|
|
318
|
+
* [{ source: 0, target: 1, since: 2020 }],
|
|
319
|
+
* { mode: "edges", edgeType: "KNOWS" }
|
|
320
|
+
* );
|
|
321
|
+
*
|
|
322
|
+
* // Custom source/target column names
|
|
323
|
+
* const edgeCount2 = db.importRows(
|
|
324
|
+
* [{ from: 0, to: 1 }],
|
|
325
|
+
* { mode: "edges", edgeType: "KNOWS", source: "from", target: "to" }
|
|
326
|
+
* );
|
|
327
|
+
* ```
|
|
328
|
+
* @param {any} rows
|
|
329
|
+
* @param {any} options
|
|
330
|
+
* @returns {number}
|
|
331
|
+
*/
|
|
332
|
+
importRows(rows, options) {
|
|
333
|
+
try {
|
|
334
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
335
|
+
wasm.database_importRows(retptr, this.__wbg_ptr, addHeapObject(rows), addHeapObject(options));
|
|
336
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
337
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
338
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
339
|
+
if (r2) {
|
|
340
|
+
throw takeObject(r1);
|
|
341
|
+
}
|
|
342
|
+
return r0 >>> 0;
|
|
343
|
+
} finally {
|
|
344
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Creates a database from a binary snapshot.
|
|
349
|
+
*
|
|
350
|
+
* The `data` must have been produced by `exportSnapshot()`.
|
|
351
|
+
*
|
|
352
|
+
* ```js
|
|
353
|
+
* const db = Database.importSnapshot(bytes);
|
|
354
|
+
* ```
|
|
355
|
+
* @param {Uint8Array} data
|
|
356
|
+
* @returns {Database}
|
|
357
|
+
*/
|
|
358
|
+
static importSnapshot(data) {
|
|
359
|
+
try {
|
|
360
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
361
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
362
|
+
const len0 = WASM_VECTOR_LEN;
|
|
363
|
+
wasm.database_importSnapshot(retptr, ptr0, len0);
|
|
364
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
365
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
366
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
367
|
+
if (r2) {
|
|
368
|
+
throw takeObject(r1);
|
|
369
|
+
}
|
|
370
|
+
return Database.__wrap(r0);
|
|
371
|
+
} finally {
|
|
372
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Returns a hierarchical memory usage breakdown.
|
|
377
|
+
*
|
|
378
|
+
* The returned object mirrors the engine's `MemoryUsage` struct with
|
|
379
|
+
* `totalBytes`, `store`, `indexes`, `mvcc`, `caches`, `stringPool`,
|
|
380
|
+
* and `bufferManager` sections.
|
|
381
|
+
*
|
|
382
|
+
* ```js
|
|
383
|
+
* const usage = db.memoryUsage();
|
|
384
|
+
* console.log(`Total: ${usage.total_bytes} bytes`);
|
|
385
|
+
* console.log(`Store: ${usage.store.total_bytes} bytes`);
|
|
386
|
+
* console.log(`Indexes: ${usage.indexes.total_bytes} bytes`);
|
|
387
|
+
* ```
|
|
388
|
+
* @returns {any}
|
|
389
|
+
*/
|
|
390
|
+
memoryUsage() {
|
|
391
|
+
try {
|
|
392
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
393
|
+
wasm.database_memoryUsage(retptr, this.__wbg_ptr);
|
|
394
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
395
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
396
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
397
|
+
if (r2) {
|
|
398
|
+
throw takeObject(r1);
|
|
399
|
+
}
|
|
400
|
+
return takeObject(r0);
|
|
401
|
+
} finally {
|
|
402
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Creates a new in-memory database.
|
|
407
|
+
*/
|
|
408
|
+
constructor() {
|
|
409
|
+
try {
|
|
410
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
411
|
+
wasm.database_new(retptr);
|
|
412
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
413
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
414
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
415
|
+
if (r2) {
|
|
416
|
+
throw takeObject(r1);
|
|
417
|
+
}
|
|
418
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
419
|
+
DatabaseFinalization.register(this, this.__wbg_ptr, this);
|
|
420
|
+
return this;
|
|
421
|
+
} finally {
|
|
422
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Returns the number of nodes in the database.
|
|
427
|
+
* @returns {number}
|
|
428
|
+
*/
|
|
429
|
+
nodeCount() {
|
|
430
|
+
const ret = wasm.database_nodeCount(this.__wbg_ptr);
|
|
431
|
+
return ret >>> 0;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Returns schema information about the database.
|
|
435
|
+
*
|
|
436
|
+
* Returns an object describing labels, edge types, and property keys.
|
|
437
|
+
*
|
|
438
|
+
* ```js
|
|
439
|
+
* const schema = db.schema();
|
|
440
|
+
* // { lpg: { labels: [...], edgeTypes: [...], propertyKeys: [...] } }
|
|
441
|
+
* ```
|
|
442
|
+
* @returns {any}
|
|
443
|
+
*/
|
|
444
|
+
schema() {
|
|
445
|
+
try {
|
|
446
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
447
|
+
wasm.database_schema(retptr, this.__wbg_ptr);
|
|
448
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
449
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
450
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
451
|
+
if (r2) {
|
|
452
|
+
throw takeObject(r1);
|
|
453
|
+
}
|
|
454
|
+
return takeObject(r0);
|
|
455
|
+
} finally {
|
|
456
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Returns the Grafeo version.
|
|
461
|
+
* @returns {string}
|
|
462
|
+
*/
|
|
463
|
+
static version() {
|
|
464
|
+
let deferred1_0;
|
|
465
|
+
let deferred1_1;
|
|
466
|
+
try {
|
|
467
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
468
|
+
wasm.database_version(retptr);
|
|
469
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
470
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
471
|
+
deferred1_0 = r0;
|
|
472
|
+
deferred1_1 = r1;
|
|
473
|
+
return getStringFromWasm0(r0, r1);
|
|
474
|
+
} finally {
|
|
475
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
476
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (Symbol.dispose) Database.prototype[Symbol.dispose] = Database.prototype.free;
|
|
481
|
+
export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
|
|
482
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
483
|
+
return addHeapObject(ret);
|
|
484
|
+
}
|
|
485
|
+
export function __wbg_Number_a5a435bd7bbec835(arg0) {
|
|
486
|
+
const ret = Number(getObject(arg0));
|
|
487
|
+
return ret;
|
|
488
|
+
}
|
|
489
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
490
|
+
const ret = String(getObject(arg1));
|
|
491
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
492
|
+
const len1 = WASM_VECTOR_LEN;
|
|
493
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
494
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
495
|
+
}
|
|
496
|
+
export function __wbg___wbindgen_bigint_get_as_i64_447a76b5c6ef7bda(arg0, arg1) {
|
|
497
|
+
const v = getObject(arg1);
|
|
498
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
499
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
500
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
501
|
+
}
|
|
502
|
+
export function __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1(arg0) {
|
|
503
|
+
const v = getObject(arg0);
|
|
504
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
505
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
506
|
+
}
|
|
507
|
+
export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
|
|
508
|
+
const ret = debugString(getObject(arg1));
|
|
509
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
510
|
+
const len1 = WASM_VECTOR_LEN;
|
|
511
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
512
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
513
|
+
}
|
|
514
|
+
export function __wbg___wbindgen_in_41dbb8413020e076(arg0, arg1) {
|
|
515
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
516
|
+
return ret;
|
|
517
|
+
}
|
|
518
|
+
export function __wbg___wbindgen_is_bigint_e2141d4f045b7eda(arg0) {
|
|
519
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
520
|
+
return ret;
|
|
521
|
+
}
|
|
522
|
+
export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
|
|
523
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
524
|
+
return ret;
|
|
525
|
+
}
|
|
526
|
+
export function __wbg___wbindgen_is_null_0b605fc6b167c56f(arg0) {
|
|
527
|
+
const ret = getObject(arg0) === null;
|
|
528
|
+
return ret;
|
|
529
|
+
}
|
|
530
|
+
export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
|
|
531
|
+
const val = getObject(arg0);
|
|
532
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
533
|
+
return ret;
|
|
534
|
+
}
|
|
535
|
+
export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
|
|
536
|
+
const ret = getObject(arg0) === undefined;
|
|
537
|
+
return ret;
|
|
538
|
+
}
|
|
539
|
+
export function __wbg___wbindgen_jsval_eq_ee31bfad3e536463(arg0, arg1) {
|
|
540
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
541
|
+
return ret;
|
|
542
|
+
}
|
|
543
|
+
export function __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b(arg0, arg1) {
|
|
544
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
545
|
+
return ret;
|
|
546
|
+
}
|
|
547
|
+
export function __wbg___wbindgen_number_get_34bb9d9dcfa21373(arg0, arg1) {
|
|
548
|
+
const obj = getObject(arg1);
|
|
549
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
550
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
551
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
552
|
+
}
|
|
553
|
+
export function __wbg___wbindgen_string_get_395e606bd0ee4427(arg0, arg1) {
|
|
554
|
+
const obj = getObject(arg1);
|
|
555
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
556
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
557
|
+
var len1 = WASM_VECTOR_LEN;
|
|
558
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
559
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
560
|
+
}
|
|
561
|
+
export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
|
|
562
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
563
|
+
}
|
|
564
|
+
export function __wbg_call_e133b57c9155d22c() { return handleError(function (arg0, arg1) {
|
|
565
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
566
|
+
return addHeapObject(ret);
|
|
567
|
+
}, arguments); }
|
|
568
|
+
export function __wbg_done_08ce71ee07e3bd17(arg0) {
|
|
569
|
+
const ret = getObject(arg0).done;
|
|
570
|
+
return ret;
|
|
571
|
+
}
|
|
572
|
+
export function __wbg_entries_e8a20ff8c9757101(arg0) {
|
|
573
|
+
const ret = Object.entries(getObject(arg0));
|
|
574
|
+
return addHeapObject(ret);
|
|
575
|
+
}
|
|
576
|
+
export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
|
|
577
|
+
let deferred0_0;
|
|
578
|
+
let deferred0_1;
|
|
579
|
+
try {
|
|
580
|
+
deferred0_0 = arg0;
|
|
581
|
+
deferred0_1 = arg1;
|
|
582
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
583
|
+
} finally {
|
|
584
|
+
wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
export function __wbg_get_326e41e095fb2575() { return handleError(function (arg0, arg1) {
|
|
588
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
589
|
+
return addHeapObject(ret);
|
|
590
|
+
}, arguments); }
|
|
591
|
+
export function __wbg_get_a8ee5c45dabc1b3b(arg0, arg1) {
|
|
592
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
593
|
+
return addHeapObject(ret);
|
|
594
|
+
}
|
|
595
|
+
export function __wbg_get_unchecked_329cfe50afab7352(arg0, arg1) {
|
|
596
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
597
|
+
return addHeapObject(ret);
|
|
598
|
+
}
|
|
599
|
+
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
600
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
601
|
+
return addHeapObject(ret);
|
|
602
|
+
}
|
|
603
|
+
export function __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6(arg0) {
|
|
604
|
+
let result;
|
|
605
|
+
try {
|
|
606
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
607
|
+
} catch (_) {
|
|
608
|
+
result = false;
|
|
609
|
+
}
|
|
610
|
+
const ret = result;
|
|
611
|
+
return ret;
|
|
612
|
+
}
|
|
613
|
+
export function __wbg_instanceof_Map_f194b366846aca0c(arg0) {
|
|
614
|
+
let result;
|
|
615
|
+
try {
|
|
616
|
+
result = getObject(arg0) instanceof Map;
|
|
617
|
+
} catch (_) {
|
|
618
|
+
result = false;
|
|
619
|
+
}
|
|
620
|
+
const ret = result;
|
|
621
|
+
return ret;
|
|
622
|
+
}
|
|
623
|
+
export function __wbg_instanceof_Uint8Array_740438561a5b956d(arg0) {
|
|
624
|
+
let result;
|
|
625
|
+
try {
|
|
626
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
627
|
+
} catch (_) {
|
|
628
|
+
result = false;
|
|
629
|
+
}
|
|
630
|
+
const ret = result;
|
|
631
|
+
return ret;
|
|
632
|
+
}
|
|
633
|
+
export function __wbg_isArray_33b91feb269ff46e(arg0) {
|
|
634
|
+
const ret = Array.isArray(getObject(arg0));
|
|
635
|
+
return ret;
|
|
636
|
+
}
|
|
637
|
+
export function __wbg_isSafeInteger_ecd6a7f9c3e053cd(arg0) {
|
|
638
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
639
|
+
return ret;
|
|
640
|
+
}
|
|
641
|
+
export function __wbg_iterator_d8f549ec8fb061b1() {
|
|
642
|
+
const ret = Symbol.iterator;
|
|
643
|
+
return addHeapObject(ret);
|
|
644
|
+
}
|
|
645
|
+
export function __wbg_length_259ee9d041e381ad(arg0) {
|
|
646
|
+
const ret = getObject(arg0).length;
|
|
647
|
+
return ret;
|
|
648
|
+
}
|
|
649
|
+
export function __wbg_length_b3416cf66a5452c8(arg0) {
|
|
650
|
+
const ret = getObject(arg0).length;
|
|
651
|
+
return ret;
|
|
652
|
+
}
|
|
653
|
+
export function __wbg_length_ea16607d7b61445b(arg0) {
|
|
654
|
+
const ret = getObject(arg0).length;
|
|
655
|
+
return ret;
|
|
656
|
+
}
|
|
657
|
+
export function __wbg_new_227d7c05414eb861() {
|
|
658
|
+
const ret = new Error();
|
|
659
|
+
return addHeapObject(ret);
|
|
660
|
+
}
|
|
661
|
+
export function __wbg_new_5f486cdf45a04d78(arg0) {
|
|
662
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
663
|
+
return addHeapObject(ret);
|
|
664
|
+
}
|
|
665
|
+
export function __wbg_new_a70fbab9066b301f() {
|
|
666
|
+
const ret = new Array();
|
|
667
|
+
return addHeapObject(ret);
|
|
668
|
+
}
|
|
669
|
+
export function __wbg_new_ab79df5bd7c26067() {
|
|
670
|
+
const ret = new Object();
|
|
671
|
+
return addHeapObject(ret);
|
|
672
|
+
}
|
|
673
|
+
export function __wbg_new_with_length_3259a525196bd8cc(arg0) {
|
|
674
|
+
const ret = new Array(arg0 >>> 0);
|
|
675
|
+
return addHeapObject(ret);
|
|
676
|
+
}
|
|
677
|
+
export function __wbg_new_with_length_81c1c31d4432cb9f(arg0) {
|
|
678
|
+
const ret = new Float32Array(arg0 >>> 0);
|
|
679
|
+
return addHeapObject(ret);
|
|
680
|
+
}
|
|
681
|
+
export function __wbg_new_with_length_825018a1616e9e55(arg0) {
|
|
682
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
683
|
+
return addHeapObject(ret);
|
|
684
|
+
}
|
|
685
|
+
export function __wbg_next_11b99ee6237339e3() { return handleError(function (arg0) {
|
|
686
|
+
const ret = getObject(arg0).next();
|
|
687
|
+
return addHeapObject(ret);
|
|
688
|
+
}, arguments); }
|
|
689
|
+
export function __wbg_next_e01a967809d1aa68(arg0) {
|
|
690
|
+
const ret = getObject(arg0).next;
|
|
691
|
+
return addHeapObject(ret);
|
|
692
|
+
}
|
|
693
|
+
export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
|
|
694
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
695
|
+
}
|
|
696
|
+
export function __wbg_set_282384002438957f(arg0, arg1, arg2) {
|
|
697
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
698
|
+
}
|
|
699
|
+
export function __wbg_set_361bc2460da3016f(arg0, arg1, arg2) {
|
|
700
|
+
getObject(arg0).set(getArrayF32FromWasm0(arg1, arg2));
|
|
701
|
+
}
|
|
702
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
703
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
704
|
+
}
|
|
705
|
+
export function __wbg_set_7eaa4f96924fd6b3() { return handleError(function (arg0, arg1, arg2) {
|
|
706
|
+
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
707
|
+
return ret;
|
|
708
|
+
}, arguments); }
|
|
709
|
+
export function __wbg_set_8c0b3ffcf05d61c2(arg0, arg1, arg2) {
|
|
710
|
+
getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));
|
|
711
|
+
}
|
|
712
|
+
export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
713
|
+
const ret = getObject(arg1).stack;
|
|
714
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
715
|
+
const len1 = WASM_VECTOR_LEN;
|
|
716
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
717
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
718
|
+
}
|
|
719
|
+
export function __wbg_value_21fc78aab0322612(arg0) {
|
|
720
|
+
const ret = getObject(arg0).value;
|
|
721
|
+
return addHeapObject(ret);
|
|
722
|
+
}
|
|
723
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
724
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
725
|
+
const ret = arg0;
|
|
726
|
+
return addHeapObject(ret);
|
|
727
|
+
}
|
|
728
|
+
export function __wbindgen_cast_0000000000000002(arg0) {
|
|
729
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
730
|
+
const ret = arg0;
|
|
731
|
+
return addHeapObject(ret);
|
|
732
|
+
}
|
|
733
|
+
export function __wbindgen_cast_0000000000000003(arg0, arg1) {
|
|
734
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
735
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
736
|
+
return addHeapObject(ret);
|
|
737
|
+
}
|
|
738
|
+
export function __wbindgen_cast_0000000000000004(arg0) {
|
|
739
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
740
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
741
|
+
return addHeapObject(ret);
|
|
742
|
+
}
|
|
743
|
+
export function __wbindgen_object_clone_ref(arg0) {
|
|
744
|
+
const ret = getObject(arg0);
|
|
745
|
+
return addHeapObject(ret);
|
|
746
|
+
}
|
|
747
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
748
|
+
takeObject(arg0);
|
|
749
|
+
}
|
|
750
|
+
const DatabaseFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
751
|
+
? { register: () => {}, unregister: () => {} }
|
|
752
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_database_free(ptr >>> 0, 1));
|
|
753
|
+
|
|
754
|
+
function addHeapObject(obj) {
|
|
755
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
756
|
+
const idx = heap_next;
|
|
757
|
+
heap_next = heap[idx];
|
|
758
|
+
|
|
759
|
+
heap[idx] = obj;
|
|
760
|
+
return idx;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function debugString(val) {
|
|
764
|
+
// primitive types
|
|
765
|
+
const type = typeof val;
|
|
766
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
767
|
+
return `${val}`;
|
|
768
|
+
}
|
|
769
|
+
if (type == 'string') {
|
|
770
|
+
return `"${val}"`;
|
|
771
|
+
}
|
|
772
|
+
if (type == 'symbol') {
|
|
773
|
+
const description = val.description;
|
|
774
|
+
if (description == null) {
|
|
775
|
+
return 'Symbol';
|
|
776
|
+
} else {
|
|
777
|
+
return `Symbol(${description})`;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (type == 'function') {
|
|
781
|
+
const name = val.name;
|
|
782
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
783
|
+
return `Function(${name})`;
|
|
784
|
+
} else {
|
|
785
|
+
return 'Function';
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
// objects
|
|
789
|
+
if (Array.isArray(val)) {
|
|
790
|
+
const length = val.length;
|
|
791
|
+
let debug = '[';
|
|
792
|
+
if (length > 0) {
|
|
793
|
+
debug += debugString(val[0]);
|
|
794
|
+
}
|
|
795
|
+
for(let i = 1; i < length; i++) {
|
|
796
|
+
debug += ', ' + debugString(val[i]);
|
|
797
|
+
}
|
|
798
|
+
debug += ']';
|
|
799
|
+
return debug;
|
|
800
|
+
}
|
|
801
|
+
// Test for built-in
|
|
802
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
803
|
+
let className;
|
|
804
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
805
|
+
className = builtInMatches[1];
|
|
806
|
+
} else {
|
|
807
|
+
// Failed to match the standard '[object ClassName]'
|
|
808
|
+
return toString.call(val);
|
|
809
|
+
}
|
|
810
|
+
if (className == 'Object') {
|
|
811
|
+
// we're a user defined class or Object
|
|
812
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
813
|
+
// easier than looping through ownProperties of `val`.
|
|
814
|
+
try {
|
|
815
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
816
|
+
} catch (_) {
|
|
817
|
+
return 'Object';
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
// errors
|
|
821
|
+
if (val instanceof Error) {
|
|
822
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
823
|
+
}
|
|
824
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
825
|
+
return className;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
function dropObject(idx) {
|
|
829
|
+
if (idx < 1028) return;
|
|
830
|
+
heap[idx] = heap_next;
|
|
831
|
+
heap_next = idx;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
835
|
+
ptr = ptr >>> 0;
|
|
836
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
840
|
+
ptr = ptr >>> 0;
|
|
841
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
let cachedDataViewMemory0 = null;
|
|
845
|
+
function getDataViewMemory0() {
|
|
846
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
847
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
848
|
+
}
|
|
849
|
+
return cachedDataViewMemory0;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
853
|
+
function getFloat32ArrayMemory0() {
|
|
854
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
855
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
856
|
+
}
|
|
857
|
+
return cachedFloat32ArrayMemory0;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function getStringFromWasm0(ptr, len) {
|
|
861
|
+
ptr = ptr >>> 0;
|
|
862
|
+
return decodeText(ptr, len);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
let cachedUint8ArrayMemory0 = null;
|
|
866
|
+
function getUint8ArrayMemory0() {
|
|
867
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
868
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
869
|
+
}
|
|
870
|
+
return cachedUint8ArrayMemory0;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function getObject(idx) { return heap[idx]; }
|
|
874
|
+
|
|
875
|
+
function handleError(f, args) {
|
|
876
|
+
try {
|
|
877
|
+
return f.apply(this, args);
|
|
878
|
+
} catch (e) {
|
|
879
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
let heap = new Array(1024).fill(undefined);
|
|
884
|
+
heap.push(undefined, null, true, false);
|
|
885
|
+
|
|
886
|
+
let heap_next = heap.length;
|
|
887
|
+
|
|
888
|
+
function isLikeNone(x) {
|
|
889
|
+
return x === undefined || x === null;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
893
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
894
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
895
|
+
WASM_VECTOR_LEN = arg.length;
|
|
896
|
+
return ptr;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
900
|
+
if (realloc === undefined) {
|
|
901
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
902
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
903
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
904
|
+
WASM_VECTOR_LEN = buf.length;
|
|
905
|
+
return ptr;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
let len = arg.length;
|
|
909
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
910
|
+
|
|
911
|
+
const mem = getUint8ArrayMemory0();
|
|
912
|
+
|
|
913
|
+
let offset = 0;
|
|
914
|
+
|
|
915
|
+
for (; offset < len; offset++) {
|
|
916
|
+
const code = arg.charCodeAt(offset);
|
|
917
|
+
if (code > 0x7F) break;
|
|
918
|
+
mem[ptr + offset] = code;
|
|
919
|
+
}
|
|
920
|
+
if (offset !== len) {
|
|
921
|
+
if (offset !== 0) {
|
|
922
|
+
arg = arg.slice(offset);
|
|
923
|
+
}
|
|
924
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
925
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
926
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
927
|
+
|
|
928
|
+
offset += ret.written;
|
|
929
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
WASM_VECTOR_LEN = offset;
|
|
933
|
+
return ptr;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function takeObject(idx) {
|
|
937
|
+
const ret = getObject(idx);
|
|
938
|
+
dropObject(idx);
|
|
939
|
+
return ret;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
943
|
+
cachedTextDecoder.decode();
|
|
944
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
945
|
+
let numBytesDecoded = 0;
|
|
946
|
+
function decodeText(ptr, len) {
|
|
947
|
+
numBytesDecoded += len;
|
|
948
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
949
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
950
|
+
cachedTextDecoder.decode();
|
|
951
|
+
numBytesDecoded = len;
|
|
952
|
+
}
|
|
953
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
const cachedTextEncoder = new TextEncoder();
|
|
957
|
+
|
|
958
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
959
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
960
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
961
|
+
view.set(buf);
|
|
962
|
+
return {
|
|
963
|
+
read: arg.length,
|
|
964
|
+
written: buf.length
|
|
965
|
+
};
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
let WASM_VECTOR_LEN = 0;
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
let wasm;
|
|
973
|
+
export function __wbg_set_wasm(val) {
|
|
974
|
+
wasm = val;
|
|
975
|
+
}
|
package/grafeo_wasm_bg.wasm
CHANGED
|
Binary file
|
package/grafeo_wasm_bg.wasm.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ export const database_executeWithLanguage: (a: number, b: number, c: number, d:
|
|
|
10
10
|
export const database_executeWithLanguageAndParams: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
11
11
|
export const database_executeWithParams: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
12
12
|
export const database_exportSnapshot: (a: number, b: number) => void;
|
|
13
|
+
export const database_importLpg: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const database_importRows: (a: number, b: number, c: number, d: number) => void;
|
|
13
15
|
export const database_importSnapshot: (a: number, b: number, c: number) => void;
|
|
16
|
+
export const database_memoryUsage: (a: number, b: number) => void;
|
|
14
17
|
export const database_new: (a: number) => void;
|
|
15
18
|
export const database_nodeCount: (a: number) => number;
|
|
16
19
|
export const database_schema: (a: number, b: number) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafeo-db/wasm-lite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.20",
|
|
5
5
|
"description": "WebAssembly bindings for Grafeo - GQL-only lightweight variant",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"graph",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"grafeo_wasm.js",
|
|
29
29
|
"grafeo_wasm.d.ts",
|
|
30
|
+
"grafeo_wasm_bg.js",
|
|
30
31
|
"grafeo_wasm_bg.wasm",
|
|
31
32
|
"grafeo_wasm_bg.wasm.d.ts"
|
|
32
33
|
],
|