@blackcatinformatics/purrdf 0.1.3
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/index.d.ts +37 -0
- package/index.mjs +128 -0
- package/package.json +44 -0
- package/pkg/purrdf_wasm.d.ts +327 -0
- package/pkg/purrdf_wasm.js +1131 -0
- package/pkg/purrdf_wasm_bg.wasm +0 -0
- package/pkg/purrdf_wasm_bg.wasm.d.ts +56 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Blackcat Informatics® Inc. <paudley@blackcatinformatics.ca>
|
|
2
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
3
|
+
|
|
4
|
+
// The wasm-bindgen-generated class declarations (DataFactory/Dataset/Quad/Sink/Term
|
|
5
|
+
// and the free `version()` function) are the source of truth for the engine surface.
|
|
6
|
+
export {
|
|
7
|
+
DataFactory,
|
|
8
|
+
Dataset,
|
|
9
|
+
Quad,
|
|
10
|
+
Sink,
|
|
11
|
+
Term,
|
|
12
|
+
version,
|
|
13
|
+
} from "./pkg/purrdf_wasm.js";
|
|
14
|
+
|
|
15
|
+
import type { Dataset, Quad } from "./pkg/purrdf_wasm.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Instantiate the wasm module. Idempotent; await once before using any other API.
|
|
19
|
+
* In Node the wasm bytes load from the colocated file automatically; in a browser,
|
|
20
|
+
* pass the bytes/URL or omit to fetch the colocated `.wasm`.
|
|
21
|
+
*
|
|
22
|
+
* After `ready()`, the RDF/JS surface augmentations are live: `Dataset` is iterable
|
|
23
|
+
* (`for (const quad of dataset)`); `Dataset.add`/`Dataset.delete` return the dataset
|
|
24
|
+
* instance so calls chain (`ds.add(q1).add(q2)`); `Term.equals`/`Quad.equals` return
|
|
25
|
+
* `false` for `null`/`undefined` instead of throwing; and
|
|
26
|
+
* `DataFactory.literal(value, languageOrDatatype)` accepts a `NamedNode` datatype as
|
|
27
|
+
* the RDF/JS spec allows (dispatching to `typedLiteral`).
|
|
28
|
+
*/
|
|
29
|
+
export function ready(wasmBytesOrUrl?: BufferSource | URL | string): Promise<void>;
|
|
30
|
+
|
|
31
|
+
/** An RDF/JS Stream (async iterable) of the dataset's quads. */
|
|
32
|
+
export function datasetToStream(dataset: Dataset): AsyncIterableIterator<Quad>;
|
|
33
|
+
|
|
34
|
+
/** Consume an (async) iterable of quads into a new Dataset via the engine's Sink. */
|
|
35
|
+
export function streamToDataset(
|
|
36
|
+
quadStream: AsyncIterable<Quad> | Iterable<Quad>,
|
|
37
|
+
): Promise<Dataset>;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Blackcat Informatics® Inc. <paudley@blackcatinformatics.ca>
|
|
2
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
3
|
+
|
|
4
|
+
// purrdf — the idiomatic RDF/JS surface over the wasm engine.
|
|
5
|
+
//
|
|
6
|
+
// The wasm-bindgen-generated classes (DataFactory/Dataset/Quad/Sink/Term) are
|
|
7
|
+
// re-exported as-is; this wrapper adds the isomorphic glue that the synchronous
|
|
8
|
+
// wasm boundary cannot express in Rust:
|
|
9
|
+
// * `ready()` — one-time async wasm instantiation (required for the `web` target).
|
|
10
|
+
// * the polymorphic RDF/JS `DataFactory.literal(value, languageOrDatatype)` —
|
|
11
|
+
// dispatching a NamedNode datatype argument to `typedLiteral` (a wasm-bindgen
|
|
12
|
+
// exported type can't be recovered from an untyped value in Rust).
|
|
13
|
+
// * `Dataset` iterability (`for (const quad of dataset)`).
|
|
14
|
+
// * `datasetToStream` / `streamToDataset` — the async RDF/JS Stream/Sink primitives
|
|
15
|
+
// over the synchronous `Dataset.quads()` / `Sink` engine surface.
|
|
16
|
+
|
|
17
|
+
import init, {
|
|
18
|
+
DataFactory,
|
|
19
|
+
Dataset,
|
|
20
|
+
Quad,
|
|
21
|
+
Sink,
|
|
22
|
+
Term,
|
|
23
|
+
version,
|
|
24
|
+
} from "./pkg/purrdf_wasm.js";
|
|
25
|
+
|
|
26
|
+
let _ready = false;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Instantiate the wasm module. Idempotent. In Node the wasm bytes are read from the
|
|
30
|
+
* colocated file; in a browser, pass the bytes/URL (or omit to fetch the colocated
|
|
31
|
+
* `.wasm`). Must be awaited once before any other API is used.
|
|
32
|
+
*/
|
|
33
|
+
export async function ready(wasmBytesOrUrl) {
|
|
34
|
+
if (_ready) return;
|
|
35
|
+
if (wasmBytesOrUrl !== undefined) {
|
|
36
|
+
await init({ module_or_path: wasmBytesOrUrl });
|
|
37
|
+
} else if (typeof process !== "undefined" && process.versions?.node) {
|
|
38
|
+
const { readFile } = await import("node:fs/promises");
|
|
39
|
+
const { fileURLToPath } = await import("node:url");
|
|
40
|
+
const wasmPath = fileURLToPath(
|
|
41
|
+
new URL("./pkg/purrdf_wasm_bg.wasm", import.meta.url),
|
|
42
|
+
);
|
|
43
|
+
await init({ module_or_path: await readFile(wasmPath) });
|
|
44
|
+
} else {
|
|
45
|
+
await init();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// RDF/JS DatasetCore is iterable over its quads.
|
|
49
|
+
if (!Dataset.prototype[Symbol.iterator]) {
|
|
50
|
+
Dataset.prototype[Symbol.iterator] = function () {
|
|
51
|
+
return this.quads()[Symbol.iterator]();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// RDF/JS DatasetCore.add(quad)/delete(quad) MUST return the dataset instance so calls
|
|
56
|
+
// chain (`ds.add(q1).add(q2)`). The wasm methods return a bool ("did the effective set
|
|
57
|
+
// change?"); the spec surface returns `this` (the changed-bit stays observable via
|
|
58
|
+
// `size`). The guard applied here is the same boundary the equals/literal shims use.
|
|
59
|
+
for (const method of ["add", "delete"]) {
|
|
60
|
+
const flag = `__purrdfChaining_${method}`;
|
|
61
|
+
if (!Dataset.prototype[flag]) {
|
|
62
|
+
const wasmMutate = Dataset.prototype[method];
|
|
63
|
+
Dataset.prototype[method] = function (quad) {
|
|
64
|
+
wasmMutate.call(this, quad);
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
Dataset.prototype[flag] = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// RDF/JS spec: Term.equals(other) / Quad.equals(other) MUST return false when `other`
|
|
72
|
+
// is null or undefined — "Returns false if other is undefined or null." The wasm
|
|
73
|
+
// `equals` takes a borrowed `&Term`/`&Quad` (non-consuming — the argument stays usable
|
|
74
|
+
// afterwards), but wasm-bindgen throws on a null borrow, so the null/undefined guard is
|
|
75
|
+
// applied here, one layer out (the same boundary where the polymorphic literal() lives).
|
|
76
|
+
for (const Klass of [Term, Quad]) {
|
|
77
|
+
if (!Klass.prototype.__purrdfNullSafeEquals) {
|
|
78
|
+
const wasmEquals = Klass.prototype.equals;
|
|
79
|
+
Klass.prototype.equals = function (other) {
|
|
80
|
+
if (other === null || other === undefined) return false;
|
|
81
|
+
return wasmEquals.call(this, other);
|
|
82
|
+
};
|
|
83
|
+
Klass.prototype.__purrdfNullSafeEquals = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Present the RDF/JS-spec polymorphic literal(value, languageOrDatatype). The wasm
|
|
88
|
+
// method takes `(value, language?)`; a NamedNode second argument is a datatype.
|
|
89
|
+
if (!DataFactory.prototype.__purrdfPolymorphicLiteral) {
|
|
90
|
+
const wasmLiteral = DataFactory.prototype.literal;
|
|
91
|
+
DataFactory.prototype.literal = function (value, languageOrDatatype) {
|
|
92
|
+
if (
|
|
93
|
+
languageOrDatatype != null &&
|
|
94
|
+
typeof languageOrDatatype === "object" &&
|
|
95
|
+
languageOrDatatype.termType === "NamedNode"
|
|
96
|
+
) {
|
|
97
|
+
return this.typedLiteral(value, languageOrDatatype);
|
|
98
|
+
}
|
|
99
|
+
return wasmLiteral.call(this, value, languageOrDatatype ?? undefined);
|
|
100
|
+
};
|
|
101
|
+
DataFactory.prototype.__purrdfPolymorphicLiteral = true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
_ready = true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* An RDF/JS Stream of the dataset's quads — an async iterable. (The engine is
|
|
109
|
+
* synchronous; the async wrapper is the RDF/JS Stream contract.)
|
|
110
|
+
*/
|
|
111
|
+
export function datasetToStream(dataset) {
|
|
112
|
+
const quads = dataset.quads();
|
|
113
|
+
return (async function* () {
|
|
114
|
+
for (const quad of quads) yield quad;
|
|
115
|
+
})();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Consume an (async) iterable of quads into a new Dataset, via the engine's streaming
|
|
120
|
+
* Sink (the purrdf-events ingestion protocol + its finish() resolution).
|
|
121
|
+
*/
|
|
122
|
+
export async function streamToDataset(quadStream) {
|
|
123
|
+
const sink = new Sink();
|
|
124
|
+
for await (const quad of quadStream) sink.push(quad);
|
|
125
|
+
return sink.finish();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { DataFactory, Dataset, Quad, Sink, Term, version };
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blackcatinformatics/purrdf",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "A wasm32, in-memory RDF 1.2 engine with an idiomatic RDF/JS (DataFactory/Dataset/Stream) API. Quoted-triple terms and directional literals included.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"author": "Blackcat Informatics® Inc. <paudley@blackcatinformatics.ca>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Blackcat-Informatics/purrdf"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"rdf",
|
|
14
|
+
"rdf-1.2",
|
|
15
|
+
"rdf-star",
|
|
16
|
+
"rdfjs",
|
|
17
|
+
"wasm",
|
|
18
|
+
"turtle",
|
|
19
|
+
"n-quads"
|
|
20
|
+
],
|
|
21
|
+
"main": "./index.mjs",
|
|
22
|
+
"module": "./index.mjs",
|
|
23
|
+
"types": "./index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"import": "./index.mjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"index.mjs",
|
|
32
|
+
"index.d.ts",
|
|
33
|
+
"pkg/purrdf_wasm.js",
|
|
34
|
+
"pkg/purrdf_wasm.d.ts",
|
|
35
|
+
"pkg/purrdf_wasm_bg.wasm",
|
|
36
|
+
"pkg/purrdf_wasm_bg.wasm.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"test": "node --test tests/*.test.mjs"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An RDF/JS `DataFactory`. Stateless except for the auto-generated blank-node
|
|
6
|
+
* counter (`blankNode()` with no argument mints a fresh label).
|
|
7
|
+
*/
|
|
8
|
+
export class DataFactory {
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* `blankNode(value?)` → a `BlankNode` term; a fresh label is minted when omitted.
|
|
13
|
+
*/
|
|
14
|
+
blankNode(value?: string | null): Term;
|
|
15
|
+
/**
|
|
16
|
+
* `defaultGraph()` → the `DefaultGraph` term.
|
|
17
|
+
*/
|
|
18
|
+
defaultGraph(): Term;
|
|
19
|
+
/**
|
|
20
|
+
* `directionalLiteral(value, language, direction)` → an RDF-1.2 base-direction
|
|
21
|
+
* literal (`direction` is `"ltr"` or `"rtl"`). The deliberate extension to stock
|
|
22
|
+
* RDF/JS — no incumbent library carries base direction.
|
|
23
|
+
*/
|
|
24
|
+
directionalLiteral(value: string, language: string, direction: string): Term;
|
|
25
|
+
/**
|
|
26
|
+
* `fromQuad(original)` → a copy of `original`.
|
|
27
|
+
*/
|
|
28
|
+
fromQuad(original: Quad): Quad;
|
|
29
|
+
/**
|
|
30
|
+
* `fromTerm(original)` → a copy of `original` (RDF/JS structural clone).
|
|
31
|
+
*/
|
|
32
|
+
fromTerm(original: Term): Term;
|
|
33
|
+
/**
|
|
34
|
+
* `literal(value, language?)` → a plain (`xsd:string`) or language-tagged literal.
|
|
35
|
+
*
|
|
36
|
+
* The RDF/JS spec's unified `literal(value, languageOrDatatype)` — where the second
|
|
37
|
+
* argument may be a string *or* a `NamedNode` — is presented by the TypeScript
|
|
38
|
+
* wrapper, which dispatches the `NamedNode` case to [`DataFactory::typed_literal`].
|
|
39
|
+
* (A `#[wasm_bindgen]`-exported type cannot be recovered from an untyped `JsValue`
|
|
40
|
+
* in Rust, so the polymorphism lives one layer out, in JS.) For base-direction
|
|
41
|
+
* literals (RDF 1.2) use [`DataFactory::directional_literal`].
|
|
42
|
+
*/
|
|
43
|
+
literal(value: string, language?: string | null): Term;
|
|
44
|
+
/**
|
|
45
|
+
* `namedNode(value)` → a `NamedNode` term.
|
|
46
|
+
*/
|
|
47
|
+
namedNode(value: string): Term;
|
|
48
|
+
constructor();
|
|
49
|
+
/**
|
|
50
|
+
* `quad(subject, predicate, object, graph?)` → a `Quad`. The graph defaults to the
|
|
51
|
+
* default graph. A quoted-triple term (from [`DataFactory::quoted_triple`]) may be
|
|
52
|
+
* passed as `subject` or `object` (the RDF-1.2 wedge).
|
|
53
|
+
*/
|
|
54
|
+
quad(subject: Term, predicate: Term, object: Term, graph?: Term | null): Quad;
|
|
55
|
+
/**
|
|
56
|
+
* `quotedTriple(subject, predicate, object)` → a quoted-triple `Term`
|
|
57
|
+
* (`termType: "Quad"`) — the RDF-1.2 wedge. Embed it by passing it as the
|
|
58
|
+
* `subject`/`object` of another quad.
|
|
59
|
+
*/
|
|
60
|
+
quotedTriple(subject: Term, predicate: Term, object: Term): Term;
|
|
61
|
+
/**
|
|
62
|
+
* `typedLiteral(value, datatype)` → a datatyped literal. `datatype` must be a
|
|
63
|
+
* `NamedNode`. (The RDF/JS `literal(value, datatype)` form, surfaced by the TS
|
|
64
|
+
* wrapper.)
|
|
65
|
+
*/
|
|
66
|
+
typedLiteral(value: string, datatype: Term): Term;
|
|
67
|
+
/**
|
|
68
|
+
* `variable(value)` → a `Variable` term.
|
|
69
|
+
*/
|
|
70
|
+
variable(value: string): Term;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* An RDF/JS `DatasetCore` backed by the engine's COW mutable dataset.
|
|
75
|
+
*/
|
|
76
|
+
export class Dataset {
|
|
77
|
+
free(): void;
|
|
78
|
+
[Symbol.dispose](): void;
|
|
79
|
+
/**
|
|
80
|
+
* `add(quad)` → insert a quad. Returns `true` if the effective set changed.
|
|
81
|
+
*/
|
|
82
|
+
add(quad: Quad): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* `delete(quad)` → remove a quad. Returns `true` if the effective set changed.
|
|
85
|
+
*/
|
|
86
|
+
delete(quad: Quad): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* `has(quad)` → whether the quad is in the dataset.
|
|
89
|
+
*/
|
|
90
|
+
has(quad: Quad): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* `match(subject?, predicate?, object?, graph?)` → a new dataset of the matching
|
|
93
|
+
* quads. An omitted (`undefined`) position is a wildcard; `defaultGraph()` matches
|
|
94
|
+
* only the default graph, a named node matches that graph.
|
|
95
|
+
*/
|
|
96
|
+
match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset;
|
|
97
|
+
/**
|
|
98
|
+
* An empty dataset.
|
|
99
|
+
*/
|
|
100
|
+
constructor();
|
|
101
|
+
/**
|
|
102
|
+
* `parse(input, format, base?)` → a dataset of the parsed quads.
|
|
103
|
+
*
|
|
104
|
+
* `format` is a media type or short name (turtle/ntriples/nquads/trig/rdfxml).
|
|
105
|
+
* Ill-typed literals are preserved verbatim (RDFLib parity), not rejected.
|
|
106
|
+
*/
|
|
107
|
+
static parse(input: string, format: string, base?: string | null): Dataset;
|
|
108
|
+
/**
|
|
109
|
+
* `quads()` → every effective quad, as a JS array.
|
|
110
|
+
*/
|
|
111
|
+
quads(): Quad[];
|
|
112
|
+
/**
|
|
113
|
+
* `query(sparql, base?)` → run a SPARQL query against this dataset, offline.
|
|
114
|
+
*
|
|
115
|
+
* Returns **SPARQL Results JSON** for SELECT / ASK and **Turtle** for
|
|
116
|
+
* CONSTRUCT / DESCRIBE. A parse error, an evaluation error, or a `SERVICE` /
|
|
117
|
+
* `LOAD` clause (unresolvable in-browser) throws a JsError — never a silent
|
|
118
|
+
* empty result.
|
|
119
|
+
*/
|
|
120
|
+
query(sparql: string, base?: string | null): string;
|
|
121
|
+
/**
|
|
122
|
+
* `serialize(format)` → the dataset rendered in `format` (a UTF-8 string).
|
|
123
|
+
*
|
|
124
|
+
* Formats: `turtle` / `ntriples` / `nquads` / `trig` / `rdfxml` (their media types
|
|
125
|
+
* too) plus `jsonld` (JSON-LD-star). Note: a quoted-triple term appearing as a quad
|
|
126
|
+
* object currently round-trips only through N-Quads (a serializer limitation for
|
|
127
|
+
* the other text formats).
|
|
128
|
+
*/
|
|
129
|
+
serialize(format: string): string;
|
|
130
|
+
/**
|
|
131
|
+
* `size` — the number of effective quads.
|
|
132
|
+
*/
|
|
133
|
+
readonly size: number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* An RDF/JS [Quad](https://rdf.js.org/data-model-spec/#quad-interface) — a statement
|
|
138
|
+
* `(subject, predicate, object, graph)` with `termType: "Quad"`.
|
|
139
|
+
*/
|
|
140
|
+
export class Quad {
|
|
141
|
+
private constructor();
|
|
142
|
+
free(): void;
|
|
143
|
+
[Symbol.dispose](): void;
|
|
144
|
+
/**
|
|
145
|
+
* A quoted-triple [`Term`] (`termType: "Quad"`) viewing this quad's `(s, p, o)` —
|
|
146
|
+
* the RDF-1.2 wedge: pass the result as a subject/object to embed it.
|
|
147
|
+
*/
|
|
148
|
+
asTerm(): Term;
|
|
149
|
+
/**
|
|
150
|
+
* Structural RDF/JS quad equality.
|
|
151
|
+
*/
|
|
152
|
+
equals(other: Quad): boolean;
|
|
153
|
+
readonly graph: Term;
|
|
154
|
+
readonly object: Term;
|
|
155
|
+
readonly predicate: Term;
|
|
156
|
+
readonly subject: Term;
|
|
157
|
+
/**
|
|
158
|
+
* Always `"Quad"` (a Quad is itself an RDF/JS term).
|
|
159
|
+
*/
|
|
160
|
+
readonly termType: string;
|
|
161
|
+
/**
|
|
162
|
+
* Empty for a Quad (per RDF/JS).
|
|
163
|
+
*/
|
|
164
|
+
readonly value: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* An RDF/JS `Sink` — a streaming consumer that interns pushed quads through the
|
|
169
|
+
* `purrdf-events` protocol and freezes them at `finish()`.
|
|
170
|
+
*/
|
|
171
|
+
export class Sink {
|
|
172
|
+
free(): void;
|
|
173
|
+
[Symbol.dispose](): void;
|
|
174
|
+
/**
|
|
175
|
+
* `finish()` — run the protocol's forward-reference resolution and return the
|
|
176
|
+
* resulting dataset. The sink is consumed; further `push`/`finish` is an error.
|
|
177
|
+
*/
|
|
178
|
+
finish(): Dataset;
|
|
179
|
+
constructor();
|
|
180
|
+
/**
|
|
181
|
+
* `push(quad)` — stream one quad into the sink (interned via the event protocol).
|
|
182
|
+
*/
|
|
183
|
+
push(quad: Quad): void;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* An RDF/JS [Term](https://rdf.js.org/data-model-spec/#term-interface).
|
|
188
|
+
*/
|
|
189
|
+
export class Term {
|
|
190
|
+
private constructor();
|
|
191
|
+
free(): void;
|
|
192
|
+
[Symbol.dispose](): void;
|
|
193
|
+
/**
|
|
194
|
+
* Structural RDF/JS term equality.
|
|
195
|
+
*/
|
|
196
|
+
equals(other: Term): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* `datatype` — the literal's datatype as a `NamedNode`, or `undefined` for a
|
|
199
|
+
* non-literal.
|
|
200
|
+
*/
|
|
201
|
+
readonly datatype: Term | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* `direction` — the RDF-1.2 base direction (`"ltr"`/`"rtl"`), or `""` when absent.
|
|
204
|
+
* The deliberate extension to stock RDF/JS (`.goals`: overcome, don't inherit).
|
|
205
|
+
*/
|
|
206
|
+
readonly direction: string;
|
|
207
|
+
/**
|
|
208
|
+
* `graph` of a quoted-triple term — always the default graph (a quoted triple has
|
|
209
|
+
* no graph slot), else `undefined`.
|
|
210
|
+
*/
|
|
211
|
+
readonly graph: Term | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* `language` — the literal's language tag, or `""` for a non-language-tagged term
|
|
214
|
+
* (RDF/JS uses the empty string, not `undefined`).
|
|
215
|
+
*/
|
|
216
|
+
readonly language: string;
|
|
217
|
+
/**
|
|
218
|
+
* `object` of a quoted-triple term, else `undefined`.
|
|
219
|
+
*/
|
|
220
|
+
readonly object: Term | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* `predicate` of a quoted-triple term as a `NamedNode`, else `undefined`.
|
|
223
|
+
*/
|
|
224
|
+
readonly predicate: Term | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* `subject` of a quoted-triple term (`termType: "Quad"`), else `undefined`.
|
|
227
|
+
*/
|
|
228
|
+
readonly subject: Term | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* `termType` — the RDF/JS discriminator.
|
|
231
|
+
*/
|
|
232
|
+
readonly termType: string;
|
|
233
|
+
/**
|
|
234
|
+
* `value` — the IRI, blank label, lexical form, or variable name. Empty for a
|
|
235
|
+
* quoted triple and the default graph (per RDF/JS).
|
|
236
|
+
*/
|
|
237
|
+
readonly value: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The purrdf engine version (the crate's SemVer), exposed to JS as `version()`.
|
|
242
|
+
*
|
|
243
|
+
* A liveness probe for the wasm build + the npm package: importing `purrdf` and
|
|
244
|
+
* calling `version()` proves the module instantiated and the engine linked.
|
|
245
|
+
*/
|
|
246
|
+
export function version(): string;
|
|
247
|
+
|
|
248
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
249
|
+
|
|
250
|
+
export interface InitOutput {
|
|
251
|
+
readonly memory: WebAssembly.Memory;
|
|
252
|
+
readonly __wbg_datafactory_free: (a: number, b: number) => void;
|
|
253
|
+
readonly __wbg_dataset_free: (a: number, b: number) => void;
|
|
254
|
+
readonly __wbg_quad_free: (a: number, b: number) => void;
|
|
255
|
+
readonly __wbg_sink_free: (a: number, b: number) => void;
|
|
256
|
+
readonly __wbg_term_free: (a: number, b: number) => void;
|
|
257
|
+
readonly datafactory_blankNode: (a: number, b: number, c: number) => number;
|
|
258
|
+
readonly datafactory_defaultGraph: (a: number) => number;
|
|
259
|
+
readonly datafactory_directionalLiteral: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
260
|
+
readonly datafactory_fromQuad: (a: number, b: number) => number;
|
|
261
|
+
readonly datafactory_fromTerm: (a: number, b: number) => number;
|
|
262
|
+
readonly datafactory_literal: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
263
|
+
readonly datafactory_namedNode: (a: number, b: number, c: number) => number;
|
|
264
|
+
readonly datafactory_new: () => number;
|
|
265
|
+
readonly datafactory_quad: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
266
|
+
readonly datafactory_quotedTriple: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
267
|
+
readonly datafactory_typedLiteral: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
268
|
+
readonly datafactory_variable: (a: number, b: number, c: number) => number;
|
|
269
|
+
readonly dataset_add: (a: number, b: number, c: number) => void;
|
|
270
|
+
readonly dataset_delete: (a: number, b: number, c: number) => void;
|
|
271
|
+
readonly dataset_has: (a: number, b: number, c: number) => void;
|
|
272
|
+
readonly dataset_match: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
273
|
+
readonly dataset_new: (a: number) => void;
|
|
274
|
+
readonly dataset_parse: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
275
|
+
readonly dataset_quads: (a: number, b: number) => void;
|
|
276
|
+
readonly dataset_query: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
277
|
+
readonly dataset_serialize: (a: number, b: number, c: number, d: number) => void;
|
|
278
|
+
readonly dataset_size: (a: number) => number;
|
|
279
|
+
readonly quad_asTerm: (a: number, b: number) => void;
|
|
280
|
+
readonly quad_equals: (a: number, b: number) => number;
|
|
281
|
+
readonly quad_graph: (a: number) => number;
|
|
282
|
+
readonly quad_object: (a: number) => number;
|
|
283
|
+
readonly quad_predicate: (a: number) => number;
|
|
284
|
+
readonly quad_subject: (a: number) => number;
|
|
285
|
+
readonly quad_term_type: (a: number, b: number) => void;
|
|
286
|
+
readonly quad_value: (a: number, b: number) => void;
|
|
287
|
+
readonly sink_finish: (a: number, b: number) => void;
|
|
288
|
+
readonly sink_new: () => number;
|
|
289
|
+
readonly sink_push: (a: number, b: number, c: number) => void;
|
|
290
|
+
readonly term_datatype: (a: number) => number;
|
|
291
|
+
readonly term_direction: (a: number, b: number) => void;
|
|
292
|
+
readonly term_equals: (a: number, b: number) => number;
|
|
293
|
+
readonly term_graph: (a: number) => number;
|
|
294
|
+
readonly term_language: (a: number, b: number) => void;
|
|
295
|
+
readonly term_object: (a: number) => number;
|
|
296
|
+
readonly term_predicate: (a: number) => number;
|
|
297
|
+
readonly term_subject: (a: number) => number;
|
|
298
|
+
readonly term_term_type: (a: number, b: number) => void;
|
|
299
|
+
readonly term_value: (a: number, b: number) => void;
|
|
300
|
+
readonly version: (a: number) => void;
|
|
301
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
302
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
303
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
304
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
311
|
+
* a precompiled `WebAssembly.Module`.
|
|
312
|
+
*
|
|
313
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
314
|
+
*
|
|
315
|
+
* @returns {InitOutput}
|
|
316
|
+
*/
|
|
317
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
321
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
322
|
+
*
|
|
323
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
324
|
+
*
|
|
325
|
+
* @returns {Promise<InitOutput>}
|
|
326
|
+
*/
|
|
327
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|