quilt-wasm 0.2.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 +68 -0
- package/package.json +31 -0
- package/quilt_wasm.d.ts +218 -0
- package/quilt_wasm.js +672 -0
- package/quilt_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# quilt-wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly bindings for Quilt's core IR — the **browser runtime** that expanded
|
|
4
|
+
`.ts.quilt` programs target. It is the JS/WASM analog of the `quilt` Python
|
|
5
|
+
module (`quilt-python/`): the same `QTerm` builder, `qlift`/`qlift_html`, and
|
|
6
|
+
`coparse` serializer, exposed to JavaScript via `wasm-bindgen`.
|
|
7
|
+
|
|
8
|
+
Like `nanobots-codegen`, it depends on `quilt` with
|
|
9
|
+
`default-features = false, features = ["rust"]`, so it uses only the
|
|
10
|
+
tree-sitter-free runtime path and builds for `wasm32-unknown-unknown` with no C
|
|
11
|
+
runtime. (Compiling the *parser/expander* to wasm — for the meta-meta demo — is
|
|
12
|
+
tracked separately as Phase 2 of issue #43.)
|
|
13
|
+
|
|
14
|
+
## Build
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
# from the repo root
|
|
18
|
+
wasm-pack build quilt-wasm --target web # for the browser demos (ESM)
|
|
19
|
+
wasm-pack build quilt-wasm --target nodejs # for Node (CommonJS) + tests
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The artifact lands in `quilt-wasm/pkg/` (git-ignored).
|
|
23
|
+
|
|
24
|
+
## Releasing to npm
|
|
25
|
+
|
|
26
|
+
Published to npm as [`quilt-wasm`](https://www.npmjs.com/package/quilt-wasm) — the
|
|
27
|
+
same bare specifier expanded `.ts.quilt` programs import. The `publish-npm` job
|
|
28
|
+
in `.github/workflows/ci.yml` runs on every `v*` tag (after the check matrix
|
|
29
|
+
passes): it does `wasm-pack build quilt-wasm --target web` and `npm publish`es
|
|
30
|
+
the resulting `pkg/`. The package version tracks the workspace version in
|
|
31
|
+
`Cargo.toml`.
|
|
32
|
+
|
|
33
|
+
Auth is **npm Trusted Publishing (OIDC)** — no secret to manage; GitHub's
|
|
34
|
+
`id-token` authenticates the publish and npm records build provenance. One-time
|
|
35
|
+
setup, because npm can only attach a trusted publisher to a package that already
|
|
36
|
+
exists:
|
|
37
|
+
|
|
38
|
+
1. Publish the first version manually: `wasm-pack build quilt-wasm --target web`,
|
|
39
|
+
then `npm login` and `npm publish` from `quilt-wasm/pkg/`.
|
|
40
|
+
2. On npmjs.com → the package → **Settings → Trusted Publisher**, add a GitHub
|
|
41
|
+
Actions publisher for repo `QuiltLang/quilt`, workflow `ci.yml`.
|
|
42
|
+
|
|
43
|
+
After that every `v*` tag publishes with no token. A version already on npm is a
|
|
44
|
+
no-op, not a failure.
|
|
45
|
+
|
|
46
|
+
## Smoke test
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
wasm-pack build quilt-wasm --target nodejs
|
|
50
|
+
node quilt-wasm/test/smoke.cjs
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
Mirrors the Python runtime one-for-one where the ABIs allow:
|
|
56
|
+
|
|
57
|
+
| Python runtime | quilt-wasm |
|
|
58
|
+
| --------------------- | ------------------------------------------- |
|
|
59
|
+
| `tb(tag)` + `.c/.w/.n/.p/.x/.e/.b` | same fluent `WasmBuilder` |
|
|
60
|
+
| `leaf/sym/quote/unquote/name` | same free functions |
|
|
61
|
+
| `cmd/write/push` | same free functions |
|
|
62
|
+
| `NL`, `POP`, `HOLE` (constants) | `NL()`, `POP()`, `HOLE()` (functions — wasm-bindgen can't export struct-valued constants) |
|
|
63
|
+
| `qlift`, `qlift_html` | same; lift `number`/`string`/`boolean` (no `QTerm` pass-through yet) |
|
|
64
|
+
| `term.coparse()` | `term.coparse()` / `term.toString()` |
|
|
65
|
+
|
|
66
|
+
Builder and term methods that take `self`/a child by value **consume** the JS
|
|
67
|
+
object (wasm-bindgen move semantics), so chain in one expression and don't reuse
|
|
68
|
+
a spliced term.
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "quilt-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Alexander Varga <varga.alex@gmail.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "WebAssembly runtime for Quilt's core IR — the browser/Node target of expanded `.ts.quilt` programs (QTerm builder, qlift/qlift_html, coparse) via wasm-bindgen.",
|
|
8
|
+
"version": "0.2.0",
|
|
9
|
+
"license": "MIT OR Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/QuiltLang/quilt"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"quilt_wasm_bg.wasm",
|
|
16
|
+
"quilt_wasm.js",
|
|
17
|
+
"quilt_wasm.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "quilt_wasm.js",
|
|
20
|
+
"types": "quilt_wasm.d.ts",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./snippets/*"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"quilt",
|
|
26
|
+
"metaprogramming",
|
|
27
|
+
"wasm",
|
|
28
|
+
"webassembly",
|
|
29
|
+
"typescript"
|
|
30
|
+
]
|
|
31
|
+
}
|
package/quilt_wasm.d.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A child placeholder (the `HOLE` constant in the Python runtime).
|
|
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;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A `StrCmd` or a child placeholder (`HOLE`), used in `quote`/`unquote` cmds.
|
|
60
|
+
*/
|
|
61
|
+
export class WasmCmdOrHole {
|
|
62
|
+
private constructor();
|
|
63
|
+
free(): void;
|
|
64
|
+
[Symbol.dispose](): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A quilt term (`Arc<QTerm>`).
|
|
69
|
+
*/
|
|
70
|
+
export class WasmQTerm {
|
|
71
|
+
private constructor();
|
|
72
|
+
free(): void;
|
|
73
|
+
[Symbol.dispose](): void;
|
|
74
|
+
/**
|
|
75
|
+
* Serialize the term back to source code.
|
|
76
|
+
*/
|
|
77
|
+
coparse(): string;
|
|
78
|
+
toString(): string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A single string command (`write`/`NL`/`push`/`POP`).
|
|
83
|
+
*/
|
|
84
|
+
export class WasmStrCmd {
|
|
85
|
+
private constructor();
|
|
86
|
+
free(): void;
|
|
87
|
+
[Symbol.dispose](): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Wrap a `StrCmd` as a `CmdOrHole`.
|
|
92
|
+
*/
|
|
93
|
+
export function cmd(c: WasmStrCmd): WasmCmdOrHole;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A leaf node: a tag whose only content is `code`.
|
|
97
|
+
*/
|
|
98
|
+
export function leaf(tag: string, code: string): WasmQTerm;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* An identifier term (the `⟨N⟩` operator).
|
|
102
|
+
*/
|
|
103
|
+
export function name(s: string): WasmQTerm;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A `Push` command.
|
|
107
|
+
*/
|
|
108
|
+
export function push(s: string): WasmStrCmd;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Lift a JS value to a term that reconstructs it (the homogeneous `↑`
|
|
112
|
+
* operator, TypeScript into TypeScript). Supports `number`, `string`, and
|
|
113
|
+
* `boolean`. Numbers with no fractional part lift to integer literals;
|
|
114
|
+
* everything is coparse-only, so the tags are advisory.
|
|
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;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Start building a tuple node with the given tag.
|
|
145
|
+
*/
|
|
146
|
+
export function tb(tag: string): WasmBuilder;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* An unquoted splice.
|
|
150
|
+
*/
|
|
151
|
+
export function unquote(tag: string, index: number, lang: string, term: WasmQTerm, cmds: WasmCmdOrHole[]): WasmQTerm;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* A `Write` command.
|
|
155
|
+
*/
|
|
156
|
+
export function write(s: string): WasmStrCmd;
|
|
157
|
+
|
|
158
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
159
|
+
|
|
160
|
+
export interface InitOutput {
|
|
161
|
+
readonly memory: WebAssembly.Memory;
|
|
162
|
+
readonly HOLE: () => number;
|
|
163
|
+
readonly NL: () => number;
|
|
164
|
+
readonly POP: () => number;
|
|
165
|
+
readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
|
|
166
|
+
readonly __wbg_wasmcmdorhole_free: (a: number, b: number) => void;
|
|
167
|
+
readonly __wbg_wasmqterm_free: (a: number, b: number) => void;
|
|
168
|
+
readonly __wbg_wasmstrcmd_free: (a: number, b: number) => void;
|
|
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;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
202
|
+
* a precompiled `WebAssembly.Module`.
|
|
203
|
+
*
|
|
204
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
205
|
+
*
|
|
206
|
+
* @returns {InitOutput}
|
|
207
|
+
*/
|
|
208
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
212
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
213
|
+
*
|
|
214
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
215
|
+
*
|
|
216
|
+
* @returns {Promise<InitOutput>}
|
|
217
|
+
*/
|
|
218
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/quilt_wasm.js
ADDED
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
/* @ts-self-types="./quilt_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A child placeholder (the `HOLE` constant in the Python runtime).
|
|
5
|
+
* @returns {WasmCmdOrHole}
|
|
6
|
+
*/
|
|
7
|
+
export function HOLE() {
|
|
8
|
+
const ret = wasm.HOLE();
|
|
9
|
+
return WasmCmdOrHole.__wrap(ret);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `NewLine` command (the `NL` constant in the Python runtime).
|
|
14
|
+
* @returns {WasmStrCmd}
|
|
15
|
+
*/
|
|
16
|
+
export function NL() {
|
|
17
|
+
const ret = wasm.NL();
|
|
18
|
+
return WasmStrCmd.__wrap(ret);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The `Pop` command (the `POP` constant in the Python runtime).
|
|
23
|
+
* @returns {WasmStrCmd}
|
|
24
|
+
*/
|
|
25
|
+
export function POP() {
|
|
26
|
+
const ret = wasm.POP();
|
|
27
|
+
return WasmStrCmd.__wrap(ret);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A fluent term builder, mirroring the Rust `QTermBuilder` (consuming form:
|
|
32
|
+
* each method takes `self` and returns the next builder, so chaining works
|
|
33
|
+
* from JS exactly as `tb("x").w("a").c(child).b()`).
|
|
34
|
+
*/
|
|
35
|
+
export class WasmBuilder {
|
|
36
|
+
static __wrap(ptr) {
|
|
37
|
+
const obj = Object.create(WasmBuilder.prototype);
|
|
38
|
+
obj.__wbg_ptr = ptr;
|
|
39
|
+
WasmBuilderFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
__destroy_into_raw() {
|
|
43
|
+
const ptr = this.__wbg_ptr;
|
|
44
|
+
this.__wbg_ptr = 0;
|
|
45
|
+
WasmBuilderFinalization.unregister(this);
|
|
46
|
+
return ptr;
|
|
47
|
+
}
|
|
48
|
+
free() {
|
|
49
|
+
const ptr = this.__destroy_into_raw();
|
|
50
|
+
wasm.__wbg_wasmbuilder_free(ptr, 0);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build the term. Consumes the builder.
|
|
54
|
+
* @returns {WasmQTerm}
|
|
55
|
+
*/
|
|
56
|
+
b() {
|
|
57
|
+
const ptr = this.__destroy_into_raw();
|
|
58
|
+
const ret = wasm.wasmbuilder_b(ptr);
|
|
59
|
+
return WasmQTerm.__wrap(ret);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Splice a child term.
|
|
63
|
+
* @param {WasmQTerm} child
|
|
64
|
+
* @returns {WasmBuilder}
|
|
65
|
+
*/
|
|
66
|
+
c(child) {
|
|
67
|
+
const ptr = this.__destroy_into_raw();
|
|
68
|
+
_assertClass(child, WasmQTerm);
|
|
69
|
+
const ret = wasm.wasmbuilder_c(ptr, child.__wbg_ptr);
|
|
70
|
+
return WasmBuilder.__wrap(ret);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Emit a child term (for an `Arc<QTerm>` this is the same as [`c`]).
|
|
74
|
+
* @param {WasmQTerm} child
|
|
75
|
+
* @returns {WasmBuilder}
|
|
76
|
+
*/
|
|
77
|
+
e(child) {
|
|
78
|
+
const ptr = this.__destroy_into_raw();
|
|
79
|
+
_assertClass(child, WasmQTerm);
|
|
80
|
+
const ret = wasm.wasmbuilder_e(ptr, child.__wbg_ptr);
|
|
81
|
+
return WasmBuilder.__wrap(ret);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Emit a newline (respecting the current prefix).
|
|
85
|
+
* @returns {WasmBuilder}
|
|
86
|
+
*/
|
|
87
|
+
n() {
|
|
88
|
+
const ptr = this.__destroy_into_raw();
|
|
89
|
+
const ret = wasm.wasmbuilder_n(ptr);
|
|
90
|
+
return WasmBuilder.__wrap(ret);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Push an indentation prefix.
|
|
94
|
+
* @param {string} s
|
|
95
|
+
* @returns {WasmBuilder}
|
|
96
|
+
*/
|
|
97
|
+
p(s) {
|
|
98
|
+
const ptr = this.__destroy_into_raw();
|
|
99
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
100
|
+
const len0 = WASM_VECTOR_LEN;
|
|
101
|
+
const ret = wasm.wasmbuilder_p(ptr, ptr0, len0);
|
|
102
|
+
return WasmBuilder.__wrap(ret);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Write literal source text.
|
|
106
|
+
* @param {string} s
|
|
107
|
+
* @returns {WasmBuilder}
|
|
108
|
+
*/
|
|
109
|
+
w(s) {
|
|
110
|
+
const ptr = this.__destroy_into_raw();
|
|
111
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
112
|
+
const len0 = WASM_VECTOR_LEN;
|
|
113
|
+
const ret = wasm.wasmbuilder_w(ptr, ptr0, len0);
|
|
114
|
+
return WasmBuilder.__wrap(ret);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Pop an indentation prefix.
|
|
118
|
+
* @returns {WasmBuilder}
|
|
119
|
+
*/
|
|
120
|
+
x() {
|
|
121
|
+
const ptr = this.__destroy_into_raw();
|
|
122
|
+
const ret = wasm.wasmbuilder_x(ptr);
|
|
123
|
+
return WasmBuilder.__wrap(ret);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (Symbol.dispose) WasmBuilder.prototype[Symbol.dispose] = WasmBuilder.prototype.free;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A `StrCmd` or a child placeholder (`HOLE`), used in `quote`/`unquote` cmds.
|
|
130
|
+
*/
|
|
131
|
+
export class WasmCmdOrHole {
|
|
132
|
+
static __wrap(ptr) {
|
|
133
|
+
const obj = Object.create(WasmCmdOrHole.prototype);
|
|
134
|
+
obj.__wbg_ptr = ptr;
|
|
135
|
+
WasmCmdOrHoleFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
136
|
+
return obj;
|
|
137
|
+
}
|
|
138
|
+
static __unwrap(jsValue) {
|
|
139
|
+
if (!(jsValue instanceof WasmCmdOrHole)) {
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
return jsValue.__destroy_into_raw();
|
|
143
|
+
}
|
|
144
|
+
__destroy_into_raw() {
|
|
145
|
+
const ptr = this.__wbg_ptr;
|
|
146
|
+
this.__wbg_ptr = 0;
|
|
147
|
+
WasmCmdOrHoleFinalization.unregister(this);
|
|
148
|
+
return ptr;
|
|
149
|
+
}
|
|
150
|
+
free() {
|
|
151
|
+
const ptr = this.__destroy_into_raw();
|
|
152
|
+
wasm.__wbg_wasmcmdorhole_free(ptr, 0);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (Symbol.dispose) WasmCmdOrHole.prototype[Symbol.dispose] = WasmCmdOrHole.prototype.free;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A quilt term (`Arc<QTerm>`).
|
|
159
|
+
*/
|
|
160
|
+
export class WasmQTerm {
|
|
161
|
+
static __wrap(ptr) {
|
|
162
|
+
const obj = Object.create(WasmQTerm.prototype);
|
|
163
|
+
obj.__wbg_ptr = ptr;
|
|
164
|
+
WasmQTermFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
165
|
+
return obj;
|
|
166
|
+
}
|
|
167
|
+
__destroy_into_raw() {
|
|
168
|
+
const ptr = this.__wbg_ptr;
|
|
169
|
+
this.__wbg_ptr = 0;
|
|
170
|
+
WasmQTermFinalization.unregister(this);
|
|
171
|
+
return ptr;
|
|
172
|
+
}
|
|
173
|
+
free() {
|
|
174
|
+
const ptr = this.__destroy_into_raw();
|
|
175
|
+
wasm.__wbg_wasmqterm_free(ptr, 0);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Serialize the term back to source code.
|
|
179
|
+
* @returns {string}
|
|
180
|
+
*/
|
|
181
|
+
coparse() {
|
|
182
|
+
let deferred1_0;
|
|
183
|
+
let deferred1_1;
|
|
184
|
+
try {
|
|
185
|
+
const ret = wasm.wasmqterm_coparse(this.__wbg_ptr);
|
|
186
|
+
deferred1_0 = ret[0];
|
|
187
|
+
deferred1_1 = ret[1];
|
|
188
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
189
|
+
} finally {
|
|
190
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @returns {string}
|
|
195
|
+
*/
|
|
196
|
+
toString() {
|
|
197
|
+
let deferred1_0;
|
|
198
|
+
let deferred1_1;
|
|
199
|
+
try {
|
|
200
|
+
const ret = wasm.wasmqterm_toString(this.__wbg_ptr);
|
|
201
|
+
deferred1_0 = ret[0];
|
|
202
|
+
deferred1_1 = ret[1];
|
|
203
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
204
|
+
} finally {
|
|
205
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (Symbol.dispose) WasmQTerm.prototype[Symbol.dispose] = WasmQTerm.prototype.free;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* A single string command (`write`/`NL`/`push`/`POP`).
|
|
213
|
+
*/
|
|
214
|
+
export class WasmStrCmd {
|
|
215
|
+
static __wrap(ptr) {
|
|
216
|
+
const obj = Object.create(WasmStrCmd.prototype);
|
|
217
|
+
obj.__wbg_ptr = ptr;
|
|
218
|
+
WasmStrCmdFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
219
|
+
return obj;
|
|
220
|
+
}
|
|
221
|
+
__destroy_into_raw() {
|
|
222
|
+
const ptr = this.__wbg_ptr;
|
|
223
|
+
this.__wbg_ptr = 0;
|
|
224
|
+
WasmStrCmdFinalization.unregister(this);
|
|
225
|
+
return ptr;
|
|
226
|
+
}
|
|
227
|
+
free() {
|
|
228
|
+
const ptr = this.__destroy_into_raw();
|
|
229
|
+
wasm.__wbg_wasmstrcmd_free(ptr, 0);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (Symbol.dispose) WasmStrCmd.prototype[Symbol.dispose] = WasmStrCmd.prototype.free;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Wrap a `StrCmd` as a `CmdOrHole`.
|
|
236
|
+
* @param {WasmStrCmd} c
|
|
237
|
+
* @returns {WasmCmdOrHole}
|
|
238
|
+
*/
|
|
239
|
+
export function cmd(c) {
|
|
240
|
+
_assertClass(c, WasmStrCmd);
|
|
241
|
+
const ret = wasm.cmd(c.__wbg_ptr);
|
|
242
|
+
return WasmCmdOrHole.__wrap(ret);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* A leaf node: a tag whose only content is `code`.
|
|
247
|
+
* @param {string} tag
|
|
248
|
+
* @param {string} code
|
|
249
|
+
* @returns {WasmQTerm}
|
|
250
|
+
*/
|
|
251
|
+
export function leaf(tag, code) {
|
|
252
|
+
const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
253
|
+
const len0 = WASM_VECTOR_LEN;
|
|
254
|
+
const ptr1 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
255
|
+
const len1 = WASM_VECTOR_LEN;
|
|
256
|
+
const ret = wasm.leaf(ptr0, len0, ptr1, len1);
|
|
257
|
+
return WasmQTerm.__wrap(ret);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* An identifier term (the `⟨N⟩` operator).
|
|
262
|
+
* @param {string} s
|
|
263
|
+
* @returns {WasmQTerm}
|
|
264
|
+
*/
|
|
265
|
+
export function name(s) {
|
|
266
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
267
|
+
const len0 = WASM_VECTOR_LEN;
|
|
268
|
+
const ret = wasm.name(ptr0, len0);
|
|
269
|
+
return WasmQTerm.__wrap(ret);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* A `Push` command.
|
|
274
|
+
* @param {string} s
|
|
275
|
+
* @returns {WasmStrCmd}
|
|
276
|
+
*/
|
|
277
|
+
export function push(s) {
|
|
278
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
279
|
+
const len0 = WASM_VECTOR_LEN;
|
|
280
|
+
const ret = wasm.push(ptr0, len0);
|
|
281
|
+
return WasmStrCmd.__wrap(ret);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Lift a JS value to a term that reconstructs it (the homogeneous `↑`
|
|
286
|
+
* operator, TypeScript into TypeScript). Supports `number`, `string`, and
|
|
287
|
+
* `boolean`. Numbers with no fractional part lift to integer literals;
|
|
288
|
+
* everything is coparse-only, so the tags are advisory.
|
|
289
|
+
*
|
|
290
|
+
* Unlike the Python runtime's `qlift`, this does *not* pass an already-built
|
|
291
|
+
* `QTerm` through unchanged: recovering an exported wasm-bindgen type from a
|
|
292
|
+
* polymorphic `JsValue` needs target-specific glue. The demos never lift a
|
|
293
|
+
* term (terms splice via `↙…↘`), so this is sufficient; a JS shim can add
|
|
294
|
+
* pass-through later if needed.
|
|
295
|
+
* @param {any} value
|
|
296
|
+
* @returns {WasmQTerm}
|
|
297
|
+
*/
|
|
298
|
+
export function qlift(value) {
|
|
299
|
+
const ret = wasm.qlift(value);
|
|
300
|
+
if (ret[2]) {
|
|
301
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
302
|
+
}
|
|
303
|
+
return WasmQTerm.__wrap(ret[0]);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Lift a JS value to an HTML term (the `↑` operator with an `html` splice
|
|
308
|
+
* target). Strings become entity-escaped `text` leaves — inert as text content
|
|
309
|
+
* or as a double-quoted attribute value — and terms pass through unchanged, so
|
|
310
|
+
* already-built fragments can be lifted too. Mirrors `qlift_html` in the
|
|
311
|
+
* Python runtime, minus the `QTerm` pass-through (see [`qlift`]).
|
|
312
|
+
* @param {any} value
|
|
313
|
+
* @returns {WasmQTerm}
|
|
314
|
+
*/
|
|
315
|
+
export function qlift_html(value) {
|
|
316
|
+
const ret = wasm.qlift_html(value);
|
|
317
|
+
if (ret[2]) {
|
|
318
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
319
|
+
}
|
|
320
|
+
return WasmQTerm.__wrap(ret[0]);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* A quoted fragment.
|
|
325
|
+
* @param {string} tag
|
|
326
|
+
* @param {number} index
|
|
327
|
+
* @param {string} lang
|
|
328
|
+
* @param {WasmQTerm} term
|
|
329
|
+
* @param {WasmCmdOrHole[]} cmds
|
|
330
|
+
* @returns {WasmQTerm}
|
|
331
|
+
*/
|
|
332
|
+
export function quote(tag, index, lang, term, cmds) {
|
|
333
|
+
const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
334
|
+
const len0 = WASM_VECTOR_LEN;
|
|
335
|
+
const ptr1 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
336
|
+
const len1 = WASM_VECTOR_LEN;
|
|
337
|
+
_assertClass(term, WasmQTerm);
|
|
338
|
+
const ptr2 = passArrayJsValueToWasm0(cmds, wasm.__wbindgen_malloc);
|
|
339
|
+
const len2 = WASM_VECTOR_LEN;
|
|
340
|
+
const ret = wasm.quote(ptr0, len0, index, ptr1, len1, term.__wbg_ptr, ptr2, len2);
|
|
341
|
+
return WasmQTerm.__wrap(ret);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* A symbol: a leaf whose tag and code are the same.
|
|
346
|
+
* @param {string} s
|
|
347
|
+
* @returns {WasmQTerm}
|
|
348
|
+
*/
|
|
349
|
+
export function sym(s) {
|
|
350
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
351
|
+
const len0 = WASM_VECTOR_LEN;
|
|
352
|
+
const ret = wasm.sym(ptr0, len0);
|
|
353
|
+
return WasmQTerm.__wrap(ret);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Start building a tuple node with the given tag.
|
|
358
|
+
* @param {string} tag
|
|
359
|
+
* @returns {WasmBuilder}
|
|
360
|
+
*/
|
|
361
|
+
export function tb(tag) {
|
|
362
|
+
const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
363
|
+
const len0 = WASM_VECTOR_LEN;
|
|
364
|
+
const ret = wasm.tb(ptr0, len0);
|
|
365
|
+
return WasmBuilder.__wrap(ret);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* An unquoted splice.
|
|
370
|
+
* @param {string} tag
|
|
371
|
+
* @param {number} index
|
|
372
|
+
* @param {string} lang
|
|
373
|
+
* @param {WasmQTerm} term
|
|
374
|
+
* @param {WasmCmdOrHole[]} cmds
|
|
375
|
+
* @returns {WasmQTerm}
|
|
376
|
+
*/
|
|
377
|
+
export function unquote(tag, index, lang, term, cmds) {
|
|
378
|
+
const ptr0 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
379
|
+
const len0 = WASM_VECTOR_LEN;
|
|
380
|
+
const ptr1 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
381
|
+
const len1 = WASM_VECTOR_LEN;
|
|
382
|
+
_assertClass(term, WasmQTerm);
|
|
383
|
+
const ptr2 = passArrayJsValueToWasm0(cmds, wasm.__wbindgen_malloc);
|
|
384
|
+
const len2 = WASM_VECTOR_LEN;
|
|
385
|
+
const ret = wasm.unquote(ptr0, len0, index, ptr1, len1, term.__wbg_ptr, ptr2, len2);
|
|
386
|
+
return WasmQTerm.__wrap(ret);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* A `Write` command.
|
|
391
|
+
* @param {string} s
|
|
392
|
+
* @returns {WasmStrCmd}
|
|
393
|
+
*/
|
|
394
|
+
export function write(s) {
|
|
395
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
396
|
+
const len0 = WASM_VECTOR_LEN;
|
|
397
|
+
const ret = wasm.write(ptr0, len0);
|
|
398
|
+
return WasmStrCmd.__wrap(ret);
|
|
399
|
+
}
|
|
400
|
+
function __wbg_get_imports() {
|
|
401
|
+
const import0 = {
|
|
402
|
+
__proto__: null,
|
|
403
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
404
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
405
|
+
return ret;
|
|
406
|
+
},
|
|
407
|
+
__wbg___wbindgen_boolean_get_edaed31a367ce1bd: function(arg0) {
|
|
408
|
+
const v = arg0;
|
|
409
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
410
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
411
|
+
},
|
|
412
|
+
__wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
|
|
413
|
+
const obj = arg1;
|
|
414
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
415
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
416
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
417
|
+
},
|
|
418
|
+
__wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
|
|
419
|
+
const obj = arg1;
|
|
420
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
421
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
422
|
+
var len1 = WASM_VECTOR_LEN;
|
|
423
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
424
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
425
|
+
},
|
|
426
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
427
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
428
|
+
},
|
|
429
|
+
__wbg_wasmcmdorhole_unwrap: function(arg0) {
|
|
430
|
+
const ret = WasmCmdOrHole.__unwrap(arg0);
|
|
431
|
+
return ret;
|
|
432
|
+
},
|
|
433
|
+
__wbindgen_init_externref_table: function() {
|
|
434
|
+
const table = wasm.__wbindgen_externrefs;
|
|
435
|
+
const offset = table.grow(4);
|
|
436
|
+
table.set(0, undefined);
|
|
437
|
+
table.set(offset + 0, undefined);
|
|
438
|
+
table.set(offset + 1, null);
|
|
439
|
+
table.set(offset + 2, true);
|
|
440
|
+
table.set(offset + 3, false);
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
return {
|
|
444
|
+
__proto__: null,
|
|
445
|
+
"./quilt_wasm_bg.js": import0,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const WasmBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
450
|
+
? { register: () => {}, unregister: () => {} }
|
|
451
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmbuilder_free(ptr, 1));
|
|
452
|
+
const WasmCmdOrHoleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
453
|
+
? { register: () => {}, unregister: () => {} }
|
|
454
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmcmdorhole_free(ptr, 1));
|
|
455
|
+
const WasmQTermFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
456
|
+
? { register: () => {}, unregister: () => {} }
|
|
457
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmqterm_free(ptr, 1));
|
|
458
|
+
const WasmStrCmdFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
459
|
+
? { register: () => {}, unregister: () => {} }
|
|
460
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmstrcmd_free(ptr, 1));
|
|
461
|
+
|
|
462
|
+
function addToExternrefTable0(obj) {
|
|
463
|
+
const idx = wasm.__externref_table_alloc();
|
|
464
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
465
|
+
return idx;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function _assertClass(instance, klass) {
|
|
469
|
+
if (!(instance instanceof klass)) {
|
|
470
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
let cachedDataViewMemory0 = null;
|
|
475
|
+
function getDataViewMemory0() {
|
|
476
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
477
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
478
|
+
}
|
|
479
|
+
return cachedDataViewMemory0;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function getStringFromWasm0(ptr, len) {
|
|
483
|
+
return decodeText(ptr >>> 0, len);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
let cachedUint8ArrayMemory0 = null;
|
|
487
|
+
function getUint8ArrayMemory0() {
|
|
488
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
489
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
490
|
+
}
|
|
491
|
+
return cachedUint8ArrayMemory0;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function isLikeNone(x) {
|
|
495
|
+
return x === undefined || x === null;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
499
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
500
|
+
for (let i = 0; i < array.length; i++) {
|
|
501
|
+
const add = addToExternrefTable0(array[i]);
|
|
502
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
503
|
+
}
|
|
504
|
+
WASM_VECTOR_LEN = array.length;
|
|
505
|
+
return ptr;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
509
|
+
if (realloc === undefined) {
|
|
510
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
511
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
512
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
513
|
+
WASM_VECTOR_LEN = buf.length;
|
|
514
|
+
return ptr;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
let len = arg.length;
|
|
518
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
519
|
+
|
|
520
|
+
const mem = getUint8ArrayMemory0();
|
|
521
|
+
|
|
522
|
+
let offset = 0;
|
|
523
|
+
|
|
524
|
+
for (; offset < len; offset++) {
|
|
525
|
+
const code = arg.charCodeAt(offset);
|
|
526
|
+
if (code > 0x7F) break;
|
|
527
|
+
mem[ptr + offset] = code;
|
|
528
|
+
}
|
|
529
|
+
if (offset !== len) {
|
|
530
|
+
if (offset !== 0) {
|
|
531
|
+
arg = arg.slice(offset);
|
|
532
|
+
}
|
|
533
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
534
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
535
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
536
|
+
|
|
537
|
+
offset += ret.written;
|
|
538
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
WASM_VECTOR_LEN = offset;
|
|
542
|
+
return ptr;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function takeFromExternrefTable0(idx) {
|
|
546
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
547
|
+
wasm.__externref_table_dealloc(idx);
|
|
548
|
+
return value;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
552
|
+
cachedTextDecoder.decode();
|
|
553
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
554
|
+
let numBytesDecoded = 0;
|
|
555
|
+
function decodeText(ptr, len) {
|
|
556
|
+
numBytesDecoded += len;
|
|
557
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
558
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
559
|
+
cachedTextDecoder.decode();
|
|
560
|
+
numBytesDecoded = len;
|
|
561
|
+
}
|
|
562
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
const cachedTextEncoder = new TextEncoder();
|
|
566
|
+
|
|
567
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
568
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
569
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
570
|
+
view.set(buf);
|
|
571
|
+
return {
|
|
572
|
+
read: arg.length,
|
|
573
|
+
written: buf.length
|
|
574
|
+
};
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
let WASM_VECTOR_LEN = 0;
|
|
579
|
+
|
|
580
|
+
let wasmModule, wasmInstance, wasm;
|
|
581
|
+
function __wbg_finalize_init(instance, module) {
|
|
582
|
+
wasmInstance = instance;
|
|
583
|
+
wasm = instance.exports;
|
|
584
|
+
wasmModule = module;
|
|
585
|
+
cachedDataViewMemory0 = null;
|
|
586
|
+
cachedUint8ArrayMemory0 = null;
|
|
587
|
+
wasm.__wbindgen_start();
|
|
588
|
+
return wasm;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
async function __wbg_load(module, imports) {
|
|
592
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
593
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
594
|
+
try {
|
|
595
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
596
|
+
} catch (e) {
|
|
597
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
598
|
+
|
|
599
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
600
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
601
|
+
|
|
602
|
+
} else { throw e; }
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const bytes = await module.arrayBuffer();
|
|
607
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
608
|
+
} else {
|
|
609
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
610
|
+
|
|
611
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
612
|
+
return { instance, module };
|
|
613
|
+
} else {
|
|
614
|
+
return instance;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function expectedResponseType(type) {
|
|
619
|
+
switch (type) {
|
|
620
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
621
|
+
}
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function initSync(module) {
|
|
627
|
+
if (wasm !== undefined) return wasm;
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
if (module !== undefined) {
|
|
631
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
632
|
+
({module} = module)
|
|
633
|
+
} else {
|
|
634
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
const imports = __wbg_get_imports();
|
|
639
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
640
|
+
module = new WebAssembly.Module(module);
|
|
641
|
+
}
|
|
642
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
643
|
+
return __wbg_finalize_init(instance, module);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
async function __wbg_init(module_or_path) {
|
|
647
|
+
if (wasm !== undefined) return wasm;
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
if (module_or_path !== undefined) {
|
|
651
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
652
|
+
({module_or_path} = module_or_path)
|
|
653
|
+
} else {
|
|
654
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (module_or_path === undefined) {
|
|
659
|
+
module_or_path = new URL('quilt_wasm_bg.wasm', import.meta.url);
|
|
660
|
+
}
|
|
661
|
+
const imports = __wbg_get_imports();
|
|
662
|
+
|
|
663
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
664
|
+
module_or_path = fetch(module_or_path);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
668
|
+
|
|
669
|
+
return __wbg_finalize_init(instance, module);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|