@quarb/wasm 0.13.0 → 0.16.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 CHANGED
@@ -3,7 +3,9 @@
3
3
  [Quarb](https://quarb.org) — the arboreal query engine —
4
4
  compiled to WebAssembly, with TypeScript types. One path
5
5
  language over JSON, YAML, TOML, CSV/TSV, XML, HTML, and
6
- Markdown, running entirely client-side: no server, no native
6
+ Markdown — including the text-level reading of HTML, Markdown,
7
+ and plain text (sections, paragraphs, quotes, lists) — running
8
+ entirely client-side: no server, no native
7
9
  dependency, the same engine that powers the
8
10
  [playground](https://demo.quarb.org) and the Quarb Scraper
9
11
  browser extension.
package/index.d.ts CHANGED
@@ -9,7 +9,10 @@ export type Format =
9
9
  | 'tsv'
10
10
  | 'xml'
11
11
  | 'html'
12
- | 'markdown';
12
+ | 'markdown'
13
+ | 'text-html'
14
+ | 'text-markdown'
15
+ | 'text';
13
16
 
14
17
  /**
15
18
  * Initialize the engine once; subsequent calls share the load.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quarb/wasm",
3
- "version": "0.13.0",
3
+ "version": "0.16.0",
4
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.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/quai.d.ts CHANGED
@@ -19,6 +19,9 @@ export interface Source {
19
19
  | 'xml'
20
20
  | 'html'
21
21
  | 'markdown'
22
+ | 'text-html'
23
+ | 'text-markdown'
24
+ | 'text'
22
25
  | 'kaiv'
23
26
  | 'daiv'
24
27
  | 'sqlite';
package/quai_wasm.d.ts CHANGED
@@ -19,12 +19,30 @@ export class QuaiSession {
19
19
  * one-document constructor does.
20
20
  */
21
21
  static mount(sources_json: string, now_millis: number): QuaiSession;
22
+ /**
23
+ * [`mount`], enriched by a `--model` file (`model_text`): the
24
+ * session runs every line against the derived structure the
25
+ * model declares over the mounted sources — value containers,
26
+ * references, and pair edges. The model's own `mount` statements
27
+ * are ignored here (the sources come from the caller, not from
28
+ * disk the wasm cannot read); its `node`/`ref`/`edge`/`def`
29
+ * statements apply.
30
+ */
31
+ static mountWithModel(sources_json: string, model_text: string, now_millis: number): QuaiSession;
22
32
  /**
23
33
  * Open a session over `input` parsed as `format` (json, yaml,
24
34
  * toml, csv, tsv, xml, html, markdown). `now_millis` pins the
25
35
  * session's `now()` (pass `Date.now()`).
26
36
  */
27
37
  constructor(format: string, input: string, now_millis: number);
38
+ /**
39
+ * Run a line and render its results as exportable markup:
40
+ * `kind` is `md`, `html`, or `txt`. Text-level node results
41
+ * render structurally (sections back to headings, lists to
42
+ * lists); anything else degrades to prose lines. History refs
43
+ * (`&N`) resolve as in a normal line.
44
+ */
45
+ render(line: string, kind: string): string;
28
46
  /**
29
47
  * Clear the history and restart numbering.
30
48
  */
@@ -80,7 +98,9 @@ export interface InitOutput {
80
98
  readonly quaisession_history: (a: number) => [number, number];
81
99
  readonly quaisession_line: (a: number) => number;
82
100
  readonly quaisession_mount: (a: number, b: number, c: number) => [number, number, number];
101
+ readonly quaisession_mountWithModel: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
83
102
  readonly quaisession_new: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
103
+ readonly quaisession_render: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
84
104
  readonly quaisession_reset: (a: number) => void;
85
105
  readonly quaisession_restore: (a: number, b: number, c: number) => void;
86
106
  readonly quaisession_run: (a: number, b: number, c: number) => [number, number];
package/quai_wasm.js CHANGED
@@ -63,6 +63,30 @@ export class QuaiSession {
63
63
  }
64
64
  return QuaiSession.__wrap(ret[0]);
65
65
  }
66
+ /**
67
+ * [`mount`], enriched by a `--model` file (`model_text`): the
68
+ * session runs every line against the derived structure the
69
+ * model declares over the mounted sources — value containers,
70
+ * references, and pair edges. The model's own `mount` statements
71
+ * are ignored here (the sources come from the caller, not from
72
+ * disk the wasm cannot read); its `node`/`ref`/`edge`/`def`
73
+ * statements apply.
74
+ * @param {string} sources_json
75
+ * @param {string} model_text
76
+ * @param {number} now_millis
77
+ * @returns {QuaiSession}
78
+ */
79
+ static mountWithModel(sources_json, model_text, now_millis) {
80
+ const ptr0 = passStringToWasm0(sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
81
+ const len0 = WASM_VECTOR_LEN;
82
+ const ptr1 = passStringToWasm0(model_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
83
+ const len1 = WASM_VECTOR_LEN;
84
+ const ret = wasm.quaisession_mountWithModel(ptr0, len0, ptr1, len1, now_millis);
85
+ if (ret[2]) {
86
+ throw takeFromExternrefTable0(ret[1]);
87
+ }
88
+ return QuaiSession.__wrap(ret[0]);
89
+ }
66
90
  /**
67
91
  * Open a session over `input` parsed as `format` (json, yaml,
68
92
  * toml, csv, tsv, xml, html, markdown). `now_millis` pins the
@@ -84,6 +108,38 @@ export class QuaiSession {
84
108
  QuaiSessionFinalization.register(this, this.__wbg_ptr, this);
85
109
  return this;
86
110
  }
111
+ /**
112
+ * Run a line and render its results as exportable markup:
113
+ * `kind` is `md`, `html`, or `txt`. Text-level node results
114
+ * render structurally (sections back to headings, lists to
115
+ * lists); anything else degrades to prose lines. History refs
116
+ * (`&N`) resolve as in a normal line.
117
+ * @param {string} line
118
+ * @param {string} kind
119
+ * @returns {string}
120
+ */
121
+ render(line, kind) {
122
+ let deferred4_0;
123
+ let deferred4_1;
124
+ try {
125
+ const ptr0 = passStringToWasm0(line, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ const ptr1 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
128
+ const len1 = WASM_VECTOR_LEN;
129
+ const ret = wasm.quaisession_render(this.__wbg_ptr, ptr0, len0, ptr1, len1);
130
+ var ptr3 = ret[0];
131
+ var len3 = ret[1];
132
+ if (ret[3]) {
133
+ ptr3 = 0; len3 = 0;
134
+ throw takeFromExternrefTable0(ret[2]);
135
+ }
136
+ deferred4_0 = ptr3;
137
+ deferred4_1 = len3;
138
+ return getStringFromWasm0(ptr3, len3);
139
+ } finally {
140
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
141
+ }
142
+ }
87
143
  /**
88
144
  * Clear the history and restart numbering.
89
145
  */
package/quai_wasm_bg.wasm CHANGED
Binary file
package/quarb_wasm.d.ts CHANGED
@@ -3,7 +3,8 @@
3
3
 
4
4
  /**
5
5
  * Execute `query` against `input` parsed as `format`
6
- * (json | yaml | toml | csv | tsv | xml | html | markdown).
6
+ * (json | yaml | toml | csv | tsv | xml | html | markdown |
7
+ * text-html | text-markdown | text).
7
8
  * `now_millis` is the invocation instant for `now()`, as from
8
9
  * `Date.now()`. Returns a JSON envelope; never throws.
9
10
  */
package/quarb_wasm.js CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  /**
4
4
  * Execute `query` against `input` parsed as `format`
5
- * (json | yaml | toml | csv | tsv | xml | html | markdown).
5
+ * (json | yaml | toml | csv | tsv | xml | html | markdown |
6
+ * text-html | text-markdown | text).
6
7
  * `now_millis` is the invocation instant for `now()`, as from
7
8
  * `Date.now()`. Returns a JSON envelope; never throws.
8
9
  * @param {string} format
Binary file