@markup-carve/carve-wasm 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,6 +48,20 @@ const html = toHtml('# Hello, Carve!')
48
48
  document.body.innerHTML = html
49
49
  ```
50
50
 
51
+ ### Source-preserving patches
52
+
53
+ Tools can prepare canonical formatting as stale-safe UTF-8 byte edits:
54
+
55
+ ```js
56
+ const patch = toCarvePatch(source)
57
+ const formatted = applySourcePatch(source, patch)
58
+ ```
59
+
60
+ `createSourcePatch(source, replacement, kind, code)` prepares the same wire
61
+ shape for another complete replacement. Its ranges are UTF-8 byte offsets. The
62
+ fingerprint and byte length catch accidental staleness; they are not a
63
+ cryptographic signature. Treat a patch as trusted edit instructions.
64
+
51
65
  ### Extensions
52
66
 
53
67
  `extensions()` reports every extension this build accepts. The list comes from
@@ -267,6 +281,9 @@ const html: string = toHtml('_Hello_')
267
281
  | `needsReview` | `(source: string, currentVersion: string) => boolean` | Whether the stamp predates `currentVersion`; unstamped counts as yes |
268
282
  | `fromDjot` | `(source: string) => string` | Convert Djot source to Carve |
269
283
  | `fromBbcode` | `(source: string) => string` | Convert BBCode source to Carve; throws past the engine's size cap |
284
+ | `createSourcePatch` | `(source, replacement, kind, code) => SourcePatch` | Build a minimal UTF-8 byte-range patch |
285
+ | `toCarvePatch` | `(source: string) => SourcePatch` | Preview canonical formatting as a patch |
286
+ | `applySourcePatch` | `(source: string, patch: SourcePatch) => string` | Validate and apply trusted patch instructions |
270
287
  | `version` | `() => string` | Returns the carve-wasm package version |
271
288
 
272
289
  ### The parsed AST
@@ -297,151 +314,14 @@ browser does natively and faster than building the object graph across the wasm
297
314
  boundary one property at a time - and it keeps the bytes available for a caller
298
315
  that stores or forwards them.
299
316
 
300
- ## carve-rs dependency pin
301
-
302
- `Cargo.toml` pins an exact carve-rs commit, and `Cargo.lock` is committed
303
- alongside it:
304
-
305
- ```toml
306
- carve = { package = "carve-lang", git = "https://github.com/markup-carve/carve-rs", rev = "..." }
307
- ```
308
-
309
- Read the current revision out of `Cargo.toml` rather than from a copy here - a
310
- revision quoted in prose goes stale the first time someone bumps the manifest
311
- without noticing the duplicate.
312
-
313
- The engine is published as `carve-lang` (carve-rs renamed it from `carve`), so a
314
- pin at any revision past that rename needs `package = "carve-lang"` as above.
315
-
316
- The crate previously tracked carve-rs' default branch with no committed lock.
317
- That never went stale, but it went the other way: every build resolved whatever
318
- had landed upstream since, so the published package could carry an engine no CI
319
- run here had ever built, and two clones a day apart could disagree. The pin
320
- makes an engine change a reviewable line in a diff.
321
-
322
- When bumping the `rev`, regenerate and commit `Cargo.lock` in the same change.
323
- The lock records the resolved revision plus the rest of the tree; leaving it
324
- behind gives every fresh clone a dirty working tree on its first build and lets
325
- the package resolve to an engine other than the one that was tested.
326
-
327
- ```sh
328
- cargo update -p carve-lang --precise <sha> # or edit the rev and re-lock
329
- cargo test && wasm-pack build --target nodejs && node tests/smoke.mjs
330
- CARVE_SPEC_CORPUS=/path/to/carve/tests/corpus node tests/corpus.mjs
331
- ```
332
-
333
- `scripts/check-engine-floor.py` is what notices a pin left behind. CI runs it
334
- against the revision carve-rb embeds:
335
-
336
- ```sh
337
- python3 scripts/check-engine-floor.py \
338
- --engine <carve-rs checkout> --manifest Cargo.toml --lock Cargo.lock \
339
- --sibling-name carve-rb --sibling-manifest <carve-rb>/ext/carve/Cargo.toml \
340
- --changelog CHANGELOG.md
341
- ```
342
-
343
- It fails when this pin is a strict ancestor of the sibling's, and it also fails
344
- when the `[Unreleased]` changelog section names a revision the build does not
345
- embed - a revision quoted in prose is a second copy of the pin, and the second
346
- copy is the one nothing else reads. A floor rather than a leash: it is
347
- deliberately not a distance check against carve-rs `main`, which merges
348
- continuously and would be red from the moment any pull request opens there.
349
-
350
- That last line is the one that can tell a drifted pin from a current one.
351
- `smoke.mjs` asserts hand-written expectations, which a stale engine satisfies
352
- happily; `corpus.mjs` renders all ~530 mandatory spec documents through the
353
- **built** artifact and requires byte-identical HTML. Without `CARVE_SPEC_CORPUS`
354
- it prints a notice and exits 0, so a checkout without the spec repo still runs
355
- the suite. CI always sets it.
356
-
357
- It measures the binding as much as the engine: carve-rs is corpus-checked
358
- upstream, but that says nothing about whether the wasm-bindgen layer drops a
359
- field or mangles an option on the way through.
360
-
361
- Regenerate the whole lock MSRV-aware, or it will quietly break the `rust-version`
362
- this crate advertises. A plain `cargo generate-lockfile` on a current toolchain
363
- picks the newest `wasm-bindgen`, which needs a newer Rust than the 1.75 declared
364
- above - fine while CI only runs `stable`, and a hard failure for anyone actually
365
- building on the floor:
366
-
367
- ```sh
368
- CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo generate-lockfile
369
- ```
370
-
371
- Nothing in CI catches this today, since the workflow uses `stable` only. Adding
372
- a 1.75 job (carve-rs has one) would turn it from a review question into a build
373
- failure.
374
-
375
- ## Build
376
-
377
- The published package uses the **bundler** target (matching the release
378
- workflow):
379
-
380
- ```bash
381
- cargo test
382
- wasm-pack build --target bundler --scope markup-carve
383
- ```
384
-
385
- `wasm-pack` emits the package into `pkg/`. For a no-bundler / `<script type=module>`
386
- setup use `--target web` (which exports a default `init()` you must `await`
387
- before calling the renderers); for Node use `--target nodejs`.
317
+ ## Development
388
318
 
389
- Point the test suite at any built package with `CARVE_WASM_PKG`, rather than
390
- only at `pkg/`:
391
-
392
- ```sh
393
- CARVE_WASM_PKG=some/other/pkg node tests/smoke.mjs
394
- ```
395
-
396
- Both wasm-pack targets load. Unset, it is `pkg/`, so nothing changes for the
397
- ordinary loop.
398
-
399
- ### Rendering-only browser build
400
-
401
- All capabilities are enabled by default, so ordinary builds and the published
402
- package keep their complete API. A browser host that only renders Carve to HTML
403
- can leave the importers, reports, AST serialization, and other output formats
404
- out of its artifact:
405
-
406
- ```sh
407
- wasm-pack build --target web --release --out-dir pkg-render . --no-default-features
408
- ```
409
-
410
- The basic HTML rendering exports, including `toHtml`, `toHtmlFull`, and
411
- `toHtmlWithOptions`, remain available. Checked rendering through
412
- `toHtmlWithReport` is part of the omitted `reports` capability. The optional
413
- features are:
414
-
415
- | Feature | Exports |
416
- | --- | --- |
417
- | `html-import` | `htmlToCarve`, `fromHtml` |
418
- | `markdown-import` | `fromMarkdown` |
419
- | `reports` | all five `*WithReport` renderers |
420
- | `ast-json` | `parseJson`, `astJsonToHtml`, `astJsonToCarve` |
421
- | `other-renderers` | the basic Markdown, plain-text, ANSI, and Carve renderers |
422
- | `lint` | `lintCarve` |
423
- | `stamp` | `readStamp`, `needsReview` |
424
- | `other-imports` | `fromDjot`, `fromBbcode` |
425
-
426
- Use a separate output directory as above if a full build also exists in the
427
- checkout.
428
-
429
- ## Release
430
-
431
- Publishing is gated. `.github/workflows/release.yml` has two jobs, and
432
- `publish` declares `verify` in `needs:`, so it cannot start while the gate
433
- fails. The gate is `scripts/verify-release-artifact.mjs`, and it is runnable by
434
- hand against a local build:
435
-
436
- ```sh
437
- wasm-pack build --target bundler --scope markup-carve
438
- CARVE_SPEC_CORPUS=/path/to/carve/tests/corpus node scripts/verify-release-artifact.mjs
439
- ```
319
+ The reference material a contributor needs lives in `docs/`, so this page can
320
+ stay about USING the package:
440
321
 
441
- It runs `npm pack` and drives `tests/smoke.mjs` and `tests/corpus.mjs` at the
442
- UNPACKED tarball, not at `pkg/`. The difference matters: npm uploads what the
443
- generated `files` list names, so a payload file left out of it would never
444
- reach the registry and would never have been tested either. The corpus
445
- population comes from the spec's example pages, so a truncated corpus fails
446
- here instead of passing over a subset, and an unset `CARVE_SPEC_CORPUS` is
447
- refused rather than skipped.
322
+ - [Building](docs/building.md) - the wasm-pack targets, pointing the tests at a
323
+ built package, and the rendering-only browser profile.
324
+ - [The carve-rs pin](docs/engine-pin.md) - why the engine is pinned to an exact
325
+ commit, and how to move it.
326
+ - [Releasing](docs/releasing.md) - the gate, what it refuses, and the runbook
327
+ for cutting a version.
package/carve_wasm.d.ts CHANGED
@@ -22,8 +22,32 @@ export interface Stamp {
22
22
  generatedBy: string | null;
23
23
  }
24
24
 
25
+ export type SourceEditKind = "formatting" | "syntax-migration" | "quick-fix" | "refactor";
26
+ export interface SourceEdit {
27
+ /** Inclusive UTF-8 byte offset. */
28
+ start: number;
29
+ /** Exclusive UTF-8 byte offset. */
30
+ end: number;
31
+ replacement: string;
32
+ kind: SourceEditKind;
33
+ code: string;
34
+ }
35
+ export interface SourceSuggestion extends SourceEdit { message: string; }
36
+ export interface SourcePatch {
37
+ version: 1;
38
+ sourceFingerprint: string;
39
+ sourceBytes: number;
40
+ edits: SourceEdit[];
41
+ unresolved: SourceSuggestion[];
42
+ }
25
43
 
26
44
 
45
+
46
+ /**
47
+ * Apply a trusted patch after its source length and fingerprint still match.
48
+ */
49
+ export function applySourcePatch(source: string, patch: any): string;
50
+
27
51
  /**
28
52
  * Render an AST-JSON document (PART 12) back to canonical Carve source.
29
53
  *
@@ -45,6 +69,11 @@ export function astJsonToCarve(json: string): string;
45
69
  */
46
70
  export function astJsonToHtml(json: string, options?: object | null): string;
47
71
 
72
+ /**
73
+ * Build the smallest single UTF-8 byte-range replacement between two sources.
74
+ */
75
+ export function createSourcePatch(source: string, replacement: string, kind: string, code: string): SourcePatch;
76
+
48
77
  /**
49
78
  * Every extension name this build accepts, in registry order.
50
79
  *
@@ -133,6 +162,11 @@ export function toAnsiWithReport(source: string, strict?: boolean | null, maximu
133
162
 
134
163
  export function toCarve(source: string): string;
135
164
 
165
+ /**
166
+ * Preview canonical formatting as a source-preserving patch.
167
+ */
168
+ export function toCarvePatch(source: string): SourcePatch;
169
+
136
170
  export function toCarveWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
137
171
 
138
172
  export function toHtml(source: string): string;
package/carve_wasm.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./carve_wasm_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- astJsonToCarve, astJsonToHtml, extensions, fromBbcode, fromDjot, fromHtml, fromMarkdown, htmlToCarve, lintCarve, needsReview, parseJson, readStamp, toAnsi, toAnsiWithReport, toCarve, toCarveWithReport, toHtml, toHtmlFull, toHtmlWithOptions, toHtmlWithReport, toHtmlWithSymbols, toMarkdown, toMarkdownWithReport, toPlainText, toPlainTextWithReport, version
8
+ applySourcePatch, astJsonToCarve, astJsonToHtml, createSourcePatch, extensions, fromBbcode, fromDjot, fromHtml, fromMarkdown, htmlToCarve, lintCarve, needsReview, parseJson, readStamp, toAnsi, toAnsiWithReport, toCarve, toCarvePatch, toCarveWithReport, toHtml, toHtmlFull, toHtmlWithOptions, toHtmlWithReport, toHtmlWithSymbols, toMarkdown, toMarkdownWithReport, toPlainText, toPlainTextWithReport, version
9
9
  } from "./carve_wasm_bg.js";
package/carve_wasm_bg.js CHANGED
@@ -1,3 +1,30 @@
1
+ /**
2
+ * Apply a trusted patch after its source length and fingerprint still match.
3
+ * @param {string} source
4
+ * @param {any} patch
5
+ * @returns {string}
6
+ */
7
+ export function applySourcePatch(source, patch) {
8
+ let deferred3_0;
9
+ let deferred3_1;
10
+ try {
11
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
12
+ const len0 = WASM_VECTOR_LEN;
13
+ const ret = wasm.applySourcePatch(ptr0, len0, patch);
14
+ var ptr2 = ret[0];
15
+ var len2 = ret[1];
16
+ if (ret[3]) {
17
+ ptr2 = 0; len2 = 0;
18
+ throw takeFromExternrefTable0(ret[2]);
19
+ }
20
+ deferred3_0 = ptr2;
21
+ deferred3_1 = len2;
22
+ return getStringFromWasm0(ptr2, len2);
23
+ } finally {
24
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
25
+ }
26
+ }
27
+
1
28
  /**
2
29
  * Render an AST-JSON document (PART 12) back to canonical Carve source.
3
30
  *
@@ -62,6 +89,30 @@ export function astJsonToHtml(json, options) {
62
89
  }
63
90
  }
64
91
 
92
+ /**
93
+ * Build the smallest single UTF-8 byte-range replacement between two sources.
94
+ * @param {string} source
95
+ * @param {string} replacement
96
+ * @param {string} kind
97
+ * @param {string} code
98
+ * @returns {SourcePatch}
99
+ */
100
+ export function createSourcePatch(source, replacement, kind, code) {
101
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
102
+ const len0 = WASM_VECTOR_LEN;
103
+ const ptr1 = passStringToWasm0(replacement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len1 = WASM_VECTOR_LEN;
105
+ const ptr2 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
106
+ const len2 = WASM_VECTOR_LEN;
107
+ const ptr3 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
108
+ const len3 = WASM_VECTOR_LEN;
109
+ const ret = wasm.createSourcePatch(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
110
+ if (ret[2]) {
111
+ throw takeFromExternrefTable0(ret[1]);
112
+ }
113
+ return takeFromExternrefTable0(ret[0]);
114
+ }
115
+
65
116
  /**
66
117
  * Every extension name this build accepts, in registry order.
67
118
  *
@@ -325,6 +376,21 @@ export function toCarve(source) {
325
376
  }
326
377
  }
327
378
 
379
+ /**
380
+ * Preview canonical formatting as a source-preserving patch.
381
+ * @param {string} source
382
+ * @returns {SourcePatch}
383
+ */
384
+ export function toCarvePatch(source) {
385
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
386
+ const len0 = WASM_VECTOR_LEN;
387
+ const ret = wasm.toCarvePatch(ptr0, len0);
388
+ if (ret[2]) {
389
+ throw takeFromExternrefTable0(ret[1]);
390
+ }
391
+ return takeFromExternrefTable0(ret[0]);
392
+ }
393
+
328
394
  /**
329
395
  * @param {string} source
330
396
  * @param {boolean | null} [strict]
@@ -632,19 +698,82 @@ export function version() {
632
698
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
633
699
  }
634
700
  }
701
+ export function __wbg_Error_2e59b1b37a9a34c3(arg0, arg1) {
702
+ const ret = Error(getStringFromWasm0(arg0, arg1));
703
+ return ret;
704
+ }
705
+ export function __wbg_Number_e6ffdb596c888833(arg0) {
706
+ const ret = Number(arg0);
707
+ return ret;
708
+ }
709
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
710
+ const ret = String(arg1);
711
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
712
+ const len1 = WASM_VECTOR_LEN;
713
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
714
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
715
+ }
716
+ export function __wbg___wbindgen_bigint_get_as_i64_2c5082002e4826e2(arg0, arg1) {
717
+ const v = arg1;
718
+ const ret = typeof(v) === 'bigint' ? v : undefined;
719
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
720
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
721
+ }
635
722
  export function __wbg___wbindgen_boolean_get_a86c216575a75c30(arg0) {
636
723
  const v = arg0;
637
724
  const ret = typeof(v) === 'boolean' ? v : undefined;
638
725
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
639
726
  }
727
+ export function __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57(arg0, arg1) {
728
+ const ret = debugString(arg1);
729
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
730
+ const len1 = WASM_VECTOR_LEN;
731
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
732
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
733
+ }
734
+ export function __wbg___wbindgen_in_4bd7a57e54337366(arg0, arg1) {
735
+ const ret = arg0 in arg1;
736
+ return ret;
737
+ }
738
+ export function __wbg___wbindgen_is_bigint_6c98f7e945dacdde(arg0) {
739
+ const ret = typeof(arg0) === 'bigint';
740
+ return ret;
741
+ }
742
+ export function __wbg___wbindgen_is_function_49868bde5eb1e745(arg0) {
743
+ const ret = typeof(arg0) === 'function';
744
+ return ret;
745
+ }
640
746
  export function __wbg___wbindgen_is_null_344c8750a8525473(arg0) {
641
747
  const ret = arg0 === null;
642
748
  return ret;
643
749
  }
750
+ export function __wbg___wbindgen_is_object_40c5a80572e8f9d3(arg0) {
751
+ const val = arg0;
752
+ const ret = typeof(val) === 'object' && val !== null;
753
+ return ret;
754
+ }
755
+ export function __wbg___wbindgen_is_string_b29b5c5a8065ba1a(arg0) {
756
+ const ret = typeof(arg0) === 'string';
757
+ return ret;
758
+ }
644
759
  export function __wbg___wbindgen_is_undefined_c0cca72b82b86f4d(arg0) {
645
760
  const ret = arg0 === undefined;
646
761
  return ret;
647
762
  }
763
+ export function __wbg___wbindgen_jsval_eq_7d430e744a913d26(arg0, arg1) {
764
+ const ret = arg0 === arg1;
765
+ return ret;
766
+ }
767
+ export function __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944(arg0, arg1) {
768
+ const ret = arg0 == arg1;
769
+ return ret;
770
+ }
771
+ export function __wbg___wbindgen_number_get_7579aab02a8a620c(arg0, arg1) {
772
+ const obj = arg1;
773
+ const ret = typeof(obj) === 'number' ? obj : undefined;
774
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
775
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
776
+ }
648
777
  export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
649
778
  const obj = arg1;
650
779
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -656,6 +785,14 @@ export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
656
785
  export function __wbg___wbindgen_throw_81fc77679af83bc6(arg0, arg1) {
657
786
  throw new Error(getStringFromWasm0(arg0, arg1));
658
787
  }
788
+ export function __wbg_call_7f2987183bb62793() { return handleError(function (arg0, arg1) {
789
+ const ret = arg0.call(arg1);
790
+ return ret;
791
+ }, arguments); }
792
+ export function __wbg_done_547d467e97529006(arg0) {
793
+ const ret = arg0.done;
794
+ return ret;
795
+ }
659
796
  export function __wbg_entries_616b1a459b85be0b(arg0) {
660
797
  const ret = Object.entries(arg0);
661
798
  return ret;
@@ -672,6 +809,10 @@ export function __wbg_get_4848e350b40afc16(arg0, arg1) {
672
809
  const ret = arg0[arg1 >>> 0];
673
810
  return ret;
674
811
  }
812
+ export function __wbg_get_ed0642c4b9d31ddf() { return handleError(function (arg0, arg1) {
813
+ const ret = Reflect.get(arg0, arg1);
814
+ return ret;
815
+ }, arguments); }
675
816
  export function __wbg_get_f96702c6245e4ef9() { return handleError(function (arg0, arg1) {
676
817
  const ret = Reflect.get(arg0, arg1);
677
818
  return ret;
@@ -680,6 +821,20 @@ export function __wbg_get_unchecked_7d7babe32e9e6a54(arg0, arg1) {
680
821
  const ret = arg0[arg1 >>> 0];
681
822
  return ret;
682
823
  }
824
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
825
+ const ret = arg0[arg1];
826
+ return ret;
827
+ }
828
+ export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
829
+ let result;
830
+ try {
831
+ result = arg0 instanceof ArrayBuffer;
832
+ } catch (_) {
833
+ result = false;
834
+ }
835
+ const ret = result;
836
+ return ret;
837
+ }
683
838
  export function __wbg_instanceof_Map_a10a2795ef4bfe97(arg0) {
684
839
  let result;
685
840
  try {
@@ -700,10 +855,32 @@ export function __wbg_instanceof_Object_72ee0c53dd8f0726(arg0) {
700
855
  const ret = result;
701
856
  return ret;
702
857
  }
858
+ export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
859
+ let result;
860
+ try {
861
+ result = arg0 instanceof Uint8Array;
862
+ } catch (_) {
863
+ result = false;
864
+ }
865
+ const ret = result;
866
+ return ret;
867
+ }
703
868
  export function __wbg_isArray_db61795ad004c139(arg0) {
704
869
  const ret = Array.isArray(arg0);
705
870
  return ret;
706
871
  }
872
+ export function __wbg_isSafeInteger_ea83862ba994770c(arg0) {
873
+ const ret = Number.isSafeInteger(arg0);
874
+ return ret;
875
+ }
876
+ export function __wbg_iterator_de403ef31815a3e6() {
877
+ const ret = Symbol.iterator;
878
+ return ret;
879
+ }
880
+ export function __wbg_length_0c32cb8543c8e4c8(arg0) {
881
+ const ret = arg0.length;
882
+ return ret;
883
+ }
707
884
  export function __wbg_length_6e821edde497a532(arg0) {
708
885
  const ret = arg0.length;
709
886
  return ret;
@@ -716,6 +893,10 @@ export function __wbg_new_4f9fafbb3909af72() {
716
893
  const ret = new Object();
717
894
  return ret;
718
895
  }
896
+ export function __wbg_new_a560378ea1240b14(arg0) {
897
+ const ret = new Uint8Array(arg0);
898
+ return ret;
899
+ }
719
900
  export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
720
901
  const ret = new Error(getStringFromWasm0(arg0, arg1));
721
902
  return ret;
@@ -724,14 +905,31 @@ export function __wbg_new_f3c9df4f38f3f798() {
724
905
  const ret = new Array();
725
906
  return ret;
726
907
  }
908
+ export function __wbg_next_01132ed6134b8ef5(arg0) {
909
+ const ret = arg0.next;
910
+ return ret;
911
+ }
912
+ export function __wbg_next_b3713ec761a9dbfd() { return handleError(function (arg0) {
913
+ const ret = arg0.next();
914
+ return ret;
915
+ }, arguments); }
727
916
  export function __wbg_parse_545d11396395fbbd() { return handleError(function (arg0, arg1) {
728
917
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
729
918
  return ret;
730
919
  }, arguments); }
920
+ export function __wbg_prototypesetcall_3e05eb9545565046(arg0, arg1, arg2) {
921
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
922
+ }
731
923
  export function __wbg_push_6bdbc990be5ac37b(arg0, arg1) {
732
924
  const ret = arg0.push(arg1);
733
925
  return ret;
734
926
  }
927
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
928
+ arg0[arg1] = arg2;
929
+ }
930
+ export function __wbg_set_6c60b2e8ad0e9383(arg0, arg1, arg2) {
931
+ arg0[arg1 >>> 0] = arg2;
932
+ }
735
933
  export function __wbg_set_8ee2d34facb8466e() { return handleError(function (arg0, arg1, arg2) {
736
934
  const ret = Reflect.set(arg0, arg1, arg2);
737
935
  return ret;
@@ -739,6 +937,10 @@ export function __wbg_set_8ee2d34facb8466e() { return handleError(function (arg0
739
937
  export function __wbg_set_name_ab9c98596fd7310a(arg0, arg1, arg2) {
740
938
  arg0.name = getStringFromWasm0(arg1, arg2);
741
939
  }
940
+ export function __wbg_value_7f6052747ccf940f(arg0) {
941
+ const ret = arg0.value;
942
+ return ret;
943
+ }
742
944
  export function __wbindgen_cast_0000000000000001(arg0) {
743
945
  // Cast intrinsic for `F64 -> Externref`.
744
946
  const ret = arg0;
@@ -749,6 +951,11 @@ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
749
951
  const ret = getStringFromWasm0(arg0, arg1);
750
952
  return ret;
751
953
  }
954
+ export function __wbindgen_cast_0000000000000003(arg0) {
955
+ // Cast intrinsic for `U64 -> Externref`.
956
+ const ret = BigInt.asUintN(64, arg0);
957
+ return ret;
958
+ }
752
959
  export function __wbindgen_init_externref_table() {
753
960
  const table = wasm.__wbindgen_externrefs;
754
961
  const offset = table.grow(4);
@@ -764,6 +971,71 @@ function addToExternrefTable0(obj) {
764
971
  return idx;
765
972
  }
766
973
 
974
+ function debugString(val) {
975
+ // primitive types
976
+ const type = typeof val;
977
+ if (type == 'number' || type == 'boolean' || val == null) {
978
+ return `${val}`;
979
+ }
980
+ if (type == 'string') {
981
+ return `"${val}"`;
982
+ }
983
+ if (type == 'symbol') {
984
+ const description = val.description;
985
+ if (description == null) {
986
+ return 'Symbol';
987
+ } else {
988
+ return `Symbol(${description})`;
989
+ }
990
+ }
991
+ if (type == 'function') {
992
+ const name = val.name;
993
+ if (typeof name == 'string' && name.length > 0) {
994
+ return `Function(${name})`;
995
+ } else {
996
+ return 'Function';
997
+ }
998
+ }
999
+ // objects
1000
+ if (Array.isArray(val)) {
1001
+ const length = val.length;
1002
+ let debug = '[';
1003
+ if (length > 0) {
1004
+ debug += debugString(val[0]);
1005
+ }
1006
+ for(let i = 1; i < length; i++) {
1007
+ debug += ', ' + debugString(val[i]);
1008
+ }
1009
+ debug += ']';
1010
+ return debug;
1011
+ }
1012
+ // Test for built-in
1013
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1014
+ let className;
1015
+ if (builtInMatches && builtInMatches.length > 1) {
1016
+ className = builtInMatches[1];
1017
+ } else {
1018
+ // Failed to match the standard '[object ClassName]'
1019
+ return toString.call(val);
1020
+ }
1021
+ if (className == 'Object') {
1022
+ // we're a user defined class or Object
1023
+ // JSON.stringify avoids problems with cycles, and is generally much
1024
+ // easier than looping through ownProperties of `val`.
1025
+ try {
1026
+ return 'Object(' + JSON.stringify(val) + ')';
1027
+ } catch (_) {
1028
+ return 'Object';
1029
+ }
1030
+ }
1031
+ // errors
1032
+ if (val instanceof Error) {
1033
+ return `${val.name}: ${val.message}\n${val.stack}`;
1034
+ }
1035
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1036
+ return className;
1037
+ }
1038
+
767
1039
  function getArrayJsValueFromWasm0(ptr, len) {
768
1040
  ptr = ptr >>> 0;
769
1041
  const mem = getDataViewMemory0();
@@ -775,6 +1047,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
775
1047
  return result;
776
1048
  }
777
1049
 
1050
+ function getArrayU8FromWasm0(ptr, len) {
1051
+ ptr = ptr >>> 0;
1052
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1053
+ }
1054
+
778
1055
  let cachedDataViewMemory0 = null;
779
1056
  function getDataViewMemory0() {
780
1057
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@markup-carve/carve-wasm",
3
3
  "type": "module",
4
4
  "description": "WASM bindings for the Carve parser and HTML renderer.",
5
- "version": "0.1.2",
5
+ "version": "0.1.3",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",