@quarb/wasm 0.27.0 → 0.29.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 +49 -7
- package/index.d.ts +49 -0
- package/index.js +55 -3
- package/package.json +6 -3
- package/quai.js +2 -2
- package/quai_wasm_bg.wasm +0 -0
- package/quarb_wasm.d.ts +67 -0
- package/quarb_wasm.js +195 -0
- package/quarb_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
compiled to WebAssembly, with TypeScript types. One path
|
|
5
5
|
language over JSON, YAML, TOML, CSV/TSV, XML, HTML, and
|
|
6
6
|
Markdown — including the text-level reading of HTML, Markdown,
|
|
7
|
-
and plain text (sections, paragraphs, quotes, lists) —
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[playground](https://demo.quarb.org)
|
|
11
|
-
|
|
7
|
+
and plain text (sections, paragraphs, quotes, lists) — and the
|
|
8
|
+
web level, a whole website as one queryable tree, running
|
|
9
|
+
entirely client-side: no server, no native dependency, the same
|
|
10
|
+
engine that powers the [playground](https://demo.quarb.org), the
|
|
11
|
+
[search box on quarb.org](https://quarb.org/search.html), and
|
|
12
|
+
the Quarb Scraper browser extension.
|
|
12
13
|
|
|
13
14
|
## Install
|
|
14
15
|
|
|
@@ -50,6 +51,47 @@ const envelope = JSON.parse(run('csv', csv, '/row @| count', Date.now()));
|
|
|
50
51
|
// {ok: true, lines: ["891"]} — or {ok: false, error: "..."}
|
|
51
52
|
```
|
|
52
53
|
|
|
54
|
+
## A website as one tree
|
|
55
|
+
|
|
56
|
+
Pack a static site's pages into a tarball and the engine reads
|
|
57
|
+
it at the web level: every page under
|
|
58
|
+
`/sites/<host>/pages/<path>`, the links between pages resolved
|
|
59
|
+
into `->link` / `<-link`, tags and categories the pages declare
|
|
60
|
+
as rows of their own, and each page readable at the text level
|
|
61
|
+
(sections, paragraphs). That is a site search with no server:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
tar czf site.tgz -C public . # every .html under public/
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { openSite } from '@quarb/wasm';
|
|
69
|
+
|
|
70
|
+
const bytes = await fetch('/site.tgz').then((r) => r.arrayBuffer());
|
|
71
|
+
const site = await openSite(bytes, { base: 'https://example.org/' });
|
|
72
|
+
|
|
73
|
+
// Full-text search: the paragraphs that mention both words,
|
|
74
|
+
// each as a link record — title, href to the block, the text.
|
|
75
|
+
site.query('//paragraph[:: == (/arbor.*?query/i)] | link | json');
|
|
76
|
+
|
|
77
|
+
// The site's own structure.
|
|
78
|
+
site.query('//page::title'); // every page
|
|
79
|
+
site.query('//page[::in_degree = 0]::path'); // orphans
|
|
80
|
+
site.query('/sites/example.org/pages/about.html | <-link::path');
|
|
81
|
+
site.query('//page @| top(5; ::pagerank) | %(::path; ::pagerank)');
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`base` is the site's root URL; without it the engine reads the
|
|
85
|
+
base off a page's `<link rel="canonical">` and falls back to
|
|
86
|
+
`https://localhost/`. A site small enough to hold in memory
|
|
87
|
+
needs no tarball: pass an object of path to HTML
|
|
88
|
+
(`openSite({ 'index.html': html, 'about.html': html2 })`). Load
|
|
89
|
+
once and query many times; a Web Worker keeps a slow query off
|
|
90
|
+
the page thread (the search box on quarb.org is
|
|
91
|
+
[built this way](https://quarb.org/articles/the-site-that-ranks-itself.html)).
|
|
92
|
+
Pass `model` for a Quarb model file over the site (aliases,
|
|
93
|
+
derived nodes, edges).
|
|
94
|
+
|
|
53
95
|
## Sessions: `@quarb/wasm/quai`
|
|
54
96
|
|
|
55
97
|
The second entry point is the **session engine** — the build
|
|
@@ -93,8 +135,8 @@ authoritative reference.
|
|
|
93
135
|
|
|
94
136
|
## Scope
|
|
95
137
|
|
|
96
|
-
This package bundles the text-format adapters listed above
|
|
97
|
-
The full engine — 40+ adapters from SQLite and Postgres to
|
|
138
|
+
This package bundles the text-format adapters listed above, the
|
|
139
|
+
text level, and the web level over a tarball. The full engine — 40+ adapters from SQLite and Postgres to
|
|
98
140
|
Kafka, S3, and cloud log services, plus the `qua` CLI and the
|
|
99
141
|
`quai` interactive session — ships as
|
|
100
142
|
[Rust crates](https://crates.io/crates/quarb) and a
|
package/index.d.ts
CHANGED
|
@@ -58,3 +58,52 @@ export function run(
|
|
|
58
58
|
|
|
59
59
|
/** The engine version, e.g. `"0.12.0"`. */
|
|
60
60
|
export function version(): string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A website loaded once and queried many times at the web level:
|
|
64
|
+
* every page under `/sites/<host>/pages/<path>`, the tags and
|
|
65
|
+
* categories the pages declare as rows of their own, every
|
|
66
|
+
* hyperlink resolved (`->link`, `<-link`, `::in_degree`,
|
|
67
|
+
* `::pagerank`), each page readable at the text level
|
|
68
|
+
* (`//section`, `//paragraph`, `| link`). Construct with
|
|
69
|
+
* {@link openSite}.
|
|
70
|
+
*/
|
|
71
|
+
export class Site {
|
|
72
|
+
/**
|
|
73
|
+
* Run a Quarb query over the site. Returns the result lines
|
|
74
|
+
* (node results as locators such as
|
|
75
|
+
* `/sites/example.org/pages/about.html!/section[2]`); throws on
|
|
76
|
+
* a parse or execution error. `opts.now` pins `now()`.
|
|
77
|
+
*/
|
|
78
|
+
query(q: string, opts?: { now?: number }): string[];
|
|
79
|
+
/** The raw JSON envelope of a query; never throws. */
|
|
80
|
+
run(q: string, now?: number): string;
|
|
81
|
+
/** Every page as a locator, sorted. */
|
|
82
|
+
entries(): string[];
|
|
83
|
+
/** Every page's locator with its declared `<title>`. */
|
|
84
|
+
titles(): Record<string, string>;
|
|
85
|
+
/** Release the wasm memory the site holds. */
|
|
86
|
+
free(): void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Open a site: a tarball of its pages (`.tar` or `.tar.gz`, as
|
|
91
|
+
* bytes), or an object of site-relative path to HTML for a site
|
|
92
|
+
* small enough to hold in memory.
|
|
93
|
+
*
|
|
94
|
+
* `opts.base` is the site's root URL (`https://example.org/`)
|
|
95
|
+
* that page paths and relative links join against; by default it
|
|
96
|
+
* is read off a page's canonical URL, and is `https://localhost/`
|
|
97
|
+
* when no page declares one. `opts.model` is a Quarb model file
|
|
98
|
+
* over the site (aliases, derived nodes, edges). `opts.wasm`
|
|
99
|
+
* forwards to {@link initQuarb} when the engine is not yet
|
|
100
|
+
* initialized.
|
|
101
|
+
*/
|
|
102
|
+
export function openSite(
|
|
103
|
+
source: Uint8Array | ArrayBuffer | Record<string, string>,
|
|
104
|
+
opts?: {
|
|
105
|
+
base?: string;
|
|
106
|
+
model?: string;
|
|
107
|
+
wasm?: BufferSource | WebAssembly.Module | Response | Promise<Response>;
|
|
108
|
+
}
|
|
109
|
+
): Promise<Site>;
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// envelope. The raw wasm-bindgen surface stays exported for
|
|
7
7
|
// callers that want to manage initialization themselves.
|
|
8
8
|
|
|
9
|
-
import init, { run, version } from './quarb_wasm.js';
|
|
9
|
+
import init, { run, version, Site as WasmSite } from './quarb_wasm.js';
|
|
10
10
|
|
|
11
11
|
let ready;
|
|
12
12
|
|
|
@@ -15,10 +15,10 @@ export function initQuarb(input) {
|
|
|
15
15
|
if (!ready) {
|
|
16
16
|
if (input === undefined && typeof process !== 'undefined' && process.versions?.node) {
|
|
17
17
|
ready = import('node:fs/promises').then(async ({ readFile }) =>
|
|
18
|
-
init(await readFile(new URL('./quarb_wasm_bg.wasm', import.meta.url)))
|
|
18
|
+
init({ module_or_path: await readFile(new URL('./quarb_wasm_bg.wasm', import.meta.url)) })
|
|
19
19
|
);
|
|
20
20
|
} else {
|
|
21
|
-
ready = init(input);
|
|
21
|
+
ready = init(input === undefined ? undefined : { module_or_path: input });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
return ready;
|
|
@@ -35,4 +35,56 @@ export async function query(format, input, q, opts = {}) {
|
|
|
35
35
|
return r.lines;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* A website loaded once and queried many times at the web level:
|
|
40
|
+
* every page under `/sites/<host>/pages/<path>`, the tags and
|
|
41
|
+
* categories the pages declare as rows of their own, every
|
|
42
|
+
* hyperlink resolved (`->link`, `<-link`), each page readable at
|
|
43
|
+
* the text level (`//section`, `//paragraph`). Construct with
|
|
44
|
+
* {@link openSite}.
|
|
45
|
+
*/
|
|
46
|
+
export class Site {
|
|
47
|
+
#inner;
|
|
48
|
+
constructor(inner) { this.#inner = inner; }
|
|
49
|
+
|
|
50
|
+
/** Run a query over the site; the result lines, or a throw. */
|
|
51
|
+
query(q, opts = {}) {
|
|
52
|
+
const r = JSON.parse(this.#inner.query(q, opts.now ?? Date.now()));
|
|
53
|
+
if (!r.ok) throw new Error(r.error);
|
|
54
|
+
return r.lines;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The raw JSON envelope of a query; never throws. */
|
|
58
|
+
run(q, now = Date.now()) { return this.#inner.query(q, now); }
|
|
59
|
+
|
|
60
|
+
/** Every page as a locator, sorted. */
|
|
61
|
+
entries() { return JSON.parse(this.#inner.entries()); }
|
|
62
|
+
|
|
63
|
+
/** Every page's locator with its declared `<title>`. */
|
|
64
|
+
titles() { return JSON.parse(this.#inner.titles()); }
|
|
65
|
+
|
|
66
|
+
/** Release the wasm memory the site holds. */
|
|
67
|
+
free() { this.#inner.free(); }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Open a site. `source` is a tarball of its pages (`.tar` or
|
|
72
|
+
* `.tar.gz`, as bytes) or a plain object of site-relative path to
|
|
73
|
+
* HTML for a site small enough to hold in memory. `opts.base` is
|
|
74
|
+
* the site's root URL that paths and relative links join against
|
|
75
|
+
* (default: read off a page's canonical URL, else
|
|
76
|
+
* `https://localhost/`); `opts.model` a Quarb model file over the
|
|
77
|
+
* site; `opts.wasm` forwards to {@link initQuarb}.
|
|
78
|
+
*/
|
|
79
|
+
export async function openSite(source, opts = {}) {
|
|
80
|
+
await initQuarb(opts.wasm);
|
|
81
|
+
const base = opts.base ?? '';
|
|
82
|
+
const model = opts.model ?? '';
|
|
83
|
+
const inner =
|
|
84
|
+
source instanceof Uint8Array || source instanceof ArrayBuffer
|
|
85
|
+
? WasmSite.open(source instanceof Uint8Array ? source : new Uint8Array(source), base, model)
|
|
86
|
+
: WasmSite.from_pages(JSON.stringify(source), base, model);
|
|
87
|
+
return new Site(inner);
|
|
88
|
+
}
|
|
89
|
+
|
|
38
90
|
export { run, version };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quarb/wasm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Quarb \u2014 the arboreal query engine \u2014 compiled to WebAssembly, with TypeScript types. One-shot queries over JSON, YAML, TOML, CSV, XML, HTML, and Markdown, plus the quai session engine (multi-source mounts, joins, &N history, kaiv, SQLite) \u2014 entirely client-side.",
|
|
3
|
+
"version": "0.29.0",
|
|
4
|
+
"description": "Quarb \u2014 the arboreal query engine \u2014 compiled to WebAssembly, with TypeScript types. One-shot queries over JSON, YAML, TOML, CSV, XML, HTML, and Markdown, a whole website as one queryable tree (site search from a tarball, links, PageRank), plus the quai session engine (multi-source mounts, joins, &N history, kaiv, SQLite) \u2014 entirely client-side.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
@@ -60,6 +60,9 @@
|
|
|
60
60
|
"markdown",
|
|
61
61
|
"jq",
|
|
62
62
|
"xpath",
|
|
63
|
-
"scraping"
|
|
63
|
+
"scraping",
|
|
64
|
+
"site-search",
|
|
65
|
+
"static-site",
|
|
66
|
+
"pagerank"
|
|
64
67
|
]
|
|
65
68
|
}
|
package/quai.js
CHANGED
|
@@ -15,10 +15,10 @@ export function initQuai(input) {
|
|
|
15
15
|
if (!ready) {
|
|
16
16
|
if (input === undefined && typeof process !== 'undefined' && process.versions?.node) {
|
|
17
17
|
ready = import('node:fs/promises').then(async ({ readFile }) =>
|
|
18
|
-
init(await readFile(new URL('./quai_wasm_bg.wasm', import.meta.url)))
|
|
18
|
+
init({ module_or_path: await readFile(new URL('./quai_wasm_bg.wasm', import.meta.url)) })
|
|
19
19
|
);
|
|
20
20
|
} else {
|
|
21
|
-
ready = init(input);
|
|
21
|
+
ready = init(input === undefined ? undefined : { module_or_path: input });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
return ready;
|
package/quai_wasm_bg.wasm
CHANGED
|
Binary file
|
package/quarb_wasm.d.ts
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A site held in memory: a tar or tar.gz of its pages at the
|
|
6
|
+
* web level — `/sites/<host>/pages/<path>` for every page, the
|
|
7
|
+
* tags and categories the pages declare as rows of their own,
|
|
8
|
+
* every hyperlink resolved (`->link`, `<-link`), each page
|
|
9
|
+
* grafted at the text level on entry. Load once, query many
|
|
10
|
+
* times.
|
|
11
|
+
*/
|
|
12
|
+
export class Site {
|
|
13
|
+
free(): void;
|
|
14
|
+
[Symbol.dispose](): void;
|
|
15
|
+
/**
|
|
16
|
+
* The pages as locators, for a quick listing without a query.
|
|
17
|
+
*/
|
|
18
|
+
entries(): string;
|
|
19
|
+
/**
|
|
20
|
+
* The same site from pages already in memory: `pages` is a
|
|
21
|
+
* JSON object of site-relative path to HTML
|
|
22
|
+
* (`{"index.html": "<!doctype html>…", "about/index.html": …}`)
|
|
23
|
+
* — no tarball needed for a site small enough to hold in a
|
|
24
|
+
* string. `base_url` and `model` as in [`open`](Self::open).
|
|
25
|
+
*/
|
|
26
|
+
static from_pages(pages: string, base_url: string, model: string): Site;
|
|
27
|
+
/**
|
|
28
|
+
* Load a tarball (gzipped or not). Pages join against the
|
|
29
|
+
* base read off a page's canonical URL. `text_level` is kept
|
|
30
|
+
* for the caller's sake: the web level always reads its
|
|
31
|
+
* pages as the reader's model.
|
|
32
|
+
*/
|
|
33
|
+
constructor(bytes: Uint8Array, text_level: boolean);
|
|
34
|
+
/**
|
|
35
|
+
* Open a tarball (gzipped or not) with every option spelled
|
|
36
|
+
* out: `base_url` is the site's root (`https://example.org/`)
|
|
37
|
+
* that every page path and relative link joins against —
|
|
38
|
+
* empty to read it off a page's canonical URL, falling back
|
|
39
|
+
* to `https://localhost/` when no page declares one; `model`
|
|
40
|
+
* is a model file over the site, empty for none.
|
|
41
|
+
*/
|
|
42
|
+
static open(bytes: Uint8Array, base_url: string, model: string): Site;
|
|
43
|
+
/**
|
|
44
|
+
* Run `query` over the site; the same JSON envelope as
|
|
45
|
+
* [`run`]. Node results render as locators
|
|
46
|
+
* (`/sites/quarb.org/pages/guides/jq.html!/section[2]`); a
|
|
47
|
+
* model's derived nodes as `/<container>/<role>[n]`.
|
|
48
|
+
*/
|
|
49
|
+
query(query: string, now_millis: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Every page's locator with its declared title, as a JSON
|
|
52
|
+
* object — read from the store, no page parsed.
|
|
53
|
+
*/
|
|
54
|
+
titles(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Like [`new`](Self::new), with a model file over the site:
|
|
57
|
+
* aliases (`alias <s/^tag://i>;`), derived nodes, edges.
|
|
58
|
+
*/
|
|
59
|
+
static with_model(bytes: Uint8Array, _text_level: boolean, model: string): Site;
|
|
60
|
+
}
|
|
61
|
+
|
|
4
62
|
/**
|
|
5
63
|
* Execute `query` against `input` parsed as `format`
|
|
6
64
|
* (json | yaml | toml | csv | tsv | xml | html | markdown |
|
|
@@ -19,7 +77,15 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
19
77
|
|
|
20
78
|
export interface InitOutput {
|
|
21
79
|
readonly memory: WebAssembly.Memory;
|
|
80
|
+
readonly __wbg_site_free: (a: number, b: number) => void;
|
|
22
81
|
readonly run: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
82
|
+
readonly site_entries: (a: number) => [number, number];
|
|
83
|
+
readonly site_from_pages: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
84
|
+
readonly site_new: (a: number, b: number, c: number) => [number, number, number];
|
|
85
|
+
readonly site_open: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
86
|
+
readonly site_query: (a: number, b: number, c: number, d: number) => [number, number];
|
|
87
|
+
readonly site_titles: (a: number) => [number, number];
|
|
88
|
+
readonly site_with_model: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
23
89
|
readonly version: () => [number, number];
|
|
24
90
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
25
91
|
readonly __externref_table_alloc: () => number;
|
|
@@ -27,6 +93,7 @@ export interface InitOutput {
|
|
|
27
93
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
28
94
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
29
95
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
96
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
30
97
|
readonly __wbindgen_start: () => void;
|
|
31
98
|
}
|
|
32
99
|
|
package/quarb_wasm.js
CHANGED
|
@@ -1,5 +1,176 @@
|
|
|
1
1
|
/* @ts-self-types="./quarb_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A site held in memory: a tar or tar.gz of its pages at the
|
|
5
|
+
* web level — `/sites/<host>/pages/<path>` for every page, the
|
|
6
|
+
* tags and categories the pages declare as rows of their own,
|
|
7
|
+
* every hyperlink resolved (`->link`, `<-link`), each page
|
|
8
|
+
* grafted at the text level on entry. Load once, query many
|
|
9
|
+
* times.
|
|
10
|
+
*/
|
|
11
|
+
export class Site {
|
|
12
|
+
static __wrap(ptr) {
|
|
13
|
+
const obj = Object.create(Site.prototype);
|
|
14
|
+
obj.__wbg_ptr = ptr;
|
|
15
|
+
SiteFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
__destroy_into_raw() {
|
|
19
|
+
const ptr = this.__wbg_ptr;
|
|
20
|
+
this.__wbg_ptr = 0;
|
|
21
|
+
SiteFinalization.unregister(this);
|
|
22
|
+
return ptr;
|
|
23
|
+
}
|
|
24
|
+
free() {
|
|
25
|
+
const ptr = this.__destroy_into_raw();
|
|
26
|
+
wasm.__wbg_site_free(ptr, 0);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The pages as locators, for a quick listing without a query.
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
entries() {
|
|
33
|
+
let deferred1_0;
|
|
34
|
+
let deferred1_1;
|
|
35
|
+
try {
|
|
36
|
+
const ret = wasm.site_entries(this.__wbg_ptr);
|
|
37
|
+
deferred1_0 = ret[0];
|
|
38
|
+
deferred1_1 = ret[1];
|
|
39
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
40
|
+
} finally {
|
|
41
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The same site from pages already in memory: `pages` is a
|
|
46
|
+
* JSON object of site-relative path to HTML
|
|
47
|
+
* (`{"index.html": "<!doctype html>…", "about/index.html": …}`)
|
|
48
|
+
* — no tarball needed for a site small enough to hold in a
|
|
49
|
+
* string. `base_url` and `model` as in [`open`](Self::open).
|
|
50
|
+
* @param {string} pages
|
|
51
|
+
* @param {string} base_url
|
|
52
|
+
* @param {string} model
|
|
53
|
+
* @returns {Site}
|
|
54
|
+
*/
|
|
55
|
+
static from_pages(pages, base_url, model) {
|
|
56
|
+
const ptr0 = passStringToWasm0(pages, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
57
|
+
const len0 = WASM_VECTOR_LEN;
|
|
58
|
+
const ptr1 = passStringToWasm0(base_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len1 = WASM_VECTOR_LEN;
|
|
60
|
+
const ptr2 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
61
|
+
const len2 = WASM_VECTOR_LEN;
|
|
62
|
+
const ret = wasm.site_from_pages(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
63
|
+
if (ret[2]) {
|
|
64
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
65
|
+
}
|
|
66
|
+
return Site.__wrap(ret[0]);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Load a tarball (gzipped or not). Pages join against the
|
|
70
|
+
* base read off a page's canonical URL. `text_level` is kept
|
|
71
|
+
* for the caller's sake: the web level always reads its
|
|
72
|
+
* pages as the reader's model.
|
|
73
|
+
* @param {Uint8Array} bytes
|
|
74
|
+
* @param {boolean} text_level
|
|
75
|
+
*/
|
|
76
|
+
constructor(bytes, text_level) {
|
|
77
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
const ret = wasm.site_new(ptr0, len0, text_level);
|
|
80
|
+
if (ret[2]) {
|
|
81
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
82
|
+
}
|
|
83
|
+
this.__wbg_ptr = ret[0];
|
|
84
|
+
SiteFinalization.register(this, this.__wbg_ptr, this);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Open a tarball (gzipped or not) with every option spelled
|
|
89
|
+
* out: `base_url` is the site's root (`https://example.org/`)
|
|
90
|
+
* that every page path and relative link joins against —
|
|
91
|
+
* empty to read it off a page's canonical URL, falling back
|
|
92
|
+
* to `https://localhost/` when no page declares one; `model`
|
|
93
|
+
* is a model file over the site, empty for none.
|
|
94
|
+
* @param {Uint8Array} bytes
|
|
95
|
+
* @param {string} base_url
|
|
96
|
+
* @param {string} model
|
|
97
|
+
* @returns {Site}
|
|
98
|
+
*/
|
|
99
|
+
static open(bytes, base_url, model) {
|
|
100
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
101
|
+
const len0 = WASM_VECTOR_LEN;
|
|
102
|
+
const ptr1 = passStringToWasm0(base_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
const len1 = WASM_VECTOR_LEN;
|
|
104
|
+
const ptr2 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
+
const len2 = WASM_VECTOR_LEN;
|
|
106
|
+
const ret = wasm.site_open(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
107
|
+
if (ret[2]) {
|
|
108
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
109
|
+
}
|
|
110
|
+
return Site.__wrap(ret[0]);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Run `query` over the site; the same JSON envelope as
|
|
114
|
+
* [`run`]. Node results render as locators
|
|
115
|
+
* (`/sites/quarb.org/pages/guides/jq.html!/section[2]`); a
|
|
116
|
+
* model's derived nodes as `/<container>/<role>[n]`.
|
|
117
|
+
* @param {string} query
|
|
118
|
+
* @param {number} now_millis
|
|
119
|
+
* @returns {string}
|
|
120
|
+
*/
|
|
121
|
+
query(query, now_millis) {
|
|
122
|
+
let deferred2_0;
|
|
123
|
+
let deferred2_1;
|
|
124
|
+
try {
|
|
125
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
126
|
+
const len0 = WASM_VECTOR_LEN;
|
|
127
|
+
const ret = wasm.site_query(this.__wbg_ptr, ptr0, len0, now_millis);
|
|
128
|
+
deferred2_0 = ret[0];
|
|
129
|
+
deferred2_1 = ret[1];
|
|
130
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
131
|
+
} finally {
|
|
132
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Every page's locator with its declared title, as a JSON
|
|
137
|
+
* object — read from the store, no page parsed.
|
|
138
|
+
* @returns {string}
|
|
139
|
+
*/
|
|
140
|
+
titles() {
|
|
141
|
+
let deferred1_0;
|
|
142
|
+
let deferred1_1;
|
|
143
|
+
try {
|
|
144
|
+
const ret = wasm.site_titles(this.__wbg_ptr);
|
|
145
|
+
deferred1_0 = ret[0];
|
|
146
|
+
deferred1_1 = ret[1];
|
|
147
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
148
|
+
} finally {
|
|
149
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Like [`new`](Self::new), with a model file over the site:
|
|
154
|
+
* aliases (`alias <s/^tag://i>;`), derived nodes, edges.
|
|
155
|
+
* @param {Uint8Array} bytes
|
|
156
|
+
* @param {boolean} _text_level
|
|
157
|
+
* @param {string} model
|
|
158
|
+
* @returns {Site}
|
|
159
|
+
*/
|
|
160
|
+
static with_model(bytes, _text_level, model) {
|
|
161
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
162
|
+
const len0 = WASM_VECTOR_LEN;
|
|
163
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
164
|
+
const len1 = WASM_VECTOR_LEN;
|
|
165
|
+
const ret = wasm.site_with_model(ptr0, len0, _text_level, ptr1, len1);
|
|
166
|
+
if (ret[2]) {
|
|
167
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
168
|
+
}
|
|
169
|
+
return Site.__wrap(ret[0]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (Symbol.dispose) Site.prototype[Symbol.dispose] = Site.prototype.free;
|
|
173
|
+
|
|
3
174
|
/**
|
|
4
175
|
* Execute `query` against `input` parsed as `format`
|
|
5
176
|
* (json | yaml | toml | csv | tsv | xml | html | markdown |
|
|
@@ -50,6 +221,13 @@ export function version() {
|
|
|
50
221
|
function __wbg_get_imports() {
|
|
51
222
|
const import0 = {
|
|
52
223
|
__proto__: null,
|
|
224
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
225
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
226
|
+
return ret;
|
|
227
|
+
},
|
|
228
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
229
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
230
|
+
},
|
|
53
231
|
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
54
232
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
55
233
|
}, arguments); },
|
|
@@ -69,6 +247,10 @@ function __wbg_get_imports() {
|
|
|
69
247
|
};
|
|
70
248
|
}
|
|
71
249
|
|
|
250
|
+
const SiteFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
251
|
+
? { register: () => {}, unregister: () => {} }
|
|
252
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_site_free(ptr, 1));
|
|
253
|
+
|
|
72
254
|
function addToExternrefTable0(obj) {
|
|
73
255
|
const idx = wasm.__externref_table_alloc();
|
|
74
256
|
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
@@ -101,6 +283,13 @@ function handleError(f, args) {
|
|
|
101
283
|
}
|
|
102
284
|
}
|
|
103
285
|
|
|
286
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
287
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
288
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
289
|
+
WASM_VECTOR_LEN = arg.length;
|
|
290
|
+
return ptr;
|
|
291
|
+
}
|
|
292
|
+
|
|
104
293
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
105
294
|
if (realloc === undefined) {
|
|
106
295
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -138,6 +327,12 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
138
327
|
return ptr;
|
|
139
328
|
}
|
|
140
329
|
|
|
330
|
+
function takeFromExternrefTable0(idx) {
|
|
331
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
332
|
+
wasm.__externref_table_dealloc(idx);
|
|
333
|
+
return value;
|
|
334
|
+
}
|
|
335
|
+
|
|
141
336
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
142
337
|
cachedTextDecoder.decode();
|
|
143
338
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
package/quarb_wasm_bg.wasm
CHANGED
|
Binary file
|