quilt-wasm 0.5.0 → 0.6.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 +128 -17
- package/package.json +7 -4
- package/quilt_runtime.js +666 -0
- package/quilt_wasm.d.ts +97 -190
- package/quilt_wasm.js +6 -672
- package/quilt_wasm_raw.d.ts +66 -0
- package/quilt_wasm_raw.js +382 -0
- package/quilt_wasm_raw_bg.wasm +0 -0
- package/quilt_wasm_bg.wasm +0 -0
package/quilt_wasm.d.ts
CHANGED
|
@@ -1,218 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Types for the quilt-wasm runtime (js/runtime.js). assemble.mjs installs this
|
|
2
|
+
// as the package's quilt_wasm.d.ts, adding the web build's init() below it.
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function HOLE(): WasmCmdOrHole;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The `NewLine` command (the `NL` constant in the Python runtime).
|
|
11
|
-
*/
|
|
12
|
-
export function NL(): WasmStrCmd;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The `Pop` command (the `POP` constant in the Python runtime).
|
|
16
|
-
*/
|
|
17
|
-
export function POP(): WasmStrCmd;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A fluent term builder, mirroring the Rust `QTermBuilder` (consuming form:
|
|
21
|
-
* each method takes `self` and returns the next builder, so chaining works
|
|
22
|
-
* from JS exactly as `tb("x").w("a").c(child).b()`).
|
|
23
|
-
*/
|
|
24
|
-
export class WasmBuilder {
|
|
25
|
-
private constructor();
|
|
26
|
-
free(): void;
|
|
27
|
-
[Symbol.dispose](): void;
|
|
28
|
-
/**
|
|
29
|
-
* Build the term. Consumes the builder.
|
|
30
|
-
*/
|
|
31
|
-
b(): WasmQTerm;
|
|
32
|
-
/**
|
|
33
|
-
* Splice a child term.
|
|
34
|
-
*/
|
|
35
|
-
c(child: WasmQTerm): WasmBuilder;
|
|
36
|
-
/**
|
|
37
|
-
* Emit a child term (for an `Arc<QTerm>` this is the same as [`c`]).
|
|
38
|
-
*/
|
|
39
|
-
e(child: WasmQTerm): WasmBuilder;
|
|
40
|
-
/**
|
|
41
|
-
* Emit a newline (respecting the current prefix).
|
|
42
|
-
*/
|
|
43
|
-
n(): WasmBuilder;
|
|
44
|
-
/**
|
|
45
|
-
* Push an indentation prefix.
|
|
46
|
-
*/
|
|
47
|
-
p(s: string): WasmBuilder;
|
|
48
|
-
/**
|
|
49
|
-
* Write literal source text.
|
|
50
|
-
*/
|
|
51
|
-
w(s: string): WasmBuilder;
|
|
52
|
-
/**
|
|
53
|
-
* Pop an indentation prefix.
|
|
54
|
-
*/
|
|
55
|
-
x(): WasmBuilder;
|
|
4
|
+
/** A single string command: `write(s)`, `NL()`, `push(s)` or `POP()`. */
|
|
5
|
+
export class WasmStrCmd {
|
|
6
|
+
private constructor();
|
|
56
7
|
}
|
|
57
8
|
|
|
58
|
-
/**
|
|
59
|
-
* A `StrCmd` or a child placeholder (`HOLE`), used in `quote`/`unquote` cmds.
|
|
60
|
-
*/
|
|
9
|
+
/** A `StrCmd` or a child placeholder (`HOLE()`), for `quote`/`unquote` cmds. */
|
|
61
10
|
export class WasmCmdOrHole {
|
|
62
|
-
|
|
63
|
-
free(): void;
|
|
64
|
-
[Symbol.dispose](): void;
|
|
11
|
+
private constructor();
|
|
65
12
|
}
|
|
66
13
|
|
|
67
|
-
/**
|
|
68
|
-
* A quilt term (`Arc<QTerm>`).
|
|
69
|
-
*/
|
|
14
|
+
/** A quilt term: immutable, and owned by the garbage collector. */
|
|
70
15
|
export class WasmQTerm {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
toString(): string;
|
|
16
|
+
private constructor();
|
|
17
|
+
/** Serialize the term back to source code. */
|
|
18
|
+
coparse(): string;
|
|
19
|
+
toString(): string;
|
|
20
|
+
/** A no-op: kept for code written when a term was a wasm handle. */
|
|
21
|
+
free(): void;
|
|
22
|
+
[Symbol.dispose](): void;
|
|
79
23
|
}
|
|
80
24
|
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
25
|
+
/** A fluent term builder; every method but `b` returns the same builder. */
|
|
26
|
+
export class WasmBuilder {
|
|
27
|
+
private constructor();
|
|
28
|
+
/** Splice a child term. */
|
|
29
|
+
c(child: WasmQTerm | string | number | boolean | bigint): WasmBuilder;
|
|
30
|
+
/** Splice a child term (the same as `c`; what expanded code spells). */
|
|
31
|
+
t(child: WasmQTerm | string | number | boolean | bigint): WasmBuilder;
|
|
32
|
+
/** Emit a child term. */
|
|
33
|
+
e(child: WasmQTerm | string | number | boolean | bigint): WasmBuilder;
|
|
34
|
+
/** Write literal source text. */
|
|
35
|
+
w(s: string): WasmBuilder;
|
|
36
|
+
/** Emit a newline (respecting the current prefix). */
|
|
37
|
+
n(): WasmBuilder;
|
|
38
|
+
/** Push an indentation prefix. */
|
|
39
|
+
p(s: string): WasmBuilder;
|
|
40
|
+
/** Pop an indentation prefix. */
|
|
41
|
+
x(): WasmBuilder;
|
|
42
|
+
/** Build the term. */
|
|
43
|
+
b(): WasmQTerm;
|
|
44
|
+
free(): void;
|
|
45
|
+
[Symbol.dispose](): void;
|
|
88
46
|
}
|
|
89
47
|
|
|
90
48
|
/**
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
export function cmd(c: WasmStrCmd): WasmCmdOrHole;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* A leaf node: a tag whose only content is `code`.
|
|
49
|
+
* A sequence of terms, for `←(items)`: the items in order, with a newline
|
|
50
|
+
* between them, or `sep` when given. Strings splice as their text.
|
|
97
51
|
*/
|
|
98
|
-
export function
|
|
52
|
+
export function qseq(items: Iterable<WasmQTerm | string | number | boolean | bigint>, sep?: string): WasmQTerm;
|
|
99
53
|
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
*/
|
|
103
|
-
export function name(s: string): WasmQTerm;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* A `Push` command.
|
|
107
|
-
*/
|
|
108
|
-
export function push(s: string): WasmStrCmd;
|
|
54
|
+
/** `↑(x)` inside a `⟨str⟩` quote: the TypeScript literal for `value`, as a string. */
|
|
55
|
+
export function qlift_str(value: number | string | boolean | WasmQTerm): string;
|
|
109
56
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* Unlike the Python runtime's `qlift`, this does *not* pass an already-built
|
|
117
|
-
* `QTerm` through unchanged: recovering an exported wasm-bindgen type from a
|
|
118
|
-
* polymorphic `JsValue` needs target-specific glue. The demos never lift a
|
|
119
|
-
* term (terms splice via `↙…↘`), so this is sufficient; a JS shim can add
|
|
120
|
-
* pass-through later if needed.
|
|
121
|
-
*/
|
|
122
|
-
export function qlift(value: any): WasmQTerm;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Lift a JS value to an HTML term (the `↑` operator with an `html` splice
|
|
126
|
-
* target). Strings become entity-escaped `text` leaves — inert as text content
|
|
127
|
-
* or as a double-quoted attribute value — and terms pass through unchanged, so
|
|
128
|
-
* already-built fragments can be lifted too. Mirrors `qlift_html` in the
|
|
129
|
-
* Python runtime, minus the `QTerm` pass-through (see [`qlift`]).
|
|
130
|
-
*/
|
|
131
|
-
export function qlift_html(value: any): WasmQTerm;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* A quoted fragment.
|
|
135
|
-
*/
|
|
136
|
-
export function quote(tag: string, index: number, lang: string, term: WasmQTerm, cmds: WasmCmdOrHole[]): WasmQTerm;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* A symbol: a leaf whose tag and code are the same.
|
|
140
|
-
*/
|
|
141
|
-
export function sym(s: string): WasmQTerm;
|
|
57
|
+
declare global {
|
|
58
|
+
interface String {
|
|
59
|
+
/** A `⟨str⟩` quote's value is its own source: `coparse()` returns it. */
|
|
60
|
+
coparse(): string;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
142
63
|
|
|
143
|
-
/**
|
|
144
|
-
* Start building a tuple node with the given tag.
|
|
145
|
-
*/
|
|
64
|
+
/** Start building a tuple node with the given tag. */
|
|
146
65
|
export function tb(tag: string): WasmBuilder;
|
|
66
|
+
/** A leaf node: a tag whose only content is `code`. */
|
|
67
|
+
export function leaf(tag: string, code: string): WasmQTerm;
|
|
68
|
+
/** A symbol: a leaf whose tag and code are the same. */
|
|
69
|
+
export function sym(s: string): WasmQTerm;
|
|
70
|
+
/** An identifier term (the `⟨N⟩` operator). */
|
|
71
|
+
export function name(s: string): WasmQTerm;
|
|
72
|
+
/** A quoted fragment. */
|
|
73
|
+
export function quote(tag: string, index: number, lang: string, term: WasmQTerm, cmds: WasmCmdOrHole[]): WasmQTerm;
|
|
74
|
+
/** An unquoted splice. */
|
|
75
|
+
export function unquote(tag: string, index: number, lang: string, term: WasmQTerm, cmds: WasmCmdOrHole[]): WasmQTerm;
|
|
76
|
+
/** Wrap a `StrCmd` as a `CmdOrHole`. */
|
|
77
|
+
export function cmd(c: WasmStrCmd): WasmCmdOrHole;
|
|
78
|
+
/** A `Write` command. */
|
|
79
|
+
export function write(s: string): WasmStrCmd;
|
|
80
|
+
/** A `Push` command. */
|
|
81
|
+
export function push(s: string): WasmStrCmd;
|
|
82
|
+
/** The `NewLine` command. */
|
|
83
|
+
export function NL(): WasmStrCmd;
|
|
84
|
+
/** The `Pop` command. */
|
|
85
|
+
export function POP(): WasmStrCmd;
|
|
86
|
+
/** A child placeholder. */
|
|
87
|
+
export function HOLE(): WasmCmdOrHole;
|
|
147
88
|
|
|
148
89
|
/**
|
|
149
|
-
*
|
|
90
|
+
* Lift a JS value to a term that reconstructs it (the homogeneous `↑`):
|
|
91
|
+
* a number, string or boolean to its literal, a term to the TypeScript that
|
|
92
|
+
* rebuilds it.
|
|
150
93
|
*/
|
|
151
|
-
export function
|
|
152
|
-
|
|
94
|
+
export function qlift(value: number | string | boolean | WasmQTerm): WasmQTerm;
|
|
153
95
|
/**
|
|
154
|
-
*
|
|
96
|
+
* Lift a JS value to an HTML term: a string to entity-escaped text, a term
|
|
97
|
+
* unchanged.
|
|
155
98
|
*/
|
|
156
|
-
export function
|
|
157
|
-
|
|
158
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
99
|
+
export function qlift_html(value: number | string | boolean | WasmQTerm): WasmQTerm;
|
|
159
100
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
readonly cmd: (a: number) => number;
|
|
170
|
-
readonly leaf: (a: number, b: number, c: number, d: number) => number;
|
|
171
|
-
readonly name: (a: number, b: number) => number;
|
|
172
|
-
readonly push: (a: number, b: number) => number;
|
|
173
|
-
readonly qlift: (a: any) => [number, number, number];
|
|
174
|
-
readonly qlift_html: (a: any) => [number, number, number];
|
|
175
|
-
readonly quote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
176
|
-
readonly sym: (a: number, b: number) => number;
|
|
177
|
-
readonly tb: (a: number, b: number) => number;
|
|
178
|
-
readonly unquote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
179
|
-
readonly wasmbuilder_b: (a: number) => number;
|
|
180
|
-
readonly wasmbuilder_c: (a: number, b: number) => number;
|
|
181
|
-
readonly wasmbuilder_e: (a: number, b: number) => number;
|
|
182
|
-
readonly wasmbuilder_n: (a: number) => number;
|
|
183
|
-
readonly wasmbuilder_p: (a: number, b: number, c: number) => number;
|
|
184
|
-
readonly wasmbuilder_w: (a: number, b: number, c: number) => number;
|
|
185
|
-
readonly wasmbuilder_x: (a: number) => number;
|
|
186
|
-
readonly wasmqterm_coparse: (a: number) => [number, number];
|
|
187
|
-
readonly write: (a: number, b: number) => number;
|
|
188
|
-
readonly wasmqterm_toString: (a: number) => [number, number];
|
|
189
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
190
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
191
|
-
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
192
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
193
|
-
readonly __externref_table_alloc: () => number;
|
|
194
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
195
|
-
readonly __wbindgen_start: () => void;
|
|
101
|
+
/** A text dialect: any rule left out is JSON's (see `qlift_text`). */
|
|
102
|
+
export interface TextDialect {
|
|
103
|
+
string?(s: string): string;
|
|
104
|
+
in_quotes?(s: string): string;
|
|
105
|
+
boolean?(b: boolean): string;
|
|
106
|
+
float?(f: number): string;
|
|
107
|
+
list_open?: string;
|
|
108
|
+
list_sep?: string;
|
|
109
|
+
list_close?: string;
|
|
196
110
|
}
|
|
197
|
-
|
|
198
|
-
export type
|
|
199
|
-
|
|
111
|
+
/** A value in a text quote: a scalar, a term, or an array of them. */
|
|
112
|
+
export type TextValue = number | string | boolean | WasmQTerm | TextValue[];
|
|
200
113
|
/**
|
|
201
|
-
*
|
|
202
|
-
* a
|
|
203
|
-
*
|
|
204
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
205
|
-
*
|
|
206
|
-
* @returns {InitOutput}
|
|
114
|
+
* Lift a JS value into a text quote: JSON's spelling unless `dialect`
|
|
115
|
+
* overrides a rule.
|
|
207
116
|
*/
|
|
208
|
-
export function
|
|
209
|
-
|
|
117
|
+
export function qlift_text(value: TextValue, dialect?: TextDialect): WasmQTerm;
|
|
210
118
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
215
|
-
*
|
|
216
|
-
* @returns {Promise<InitOutput>}
|
|
119
|
+
* `qlift_text` for a hole between two `"` the author wrote: a string as its
|
|
120
|
+
* escaped contents, an array as its elements joined by the separator.
|
|
217
121
|
*/
|
|
218
|
-
export
|
|
122
|
+
export function qlift_text_in_quotes(value: TextValue, dialect?: TextDialect): WasmQTerm;
|
|
123
|
+
|
|
124
|
+
/** Load the wasm. Await it before calling the runtime. */
|
|
125
|
+
export { default, initSync } from "./quilt_wasm_raw.js";
|