@quillmark/wasm 0.81.0 → 0.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,5 @@
1
1
  /**
2
2
  * Typed in-memory Quillmark document.
3
- *
4
- * Created via `Document.fromMarkdown(markdown)`. Exposes:
5
- * - `quillRef` (string)
6
- * - `frontmatter` (JS object/Record)
7
- * - `body` (string)
8
- * - `cards` (array of Card objects)
9
- * - `warnings` (array of Diagnostic objects)
10
- *
11
- * `toMarkdown()` emits canonical Quillmark Markdown that round-trips back to
12
- * an equal `Document` by value and by type.
13
3
  */
14
4
  export class Document {
15
5
  static __wrap(ptr) {
@@ -30,10 +20,7 @@ export class Document {
30
20
  wasm.__wbg_document_free(ptr, 0);
31
21
  }
32
22
  /**
33
- * Number of composable cards (excludes the main card).
34
- *
35
- * O(1). Use this to validate indices before calling card mutators
36
- * instead of allocating the full `cards` array.
23
+ * Number of composable cards (excludes the main card). O(1).
37
24
  * @returns {number}
38
25
  */
39
26
  get cardCount() {
@@ -41,7 +28,6 @@ export class Document {
41
28
  return ret >>> 0;
42
29
  }
43
30
  /**
44
- * Ordered list of composable card blocks as typed `Card` objects.
45
31
  * @returns {Card[]}
46
32
  */
47
33
  get cards() {
@@ -49,12 +35,6 @@ export class Document {
49
35
  return takeObject(ret);
50
36
  }
51
37
  /**
52
- * Return a fresh `Document` handle with the same parse state.
53
- *
54
- * Mutations on the returned handle do not affect the original and
55
- * vice versa. Parse-time warnings are snapshotted alongside the
56
- * document — they describe the original parse, not the edit
57
- * history of either handle.
58
38
  * @returns {Document}
59
39
  */
60
40
  clone() {
@@ -63,16 +43,8 @@ export class Document {
63
43
  }
64
44
  /**
65
45
  * Schema version this build writes via [`toJson`](Document::to_json).
66
- *
67
- * Compare a payload's [`schemaVersionOf`](Document::schema_version_of)
68
- * against this to detect mismatches before calling
69
- * [`fromJson`](Document::from_json).
70
- *
71
- * The tag tracks the **`Document` model version** — the crate version
72
- * at which the wire format was last changed — not the running crate
73
- * version. Every patch and minor release within the same model
74
- * generation returns the same string; the tag advances only when a
75
- * new schema variant ships.
46
+ * Tracks the `Document` model version (not the running crate version):
47
+ * the tag advances only when the wire format changes, not on every release.
76
48
  * @returns {string}
77
49
  */
78
50
  static currentSchemaVersion() {
@@ -92,14 +64,8 @@ export class Document {
92
64
  }
93
65
  }
94
66
  /**
95
- * Structural equality against another `Document`.
96
- *
97
- * Compares `main` and `cards` by value (matching core's [`PartialEq`]).
98
- * Parse-time `warnings` are intentionally excluded — they describe the
99
- * source text, not the document's content.
100
- *
101
- * Use this to debounce upstream prop updates: keep the last parsed
102
- * `Document` and compare instead of re-parsing on every keystroke.
67
+ * Structural equality (parse-time `warnings` excluded). Use to debounce
68
+ * upstream prop updates instead of re-parsing on every keystroke.
103
69
  * @param {Document} other
104
70
  * @returns {boolean}
105
71
  */
@@ -109,19 +75,12 @@ export class Document {
109
75
  return ret !== 0;
110
76
  }
111
77
  /**
112
- * Reconstruct a `Document` from its versioned storage DTO string.
113
- *
114
- * `json` must be a string produced by [`toJson`](Document::to_json)
115
- * the versioned storage DTO. Parsing and schema dispatch happen inside
116
- * the module via `serde_json`; the JS `JSON` global is not involved.
117
- * Unknown `schema` tags are rejected.
78
+ * Reconstruct a `Document` from a versioned storage DTO string produced
79
+ * by [`toJson`](Document::to_json). Unknown `schema` tags are rejected.
80
+ * The result carries no parse-time warnings (`.warnings` is always empty).
118
81
  *
119
- * The reconstructed document carries no parse-time warnings the DTO
120
- * describes content, not source text — so `.warnings` is always empty.
121
- *
122
- * Throws a JS `Error` if `json` is not a valid storage DTO (malformed
123
- * JSON, unknown `schema`, missing fields, or an unparseable quill
124
- * reference).
82
+ * Throws if `json` is not a valid storage DTO (malformed JSON, unknown
83
+ * `schema`, missing fields, or unparseable quill reference).
125
84
  * @param {string} json
126
85
  * @returns {Document}
127
86
  */
@@ -143,10 +102,7 @@ export class Document {
143
102
  }
144
103
  }
145
104
  /**
146
- * Parse markdown into a typed Document.
147
- *
148
- * Returns the document with any parse-time warnings accessible via `.warnings`.
149
- * Throws on parse errors.
105
+ * Parse markdown into a typed Document. Throws on parse errors.
150
106
  * @param {string} markdown
151
107
  * @returns {Document}
152
108
  */
@@ -168,11 +124,7 @@ export class Document {
168
124
  }
169
125
  }
170
126
  /**
171
- * Insert a card at the given index.
172
- *
173
- * `index` must be in `0..=cards.length`. Out-of-range throws an `Error`.
174
- *
175
- * Mutators never modify `warnings`.
127
+ * Insert a card at `index` (must be in `0..=cards.length`).
176
128
  * @param {number} index
177
129
  * @param {CardInput} card
178
130
  */
@@ -190,13 +142,8 @@ export class Document {
190
142
  }
191
143
  }
192
144
  /**
193
- * The document's main (entry) card.
194
- *
195
- * Carries the QUILL sentinel, the document-level frontmatter, and the
196
- * global body. Frontmatter/body reads and mutations go through this
197
- * handle — there are no document-level shortcuts after the rework.
198
- *
199
- * Allocates and serializes on each call — cache locally if read in a hot loop.
145
+ * The document's main (entry) card. Allocates and serializes on each
146
+ * call — cache locally if read in a hot loop.
200
147
  * @returns {Card}
201
148
  */
202
149
  get main() {
@@ -204,12 +151,7 @@ export class Document {
204
151
  return takeObject(ret);
205
152
  }
206
153
  /**
207
- * Move the card at `from` to position `to`.
208
- *
209
- * `from == to` is a no-op. Both indices must be in `0..cards.length`.
210
- * Out-of-range throws an `Error`.
211
- *
212
- * Mutators never modify `warnings`.
154
+ * Move the card at `from` to position `to`. `from == to` is a no-op.
213
155
  * @param {number} from
214
156
  * @param {number} to
215
157
  */
@@ -228,13 +170,7 @@ export class Document {
228
170
  }
229
171
  /**
230
172
  * Append a card to the end of the card list.
231
- *
232
- * `card` must be a JS object with a `tag` string field and optional
233
- * `fields` (object) and `body` (string).
234
- *
235
- * Throws an `Error` if `card.tag` is not a valid tag name.
236
- *
237
- * Mutators never modify `warnings`.
173
+ * Throws if `card.kind` is not a valid kind name.
238
174
  * @param {CardInput} card
239
175
  */
240
176
  pushCard(card) {
@@ -251,7 +187,6 @@ export class Document {
251
187
  }
252
188
  }
253
189
  /**
254
- * The QUILL reference string (e.g. `"usaf_memo@0.1"`).
255
190
  * @returns {string}
256
191
  */
257
192
  get quillRef() {
@@ -271,9 +206,6 @@ export class Document {
271
206
  }
272
207
  }
273
208
  /**
274
- * Remove the card at `index` and return it, or `undefined` if out of range.
275
- *
276
- * Mutators never modify `warnings`.
277
209
  * @param {number} index
278
210
  * @returns {Card | undefined}
279
211
  */
@@ -282,13 +214,8 @@ export class Document {
282
214
  return takeObject(ret);
283
215
  }
284
216
  /**
285
- * Remove a frontmatter field on the card at `index`, returning the
286
- * removed value or `undefined` if the field was absent.
287
- *
288
- * Throws if `index` is out of range, `name` is reserved, or `name` does
289
- * not match `[a-z_][a-z0-9_]*`.
290
- *
291
- * Mutators never modify `warnings`.
217
+ * Remove a field on the card at `index`. Returns the removed value or
218
+ * `undefined`. Throws if `index` is out of range or `name` is invalid.
292
219
  * @param {number} index
293
220
  * @param {string} name
294
221
  * @returns {any}
@@ -311,14 +238,8 @@ export class Document {
311
238
  }
312
239
  }
313
240
  /**
314
- * Remove a frontmatter field on the main card, returning the removed value or `undefined`.
315
- *
316
- * Throws an `Error` whose message includes the `EditError` variant name
317
- * and details if `name` is reserved (`BODY`, `CARDS`, `QUILL`, `CARD`)
318
- * or does not match `[a-z_][a-z0-9_]*`. Absence of an otherwise-valid
319
- * name returns `undefined`.
320
- *
321
- * Mutators never modify `warnings`.
241
+ * Remove a payload field on the main card, returning the removed value or
242
+ * `undefined`. Throws if `name` does not match `[a-z_][a-z0-9_]*`.
322
243
  * @param {string} name
323
244
  * @returns {any}
324
245
  */
@@ -340,9 +261,6 @@ export class Document {
340
261
  }
341
262
  }
342
263
  /**
343
- * Replace the main card's body (the global Markdown body).
344
- *
345
- * Mutators never modify `warnings`.
346
264
  * @param {string} body
347
265
  */
348
266
  replaceBody(body) {
@@ -351,24 +269,10 @@ export class Document {
351
269
  wasm.document_replaceBody(this.__wbg_ptr, ptr0, len0);
352
270
  }
353
271
  /**
354
- * Read the schema version from a raw storage DTO string without
355
- * performing a full parse, or `undefined`.
356
- *
357
- * Returns the `schema` field as-is — including unknown future versions
358
- * that `fromJson` would reject. Use this to distinguish "this build is
359
- * too old for the payload" from "the payload is corrupt" when
360
- * [`fromJson`](Document::from_json) throws:
361
- *
362
- * ```js
363
- * const v = Document.schemaVersionOf(blob);
364
- * if (v === undefined) {
365
- * // not a stored DTO at all — try fromMarkdown
366
- * } else if (v !== Document.currentSchemaVersion()) {
367
- * // newer (or older unmigrated) schema — prompt the user to upgrade
368
- * } else {
369
- * doc = Document.fromJson(blob);
370
- * }
371
- * ```
272
+ * Read the `schema` version tag from a raw storage DTO string without a
273
+ * full parse, or `undefined`. Returns unknown future versions as-is —
274
+ * useful to distinguish "build too old" from "payload corrupt" when
275
+ * `fromJson` throws.
372
276
  * @param {string} json
373
277
  * @returns {string | undefined}
374
278
  */
@@ -391,26 +295,18 @@ export class Document {
391
295
  }
392
296
  }
393
297
  /**
394
- * Replace the tag of the composable card at `index`.
395
- *
396
- * Mutates only the sentinel the card's frontmatter and body are
397
- * untouched. Schema-aware migration (clearing orphan fields, applying
398
- * new defaults) is the caller's responsibility; `setCardTag` is a
399
- * structural primitive.
400
- *
401
- * Throws if `index` is out of range or if `newTag` does not match
402
- * `[a-z_][a-z0-9_]*`.
403
- *
404
- * Mutators never modify `warnings`.
298
+ * Replace the kind of the card at `index`. Payload and body are untouched;
299
+ * schema-aware migration is the caller's responsibility.
300
+ * Throws if `index` is out of range or `newKind` is invalid.
405
301
  * @param {number} index
406
- * @param {string} new_tag
302
+ * @param {string} new_kind
407
303
  */
408
- setCardTag(index, new_tag) {
304
+ setCardKind(index, new_kind) {
409
305
  try {
410
306
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
411
- const ptr0 = passStringToWasm0(new_tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
307
+ const ptr0 = passStringToWasm0(new_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
412
308
  const len0 = WASM_VECTOR_LEN;
413
- wasm.document_setCardTag(retptr, this.__wbg_ptr, index, ptr0, len0);
309
+ wasm.document_setCardKind(retptr, this.__wbg_ptr, index, ptr0, len0);
414
310
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
415
311
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
416
312
  if (r1) {
@@ -421,16 +317,9 @@ export class Document {
421
317
  }
422
318
  }
423
319
  /**
424
- * Update a frontmatter field on the main card.
320
+ * Update a payload field on the main card. Clears any existing `!fill` marker.
425
321
  *
426
- * Convenience method: equivalent to `doc.mainMut().setField(name, value)`.
427
- * Clears any existing `!fill` marker on the field.
428
- *
429
- * Throws an `Error` whose message includes the `EditError` variant name and
430
- * details if `name` is reserved (`BODY`, `CARDS`, `QUILL`, `CARD`) or does
431
- * not match `[a-z_][a-z0-9_]*`.
432
- *
433
- * Mutators never modify `warnings`.
322
+ * Throws if `name` does not match `[a-z_][a-z0-9_]*`.
434
323
  * @param {string} name
435
324
  * @param {any} value
436
325
  */
@@ -450,13 +339,8 @@ export class Document {
450
339
  }
451
340
  }
452
341
  /**
453
- * Update a frontmatter field on the main card AND mark it as `!fill`.
454
- *
455
- * Convenience method: equivalent to `doc.mainMut().setFill(name, value)`.
456
- *
342
+ * Update a payload field on the main card and mark it as `!fill`.
457
343
  * Throws on invalid name (see [`setField`](Document::set_field)).
458
- *
459
- * Mutators never modify `warnings`.
460
344
  * @param {string} name
461
345
  * @param {any} value
462
346
  */
@@ -476,11 +360,7 @@ export class Document {
476
360
  }
477
361
  }
478
362
  /**
479
- * Replace the QUILL reference string.
480
- *
481
- * Throws if `ref_str` is not a valid `QuillReference`.
482
- *
483
- * Mutators never modify `warnings`.
363
+ * Replace the QUILL reference string. Throws if `ref_str` is invalid.
484
364
  * @param {string} ref_str
485
365
  */
486
366
  setQuillRef(ref_str) {
@@ -501,36 +381,12 @@ export class Document {
501
381
  /**
502
382
  * Serialize this document to a versioned storage DTO string.
503
383
  *
504
- * Returns the document as a JSON string carrying a `schema` version
505
- * field. The string is produced inside the module via `serde_json` and
506
- * round-trips losslessly back to an equal `Document` via
507
- * [`fromJson`](Document::from_json) — the JS `JSON` global is not
508
- * involved in either direction.
509
- *
510
- * Use this — not [`toMarkdown`](Document::to_markdown) — to persist a
511
- * document across a process restart or crate upgrade; the wire format
512
- * is frozen per `schema` version, whereas Markdown syntax evolves.
513
- * Parse-time `warnings` are not part of the DTO.
514
- *
515
- * The result is standard JSON text, so callers that want to inspect it
516
- * may `JSON.parse` it — but treating it as an opaque blob is the
517
- * intended use.
518
- *
519
- * ## Byte-stability
384
+ * Prefer this over `toMarkdown` for persistence across restarts or crate
385
+ * upgrades the wire format is frozen per `schema` version. Parse-time
386
+ * `warnings` are excluded from the DTO.
520
387
  *
521
- * The output is a **byte-deterministic** function of the document's
522
- * value within a given `schema` version: two documents that compare
523
- * equal under [`equals`](Document::equals) serialize to byte-equal
524
- * strings, and the same document re-serialized in a later patch or
525
- * minor release of this crate (same `schema`) produces the same bytes.
526
- * Content-hash use cases (template-divergence detection, cache keys)
527
- * can rely on this without re-canonicalizing.
528
- *
529
- * Specifics: object fields are emitted in struct-declaration order;
530
- * frontmatter field values preserve their YAML insertion order (no
531
- * key sorting); whitespace is `serde_json`'s compact form (no spaces
532
- * between tokens, no trailing newline); strings use `serde_json`'s
533
- * standard escape set. A schema-version bump may change any of these.
388
+ * Output is **byte-deterministic** within a `schema` version: equal
389
+ * documents produce byte-equal output, safe for content-hash use cases.
534
390
  * @returns {string}
535
391
  */
536
392
  toJson() {
@@ -550,11 +406,8 @@ export class Document {
550
406
  }
551
407
  }
552
408
  /**
553
- * Emit canonical Quillmark Markdown.
554
- *
555
- * Returns the document serialised as a Quillmark Markdown string.
556
- * The output is type-fidelity round-trip safe: re-parsing the result
557
- * produces a `Document` equal to `self` by value and by type.
409
+ * Emit canonical Quillmark Markdown. Round-trip safe: re-parsing the
410
+ * result produces a `Document` equal to `self` by value and by type.
558
411
  * @returns {string}
559
412
  */
560
413
  toMarkdown() {
@@ -574,18 +427,11 @@ export class Document {
574
427
  }
575
428
  }
576
429
  /**
577
- * Reconstruct a `Document` from a storage DTO string, or `undefined`.
578
- *
579
- * Like [`fromJson`](Document::from_json), but returns `undefined`
580
- * instead of throwing when `json` is not a valid storage DTO. Use this
581
- * to detect format and fall back without exceptions as control flow:
582
- *
583
- * ```js
584
- * const doc = Document.tryFromJson(content) ?? Document.fromMarkdown(content);
585
- * ```
586
- *
587
- * `undefined` only ever means "not a storage DTO" — `fromMarkdown`
588
- * still throws on genuinely malformed markdown.
430
+ * Like [`fromJson`](Document::from_json) but returns `undefined` instead
431
+ * of throwing when `json` is not a valid storage DTO — use to
432
+ * discriminate format without exceptions as control flow.
433
+ * `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
434
+ * genuinely malformed markdown.
589
435
  * @param {string} json
590
436
  * @returns {Document | undefined}
591
437
  */
@@ -596,11 +442,7 @@ export class Document {
596
442
  return ret === 0 ? undefined : Document.__wrap(ret);
597
443
  }
598
444
  /**
599
- * Replace the body of the card at `index`.
600
- *
601
- * Throws if `index` is out of range.
602
- *
603
- * Mutators never modify `warnings`.
445
+ * Replace the body of the card at `index`. Throws if out of range.
604
446
  * @param {number} index
605
447
  * @param {string} body
606
448
  */
@@ -621,13 +463,7 @@ export class Document {
621
463
  }
622
464
  /**
623
465
  * Update a field on the card at `index`.
624
- *
625
- * Convenience method: equivalent to `doc.card_mut(index)?.set_field(name, value)`.
626
- *
627
- * Throws if `index` is out of range, `name` is reserved or invalid, or
628
- * `value` cannot be serialized.
629
- *
630
- * Mutators never modify `warnings`.
466
+ * Throws if `index` is out of range, `name` is reserved or invalid.
631
467
  * @param {number} index
632
468
  * @param {string} name
633
469
  * @param {any} value
@@ -648,7 +484,6 @@ export class Document {
648
484
  }
649
485
  }
650
486
  /**
651
- * Non-fatal parse-time warnings as an array of typed `Diagnostic` objects.
652
487
  * @returns {Diagnostic[]}
653
488
  */
654
489
  get warnings() {
@@ -658,9 +493,6 @@ export class Document {
658
493
  }
659
494
  if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
660
495
 
661
- /**
662
- * Opaque, shareable Quill handle.
663
- */
664
496
  export class Quill {
665
497
  static __wrap(ptr) {
666
498
  ptr = ptr >>> 0;
@@ -700,13 +532,8 @@ export class Quill {
700
532
  }
701
533
  }
702
534
  /**
703
- * A blank form for a card of the given kind no document values supplied.
704
- *
705
- * Returns `null` if `cardKind` is not declared in this quill's schema.
706
- * Otherwise returns a plain JS object shaped like a single entry in
707
- * [`Form::cards`].
708
- *
709
- * [`Form::cards`]: quillmark::form::Form::cards
535
+ * Blank `FormCard` for the given card kind. Returns `null` if `cardKind`
536
+ * is not declared in this quill's schema.
710
537
  * @param {string} card_kind
711
538
  * @returns {FormCard | null}
712
539
  */
@@ -728,13 +555,8 @@ export class Quill {
728
555
  }
729
556
  }
730
557
  /**
731
- * A blank form for the main card no document values supplied.
732
- *
733
- * Returns a plain JS object with the same shape as one entry in
734
- * [`Form::main`]. Every declared field's `source` is `"default"` (when
735
- * the schema declares a default) or `"missing"`.
736
- *
737
- * [`Form::main`]: quillmark::form::Form::main
558
+ * Blank `FormCard` for the main card with no document values.
559
+ * Every field's `source` is `"default"` or `"missing"`.
738
560
  * @returns {FormCard}
739
561
  */
740
562
  blankMain() {
@@ -753,7 +575,6 @@ export class Quill {
753
575
  }
754
576
  }
755
577
  /**
756
- * Auto-generated annotated Markdown blueprint for LLM consumers.
757
578
  * @returns {string}
758
579
  */
759
580
  get blueprint() {
@@ -773,23 +594,8 @@ export class Quill {
773
594
  }
774
595
  }
775
596
  /**
776
- * The schema-aware form view of `doc`.
777
- *
778
- * Returns a plain JS object (not a class) that is immediately
779
- * `JSON.stringify`-able. The shape mirrors [`Form`]:
780
- *
781
- * ```json
782
- * {
783
- * "main": { "schema": {...}, "values": { "field": {...} } },
784
- * "cards": [ ... ],
785
- * "diagnostics": [ ... ]
786
- * }
787
- * ```
788
- *
789
- * **Snapshot semantics.** This is a read-only snapshot of the document
790
- * at call time. Subsequent edits to `doc` require calling `form` again.
791
- *
792
- * [`Form`]: quillmark::form::Form
597
+ * The schema-aware form view of `doc`. Read-only snapshot at call time;
598
+ * subsequent edits to `doc` require calling `form` again.
793
599
  * @param {Document} doc
794
600
  * @returns {Form}
795
601
  */
@@ -811,13 +617,7 @@ export class Quill {
811
617
  }
812
618
  /**
813
619
  * Identity snapshot of the `quill:` section of `Quill.yaml`, plus
814
- * `supportedFormats` and any custom `quill:` keys.
815
- *
816
- * Consumers that need validation run their own validator against
817
- * `metadata.schema`.
818
- *
819
- * Equivalent by value for the lifetime of the handle; the quill is
820
- * immutable once constructed.
620
+ * `supportedFormats` and any extra `quill:` keys.
821
621
  * @returns {QuillMetadata}
822
622
  */
823
623
  get metadata() {
@@ -825,7 +625,6 @@ export class Quill {
825
625
  return takeObject(ret);
826
626
  }
827
627
  /**
828
- * Open an iterative render session for page-selective rendering.
829
628
  * @param {Document} doc
830
629
  * @returns {RenderSession}
831
630
  */
@@ -846,7 +645,6 @@ export class Quill {
846
645
  }
847
646
  }
848
647
  /**
849
- * Render a document to final artifacts.
850
648
  * @param {Document} doc
851
649
  * @param {RenderOptions | null} [opts]
852
650
  * @returns {RenderResult}
@@ -876,12 +674,9 @@ export class Quill {
876
674
  return takeObject(ret);
877
675
  }
878
676
  /**
879
- * Whether this quill's backend supports canvas preview.
880
- *
881
677
  * `true` iff `RenderSession.paint` and `RenderSession.pageSize` will
882
- * succeed for sessions opened by this quill. Use this as a precondition
883
- * probe before mounting a canvas-based preview UI; the throw on `paint`
884
- * remains the enforcement contract.
678
+ * succeed for sessions opened by this quill. Use as a precondition
679
+ * probe before mounting a canvas-based preview UI.
885
680
  * @returns {boolean}
886
681
  */
887
682
  get supportsCanvas() {
@@ -891,9 +686,6 @@ export class Quill {
891
686
  }
892
687
  if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
893
688
 
894
- /**
895
- * Quillmark WASM Engine
896
- */
897
689
  export class Quillmark {
898
690
  __destroy_into_raw() {
899
691
  const ptr = this.__wbg_ptr;
@@ -905,9 +697,6 @@ export class Quillmark {
905
697
  const ptr = this.__destroy_into_raw();
906
698
  wasm.__wbg_quillmark_free(ptr, 0);
907
699
  }
908
- /**
909
- * JavaScript constructor: `new Quillmark()`
910
- */
911
700
  constructor() {
912
701
  const ret = wasm.quillmark_new();
913
702
  this.__wbg_ptr = ret >>> 0;
@@ -943,19 +732,12 @@ export class Quillmark {
943
732
  if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
944
733
 
945
734
  /**
946
- * An iterative render handle backed by an immutable compiled snapshot.
947
- *
948
- * Created via [`Quill::open`]. Holds the compiled output so that
949
- * [`RenderSession::render`], [`RenderSession::paint`], and
950
- * [`RenderSession::page_size`] can be called repeatedly without
951
- * recompiling.
735
+ * Iterative render handle backed by an immutable compiled snapshot.
952
736
  *
953
- * **Empty documents.** A document that compiles to zero pages still
954
- * produces a valid session (`pageCount === 0`). Iterating
955
- * `0..pageCount` is then a no-op; calling `paint(ctx, 0)` or
956
- * `pageSize(0)` throws `"... page index 0 out of range
957
- * (pageCount=0)"`. Hosts that surface "no pages to preview" UI should
958
- * branch on `pageCount === 0` rather than on a thrown error.
737
+ * **Empty documents.** A zero-page document yields a valid session
738
+ * (`pageCount === 0`); `paint(ctx, 0)` or `pageSize(0)` throws with
739
+ * `"page index 0 out of range (pageCount=0)"`. Branch on `pageCount === 0`
740
+ * rather than catching the error.
959
741
  */
960
742
  export class RenderSession {
961
743
  static __wrap(ptr) {
@@ -977,9 +759,6 @@ export class RenderSession {
977
759
  }
978
760
  /**
979
761
  * The backend that produced this session (e.g. `"typst"`).
980
- *
981
- * Equal to the `backendId` of the [`Quill`] that opened this session
982
- * (sessions inherit their quill's backend), so checking either is fine.
983
762
  * @returns {string}
984
763
  */
985
764
  get backendId() {
@@ -999,10 +778,6 @@ export class RenderSession {
999
778
  }
1000
779
  }
1001
780
  /**
1002
- * Number of pages in this render session.
1003
- *
1004
- * Stable for the lifetime of the session — the underlying compiled
1005
- * document is an immutable snapshot.
1006
781
  * @returns {number}
1007
782
  */
1008
783
  get pageCount() {
@@ -1011,18 +786,7 @@ export class RenderSession {
1011
786
  }
1012
787
  /**
1013
788
  * Page dimensions in Typst points (1 pt = 1/72 inch).
1014
- *
1015
- * Report-only: the painter sizes the canvas itself based on
1016
- * `PaintOptions`. Exposed for consumers that need page geometry
1017
- * up-front (e.g. to lay out a scrollable list of canvases before
1018
- * any pixels are rendered).
1019
- *
1020
- * Stable for a given `page` across the session's lifetime — the
1021
- * compiled document is an immutable snapshot, so callers can cache
1022
- * results.
1023
- *
1024
- * Throws if the underlying backend has no canvas painter (i.e. is not
1025
- * the Typst backend) or if `page` is out of range.
789
+ * Throws if the backend has no canvas painter or `page` is out of range.
1026
790
  * @param {number} page
1027
791
  * @returns {PageSize}
1028
792
  */
@@ -1042,42 +806,14 @@ export class RenderSession {
1042
806
  }
1043
807
  }
1044
808
  /**
1045
- * Paint `page` into a 2D canvas context.
1046
- *
1047
- * Accepts either a `CanvasRenderingContext2D` (main thread) or an
1048
- * `OffscreenCanvasRenderingContext2D` (Worker / off-DOM rasterization).
1049
- * Both dispatch to the same Rust rasterizer; the dispatch happens at
1050
- * the JS boundary so neither context type is privileged.
1051
- *
1052
- * The painter owns `canvas.width` / `canvas.height` and writes them
1053
- * itself; consumers must not. The painter does not touch
1054
- * `canvas.style.*` — that's layout, owned by the consumer (see
1055
- * `PaintResult.layoutWidth` / `layoutHeight`).
1056
- *
1057
- * `opts.layoutScale` (default 1.0) is layout-space pixels per Typst
1058
- * point and determines the canvas's display-box size. `opts.densityScale`
1059
- * (default 1.0) is the rasterization density multiplier the consumer
1060
- * folds `window.devicePixelRatio`, in-app zoom, and
1061
- * `visualViewport.scale` (pinch-zoom) into. The effective
1062
- * rasterization scale is `layoutScale * densityScale`.
1063
- *
1064
- * If `layoutScale * densityScale` would exceed the safe backing-store
1065
- * maximum (16384 px per side), `densityScale` is clamped
1066
- * proportionally so the largest dimension fits. The actual
1067
- * backing-store dimensions are reported in the returned
1068
- * `PaintResult` — compare against
1069
- * `round(layoutWidth * densityScale)` to detect clamping.
1070
- *
1071
- * Each call resets the backing store (`paint` is always a full
1072
- * repaint). Consumers do not need to call `clearRect`.
1073
- *
1074
- * Throws when:
1075
- * - the backend does not support canvas preview (message includes the
1076
- * resolved `backendId`),
1077
- * - `page` is out of range,
1078
- * - `ctx` is neither `CanvasRenderingContext2D` nor
1079
- * `OffscreenCanvasRenderingContext2D`,
1080
- * - `opts.layoutScale` or `opts.densityScale` is non-finite or `<= 0`.
809
+ * Paint `page` into a `CanvasRenderingContext2D` or
810
+ * `OffscreenCanvasRenderingContext2D`. The painter owns
811
+ * `canvas.width`/`height` (no `clearRect` needed); consumers own
812
+ * `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
813
+ * per side, `densityScale` is clamped detect via `PaintResult.pixelWidth`.
814
+ *
815
+ * Throws if the backend has no canvas painter, `page` is out of range,
816
+ * `ctx` is the wrong type, or either scale is non-finite or `<= 0`.
1081
817
  * @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
1082
818
  * @param {number} page
1083
819
  * @param {PaintOptions | undefined} opts
@@ -1099,7 +835,6 @@ export class RenderSession {
1099
835
  }
1100
836
  }
1101
837
  /**
1102
- * Render all or selected pages from this session.
1103
838
  * @param {RenderOptions | null} [opts]
1104
839
  * @returns {RenderResult}
1105
840
  */
@@ -1119,11 +854,7 @@ export class RenderSession {
1119
854
  }
1120
855
  }
1121
856
  /**
1122
- * Whether this session's backend supports canvas preview.
1123
- *
1124
- * `true` iff [`paint`](Self::paint) and [`page_size`](Self::page_size)
1125
- * will succeed. Equal to `Quill.supportsCanvas` for the quill that
1126
- * opened this session.
857
+ * `true` iff `paint` and `pageSize` will succeed for this session.
1127
858
  * @returns {boolean}
1128
859
  */
1129
860
  get supportsCanvas() {
@@ -1131,14 +862,8 @@ export class RenderSession {
1131
862
  return ret !== 0;
1132
863
  }
1133
864
  /**
1134
- * Session-level warnings attached at `quill.open(...)` time.
1135
- *
1136
- * Snapshot of any non-fatal diagnostics emitted while opening the
1137
- * session (e.g. version compatibility shims). Stable across the
1138
- * session's lifetime. These are also appended to
1139
- * [`RenderResult.warnings`] on every `render()` call; the accessor
1140
- * surfaces them to canvas-preview consumers that don't go through
1141
- * `render()`.
865
+ * Non-fatal diagnostics emitted when opening the session. Also appended
866
+ * to `RenderResult.warnings` on each `render()` call.
1142
867
  * @returns {Diagnostic[]}
1143
868
  */
1144
869
  get warnings() {