@markup-carve/carve-wasm 0.1.2 → 0.1.4

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/carve_wasm_bg.js CHANGED
@@ -1,3 +1,156 @@
1
+ /**
2
+ * Replay patch JSON onto a PART 12 tree, returning the result as AST JSON.
3
+ * @param {string} ast
4
+ * @param {string} patch
5
+ * @returns {string}
6
+ */
7
+ export function applyAstPatch(ast, patch) {
8
+ let deferred4_0;
9
+ let deferred4_1;
10
+ try {
11
+ const ptr0 = passStringToWasm0(ast, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
12
+ const len0 = WASM_VECTOR_LEN;
13
+ const ptr1 = passStringToWasm0(patch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
14
+ const len1 = WASM_VECTOR_LEN;
15
+ const ret = wasm.applyAstPatch(ptr0, len0, ptr1, len1);
16
+ var ptr3 = ret[0];
17
+ var len3 = ret[1];
18
+ if (ret[3]) {
19
+ ptr3 = 0; len3 = 0;
20
+ throw takeFromExternrefTable0(ret[2]);
21
+ }
22
+ deferred4_0 = ptr3;
23
+ deferred4_1 = len3;
24
+ return getStringFromWasm0(ptr3, len3);
25
+ } finally {
26
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Apply a security profile to an AST-JSON document (PART 12), keeping the
32
+ * filtered tree.
33
+ *
34
+ * The `profile` render option filters on the way to HTML and throws the result
35
+ * of the filtering away. This is the same pass with the tree kept, so a host
36
+ * that stores, diffs or re-renders an untrusted document does not have to
37
+ * render HTML and parse it back to get one.
38
+ *
39
+ * `violations` reports what the filter degraded or stripped, which the HTML
40
+ * path cannot: a profile whose action is `error` throws instead, so a
41
+ * resolved call under `to-text` or `strip` is the only place this is visible.
42
+ *
43
+ * Only `profileBaseHost` and `smartTypography` are read from `options`. The
44
+ * rest of the render options describe a renderer, and this is not one.
45
+ *
46
+ * The profile's `max_length` is NOT enforced here: the engine applies it to the
47
+ * source bytes before a parse, and this entry point is handed a tree.
48
+ * @param {string} json
49
+ * @param {string} profile
50
+ * @param {object | null} [options]
51
+ * @returns {ProfileFilterResult}
52
+ */
53
+ export function applyProfile(json, profile, options) {
54
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
55
+ const len0 = WASM_VECTOR_LEN;
56
+ const ptr1 = passStringToWasm0(profile, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
57
+ const len1 = WASM_VECTOR_LEN;
58
+ const ret = wasm.applyProfile(ptr0, len0, ptr1, len1, isLikeNone(options) ? 0 : addToExternrefTable0(options));
59
+ if (ret[2]) {
60
+ throw takeFromExternrefTable0(ret[1]);
61
+ }
62
+ return takeFromExternrefTable0(ret[0]);
63
+ }
64
+
65
+ /**
66
+ * Replay a reversible patch, forward or inverted.
67
+ *
68
+ * The fingerprint is checked first: a tree that is not the one this patch was
69
+ * made against is refused rather than half-patched. That is a broken caller
70
+ * contract, so it throws.
71
+ * @param {string} ast
72
+ * @param {string} patch
73
+ * @param {boolean | null} [inverse]
74
+ * @returns {string}
75
+ */
76
+ export function applyReversibleAstPatch(ast, patch, inverse) {
77
+ let deferred4_0;
78
+ let deferred4_1;
79
+ try {
80
+ const ptr0 = passStringToWasm0(ast, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
81
+ const len0 = WASM_VECTOR_LEN;
82
+ const ptr1 = passStringToWasm0(patch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
83
+ const len1 = WASM_VECTOR_LEN;
84
+ const ret = wasm.applyReversibleAstPatch(ptr0, len0, ptr1, len1, isLikeNone(inverse) ? 0xFFFFFF : inverse ? 1 : 0);
85
+ var ptr3 = ret[0];
86
+ var len3 = ret[1];
87
+ if (ret[3]) {
88
+ ptr3 = 0; len3 = 0;
89
+ throw takeFromExternrefTable0(ret[2]);
90
+ }
91
+ deferred4_0 = ptr3;
92
+ deferred4_1 = len3;
93
+ return getStringFromWasm0(ptr3, len3);
94
+ } finally {
95
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Apply a trusted patch after its source length and fingerprint still match.
101
+ * @param {string} source
102
+ * @param {any} patch
103
+ * @returns {string}
104
+ */
105
+ export function applySourcePatch(source, patch) {
106
+ let deferred3_0;
107
+ let deferred3_1;
108
+ try {
109
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
110
+ const len0 = WASM_VECTOR_LEN;
111
+ const ret = wasm.applySourcePatch(ptr0, len0, patch);
112
+ var ptr2 = ret[0];
113
+ var len2 = ret[1];
114
+ if (ret[3]) {
115
+ ptr2 = 0; len2 = 0;
116
+ throw takeFromExternrefTable0(ret[2]);
117
+ }
118
+ deferred3_0 = ptr2;
119
+ deferred3_1 = len2;
120
+ return getStringFromWasm0(ptr2, len2);
121
+ } finally {
122
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Render an AST-JSON document (PART 12) to ANSI-styled text. See
128
+ * [`ast_json_to_markdown`], including what a tree without positions costs.
129
+ * @param {string} json
130
+ * @param {object | null} [options]
131
+ * @returns {string}
132
+ */
133
+ export function astJsonToAnsi(json, options) {
134
+ let deferred3_0;
135
+ let deferred3_1;
136
+ try {
137
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
+ const len0 = WASM_VECTOR_LEN;
139
+ const ret = wasm.astJsonToAnsi(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
140
+ var ptr2 = ret[0];
141
+ var len2 = ret[1];
142
+ if (ret[3]) {
143
+ ptr2 = 0; len2 = 0;
144
+ throw takeFromExternrefTable0(ret[2]);
145
+ }
146
+ deferred3_0 = ptr2;
147
+ deferred3_1 = len2;
148
+ return getStringFromWasm0(ptr2, len2);
149
+ } finally {
150
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
151
+ }
152
+ }
153
+
1
154
  /**
2
155
  * Render an AST-JSON document (PART 12) back to canonical Carve source.
3
156
  *
@@ -62,6 +215,242 @@ export function astJsonToHtml(json, options) {
62
215
  }
63
216
  }
64
217
 
218
+ /**
219
+ * Render an AST-JSON document (PART 12) to Markdown.
220
+ *
221
+ * The direct call for a host that already holds a tree. Without it Markdown was
222
+ * reached through `astJsonToCarve` and then `toMarkdown`: a canonical write, a
223
+ * re-parse and a second render for one answer, and lossier than this, because a
224
+ * tree holding something no Carve source can spell is refused by the write
225
+ * rather than rendered.
226
+ *
227
+ * Takes the same options object as [`to_markdown_with_options`], and reads the
228
+ * same narrow part of it. The profile filter and the `before_render` hooks run,
229
+ * as they do in [`ast_json_to_html`].
230
+ *
231
+ * ORDERING FOLLOWS THE TREE. `toMarkdown` parses with positions on, because
232
+ * section 7 orders collected definitions by source position. A tree arriving as
233
+ * JSON carries whatever positions its producer put there, and one carrying none
234
+ * prints its footnote and link definitions in label order. That is the only
235
+ * order available to a tree without spans, so it is reported here rather than
236
+ * repaired.
237
+ * @param {string} json
238
+ * @param {object | null} [options]
239
+ * @returns {string}
240
+ */
241
+ export function astJsonToMarkdown(json, options) {
242
+ let deferred3_0;
243
+ let deferred3_1;
244
+ try {
245
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
246
+ const len0 = WASM_VECTOR_LEN;
247
+ const ret = wasm.astJsonToMarkdown(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
248
+ var ptr2 = ret[0];
249
+ var len2 = ret[1];
250
+ if (ret[3]) {
251
+ ptr2 = 0; len2 = 0;
252
+ throw takeFromExternrefTable0(ret[2]);
253
+ }
254
+ deferred3_0 = ptr2;
255
+ deferred3_1 = len2;
256
+ return getStringFromWasm0(ptr2, len2);
257
+ } finally {
258
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Render an AST-JSON document (PART 12) to plain text. See
264
+ * [`ast_json_to_markdown`], including what a tree without positions costs.
265
+ * @param {string} json
266
+ * @param {object | null} [options]
267
+ * @returns {string}
268
+ */
269
+ export function astJsonToPlainText(json, options) {
270
+ let deferred3_0;
271
+ let deferred3_1;
272
+ try {
273
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
274
+ const len0 = WASM_VECTOR_LEN;
275
+ const ret = wasm.astJsonToPlainText(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
276
+ var ptr2 = ret[0];
277
+ var len2 = ret[1];
278
+ if (ret[3]) {
279
+ ptr2 = 0; len2 = 0;
280
+ throw takeFromExternrefTable0(ret[2]);
281
+ }
282
+ deferred3_0 = ptr2;
283
+ deferred3_1 = len2;
284
+ return getStringFromWasm0(ptr2, len2);
285
+ } finally {
286
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
287
+ }
288
+ }
289
+
290
+ /**
291
+ * The difference between two PART 12 trees, as patch JSON.
292
+ *
293
+ * ```js
294
+ * const patch = createAstPatch(parseJson('# One\n'), parseJson('# Two\n'))
295
+ * applyAstPatch(parseJson('# One\n'), patch) // the '# Two' tree
296
+ * ```
297
+ *
298
+ * Trees and patches both cross as JSON strings, matching `parseJson` and
299
+ * `astJsonToHtml`. A patch carries node payloads, so it carries arbitrary
300
+ * document text - the reason `parseJson` chose a string in the first place.
301
+ *
302
+ * The engine's `ast_patch_to_json` and `ast_patch_from_json` are not bound
303
+ * separately. With the patch crossing as JSON they ARE the encoding of this
304
+ * pair, and a host calling them would be converting JSON it already holds.
305
+ *
306
+ * The operations are position-independent `{ op, path, value }`, so a patch
307
+ * stays meaningful against a tree that moved underneath it - unlike a source
308
+ * patch, which `createSourcePatch` fingerprints against staleness.
309
+ * @param {string} before
310
+ * @param {string} after
311
+ * @returns {string}
312
+ */
313
+ export function createAstPatch(before, after) {
314
+ let deferred4_0;
315
+ let deferred4_1;
316
+ try {
317
+ const ptr0 = passStringToWasm0(before, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
318
+ const len0 = WASM_VECTOR_LEN;
319
+ const ptr1 = passStringToWasm0(after, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
320
+ const len1 = WASM_VECTOR_LEN;
321
+ const ret = wasm.createAstPatch(ptr0, len0, ptr1, len1);
322
+ var ptr3 = ret[0];
323
+ var len3 = ret[1];
324
+ if (ret[3]) {
325
+ ptr3 = 0; len3 = 0;
326
+ throw takeFromExternrefTable0(ret[2]);
327
+ }
328
+ deferred4_0 = ptr3;
329
+ deferred4_1 = len3;
330
+ return getStringFromWasm0(ptr3, len3);
331
+ } finally {
332
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
333
+ }
334
+ }
335
+
336
+ /**
337
+ * The same difference with its inverse and both fingerprints, as one JSON
338
+ * object: `{ forward, inverse, beforeFingerprint, afterFingerprint }`.
339
+ *
340
+ * This is the shape an undo step wants. THE STACK IS THE HOST'S: every entry
341
+ * point in this package is a pure function that owns nothing, so there is no
342
+ * history kept here to undo against, and a browser host already has one - a
343
+ * key handler, a toolbar, an editor's own history plugin.
344
+ *
345
+ * What the pair adds over two `createAstPatch` calls is the precondition.
346
+ * [`apply_reversible_ast_patch`] refuses a tree whose fingerprint is not the
347
+ * one the patch was made against, so an undo cannot be replayed onto a
348
+ * document that has moved on.
349
+ * @param {string} before
350
+ * @param {string} after
351
+ * @returns {string}
352
+ */
353
+ export function createReversibleAstPatch(before, after) {
354
+ let deferred4_0;
355
+ let deferred4_1;
356
+ try {
357
+ const ptr0 = passStringToWasm0(before, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
358
+ const len0 = WASM_VECTOR_LEN;
359
+ const ptr1 = passStringToWasm0(after, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
360
+ const len1 = WASM_VECTOR_LEN;
361
+ const ret = wasm.createReversibleAstPatch(ptr0, len0, ptr1, len1);
362
+ var ptr3 = ret[0];
363
+ var len3 = ret[1];
364
+ if (ret[3]) {
365
+ ptr3 = 0; len3 = 0;
366
+ throw takeFromExternrefTable0(ret[2]);
367
+ }
368
+ deferred4_0 = ptr3;
369
+ deferred4_1 = len3;
370
+ return getStringFromWasm0(ptr3, len3);
371
+ } finally {
372
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
373
+ }
374
+ }
375
+
376
+ /**
377
+ * Build the smallest single UTF-8 byte-range replacement between two sources.
378
+ * @param {string} source
379
+ * @param {string} replacement
380
+ * @param {string} kind
381
+ * @param {string} code
382
+ * @returns {SourcePatch}
383
+ */
384
+ export function createSourcePatch(source, replacement, kind, code) {
385
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
386
+ const len0 = WASM_VECTOR_LEN;
387
+ const ptr1 = passStringToWasm0(replacement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
388
+ const len1 = WASM_VECTOR_LEN;
389
+ const ptr2 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
390
+ const len2 = WASM_VECTOR_LEN;
391
+ const ptr3 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
392
+ const len3 = WASM_VECTOR_LEN;
393
+ const ret = wasm.createSourcePatch(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
394
+ if (ret[2]) {
395
+ throw takeFromExternrefTable0(ret[1]);
396
+ }
397
+ return takeFromExternrefTable0(ret[0]);
398
+ }
399
+
400
+ /**
401
+ * Expand `{{ path }}` include directives (spec PART 9 §19) through a JS
402
+ * resolver, and hand back the expanded tree as AST JSON.
403
+ *
404
+ * The resolver MUST BE SYNCHRONOUS, which decides who can use this. A browser
405
+ * host that would resolve a path by `fetch` cannot: `fetch` is a Promise and
406
+ * wasm-bindgen cannot await across the call. A host whose files are already in
407
+ * memory - an editor with its open buffers, a bundler, a VFS, a test harness -
408
+ * resolves from that map and is exactly who this is for.
409
+ *
410
+ * ```js
411
+ * const files = new Map([['child.crv', 'Included body.\n']])
412
+ * expandIncludes('Before.\n\n{{ child.crv }}\n', {
413
+ * resolve: (path) => files.get(path) ?? null,
414
+ * })
415
+ * // { json, warnings: [], suppressedWarnings: 0, dependencies: […],
416
+ * // chargedBytes: 15, resolverErrors: [] }
417
+ * ```
418
+ *
419
+ * The resolver returns the child's source as a string, or
420
+ * `{ source, id }` when it can name the file canonically - the id is what the
421
+ * cycle guard compares, so two spellings of one file defeat it without one.
422
+ * `null` refuses the directive as `not-found`; `{ denial }` refuses it in one
423
+ * of the classes §19 names.
424
+ *
425
+ * An `async` resolver returns a Promise, which is not a string and cannot be
426
+ * awaited. That is a per-document failure reported in `resolverErrors`,
427
+ * matching what an `async` `renderers.math` gets from
428
+ * [`to_html_with_renderers`]: the directive stays literal and the caller is
429
+ * told why, rather than the value being swallowed or stringified.
430
+ *
431
+ * The BUDGETS are part of the contract, not a detail: `maxBytes` defaults to
432
+ * `max(1 MB, 8 x source bytes)`, `maxDepth` to 16, `maxResolverCalls` to 1000
433
+ * and `maxWarnings` to 100. They bound what a document of directives can make
434
+ * a host do, and lowering them is how a host serving untrusted documents keeps
435
+ * that bounded.
436
+ *
437
+ * The tree carries no positions. Expansion merges nodes from several files,
438
+ * and a span on a node that came from a child would point into a source the
439
+ * caller did not pass.
440
+ * @param {string} source
441
+ * @param {object} options
442
+ * @returns {IncludeExpansion}
443
+ */
444
+ export function expandIncludes(source, options) {
445
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
446
+ const len0 = WASM_VECTOR_LEN;
447
+ const ret = wasm.expandIncludes(ptr0, len0, options);
448
+ if (ret[2]) {
449
+ throw takeFromExternrefTable0(ret[1]);
450
+ }
451
+ return takeFromExternrefTable0(ret[0]);
452
+ }
453
+
65
454
  /**
66
455
  * Every extension name this build accepts, in registry order.
67
456
  *
@@ -133,7 +522,7 @@ export function fromDjot(source) {
133
522
  /**
134
523
  * @param {string} source
135
524
  * @param {string | null} [mode]
136
- * @returns {any}
525
+ * @returns {MigrationResult}
137
526
  */
138
527
  export function fromHtml(source, mode) {
139
528
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -149,7 +538,7 @@ export function fromHtml(source, mode) {
149
538
 
150
539
  /**
151
540
  * @param {string} source
152
- * @returns {any}
541
+ * @returns {MigrationResult}
153
542
  */
154
543
  export function fromMarkdown(source) {
155
544
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -161,6 +550,77 @@ export function fromMarkdown(source) {
161
550
  return takeFromExternrefTable0(ret[0]);
162
551
  }
163
552
 
553
+ /**
554
+ * Convert a ProseMirror document back to canonical Carve source.
555
+ *
556
+ * The save half of the editor loop. A payload the schema map does not describe
557
+ * is refused rather than written approximately, so an editor extended with a
558
+ * node the bridge has never seen fails where it can be reported.
559
+ * @param {string} doc
560
+ * @returns {string}
561
+ */
562
+ export function fromProseMirror(doc) {
563
+ let deferred3_0;
564
+ let deferred3_1;
565
+ try {
566
+ const ptr0 = passStringToWasm0(doc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
567
+ const len0 = WASM_VECTOR_LEN;
568
+ const ret = wasm.fromProseMirror(ptr0, len0);
569
+ var ptr2 = ret[0];
570
+ var len2 = ret[1];
571
+ if (ret[3]) {
572
+ ptr2 = 0; len2 = 0;
573
+ throw takeFromExternrefTable0(ret[2]);
574
+ }
575
+ deferred3_0 = ptr2;
576
+ deferred3_1 = len2;
577
+ return getStringFromWasm0(ptr2, len2);
578
+ } finally {
579
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
580
+ }
581
+ }
582
+
583
+ /**
584
+ * Import HTML straight to the tree, as AST JSON.
585
+ *
586
+ * `htmlToCarve` writes Carve SOURCE, so a host that wanted the tree had to
587
+ * re-parse what it had just written - two parses of one document to get one
588
+ * answer. This is the same importer without that round trip.
589
+ *
590
+ * ```js
591
+ * const { value, report } = htmlToAst('<p>Hello <b>world</b></p>', 'safe')
592
+ * astJsonToHtml(value)
593
+ * ```
594
+ *
595
+ * Returns the SAME `{ value, report }` shape `htmlToCarve` does, with `value`
596
+ * holding the tree instead of the source, in the same fidelity vocabulary. A
597
+ * third result shape for one importer is what that avoids.
598
+ *
599
+ * The REPORT IS NOT ALWAYS IDENTICAL, and the difference is the point. A loss
600
+ * only a WRITER takes is not reported here, because no writer ran (PART 12
601
+ * §16): a `<figure>` wrapping a table, or a table with an explicit
602
+ * head/body/foot grouping, has no Carve spelling, so `htmlToCarve` reports
603
+ * `structure-unspellable` and this does not - the tree keeps the thing that
604
+ * would have been lost.
605
+ *
606
+ * `mode` is spelled as it is there: `safe` (the default), `semantic`, and
607
+ * trusted-only `roundtrip`.
608
+ * @param {string} source
609
+ * @param {string | null} [mode]
610
+ * @returns {MigrationResult}
611
+ */
612
+ export function htmlToAst(source, mode) {
613
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
614
+ const len0 = WASM_VECTOR_LEN;
615
+ var ptr1 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
616
+ var len1 = WASM_VECTOR_LEN;
617
+ const ret = wasm.htmlToAst(ptr0, len0, ptr1, len1);
618
+ if (ret[2]) {
619
+ throw takeFromExternrefTable0(ret[1]);
620
+ }
621
+ return takeFromExternrefTable0(ret[0]);
622
+ }
623
+
164
624
  /**
165
625
  * Import HTML through the Rust HTML5 DOM and canonical Carve writer.
166
626
  *
@@ -168,7 +628,7 @@ export function fromMarkdown(source) {
168
628
  * decision observable. `roundtrip` is only safe for Carve-produced HTML.
169
629
  * @param {string} source
170
630
  * @param {string | null} [mode]
171
- * @returns {any}
631
+ * @returns {MigrationResult}
172
632
  */
173
633
  export function htmlToCarve(source, mode) {
174
634
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -182,6 +642,25 @@ export function htmlToCarve(source, mode) {
182
642
  return takeFromExternrefTable0(ret[0]);
183
643
  }
184
644
 
645
+ /**
646
+ * The accessibility diagnostics, a second family beside `lintCarve`.
647
+ *
648
+ * Its own rule ids (`a11y/image-alt`, `a11y/heading-jump`) and its own
649
+ * severity, which `lintCarve` has no field for. Offsets are `null` when the
650
+ * node that triggered the rule carried no position.
651
+ * @param {string} source
652
+ * @returns {AccessibilityDiagnostic[]}
653
+ */
654
+ export function lintAccessibility(source) {
655
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
656
+ const len0 = WASM_VECTOR_LEN;
657
+ const ret = wasm.lintAccessibility(ptr0, len0);
658
+ if (ret[2]) {
659
+ throw takeFromExternrefTable0(ret[1]);
660
+ }
661
+ return takeFromExternrefTable0(ret[0]);
662
+ }
663
+
185
664
  /**
186
665
  * Lint a document for the degradations PART 15 describes.
187
666
  *
@@ -205,6 +684,135 @@ export function lintCarve(source) {
205
684
  return takeFromExternrefTable0(ret[0]);
206
685
  }
207
686
 
687
+ /**
688
+ * Lint a document with the same options object the render entry points take.
689
+ *
690
+ * `lintCarve` is the option-less form. Which degradations exist depends on the
691
+ * extensions in play, so a host that renders with a set has to lint with it.
692
+ * @param {string} source
693
+ * @param {object | null} [options]
694
+ * @returns {LintWarning[]}
695
+ */
696
+ export function lintCarveWithOptions(source, options) {
697
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
698
+ const len0 = WASM_VECTOR_LEN;
699
+ const ret = wasm.lintCarveWithOptions(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
700
+ if (ret[2]) {
701
+ throw takeFromExternrefTable0(ret[1]);
702
+ }
703
+ return takeFromExternrefTable0(ret[0]);
704
+ }
705
+
706
+ /**
707
+ * Import Markdown straight to the tree, as AST JSON.
708
+ *
709
+ * `fromMarkdown` writes Carve SOURCE, so a host that wanted the tree had to
710
+ * re-parse what it had just written. This is the same importer without that
711
+ * round trip. The losses `fromMarkdown` reports are not repeated here; a host
712
+ * that needs them calls that one.
713
+ * @param {string} source
714
+ * @returns {string}
715
+ */
716
+ export function markdownToAstJson(source) {
717
+ let deferred2_0;
718
+ let deferred2_1;
719
+ try {
720
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
721
+ const len0 = WASM_VECTOR_LEN;
722
+ const ret = wasm.markdownToAstJson(ptr0, len0);
723
+ deferred2_0 = ret[0];
724
+ deferred2_1 = ret[1];
725
+ return getStringFromWasm0(ret[0], ret[1]);
726
+ } finally {
727
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
728
+ }
729
+ }
730
+
731
+ /**
732
+ * Three-way merge over PART 12 trees, with conflicts as a VALUE.
733
+ *
734
+ * ```js
735
+ * const { ok, ast, conflicts } = JSON.parse(mergeAst(base, ours, theirs))
736
+ * ```
737
+ *
738
+ * Returns `{ ok, ast, conflicts, resolverErrors }` as one JSON string. A
739
+ * conflict does NOT throw: it is a result the caller asked for, and two people
740
+ * editing one document is the ordinary case rather than a broken contract.
741
+ * `ok` is false, `ast` is null, and `conflicts` says where and why.
742
+ *
743
+ * The `{ ok, ast, conflicts }` shape and the three `reason` names -
744
+ * `both-changed`, `delete-edit`, `concurrent-sequence-edit` - are carve-js's,
745
+ * so a host merging with either engine reads one contract. The Rust engine
746
+ * carries no `deleted` flags on a conflict, so that optional carve-js field is
747
+ * absent here rather than guessed at.
748
+ *
749
+ * `options.resolve` is an optional `(conflict) => 'base' | 'ours' | 'theirs' |
750
+ * { value } | null`, answering conflicts while the merge runs; an answer of
751
+ * `null` leaves one unresolved. IT MUST BE SYNCHRONOUS. A resolver that asks a
752
+ * server, or asks the user, returns a Promise the merge cannot await - that is
753
+ * reported in `resolverErrors` and the conflict is left unresolved, the same
754
+ * treatment an `async` `renderers.math` gets.
755
+ * @param {string} base
756
+ * @param {string} ours
757
+ * @param {string} theirs
758
+ * @param {object | null} [options]
759
+ * @returns {string}
760
+ */
761
+ export function mergeAst(base, ours, theirs, options) {
762
+ let deferred5_0;
763
+ let deferred5_1;
764
+ try {
765
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
766
+ const len0 = WASM_VECTOR_LEN;
767
+ const ptr1 = passStringToWasm0(ours, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
768
+ const len1 = WASM_VECTOR_LEN;
769
+ const ptr2 = passStringToWasm0(theirs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
770
+ const len2 = WASM_VECTOR_LEN;
771
+ const ret = wasm.mergeAst(ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(options) ? 0 : addToExternrefTable0(options));
772
+ var ptr4 = ret[0];
773
+ var len4 = ret[1];
774
+ if (ret[3]) {
775
+ ptr4 = 0; len4 = 0;
776
+ throw takeFromExternrefTable0(ret[2]);
777
+ }
778
+ deferred5_0 = ptr4;
779
+ deferred5_1 = len4;
780
+ return getStringFromWasm0(ptr4, len4);
781
+ } finally {
782
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
783
+ }
784
+ }
785
+
786
+ /**
787
+ * Convert BBCode and retain a conservative v2 fidelity report.
788
+ * @param {string} source
789
+ * @returns {MigrationResult}
790
+ */
791
+ export function migrateBbcode(source) {
792
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
793
+ const len0 = WASM_VECTOR_LEN;
794
+ const ret = wasm.migrateBbcode(ptr0, len0);
795
+ if (ret[2]) {
796
+ throw takeFromExternrefTable0(ret[1]);
797
+ }
798
+ return takeFromExternrefTable0(ret[0]);
799
+ }
800
+
801
+ /**
802
+ * Convert Djot and retain a conservative v2 fidelity report.
803
+ * @param {string} source
804
+ * @returns {MigrationResult}
805
+ */
806
+ export function migrateDjot(source) {
807
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
808
+ const len0 = WASM_VECTOR_LEN;
809
+ const ret = wasm.migrateDjot(ptr0, len0);
810
+ if (ret[2]) {
811
+ throw takeFromExternrefTable0(ret[1]);
812
+ }
813
+ return takeFromExternrefTable0(ret[0]);
814
+ }
815
+
208
816
  /**
209
817
  * Whether a document was last processed under an older spec version than
210
818
  * `currentVersion`. An unstamped document counts as needing review.
@@ -252,19 +860,302 @@ export function parseJson(source) {
252
860
  deferred2_1 = ret[1];
253
861
  return getStringFromWasm0(ret[0], ret[1]);
254
862
  } finally {
255
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
863
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
864
+ }
865
+ }
866
+
867
+ /**
868
+ * Serialize the tree with the same options object as
869
+ * [`to_html_with_options`], so a host can export the tree of an untrusted
870
+ * document under the `profile` it renders that document with.
871
+ *
872
+ * `positions` is not read: every serialized tree this binding produces carries
873
+ * them, as in [`parse_json`].
874
+ * @param {string} source
875
+ * @param {object | null} [options]
876
+ * @returns {string}
877
+ */
878
+ export function parseJsonWithOptions(source, options) {
879
+ let deferred3_0;
880
+ let deferred3_1;
881
+ try {
882
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
883
+ const len0 = WASM_VECTOR_LEN;
884
+ const ret = wasm.parseJsonWithOptions(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
885
+ var ptr2 = ret[0];
886
+ var len2 = ret[1];
887
+ if (ret[3]) {
888
+ ptr2 = 0; len2 = 0;
889
+ throw takeFromExternrefTable0(ret[2]);
890
+ }
891
+ deferred3_0 = ptr2;
892
+ deferred3_1 = len2;
893
+ return getStringFromWasm0(ptr2, len2);
894
+ } finally {
895
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
896
+ }
897
+ }
898
+
899
+ /**
900
+ * Parse the locator portion of a citation into `{ label, value, suffixText }`.
901
+ *
902
+ * A field the source did not carry is `null`. Same shape as carve-js
903
+ * `parseLocator`; pure, and never throws on bad input.
904
+ * @param {string} loc
905
+ * @returns {ParsedLocator}
906
+ */
907
+ export function parseLocator(loc) {
908
+ const ptr0 = passStringToWasm0(loc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
909
+ const len0 = WASM_VECTOR_LEN;
910
+ const ret = wasm.parseLocator(ptr0, len0);
911
+ if (ret[2]) {
912
+ throw takeFromExternrefTable0(ret[1]);
913
+ }
914
+ return takeFromExternrefTable0(ret[0]);
915
+ }
916
+
917
+ /**
918
+ * Parse a document and keep what a later [`reparse`] needs.
919
+ *
920
+ * Returns one JSON object: `{ source, document, sourceLayout, changedSource,
921
+ * reusedPreviousTree }`. `document` is the PART 12 tree, `sourceLayout` the
922
+ * byte-exact record [`parse_source_layout_json`] produces, and
923
+ * `changedSource` the byte ranges this parse covered - the whole document, on
924
+ * a first parse.
925
+ *
926
+ * The snapshot crosses as JSON rather than as a handle a host has to `free()`.
927
+ * Every other entry point here is a pure function that owns nothing, and the
928
+ * engine's own snapshot holds only the source, so there is no tree being kept
929
+ * alive in wasm memory for a handle to point at.
930
+ * @param {string} source
931
+ * @returns {string}
932
+ */
933
+ export function parseSnapshot(source) {
934
+ let deferred2_0;
935
+ let deferred2_1;
936
+ try {
937
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
938
+ const len0 = WASM_VECTOR_LEN;
939
+ const ret = wasm.parseSnapshot(ptr0, len0);
940
+ deferred2_0 = ret[0];
941
+ deferred2_1 = ret[1];
942
+ return getStringFromWasm0(ret[0], ret[1]);
943
+ } finally {
944
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
945
+ }
946
+ }
947
+
948
+ /**
949
+ * The PART 12 §13 source-layout sidecar for a document.
950
+ *
951
+ * Separate from `parseJson`, which carries semantic positions on the nodes.
952
+ * This is the byte-exact record of the SOURCE: its line endings, whether it
953
+ * had a BOM, and a path-addressed byte span per node - what a host needs to
954
+ * write an edit back into the file it came from.
955
+ * @param {string} source
956
+ * @returns {string}
957
+ */
958
+ export function parseSourceLayoutJson(source) {
959
+ let deferred2_0;
960
+ let deferred2_1;
961
+ try {
962
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
963
+ const len0 = WASM_VECTOR_LEN;
964
+ const ret = wasm.parseSourceLayoutJson(ptr0, len0);
965
+ deferred2_0 = ret[0];
966
+ deferred2_1 = ret[1];
967
+ return getStringFromWasm0(ret[0], ret[1]);
968
+ } finally {
969
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
970
+ }
971
+ }
972
+
973
+ /**
974
+ * Read a document's provenance marker: `{ version, generatedBy }`, or `null`.
975
+ * @param {string} source
976
+ * @returns {Stamp | null}
977
+ */
978
+ export function readStamp(source) {
979
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
980
+ const len0 = WASM_VECTOR_LEN;
981
+ const ret = wasm.readStamp(ptr0, len0);
982
+ if (ret[2]) {
983
+ throw takeFromExternrefTable0(ret[1]);
984
+ }
985
+ return takeFromExternrefTable0(ret[0]);
986
+ }
987
+
988
+ /**
989
+ * Re-parse `source` with `changes` applied.
990
+ *
991
+ * ```js
992
+ * const first = JSON.parse(parseSnapshot('# One\n'))
993
+ * const next = JSON.parse(reparse(first.source, '[{"range":[2,5],"replacement":"Two"}]'))
994
+ * ```
995
+ *
996
+ * `changes` is a JSON array of `{ range: [start, end], replacement }`.
997
+ *
998
+ * THE OFFSETS ARE UTF-8 BYTE OFFSETS, which is what `parseJson` positions and
999
+ * `createSourcePatch` ranges already mean. A browser editor counts UTF-16 code
1000
+ * units, so a host holding a `selectionStart` converts before calling - an
1001
+ * offset that lands inside a multi-byte character is refused rather than
1002
+ * guessed at.
1003
+ *
1004
+ * A malformed change THROWS: overlapping ranges, an end past the source, and a
1005
+ * range that splits a code point are all a broken caller contract, not a
1006
+ * result the caller asked for.
1007
+ *
1008
+ * `reusedPreviousTree` says whether the parse reused any of the previous one.
1009
+ * The pinned engine always reports `false` - it validates and applies the
1010
+ * edits and then parses the whole source - so a host should read this as the
1011
+ * engine's own answer rather than assume work was saved.
1012
+ * @param {string} source
1013
+ * @param {string} changes
1014
+ * @returns {string}
1015
+ */
1016
+ export function reparse(source, changes) {
1017
+ let deferred4_0;
1018
+ let deferred4_1;
1019
+ try {
1020
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1021
+ const len0 = WASM_VECTOR_LEN;
1022
+ const ptr1 = passStringToWasm0(changes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1023
+ const len1 = WASM_VECTOR_LEN;
1024
+ const ret = wasm.reparse(ptr0, len0, ptr1, len1);
1025
+ var ptr3 = ret[0];
1026
+ var len3 = ret[1];
1027
+ if (ret[3]) {
1028
+ ptr3 = 0; len3 = 0;
1029
+ throw takeFromExternrefTable0(ret[2]);
1030
+ }
1031
+ deferred4_0 = ptr3;
1032
+ deferred4_1 = len3;
1033
+ return getStringFromWasm0(ptr3, len3);
1034
+ } finally {
1035
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1036
+ }
1037
+ }
1038
+
1039
+ /**
1040
+ * Sanitize an SVG document, the helper a host embedding SVG would otherwise
1041
+ * reimplement.
1042
+ *
1043
+ * `{ svg, ok }`. `ok` false means the input was not a single well-formed
1044
+ * `<svg>` root, and a caller must then show the SOURCE rather than the input:
1045
+ * `svg` carries nothing to display. Every option defaults to `false`, which is
1046
+ * the strict setting.
1047
+ * @param {string} source
1048
+ * @param {object | null} [options]
1049
+ * @returns {SanitizeResult}
1050
+ */
1051
+ export function sanitizeSvg(source, options) {
1052
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1053
+ const len0 = WASM_VECTOR_LEN;
1054
+ const ret = wasm.sanitizeSvg(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
1055
+ if (ret[2]) {
1056
+ throw takeFromExternrefTable0(ret[1]);
1057
+ }
1058
+ return takeFromExternrefTable0(ret[0]);
1059
+ }
1060
+
1061
+ /**
1062
+ * Write a provenance marker onto already-formatted Carve.
1063
+ *
1064
+ * The other half of `readStamp` and `needsReview`, which could read a marker
1065
+ * this package had no way to write. `generatedBy` is the engine identity a
1066
+ * host wants recorded, e.g. `"my-app 1.2"`; `form` is `"line"` (default) or
1067
+ * `"block"`. Same signature as carve-js `stampCarve`.
1068
+ *
1069
+ * The input is expected to be formatted already: this appends the marker and
1070
+ * replaces one the document carries, it does not canonicalize. `toCarve` is
1071
+ * the formatter.
1072
+ * @param {string} formatted
1073
+ * @param {string} generated_by
1074
+ * @param {string | null} [form]
1075
+ * @returns {string}
1076
+ */
1077
+ export function stampCarve(formatted, generated_by, form) {
1078
+ let deferred5_0;
1079
+ let deferred5_1;
1080
+ try {
1081
+ const ptr0 = passStringToWasm0(formatted, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1082
+ const len0 = WASM_VECTOR_LEN;
1083
+ const ptr1 = passStringToWasm0(generated_by, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1084
+ const len1 = WASM_VECTOR_LEN;
1085
+ var ptr2 = isLikeNone(form) ? 0 : passStringToWasm0(form, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1086
+ var len2 = WASM_VECTOR_LEN;
1087
+ const ret = wasm.stampCarve(ptr0, len0, ptr1, len1, ptr2, len2);
1088
+ var ptr4 = ret[0];
1089
+ var len4 = ret[1];
1090
+ if (ret[3]) {
1091
+ ptr4 = 0; len4 = 0;
1092
+ throw takeFromExternrefTable0(ret[2]);
1093
+ }
1094
+ deferred5_0 = ptr4;
1095
+ deferred5_1 = len4;
1096
+ return getStringFromWasm0(ptr4, len4);
1097
+ } finally {
1098
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
1099
+ }
1100
+ }
1101
+
1102
+ /**
1103
+ * @param {string} source
1104
+ * @returns {string}
1105
+ */
1106
+ export function toAnsi(source) {
1107
+ let deferred2_0;
1108
+ let deferred2_1;
1109
+ try {
1110
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1111
+ const len0 = WASM_VECTOR_LEN;
1112
+ const ret = wasm.toAnsi(ptr0, len0);
1113
+ deferred2_0 = ret[0];
1114
+ deferred2_1 = ret[1];
1115
+ return getStringFromWasm0(ret[0], ret[1]);
1116
+ } finally {
1117
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * Render to ANSI text with an options object. See
1123
+ * [`to_markdown_with_options`].
1124
+ * @param {string} source
1125
+ * @param {object | null} [options]
1126
+ * @returns {string}
1127
+ */
1128
+ export function toAnsiWithOptions(source, options) {
1129
+ let deferred3_0;
1130
+ let deferred3_1;
1131
+ try {
1132
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1133
+ const len0 = WASM_VECTOR_LEN;
1134
+ const ret = wasm.toAnsiWithOptions(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
1135
+ var ptr2 = ret[0];
1136
+ var len2 = ret[1];
1137
+ if (ret[3]) {
1138
+ ptr2 = 0; len2 = 0;
1139
+ throw takeFromExternrefTable0(ret[2]);
1140
+ }
1141
+ deferred3_0 = ptr2;
1142
+ deferred3_1 = len2;
1143
+ return getStringFromWasm0(ptr2, len2);
1144
+ } finally {
1145
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
256
1146
  }
257
1147
  }
258
1148
 
259
1149
  /**
260
- * Read a document's provenance marker: `{ version, generatedBy }`, or `null`.
261
1150
  * @param {string} source
262
- * @returns {Stamp | null}
1151
+ * @param {boolean | null} [strict]
1152
+ * @param {number | null} [maximum]
1153
+ * @returns {any}
263
1154
  */
264
- export function readStamp(source) {
1155
+ export function toAnsiWithReport(source, strict, maximum) {
265
1156
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
266
1157
  const len0 = WASM_VECTOR_LEN;
267
- const ret = wasm.readStamp(ptr0, len0);
1158
+ const ret = wasm.toAnsiWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
268
1159
  if (ret[2]) {
269
1160
  throw takeFromExternrefTable0(ret[1]);
270
1161
  }
@@ -275,13 +1166,13 @@ export function readStamp(source) {
275
1166
  * @param {string} source
276
1167
  * @returns {string}
277
1168
  */
278
- export function toAnsi(source) {
1169
+ export function toCarve(source) {
279
1170
  let deferred2_0;
280
1171
  let deferred2_1;
281
1172
  try {
282
1173
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283
1174
  const len0 = WASM_VECTOR_LEN;
284
- const ret = wasm.toAnsi(ptr0, len0);
1175
+ const ret = wasm.toCarve(ptr0, len0);
285
1176
  deferred2_0 = ret[0];
286
1177
  deferred2_1 = ret[1];
287
1178
  return getStringFromWasm0(ret[0], ret[1]);
@@ -291,15 +1182,14 @@ export function toAnsi(source) {
291
1182
  }
292
1183
 
293
1184
  /**
1185
+ * Preview canonical formatting as a source-preserving patch.
294
1186
  * @param {string} source
295
- * @param {boolean | null} [strict]
296
- * @param {number | null} [maximum]
297
- * @returns {any}
1187
+ * @returns {SourcePatch}
298
1188
  */
299
- export function toAnsiWithReport(source, strict, maximum) {
1189
+ export function toCarvePatch(source) {
300
1190
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
301
1191
  const len0 = WASM_VECTOR_LEN;
302
- const ret = wasm.toAnsiWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
1192
+ const ret = wasm.toCarvePatch(ptr0, len0);
303
1193
  if (ret[2]) {
304
1194
  throw takeFromExternrefTable0(ret[1]);
305
1195
  }
@@ -307,21 +1197,32 @@ export function toAnsiWithReport(source, strict, maximum) {
307
1197
  }
308
1198
 
309
1199
  /**
1200
+ * Write canonical Carve with an options object.
1201
+ *
1202
+ * `profile` is the only option this target reads; see
1203
+ * [`to_markdown_with_options`] for why.
310
1204
  * @param {string} source
1205
+ * @param {object | null} [options]
311
1206
  * @returns {string}
312
1207
  */
313
- export function toCarve(source) {
314
- let deferred2_0;
315
- let deferred2_1;
1208
+ export function toCarveWithOptions(source, options) {
1209
+ let deferred3_0;
1210
+ let deferred3_1;
316
1211
  try {
317
1212
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
318
1213
  const len0 = WASM_VECTOR_LEN;
319
- const ret = wasm.toCarve(ptr0, len0);
320
- deferred2_0 = ret[0];
321
- deferred2_1 = ret[1];
322
- return getStringFromWasm0(ret[0], ret[1]);
1214
+ const ret = wasm.toCarveWithOptions(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
1215
+ var ptr2 = ret[0];
1216
+ var len2 = ret[1];
1217
+ if (ret[3]) {
1218
+ ptr2 = 0; len2 = 0;
1219
+ throw takeFromExternrefTable0(ret[2]);
1220
+ }
1221
+ deferred3_0 = ptr2;
1222
+ deferred3_1 = len2;
1223
+ return getStringFromWasm0(ptr2, len2);
323
1224
  } finally {
324
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1225
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
325
1226
  }
326
1227
  }
327
1228
 
@@ -456,11 +1357,22 @@ export function toHtmlFull(source, symbols) {
456
1357
  * * `lowercaseHeadingIds` (default `false`) and `asciiHeadingIds`
457
1358
  * (`"off"` (default), `"fold"`, `"strict"`) - the slug policy, for a host
458
1359
  * whose anchors have to match another generator's.
1360
+ * * `mentionUrl` and `tagUrl` - URL templates for `@mention` and `#tag`.
1361
+ * Without them both render as inert spans, which is why a host that wants
1362
+ * them linked has to say where to. The token name is percent-encoded into
1363
+ * `{name}` - `{user}` works too for a mention - and the result goes through
1364
+ * the same URL sanitizer as an authored link. These are the HOST's
1365
+ * configuration, not the document's: the template is trusted, the name
1366
+ * substituted into it is not.
459
1367
  *
460
1368
  * An unrecognized key is ignored: the object is configuration, and a caller
461
1369
  * who mistypes one deserves the render to still work. A wrong TYPE on a key
462
1370
  * that is recognized does throw, because that changes behavior silently.
463
1371
  *
1372
+ * `renderers` is the one recognized key this entry point refuses, because a
1373
+ * render callback can fail and a bare string has nowhere to report that. Use
1374
+ * [`to_html_with_renderers`].
1375
+ *
464
1376
  * Turning sections off changes nothing else. Ids, collision dedup, `</#id>`
465
1377
  * crossrefs, implicit `[Heading][]` references and heading numbering all
466
1378
  * resolve against the slug rather than the element carrying it, and the
@@ -491,6 +1403,77 @@ export function toHtmlWithOptions(source, options) {
491
1403
  }
492
1404
  }
493
1405
 
1406
+ /**
1407
+ * Render with a build-time math renderer, the option `mode: "static"` needs.
1408
+ *
1409
+ * Static output carries no client scripts, so a formula it contains has to be
1410
+ * rendered while the HTML is being written. `renderers.math` is the callback
1411
+ * the engine calls for each ``` ```math ``` fence, with the TeX source and a
1412
+ * display flag; KaTeX's `renderToString` has that exact shape.
1413
+ *
1414
+ * ```js
1415
+ * toHtmlWithRenderers(src, {
1416
+ * mode: 'static',
1417
+ * extensions: ['math-block'],
1418
+ * renderers: { math: (tex, display) => katex.renderToString(tex, { displayMode: display }) },
1419
+ * })
1420
+ * // { html: '…', rendererErrors: [] }
1421
+ * ```
1422
+ *
1423
+ * SECURITY: what the callback returns is inserted as **TRUSTED RAW HTML**, the
1424
+ * same trust class as a `symbols` value. The difference worth stating: a symbol
1425
+ * value is host configuration keyed by a NAME, while a renderer is host
1426
+ * configuration that is HANDED DOCUMENT CONTENT and typically echoes some of it
1427
+ * back. A host rendering documents it did not author is accepting whatever its
1428
+ * renderer makes of that input, so the escaping is the renderer's job.
1429
+ *
1430
+ * The engine consults the renderer only under `mode: "static"`; interactive
1431
+ * output keeps the `\[…\]` source for the client to typeset, and so does a
1432
+ * static render with no renderer supplied.
1433
+ *
1434
+ * The callback must be SYNCHRONOUS. wasm-bindgen cannot await across it, so an
1435
+ * `async` renderer returns a Promise the engine has no way to resolve; that is
1436
+ * recorded as a failure rather than stringified into the document.
1437
+ *
1438
+ * `renderers.diagrams` is the same callback one level down, keyed by the
1439
+ * fence's css class: `{ mermaid: (source) => html }`. A host that renders its
1440
+ * diagrams beforehand passes the lookup in that one line -
1441
+ * `(source) => prerendered.get(source)`. Mermaid itself cannot be passed,
1442
+ * because its `render` returns a Promise from v10 on.
1443
+ *
1444
+ * ```js
1445
+ * toHtmlWithRenderers(src, {
1446
+ * mode: 'static',
1447
+ * extensions: ['fenced-render'],
1448
+ * renderers: { diagrams: { mermaid: (source) => prerendered.get(source) } },
1449
+ * })
1450
+ * ```
1451
+ *
1452
+ * A diagram key the document never uses renders nothing and reports nothing.
1453
+ * So does a fence whose class the caller did not configure: the engine
1454
+ * degrades it to an escaped source block, and this binding never sees the
1455
+ * node.
1456
+ *
1457
+ * A callback that throws, or returns anything other than a string, does not
1458
+ * abort the render: the node it was called for emits nothing and the failure
1459
+ * is reported in `rendererErrors`, with `renderer` naming the css class.
1460
+ * This entry point exists because [`to_html_with_options`] returns a bare
1461
+ * string with nowhere to put that, and so it rejects `renderers` rather than
1462
+ * dropping the failures.
1463
+ * @param {string} source
1464
+ * @param {object | null} [options]
1465
+ * @returns {StaticRenderResult}
1466
+ */
1467
+ export function toHtmlWithRenderers(source, options) {
1468
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1469
+ const len0 = WASM_VECTOR_LEN;
1470
+ const ret = wasm.toHtmlWithRenderers(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
1471
+ if (ret[2]) {
1472
+ throw takeFromExternrefTable0(ret[1]);
1473
+ }
1474
+ return takeFromExternrefTable0(ret[0]);
1475
+ }
1476
+
494
1477
  /**
495
1478
  * @param {string} source
496
1479
  * @param {boolean | null} [strict]
@@ -566,6 +1549,52 @@ export function toMarkdown(source) {
566
1549
  }
567
1550
  }
568
1551
 
1552
+ /**
1553
+ * Render to Markdown with the same options object as
1554
+ * [`to_html_with_options`].
1555
+ *
1556
+ * `profile` is why this exists. Without it a host can hold an untrusted
1557
+ * document to a profile on the way to HTML and not on the way to Markdown,
1558
+ * out of one package: the max-length bound, the denied constructs and the
1559
+ * link policy were all unreachable here. A document the profile rejects
1560
+ * throws a `ProfileViolationError` rather than resolving to an empty string.
1561
+ *
1562
+ * What these targets read is narrower than HTML's list: `profile` and
1563
+ * `smartTypography` change the output and extensions run, while `symbols`
1564
+ * (markup-carve/carve-rs#1668), `labels`, `sections`, `sourceLine`, `mode` and
1565
+ * the heading-id switches are HTML-side concerns the engine's other renderers
1566
+ * do not consult. `renderers` is refused for the reason
1567
+ * [`to_html_with_options`] refuses it.
1568
+ *
1569
+ * [`to_carve_with_options`] is narrower again and reads `profile` alone: the
1570
+ * engine's canonical writer is parse-only by contract, so extensions and
1571
+ * `smartTypography` are inert there. They are accepted rather than refused
1572
+ * because one options object is meant to serve every target.
1573
+ * @param {string} source
1574
+ * @param {object | null} [options]
1575
+ * @returns {string}
1576
+ */
1577
+ export function toMarkdownWithOptions(source, options) {
1578
+ let deferred3_0;
1579
+ let deferred3_1;
1580
+ try {
1581
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1582
+ const len0 = WASM_VECTOR_LEN;
1583
+ const ret = wasm.toMarkdownWithOptions(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
1584
+ var ptr2 = ret[0];
1585
+ var len2 = ret[1];
1586
+ if (ret[3]) {
1587
+ ptr2 = 0; len2 = 0;
1588
+ throw takeFromExternrefTable0(ret[2]);
1589
+ }
1590
+ deferred3_0 = ptr2;
1591
+ deferred3_1 = len2;
1592
+ return getStringFromWasm0(ptr2, len2);
1593
+ } finally {
1594
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1595
+ }
1596
+ }
1597
+
569
1598
  /**
570
1599
  * @param {string} source
571
1600
  * @param {boolean | null} [strict]
@@ -601,6 +1630,34 @@ export function toPlainText(source) {
601
1630
  }
602
1631
  }
603
1632
 
1633
+ /**
1634
+ * Render to plain text with an options object. See
1635
+ * [`to_markdown_with_options`].
1636
+ * @param {string} source
1637
+ * @param {object | null} [options]
1638
+ * @returns {string}
1639
+ */
1640
+ export function toPlainTextWithOptions(source, options) {
1641
+ let deferred3_0;
1642
+ let deferred3_1;
1643
+ try {
1644
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1645
+ const len0 = WASM_VECTOR_LEN;
1646
+ const ret = wasm.toPlainTextWithOptions(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
1647
+ var ptr2 = ret[0];
1648
+ var len2 = ret[1];
1649
+ if (ret[3]) {
1650
+ ptr2 = 0; len2 = 0;
1651
+ throw takeFromExternrefTable0(ret[2]);
1652
+ }
1653
+ deferred3_0 = ptr2;
1654
+ deferred3_1 = len2;
1655
+ return getStringFromWasm0(ptr2, len2);
1656
+ } finally {
1657
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1658
+ }
1659
+ }
1660
+
604
1661
  /**
605
1662
  * @param {string} source
606
1663
  * @param {boolean | null} [strict]
@@ -617,6 +1674,33 @@ export function toPlainTextWithReport(source, strict, maximum) {
617
1674
  return takeFromExternrefTable0(ret[0]);
618
1675
  }
619
1676
 
1677
+ /**
1678
+ * Convert Carve source to the ProseMirror document shape.
1679
+ *
1680
+ * ProseMirror runs in a browser and nowhere else, so this is the one engine
1681
+ * capability whose whole audience sits behind a WASM binding. Without it a host
1682
+ * wiring a Carve editor either round-trips to a server or reimplements the node
1683
+ * mapping in JS, where it drifts from the engine's.
1684
+ *
1685
+ * Returns `{ json, dropped, degraded }`. `json` is the ProseMirror document as
1686
+ * a JSON string, the same choice `parseJson` makes and for the same reason.
1687
+ * The two maps say what the ProseMirror model could not hold: `dropped` where
1688
+ * the content is gone, `degraded` where the text survives without its node
1689
+ * type. A silent conversion is the degradation shape `lintCarve` exists to
1690
+ * avoid.
1691
+ * @param {string} source
1692
+ * @returns {ProseMirrorResult}
1693
+ */
1694
+ export function toProseMirror(source) {
1695
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1696
+ const len0 = WASM_VECTOR_LEN;
1697
+ const ret = wasm.toProseMirror(ptr0, len0);
1698
+ if (ret[2]) {
1699
+ throw takeFromExternrefTable0(ret[1]);
1700
+ }
1701
+ return takeFromExternrefTable0(ret[0]);
1702
+ }
1703
+
620
1704
  /**
621
1705
  * @returns {string}
622
1706
  */
@@ -632,19 +1716,82 @@ export function version() {
632
1716
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
633
1717
  }
634
1718
  }
1719
+ export function __wbg_Error_2e59b1b37a9a34c3(arg0, arg1) {
1720
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1721
+ return ret;
1722
+ }
1723
+ export function __wbg_Number_e6ffdb596c888833(arg0) {
1724
+ const ret = Number(arg0);
1725
+ return ret;
1726
+ }
1727
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
1728
+ const ret = String(arg1);
1729
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1730
+ const len1 = WASM_VECTOR_LEN;
1731
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1732
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1733
+ }
1734
+ export function __wbg___wbindgen_bigint_get_as_i64_2c5082002e4826e2(arg0, arg1) {
1735
+ const v = arg1;
1736
+ const ret = typeof(v) === 'bigint' ? v : undefined;
1737
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1738
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1739
+ }
635
1740
  export function __wbg___wbindgen_boolean_get_a86c216575a75c30(arg0) {
636
1741
  const v = arg0;
637
1742
  const ret = typeof(v) === 'boolean' ? v : undefined;
638
1743
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
639
1744
  }
1745
+ export function __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57(arg0, arg1) {
1746
+ const ret = debugString(arg1);
1747
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1748
+ const len1 = WASM_VECTOR_LEN;
1749
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1750
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1751
+ }
1752
+ export function __wbg___wbindgen_in_4bd7a57e54337366(arg0, arg1) {
1753
+ const ret = arg0 in arg1;
1754
+ return ret;
1755
+ }
1756
+ export function __wbg___wbindgen_is_bigint_6c98f7e945dacdde(arg0) {
1757
+ const ret = typeof(arg0) === 'bigint';
1758
+ return ret;
1759
+ }
1760
+ export function __wbg___wbindgen_is_function_49868bde5eb1e745(arg0) {
1761
+ const ret = typeof(arg0) === 'function';
1762
+ return ret;
1763
+ }
640
1764
  export function __wbg___wbindgen_is_null_344c8750a8525473(arg0) {
641
1765
  const ret = arg0 === null;
642
1766
  return ret;
643
1767
  }
1768
+ export function __wbg___wbindgen_is_object_40c5a80572e8f9d3(arg0) {
1769
+ const val = arg0;
1770
+ const ret = typeof(val) === 'object' && val !== null;
1771
+ return ret;
1772
+ }
1773
+ export function __wbg___wbindgen_is_string_b29b5c5a8065ba1a(arg0) {
1774
+ const ret = typeof(arg0) === 'string';
1775
+ return ret;
1776
+ }
644
1777
  export function __wbg___wbindgen_is_undefined_c0cca72b82b86f4d(arg0) {
645
1778
  const ret = arg0 === undefined;
646
1779
  return ret;
647
1780
  }
1781
+ export function __wbg___wbindgen_jsval_eq_7d430e744a913d26(arg0, arg1) {
1782
+ const ret = arg0 === arg1;
1783
+ return ret;
1784
+ }
1785
+ export function __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944(arg0, arg1) {
1786
+ const ret = arg0 == arg1;
1787
+ return ret;
1788
+ }
1789
+ export function __wbg___wbindgen_number_get_7579aab02a8a620c(arg0, arg1) {
1790
+ const obj = arg1;
1791
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1792
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1793
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1794
+ }
648
1795
  export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
649
1796
  const obj = arg1;
650
1797
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -656,6 +1803,26 @@ export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
656
1803
  export function __wbg___wbindgen_throw_81fc77679af83bc6(arg0, arg1) {
657
1804
  throw new Error(getStringFromWasm0(arg0, arg1));
658
1805
  }
1806
+ export function __wbg___wbindgen_typeof_ec2e006152efc95c(arg0) {
1807
+ const ret = typeof arg0;
1808
+ return ret;
1809
+ }
1810
+ export function __wbg_call_368fa9c372d473ba() { return handleError(function (arg0, arg1, arg2, arg3) {
1811
+ const ret = arg0.call(arg1, arg2, arg3);
1812
+ return ret;
1813
+ }, arguments); }
1814
+ export function __wbg_call_7f2987183bb62793() { return handleError(function (arg0, arg1) {
1815
+ const ret = arg0.call(arg1);
1816
+ return ret;
1817
+ }, arguments); }
1818
+ export function __wbg_call_d578befcc3145dee() { return handleError(function (arg0, arg1, arg2) {
1819
+ const ret = arg0.call(arg1, arg2);
1820
+ return ret;
1821
+ }, arguments); }
1822
+ export function __wbg_done_547d467e97529006(arg0) {
1823
+ const ret = arg0.done;
1824
+ return ret;
1825
+ }
659
1826
  export function __wbg_entries_616b1a459b85be0b(arg0) {
660
1827
  const ret = Object.entries(arg0);
661
1828
  return ret;
@@ -672,6 +1839,10 @@ export function __wbg_get_4848e350b40afc16(arg0, arg1) {
672
1839
  const ret = arg0[arg1 >>> 0];
673
1840
  return ret;
674
1841
  }
1842
+ export function __wbg_get_ed0642c4b9d31ddf() { return handleError(function (arg0, arg1) {
1843
+ const ret = Reflect.get(arg0, arg1);
1844
+ return ret;
1845
+ }, arguments); }
675
1846
  export function __wbg_get_f96702c6245e4ef9() { return handleError(function (arg0, arg1) {
676
1847
  const ret = Reflect.get(arg0, arg1);
677
1848
  return ret;
@@ -680,6 +1851,30 @@ export function __wbg_get_unchecked_7d7babe32e9e6a54(arg0, arg1) {
680
1851
  const ret = arg0[arg1 >>> 0];
681
1852
  return ret;
682
1853
  }
1854
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
1855
+ const ret = arg0[arg1];
1856
+ return ret;
1857
+ }
1858
+ export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
1859
+ let result;
1860
+ try {
1861
+ result = arg0 instanceof ArrayBuffer;
1862
+ } catch (_) {
1863
+ result = false;
1864
+ }
1865
+ const ret = result;
1866
+ return ret;
1867
+ }
1868
+ export function __wbg_instanceof_Error_e3390d6805733dad(arg0) {
1869
+ let result;
1870
+ try {
1871
+ result = arg0 instanceof Error;
1872
+ } catch (_) {
1873
+ result = false;
1874
+ }
1875
+ const ret = result;
1876
+ return ret;
1877
+ }
683
1878
  export function __wbg_instanceof_Map_a10a2795ef4bfe97(arg0) {
684
1879
  let result;
685
1880
  try {
@@ -700,14 +1895,50 @@ export function __wbg_instanceof_Object_72ee0c53dd8f0726(arg0) {
700
1895
  const ret = result;
701
1896
  return ret;
702
1897
  }
1898
+ export function __wbg_instanceof_Promise_95d523058012a13d(arg0) {
1899
+ let result;
1900
+ try {
1901
+ result = arg0 instanceof Promise;
1902
+ } catch (_) {
1903
+ result = false;
1904
+ }
1905
+ const ret = result;
1906
+ return ret;
1907
+ }
1908
+ export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
1909
+ let result;
1910
+ try {
1911
+ result = arg0 instanceof Uint8Array;
1912
+ } catch (_) {
1913
+ result = false;
1914
+ }
1915
+ const ret = result;
1916
+ return ret;
1917
+ }
703
1918
  export function __wbg_isArray_db61795ad004c139(arg0) {
704
1919
  const ret = Array.isArray(arg0);
705
1920
  return ret;
706
1921
  }
1922
+ export function __wbg_isSafeInteger_ea83862ba994770c(arg0) {
1923
+ const ret = Number.isSafeInteger(arg0);
1924
+ return ret;
1925
+ }
1926
+ export function __wbg_iterator_de403ef31815a3e6() {
1927
+ const ret = Symbol.iterator;
1928
+ return ret;
1929
+ }
1930
+ export function __wbg_length_0c32cb8543c8e4c8(arg0) {
1931
+ const ret = arg0.length;
1932
+ return ret;
1933
+ }
707
1934
  export function __wbg_length_6e821edde497a532(arg0) {
708
1935
  const ret = arg0.length;
709
1936
  return ret;
710
1937
  }
1938
+ export function __wbg_message_7367f8c7d0fa1589(arg0) {
1939
+ const ret = arg0.message;
1940
+ return ret;
1941
+ }
711
1942
  export function __wbg_new_47dfee3855dec446(arg0, arg1) {
712
1943
  const ret = new TypeError(getStringFromWasm0(arg0, arg1));
713
1944
  return ret;
@@ -716,6 +1947,10 @@ export function __wbg_new_4f9fafbb3909af72() {
716
1947
  const ret = new Object();
717
1948
  return ret;
718
1949
  }
1950
+ export function __wbg_new_a560378ea1240b14(arg0) {
1951
+ const ret = new Uint8Array(arg0);
1952
+ return ret;
1953
+ }
719
1954
  export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
720
1955
  const ret = new Error(getStringFromWasm0(arg0, arg1));
721
1956
  return ret;
@@ -724,14 +1959,31 @@ export function __wbg_new_f3c9df4f38f3f798() {
724
1959
  const ret = new Array();
725
1960
  return ret;
726
1961
  }
1962
+ export function __wbg_next_01132ed6134b8ef5(arg0) {
1963
+ const ret = arg0.next;
1964
+ return ret;
1965
+ }
1966
+ export function __wbg_next_b3713ec761a9dbfd() { return handleError(function (arg0) {
1967
+ const ret = arg0.next();
1968
+ return ret;
1969
+ }, arguments); }
727
1970
  export function __wbg_parse_545d11396395fbbd() { return handleError(function (arg0, arg1) {
728
1971
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
729
1972
  return ret;
730
1973
  }, arguments); }
1974
+ export function __wbg_prototypesetcall_3e05eb9545565046(arg0, arg1, arg2) {
1975
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1976
+ }
731
1977
  export function __wbg_push_6bdbc990be5ac37b(arg0, arg1) {
732
1978
  const ret = arg0.push(arg1);
733
1979
  return ret;
734
1980
  }
1981
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
1982
+ arg0[arg1] = arg2;
1983
+ }
1984
+ export function __wbg_set_6c60b2e8ad0e9383(arg0, arg1, arg2) {
1985
+ arg0[arg1 >>> 0] = arg2;
1986
+ }
735
1987
  export function __wbg_set_8ee2d34facb8466e() { return handleError(function (arg0, arg1, arg2) {
736
1988
  const ret = Reflect.set(arg0, arg1, arg2);
737
1989
  return ret;
@@ -739,6 +1991,14 @@ export function __wbg_set_8ee2d34facb8466e() { return handleError(function (arg0
739
1991
  export function __wbg_set_name_ab9c98596fd7310a(arg0, arg1, arg2) {
740
1992
  arg0.name = getStringFromWasm0(arg1, arg2);
741
1993
  }
1994
+ export function __wbg_stringify_a2c39d991e1bf91d() { return handleError(function (arg0) {
1995
+ const ret = JSON.stringify(arg0);
1996
+ return ret;
1997
+ }, arguments); }
1998
+ export function __wbg_value_7f6052747ccf940f(arg0) {
1999
+ const ret = arg0.value;
2000
+ return ret;
2001
+ }
742
2002
  export function __wbindgen_cast_0000000000000001(arg0) {
743
2003
  // Cast intrinsic for `F64 -> Externref`.
744
2004
  const ret = arg0;
@@ -749,6 +2009,11 @@ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
749
2009
  const ret = getStringFromWasm0(arg0, arg1);
750
2010
  return ret;
751
2011
  }
2012
+ export function __wbindgen_cast_0000000000000003(arg0) {
2013
+ // Cast intrinsic for `U64 -> Externref`.
2014
+ const ret = BigInt.asUintN(64, arg0);
2015
+ return ret;
2016
+ }
752
2017
  export function __wbindgen_init_externref_table() {
753
2018
  const table = wasm.__wbindgen_externrefs;
754
2019
  const offset = table.grow(4);
@@ -764,6 +2029,71 @@ function addToExternrefTable0(obj) {
764
2029
  return idx;
765
2030
  }
766
2031
 
2032
+ function debugString(val) {
2033
+ // primitive types
2034
+ const type = typeof val;
2035
+ if (type == 'number' || type == 'boolean' || val == null) {
2036
+ return `${val}`;
2037
+ }
2038
+ if (type == 'string') {
2039
+ return `"${val}"`;
2040
+ }
2041
+ if (type == 'symbol') {
2042
+ const description = val.description;
2043
+ if (description == null) {
2044
+ return 'Symbol';
2045
+ } else {
2046
+ return `Symbol(${description})`;
2047
+ }
2048
+ }
2049
+ if (type == 'function') {
2050
+ const name = val.name;
2051
+ if (typeof name == 'string' && name.length > 0) {
2052
+ return `Function(${name})`;
2053
+ } else {
2054
+ return 'Function';
2055
+ }
2056
+ }
2057
+ // objects
2058
+ if (Array.isArray(val)) {
2059
+ const length = val.length;
2060
+ let debug = '[';
2061
+ if (length > 0) {
2062
+ debug += debugString(val[0]);
2063
+ }
2064
+ for(let i = 1; i < length; i++) {
2065
+ debug += ', ' + debugString(val[i]);
2066
+ }
2067
+ debug += ']';
2068
+ return debug;
2069
+ }
2070
+ // Test for built-in
2071
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2072
+ let className;
2073
+ if (builtInMatches && builtInMatches.length > 1) {
2074
+ className = builtInMatches[1];
2075
+ } else {
2076
+ // Failed to match the standard '[object ClassName]'
2077
+ return toString.call(val);
2078
+ }
2079
+ if (className == 'Object') {
2080
+ // we're a user defined class or Object
2081
+ // JSON.stringify avoids problems with cycles, and is generally much
2082
+ // easier than looping through ownProperties of `val`.
2083
+ try {
2084
+ return 'Object(' + JSON.stringify(val) + ')';
2085
+ } catch (_) {
2086
+ return 'Object';
2087
+ }
2088
+ }
2089
+ // errors
2090
+ if (val instanceof Error) {
2091
+ return `${val.name}: ${val.message}\n${val.stack}`;
2092
+ }
2093
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2094
+ return className;
2095
+ }
2096
+
767
2097
  function getArrayJsValueFromWasm0(ptr, len) {
768
2098
  ptr = ptr >>> 0;
769
2099
  const mem = getDataViewMemory0();
@@ -775,6 +2105,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
775
2105
  return result;
776
2106
  }
777
2107
 
2108
+ function getArrayU8FromWasm0(ptr, len) {
2109
+ ptr = ptr >>> 0;
2110
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2111
+ }
2112
+
778
2113
  let cachedDataViewMemory0 = null;
779
2114
  function getDataViewMemory0() {
780
2115
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {