rete-graph 0.3.2 → 0.3.5
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 +73 -5
- package/dist/index.js +846 -26
- package/dist/rete-graph.js +847 -27
- package/dist/rete-graph.min.js +6 -6
- package/dist/rete_wasm_bg.wasm +0 -0
- package/index.d.ts +129 -3
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rete-graph v0.3.
|
|
1
|
+
/*! rete-graph v0.3.5 | Apache-2.0 | https://github.com/caviri/rete */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __esm = (fn, res) => function __init() {
|
|
@@ -149,18 +149,27 @@ parentPort.on("message", async ({ port, signal, method, url, headers, body }) =>
|
|
|
149
149
|
var rete_wasm_exports = {};
|
|
150
150
|
__export(rete_wasm_exports, {
|
|
151
151
|
Graph: () => Graph,
|
|
152
|
+
QuadCursor: () => QuadCursor,
|
|
152
153
|
RemoteGraph: () => RemoteGraph,
|
|
153
154
|
__start: () => __start,
|
|
154
155
|
build: () => build,
|
|
156
|
+
build_with_card: () => build_with_card,
|
|
157
|
+
build_with_card_syntax: () => build_with_card_syntax,
|
|
158
|
+
build_with_derived_card: () => build_with_derived_card,
|
|
155
159
|
card: () => card,
|
|
160
|
+
card_and_build: () => card_and_build,
|
|
161
|
+
card_and_build_url: () => card_and_build_url,
|
|
156
162
|
card_url: () => card_url,
|
|
157
163
|
check_schema: () => check_schema,
|
|
158
164
|
check_schema_url: () => check_schema_url,
|
|
159
165
|
communities: () => communities,
|
|
160
166
|
default: () => __wbg_init,
|
|
161
167
|
file_layout: () => file_layout,
|
|
168
|
+
file_len_url: () => file_len_url,
|
|
169
|
+
forget_local_file: () => forget_local_file,
|
|
162
170
|
graph_names: () => graph_names,
|
|
163
171
|
header_ranges: () => header_ranges,
|
|
172
|
+
heap_bytes: () => heap_bytes,
|
|
164
173
|
info: () => info,
|
|
165
174
|
initSync: () => initSync,
|
|
166
175
|
prefix_search: () => prefix_search,
|
|
@@ -175,6 +184,7 @@ __export(rete_wasm_exports, {
|
|
|
175
184
|
reason: () => reason,
|
|
176
185
|
reason_construct_url: () => reason_construct_url,
|
|
177
186
|
reason_url: () => reason_url,
|
|
187
|
+
register_local_file: () => register_local_file,
|
|
178
188
|
schema: () => schema,
|
|
179
189
|
schema_packed: () => schema_packed,
|
|
180
190
|
schema_url: () => schema_url,
|
|
@@ -184,6 +194,7 @@ __export(rete_wasm_exports, {
|
|
|
184
194
|
sparql_url: () => sparql_url,
|
|
185
195
|
summary_overview: () => summary_overview,
|
|
186
196
|
text_search: () => text_search,
|
|
197
|
+
validate_card: () => validate_card,
|
|
187
198
|
why_triples: () => why_triples,
|
|
188
199
|
why_url: () => why_url
|
|
189
200
|
});
|
|
@@ -211,6 +222,24 @@ var Graph = class {
|
|
|
211
222
|
}
|
|
212
223
|
return v1;
|
|
213
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* See [`card_and_build`] — the card and the build record of the resident
|
|
227
|
+
* file, in the same envelope the remote path returns, so one caller
|
|
228
|
+
* handles both sources.
|
|
229
|
+
* @returns {string}
|
|
230
|
+
*/
|
|
231
|
+
card_and_build() {
|
|
232
|
+
let deferred1_0;
|
|
233
|
+
let deferred1_1;
|
|
234
|
+
try {
|
|
235
|
+
const ret = wasm.graph_card_and_build(this.__wbg_ptr);
|
|
236
|
+
deferred1_0 = ret[0];
|
|
237
|
+
deferred1_1 = ret[1];
|
|
238
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
239
|
+
} finally {
|
|
240
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
214
243
|
/**
|
|
215
244
|
* See [`file_layout`].
|
|
216
245
|
* @returns {string}
|
|
@@ -338,6 +367,30 @@ var Graph = class {
|
|
|
338
367
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
339
368
|
}
|
|
340
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* A **lazy, resumable cursor** over the quads of this graph — the streaming
|
|
372
|
+
* export path. See [`QuadCursor`]; `graph` selects one graph (`""` = the
|
|
373
|
+
* default graph), `None` streams the default graph followed by every named
|
|
374
|
+
* graph. `s` / `p` / `o` optionally restrict the dump to a triple pattern,
|
|
375
|
+
* which **prunes tiles** rather than filtering rows.
|
|
376
|
+
* @param {string | null} [graph]
|
|
377
|
+
* @param {string | null} [s]
|
|
378
|
+
* @param {string | null} [p]
|
|
379
|
+
* @param {string | null} [o]
|
|
380
|
+
* @returns {QuadCursor}
|
|
381
|
+
*/
|
|
382
|
+
quads(graph, s, p, o) {
|
|
383
|
+
var ptr0 = isLikeNone(graph) ? 0 : passStringToWasm0(graph, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
384
|
+
var len0 = WASM_VECTOR_LEN;
|
|
385
|
+
var ptr1 = isLikeNone(s) ? 0 : passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
386
|
+
var len1 = WASM_VECTOR_LEN;
|
|
387
|
+
var ptr2 = isLikeNone(p) ? 0 : passStringToWasm0(p, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
388
|
+
var len2 = WASM_VECTOR_LEN;
|
|
389
|
+
var ptr3 = isLikeNone(o) ? 0 : passStringToWasm0(o, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
390
|
+
var len3 = WASM_VECTOR_LEN;
|
|
391
|
+
const ret = wasm.graph_quads(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
392
|
+
return QuadCursor.__wrap(ret);
|
|
393
|
+
}
|
|
341
394
|
/**
|
|
342
395
|
* See [`query`].
|
|
343
396
|
* @param {string} query
|
|
@@ -394,6 +447,41 @@ var Graph = class {
|
|
|
394
447
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
395
448
|
}
|
|
396
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* As [`query`], with explicit opt-in toggles: `reason` (OWL 2 QL
|
|
452
|
+
* entailment) and `union_default` (union default graph — a pattern
|
|
453
|
+
* outside `GRAPH` matches the merge of the default graph and every named
|
|
454
|
+
* graph, the Virtuoso / GraphDB / Jena TDB mode; non-standard, so plain
|
|
455
|
+
* [`Graph::query`] never does this).
|
|
456
|
+
* @param {string} query
|
|
457
|
+
* @param {string} format
|
|
458
|
+
* @param {boolean} reason
|
|
459
|
+
* @param {boolean} union_default
|
|
460
|
+
* @returns {string}
|
|
461
|
+
*/
|
|
462
|
+
query_opts(query2, format, reason2, union_default) {
|
|
463
|
+
let deferred4_0;
|
|
464
|
+
let deferred4_1;
|
|
465
|
+
try {
|
|
466
|
+
const ptr0 = passStringToWasm0(query2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
467
|
+
const len0 = WASM_VECTOR_LEN;
|
|
468
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
469
|
+
const len1 = WASM_VECTOR_LEN;
|
|
470
|
+
const ret = wasm.graph_query_opts(this.__wbg_ptr, ptr0, len0, ptr1, len1, reason2, union_default);
|
|
471
|
+
var ptr3 = ret[0];
|
|
472
|
+
var len3 = ret[1];
|
|
473
|
+
if (ret[3]) {
|
|
474
|
+
ptr3 = 0;
|
|
475
|
+
len3 = 0;
|
|
476
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
477
|
+
}
|
|
478
|
+
deferred4_0 = ptr3;
|
|
479
|
+
deferred4_1 = len3;
|
|
480
|
+
return getStringFromWasm0(ptr3, len3);
|
|
481
|
+
} finally {
|
|
482
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
397
485
|
/**
|
|
398
486
|
* As [`query`], with OWL 2 QL entailment on (`rdfs:subClassOf` /
|
|
399
487
|
* `subPropertyOf` / `domain` / `range` reasoning by query rewriting).
|
|
@@ -456,6 +544,23 @@ var Graph = class {
|
|
|
456
544
|
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
457
545
|
}
|
|
458
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* The card's `signals.quoted_triples` for this file, from its header: does
|
|
549
|
+
* it hold quoted triples, and in which surfaces can an export write them.
|
|
550
|
+
* @returns {string}
|
|
551
|
+
*/
|
|
552
|
+
quoted_triples_signal() {
|
|
553
|
+
let deferred1_0;
|
|
554
|
+
let deferred1_1;
|
|
555
|
+
try {
|
|
556
|
+
const ret = wasm.graph_quoted_triples_signal(this.__wbg_ptr);
|
|
557
|
+
deferred1_0 = ret[0];
|
|
558
|
+
deferred1_1 = ret[1];
|
|
559
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
560
|
+
} finally {
|
|
561
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
459
564
|
/**
|
|
460
565
|
* See [`reach`].
|
|
461
566
|
* @param {string} predicate
|
|
@@ -561,6 +666,34 @@ var Graph = class {
|
|
|
561
666
|
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
562
667
|
}
|
|
563
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* Byte length of the TEXT_INDEX section, `0` when the file has none — a
|
|
671
|
+
* header read, never a fault. The UI asks this to decide whether to offer
|
|
672
|
+
* full-text search at all, and to state the cost before the first one.
|
|
673
|
+
* `f64` because the section outgrows `u32`: causenet's is 1.88 GB.
|
|
674
|
+
* @returns {number}
|
|
675
|
+
*/
|
|
676
|
+
text_index_len() {
|
|
677
|
+
const ret = wasm.graph_text_index_len(this.__wbg_ptr);
|
|
678
|
+
return ret;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Byte length of the TEXT_INDEX's leading **token table** — what a first
|
|
682
|
+
* [`Graph::text_search_one`] actually faults, and therefore the only honest
|
|
683
|
+
* number to quote as its cost. [`Graph::text_index_len`] is the whole
|
|
684
|
+
* section, postings blob included, and overstates it 6.5× on
|
|
685
|
+
* `epfl-infoscience` (195 MB section, 29 MB token table); the postings are
|
|
686
|
+
* only ever fetched one list at a time. `0` when the file has no text index
|
|
687
|
+
* or the length could not be read — the caller must then say nothing about
|
|
688
|
+
* a token table rather than pass the section length off as one.
|
|
689
|
+
* `f64` for the same reason as the section length: causenet's table is
|
|
690
|
+
* 1.88 GB.
|
|
691
|
+
* @returns {number}
|
|
692
|
+
*/
|
|
693
|
+
text_index_token_table_len() {
|
|
694
|
+
const ret = wasm.graph_text_index_token_table_len(this.__wbg_ptr);
|
|
695
|
+
return ret;
|
|
696
|
+
}
|
|
564
697
|
/**
|
|
565
698
|
* See [`text_search`].
|
|
566
699
|
* @param {string[]} words
|
|
@@ -591,6 +724,37 @@ var Graph = class {
|
|
|
591
724
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
592
725
|
}
|
|
593
726
|
}
|
|
727
|
+
/**
|
|
728
|
+
* [`Graph::text_search`] from ONE phrase: whitespace splits it into words
|
|
729
|
+
* and **every** word must match (AND), like `rete search --contains a b`.
|
|
730
|
+
* One string in, one string out — that is what the remote twin's
|
|
731
|
+
* hand-marshaled asyncify path can carry (a JS array marshaled raw is what
|
|
732
|
+
* traps), and the UI is a single text box either way. Same JSON envelope.
|
|
733
|
+
* @param {string} phrase
|
|
734
|
+
* @param {number} limit
|
|
735
|
+
* @returns {string}
|
|
736
|
+
*/
|
|
737
|
+
text_search_one(phrase, limit) {
|
|
738
|
+
let deferred3_0;
|
|
739
|
+
let deferred3_1;
|
|
740
|
+
try {
|
|
741
|
+
const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
742
|
+
const len0 = WASM_VECTOR_LEN;
|
|
743
|
+
const ret = wasm.graph_text_search_one(this.__wbg_ptr, ptr0, len0, limit);
|
|
744
|
+
var ptr2 = ret[0];
|
|
745
|
+
var len2 = ret[1];
|
|
746
|
+
if (ret[3]) {
|
|
747
|
+
ptr2 = 0;
|
|
748
|
+
len2 = 0;
|
|
749
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
750
|
+
}
|
|
751
|
+
deferred3_0 = ptr2;
|
|
752
|
+
deferred3_1 = len2;
|
|
753
|
+
return getStringFromWasm0(ptr2, len2);
|
|
754
|
+
} finally {
|
|
755
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
594
758
|
/**
|
|
595
759
|
* See [`why_triples`].
|
|
596
760
|
* @param {string | null} [subject]
|
|
@@ -625,6 +789,107 @@ var Graph = class {
|
|
|
625
789
|
}
|
|
626
790
|
};
|
|
627
791
|
if (Symbol.dispose) Graph.prototype[Symbol.dispose] = Graph.prototype.free;
|
|
792
|
+
var QuadCursor = class _QuadCursor {
|
|
793
|
+
static __wrap(ptr) {
|
|
794
|
+
const obj = Object.create(_QuadCursor.prototype);
|
|
795
|
+
obj.__wbg_ptr = ptr;
|
|
796
|
+
QuadCursorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
797
|
+
return obj;
|
|
798
|
+
}
|
|
799
|
+
__destroy_into_raw() {
|
|
800
|
+
const ptr = this.__wbg_ptr;
|
|
801
|
+
this.__wbg_ptr = 0;
|
|
802
|
+
QuadCursorFinalization.unregister(this);
|
|
803
|
+
return ptr;
|
|
804
|
+
}
|
|
805
|
+
free() {
|
|
806
|
+
const ptr = this.__destroy_into_raw();
|
|
807
|
+
wasm.__wbg_quadcursor_free(ptr, 0);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Whether every selected graph has been streamed to its end.
|
|
811
|
+
* @returns {boolean}
|
|
812
|
+
*/
|
|
813
|
+
done() {
|
|
814
|
+
const ret = wasm.quadcursor_done(this.__wbg_ptr);
|
|
815
|
+
return ret !== 0;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Up to `max` quads as a **flat** `string[]` of `[s, p, o, g, s, p, o, g, …]`
|
|
819
|
+
* N-Triples term tokens, `g` being `""` for the default graph. Flat because
|
|
820
|
+
* a nested array would allocate one JS array per quad for no gain — the
|
|
821
|
+
* caller slices it into tuples as it yields them.
|
|
822
|
+
*
|
|
823
|
+
* An empty array means the stream is finished; keep calling until you get
|
|
824
|
+
* one (that final call is what verifies no range fetch failed mid-dump).
|
|
825
|
+
* @param {number | null} [max]
|
|
826
|
+
* @returns {string[]}
|
|
827
|
+
*/
|
|
828
|
+
next_batch(max) {
|
|
829
|
+
const ret = wasm.quadcursor_next_batch(this.__wbg_ptr, isLikeNone(max) ? Number.MAX_SAFE_INTEGER : max >>> 0);
|
|
830
|
+
if (ret[3]) {
|
|
831
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
832
|
+
}
|
|
833
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
834
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
835
|
+
return v1;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Up to `max` quads already serialized as N-Quads lines in **one** string —
|
|
839
|
+
* the `.rete` → Oxigraph / N-Quads-file path. One string crossing per batch
|
|
840
|
+
* instead of four per quad: no per-term JS string, no re-serialization in
|
|
841
|
+
* JavaScript, and the terms are already canonical N-Triples tokens, so the
|
|
842
|
+
* lines are emitted verbatim.
|
|
843
|
+
*
|
|
844
|
+
* An empty string means the stream is finished.
|
|
845
|
+
* @param {number | null} [max]
|
|
846
|
+
* @returns {string}
|
|
847
|
+
*/
|
|
848
|
+
next_nquads(max) {
|
|
849
|
+
let deferred2_0;
|
|
850
|
+
let deferred2_1;
|
|
851
|
+
try {
|
|
852
|
+
const ret = wasm.quadcursor_next_nquads(this.__wbg_ptr, isLikeNone(max) ? Number.MAX_SAFE_INTEGER : max >>> 0);
|
|
853
|
+
var ptr1 = ret[0];
|
|
854
|
+
var len1 = ret[1];
|
|
855
|
+
if (ret[3]) {
|
|
856
|
+
ptr1 = 0;
|
|
857
|
+
len1 = 0;
|
|
858
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
859
|
+
}
|
|
860
|
+
deferred2_0 = ptr1;
|
|
861
|
+
deferred2_1 = len1;
|
|
862
|
+
return getStringFromWasm0(ptr1, len1);
|
|
863
|
+
} finally {
|
|
864
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* How [`next_nquads`](Self::next_nquads) spells a quoted triple — the
|
|
869
|
+
* values of `rete export --quoted-triple-syntax`:
|
|
870
|
+
*
|
|
871
|
+
* - `"rdf-star"` (or `""`; the cursor's initial state): `<<s p o>>`, the
|
|
872
|
+
* stored token, verbatim — what this cursor always wrote.
|
|
873
|
+
* - `"rdf12"`: the RDF 1.2 triple term `<<( s p o )>>`, nested terms too,
|
|
874
|
+
* which current RDF 1.2 parsers (Oxigraph 0.5, Jena 5) load. RDF 1.2
|
|
875
|
+
* admits a triple term in object position only, so a quoted triple in a
|
|
876
|
+
* statement's subject/predicate (or in another's subject) makes the next
|
|
877
|
+
* call fail by name instead of writing a line nothing parses.
|
|
878
|
+
*
|
|
879
|
+
* Anything else is refused. A file whose header records no quoted triple
|
|
880
|
+
* is written byte-for-byte the same under both.
|
|
881
|
+
* @param {string} syntax
|
|
882
|
+
*/
|
|
883
|
+
set_quoted_triple_syntax(syntax) {
|
|
884
|
+
const ptr0 = passStringToWasm0(syntax, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
885
|
+
const len0 = WASM_VECTOR_LEN;
|
|
886
|
+
const ret = wasm.quadcursor_set_quoted_triple_syntax(this.__wbg_ptr, ptr0, len0);
|
|
887
|
+
if (ret[1]) {
|
|
888
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
if (Symbol.dispose) QuadCursor.prototype[Symbol.dispose] = QuadCursor.prototype.free;
|
|
628
893
|
var RemoteGraph = class {
|
|
629
894
|
__destroy_into_raw() {
|
|
630
895
|
const ptr = this.__wbg_ptr;
|
|
@@ -653,6 +918,31 @@ var RemoteGraph = class {
|
|
|
653
918
|
}
|
|
654
919
|
return v1;
|
|
655
920
|
}
|
|
921
|
+
/**
|
|
922
|
+
* See [`card_and_build_url`] — card + build record over the resident
|
|
923
|
+
* handle's reader, still one coalesced range (and served from the block
|
|
924
|
+
* cache when the header range is already there).
|
|
925
|
+
* @returns {string}
|
|
926
|
+
*/
|
|
927
|
+
card_and_build() {
|
|
928
|
+
let deferred2_0;
|
|
929
|
+
let deferred2_1;
|
|
930
|
+
try {
|
|
931
|
+
const ret = wasm.remotegraph_card_and_build(this.__wbg_ptr);
|
|
932
|
+
var ptr1 = ret[0];
|
|
933
|
+
var len1 = ret[1];
|
|
934
|
+
if (ret[3]) {
|
|
935
|
+
ptr1 = 0;
|
|
936
|
+
len1 = 0;
|
|
937
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
938
|
+
}
|
|
939
|
+
deferred2_0 = ptr1;
|
|
940
|
+
deferred2_1 = len1;
|
|
941
|
+
return getStringFromWasm0(ptr1, len1);
|
|
942
|
+
} finally {
|
|
943
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
656
946
|
/**
|
|
657
947
|
* The file's content hash (blake3-16, hex). The worker keys its session
|
|
658
948
|
* cache by this rather than the URL, so two URLs of the same file share the
|
|
@@ -757,6 +1047,36 @@ var RemoteGraph = class {
|
|
|
757
1047
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
758
1048
|
}
|
|
759
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* See [`Graph::quads`] — the SAME lazy cursor, over the lazily range-read
|
|
1052
|
+
* remote handle.
|
|
1053
|
+
*
|
|
1054
|
+
* An **unfiltered** dump is not network-lazy and cannot be: it resolves
|
|
1055
|
+
* every term and visits every tile, so it ends up fetching essentially the
|
|
1056
|
+
* whole file (and what it faults stays resident). A **filtered** one is:
|
|
1057
|
+
* pass `s` / `p` / `o` and the scan routes to one permutation, keeps only
|
|
1058
|
+
* the tiles whose synopsis admits the bound components, and fetches those.
|
|
1059
|
+
* On `cordis.rete` (801 MB) one predicate of one named graph costs 16 MB
|
|
1060
|
+
* instead of 376 MB. To peek at an unfiltered graph, still prefer a `LIMIT`
|
|
1061
|
+
* query. Worker-only in the browser, like every other read here.
|
|
1062
|
+
* @param {string | null} [graph]
|
|
1063
|
+
* @param {string | null} [s]
|
|
1064
|
+
* @param {string | null} [p]
|
|
1065
|
+
* @param {string | null} [o]
|
|
1066
|
+
* @returns {QuadCursor}
|
|
1067
|
+
*/
|
|
1068
|
+
quads(graph, s, p, o) {
|
|
1069
|
+
var ptr0 = isLikeNone(graph) ? 0 : passStringToWasm0(graph, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1070
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1071
|
+
var ptr1 = isLikeNone(s) ? 0 : passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1072
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1073
|
+
var ptr2 = isLikeNone(p) ? 0 : passStringToWasm0(p, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1074
|
+
var len2 = WASM_VECTOR_LEN;
|
|
1075
|
+
var ptr3 = isLikeNone(o) ? 0 : passStringToWasm0(o, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1076
|
+
var len3 = WASM_VECTOR_LEN;
|
|
1077
|
+
const ret = wasm.remotegraph_quads(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
1078
|
+
return QuadCursor.__wrap(ret);
|
|
1079
|
+
}
|
|
760
1080
|
/**
|
|
761
1081
|
* See [`sparql_url`] — same query, but over the resident, cached handle.
|
|
762
1082
|
* The incompleteness verdict is PER QUERY: reset the sticky failure flags
|
|
@@ -790,6 +1110,39 @@ var RemoteGraph = class {
|
|
|
790
1110
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
791
1111
|
}
|
|
792
1112
|
}
|
|
1113
|
+
/**
|
|
1114
|
+
* As [`query`], with explicit opt-in toggles — see [`Graph::query_opts`].
|
|
1115
|
+
* With `union_default` on, a lazy remote read may fault the index tiles of
|
|
1116
|
+
* every named graph the union touches (the merge is strictly opt-in).
|
|
1117
|
+
* @param {string} query
|
|
1118
|
+
* @param {string} format
|
|
1119
|
+
* @param {boolean} reason
|
|
1120
|
+
* @param {boolean} union_default
|
|
1121
|
+
* @returns {string}
|
|
1122
|
+
*/
|
|
1123
|
+
query_opts(query2, format, reason2, union_default) {
|
|
1124
|
+
let deferred4_0;
|
|
1125
|
+
let deferred4_1;
|
|
1126
|
+
try {
|
|
1127
|
+
const ptr0 = passStringToWasm0(query2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1128
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1129
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1130
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1131
|
+
const ret = wasm.remotegraph_query_opts(this.__wbg_ptr, ptr0, len0, ptr1, len1, reason2, union_default);
|
|
1132
|
+
var ptr3 = ret[0];
|
|
1133
|
+
var len3 = ret[1];
|
|
1134
|
+
if (ret[3]) {
|
|
1135
|
+
ptr3 = 0;
|
|
1136
|
+
len3 = 0;
|
|
1137
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1138
|
+
}
|
|
1139
|
+
deferred4_0 = ptr3;
|
|
1140
|
+
deferred4_1 = len3;
|
|
1141
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1142
|
+
} finally {
|
|
1143
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
793
1146
|
/**
|
|
794
1147
|
* As [`query`], with OWL 2 QL entailment on (reason over the ontology while
|
|
795
1148
|
* reading only the bytes the rewritten query touches).
|
|
@@ -820,6 +1173,23 @@ var RemoteGraph = class {
|
|
|
820
1173
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
821
1174
|
}
|
|
822
1175
|
}
|
|
1176
|
+
/**
|
|
1177
|
+
* See [`Graph::quoted_triples_signal`] — from the header the open already
|
|
1178
|
+
* holds, so no range read at all.
|
|
1179
|
+
* @returns {string}
|
|
1180
|
+
*/
|
|
1181
|
+
quoted_triples_signal() {
|
|
1182
|
+
let deferred1_0;
|
|
1183
|
+
let deferred1_1;
|
|
1184
|
+
try {
|
|
1185
|
+
const ret = wasm.remotegraph_quoted_triples_signal(this.__wbg_ptr);
|
|
1186
|
+
deferred1_0 = ret[0];
|
|
1187
|
+
deferred1_1 = ret[1];
|
|
1188
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1189
|
+
} finally {
|
|
1190
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
823
1193
|
/**
|
|
824
1194
|
* See [`schema_url`] — the **baked** schema pyramid over the resident
|
|
825
1195
|
* handle. Deliberately never falls back to the scanning [`schema`]: that
|
|
@@ -880,9 +1250,11 @@ var RemoteGraph = class {
|
|
|
880
1250
|
}
|
|
881
1251
|
}
|
|
882
1252
|
/**
|
|
883
|
-
* `{ fileLength, bytes, requests }` — CUMULATIVE physical fetches
|
|
884
|
-
* session opened. The worker diffs successive calls to report a
|
|
885
|
-
* query's traffic (a fully cached re-run adds ~0).
|
|
1253
|
+
* `{ fileLength, bytes, requests, base }` — CUMULATIVE physical fetches
|
|
1254
|
+
* since this session opened. The worker diffs successive calls to report a
|
|
1255
|
+
* single query's traffic (a fully cached re-run adds ~0). `fileLength` is
|
|
1256
|
+
* the **graph's** length and `base` the byte offset it starts at: `0` for an
|
|
1257
|
+
* ordinary `.rete`, and the size of the HTML shell for a polyglot file.
|
|
886
1258
|
* @returns {string}
|
|
887
1259
|
*/
|
|
888
1260
|
stats() {
|
|
@@ -897,6 +1269,34 @@ var RemoteGraph = class {
|
|
|
897
1269
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
898
1270
|
}
|
|
899
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* See [`Graph::text_index_len`] — read from the resident header, so it
|
|
1274
|
+
* costs no fetch at all. Worth asking before [`RemoteGraph::text_search`]:
|
|
1275
|
+
* it is the size of the section the first search starts pulling over the
|
|
1276
|
+
* wire, so the UI can warn instead of surprising the user.
|
|
1277
|
+
* @returns {number}
|
|
1278
|
+
*/
|
|
1279
|
+
text_index_len() {
|
|
1280
|
+
const ret = wasm.remotegraph_text_index_len(this.__wbg_ptr);
|
|
1281
|
+
return ret;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* See [`Graph::text_index_token_table_len`] — the figure to quote before
|
|
1285
|
+
* [`RemoteGraph::text_search`], because it is what that first search pulls
|
|
1286
|
+
* over the wire; the section length would promise the user several times
|
|
1287
|
+
* the real bill.
|
|
1288
|
+
*
|
|
1289
|
+
* Unlike [`RemoteGraph::text_index_len`] this is not free: the token
|
|
1290
|
+
* table's length lives in the section's first bytes, not the header, so it
|
|
1291
|
+
* costs ONE ≤10-byte range read (memoized). Trivial next to the table it
|
|
1292
|
+
* measures — but it *is* IO, so the asyncify path must drive this call
|
|
1293
|
+
* rather than treat it as a header field.
|
|
1294
|
+
* @returns {number}
|
|
1295
|
+
*/
|
|
1296
|
+
text_index_token_table_len() {
|
|
1297
|
+
const ret = wasm.remotegraph_text_index_token_table_len(this.__wbg_ptr);
|
|
1298
|
+
return ret;
|
|
1299
|
+
}
|
|
900
1300
|
/**
|
|
901
1301
|
* See [`text_search`] — over the resident remote handle. Faults the TEXT_INDEX
|
|
902
1302
|
* token table on the first call, then fetches only the queried posting lists
|
|
@@ -929,6 +1329,36 @@ var RemoteGraph = class {
|
|
|
929
1329
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
930
1330
|
}
|
|
931
1331
|
}
|
|
1332
|
+
/**
|
|
1333
|
+
* See [`Graph::text_search_one`] — over the resident remote handle, with
|
|
1334
|
+
* the same token-table-then-posting-lists fault pattern as
|
|
1335
|
+
* [`RemoteGraph::text_search`]. This is the shape the playground's raw
|
|
1336
|
+
* asyncify glue drives: one string in, one string out, marshaled once.
|
|
1337
|
+
* @param {string} phrase
|
|
1338
|
+
* @param {number} limit
|
|
1339
|
+
* @returns {string}
|
|
1340
|
+
*/
|
|
1341
|
+
text_search_one(phrase, limit) {
|
|
1342
|
+
let deferred3_0;
|
|
1343
|
+
let deferred3_1;
|
|
1344
|
+
try {
|
|
1345
|
+
const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1346
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1347
|
+
const ret = wasm.remotegraph_text_search_one(this.__wbg_ptr, ptr0, len0, limit);
|
|
1348
|
+
var ptr2 = ret[0];
|
|
1349
|
+
var len2 = ret[1];
|
|
1350
|
+
if (ret[3]) {
|
|
1351
|
+
ptr2 = 0;
|
|
1352
|
+
len2 = 0;
|
|
1353
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1354
|
+
}
|
|
1355
|
+
deferred3_0 = ptr2;
|
|
1356
|
+
deferred3_1 = len2;
|
|
1357
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1358
|
+
} finally {
|
|
1359
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
932
1362
|
};
|
|
933
1363
|
if (Symbol.dispose) RemoteGraph.prototype[Symbol.dispose] = RemoteGraph.prototype.free;
|
|
934
1364
|
function __start() {
|
|
@@ -947,6 +1377,53 @@ function build(text, format) {
|
|
|
947
1377
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
948
1378
|
return v3;
|
|
949
1379
|
}
|
|
1380
|
+
function build_with_card(text, format, card_json) {
|
|
1381
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1382
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1383
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1384
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1385
|
+
const ptr2 = passStringToWasm0(card_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1386
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1387
|
+
const ret = wasm.build_with_card(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1388
|
+
if (ret[3]) {
|
|
1389
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1390
|
+
}
|
|
1391
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1392
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1393
|
+
return v4;
|
|
1394
|
+
}
|
|
1395
|
+
function build_with_card_syntax(text, format, card_json, quoted_triple_syntax) {
|
|
1396
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1397
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1398
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1399
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1400
|
+
const ptr2 = passStringToWasm0(card_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1401
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1402
|
+
const ptr3 = passStringToWasm0(quoted_triple_syntax, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1403
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1404
|
+
const ret = wasm.build_with_card_syntax(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
1405
|
+
if (ret[3]) {
|
|
1406
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1407
|
+
}
|
|
1408
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1409
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1410
|
+
return v5;
|
|
1411
|
+
}
|
|
1412
|
+
function build_with_derived_card(text, format, card_json) {
|
|
1413
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1414
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1415
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1416
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1417
|
+
const ptr2 = passStringToWasm0(card_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1418
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1419
|
+
const ret = wasm.build_with_derived_card(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1420
|
+
if (ret[3]) {
|
|
1421
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1422
|
+
}
|
|
1423
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1424
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1425
|
+
return v4;
|
|
1426
|
+
}
|
|
950
1427
|
function card(bytes) {
|
|
951
1428
|
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
952
1429
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -961,6 +1438,48 @@ function card(bytes) {
|
|
|
961
1438
|
}
|
|
962
1439
|
return v2;
|
|
963
1440
|
}
|
|
1441
|
+
function card_and_build(bytes) {
|
|
1442
|
+
let deferred3_0;
|
|
1443
|
+
let deferred3_1;
|
|
1444
|
+
try {
|
|
1445
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
1446
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1447
|
+
const ret = wasm.card_and_build(ptr0, len0);
|
|
1448
|
+
var ptr2 = ret[0];
|
|
1449
|
+
var len2 = ret[1];
|
|
1450
|
+
if (ret[3]) {
|
|
1451
|
+
ptr2 = 0;
|
|
1452
|
+
len2 = 0;
|
|
1453
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1454
|
+
}
|
|
1455
|
+
deferred3_0 = ptr2;
|
|
1456
|
+
deferred3_1 = len2;
|
|
1457
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1458
|
+
} finally {
|
|
1459
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
function card_and_build_url(url) {
|
|
1463
|
+
let deferred3_0;
|
|
1464
|
+
let deferred3_1;
|
|
1465
|
+
try {
|
|
1466
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1467
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1468
|
+
const ret = wasm.card_and_build_url(ptr0, len0);
|
|
1469
|
+
var ptr2 = ret[0];
|
|
1470
|
+
var len2 = ret[1];
|
|
1471
|
+
if (ret[3]) {
|
|
1472
|
+
ptr2 = 0;
|
|
1473
|
+
len2 = 0;
|
|
1474
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1475
|
+
}
|
|
1476
|
+
deferred3_0 = ptr2;
|
|
1477
|
+
deferred3_1 = len2;
|
|
1478
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1479
|
+
} finally {
|
|
1480
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
964
1483
|
function card_url(url) {
|
|
965
1484
|
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
966
1485
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -1059,6 +1578,33 @@ function file_layout(bytes) {
|
|
|
1059
1578
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1060
1579
|
}
|
|
1061
1580
|
}
|
|
1581
|
+
function file_len_url(url) {
|
|
1582
|
+
let deferred3_0;
|
|
1583
|
+
let deferred3_1;
|
|
1584
|
+
try {
|
|
1585
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1587
|
+
const ret = wasm.file_len_url(ptr0, len0);
|
|
1588
|
+
var ptr2 = ret[0];
|
|
1589
|
+
var len2 = ret[1];
|
|
1590
|
+
if (ret[3]) {
|
|
1591
|
+
ptr2 = 0;
|
|
1592
|
+
len2 = 0;
|
|
1593
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1594
|
+
}
|
|
1595
|
+
deferred3_0 = ptr2;
|
|
1596
|
+
deferred3_1 = len2;
|
|
1597
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1598
|
+
} finally {
|
|
1599
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
function forget_local_file(url) {
|
|
1603
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1604
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1605
|
+
const ret = wasm.forget_local_file(ptr0, len0);
|
|
1606
|
+
return ret !== 0;
|
|
1607
|
+
}
|
|
1062
1608
|
function graph_names(bytes) {
|
|
1063
1609
|
let deferred3_0;
|
|
1064
1610
|
let deferred3_1;
|
|
@@ -1101,6 +1647,10 @@ function header_ranges(head) {
|
|
|
1101
1647
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1102
1648
|
}
|
|
1103
1649
|
}
|
|
1650
|
+
function heap_bytes() {
|
|
1651
|
+
const ret = wasm.heap_bytes();
|
|
1652
|
+
return ret;
|
|
1653
|
+
}
|
|
1104
1654
|
function info(bytes) {
|
|
1105
1655
|
let deferred3_0;
|
|
1106
1656
|
let deferred3_1;
|
|
@@ -1406,6 +1956,14 @@ function reason_url(url, graph) {
|
|
|
1406
1956
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1407
1957
|
}
|
|
1408
1958
|
}
|
|
1959
|
+
function register_local_file(url, blob) {
|
|
1960
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1961
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1962
|
+
const ret = wasm.register_local_file(ptr0, len0, blob);
|
|
1963
|
+
if (ret[1]) {
|
|
1964
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1409
1967
|
function schema(bytes) {
|
|
1410
1968
|
let deferred3_0;
|
|
1411
1969
|
let deferred3_1;
|
|
@@ -1621,6 +2179,20 @@ function text_search(bytes, words, contains_prefix, limit) {
|
|
|
1621
2179
|
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1622
2180
|
}
|
|
1623
2181
|
}
|
|
2182
|
+
function validate_card(card_json) {
|
|
2183
|
+
let deferred2_0;
|
|
2184
|
+
let deferred2_1;
|
|
2185
|
+
try {
|
|
2186
|
+
const ptr0 = passStringToWasm0(card_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2187
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2188
|
+
const ret = wasm.validate_card(ptr0, len0);
|
|
2189
|
+
deferred2_0 = ret[0];
|
|
2190
|
+
deferred2_1 = ret[1];
|
|
2191
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2192
|
+
} finally {
|
|
2193
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
1624
2196
|
function why_triples(bytes, subject, predicate, object) {
|
|
1625
2197
|
let deferred6_0;
|
|
1626
2198
|
let deferred6_1;
|
|
@@ -1740,6 +2312,11 @@ function __wbg_get_imports() {
|
|
|
1740
2312
|
__wbg_error_78ff5b3a29b770e0: function(arg0) {
|
|
1741
2313
|
console.error(arg0);
|
|
1742
2314
|
},
|
|
2315
|
+
__wbg_getRandomValues_3f44b700395062e5: function() {
|
|
2316
|
+
return handleError(function(arg0, arg1) {
|
|
2317
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
2318
|
+
}, arguments);
|
|
2319
|
+
},
|
|
1743
2320
|
__wbg_getRandomValues_c44a50d8cfdaebeb: function() {
|
|
1744
2321
|
return handleError(function(arg0, arg1) {
|
|
1745
2322
|
arg0.getRandomValues(arg1);
|
|
@@ -1782,6 +2359,16 @@ function __wbg_get_imports() {
|
|
|
1782
2359
|
const ret = new Uint8Array(arg0);
|
|
1783
2360
|
return ret;
|
|
1784
2361
|
},
|
|
2362
|
+
__wbg_new_a1b9f645bba64f0f: function() {
|
|
2363
|
+
return handleError(function() {
|
|
2364
|
+
const ret = new FileReaderSync();
|
|
2365
|
+
return ret;
|
|
2366
|
+
}, arguments);
|
|
2367
|
+
},
|
|
2368
|
+
__wbg_new_d90091b82fdf5b91: function() {
|
|
2369
|
+
const ret = new Array();
|
|
2370
|
+
return ret;
|
|
2371
|
+
},
|
|
1785
2372
|
__wbg_new_with_length_36a4998e27b014c5: function(arg0) {
|
|
1786
2373
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
1787
2374
|
return ret;
|
|
@@ -1806,11 +2393,21 @@ function __wbg_get_imports() {
|
|
|
1806
2393
|
__wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
|
|
1807
2394
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1808
2395
|
},
|
|
2396
|
+
__wbg_push_a6822215aa43e71c: function(arg0, arg1) {
|
|
2397
|
+
const ret = arg0.push(arg1);
|
|
2398
|
+
return ret;
|
|
2399
|
+
},
|
|
1809
2400
|
__wbg_randomFillSync_6c25eac9869eb53c: function() {
|
|
1810
2401
|
return handleError(function(arg0, arg1) {
|
|
1811
2402
|
arg0.randomFillSync(arg1);
|
|
1812
2403
|
}, arguments);
|
|
1813
2404
|
},
|
|
2405
|
+
__wbg_readAsArrayBuffer_f1b8da05559618d9: function() {
|
|
2406
|
+
return handleError(function(arg0, arg1) {
|
|
2407
|
+
const ret = arg0.readAsArrayBuffer(arg1);
|
|
2408
|
+
return ret;
|
|
2409
|
+
}, arguments);
|
|
2410
|
+
},
|
|
1814
2411
|
__wbg_require_b4edbdcf3e2a1ef0: function() {
|
|
1815
2412
|
return handleError(function() {
|
|
1816
2413
|
const ret = module.require;
|
|
@@ -1853,6 +2450,16 @@ function __wbg_get_imports() {
|
|
|
1853
2450
|
__wbg_set_responseType_cfb49ea8269f8317: function(arg0, arg1) {
|
|
1854
2451
|
arg0.responseType = __wbindgen_enum_XmlHttpRequestResponseType[arg1];
|
|
1855
2452
|
},
|
|
2453
|
+
__wbg_size_9970092b88b1094c: function(arg0) {
|
|
2454
|
+
const ret = arg0.size;
|
|
2455
|
+
return ret;
|
|
2456
|
+
},
|
|
2457
|
+
__wbg_slice_02bb778501725738: function() {
|
|
2458
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
2459
|
+
const ret = arg0.slice(arg1, arg2);
|
|
2460
|
+
return ret;
|
|
2461
|
+
}, arguments);
|
|
2462
|
+
},
|
|
1856
2463
|
__wbg_static_accessor_GLOBAL_9d53f2689e622ca1: function() {
|
|
1857
2464
|
const ret = typeof global === "undefined" ? null : global;
|
|
1858
2465
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
@@ -1914,6 +2521,9 @@ var __wbindgen_enum_XmlHttpRequestResponseType = ["", "arraybuffer", "blob", "do
|
|
|
1914
2521
|
var GraphFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
1915
2522
|
}, unregister: () => {
|
|
1916
2523
|
} } : new FinalizationRegistry((ptr) => wasm.__wbg_graph_free(ptr, 1));
|
|
2524
|
+
var QuadCursorFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
2525
|
+
}, unregister: () => {
|
|
2526
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_quadcursor_free(ptr, 1));
|
|
1917
2527
|
var RemoteGraphFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
1918
2528
|
}, unregister: () => {
|
|
1919
2529
|
} } : new FinalizationRegistry((ptr) => wasm.__wbg_remotegraph_free(ptr, 1));
|
|
@@ -1978,6 +2588,16 @@ ${val.stack}`;
|
|
|
1978
2588
|
}
|
|
1979
2589
|
return className;
|
|
1980
2590
|
}
|
|
2591
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
2592
|
+
ptr = ptr >>> 0;
|
|
2593
|
+
const mem = getDataViewMemory0();
|
|
2594
|
+
const result = [];
|
|
2595
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
2596
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
2597
|
+
}
|
|
2598
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
2599
|
+
return result;
|
|
2600
|
+
}
|
|
1981
2601
|
function getArrayU8FromWasm0(ptr, len) {
|
|
1982
2602
|
ptr = ptr >>> 0;
|
|
1983
2603
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -2224,20 +2844,20 @@ var Quad = class {
|
|
|
2224
2844
|
}
|
|
2225
2845
|
};
|
|
2226
2846
|
function toRdfjs(t) {
|
|
2227
|
-
const
|
|
2228
|
-
switch (
|
|
2847
|
+
const term2 = t instanceof Term ? t : Term.parse(t);
|
|
2848
|
+
switch (term2.kind) {
|
|
2229
2849
|
case "iri":
|
|
2230
|
-
return new NamedNode(
|
|
2850
|
+
return new NamedNode(term2.value);
|
|
2231
2851
|
case "bnode":
|
|
2232
|
-
return new BlankNode(
|
|
2852
|
+
return new BlankNode(term2.value.replace(/^_:/, ""));
|
|
2233
2853
|
case "triple": {
|
|
2234
|
-
const [s, p, o] = splitQuoted(
|
|
2854
|
+
const [s, p, o] = splitQuoted(term2.value);
|
|
2235
2855
|
return new Quad(toRdfjs(s), toRdfjs(p), toRdfjs(o));
|
|
2236
2856
|
}
|
|
2237
2857
|
default:
|
|
2238
|
-
if (
|
|
2239
|
-
if (
|
|
2240
|
-
return new Literal(
|
|
2858
|
+
if (term2.lang) return new Literal(term2.value, term2.lang);
|
|
2859
|
+
if (term2.datatype) return new Literal(term2.value, new NamedNode(term2.datatype));
|
|
2860
|
+
return new Literal(term2.value);
|
|
2241
2861
|
}
|
|
2242
2862
|
}
|
|
2243
2863
|
function splitQuoted(token) {
|
|
@@ -2271,18 +2891,18 @@ function splitQuoted(token) {
|
|
|
2271
2891
|
return parts.map((p) => p.trim()).filter(Boolean);
|
|
2272
2892
|
}
|
|
2273
2893
|
var XSD_STRING = "http://www.w3.org/2001/XMLSchema#string";
|
|
2274
|
-
function toN3(
|
|
2275
|
-
switch (
|
|
2894
|
+
function toN3(term2) {
|
|
2895
|
+
switch (term2.termType) {
|
|
2276
2896
|
case "NamedNode":
|
|
2277
|
-
return `<${
|
|
2897
|
+
return `<${term2.value}>`;
|
|
2278
2898
|
case "Literal": {
|
|
2279
|
-
const dt =
|
|
2280
|
-
return new Term("literal",
|
|
2899
|
+
const dt = term2.language || !term2.datatype || term2.datatype.value === XSD_STRING ? null : term2.datatype.value;
|
|
2900
|
+
return new Term("literal", term2.value, dt, term2.language || null).n3;
|
|
2281
2901
|
}
|
|
2282
2902
|
case "Quad":
|
|
2283
|
-
return `<< ${toN3(
|
|
2903
|
+
return `<< ${toN3(term2.subject)} ${toN3(term2.predicate)} ${toN3(term2.object)} >>`;
|
|
2284
2904
|
default:
|
|
2285
|
-
throw new TypeError(`cannot serialize ${
|
|
2905
|
+
throw new TypeError(`cannot serialize ${term2.termType} into a pattern`);
|
|
2286
2906
|
}
|
|
2287
2907
|
}
|
|
2288
2908
|
var isVarish = (t) => t == null || t.termType === "Variable";
|
|
@@ -2360,7 +2980,7 @@ var ReteSource = class {
|
|
|
2360
2980
|
return this.#matchArray(subject, predicate, object, graph).length;
|
|
2361
2981
|
}
|
|
2362
2982
|
#matchArray(subject, predicate, object, graph) {
|
|
2363
|
-
const wantBnode = (
|
|
2983
|
+
const wantBnode = (term2) => term2 != null && term2.termType === "BlankNode" ? `_:${term2.value}` : null;
|
|
2364
2984
|
const wantS = wantBnode(subject), wantO = wantBnode(object);
|
|
2365
2985
|
const free = {
|
|
2366
2986
|
s: isVarish(subject) || subject.termType === "BlankNode",
|
|
@@ -2419,6 +3039,7 @@ var ReteSource = class {
|
|
|
2419
3039
|
};
|
|
2420
3040
|
|
|
2421
3041
|
// src/index.js
|
|
3042
|
+
var DUMP_BATCH = 1e4;
|
|
2422
3043
|
var XSD = "http://www.w3.org/2001/XMLSchema#";
|
|
2423
3044
|
var INT_TYPES = new Set(
|
|
2424
3045
|
[
|
|
@@ -2526,6 +3147,14 @@ function parseLiteral(token) {
|
|
|
2526
3147
|
return new Term("literal", lex);
|
|
2527
3148
|
}
|
|
2528
3149
|
var cleanIri = (token) => Term.parse(token).value;
|
|
3150
|
+
function term(value, what) {
|
|
3151
|
+
if (value === void 0 || value === null) return "";
|
|
3152
|
+
if (value instanceof Term) return value.n3;
|
|
3153
|
+
if (typeof value !== "string")
|
|
3154
|
+
throw new TypeError(`the \`${what}\` option takes an IRI string, a Term, null, or undefined`);
|
|
3155
|
+
if (value.startsWith("<") || value.startsWith('"') || value.startsWith("_:")) return value;
|
|
3156
|
+
return `<${value}>`;
|
|
3157
|
+
}
|
|
2529
3158
|
var embeddedWasm = null;
|
|
2530
3159
|
var ready = null;
|
|
2531
3160
|
function __setWasmSource(bytes) {
|
|
@@ -2533,10 +3162,15 @@ function __setWasmSource(bytes) {
|
|
|
2533
3162
|
}
|
|
2534
3163
|
function init(source = null) {
|
|
2535
3164
|
ready ??= (async () => {
|
|
3165
|
+
const node = typeof process !== "undefined" && !!process.versions?.node;
|
|
3166
|
+
if (node && typeof globalThis.crypto?.getRandomValues !== "function") {
|
|
3167
|
+
const { webcrypto } = await import("node:crypto");
|
|
3168
|
+
Object.defineProperty(globalThis, "crypto", { value: webcrypto, configurable: true });
|
|
3169
|
+
}
|
|
2536
3170
|
const src = source ?? embeddedWasm;
|
|
2537
3171
|
if (src) {
|
|
2538
3172
|
await __wbg_init({ module_or_path: src });
|
|
2539
|
-
} else if (
|
|
3173
|
+
} else if (node) {
|
|
2540
3174
|
const { readFile } = await import("node:fs/promises");
|
|
2541
3175
|
const bytes = await readFile(new URL("./rete_wasm_bg.wasm", import.meta.url));
|
|
2542
3176
|
await __wbg_init({ module_or_path: bytes });
|
|
@@ -2549,15 +3183,34 @@ function init(source = null) {
|
|
|
2549
3183
|
var Graph2 = class {
|
|
2550
3184
|
#g;
|
|
2551
3185
|
#remote;
|
|
3186
|
+
#warnings = [];
|
|
2552
3187
|
constructor(inner, source, remote) {
|
|
2553
3188
|
this.#g = inner;
|
|
2554
3189
|
this.source = source;
|
|
2555
3190
|
this.#remote = remote;
|
|
2556
3191
|
}
|
|
2557
|
-
/**
|
|
3192
|
+
/**
|
|
3193
|
+
* The engine's raw JSON result envelope. Carries a `warnings` array when the
|
|
3194
|
+
* query raised type errors (see {@link Graph#lastWarnings}).
|
|
3195
|
+
*/
|
|
2558
3196
|
queryRaw(query2, { reason: reason2 = false } = {}) {
|
|
3197
|
+
this.#warnings = [];
|
|
2559
3198
|
const s = reason2 ? this.#g.query_reasoned(query2, "json") : this.#g.query(query2, "json");
|
|
2560
|
-
|
|
3199
|
+
const env = JSON.parse(s);
|
|
3200
|
+
this.#warnings = env.warnings ?? [];
|
|
3201
|
+
return env;
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Diagnostics from the most recent `query()` / `queryRaw()` on this graph:
|
|
3205
|
+
* the SPARQL type errors a FILTER silently turned into `false` (CONTAINS on
|
|
3206
|
+
* an IRI, STRSTARTS on a number, a language-tag mismatch, an invalid regex,
|
|
3207
|
+
* …), each `{severity, function, argument, argKind, count, sample, hint,
|
|
3208
|
+
* message}`, plus an optional case-sensitivity hint (`severity: "hint"`) for
|
|
3209
|
+
* an empty result. Empty when there is nothing to report. Results themselves
|
|
3210
|
+
* are never changed.
|
|
3211
|
+
*/
|
|
3212
|
+
lastWarnings() {
|
|
3213
|
+
return this.#warnings.map((w) => ({ ...w }));
|
|
2561
3214
|
}
|
|
2562
3215
|
/**
|
|
2563
3216
|
* Run a SPARQL query: SELECT → array of `{var: Term}` rows, ASK → boolean,
|
|
@@ -2612,7 +3265,11 @@ var Graph2 = class {
|
|
|
2612
3265
|
*/
|
|
2613
3266
|
card() {
|
|
2614
3267
|
const s = this.#g.card();
|
|
2615
|
-
|
|
3268
|
+
if (!s) return null;
|
|
3269
|
+
const card2 = JSON.parse(s);
|
|
3270
|
+
if (!card2.signals || typeof card2.signals !== "object") card2.signals = {};
|
|
3271
|
+
card2.signals.quoted_triples = JSON.parse(this.#g.quoted_triples_signal());
|
|
3272
|
+
return card2;
|
|
2616
3273
|
}
|
|
2617
3274
|
/**
|
|
2618
3275
|
* The example SPARQL queries the file ships with. Rich entries carry
|
|
@@ -2638,6 +3295,146 @@ var Graph2 = class {
|
|
|
2638
3295
|
get quads() {
|
|
2639
3296
|
return this.info().quads;
|
|
2640
3297
|
}
|
|
3298
|
+
// -------------------------------------------------------------------------
|
|
3299
|
+
// Streaming dump. See DUMP_BATCH for why this crosses the wasm boundary in
|
|
3300
|
+
// batches rather than one quad — or one whole graph — at a time.
|
|
3301
|
+
/**
|
|
3302
|
+
* Every quad of the graph, streamed lazily:
|
|
3303
|
+
* `for await (const [s, p, o, g] of graph.dump())`.
|
|
3304
|
+
*
|
|
3305
|
+
* (Named `dump()`, not `quads()`, because `graph.quads` is already this
|
|
3306
|
+
* client's quad **count** — the engine calls the streaming scan a dump too.)
|
|
3307
|
+
*
|
|
3308
|
+
* `g` is the graph Term, or `null` for the default graph. Nothing is ever
|
|
3309
|
+
* materialized: the engine decodes one triple per step and the wrapper holds
|
|
3310
|
+
* at most `batch` of them, so this runs in memory independent of the graph's
|
|
3311
|
+
* size — a billion-quad file streams in the same footprint as a thousand.
|
|
3312
|
+
*
|
|
3313
|
+
* Options:
|
|
3314
|
+
* - `graph`: omit (or `undefined`) for the default graph **followed by every
|
|
3315
|
+
* named graph**; `null` for the default graph only; an IRI string for that
|
|
3316
|
+
* named graph only.
|
|
3317
|
+
* - `raw: true` yields the engine's N-Triples term tokens (`"<urn:a>"`,
|
|
3318
|
+
* `'"x"@en'`) instead of `Term` objects — no per-term parsing, for when you
|
|
3319
|
+
* are re-serializing rather than inspecting.
|
|
3320
|
+
* - `batch`: quads fetched per wasm call (default 10 000).
|
|
3321
|
+
*/
|
|
3322
|
+
async *dump({ graph, subject, predicate, object, raw = false, batch = DUMP_BATCH } = {}) {
|
|
3323
|
+
const cursor = this.#cursor({ graph, subject, predicate, object });
|
|
3324
|
+
try {
|
|
3325
|
+
for (; ; ) {
|
|
3326
|
+
const flat = cursor.next_batch(batch);
|
|
3327
|
+
if (flat.length === 0) return;
|
|
3328
|
+
for (let i = 0; i < flat.length; i += 4) {
|
|
3329
|
+
const g = flat[i + 3];
|
|
3330
|
+
yield raw ? [flat[i], flat[i + 1], flat[i + 2], g === "" ? null : g] : [
|
|
3331
|
+
Term.parse(flat[i]),
|
|
3332
|
+
Term.parse(flat[i + 1]),
|
|
3333
|
+
Term.parse(flat[i + 2]),
|
|
3334
|
+
g === "" ? null : Term.parse(g)
|
|
3335
|
+
];
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
} finally {
|
|
3339
|
+
cursor.free();
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
/**
|
|
3343
|
+
* The graph as N-Quads text, in chunks — the constant-memory serialization
|
|
3344
|
+
* path. Each chunk is a batch's worth of complete lines (`\n`-terminated), so
|
|
3345
|
+
* chunks can be concatenated or written straight through:
|
|
3346
|
+
*
|
|
3347
|
+
* ```js
|
|
3348
|
+
* for await (const chunk of graph.nquads()) out.write(chunk);
|
|
3349
|
+
* ```
|
|
3350
|
+
*
|
|
3351
|
+
* Terms are already canonical N-Triples tokens inside the file, so the engine
|
|
3352
|
+
* emits the lines directly: one string per batch crosses the wasm boundary
|
|
3353
|
+
* instead of four per quad, and nothing is re-serialized in JavaScript.
|
|
3354
|
+
* Takes the same `graph` / `batch` options as {@link dump}.
|
|
3355
|
+
*
|
|
3356
|
+
* `quotedTripleSyntax` is how a quoted triple is spelled, with the values and
|
|
3357
|
+
* default of `rete export --quoted-triple-syntax`: `"rdf12"` (default) writes
|
|
3358
|
+
* the RDF 1.2 triple term `<<( s p o )>>`, which current parsers (Oxigraph
|
|
3359
|
+
* 0.5, Jena 5) load; `"rdf-star"` writes rete's stored `<<s p o>>`. RDF 1.2
|
|
3360
|
+
* has no triple term in subject position, so such a statement makes the
|
|
3361
|
+
* stream throw under `"rdf12"` (chunks already yielded stay yielded). A graph
|
|
3362
|
+
* with no quoted triples is written byte-for-byte the same either way.
|
|
3363
|
+
*/
|
|
3364
|
+
async *nquads({
|
|
3365
|
+
graph,
|
|
3366
|
+
subject,
|
|
3367
|
+
predicate,
|
|
3368
|
+
object,
|
|
3369
|
+
batch = DUMP_BATCH,
|
|
3370
|
+
quotedTripleSyntax = "rdf12"
|
|
3371
|
+
} = {}) {
|
|
3372
|
+
const cursor = this.#cursor({ graph, subject, predicate, object });
|
|
3373
|
+
try {
|
|
3374
|
+
cursor.set_quoted_triple_syntax(quotedTripleSyntax);
|
|
3375
|
+
for (; ; ) {
|
|
3376
|
+
const chunk = cursor.next_nquads(batch);
|
|
3377
|
+
if (chunk.length === 0) return;
|
|
3378
|
+
yield chunk;
|
|
3379
|
+
}
|
|
3380
|
+
} finally {
|
|
3381
|
+
cursor.free();
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
/**
|
|
3385
|
+
* Write the whole graph as N-Quads into `sink`, and return the byte length
|
|
3386
|
+
* written. `sink` may be a Node `Writable`, a WHATWG `WritableStream`, or any
|
|
3387
|
+
* function taking a string chunk — so:
|
|
3388
|
+
*
|
|
3389
|
+
* ```js
|
|
3390
|
+
* await graph.writeNQuads(createWriteStream("out.nq")); // Node
|
|
3391
|
+
* const parts = []; await graph.writeNQuads((c) => parts.push(c));
|
|
3392
|
+
* ```
|
|
3393
|
+
*
|
|
3394
|
+
* Memory stays flat: one batch of text is live at a time, and backpressure is
|
|
3395
|
+
* honored on both stream kinds.
|
|
3396
|
+
*/
|
|
3397
|
+
async writeNQuads(sink, options = {}) {
|
|
3398
|
+
const write = sinkWriter(sink);
|
|
3399
|
+
let bytes = 0;
|
|
3400
|
+
for await (const chunk of this.nquads(options)) {
|
|
3401
|
+
bytes += chunk.length;
|
|
3402
|
+
await write(chunk);
|
|
3403
|
+
}
|
|
3404
|
+
await write(null);
|
|
3405
|
+
return bytes;
|
|
3406
|
+
}
|
|
3407
|
+
/**
|
|
3408
|
+
* The whole graph as ONE N-Quads string — the ready-to-load form for
|
|
3409
|
+
* `store.load(text, {format: "application/n-quads"})` (Oxigraph, N3.js, …).
|
|
3410
|
+
*
|
|
3411
|
+
* Unlike {@link nquads} this necessarily holds the entire serialization in
|
|
3412
|
+
* memory, so it is for graphs you are willing to materialize; stream with
|
|
3413
|
+
* {@link nquads} / {@link writeNQuads} for anything large.
|
|
3414
|
+
*/
|
|
3415
|
+
async toNQuads(options = {}) {
|
|
3416
|
+
const parts = [];
|
|
3417
|
+
for await (const chunk of this.nquads(options)) parts.push(chunk);
|
|
3418
|
+
return parts.join("");
|
|
3419
|
+
}
|
|
3420
|
+
/**
|
|
3421
|
+
* Open an engine-side cursor for the `graph` / `subject` / `predicate` /
|
|
3422
|
+
* `object` options of the dump methods.
|
|
3423
|
+
*
|
|
3424
|
+
* The three term filters are not a row test the wrapper applies — they go into
|
|
3425
|
+
* the engine's scan as a triple pattern, which routes to one permutation and
|
|
3426
|
+
* drops every index tile whose synopsis proves it cannot match *before*
|
|
3427
|
+
* fetching it. That is what makes a filtered dump of a remote graph cost the
|
|
3428
|
+
* slice rather than the graph.
|
|
3429
|
+
*/
|
|
3430
|
+
#cursor({ graph, subject, predicate, object }) {
|
|
3431
|
+
let slot;
|
|
3432
|
+
if (graph === void 0) slot = void 0;
|
|
3433
|
+
else if (graph === null) slot = "";
|
|
3434
|
+
else if (typeof graph === "string") slot = graph;
|
|
3435
|
+
else throw new TypeError("the `graph` option takes an IRI string, null, or undefined");
|
|
3436
|
+
return this.#g.quads(slot, term(subject, "subject"), term(predicate, "predicate"), term(object, "object"));
|
|
3437
|
+
}
|
|
2641
3438
|
graphNames() {
|
|
2642
3439
|
return JSON.parse(this.#g.graph_names()).map(cleanIri);
|
|
2643
3440
|
}
|
|
@@ -2650,6 +3447,25 @@ var Graph2 = class {
|
|
|
2650
3447
|
return this.#remote ? this.#g.content_hash() : null;
|
|
2651
3448
|
}
|
|
2652
3449
|
};
|
|
3450
|
+
function sinkWriter(sink) {
|
|
3451
|
+
if (typeof sink === "function") return async (chunk) => chunk === null ? void 0 : sink(chunk);
|
|
3452
|
+
if (typeof sink?.getWriter === "function") {
|
|
3453
|
+
const writer = sink.getWriter();
|
|
3454
|
+
return async (chunk) => {
|
|
3455
|
+
if (chunk === null) return writer.releaseLock();
|
|
3456
|
+
await writer.ready;
|
|
3457
|
+
return writer.write(chunk);
|
|
3458
|
+
};
|
|
3459
|
+
}
|
|
3460
|
+
if (typeof sink?.write === "function") {
|
|
3461
|
+
return async (chunk) => {
|
|
3462
|
+
if (chunk === null) return void 0;
|
|
3463
|
+
if (sink.write(chunk) === false)
|
|
3464
|
+
await new Promise((resolve) => sink.once("drain", resolve));
|
|
3465
|
+
};
|
|
3466
|
+
}
|
|
3467
|
+
throw new TypeError("writeNQuads() takes a Writable, a WritableStream, or a function(chunk)");
|
|
3468
|
+
}
|
|
2653
3469
|
var isBytes = (s) => s instanceof Uint8Array || s instanceof ArrayBuffer || ArrayBuffer.isView(s);
|
|
2654
3470
|
async function open(source, { headers } = {}) {
|
|
2655
3471
|
await init();
|
|
@@ -2680,9 +3496,12 @@ async function open(source, { headers } = {}) {
|
|
|
2680
3496
|
}
|
|
2681
3497
|
throw new TypeError("open() takes a Uint8Array/ArrayBuffer or an http(s):// URL");
|
|
2682
3498
|
}
|
|
2683
|
-
async function build2(text, format = "nt") {
|
|
3499
|
+
async function build2(text, format = "nt", { quotedTripleSyntax = "rdf-star" } = {}) {
|
|
2684
3500
|
await init();
|
|
2685
|
-
return
|
|
3501
|
+
return build_with_card_syntax(text, format, "", quotedTripleSyntax);
|
|
3502
|
+
}
|
|
3503
|
+
function heapBytes() {
|
|
3504
|
+
return heap_bytes();
|
|
2686
3505
|
}
|
|
2687
3506
|
export {
|
|
2688
3507
|
Graph2 as Graph,
|
|
@@ -2690,6 +3509,7 @@ export {
|
|
|
2690
3509
|
Term,
|
|
2691
3510
|
__setWasmSource,
|
|
2692
3511
|
build2 as build,
|
|
3512
|
+
heapBytes,
|
|
2693
3513
|
init,
|
|
2694
3514
|
open,
|
|
2695
3515
|
rete_wasm_exports as wasm
|