rete-graph 0.1.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 +79 -0
- package/dist/index.js +1436 -0
- package/dist/rete-graph.js +1492 -0
- package/dist/rete-graph.min.js +22 -0
- package/dist/rete_wasm_bg.wasm +0 -0
- package/index.d.ts +65 -0
- package/package.json +33 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1436 @@
|
|
|
1
|
+
/*! rete-graph v0.1.0 | Apache-2.0 | https://github.com/caviri/rete */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __esm = (fn, res) => function __init() {
|
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
};
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/node-sync-xhr.js
|
|
13
|
+
var node_sync_xhr_exports = {};
|
|
14
|
+
__export(node_sync_xhr_exports, {
|
|
15
|
+
NodeSyncXMLHttpRequest: () => NodeSyncXMLHttpRequest,
|
|
16
|
+
install: () => install
|
|
17
|
+
});
|
|
18
|
+
import { MessageChannel, Worker, receiveMessageOnPort } from "node:worker_threads";
|
|
19
|
+
function syncFetch(method, url, headers, body) {
|
|
20
|
+
if (!worker) {
|
|
21
|
+
worker = new Worker(WORKER_SRC, { eval: true });
|
|
22
|
+
worker.unref();
|
|
23
|
+
}
|
|
24
|
+
const signal = new Int32Array(new SharedArrayBuffer(4));
|
|
25
|
+
const { port1, port2 } = new MessageChannel();
|
|
26
|
+
worker.postMessage({ port: port2, signal, method, url, headers, body }, [port2]);
|
|
27
|
+
Atomics.wait(signal, 0, 0);
|
|
28
|
+
const msg = receiveMessageOnPort(port1);
|
|
29
|
+
port1.close();
|
|
30
|
+
if (!msg) throw new Error(`sync fetch: no response for ${method} ${url}`);
|
|
31
|
+
if (msg.message.error) throw new Error(`sync fetch failed: ${msg.message.error}`);
|
|
32
|
+
return msg.message;
|
|
33
|
+
}
|
|
34
|
+
function install() {
|
|
35
|
+
if (typeof globalThis.XMLHttpRequest === "undefined") {
|
|
36
|
+
globalThis.XMLHttpRequest = NodeSyncXMLHttpRequest;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
var WORKER_SRC, worker, NodeSyncXMLHttpRequest;
|
|
40
|
+
var init_node_sync_xhr = __esm({
|
|
41
|
+
"src/node-sync-xhr.js"() {
|
|
42
|
+
WORKER_SRC = `
|
|
43
|
+
const { parentPort } = require("node:worker_threads");
|
|
44
|
+
parentPort.on("message", async ({ port, signal, method, url, headers, body }) => {
|
|
45
|
+
const result = { status: 0, headers: {}, body: null, error: null };
|
|
46
|
+
try {
|
|
47
|
+
const resp = await fetch(url, { method, headers, body: body ?? undefined });
|
|
48
|
+
result.status = resp.status;
|
|
49
|
+
for (const [k, v] of resp.headers) result.headers[k.toLowerCase()] = v;
|
|
50
|
+
result.body = await resp.arrayBuffer();
|
|
51
|
+
} catch (e) {
|
|
52
|
+
result.error = String(e);
|
|
53
|
+
}
|
|
54
|
+
port.postMessage(result, result.body ? [result.body] : []);
|
|
55
|
+
port.close();
|
|
56
|
+
Atomics.store(signal, 0, 1);
|
|
57
|
+
Atomics.notify(signal, 0);
|
|
58
|
+
});
|
|
59
|
+
`;
|
|
60
|
+
worker = null;
|
|
61
|
+
NodeSyncXMLHttpRequest = class {
|
|
62
|
+
#method;
|
|
63
|
+
#url;
|
|
64
|
+
#headers = {};
|
|
65
|
+
#resp = null;
|
|
66
|
+
responseType = "";
|
|
67
|
+
open(method, url, async = false) {
|
|
68
|
+
if (async) throw new Error("NodeSyncXMLHttpRequest only supports synchronous mode");
|
|
69
|
+
this.#method = method;
|
|
70
|
+
this.#url = url;
|
|
71
|
+
}
|
|
72
|
+
setRequestHeader(name, value) {
|
|
73
|
+
this.#headers[name] = value;
|
|
74
|
+
}
|
|
75
|
+
overrideMimeType() {
|
|
76
|
+
}
|
|
77
|
+
send(body = null) {
|
|
78
|
+
this.#resp = syncFetch(this.#method, this.#url, this.#headers, body);
|
|
79
|
+
}
|
|
80
|
+
get status() {
|
|
81
|
+
return this.#resp?.status ?? 0;
|
|
82
|
+
}
|
|
83
|
+
getResponseHeader(name) {
|
|
84
|
+
return this.#resp?.headers[String(name).toLowerCase()] ?? null;
|
|
85
|
+
}
|
|
86
|
+
get responseText() {
|
|
87
|
+
return new TextDecoder().decode(this.#resp?.body ?? new ArrayBuffer(0));
|
|
88
|
+
}
|
|
89
|
+
get response() {
|
|
90
|
+
if (this.responseType === "arraybuffer") return this.#resp?.body ?? new ArrayBuffer(0);
|
|
91
|
+
return this.responseText;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// vendor/pkg/rete_wasm.js
|
|
98
|
+
var Graph = class {
|
|
99
|
+
__destroy_into_raw() {
|
|
100
|
+
const ptr = this.__wbg_ptr;
|
|
101
|
+
this.__wbg_ptr = 0;
|
|
102
|
+
GraphFinalization.unregister(this);
|
|
103
|
+
return ptr;
|
|
104
|
+
}
|
|
105
|
+
free() {
|
|
106
|
+
const ptr = this.__destroy_into_raw();
|
|
107
|
+
wasm.__wbg_graph_free(ptr, 0);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* See [`file_layout`].
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
file_layout() {
|
|
114
|
+
let deferred2_0;
|
|
115
|
+
let deferred2_1;
|
|
116
|
+
try {
|
|
117
|
+
const ret = wasm.graph_file_layout(this.__wbg_ptr);
|
|
118
|
+
var ptr1 = ret[0];
|
|
119
|
+
var len1 = ret[1];
|
|
120
|
+
if (ret[3]) {
|
|
121
|
+
ptr1 = 0;
|
|
122
|
+
len1 = 0;
|
|
123
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
124
|
+
}
|
|
125
|
+
deferred2_0 = ptr1;
|
|
126
|
+
deferred2_1 = len1;
|
|
127
|
+
return getStringFromWasm0(ptr1, len1);
|
|
128
|
+
} finally {
|
|
129
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* See [`graph_names`].
|
|
134
|
+
* @returns {string}
|
|
135
|
+
*/
|
|
136
|
+
graph_names() {
|
|
137
|
+
let deferred2_0;
|
|
138
|
+
let deferred2_1;
|
|
139
|
+
try {
|
|
140
|
+
const ret = wasm.graph_graph_names(this.__wbg_ptr);
|
|
141
|
+
var ptr1 = ret[0];
|
|
142
|
+
var len1 = ret[1];
|
|
143
|
+
if (ret[3]) {
|
|
144
|
+
ptr1 = 0;
|
|
145
|
+
len1 = 0;
|
|
146
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
147
|
+
}
|
|
148
|
+
deferred2_0 = ptr1;
|
|
149
|
+
deferred2_1 = len1;
|
|
150
|
+
return getStringFromWasm0(ptr1, len1);
|
|
151
|
+
} finally {
|
|
152
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* See [`info`].
|
|
157
|
+
* @returns {string}
|
|
158
|
+
*/
|
|
159
|
+
info() {
|
|
160
|
+
let deferred1_0;
|
|
161
|
+
let deferred1_1;
|
|
162
|
+
try {
|
|
163
|
+
const ret = wasm.graph_info(this.__wbg_ptr);
|
|
164
|
+
deferred1_0 = ret[0];
|
|
165
|
+
deferred1_1 = ret[1];
|
|
166
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
167
|
+
} finally {
|
|
168
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Open a `.rete` image and keep it resident for repeated querying.
|
|
173
|
+
* @param {Uint8Array} bytes
|
|
174
|
+
*/
|
|
175
|
+
constructor(bytes) {
|
|
176
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
177
|
+
const len0 = WASM_VECTOR_LEN;
|
|
178
|
+
const ret = wasm.graph_new(ptr0, len0);
|
|
179
|
+
if (ret[2]) {
|
|
180
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
181
|
+
}
|
|
182
|
+
this.__wbg_ptr = ret[0];
|
|
183
|
+
GraphFinalization.register(this, this.__wbg_ptr, this);
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* See [`prefix_search`].
|
|
188
|
+
* @param {string} prefix
|
|
189
|
+
* @param {number} limit
|
|
190
|
+
* @returns {string}
|
|
191
|
+
*/
|
|
192
|
+
prefix_search(prefix, limit) {
|
|
193
|
+
let deferred3_0;
|
|
194
|
+
let deferred3_1;
|
|
195
|
+
try {
|
|
196
|
+
const ptr0 = passStringToWasm0(prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
197
|
+
const len0 = WASM_VECTOR_LEN;
|
|
198
|
+
const ret = wasm.graph_prefix_search(this.__wbg_ptr, ptr0, len0, limit);
|
|
199
|
+
var ptr2 = ret[0];
|
|
200
|
+
var len2 = ret[1];
|
|
201
|
+
if (ret[3]) {
|
|
202
|
+
ptr2 = 0;
|
|
203
|
+
len2 = 0;
|
|
204
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
205
|
+
}
|
|
206
|
+
deferred3_0 = ptr2;
|
|
207
|
+
deferred3_1 = len2;
|
|
208
|
+
return getStringFromWasm0(ptr2, len2);
|
|
209
|
+
} finally {
|
|
210
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* See [`pyramid_tree`].
|
|
215
|
+
* @returns {string}
|
|
216
|
+
*/
|
|
217
|
+
pyramid_tree() {
|
|
218
|
+
let deferred2_0;
|
|
219
|
+
let deferred2_1;
|
|
220
|
+
try {
|
|
221
|
+
const ret = wasm.graph_pyramid_tree(this.__wbg_ptr);
|
|
222
|
+
var ptr1 = ret[0];
|
|
223
|
+
var len1 = ret[1];
|
|
224
|
+
if (ret[3]) {
|
|
225
|
+
ptr1 = 0;
|
|
226
|
+
len1 = 0;
|
|
227
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
228
|
+
}
|
|
229
|
+
deferred2_0 = ptr1;
|
|
230
|
+
deferred2_1 = len1;
|
|
231
|
+
return getStringFromWasm0(ptr1, len1);
|
|
232
|
+
} finally {
|
|
233
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* See [`query`].
|
|
238
|
+
* @param {string} query
|
|
239
|
+
* @param {string} format
|
|
240
|
+
* @returns {string}
|
|
241
|
+
*/
|
|
242
|
+
query(query, format) {
|
|
243
|
+
let deferred4_0;
|
|
244
|
+
let deferred4_1;
|
|
245
|
+
try {
|
|
246
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
247
|
+
const len0 = WASM_VECTOR_LEN;
|
|
248
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
249
|
+
const len1 = WASM_VECTOR_LEN;
|
|
250
|
+
const ret = wasm.graph_query(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
251
|
+
var ptr3 = ret[0];
|
|
252
|
+
var len3 = ret[1];
|
|
253
|
+
if (ret[3]) {
|
|
254
|
+
ptr3 = 0;
|
|
255
|
+
len3 = 0;
|
|
256
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
257
|
+
}
|
|
258
|
+
deferred4_0 = ptr3;
|
|
259
|
+
deferred4_1 = len3;
|
|
260
|
+
return getStringFromWasm0(ptr3, len3);
|
|
261
|
+
} finally {
|
|
262
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* See [`query_communities`].
|
|
267
|
+
* @param {string} query
|
|
268
|
+
* @param {number | null} [round]
|
|
269
|
+
* @returns {string}
|
|
270
|
+
*/
|
|
271
|
+
query_communities(query, round) {
|
|
272
|
+
let deferred3_0;
|
|
273
|
+
let deferred3_1;
|
|
274
|
+
try {
|
|
275
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
277
|
+
const ret = wasm.graph_query_communities(this.__wbg_ptr, ptr0, len0, isLikeNone(round) ? Number.MAX_SAFE_INTEGER : round >>> 0);
|
|
278
|
+
var ptr2 = ret[0];
|
|
279
|
+
var len2 = ret[1];
|
|
280
|
+
if (ret[3]) {
|
|
281
|
+
ptr2 = 0;
|
|
282
|
+
len2 = 0;
|
|
283
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
284
|
+
}
|
|
285
|
+
deferred3_0 = ptr2;
|
|
286
|
+
deferred3_1 = len2;
|
|
287
|
+
return getStringFromWasm0(ptr2, len2);
|
|
288
|
+
} finally {
|
|
289
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* As [`query`], with OWL 2 QL entailment on (`rdfs:subClassOf` /
|
|
294
|
+
* `subPropertyOf` / `domain` / `range` reasoning by query rewriting).
|
|
295
|
+
* @param {string} query
|
|
296
|
+
* @param {string} format
|
|
297
|
+
* @returns {string}
|
|
298
|
+
*/
|
|
299
|
+
query_reasoned(query, format) {
|
|
300
|
+
let deferred4_0;
|
|
301
|
+
let deferred4_1;
|
|
302
|
+
try {
|
|
303
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
304
|
+
const len0 = WASM_VECTOR_LEN;
|
|
305
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
306
|
+
const len1 = WASM_VECTOR_LEN;
|
|
307
|
+
const ret = wasm.graph_query_reasoned(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
308
|
+
var ptr3 = ret[0];
|
|
309
|
+
var len3 = ret[1];
|
|
310
|
+
if (ret[3]) {
|
|
311
|
+
ptr3 = 0;
|
|
312
|
+
len3 = 0;
|
|
313
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
314
|
+
}
|
|
315
|
+
deferred4_0 = ptr3;
|
|
316
|
+
deferred4_1 = len3;
|
|
317
|
+
return getStringFromWasm0(ptr3, len3);
|
|
318
|
+
} finally {
|
|
319
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* See [`query_triples`].
|
|
324
|
+
* @param {string | null} [subject]
|
|
325
|
+
* @param {string | null} [predicate]
|
|
326
|
+
* @param {string | null} [object]
|
|
327
|
+
* @returns {string}
|
|
328
|
+
*/
|
|
329
|
+
query_triples(subject, predicate, object) {
|
|
330
|
+
let deferred5_0;
|
|
331
|
+
let deferred5_1;
|
|
332
|
+
try {
|
|
333
|
+
var ptr0 = isLikeNone(subject) ? 0 : passStringToWasm0(subject, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
334
|
+
var len0 = WASM_VECTOR_LEN;
|
|
335
|
+
var ptr1 = isLikeNone(predicate) ? 0 : passStringToWasm0(predicate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
336
|
+
var len1 = WASM_VECTOR_LEN;
|
|
337
|
+
var ptr2 = isLikeNone(object) ? 0 : passStringToWasm0(object, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
338
|
+
var len2 = WASM_VECTOR_LEN;
|
|
339
|
+
const ret = wasm.graph_query_triples(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
340
|
+
var ptr4 = ret[0];
|
|
341
|
+
var len4 = ret[1];
|
|
342
|
+
if (ret[3]) {
|
|
343
|
+
ptr4 = 0;
|
|
344
|
+
len4 = 0;
|
|
345
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
346
|
+
}
|
|
347
|
+
deferred5_0 = ptr4;
|
|
348
|
+
deferred5_1 = len4;
|
|
349
|
+
return getStringFromWasm0(ptr4, len4);
|
|
350
|
+
} finally {
|
|
351
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* See [`reach`].
|
|
356
|
+
* @param {string} predicate
|
|
357
|
+
* @param {string} seeds
|
|
358
|
+
* @param {boolean} reverse
|
|
359
|
+
* @returns {string}
|
|
360
|
+
*/
|
|
361
|
+
reach(predicate, seeds, reverse) {
|
|
362
|
+
let deferred4_0;
|
|
363
|
+
let deferred4_1;
|
|
364
|
+
try {
|
|
365
|
+
const ptr0 = passStringToWasm0(predicate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
366
|
+
const len0 = WASM_VECTOR_LEN;
|
|
367
|
+
const ptr1 = passStringToWasm0(seeds, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
368
|
+
const len1 = WASM_VECTOR_LEN;
|
|
369
|
+
const ret = wasm.graph_reach(this.__wbg_ptr, ptr0, len0, ptr1, len1, reverse);
|
|
370
|
+
var ptr3 = ret[0];
|
|
371
|
+
var len3 = ret[1];
|
|
372
|
+
if (ret[3]) {
|
|
373
|
+
ptr3 = 0;
|
|
374
|
+
len3 = 0;
|
|
375
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
376
|
+
}
|
|
377
|
+
deferred4_0 = ptr3;
|
|
378
|
+
deferred4_1 = len3;
|
|
379
|
+
return getStringFromWasm0(ptr3, len3);
|
|
380
|
+
} finally {
|
|
381
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* See [`reason`].
|
|
386
|
+
* @param {string | null} [graph]
|
|
387
|
+
* @returns {string}
|
|
388
|
+
*/
|
|
389
|
+
reason(graph) {
|
|
390
|
+
let deferred2_0;
|
|
391
|
+
let deferred2_1;
|
|
392
|
+
try {
|
|
393
|
+
var ptr0 = isLikeNone(graph) ? 0 : passStringToWasm0(graph, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
394
|
+
var len0 = WASM_VECTOR_LEN;
|
|
395
|
+
const ret = wasm.graph_reason(this.__wbg_ptr, ptr0, len0);
|
|
396
|
+
deferred2_0 = ret[0];
|
|
397
|
+
deferred2_1 = ret[1];
|
|
398
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
399
|
+
} finally {
|
|
400
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* See [`schema`] — the live (scanning) profile; prefer `schema_packed` when
|
|
405
|
+
* the file carries a pyramid.
|
|
406
|
+
* @returns {string}
|
|
407
|
+
*/
|
|
408
|
+
schema() {
|
|
409
|
+
let deferred2_0;
|
|
410
|
+
let deferred2_1;
|
|
411
|
+
try {
|
|
412
|
+
const ret = wasm.graph_schema(this.__wbg_ptr);
|
|
413
|
+
var ptr1 = ret[0];
|
|
414
|
+
var len1 = ret[1];
|
|
415
|
+
if (ret[3]) {
|
|
416
|
+
ptr1 = 0;
|
|
417
|
+
len1 = 0;
|
|
418
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
419
|
+
}
|
|
420
|
+
deferred2_0 = ptr1;
|
|
421
|
+
deferred2_1 = len1;
|
|
422
|
+
return getStringFromWasm0(ptr1, len1);
|
|
423
|
+
} finally {
|
|
424
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* See [`shacl`].
|
|
429
|
+
* @param {string} shapes_turtle
|
|
430
|
+
* @param {string | null | undefined} graph
|
|
431
|
+
* @param {string} format
|
|
432
|
+
* @returns {string}
|
|
433
|
+
*/
|
|
434
|
+
shacl(shapes_turtle, graph, format) {
|
|
435
|
+
let deferred5_0;
|
|
436
|
+
let deferred5_1;
|
|
437
|
+
try {
|
|
438
|
+
const ptr0 = passStringToWasm0(shapes_turtle, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
439
|
+
const len0 = WASM_VECTOR_LEN;
|
|
440
|
+
var ptr1 = isLikeNone(graph) ? 0 : passStringToWasm0(graph, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
441
|
+
var len1 = WASM_VECTOR_LEN;
|
|
442
|
+
const ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
443
|
+
const len2 = WASM_VECTOR_LEN;
|
|
444
|
+
const ret = wasm.graph_shacl(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
445
|
+
var ptr4 = ret[0];
|
|
446
|
+
var len4 = ret[1];
|
|
447
|
+
if (ret[3]) {
|
|
448
|
+
ptr4 = 0;
|
|
449
|
+
len4 = 0;
|
|
450
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
451
|
+
}
|
|
452
|
+
deferred5_0 = ptr4;
|
|
453
|
+
deferred5_1 = len4;
|
|
454
|
+
return getStringFromWasm0(ptr4, len4);
|
|
455
|
+
} finally {
|
|
456
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* See [`text_search`].
|
|
461
|
+
* @param {string[]} words
|
|
462
|
+
* @param {string | null | undefined} contains_prefix
|
|
463
|
+
* @param {number} limit
|
|
464
|
+
* @returns {string}
|
|
465
|
+
*/
|
|
466
|
+
text_search(words, contains_prefix, limit) {
|
|
467
|
+
let deferred4_0;
|
|
468
|
+
let deferred4_1;
|
|
469
|
+
try {
|
|
470
|
+
const ptr0 = passArrayJsValueToWasm0(words, wasm.__wbindgen_malloc);
|
|
471
|
+
const len0 = WASM_VECTOR_LEN;
|
|
472
|
+
var ptr1 = isLikeNone(contains_prefix) ? 0 : passStringToWasm0(contains_prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
473
|
+
var len1 = WASM_VECTOR_LEN;
|
|
474
|
+
const ret = wasm.graph_text_search(this.__wbg_ptr, ptr0, len0, ptr1, len1, limit);
|
|
475
|
+
var ptr3 = ret[0];
|
|
476
|
+
var len3 = ret[1];
|
|
477
|
+
if (ret[3]) {
|
|
478
|
+
ptr3 = 0;
|
|
479
|
+
len3 = 0;
|
|
480
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
481
|
+
}
|
|
482
|
+
deferred4_0 = ptr3;
|
|
483
|
+
deferred4_1 = len3;
|
|
484
|
+
return getStringFromWasm0(ptr3, len3);
|
|
485
|
+
} finally {
|
|
486
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* See [`why_triples`].
|
|
491
|
+
* @param {string | null} [subject]
|
|
492
|
+
* @param {string | null} [predicate]
|
|
493
|
+
* @param {string | null} [object]
|
|
494
|
+
* @returns {string}
|
|
495
|
+
*/
|
|
496
|
+
why_triples(subject, predicate, object) {
|
|
497
|
+
let deferred5_0;
|
|
498
|
+
let deferred5_1;
|
|
499
|
+
try {
|
|
500
|
+
var ptr0 = isLikeNone(subject) ? 0 : passStringToWasm0(subject, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
501
|
+
var len0 = WASM_VECTOR_LEN;
|
|
502
|
+
var ptr1 = isLikeNone(predicate) ? 0 : passStringToWasm0(predicate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
503
|
+
var len1 = WASM_VECTOR_LEN;
|
|
504
|
+
var ptr2 = isLikeNone(object) ? 0 : passStringToWasm0(object, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
505
|
+
var len2 = WASM_VECTOR_LEN;
|
|
506
|
+
const ret = wasm.graph_why_triples(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
507
|
+
var ptr4 = ret[0];
|
|
508
|
+
var len4 = ret[1];
|
|
509
|
+
if (ret[3]) {
|
|
510
|
+
ptr4 = 0;
|
|
511
|
+
len4 = 0;
|
|
512
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
513
|
+
}
|
|
514
|
+
deferred5_0 = ptr4;
|
|
515
|
+
deferred5_1 = len4;
|
|
516
|
+
return getStringFromWasm0(ptr4, len4);
|
|
517
|
+
} finally {
|
|
518
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
if (Symbol.dispose) Graph.prototype[Symbol.dispose] = Graph.prototype.free;
|
|
523
|
+
var RemoteGraph = class {
|
|
524
|
+
__destroy_into_raw() {
|
|
525
|
+
const ptr = this.__wbg_ptr;
|
|
526
|
+
this.__wbg_ptr = 0;
|
|
527
|
+
RemoteGraphFinalization.unregister(this);
|
|
528
|
+
return ptr;
|
|
529
|
+
}
|
|
530
|
+
free() {
|
|
531
|
+
const ptr = this.__destroy_into_raw();
|
|
532
|
+
wasm.__wbg_remotegraph_free(ptr, 0);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* The file's content hash (blake3-16, hex). The worker keys its session
|
|
536
|
+
* cache by this rather than the URL, so two URLs of the same file share the
|
|
537
|
+
* cache — and it's the stable key a future IndexedDB block store (L3) needs
|
|
538
|
+
* to survive page reloads.
|
|
539
|
+
* @returns {string}
|
|
540
|
+
*/
|
|
541
|
+
content_hash() {
|
|
542
|
+
let deferred1_0;
|
|
543
|
+
let deferred1_1;
|
|
544
|
+
try {
|
|
545
|
+
const ret = wasm.remotegraph_content_hash(this.__wbg_ptr);
|
|
546
|
+
deferred1_0 = ret[0];
|
|
547
|
+
deferred1_1 = ret[1];
|
|
548
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
549
|
+
} finally {
|
|
550
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Open a remote `.rete` over HTTP range and keep it resident for repeated
|
|
555
|
+
* querying. The first query faults in the dictionary chunks + index tiles it
|
|
556
|
+
* needs; later queries on this handle reuse them and the block cache.
|
|
557
|
+
* @param {string} url
|
|
558
|
+
*/
|
|
559
|
+
constructor(url) {
|
|
560
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
561
|
+
const len0 = WASM_VECTOR_LEN;
|
|
562
|
+
const ret = wasm.remotegraph_new(ptr0, len0);
|
|
563
|
+
if (ret[2]) {
|
|
564
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
565
|
+
}
|
|
566
|
+
this.__wbg_ptr = ret[0];
|
|
567
|
+
RemoteGraphFinalization.register(this, this.__wbg_ptr, this);
|
|
568
|
+
return this;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* See [`prefix_search`] — over the resident, cached remote handle. Faults the
|
|
572
|
+
* pyramid (where the label index lives) on the first call, then serves the
|
|
573
|
+
* search from memory.
|
|
574
|
+
* @param {string} prefix
|
|
575
|
+
* @param {number} limit
|
|
576
|
+
* @returns {string}
|
|
577
|
+
*/
|
|
578
|
+
prefix_search(prefix, limit) {
|
|
579
|
+
let deferred3_0;
|
|
580
|
+
let deferred3_1;
|
|
581
|
+
try {
|
|
582
|
+
const ptr0 = passStringToWasm0(prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
583
|
+
const len0 = WASM_VECTOR_LEN;
|
|
584
|
+
const ret = wasm.remotegraph_prefix_search(this.__wbg_ptr, ptr0, len0, limit);
|
|
585
|
+
var ptr2 = ret[0];
|
|
586
|
+
var len2 = ret[1];
|
|
587
|
+
if (ret[3]) {
|
|
588
|
+
ptr2 = 0;
|
|
589
|
+
len2 = 0;
|
|
590
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
591
|
+
}
|
|
592
|
+
deferred3_0 = ptr2;
|
|
593
|
+
deferred3_1 = len2;
|
|
594
|
+
return getStringFromWasm0(ptr2, len2);
|
|
595
|
+
} finally {
|
|
596
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* See [`sparql_url`] — same query, but over the resident, cached handle.
|
|
601
|
+
* @param {string} query
|
|
602
|
+
* @param {string} format
|
|
603
|
+
* @returns {string}
|
|
604
|
+
*/
|
|
605
|
+
query(query, format) {
|
|
606
|
+
let deferred4_0;
|
|
607
|
+
let deferred4_1;
|
|
608
|
+
try {
|
|
609
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
610
|
+
const len0 = WASM_VECTOR_LEN;
|
|
611
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
612
|
+
const len1 = WASM_VECTOR_LEN;
|
|
613
|
+
const ret = wasm.remotegraph_query(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
614
|
+
var ptr3 = ret[0];
|
|
615
|
+
var len3 = ret[1];
|
|
616
|
+
if (ret[3]) {
|
|
617
|
+
ptr3 = 0;
|
|
618
|
+
len3 = 0;
|
|
619
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
620
|
+
}
|
|
621
|
+
deferred4_0 = ptr3;
|
|
622
|
+
deferred4_1 = len3;
|
|
623
|
+
return getStringFromWasm0(ptr3, len3);
|
|
624
|
+
} finally {
|
|
625
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* As [`query`], with OWL 2 QL entailment on (reason over the ontology while
|
|
630
|
+
* reading only the bytes the rewritten query touches).
|
|
631
|
+
* @param {string} query
|
|
632
|
+
* @param {string} format
|
|
633
|
+
* @returns {string}
|
|
634
|
+
*/
|
|
635
|
+
query_reasoned(query, format) {
|
|
636
|
+
let deferred4_0;
|
|
637
|
+
let deferred4_1;
|
|
638
|
+
try {
|
|
639
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
640
|
+
const len0 = WASM_VECTOR_LEN;
|
|
641
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
642
|
+
const len1 = WASM_VECTOR_LEN;
|
|
643
|
+
const ret = wasm.remotegraph_query_reasoned(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
644
|
+
var ptr3 = ret[0];
|
|
645
|
+
var len3 = ret[1];
|
|
646
|
+
if (ret[3]) {
|
|
647
|
+
ptr3 = 0;
|
|
648
|
+
len3 = 0;
|
|
649
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
650
|
+
}
|
|
651
|
+
deferred4_0 = ptr3;
|
|
652
|
+
deferred4_1 = len3;
|
|
653
|
+
return getStringFromWasm0(ptr3, len3);
|
|
654
|
+
} finally {
|
|
655
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* `{ fileLength, bytes, requests }` — CUMULATIVE physical fetches since this
|
|
660
|
+
* session opened. The worker diffs successive calls to report a single
|
|
661
|
+
* query's traffic (a fully cached re-run adds ~0).
|
|
662
|
+
* @returns {string}
|
|
663
|
+
*/
|
|
664
|
+
stats() {
|
|
665
|
+
let deferred1_0;
|
|
666
|
+
let deferred1_1;
|
|
667
|
+
try {
|
|
668
|
+
const ret = wasm.remotegraph_stats(this.__wbg_ptr);
|
|
669
|
+
deferred1_0 = ret[0];
|
|
670
|
+
deferred1_1 = ret[1];
|
|
671
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
672
|
+
} finally {
|
|
673
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* See [`text_search`] — over the resident remote handle. Faults the TEXT_INDEX
|
|
678
|
+
* token table on the first call, then fetches only the queried posting lists
|
|
679
|
+
* (never the whole postings blob), serving repeat searches from memory.
|
|
680
|
+
* @param {string[]} words
|
|
681
|
+
* @param {string | null | undefined} contains_prefix
|
|
682
|
+
* @param {number} limit
|
|
683
|
+
* @returns {string}
|
|
684
|
+
*/
|
|
685
|
+
text_search(words, contains_prefix, limit) {
|
|
686
|
+
let deferred4_0;
|
|
687
|
+
let deferred4_1;
|
|
688
|
+
try {
|
|
689
|
+
const ptr0 = passArrayJsValueToWasm0(words, wasm.__wbindgen_malloc);
|
|
690
|
+
const len0 = WASM_VECTOR_LEN;
|
|
691
|
+
var ptr1 = isLikeNone(contains_prefix) ? 0 : passStringToWasm0(contains_prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
692
|
+
var len1 = WASM_VECTOR_LEN;
|
|
693
|
+
const ret = wasm.remotegraph_text_search(this.__wbg_ptr, ptr0, len0, ptr1, len1, limit);
|
|
694
|
+
var ptr3 = ret[0];
|
|
695
|
+
var len3 = ret[1];
|
|
696
|
+
if (ret[3]) {
|
|
697
|
+
ptr3 = 0;
|
|
698
|
+
len3 = 0;
|
|
699
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
700
|
+
}
|
|
701
|
+
deferred4_0 = ptr3;
|
|
702
|
+
deferred4_1 = len3;
|
|
703
|
+
return getStringFromWasm0(ptr3, len3);
|
|
704
|
+
} finally {
|
|
705
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
if (Symbol.dispose) RemoteGraph.prototype[Symbol.dispose] = RemoteGraph.prototype.free;
|
|
710
|
+
function build(text, format) {
|
|
711
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
712
|
+
const len0 = WASM_VECTOR_LEN;
|
|
713
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
714
|
+
const len1 = WASM_VECTOR_LEN;
|
|
715
|
+
const ret = wasm.build(ptr0, len0, ptr1, len1);
|
|
716
|
+
if (ret[3]) {
|
|
717
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
718
|
+
}
|
|
719
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
720
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
721
|
+
return v3;
|
|
722
|
+
}
|
|
723
|
+
function __wbg_get_imports() {
|
|
724
|
+
const import0 = {
|
|
725
|
+
__proto__: null,
|
|
726
|
+
__wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
|
|
727
|
+
const ret = debugString(arg1);
|
|
728
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
729
|
+
const len1 = WASM_VECTOR_LEN;
|
|
730
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
731
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
732
|
+
},
|
|
733
|
+
__wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
|
|
734
|
+
const ret = typeof arg0 === "function";
|
|
735
|
+
return ret;
|
|
736
|
+
},
|
|
737
|
+
__wbg___wbindgen_is_null_87c3bfe968c6a5ad: function(arg0) {
|
|
738
|
+
const ret = arg0 === null;
|
|
739
|
+
return ret;
|
|
740
|
+
},
|
|
741
|
+
__wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
|
|
742
|
+
const val = arg0;
|
|
743
|
+
const ret = typeof val === "object" && val !== null;
|
|
744
|
+
return ret;
|
|
745
|
+
},
|
|
746
|
+
__wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
|
|
747
|
+
const ret = typeof arg0 === "string";
|
|
748
|
+
return ret;
|
|
749
|
+
},
|
|
750
|
+
__wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
|
|
751
|
+
const ret = arg0 === void 0;
|
|
752
|
+
return ret;
|
|
753
|
+
},
|
|
754
|
+
__wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
|
|
755
|
+
const obj = arg1;
|
|
756
|
+
const ret = typeof obj === "string" ? obj : void 0;
|
|
757
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
758
|
+
var len1 = WASM_VECTOR_LEN;
|
|
759
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
760
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
761
|
+
},
|
|
762
|
+
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
763
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
764
|
+
},
|
|
765
|
+
__wbg_call_6e37a87ff352da3d: function() {
|
|
766
|
+
return handleError(function(arg0, arg1, arg2, arg3, arg4) {
|
|
767
|
+
const ret = arg0.call(arg1, arg2, arg3, arg4);
|
|
768
|
+
return ret;
|
|
769
|
+
}, arguments);
|
|
770
|
+
},
|
|
771
|
+
__wbg_call_9c758de292015997: function() {
|
|
772
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
773
|
+
const ret = arg0.call(arg1, arg2);
|
|
774
|
+
return ret;
|
|
775
|
+
}, arguments);
|
|
776
|
+
},
|
|
777
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
778
|
+
const ret = arg0.crypto;
|
|
779
|
+
return ret;
|
|
780
|
+
},
|
|
781
|
+
__wbg_encodeURIComponent_9ff907ad9d03c7bb: function(arg0, arg1) {
|
|
782
|
+
const ret = encodeURIComponent(getStringFromWasm0(arg0, arg1));
|
|
783
|
+
return ret;
|
|
784
|
+
},
|
|
785
|
+
__wbg_error_78ff5b3a29b770e0: function(arg0) {
|
|
786
|
+
console.error(arg0);
|
|
787
|
+
},
|
|
788
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() {
|
|
789
|
+
return handleError(function(arg0, arg1) {
|
|
790
|
+
arg0.getRandomValues(arg1);
|
|
791
|
+
}, arguments);
|
|
792
|
+
},
|
|
793
|
+
__wbg_getResponseHeader_db1ae5b1693dd680: function() {
|
|
794
|
+
return handleError(function(arg0, arg1, arg2, arg3) {
|
|
795
|
+
const ret = arg1.getResponseHeader(getStringFromWasm0(arg2, arg3));
|
|
796
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
797
|
+
var len1 = WASM_VECTOR_LEN;
|
|
798
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
799
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
800
|
+
}, arguments);
|
|
801
|
+
},
|
|
802
|
+
__wbg_get_de6a0f7d4d18a304: function() {
|
|
803
|
+
return handleError(function(arg0, arg1) {
|
|
804
|
+
const ret = Reflect.get(arg0, arg1);
|
|
805
|
+
return ret;
|
|
806
|
+
}, arguments);
|
|
807
|
+
},
|
|
808
|
+
__wbg_length_4a591ecaa01354d9: function(arg0) {
|
|
809
|
+
const ret = arg0.length;
|
|
810
|
+
return ret;
|
|
811
|
+
},
|
|
812
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
813
|
+
const ret = arg0.msCrypto;
|
|
814
|
+
return ret;
|
|
815
|
+
},
|
|
816
|
+
__wbg_new_2ee370dca414d926: function() {
|
|
817
|
+
return handleError(function() {
|
|
818
|
+
const ret = new XMLHttpRequest();
|
|
819
|
+
return ret;
|
|
820
|
+
}, arguments);
|
|
821
|
+
},
|
|
822
|
+
__wbg_new_50bb5ebeecef71a8: function(arg0, arg1) {
|
|
823
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
824
|
+
return ret;
|
|
825
|
+
},
|
|
826
|
+
__wbg_new_578aeef4b6b94378: function(arg0) {
|
|
827
|
+
const ret = new Uint8Array(arg0);
|
|
828
|
+
return ret;
|
|
829
|
+
},
|
|
830
|
+
__wbg_new_with_length_36a4998e27b014c5: function(arg0) {
|
|
831
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
832
|
+
return ret;
|
|
833
|
+
},
|
|
834
|
+
__wbg_new_with_length_b4a87ccced374381: function(arg0) {
|
|
835
|
+
const ret = new Float64Array(arg0 >>> 0);
|
|
836
|
+
return ret;
|
|
837
|
+
},
|
|
838
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
839
|
+
const ret = arg0.node;
|
|
840
|
+
return ret;
|
|
841
|
+
},
|
|
842
|
+
__wbg_open_837bab9ccb9e06da: function() {
|
|
843
|
+
return handleError(function(arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
844
|
+
arg0.open(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), arg5 !== 0);
|
|
845
|
+
}, arguments);
|
|
846
|
+
},
|
|
847
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
848
|
+
const ret = arg0.process;
|
|
849
|
+
return ret;
|
|
850
|
+
},
|
|
851
|
+
__wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
|
|
852
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
853
|
+
},
|
|
854
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() {
|
|
855
|
+
return handleError(function(arg0, arg1) {
|
|
856
|
+
arg0.randomFillSync(arg1);
|
|
857
|
+
}, arguments);
|
|
858
|
+
},
|
|
859
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() {
|
|
860
|
+
return handleError(function() {
|
|
861
|
+
const ret = module.require;
|
|
862
|
+
return ret;
|
|
863
|
+
}, arguments);
|
|
864
|
+
},
|
|
865
|
+
__wbg_responseText_266ec252b6be1e56: function() {
|
|
866
|
+
return handleError(function(arg0, arg1) {
|
|
867
|
+
const ret = arg1.responseText;
|
|
868
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
869
|
+
var len1 = WASM_VECTOR_LEN;
|
|
870
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
871
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
872
|
+
}, arguments);
|
|
873
|
+
},
|
|
874
|
+
__wbg_response_8ec82c168e320475: function() {
|
|
875
|
+
return handleError(function(arg0) {
|
|
876
|
+
const ret = arg0.response;
|
|
877
|
+
return ret;
|
|
878
|
+
}, arguments);
|
|
879
|
+
},
|
|
880
|
+
__wbg_send_4e22a258e556a44c: function() {
|
|
881
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
882
|
+
arg0.send(arg1 === 0 ? void 0 : getStringFromWasm0(arg1, arg2));
|
|
883
|
+
}, arguments);
|
|
884
|
+
},
|
|
885
|
+
__wbg_send_dce79f146638dfda: function() {
|
|
886
|
+
return handleError(function(arg0) {
|
|
887
|
+
arg0.send();
|
|
888
|
+
}, arguments);
|
|
889
|
+
},
|
|
890
|
+
__wbg_setRequestHeader_b5e8e6d03614f3e5: function() {
|
|
891
|
+
return handleError(function(arg0, arg1, arg2, arg3, arg4) {
|
|
892
|
+
arg0.setRequestHeader(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
893
|
+
}, arguments);
|
|
894
|
+
},
|
|
895
|
+
__wbg_set_index_c69336ea758c0507: function(arg0, arg1, arg2) {
|
|
896
|
+
arg0[arg1 >>> 0] = arg2;
|
|
897
|
+
},
|
|
898
|
+
__wbg_set_responseType_cfb49ea8269f8317: function(arg0, arg1) {
|
|
899
|
+
arg0.responseType = __wbindgen_enum_XmlHttpRequestResponseType[arg1];
|
|
900
|
+
},
|
|
901
|
+
__wbg_static_accessor_GLOBAL_9d53f2689e622ca1: function() {
|
|
902
|
+
const ret = typeof global === "undefined" ? null : global;
|
|
903
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
904
|
+
},
|
|
905
|
+
__wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a: function() {
|
|
906
|
+
const ret = typeof globalThis === "undefined" ? null : globalThis;
|
|
907
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
908
|
+
},
|
|
909
|
+
__wbg_static_accessor_SELF_4c59f6c7ea29a144: function() {
|
|
910
|
+
const ret = typeof self === "undefined" ? null : self;
|
|
911
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
912
|
+
},
|
|
913
|
+
__wbg_static_accessor_WINDOW_e70ae9f2eb052253: function() {
|
|
914
|
+
const ret = typeof window === "undefined" ? null : window;
|
|
915
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
916
|
+
},
|
|
917
|
+
__wbg_status_214edd0820ca76fc: function() {
|
|
918
|
+
return handleError(function(arg0) {
|
|
919
|
+
const ret = arg0.status;
|
|
920
|
+
return ret;
|
|
921
|
+
}, arguments);
|
|
922
|
+
},
|
|
923
|
+
__wbg_subarray_4aa221f6a4f5ab22: function(arg0, arg1, arg2) {
|
|
924
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
925
|
+
return ret;
|
|
926
|
+
},
|
|
927
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
928
|
+
const ret = arg0.versions;
|
|
929
|
+
return ret;
|
|
930
|
+
},
|
|
931
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
932
|
+
const ret = arg0;
|
|
933
|
+
return ret;
|
|
934
|
+
},
|
|
935
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
936
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
937
|
+
return ret;
|
|
938
|
+
},
|
|
939
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
940
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
941
|
+
return ret;
|
|
942
|
+
},
|
|
943
|
+
__wbindgen_init_externref_table: function() {
|
|
944
|
+
const table = wasm.__wbindgen_externrefs;
|
|
945
|
+
const offset = table.grow(4);
|
|
946
|
+
table.set(0, void 0);
|
|
947
|
+
table.set(offset + 0, void 0);
|
|
948
|
+
table.set(offset + 1, null);
|
|
949
|
+
table.set(offset + 2, true);
|
|
950
|
+
table.set(offset + 3, false);
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
return {
|
|
954
|
+
__proto__: null,
|
|
955
|
+
"./rete_wasm_bg.js": import0
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
var __wbindgen_enum_XmlHttpRequestResponseType = ["", "arraybuffer", "blob", "document", "json", "text"];
|
|
959
|
+
var GraphFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
960
|
+
}, unregister: () => {
|
|
961
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_graph_free(ptr, 1));
|
|
962
|
+
var RemoteGraphFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
963
|
+
}, unregister: () => {
|
|
964
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_remotegraph_free(ptr, 1));
|
|
965
|
+
function addToExternrefTable0(obj) {
|
|
966
|
+
const idx = wasm.__externref_table_alloc();
|
|
967
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
968
|
+
return idx;
|
|
969
|
+
}
|
|
970
|
+
function debugString(val) {
|
|
971
|
+
const type = typeof val;
|
|
972
|
+
if (type == "number" || type == "boolean" || val == null) {
|
|
973
|
+
return `${val}`;
|
|
974
|
+
}
|
|
975
|
+
if (type == "string") {
|
|
976
|
+
return `"${val}"`;
|
|
977
|
+
}
|
|
978
|
+
if (type == "symbol") {
|
|
979
|
+
const description = val.description;
|
|
980
|
+
if (description == null) {
|
|
981
|
+
return "Symbol";
|
|
982
|
+
} else {
|
|
983
|
+
return `Symbol(${description})`;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
if (type == "function") {
|
|
987
|
+
const name = val.name;
|
|
988
|
+
if (typeof name == "string" && name.length > 0) {
|
|
989
|
+
return `Function(${name})`;
|
|
990
|
+
} else {
|
|
991
|
+
return "Function";
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if (Array.isArray(val)) {
|
|
995
|
+
const length = val.length;
|
|
996
|
+
let debug = "[";
|
|
997
|
+
if (length > 0) {
|
|
998
|
+
debug += debugString(val[0]);
|
|
999
|
+
}
|
|
1000
|
+
for (let i = 1; i < length; i++) {
|
|
1001
|
+
debug += ", " + debugString(val[i]);
|
|
1002
|
+
}
|
|
1003
|
+
debug += "]";
|
|
1004
|
+
return debug;
|
|
1005
|
+
}
|
|
1006
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
1007
|
+
let className;
|
|
1008
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
1009
|
+
className = builtInMatches[1];
|
|
1010
|
+
} else {
|
|
1011
|
+
return toString.call(val);
|
|
1012
|
+
}
|
|
1013
|
+
if (className == "Object") {
|
|
1014
|
+
try {
|
|
1015
|
+
return "Object(" + JSON.stringify(val) + ")";
|
|
1016
|
+
} catch (_) {
|
|
1017
|
+
return "Object";
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
if (val instanceof Error) {
|
|
1021
|
+
return `${val.name}: ${val.message}
|
|
1022
|
+
${val.stack}`;
|
|
1023
|
+
}
|
|
1024
|
+
return className;
|
|
1025
|
+
}
|
|
1026
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1027
|
+
ptr = ptr >>> 0;
|
|
1028
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1029
|
+
}
|
|
1030
|
+
var cachedDataViewMemory0 = null;
|
|
1031
|
+
function getDataViewMemory0() {
|
|
1032
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
1033
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1034
|
+
}
|
|
1035
|
+
return cachedDataViewMemory0;
|
|
1036
|
+
}
|
|
1037
|
+
function getStringFromWasm0(ptr, len) {
|
|
1038
|
+
return decodeText(ptr >>> 0, len);
|
|
1039
|
+
}
|
|
1040
|
+
var cachedUint8ArrayMemory0 = null;
|
|
1041
|
+
function getUint8ArrayMemory0() {
|
|
1042
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1043
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1044
|
+
}
|
|
1045
|
+
return cachedUint8ArrayMemory0;
|
|
1046
|
+
}
|
|
1047
|
+
function handleError(f, args) {
|
|
1048
|
+
try {
|
|
1049
|
+
return f.apply(this, args);
|
|
1050
|
+
} catch (e) {
|
|
1051
|
+
const idx = addToExternrefTable0(e);
|
|
1052
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function isLikeNone(x) {
|
|
1056
|
+
return x === void 0 || x === null;
|
|
1057
|
+
}
|
|
1058
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1059
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1060
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1061
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1062
|
+
return ptr;
|
|
1063
|
+
}
|
|
1064
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1065
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1066
|
+
for (let i = 0; i < array.length; i++) {
|
|
1067
|
+
const add = addToExternrefTable0(array[i]);
|
|
1068
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1069
|
+
}
|
|
1070
|
+
WASM_VECTOR_LEN = array.length;
|
|
1071
|
+
return ptr;
|
|
1072
|
+
}
|
|
1073
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1074
|
+
if (realloc === void 0) {
|
|
1075
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1076
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
1077
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
1078
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1079
|
+
return ptr2;
|
|
1080
|
+
}
|
|
1081
|
+
let len = arg.length;
|
|
1082
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1083
|
+
const mem = getUint8ArrayMemory0();
|
|
1084
|
+
let offset = 0;
|
|
1085
|
+
for (; offset < len; offset++) {
|
|
1086
|
+
const code = arg.charCodeAt(offset);
|
|
1087
|
+
if (code > 127) break;
|
|
1088
|
+
mem[ptr + offset] = code;
|
|
1089
|
+
}
|
|
1090
|
+
if (offset !== len) {
|
|
1091
|
+
if (offset !== 0) {
|
|
1092
|
+
arg = arg.slice(offset);
|
|
1093
|
+
}
|
|
1094
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1095
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1096
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1097
|
+
offset += ret.written;
|
|
1098
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1099
|
+
}
|
|
1100
|
+
WASM_VECTOR_LEN = offset;
|
|
1101
|
+
return ptr;
|
|
1102
|
+
}
|
|
1103
|
+
function takeFromExternrefTable0(idx) {
|
|
1104
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1105
|
+
wasm.__externref_table_dealloc(idx);
|
|
1106
|
+
return value;
|
|
1107
|
+
}
|
|
1108
|
+
var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
1109
|
+
cachedTextDecoder.decode();
|
|
1110
|
+
var MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1111
|
+
var numBytesDecoded = 0;
|
|
1112
|
+
function decodeText(ptr, len) {
|
|
1113
|
+
numBytesDecoded += len;
|
|
1114
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1115
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
1116
|
+
cachedTextDecoder.decode();
|
|
1117
|
+
numBytesDecoded = len;
|
|
1118
|
+
}
|
|
1119
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1120
|
+
}
|
|
1121
|
+
var cachedTextEncoder = new TextEncoder();
|
|
1122
|
+
if (!("encodeInto" in cachedTextEncoder)) {
|
|
1123
|
+
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
1124
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1125
|
+
view.set(buf);
|
|
1126
|
+
return {
|
|
1127
|
+
read: arg.length,
|
|
1128
|
+
written: buf.length
|
|
1129
|
+
};
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
var WASM_VECTOR_LEN = 0;
|
|
1133
|
+
var wasmModule;
|
|
1134
|
+
var wasmInstance;
|
|
1135
|
+
var wasm;
|
|
1136
|
+
function __wbg_finalize_init(instance, module2) {
|
|
1137
|
+
wasmInstance = instance;
|
|
1138
|
+
wasm = instance.exports;
|
|
1139
|
+
wasmModule = module2;
|
|
1140
|
+
cachedDataViewMemory0 = null;
|
|
1141
|
+
cachedUint8ArrayMemory0 = null;
|
|
1142
|
+
wasm.__wbindgen_start();
|
|
1143
|
+
return wasm;
|
|
1144
|
+
}
|
|
1145
|
+
async function __wbg_load(module2, imports) {
|
|
1146
|
+
if (typeof Response === "function" && module2 instanceof Response) {
|
|
1147
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
1148
|
+
try {
|
|
1149
|
+
return await WebAssembly.instantiateStreaming(module2, imports);
|
|
1150
|
+
} catch (e) {
|
|
1151
|
+
const validResponse = module2.ok && expectedResponseType(module2.type);
|
|
1152
|
+
if (validResponse && module2.headers.get("Content-Type") !== "application/wasm") {
|
|
1153
|
+
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);
|
|
1154
|
+
} else {
|
|
1155
|
+
throw e;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
const bytes = await module2.arrayBuffer();
|
|
1160
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1161
|
+
} else {
|
|
1162
|
+
const instance = await WebAssembly.instantiate(module2, imports);
|
|
1163
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1164
|
+
return { instance, module: module2 };
|
|
1165
|
+
} else {
|
|
1166
|
+
return instance;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function expectedResponseType(type) {
|
|
1170
|
+
switch (type) {
|
|
1171
|
+
case "basic":
|
|
1172
|
+
case "cors":
|
|
1173
|
+
case "default":
|
|
1174
|
+
return true;
|
|
1175
|
+
}
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
async function __wbg_init(module_or_path) {
|
|
1180
|
+
if (wasm !== void 0) return wasm;
|
|
1181
|
+
if (module_or_path !== void 0) {
|
|
1182
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1183
|
+
({ module_or_path } = module_or_path);
|
|
1184
|
+
} else {
|
|
1185
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
if (module_or_path === void 0) {
|
|
1189
|
+
module_or_path = new URL("rete_wasm_bg.wasm", import.meta.url);
|
|
1190
|
+
}
|
|
1191
|
+
const imports = __wbg_get_imports();
|
|
1192
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
1193
|
+
module_or_path = fetch(module_or_path);
|
|
1194
|
+
}
|
|
1195
|
+
const { instance, module: module2 } = await __wbg_load(await module_or_path, imports);
|
|
1196
|
+
return __wbg_finalize_init(instance, module2);
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// src/index.js
|
|
1200
|
+
var XSD = "http://www.w3.org/2001/XMLSchema#";
|
|
1201
|
+
var INT_TYPES = new Set(
|
|
1202
|
+
[
|
|
1203
|
+
"integer",
|
|
1204
|
+
"long",
|
|
1205
|
+
"int",
|
|
1206
|
+
"short",
|
|
1207
|
+
"byte",
|
|
1208
|
+
"nonNegativeInteger",
|
|
1209
|
+
"nonPositiveInteger",
|
|
1210
|
+
"negativeInteger",
|
|
1211
|
+
"positiveInteger",
|
|
1212
|
+
"unsignedLong",
|
|
1213
|
+
"unsignedInt",
|
|
1214
|
+
"unsignedShort",
|
|
1215
|
+
"unsignedByte"
|
|
1216
|
+
].map((t) => XSD + t)
|
|
1217
|
+
);
|
|
1218
|
+
var FLOAT_TYPES = new Set(["decimal", "double", "float"].map((t) => XSD + t));
|
|
1219
|
+
var Term = class _Term {
|
|
1220
|
+
/** @param {string} kind @param {string} value */
|
|
1221
|
+
constructor(kind, value, datatype = null, lang = null) {
|
|
1222
|
+
this.kind = kind;
|
|
1223
|
+
this.value = value;
|
|
1224
|
+
this.datatype = datatype;
|
|
1225
|
+
this.lang = lang;
|
|
1226
|
+
}
|
|
1227
|
+
/** Parse an N-Triples-style term token as emitted by the engine. */
|
|
1228
|
+
static parse(token) {
|
|
1229
|
+
if (token.startsWith("<<")) return new _Term("triple", token);
|
|
1230
|
+
if (token.startsWith("<") && token.endsWith(">"))
|
|
1231
|
+
return new _Term("iri", token.slice(1, -1));
|
|
1232
|
+
if (token.startsWith("_:")) return new _Term("bnode", token);
|
|
1233
|
+
if (token.startsWith('"')) return parseLiteral(token);
|
|
1234
|
+
return new _Term("literal", token);
|
|
1235
|
+
}
|
|
1236
|
+
/** The closest JS value: number/boolean/BigInt for common XSD types. */
|
|
1237
|
+
toJS() {
|
|
1238
|
+
if (this.kind === "literal" && this.datatype) {
|
|
1239
|
+
if (INT_TYPES.has(this.datatype)) {
|
|
1240
|
+
const n = Number(this.value);
|
|
1241
|
+
return Number.isSafeInteger(n) ? n : BigInt(this.value);
|
|
1242
|
+
}
|
|
1243
|
+
if (FLOAT_TYPES.has(this.datatype)) return Number(this.value);
|
|
1244
|
+
if (this.datatype === XSD + "boolean") return this.value === "true";
|
|
1245
|
+
}
|
|
1246
|
+
return this.value;
|
|
1247
|
+
}
|
|
1248
|
+
/** The term back in N-Triples surface form. */
|
|
1249
|
+
get n3() {
|
|
1250
|
+
if (this.kind === "iri") return `<${this.value}>`;
|
|
1251
|
+
if (this.kind === "bnode" || this.kind === "triple") return this.value;
|
|
1252
|
+
const body = this.value.replaceAll("\\", "\\\\").replaceAll('"', '\\"').replaceAll("\n", "\\n").replaceAll("\r", "\\r");
|
|
1253
|
+
if (this.lang) return `"${body}"@${this.lang}`;
|
|
1254
|
+
if (this.datatype) return `"${body}"^^<${this.datatype}>`;
|
|
1255
|
+
return `"${body}"`;
|
|
1256
|
+
}
|
|
1257
|
+
toString() {
|
|
1258
|
+
return this.value;
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
function unescapeNt(s) {
|
|
1262
|
+
if (!s.includes("\\")) return s;
|
|
1263
|
+
const simple = { t: " ", b: "\b", n: "\n", r: "\r", f: "\f", '"': '"', "'": "'", "\\": "\\" };
|
|
1264
|
+
let out = "";
|
|
1265
|
+
for (let i = 0; i < s.length; ) {
|
|
1266
|
+
const c = s[i];
|
|
1267
|
+
if (c !== "\\" || i + 1 >= s.length) {
|
|
1268
|
+
out += c;
|
|
1269
|
+
i += 1;
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
const e = s[i + 1];
|
|
1273
|
+
if (e in simple) {
|
|
1274
|
+
out += simple[e];
|
|
1275
|
+
i += 2;
|
|
1276
|
+
} else if (e === "u" && i + 6 <= s.length) {
|
|
1277
|
+
out += String.fromCharCode(parseInt(s.slice(i + 2, i + 6), 16));
|
|
1278
|
+
i += 6;
|
|
1279
|
+
} else if (e === "U" && i + 10 <= s.length) {
|
|
1280
|
+
out += String.fromCodePoint(parseInt(s.slice(i + 2, i + 10), 16));
|
|
1281
|
+
i += 10;
|
|
1282
|
+
} else {
|
|
1283
|
+
out += c;
|
|
1284
|
+
i += 1;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
return out;
|
|
1288
|
+
}
|
|
1289
|
+
function parseLiteral(token) {
|
|
1290
|
+
let i = 1;
|
|
1291
|
+
while (i < token.length) {
|
|
1292
|
+
if (token[i] === "\\") {
|
|
1293
|
+
i += 2;
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
if (token[i] === '"') break;
|
|
1297
|
+
i += 1;
|
|
1298
|
+
}
|
|
1299
|
+
const lex = unescapeNt(token.slice(1, i));
|
|
1300
|
+
const rest = token.slice(i + 1);
|
|
1301
|
+
if (rest.startsWith("@")) return new Term("literal", lex, null, rest.slice(1));
|
|
1302
|
+
if (rest.startsWith("^^<") && rest.endsWith(">"))
|
|
1303
|
+
return new Term("literal", lex, rest.slice(3, -1));
|
|
1304
|
+
return new Term("literal", lex);
|
|
1305
|
+
}
|
|
1306
|
+
var cleanIri = (token) => Term.parse(token).value;
|
|
1307
|
+
var embeddedWasm = null;
|
|
1308
|
+
var ready = null;
|
|
1309
|
+
function __setWasmSource(bytes) {
|
|
1310
|
+
embeddedWasm = bytes;
|
|
1311
|
+
}
|
|
1312
|
+
function init(source = null) {
|
|
1313
|
+
ready ??= (async () => {
|
|
1314
|
+
const src = source ?? embeddedWasm;
|
|
1315
|
+
if (src) {
|
|
1316
|
+
await __wbg_init({ module_or_path: src });
|
|
1317
|
+
} else if (typeof process !== "undefined" && process.versions?.node) {
|
|
1318
|
+
const { readFile } = await import("node:fs/promises");
|
|
1319
|
+
const bytes = await readFile(new URL("./rete_wasm_bg.wasm", import.meta.url));
|
|
1320
|
+
await __wbg_init({ module_or_path: bytes });
|
|
1321
|
+
} else {
|
|
1322
|
+
await __wbg_init();
|
|
1323
|
+
}
|
|
1324
|
+
})();
|
|
1325
|
+
return ready;
|
|
1326
|
+
}
|
|
1327
|
+
var Graph2 = class {
|
|
1328
|
+
#g;
|
|
1329
|
+
#remote;
|
|
1330
|
+
constructor(inner, source, remote) {
|
|
1331
|
+
this.#g = inner;
|
|
1332
|
+
this.source = source;
|
|
1333
|
+
this.#remote = remote;
|
|
1334
|
+
}
|
|
1335
|
+
/** The engine's raw JSON result envelope. */
|
|
1336
|
+
queryRaw(query, { reason = false } = {}) {
|
|
1337
|
+
const s = reason ? this.#g.query_reasoned(query, "json") : this.#g.query(query, "json");
|
|
1338
|
+
return JSON.parse(s);
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Run a SPARQL query: SELECT → array of `{var: Term}` rows, ASK → boolean,
|
|
1342
|
+
* CONSTRUCT/DESCRIBE → array of `[s, p, o]` Term triples.
|
|
1343
|
+
* `reason: true` turns on OWL 2 QL entailment by query rewriting.
|
|
1344
|
+
*/
|
|
1345
|
+
query(query, opts = {}) {
|
|
1346
|
+
const env = this.queryRaw(query, opts);
|
|
1347
|
+
switch (env.kind) {
|
|
1348
|
+
case "select":
|
|
1349
|
+
return env.rows.map(
|
|
1350
|
+
(row) => Object.fromEntries(Object.entries(row).map(([k, v]) => [k, Term.parse(v)]))
|
|
1351
|
+
);
|
|
1352
|
+
case "ask":
|
|
1353
|
+
return env.boolean;
|
|
1354
|
+
case "construct":
|
|
1355
|
+
return env.triples.map((t) => t.map((tok) => Term.parse(tok)));
|
|
1356
|
+
default:
|
|
1357
|
+
throw new Error(`unexpected result kind: ${env.kind}`);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
/** Label prefix search: `[{label, subject}]` with clean IRIs. */
|
|
1361
|
+
prefixSearch(prefix, limit = 20) {
|
|
1362
|
+
return JSON.parse(this.#g.prefix_search(prefix, limit)).map(({ label, subject }) => ({
|
|
1363
|
+
label,
|
|
1364
|
+
subject: cleanIri(subject)
|
|
1365
|
+
}));
|
|
1366
|
+
}
|
|
1367
|
+
/** Full-text search over the file's TEXT_INDEX; returns subject IRIs. */
|
|
1368
|
+
textSearch(words, { contains = null, limit = 100 } = {}) {
|
|
1369
|
+
const list = typeof words === "string" ? words.split(/\s+/).filter(Boolean) : words;
|
|
1370
|
+
return JSON.parse(this.#g.text_search(list, contains ?? void 0, limit)).map(
|
|
1371
|
+
(h) => cleanIri(h.subject)
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
/** Class/predicate profile: `{classes: [[iri, n]], relations: [[s,p,o,n]]}`. */
|
|
1375
|
+
schema() {
|
|
1376
|
+
const env = JSON.parse(this.#g.schema());
|
|
1377
|
+
return {
|
|
1378
|
+
classes: env.classes.map(([c, n]) => [cleanIri(c), n]),
|
|
1379
|
+
relations: env.relations.map(([s, p, o, n]) => [cleanIri(s), cleanIri(p), cleanIri(o), n])
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
info() {
|
|
1383
|
+
return JSON.parse(this.#g.info?.() ?? "{}");
|
|
1384
|
+
}
|
|
1385
|
+
get quads() {
|
|
1386
|
+
return this.info().quads;
|
|
1387
|
+
}
|
|
1388
|
+
graphNames() {
|
|
1389
|
+
return JSON.parse(this.#g.graph_names()).map(cleanIri);
|
|
1390
|
+
}
|
|
1391
|
+
/** Remote graphs: cumulative physical fetch counters; null for bytes. */
|
|
1392
|
+
stats() {
|
|
1393
|
+
return this.#remote ? JSON.parse(this.#g.stats()) : null;
|
|
1394
|
+
}
|
|
1395
|
+
/** Remote graphs: blake3-16 hex content hash; null for bytes. */
|
|
1396
|
+
contentHash() {
|
|
1397
|
+
return this.#remote ? this.#g.content_hash() : null;
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
var isBytes = (s) => s instanceof Uint8Array || s instanceof ArrayBuffer || ArrayBuffer.isView(s);
|
|
1401
|
+
async function open(source, { headers } = {}) {
|
|
1402
|
+
await init();
|
|
1403
|
+
if (headers) {
|
|
1404
|
+
throw new Error("custom headers are not supported by the JS client yet");
|
|
1405
|
+
}
|
|
1406
|
+
if (typeof source === "string" && /^https?:\/\//.test(source)) {
|
|
1407
|
+
if (typeof XMLHttpRequest === "undefined") {
|
|
1408
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
1409
|
+
const { install: install2 } = await Promise.resolve().then(() => (init_node_sync_xhr(), node_sync_xhr_exports));
|
|
1410
|
+
install2();
|
|
1411
|
+
} else {
|
|
1412
|
+
throw new Error(
|
|
1413
|
+
"remote .rete opens need synchronous XHR: run inside a web worker (browser main threads forbid it) or in Node"
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
return new Graph2(new RemoteGraph(source), source, true);
|
|
1418
|
+
}
|
|
1419
|
+
if (isBytes(source)) {
|
|
1420
|
+
const bytes = source instanceof Uint8Array ? source : new Uint8Array(source instanceof ArrayBuffer ? source : source.buffer);
|
|
1421
|
+
return new Graph2(new Graph(bytes), "<bytes>", false);
|
|
1422
|
+
}
|
|
1423
|
+
throw new TypeError("open() takes a Uint8Array/ArrayBuffer or an http(s):// URL");
|
|
1424
|
+
}
|
|
1425
|
+
async function build2(text, format = "nt") {
|
|
1426
|
+
await init();
|
|
1427
|
+
return build(text, format);
|
|
1428
|
+
}
|
|
1429
|
+
export {
|
|
1430
|
+
Graph2 as Graph,
|
|
1431
|
+
Term,
|
|
1432
|
+
__setWasmSource,
|
|
1433
|
+
build2 as build,
|
|
1434
|
+
init,
|
|
1435
|
+
open
|
|
1436
|
+
};
|