@sebastienrousseau/noyalib-wasm 0.0.12
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 +333 -0
- package/noyalib_wasm.d.ts +95 -0
- package/noyalib_wasm.js +9 -0
- package/noyalib_wasm_bg.js +676 -0
- package/noyalib_wasm_bg.wasm +0 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 OR MIT -->
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://cloudcdn.pro/noyalib/v1/logos/noyalib.svg" alt="Noyalib logo" width="128" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">noyalib-wasm</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong><code>wasm-bindgen</code> wrapper around noyalib —
|
|
11
|
+
pure-Rust YAML 1.2, zero <code>unsafe</code>, ~338 KB after
|
|
12
|
+
LTO. Runs in browsers, Node, Cloudflare Workers, Deno, and
|
|
13
|
+
any other WASM-capable host.</strong>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://github.com/sebastienrousseau/noyalib/actions"><img src="https://img.shields.io/github/actions/workflow/status/sebastienrousseau/noyalib/ci.yml?style=for-the-badge&logo=github" alt="Build" /></a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@noyalib/noyalib-wasm"><img src="https://img.shields.io/npm/v/@noyalib/noyalib-wasm?style=for-the-badge&color=fc8d62&logo=npm" alt="npm" /></a>
|
|
19
|
+
<a href="https://docs.rs/noyalib-wasm"><img src="https://img.shields.io/badge/docs.rs-noyalib--wasm-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" alt="Docs.rs" /></a>
|
|
20
|
+
<a href="https://bundlephobia.com/package/@noyalib/noyalib-wasm"><img src="https://img.shields.io/bundlephobia/minzip/@noyalib/noyalib-wasm?style=for-the-badge&color=informational" alt="Bundle size" /></a>
|
|
21
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/sebastienrousseau/noyalib"><img src="https://img.shields.io/ossf-scorecard/github.com/sebastienrousseau/noyalib?style=for-the-badge&label=OpenSSF%20Scorecard&logo=openssf" alt="OpenSSF Scorecard" /></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Contents
|
|
27
|
+
|
|
28
|
+
- [Install](#install) — npm, build from source
|
|
29
|
+
- [Quick Start](#quick-start) — parse, edit, validate
|
|
30
|
+
- [Why this approach?](#why-this-approach) — vs `js-yaml`
|
|
31
|
+
- [Surface](#surface) — exported APIs
|
|
32
|
+
- [Bundle size](#bundle-size) — what you ship to users
|
|
33
|
+
- [Targets](#targets) — every wasm-pack flavour
|
|
34
|
+
- [Provenance](#provenance) — npm + cosign
|
|
35
|
+
- [Examples](#examples) — Node + browser demos
|
|
36
|
+
- [When not to use noyalib-wasm](#when-not-to-use-noyalib-wasm)
|
|
37
|
+
- [Documentation](#documentation)
|
|
38
|
+
- [License](#license)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install @noyalib/noyalib-wasm
|
|
46
|
+
# or
|
|
47
|
+
pnpm add @noyalib/noyalib-wasm
|
|
48
|
+
# or
|
|
49
|
+
yarn add @noyalib/noyalib-wasm
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or build from source against any wasm-pack target:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
git clone https://github.com/sebastienrousseau/noyalib-wasm
|
|
56
|
+
cd noyalib-wasm
|
|
57
|
+
wasm-pack build --release --target bundler
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> **Split from the monorepo since v0.0.12.** Prior versions
|
|
61
|
+
> shipped from `sebastienrousseau/noyalib/crates/noyalib-wasm/`.
|
|
62
|
+
> From v0.0.12 onward `noyalib-wasm` lives here as its own crate,
|
|
63
|
+
> released in strict lockstep with the parent
|
|
64
|
+
> [`noyalib`](https://github.com/sebastienrousseau/noyalib) at
|
|
65
|
+
> the same version. See
|
|
66
|
+
> [ADR-0005](https://github.com/sebastienrousseau/noyalib/blob/main/doc/adr/0005-workspace-split.md)
|
|
67
|
+
> for the rationale and rollback recipe.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import init, {
|
|
75
|
+
parse,
|
|
76
|
+
stringify,
|
|
77
|
+
validateJson,
|
|
78
|
+
getPath,
|
|
79
|
+
merge,
|
|
80
|
+
WasmDocument,
|
|
81
|
+
} from "@noyalib/noyalib-wasm";
|
|
82
|
+
|
|
83
|
+
await init(); // load the WASM blob
|
|
84
|
+
|
|
85
|
+
// Plain parse / stringify — like js-yaml. Mappings come back as
|
|
86
|
+
// plain JS Objects (not `Map`), so dotted property access works.
|
|
87
|
+
const obj = parse("host: api.example.com\nport: 8080\n");
|
|
88
|
+
console.log(obj.host); // "api.example.com"
|
|
89
|
+
const yaml = stringify(obj);
|
|
90
|
+
|
|
91
|
+
// Indexed read without going through `parse`.
|
|
92
|
+
const port = getPath("host: api.example.com\nport: 8080\n", "port"); // 8080
|
|
93
|
+
|
|
94
|
+
// JSON-compatible YAML 1.2 schema check.
|
|
95
|
+
validateJson("a: 1\nb: [2, 3]\n"); // true
|
|
96
|
+
|
|
97
|
+
// Lossless CST edit — comments + indentation preserved.
|
|
98
|
+
const doc = new WasmDocument(source);
|
|
99
|
+
doc.set("server.port", "9090");
|
|
100
|
+
fs.writeFileSync("config.yaml", doc.toString());
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Why this approach?
|
|
106
|
+
|
|
107
|
+
[`js-yaml`](https://github.com/nodeca/js-yaml) is the de-facto
|
|
108
|
+
JS YAML parser, and it's good — but it makes two tradeoffs that
|
|
109
|
+
hurt for editor and tooling workloads:
|
|
110
|
+
|
|
111
|
+
1. **`js-yaml` discards comments by spec.** It implements the
|
|
112
|
+
YAML data model, which excludes comments. Round-tripping a
|
|
113
|
+
document through `parse` → `dump` strips every `#` line.
|
|
114
|
+
noyalib's `Document` API runs through a lossless CST that
|
|
115
|
+
reproduces the source byte-for-byte; only the surgically
|
|
116
|
+
touched span changes on a `set`.
|
|
117
|
+
|
|
118
|
+
2. **`js-yaml` follows YAML 1.1 by default.** That's the
|
|
119
|
+
"Norway problem": `country: NO` parses as `country: false`,
|
|
120
|
+
silently rewriting the country code. noyalib defaults to
|
|
121
|
+
YAML 1.2 strict semantics; only `true` / `false` are
|
|
122
|
+
booleans.
|
|
123
|
+
|
|
124
|
+
### Custom YAML tags
|
|
125
|
+
|
|
126
|
+
`parse(yaml)` surfaces YAML tags as plain JS object keys:
|
|
127
|
+
`!Color '#ff8800'` deserialises into `{ "!Color": "#ff8800" }`.
|
|
128
|
+
This matches the serde-bridge convention every other
|
|
129
|
+
`serde-wasm-bindgen` consumer uses (the `Value::Tagged` variant
|
|
130
|
+
serialises as a single-entry map for cross-format interop).
|
|
131
|
+
Round-tripping via `stringify` does **not** restore the
|
|
132
|
+
YAML-tag prefix — the JS object's tag-as-key shape becomes a
|
|
133
|
+
quoted mapping key in the emitted YAML.
|
|
134
|
+
|
|
135
|
+
For editor / tooling workloads where the YAML-tag wire form
|
|
136
|
+
must survive a parse → emit cycle, use the `WasmDocument`
|
|
137
|
+
class instead. Its `set` / `setValue` are surgical edits
|
|
138
|
+
through the CST, so untouched tag prefixes round-trip
|
|
139
|
+
verbatim:
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
const doc = new WasmDocument("color: !Color '#ff8800'\n");
|
|
143
|
+
doc.set("color", "!Color '#00aaff'"); // tag survives
|
|
144
|
+
console.log(doc.toString()); // "color: !Color '#00aaff'\n"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Other differences worth knowing about:
|
|
148
|
+
|
|
149
|
+
- **JSON Schema 2020-12 validation built in.** Same engine as
|
|
150
|
+
the `noyavalidate` CLI ships.
|
|
151
|
+
- **Pure-Rust, zero `unsafe`.** Every byte of the parser,
|
|
152
|
+
scanner, formatter, and CST is checked at compile time by the
|
|
153
|
+
workspace `#![forbid(unsafe_code)]` lint.
|
|
154
|
+
- **~338 KB bundle.** That's roughly the same size as `js-yaml`
|
|
155
|
+
minified + gzipped, with the lossless-CST surface and YAML
|
|
156
|
+
1.2 semantics baked in.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Surface
|
|
161
|
+
|
|
162
|
+
All exports are camelCase, matching JS conventions.
|
|
163
|
+
|
|
164
|
+
### Free functions
|
|
165
|
+
|
|
166
|
+
| Export | What it does |
|
|
167
|
+
|---|---|
|
|
168
|
+
| `parse(yaml: string): any` | Parse a YAML document into a JS value. Mappings become plain Objects; sequences become Arrays; scalars become numbers / strings / booleans / null. Mirrors `js-yaml`'s `load`. |
|
|
169
|
+
| `stringify(value: any): string` | Serialise a JS value back to YAML. |
|
|
170
|
+
| `validateJson(yaml: string): boolean` | Validate that the document conforms to the YAML 1.2 JSON-compatible schema (only types JSON allows: null / bool / number / string / array / object). Returns `true` / `false`; structural JSON Schema 2020-12 validation is on the `noyavalidate` CLI roadmap. |
|
|
171
|
+
| `getPath(yaml: string, path: string): any` | Indexed read without going through `parse`. Dotted paths (`"server.host"`); returns `null` if missing. |
|
|
172
|
+
| `merge(base: string, override: string): string` | Deep-merge two YAML documents. Delegates to `noyalib::Value::merge`. |
|
|
173
|
+
|
|
174
|
+
### `WasmDocument` class — lossless CST
|
|
175
|
+
|
|
176
|
+
Construct with `new WasmDocument(yaml)`. Every method preserves
|
|
177
|
+
comments and formatting around untouched spans byte-faithfully.
|
|
178
|
+
|
|
179
|
+
| Method | What it does |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `toString(): string` | Re-emit. Byte-identical to the parsed source if no edits were made. |
|
|
182
|
+
| `get(path: string): any` | Parsed value at a dotted path. Returns `null` if missing. |
|
|
183
|
+
| `getSource(path: string): string \| null` | Raw source fragment at a dotted path (no re-quoting / canonicalisation). |
|
|
184
|
+
| `set(path: string, fragment: string): void` | Surgically rewrite a value at a dotted path. The fragment is a YAML-shaped string (`"9090"`, `"[1,2,3]"`, …). |
|
|
185
|
+
| `setValue(path: string, value: any): void` | Same as `set` but accepts a JS value instead of a YAML fragment. |
|
|
186
|
+
| `spanAt(path: string): { start: number, end: number } \| null` | Byte range of the value at a dotted path. |
|
|
187
|
+
| `commentsAt(path: string): { before: string[], inline: string \| null }` | Comments associated with the node at a path. |
|
|
188
|
+
| `replaceSpan(start: number, end: number, replacement: string): void` | Primitive byte replacement. |
|
|
189
|
+
|
|
190
|
+
Every function is `async` only via `init()` — once the WASM
|
|
191
|
+
blob is loaded, individual calls are synchronous.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Bundle size
|
|
196
|
+
|
|
197
|
+
| Build | Size (raw) | Size (gzip) |
|
|
198
|
+
|---|---|---|
|
|
199
|
+
| Default (`wasm-pack build --release --target bundler`) | ~338 KB | ~140 KB |
|
|
200
|
+
| `--features wasm-opt` (post-build pass) | ~280 KB | ~115 KB |
|
|
201
|
+
|
|
202
|
+
Tree-shaking-friendly — the `Document` API and the plain
|
|
203
|
+
`parse` / `stringify` API are independent modules; bundlers
|
|
204
|
+
drop whichever your code does not import.
|
|
205
|
+
|
|
206
|
+
For comparison: `js-yaml` 4.x lands around ~50 KB minified +
|
|
207
|
+
~12 KB gzipped, but does not provide lossless-CST or schema
|
|
208
|
+
validation.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Targets
|
|
213
|
+
|
|
214
|
+
`wasm-pack build` supports every target wasm-bindgen does:
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
wasm-pack build --target bundler # webpack, rollup, esbuild
|
|
218
|
+
wasm-pack build --target web # native ES module via <script type="module">
|
|
219
|
+
wasm-pack build --target nodejs # commonjs Node import
|
|
220
|
+
wasm-pack build --target deno # Deno-native module
|
|
221
|
+
wasm-pack build --target no-modules # plain global, no module loader
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Cloudflare Workers and edge runtimes generally consume the
|
|
225
|
+
`bundler` target via their packaging step.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Provenance
|
|
230
|
+
|
|
231
|
+
Every release on npm carries an
|
|
232
|
+
[npm provenance attestation](https://docs.npmjs.com/generating-provenance-statements)
|
|
233
|
+
linking the published bundle to the GitHub Actions run that
|
|
234
|
+
produced it. Verify via:
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
npm view @noyalib/noyalib-wasm provenance
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The underlying `.wasm` is also signed with cosign keyless
|
|
241
|
+
alongside every release; the verify command is identical to
|
|
242
|
+
the source crate's:
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
cosign verify-blob \
|
|
246
|
+
--certificate-identity-regexp 'https://github.com/sebastienrousseau/noyalib/' \
|
|
247
|
+
--certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
|
|
248
|
+
--certificate noyalib_wasm_bg.wasm.pem \
|
|
249
|
+
--signature noyalib_wasm_bg.wasm.sig \
|
|
250
|
+
noyalib_wasm_bg.wasm
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Full cookbook: [`pkg/VERIFY.md`](https://github.com/sebastienrousseau/noyalib/blob/main/pkg/VERIFY.md).
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Examples
|
|
258
|
+
|
|
259
|
+
Browser + Node demos under
|
|
260
|
+
[`crates/noyalib-wasm/examples/`](examples/):
|
|
261
|
+
|
|
262
|
+
| Path | Target | What it shows |
|
|
263
|
+
|---|---|---|
|
|
264
|
+
| [`node-stringify.js`](examples/node-stringify.js) | Node | `parse` + `stringify` round-trip. |
|
|
265
|
+
| [`cst-edit.js`](examples/cst-edit.js) | Node | Lossless CST edit; comments + whitespace preserved. |
|
|
266
|
+
| [`schema-validate.js`](examples/schema-validate.js) | Node | JSON Schema 2020-12 validation, good and bad cases. |
|
|
267
|
+
| [`browser/index.html`](examples/browser/index.html) | Browser | Live in-page YAML editor with a parsed-JSON pane. |
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Node:
|
|
271
|
+
wasm-pack build --release --target nodejs crates/noyalib-wasm
|
|
272
|
+
node crates/noyalib-wasm/examples/cst-edit.js
|
|
273
|
+
|
|
274
|
+
# Browser:
|
|
275
|
+
wasm-pack build --release --target web crates/noyalib-wasm
|
|
276
|
+
cd crates/noyalib-wasm/examples/browser
|
|
277
|
+
python3 -m http.server # or any static-file server
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## When not to use noyalib-wasm
|
|
283
|
+
|
|
284
|
+
- **You only ever consume YAML in Node and don't care about
|
|
285
|
+
comment-preserving edits or YAML 1.2 strictness.** `js-yaml`
|
|
286
|
+
is smaller (~50 KB minified) and the de-facto standard;
|
|
287
|
+
reach for it first.
|
|
288
|
+
- **You need a streaming parser for multi-GB documents.** The
|
|
289
|
+
WASM bindings always read the full document into memory.
|
|
290
|
+
For TB-scale streaming workloads, drive the noyalib library
|
|
291
|
+
directly from a Rust process and pipe results out.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Compatibility
|
|
296
|
+
|
|
297
|
+
**MSRV: Rust 1.85.0** stable. The `wasm-bindgen` 0.2 ecosystem
|
|
298
|
+
floors the toolchain at 1.85; the core `noyalib` library
|
|
299
|
+
itself stays at 1.75. CI verifies the floor on every PR via
|
|
300
|
+
the `Per-crate MSRV` workflow job. The bump policy lives in
|
|
301
|
+
[`doc/POLICIES.md`](https://github.com/sebastienrousseau/noyalib/blob/main/doc/POLICIES.md#1-msrv-minimum-supported-rust-version).
|
|
302
|
+
|
|
303
|
+
**Tier-1 WASM targets** (CI-verified each PR via
|
|
304
|
+
`wasm-pack test --node`): `wasm32-unknown-unknown` produced
|
|
305
|
+
under every `wasm-pack` mode — `bundler` (Webpack, Rollup,
|
|
306
|
+
esbuild, Vite), `web` (native ES module), `nodejs` (CJS),
|
|
307
|
+
`deno`, `no-modules`. Cloudflare Workers, Deno, and Bun
|
|
308
|
+
consume the `bundler` target.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Documentation
|
|
313
|
+
|
|
314
|
+
- **Engineering policies** (MSRV, SemVer, security, performance, concurrency, platform support, feature flags):
|
|
315
|
+
[`doc/POLICIES.md`](https://github.com/sebastienrousseau/noyalib/blob/main/doc/POLICIES.md)
|
|
316
|
+
- **Security policy**:
|
|
317
|
+
[`SECURITY.md`](https://github.com/sebastienrousseau/noyalib/blob/main/SECURITY.md)
|
|
318
|
+
- **JS API reference**:
|
|
319
|
+
[`doc/js-api.md`](https://github.com/sebastienrousseau/noyalib/blob/main/crates/noyalib-wasm/doc/js-api.md)
|
|
320
|
+
- **Bundling (Vite, Webpack, Next.js, Cloudflare Workers, Deno, Bun)**:
|
|
321
|
+
[`doc/bundling.md`](https://github.com/sebastienrousseau/noyalib/blob/main/crates/noyalib-wasm/doc/bundling.md)
|
|
322
|
+
- **npm package**:
|
|
323
|
+
<https://www.npmjs.com/package/@noyalib/noyalib-wasm>
|
|
324
|
+
- **API reference (rustdoc)**: <https://docs.rs/noyalib-wasm>
|
|
325
|
+
- **Workspace README**:
|
|
326
|
+
<https://github.com/sebastienrousseau/noyalib#readme>
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## License
|
|
331
|
+
|
|
332
|
+
Dual-licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
333
|
+
or [MIT](https://opensource.org/licenses/MIT), at your option.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A YAML document with byte-faithful source preservation and path-targeted edits.
|
|
6
|
+
*/
|
|
7
|
+
export class WasmDocument {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Read the YAML comments associated with the node at `path`.
|
|
12
|
+
* Returns `{ before: string[], inline: string | null }` so the
|
|
13
|
+
* caller can surface human-authored doc-comments alongside
|
|
14
|
+
* values — the demo that motivates the entire CST architecture.
|
|
15
|
+
*
|
|
16
|
+
* Bound on the JS side as `commentsAt(path)` per JS naming
|
|
17
|
+
* conventions.
|
|
18
|
+
*/
|
|
19
|
+
commentsAt(path: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Get the parsed value at a dotted path.
|
|
22
|
+
*/
|
|
23
|
+
get(path: string): any;
|
|
24
|
+
/**
|
|
25
|
+
* Get the raw source fragment at a dotted path.
|
|
26
|
+
*
|
|
27
|
+
* Bound on the JS side as `getSource(path)` per JS naming
|
|
28
|
+
* conventions.
|
|
29
|
+
*/
|
|
30
|
+
getSource(path: string): any;
|
|
31
|
+
/**
|
|
32
|
+
* Parse a YAML string into a lossless Document.
|
|
33
|
+
*/
|
|
34
|
+
constructor(yaml: string);
|
|
35
|
+
/**
|
|
36
|
+
* Replace the bytes at `start..end` with `replacement`.
|
|
37
|
+
*
|
|
38
|
+
* Bound on the JS side as `replaceSpan(start, end, replacement)`
|
|
39
|
+
* per JS naming conventions.
|
|
40
|
+
*/
|
|
41
|
+
replaceSpan(start: number, end: number, replacement: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Set a value at a dotted path using a YAML fragment string.
|
|
44
|
+
*/
|
|
45
|
+
set(path: string, fragment: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Set a value at a dotted path using a JS object.
|
|
48
|
+
*
|
|
49
|
+
* Bound on the JS side as `setValue(path, value)` per JS naming
|
|
50
|
+
* conventions.
|
|
51
|
+
*/
|
|
52
|
+
setValue(path: string, value: any): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get the byte range `{ start, end }` for the value at a dotted path.
|
|
55
|
+
*
|
|
56
|
+
* Bound on the JS side as `spanAt(path)` per JS naming
|
|
57
|
+
* conventions.
|
|
58
|
+
*/
|
|
59
|
+
spanAt(path: string): any;
|
|
60
|
+
/**
|
|
61
|
+
* Re-emit the document as a string. Byte-identical to original if no edits.
|
|
62
|
+
*
|
|
63
|
+
* Bound on the JS side as `toString()` (the conventional camelCase
|
|
64
|
+
* name) so callers can write `doc.toString()` and override the
|
|
65
|
+
* default `Object.prototype.toString` rather than coexist with it.
|
|
66
|
+
*/
|
|
67
|
+
toString(): string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get a value at a dotted path from a YAML string. Bound on the
|
|
72
|
+
* JS side as `getPath(yaml, path)` per JS naming conventions.
|
|
73
|
+
*/
|
|
74
|
+
export function getPath(yaml: string, path: string): any;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Merge two YAML documents.
|
|
78
|
+
*/
|
|
79
|
+
export function merge(base_yaml: string, override_yaml: string): string;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Parse a YAML string and return a JS object.
|
|
83
|
+
*/
|
|
84
|
+
export function parse(yaml: string): any;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Serialize a JS object to a YAML string.
|
|
88
|
+
*/
|
|
89
|
+
export function stringify(value: any): string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Validate YAML against the JSON-compatible schema. Bound on the
|
|
93
|
+
* JS side as `validateJson(yaml)` per JS naming conventions.
|
|
94
|
+
*/
|
|
95
|
+
export function validateJson(yaml: string): boolean;
|
package/noyalib_wasm.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./noyalib_wasm.d.ts" */
|
|
2
|
+
import * as wasm from "./noyalib_wasm_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./noyalib_wasm_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
WasmDocument, getPath, merge, parse, stringify, validateJson
|
|
9
|
+
} from "./noyalib_wasm_bg.js";
|
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A YAML document with byte-faithful source preservation and path-targeted edits.
|
|
3
|
+
*/
|
|
4
|
+
export class WasmDocument {
|
|
5
|
+
__destroy_into_raw() {
|
|
6
|
+
const ptr = this.__wbg_ptr;
|
|
7
|
+
this.__wbg_ptr = 0;
|
|
8
|
+
WasmDocumentFinalization.unregister(this);
|
|
9
|
+
return ptr;
|
|
10
|
+
}
|
|
11
|
+
free() {
|
|
12
|
+
const ptr = this.__destroy_into_raw();
|
|
13
|
+
wasm.__wbg_wasmdocument_free(ptr, 0);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Read the YAML comments associated with the node at `path`.
|
|
17
|
+
* Returns `{ before: string[], inline: string | null }` so the
|
|
18
|
+
* caller can surface human-authored doc-comments alongside
|
|
19
|
+
* values — the demo that motivates the entire CST architecture.
|
|
20
|
+
*
|
|
21
|
+
* Bound on the JS side as `commentsAt(path)` per JS naming
|
|
22
|
+
* conventions.
|
|
23
|
+
* @param {string} path
|
|
24
|
+
* @returns {any}
|
|
25
|
+
*/
|
|
26
|
+
commentsAt(path) {
|
|
27
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29
|
+
const ret = wasm.wasmdocument_commentsAt(this.__wbg_ptr, ptr0, len0);
|
|
30
|
+
if (ret[2]) {
|
|
31
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
32
|
+
}
|
|
33
|
+
return takeFromExternrefTable0(ret[0]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the parsed value at a dotted path.
|
|
37
|
+
* @param {string} path
|
|
38
|
+
* @returns {any}
|
|
39
|
+
*/
|
|
40
|
+
get(path) {
|
|
41
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
42
|
+
const len0 = WASM_VECTOR_LEN;
|
|
43
|
+
const ret = wasm.wasmdocument_get(this.__wbg_ptr, ptr0, len0);
|
|
44
|
+
if (ret[2]) {
|
|
45
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
46
|
+
}
|
|
47
|
+
return takeFromExternrefTable0(ret[0]);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the raw source fragment at a dotted path.
|
|
51
|
+
*
|
|
52
|
+
* Bound on the JS side as `getSource(path)` per JS naming
|
|
53
|
+
* conventions.
|
|
54
|
+
* @param {string} path
|
|
55
|
+
* @returns {any}
|
|
56
|
+
*/
|
|
57
|
+
getSource(path) {
|
|
58
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
const ret = wasm.wasmdocument_getSource(this.__wbg_ptr, ptr0, len0);
|
|
61
|
+
return ret;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse a YAML string into a lossless Document.
|
|
65
|
+
* @param {string} yaml
|
|
66
|
+
*/
|
|
67
|
+
constructor(yaml) {
|
|
68
|
+
const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
69
|
+
const len0 = WASM_VECTOR_LEN;
|
|
70
|
+
const ret = wasm.wasmdocument_new(ptr0, len0);
|
|
71
|
+
if (ret[2]) {
|
|
72
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
73
|
+
}
|
|
74
|
+
this.__wbg_ptr = ret[0];
|
|
75
|
+
WasmDocumentFinalization.register(this, this.__wbg_ptr, this);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Replace the bytes at `start..end` with `replacement`.
|
|
80
|
+
*
|
|
81
|
+
* Bound on the JS side as `replaceSpan(start, end, replacement)`
|
|
82
|
+
* per JS naming conventions.
|
|
83
|
+
* @param {number} start
|
|
84
|
+
* @param {number} end
|
|
85
|
+
* @param {string} replacement
|
|
86
|
+
*/
|
|
87
|
+
replaceSpan(start, end, replacement) {
|
|
88
|
+
const ptr0 = passStringToWasm0(replacement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
89
|
+
const len0 = WASM_VECTOR_LEN;
|
|
90
|
+
const ret = wasm.wasmdocument_replaceSpan(this.__wbg_ptr, start, end, ptr0, len0);
|
|
91
|
+
if (ret[1]) {
|
|
92
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Set a value at a dotted path using a YAML fragment string.
|
|
97
|
+
* @param {string} path
|
|
98
|
+
* @param {string} fragment
|
|
99
|
+
*/
|
|
100
|
+
set(path, fragment) {
|
|
101
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
const ptr1 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
104
|
+
const len1 = WASM_VECTOR_LEN;
|
|
105
|
+
const ret = wasm.wasmdocument_set(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
106
|
+
if (ret[1]) {
|
|
107
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Set a value at a dotted path using a JS object.
|
|
112
|
+
*
|
|
113
|
+
* Bound on the JS side as `setValue(path, value)` per JS naming
|
|
114
|
+
* conventions.
|
|
115
|
+
* @param {string} path
|
|
116
|
+
* @param {any} value
|
|
117
|
+
*/
|
|
118
|
+
setValue(path, value) {
|
|
119
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
120
|
+
const len0 = WASM_VECTOR_LEN;
|
|
121
|
+
const ret = wasm.wasmdocument_setValue(this.__wbg_ptr, ptr0, len0, value);
|
|
122
|
+
if (ret[1]) {
|
|
123
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get the byte range `{ start, end }` for the value at a dotted path.
|
|
128
|
+
*
|
|
129
|
+
* Bound on the JS side as `spanAt(path)` per JS naming
|
|
130
|
+
* conventions.
|
|
131
|
+
* @param {string} path
|
|
132
|
+
* @returns {any}
|
|
133
|
+
*/
|
|
134
|
+
spanAt(path) {
|
|
135
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
136
|
+
const len0 = WASM_VECTOR_LEN;
|
|
137
|
+
const ret = wasm.wasmdocument_spanAt(this.__wbg_ptr, ptr0, len0);
|
|
138
|
+
if (ret[2]) {
|
|
139
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
140
|
+
}
|
|
141
|
+
return takeFromExternrefTable0(ret[0]);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Re-emit the document as a string. Byte-identical to original if no edits.
|
|
145
|
+
*
|
|
146
|
+
* Bound on the JS side as `toString()` (the conventional camelCase
|
|
147
|
+
* name) so callers can write `doc.toString()` and override the
|
|
148
|
+
* default `Object.prototype.toString` rather than coexist with it.
|
|
149
|
+
* @returns {string}
|
|
150
|
+
*/
|
|
151
|
+
toString() {
|
|
152
|
+
let deferred1_0;
|
|
153
|
+
let deferred1_1;
|
|
154
|
+
try {
|
|
155
|
+
const ret = wasm.wasmdocument_toString(this.__wbg_ptr);
|
|
156
|
+
deferred1_0 = ret[0];
|
|
157
|
+
deferred1_1 = ret[1];
|
|
158
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
159
|
+
} finally {
|
|
160
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get a value at a dotted path from a YAML string. Bound on the
|
|
168
|
+
* JS side as `getPath(yaml, path)` per JS naming conventions.
|
|
169
|
+
* @param {string} yaml
|
|
170
|
+
* @param {string} path
|
|
171
|
+
* @returns {any}
|
|
172
|
+
*/
|
|
173
|
+
export function getPath(yaml, path) {
|
|
174
|
+
const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
175
|
+
const len0 = WASM_VECTOR_LEN;
|
|
176
|
+
const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
177
|
+
const len1 = WASM_VECTOR_LEN;
|
|
178
|
+
const ret = wasm.getPath(ptr0, len0, ptr1, len1);
|
|
179
|
+
if (ret[2]) {
|
|
180
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
181
|
+
}
|
|
182
|
+
return takeFromExternrefTable0(ret[0]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Merge two YAML documents.
|
|
187
|
+
* @param {string} base_yaml
|
|
188
|
+
* @param {string} override_yaml
|
|
189
|
+
* @returns {string}
|
|
190
|
+
*/
|
|
191
|
+
export function merge(base_yaml, override_yaml) {
|
|
192
|
+
let deferred4_0;
|
|
193
|
+
let deferred4_1;
|
|
194
|
+
try {
|
|
195
|
+
const ptr0 = passStringToWasm0(base_yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
196
|
+
const len0 = WASM_VECTOR_LEN;
|
|
197
|
+
const ptr1 = passStringToWasm0(override_yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
198
|
+
const len1 = WASM_VECTOR_LEN;
|
|
199
|
+
const ret = wasm.merge(ptr0, len0, ptr1, len1);
|
|
200
|
+
var ptr3 = ret[0];
|
|
201
|
+
var len3 = ret[1];
|
|
202
|
+
if (ret[3]) {
|
|
203
|
+
ptr3 = 0; len3 = 0;
|
|
204
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
205
|
+
}
|
|
206
|
+
deferred4_0 = ptr3;
|
|
207
|
+
deferred4_1 = len3;
|
|
208
|
+
return getStringFromWasm0(ptr3, len3);
|
|
209
|
+
} finally {
|
|
210
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Parse a YAML string and return a JS object.
|
|
216
|
+
* @param {string} yaml
|
|
217
|
+
* @returns {any}
|
|
218
|
+
*/
|
|
219
|
+
export function parse(yaml) {
|
|
220
|
+
const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
221
|
+
const len0 = WASM_VECTOR_LEN;
|
|
222
|
+
const ret = wasm.parse(ptr0, len0);
|
|
223
|
+
if (ret[2]) {
|
|
224
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
225
|
+
}
|
|
226
|
+
return takeFromExternrefTable0(ret[0]);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Serialize a JS object to a YAML string.
|
|
231
|
+
* @param {any} value
|
|
232
|
+
* @returns {string}
|
|
233
|
+
*/
|
|
234
|
+
export function stringify(value) {
|
|
235
|
+
let deferred2_0;
|
|
236
|
+
let deferred2_1;
|
|
237
|
+
try {
|
|
238
|
+
const ret = wasm.stringify(value);
|
|
239
|
+
var ptr1 = ret[0];
|
|
240
|
+
var len1 = ret[1];
|
|
241
|
+
if (ret[3]) {
|
|
242
|
+
ptr1 = 0; len1 = 0;
|
|
243
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
244
|
+
}
|
|
245
|
+
deferred2_0 = ptr1;
|
|
246
|
+
deferred2_1 = len1;
|
|
247
|
+
return getStringFromWasm0(ptr1, len1);
|
|
248
|
+
} finally {
|
|
249
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Validate YAML against the JSON-compatible schema. Bound on the
|
|
255
|
+
* JS side as `validateJson(yaml)` per JS naming conventions.
|
|
256
|
+
* @param {string} yaml
|
|
257
|
+
* @returns {boolean}
|
|
258
|
+
*/
|
|
259
|
+
export function validateJson(yaml) {
|
|
260
|
+
const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
261
|
+
const len0 = WASM_VECTOR_LEN;
|
|
262
|
+
const ret = wasm.validateJson(ptr0, len0);
|
|
263
|
+
if (ret[2]) {
|
|
264
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
265
|
+
}
|
|
266
|
+
return ret[0] !== 0;
|
|
267
|
+
}
|
|
268
|
+
export function __wbg_Error_92b29b0548f8b746(arg0, arg1) {
|
|
269
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
270
|
+
return ret;
|
|
271
|
+
}
|
|
272
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
273
|
+
const ret = String(arg1);
|
|
274
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
275
|
+
const len1 = WASM_VECTOR_LEN;
|
|
276
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
277
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
278
|
+
}
|
|
279
|
+
export function __wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f(arg0, arg1) {
|
|
280
|
+
const v = arg1;
|
|
281
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
282
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
283
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
284
|
+
}
|
|
285
|
+
export function __wbg___wbindgen_boolean_get_fa956cfa2d1bd751(arg0) {
|
|
286
|
+
const v = arg0;
|
|
287
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
288
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
289
|
+
}
|
|
290
|
+
export function __wbg___wbindgen_debug_string_c25d447a39f5578f(arg0, arg1) {
|
|
291
|
+
const ret = debugString(arg1);
|
|
292
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
293
|
+
const len1 = WASM_VECTOR_LEN;
|
|
294
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
295
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
296
|
+
}
|
|
297
|
+
export function __wbg___wbindgen_in_aca499c5de7ff5e5(arg0, arg1) {
|
|
298
|
+
const ret = arg0 in arg1;
|
|
299
|
+
return ret;
|
|
300
|
+
}
|
|
301
|
+
export function __wbg___wbindgen_is_bigint_2f76dc55065b4273(arg0) {
|
|
302
|
+
const ret = typeof(arg0) === 'bigint';
|
|
303
|
+
return ret;
|
|
304
|
+
}
|
|
305
|
+
export function __wbg___wbindgen_is_function_1ff95bcc5517c252(arg0) {
|
|
306
|
+
const ret = typeof(arg0) === 'function';
|
|
307
|
+
return ret;
|
|
308
|
+
}
|
|
309
|
+
export function __wbg___wbindgen_is_object_a27215656b807791(arg0) {
|
|
310
|
+
const val = arg0;
|
|
311
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
312
|
+
return ret;
|
|
313
|
+
}
|
|
314
|
+
export function __wbg___wbindgen_is_string_ea5e6cc2e4141dfe(arg0) {
|
|
315
|
+
const ret = typeof(arg0) === 'string';
|
|
316
|
+
return ret;
|
|
317
|
+
}
|
|
318
|
+
export function __wbg___wbindgen_jsval_eq_e659fcf7b0e32763(arg0, arg1) {
|
|
319
|
+
const ret = arg0 === arg1;
|
|
320
|
+
return ret;
|
|
321
|
+
}
|
|
322
|
+
export function __wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170(arg0, arg1) {
|
|
323
|
+
const ret = arg0 == arg1;
|
|
324
|
+
return ret;
|
|
325
|
+
}
|
|
326
|
+
export function __wbg___wbindgen_number_get_394265ed1e1b84ee(arg0, arg1) {
|
|
327
|
+
const obj = arg1;
|
|
328
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
329
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
330
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
331
|
+
}
|
|
332
|
+
export function __wbg___wbindgen_string_get_b0ca35b86a603356(arg0, arg1) {
|
|
333
|
+
const obj = arg1;
|
|
334
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
335
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
336
|
+
var len1 = WASM_VECTOR_LEN;
|
|
337
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
338
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
339
|
+
}
|
|
340
|
+
export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
|
|
341
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
342
|
+
}
|
|
343
|
+
export function __wbg_call_8a2dd23819f8a60a() { return handleError(function (arg0, arg1) {
|
|
344
|
+
const ret = arg0.call(arg1);
|
|
345
|
+
return ret;
|
|
346
|
+
}, arguments); }
|
|
347
|
+
export function __wbg_done_89b2b13e91a60321(arg0) {
|
|
348
|
+
const ret = arg0.done;
|
|
349
|
+
return ret;
|
|
350
|
+
}
|
|
351
|
+
export function __wbg_entries_015dc610cd81ede0(arg0) {
|
|
352
|
+
const ret = Object.entries(arg0);
|
|
353
|
+
return ret;
|
|
354
|
+
}
|
|
355
|
+
export function __wbg_get_507a50627bffa49b(arg0, arg1) {
|
|
356
|
+
const ret = arg0[arg1 >>> 0];
|
|
357
|
+
return ret;
|
|
358
|
+
}
|
|
359
|
+
export function __wbg_get_c7eb1f358a7654df() { return handleError(function (arg0, arg1) {
|
|
360
|
+
const ret = Reflect.get(arg0, arg1);
|
|
361
|
+
return ret;
|
|
362
|
+
}, arguments); }
|
|
363
|
+
export function __wbg_get_unchecked_6e0ad6d2a41b06f6(arg0, arg1) {
|
|
364
|
+
const ret = arg0[arg1 >>> 0];
|
|
365
|
+
return ret;
|
|
366
|
+
}
|
|
367
|
+
export function __wbg_instanceof_ArrayBuffer_4480b9e0068a8adb(arg0) {
|
|
368
|
+
let result;
|
|
369
|
+
try {
|
|
370
|
+
result = arg0 instanceof ArrayBuffer;
|
|
371
|
+
} catch (_) {
|
|
372
|
+
result = false;
|
|
373
|
+
}
|
|
374
|
+
const ret = result;
|
|
375
|
+
return ret;
|
|
376
|
+
}
|
|
377
|
+
export function __wbg_instanceof_Map_e5b5e3db98422fcc(arg0) {
|
|
378
|
+
let result;
|
|
379
|
+
try {
|
|
380
|
+
result = arg0 instanceof Map;
|
|
381
|
+
} catch (_) {
|
|
382
|
+
result = false;
|
|
383
|
+
}
|
|
384
|
+
const ret = result;
|
|
385
|
+
return ret;
|
|
386
|
+
}
|
|
387
|
+
export function __wbg_instanceof_Uint8Array_309b927aaf7a3fc7(arg0) {
|
|
388
|
+
let result;
|
|
389
|
+
try {
|
|
390
|
+
result = arg0 instanceof Uint8Array;
|
|
391
|
+
} catch (_) {
|
|
392
|
+
result = false;
|
|
393
|
+
}
|
|
394
|
+
const ret = result;
|
|
395
|
+
return ret;
|
|
396
|
+
}
|
|
397
|
+
export function __wbg_isArray_0677c962b281d01a(arg0) {
|
|
398
|
+
const ret = Array.isArray(arg0);
|
|
399
|
+
return ret;
|
|
400
|
+
}
|
|
401
|
+
export function __wbg_isSafeInteger_04f36e4056f1b851(arg0) {
|
|
402
|
+
const ret = Number.isSafeInteger(arg0);
|
|
403
|
+
return ret;
|
|
404
|
+
}
|
|
405
|
+
export function __wbg_iterator_6f722e4a93058b71() {
|
|
406
|
+
const ret = Symbol.iterator;
|
|
407
|
+
return ret;
|
|
408
|
+
}
|
|
409
|
+
export function __wbg_length_1f0964f4a5e2c6d8(arg0) {
|
|
410
|
+
const ret = arg0.length;
|
|
411
|
+
return ret;
|
|
412
|
+
}
|
|
413
|
+
export function __wbg_length_370319915dc99107(arg0) {
|
|
414
|
+
const ret = arg0.length;
|
|
415
|
+
return ret;
|
|
416
|
+
}
|
|
417
|
+
export function __wbg_new_32b398fb48b6d94a() {
|
|
418
|
+
const ret = new Array();
|
|
419
|
+
return ret;
|
|
420
|
+
}
|
|
421
|
+
export function __wbg_new_7796ffc7ed656783() {
|
|
422
|
+
const ret = new Map();
|
|
423
|
+
return ret;
|
|
424
|
+
}
|
|
425
|
+
export function __wbg_new_cd45aabdf6073e84(arg0) {
|
|
426
|
+
const ret = new Uint8Array(arg0);
|
|
427
|
+
return ret;
|
|
428
|
+
}
|
|
429
|
+
export function __wbg_new_da52cf8fe3429cb2() {
|
|
430
|
+
const ret = new Object();
|
|
431
|
+
return ret;
|
|
432
|
+
}
|
|
433
|
+
export function __wbg_next_6dbf2c0ac8cde20f(arg0) {
|
|
434
|
+
const ret = arg0.next;
|
|
435
|
+
return ret;
|
|
436
|
+
}
|
|
437
|
+
export function __wbg_next_71f2aa1cb3d1e37e() { return handleError(function (arg0) {
|
|
438
|
+
const ret = arg0.next();
|
|
439
|
+
return ret;
|
|
440
|
+
}, arguments); }
|
|
441
|
+
export function __wbg_prototypesetcall_4770620bbe4688a0(arg0, arg1, arg2) {
|
|
442
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
443
|
+
}
|
|
444
|
+
export function __wbg_set_575dd786d51585f8(arg0, arg1, arg2) {
|
|
445
|
+
const ret = arg0.set(arg1, arg2);
|
|
446
|
+
return ret;
|
|
447
|
+
}
|
|
448
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
449
|
+
arg0[arg1] = arg2;
|
|
450
|
+
}
|
|
451
|
+
export function __wbg_set_8a16b38e4805b298(arg0, arg1, arg2) {
|
|
452
|
+
arg0[arg1 >>> 0] = arg2;
|
|
453
|
+
}
|
|
454
|
+
export function __wbg_value_a5d5488a9589444a(arg0) {
|
|
455
|
+
const ret = arg0.value;
|
|
456
|
+
return ret;
|
|
457
|
+
}
|
|
458
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
459
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
460
|
+
const ret = arg0;
|
|
461
|
+
return ret;
|
|
462
|
+
}
|
|
463
|
+
export function __wbindgen_cast_0000000000000002(arg0) {
|
|
464
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
465
|
+
const ret = arg0;
|
|
466
|
+
return ret;
|
|
467
|
+
}
|
|
468
|
+
export function __wbindgen_cast_0000000000000003(arg0, arg1) {
|
|
469
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
470
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
471
|
+
return ret;
|
|
472
|
+
}
|
|
473
|
+
export function __wbindgen_cast_0000000000000004(arg0) {
|
|
474
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
475
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
476
|
+
return ret;
|
|
477
|
+
}
|
|
478
|
+
export function __wbindgen_init_externref_table() {
|
|
479
|
+
const table = wasm.__wbindgen_externrefs;
|
|
480
|
+
const offset = table.grow(4);
|
|
481
|
+
table.set(0, undefined);
|
|
482
|
+
table.set(offset + 0, undefined);
|
|
483
|
+
table.set(offset + 1, null);
|
|
484
|
+
table.set(offset + 2, true);
|
|
485
|
+
table.set(offset + 3, false);
|
|
486
|
+
}
|
|
487
|
+
const WasmDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
488
|
+
? { register: () => {}, unregister: () => {} }
|
|
489
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdocument_free(ptr, 1));
|
|
490
|
+
|
|
491
|
+
function addToExternrefTable0(obj) {
|
|
492
|
+
const idx = wasm.__externref_table_alloc();
|
|
493
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
494
|
+
return idx;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function debugString(val) {
|
|
498
|
+
// primitive types
|
|
499
|
+
const type = typeof val;
|
|
500
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
501
|
+
return `${val}`;
|
|
502
|
+
}
|
|
503
|
+
if (type == 'string') {
|
|
504
|
+
return `"${val}"`;
|
|
505
|
+
}
|
|
506
|
+
if (type == 'symbol') {
|
|
507
|
+
const description = val.description;
|
|
508
|
+
if (description == null) {
|
|
509
|
+
return 'Symbol';
|
|
510
|
+
} else {
|
|
511
|
+
return `Symbol(${description})`;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
if (type == 'function') {
|
|
515
|
+
const name = val.name;
|
|
516
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
517
|
+
return `Function(${name})`;
|
|
518
|
+
} else {
|
|
519
|
+
return 'Function';
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
// objects
|
|
523
|
+
if (Array.isArray(val)) {
|
|
524
|
+
const length = val.length;
|
|
525
|
+
let debug = '[';
|
|
526
|
+
if (length > 0) {
|
|
527
|
+
debug += debugString(val[0]);
|
|
528
|
+
}
|
|
529
|
+
for(let i = 1; i < length; i++) {
|
|
530
|
+
debug += ', ' + debugString(val[i]);
|
|
531
|
+
}
|
|
532
|
+
debug += ']';
|
|
533
|
+
return debug;
|
|
534
|
+
}
|
|
535
|
+
// Test for built-in
|
|
536
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
537
|
+
let className;
|
|
538
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
539
|
+
className = builtInMatches[1];
|
|
540
|
+
} else {
|
|
541
|
+
// Failed to match the standard '[object ClassName]'
|
|
542
|
+
return toString.call(val);
|
|
543
|
+
}
|
|
544
|
+
if (className == 'Object') {
|
|
545
|
+
// we're a user defined class or Object
|
|
546
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
547
|
+
// easier than looping through ownProperties of `val`.
|
|
548
|
+
try {
|
|
549
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
550
|
+
} catch (_) {
|
|
551
|
+
return 'Object';
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
// errors
|
|
555
|
+
if (val instanceof Error) {
|
|
556
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
557
|
+
}
|
|
558
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
559
|
+
return className;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
563
|
+
ptr = ptr >>> 0;
|
|
564
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
let cachedDataViewMemory0 = null;
|
|
568
|
+
function getDataViewMemory0() {
|
|
569
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
570
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
571
|
+
}
|
|
572
|
+
return cachedDataViewMemory0;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function getStringFromWasm0(ptr, len) {
|
|
576
|
+
return decodeText(ptr >>> 0, len);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
let cachedUint8ArrayMemory0 = null;
|
|
580
|
+
function getUint8ArrayMemory0() {
|
|
581
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
582
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
583
|
+
}
|
|
584
|
+
return cachedUint8ArrayMemory0;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function handleError(f, args) {
|
|
588
|
+
try {
|
|
589
|
+
return f.apply(this, args);
|
|
590
|
+
} catch (e) {
|
|
591
|
+
const idx = addToExternrefTable0(e);
|
|
592
|
+
wasm.__wbindgen_exn_store(idx);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function isLikeNone(x) {
|
|
597
|
+
return x === undefined || x === null;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
601
|
+
if (realloc === undefined) {
|
|
602
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
603
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
604
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
605
|
+
WASM_VECTOR_LEN = buf.length;
|
|
606
|
+
return ptr;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
let len = arg.length;
|
|
610
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
611
|
+
|
|
612
|
+
const mem = getUint8ArrayMemory0();
|
|
613
|
+
|
|
614
|
+
let offset = 0;
|
|
615
|
+
|
|
616
|
+
for (; offset < len; offset++) {
|
|
617
|
+
const code = arg.charCodeAt(offset);
|
|
618
|
+
if (code > 0x7F) break;
|
|
619
|
+
mem[ptr + offset] = code;
|
|
620
|
+
}
|
|
621
|
+
if (offset !== len) {
|
|
622
|
+
if (offset !== 0) {
|
|
623
|
+
arg = arg.slice(offset);
|
|
624
|
+
}
|
|
625
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
626
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
627
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
628
|
+
|
|
629
|
+
offset += ret.written;
|
|
630
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
WASM_VECTOR_LEN = offset;
|
|
634
|
+
return ptr;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function takeFromExternrefTable0(idx) {
|
|
638
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
639
|
+
wasm.__externref_table_dealloc(idx);
|
|
640
|
+
return value;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
644
|
+
cachedTextDecoder.decode();
|
|
645
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
646
|
+
let numBytesDecoded = 0;
|
|
647
|
+
function decodeText(ptr, len) {
|
|
648
|
+
numBytesDecoded += len;
|
|
649
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
650
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
651
|
+
cachedTextDecoder.decode();
|
|
652
|
+
numBytesDecoded = len;
|
|
653
|
+
}
|
|
654
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const cachedTextEncoder = new TextEncoder();
|
|
658
|
+
|
|
659
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
660
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
661
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
662
|
+
view.set(buf);
|
|
663
|
+
return {
|
|
664
|
+
read: arg.length,
|
|
665
|
+
written: buf.length
|
|
666
|
+
};
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
let WASM_VECTOR_LEN = 0;
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
let wasm;
|
|
674
|
+
export function __wbg_set_wasm(val) {
|
|
675
|
+
wasm = val;
|
|
676
|
+
}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sebastienrousseau/noyalib-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Sebastien Rousseau <sebastian.rousseau@gmail.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "WebAssembly (wasm-bindgen) bindings for the noyalib YAML library — browser-ready parse / serialise / lossless edit",
|
|
8
|
+
"version": "0.0.12",
|
|
9
|
+
"license": "MIT OR Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/sebastienrousseau/noyalib-wasm"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"noyalib_wasm_bg.wasm",
|
|
16
|
+
"noyalib_wasm.js",
|
|
17
|
+
"noyalib_wasm_bg.js",
|
|
18
|
+
"noyalib_wasm.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"main": "noyalib_wasm.js",
|
|
21
|
+
"homepage": "https://github.com/sebastienrousseau/noyalib-wasm",
|
|
22
|
+
"types": "noyalib_wasm.d.ts",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"./noyalib_wasm.js",
|
|
25
|
+
"./snippets/*"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"yaml",
|
|
29
|
+
"wasm",
|
|
30
|
+
"wasm-bindgen",
|
|
31
|
+
"browser",
|
|
32
|
+
"noyalib"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|