/* tslint:disable */ /* eslint-disable */ /** * A path to a value nested inside a field `value`: `string` keys and * `number` array indices, e.g. `["addr", "street"]` or `["recipients", 0, "name"]`. */ export type PathStep = string | number; /** A field or comment entry in a `Card.payloadItems` list. */ export type PayloadItem = | { type: "field"; key: string; value: unknown; fill?: boolean; /** * Paths to `!must_fill` markers nested *inside* `value` (the `value` * projection itself is fill-free). Absent when the field has no nested * placeholders. Preserved across `insertCard`. */ nestedFills?: PathStep[][]; } | { type: "comment"; text: string; inline?: boolean }; /** * A single card block, as read back from a document. Every `Card` is a valid * `CardInput`, so a card read from one document pushes straight into another. * * `$` system entries are hoisted to named fields: `kind` (the `$kind`, empty * string when none), `quill` (`$quill` `name@version`, main card only), `ext` * (`$ext`), and `seed` (the `$seed` per-kind overlay map, main card only). * `payloadItems` carries user fields and comments in order. */ export interface Card { kind: string; quill?: string; ext?: Record; seed?: Record; payloadItems: PayloadItem[]; /** * The card body as canonical `Content`, never a markdown string. For the * markdown projection call `exportMarkdown(card.body)`. */ body: Content; } /** * A card written *into* a document, accepted by `Document.insertCard`. Like * `Card`, but `body` also takes a markdown `string`, and every field but `kind` * is optional (defaulting to no payload items and an empty body). */ export interface CardInput { kind: string; quill?: string; ext?: Record; seed?: Record; payloadItems?: PayloadItem[]; body?: Content | string; } /** * Canonical richtext content: the model behind a card body and richtext fields. * One text sequence over a single coordinate space (Unicode scalar values): * `text` plus line attributes, anchored `marks`, and embedded `islands`. Every * edit is a splice; markdown is a projection, not the model. */ export interface Content { text: string; lines: ContentLine[]; marks: ContentMark[]; islands: ContentIsland[]; } /** One `\n`-separated segment of `Content.text`, in order. `kind` is a closed * set: a role outside it is refused wherever content is decoded. Every role * spells its payload in `attrs`, so `kind === "heading"` narrows `attrs` to * `{ level: number }` with no guard. */ export type ContentLine = { containers: ContentContainer[]; /** A within-block hard line break rather than a new block. Omitted (false) in the common case. */ continues?: boolean; } & ContentLineKind; /** A line's block role, shared by `ContentLine` and the `setKind` op. */ export type ContentLineKind = | { kind: "para" } | { kind: "heading"; attrs: { level: number } } | { kind: "code"; attrs?: { lang?: string } } | { kind: "island" } | { kind: "rule" }; /** An ancestor block a line nests inside, outermost first. Closed like * `ContentLine.kind`. * * Two adjacent lines sit in the same container iff their whole path matches, so * `instance` is what tells one container from an adjacent sibling of identical * shape — two consecutive quotes, two consecutive lists — which contiguity * alone reads as one. * * **A writer owes a distinct value per adjacent sibling run.** Runs of one shape * sharing one arrive as one: a second list's items come back as continuation * paragraphs of the first, markers gone. Nothing reports that — an omitted field * and a `0` stamped on both are the same write — so a codec flattening a tree * takes them from `assignInstances` in `@quillmark/wasm` rather than by hand. * Any distinct pair works; a write is canonicalized to `0`/`1`. * * Absent is `0`, and a read omits it there, so a container with nothing adjacent * to be told apart from carries no key. A read does spell one on pairs no writer * had to: `1.` beside a list starting at `3` differs by `start`, so those runs * arrive apart with nothing written, and the canonical form spends a * discriminator anyway because Markdown reads only a list's first number. */ export type ContentContainer = | { container: "list_item"; attrs: { ordered: boolean; start: number; ordinal: number }; instance?: number; } | { container: "quote"; instance?: number }; /** A mark over char range `[start, end)` into `Content.text`. `type` is a * closed set, so `type === "link"` narrows `attrs` to `{ url: string }` with no * guard. An `anchor`'s `id` is a caller-supplied opaque * handle, unique per `Content` and invariant while the mark lives (positions * rebase, the id never does); it has no markdown projection and survives only * through the edit lane. */ export type ContentMark = { start: number; end: number } & ContentMarkKind; /** A mark's type with its payload, shared by `ContentMark` and a `MarkOp`'s * `add` / `remove`. */ export type ContentMarkKind = | { type: "strong" | "emph" | "underline" | "strike" | "code" } | { type: "link"; attrs: { url: string } } | { type: "anchor"; attrs: { id: string } }; /** A cell in a `TableProps`. `marks` rides the prose `ContentMark` shape, but * each mark's `start`/`end` are USV offsets into this cell's `text`, not into * `Content.text`. */ export interface TableCell { text: string; marks: ContentMark[]; } /** `props` of a `type: "table"` island: a pipe table normalized to one column * count that `header`, every row of `rows`, and `aligns` all share. */ export interface TableProps { header: TableCell[]; rows: TableCell[][]; /** Per-column alignment, one entry per column. */ aligns: ("none" | "left" | "center" | "right")[]; } /** `props` of a `type: "image"` island. Stores and round-trips; no backend * typesets one, and a render that holds one warns `backend::declined_construct`, * because what `url` names is undecided. */ export interface ImageProps { url: string; alt: string; } /** How faithfully the markdown projection can carry an island. */ export type ContentLossClass = "lossless" | "degraded" | "unrepresentable"; /** A structured object occupying one island slot in `Content.text`. `type` is a * closed set, so `type === "table"` narrows `props` to `TableProps`. */ export type ContentIsland = { id: string; loss: ContentLossClass; } & ( | { type: "table"; props: TableProps } | { type: "image"; props: ImageProps } ); /** * A write address: one navigation concept for the whole `Document` surface. An * absent `field` targets the card body; an absent `card` targets the main card. * `{}` is the main-card body; `{ card: 2 }` the body of the composable card at * index 2; `{ field: "intro" }` the main card's `intro` field; `{ card: 2, * field: "intro" }` a card field. * * On the `Addr`-taking verbs a **bare string** is shorthand for `{ field: name }` * (`doc.storeField("qty", 3)`); a bare number is *not* an addr. * * `doc.pathFor(addr)` mints the address as its canonical `DocPath` string, the * anchor `Diagnostic.path` carries and `session.locate` / `session.fieldBoxes` * take. A card path is kind-qualified, so a hand-built one needs the card's * `$kind`, and a wrong-kind path matches nothing silently. * * An `Addr` names a field, never a value inside one: every verb that takes one * would then carry an element axis it cannot answer. The one read that reaches * inside takes the path as its own argument, `reader.getContentAt(addr, path)`. */ export interface Addr { card?: number; field?: string; } /** * A card-only address, taken by the card-scoped verbs (`storeFields`, * `storeExt`, `getExt`, `commitFields`, …). An absent `card` targets the main * card; a present `field` throws. */ export interface CardAddr { card?: number; } /** * A text-splice change set over the USV content (CodeMirror `ChangeSet` * semantics), returned by `revise` and by the `rebase` codec. Map a stored * position through it with `mapPos`. * * Applying one admits an `insert` string rather than storing it verbatim: `\r` * and the Unicode bidi controls drop, and a line separator — VT, FF, NEL, * U+2028, U+2029 — becomes a space. Nothing reports the substitution. */ export interface Delta { ops: ({ retain: number } | { insert: string } | { delete: number })[]; } /** Which side of a same-position insertion `mapPos` lands a point on. */ export type Assoc = "before" | "after"; /** * A mark edit in final-text coordinates (post-delta, post-line-op). `add` / * `remove` are a `ContentMark` under an op, so a held mark spreads in whole; * `removeAnchor` drops one identity anchor by id. An `add` of an `anchor` * requires a non-empty `id` not already live in the field; a collision or the * empty id throws. */ export type MarkOp = | ({ op: "add" | "remove" } & ContentMark) | { op: "removeAnchor"; id: string }; /** * A line/block edit. `split`/`join` splice `\n` in post-`delta`, * post-`islandOps` coordinates; `setKind`/`setContainers`/`setContinues` touch * metadata. `setContinues` sets or clears a line's within-block hard-break flag * (`ContentLine.continues`); `continues: true` lands as `false` on line 0, which * nothing precedes, on a line whose containers differ from the line above, and * on one following a heading, island or rule, each a block of one line. * `setKind` lands a kind the line's text contradicts — `island` or `rule` over * prose, `code` over a slot — as `para`, which is what re-importing the line's * own markdown yields. Read the content back to see where an op settled. */ export type LineOp = | { op: "split"; at: number } | { op: "join"; line: number } | ({ op: "setKind"; line: number } & ContentLineKind) | { op: "setContainers"; line: number; containers: ContentContainer[] } | { op: "setContinues"; line: number; continues: boolean }; /** * An island edit: the only channel that reaches an island's payload, a table's * cells or an image's url. Both ops leave the field's text and marks alone, so * an island edit keeps every identity anchor in the field. * * `set` addresses an existing island by `id`; an unknown `id` throws. `insert` * places a new island's slot at `at` together with its entry, so a slot never * exists without an island behind it; its `id` must be non-empty and unused. * `at` is a position in the text the `delta` and this bundle's earlier island * ops left, so slots after `a` and `b` of `abc` go in at 1 and 3. A stale frame * misplaces slots and never throws. A `delta` insert string may not carry a * slot, which would orphan: split such a splice into the slot-free `delta` plus * one `insert` per slot. * * Deleting an island needs no op: a `delta` that removes its slot drops the * island whole, and a block island's line demotes to `para`. Re-landing it is an * `insert` of the full island under its original id; a pasted copy of a live * island mints a fresh one. * * A `set` stores the `loss` it is given; nothing re-derives the class from the * new `props`. * * An island is *inline* (a slot inside a paragraph) or a **block** (that slot * alone on a line under `kind: "island"`), and for a slot alone on a line the * type settles which: markdown writes a `table` as a block and an image inline, * so the line's `kind` is read off the type and a `setKind` spelling it * otherwise does not survive. Landing a block island is one bundle of all three * channels, in the order they apply: `delta` inserts the `\n` that opens the * line, `islandOps` inserts the slot, `lineOps` tags the line * `{ op: "setKind", kind: "island" }`. `{ op: "split" }` cannot open that line, * since line ops run after island ops. * * A `table` has no inline placement: markdown writes it as a block, so an * `insert` whose `at` is not an empty line throws, as does a `set` retyping an * inline island into one. */ export type IslandOp = | ({ op: "set" } & ContentIsland) | ({ op: "insert"; at: number } & ContentIsland); /** * A committed content edit bundle for `applyChange`, applied in order: a text * `delta`, then `islandOps`, then `lineOps`, then `markOps` (mark ranges are in * final-text coordinates). Every field is optional. * * Within each channel ops apply in sequence against the state the earlier ones * left: an island `insert`'s `at` counts earlier ops' slots, and `lineOps` * positions and indices renumber through earlier `split`/`join`. * * **Mark rebase.** `delta`, `islandOps` and `lineOps` each move text, and each * rebases the marks already in the field by one rule: a range mark's `start` * takes assoc `after` and its `end` `before`, so an insertion at either edge * grows text *outside* the span; a **zero-width** mark takes `before`, so an * insertion at its own position leaves it put. That last case is the one * position where the two assocs differ, and where an anchor most often sits. * * `markOps` name the result, so a caller emitting them predicts this rebase. * `mapMarks(content, bundle)` runs it instead: pass the bundle's text-moving * channels, diff the marks it returns against the ones you intend, and emit * only the difference. Reproducing the rule by hand is a second copy to drift. */ export interface ChangeBundle { delta?: Delta; islandOps?: IslandOp[]; lineOps?: LineOp[]; markOps?: MarkOp[]; } /** * One segment of a parsed `Diagnostic.path` (see `parseDocPath`). The head * carries the document-model root: `main` (only before `body`), a `card` * (`kind: null` is the unknown-kind `cards[i]` form), or a `field`; the tail is * `field` / `index` / a terminal `body`. */ export type DocPathSeg = | { seg: "main" } | { seg: "card"; kind: string | null; index: number } | { seg: "field"; name: string } | { seg: "index"; index: number } | { seg: "body" }; /** * The commitment-ladder rung that produced a `ResolvedField.value`. * * A container has no rung of its own — it is a namespace, and its value is the * composition of its cells' — so it reports the strongest rung that contributed: * `authored` if the document wrote any of it, else `default` if any cell below * resolved to one, else `blank`. */ export type FieldSource = "authored" | "default" | "blank"; /** * One resolved row: its `name`, the value the render projection would use, and * the `FieldSource` rung it came from. Rows are an ordered array, so declaration * order is structural rather than object-key order. */ export interface ResolvedField { name: string; value: unknown; source: FieldSource; } /** * The main card's resolved rows in declaration order, plus its body row: * `null` when the main enables no body. */ export interface ResolvedMain { fields: ResolvedField[]; body: ResolvedField | null; } /** * One composable card's resolved rows in declaration order, with its authored * `kind` (`null` for an unknown-kind card), its document-array `index`, and its * body row: `null` when the kind enables no body. */ export interface ResolvedCard { kind: string | null; index: number; fields: ResolvedField[]; body: ResolvedField | null; } /** * The resolved-value view (`Quill.resolve`): the main card and every composable * card. Value and provenance only; completeness stays `Quill.validate`'s. */ export interface Resolved { main: ResolvedMain; cards: ResolvedCard[]; } /** UI layout hints for a single field. Display order is not a hint: key order * in the schema's `fields`/`properties` objects is the ordering contract. */ export interface QuillFieldUi { title?: string; group?: string; compact?: boolean; multiline?: boolean; /** Label for an `enum`'s blank option. Absent, the consumer supplies a * conventional label of its own. */ blank_title?: string; /** The control the field asks for, where the shape admits more than one. * A request, not a contract: a consumer that cannot draw it falls back to * its own choice for the type. `"table"` is valid only on an `array` * whose `items` is an `object`. */ layout?: "table"; } /** One entry in a card's `ui.groups` registry: a display-label override for the * group id (the map key). An empty object carries no override, and the consumer * derives the label from the id (`memo_for` → "Memo For"). */ export interface QuillGroupUi { title?: string; } /** UI layout hints for a card (main or named card kind). */ export interface QuillCardUi { title?: string; /** The groups a field's `ui.group` may reference, keyed by group id. Key * order is the display-order contract, as with `fields`. Absent when the * card declares no groups. */ groups?: Record; } /** A block construct a body can hold. `paragraph` is the floor and cannot be * declined, so it is absent. */ export type QuillBlockConstruct = | "heading" | "rule" | "code" | "list" | "quote" | "table" | "image"; /** Body namespace for a card (main or named card kind). */ export interface QuillCardBody { /** When false, consumers must not accept or store body content for this card kind. Defaults to true. */ enabled?: boolean; /** Example body content embedded verbatim in the blueprint body region. Fallback is "Write body here." */ example?: string; /** Block constructs this quill's plate does not typeset in this body; * absent or empty declines nothing. A body that holds one anyway draws a * non-fatal `plate::unsupported_construct` warning. Nothing verifies the * claim: absence from this list is not a promise the plate typesets it. */ unsupported?: QuillBlockConstruct[]; } /** Schema entry for a single field declared in a quill's `Quill.yaml`. * * One declaration, and no `required` key. `default` and `example` say what the * cell holds, and `default`'s absence is the obligation: a field nobody * declared a value for carries a `!must_fill` marker in the blueprint and warns * `validation::must_fill` while the document leaves it unauthored. Neither * gates render: an absent field blank-fills. */ export interface QuillFieldSchema { type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "date" | "datetime" | "richtext" | "plaintext" | "enum" | "matrix"; description?: string; default?: unknown; example?: unknown; /** The closed set of allowed values. Required on `type: "enum"`, and valid * nowhere else. */ values?: string[]; /** Per-member field sets on a card-level `type: "enum"` field, keyed by * member: the fields that exist only where the discriminant holds that * member. Declaring it makes the field rest as a container, * `{value: , …that member's fields}`, rather than a bare string. */ variants?: Record>; /** The roster of a `type: "matrix"` field, required there and valid * nowhere else: the closed vocabulary a document ticks, in display order. * Each member is an object of `held` plus the field's `properties` * (the columns), addressed as `..held`. */ members?: QuillMatrixGroup[]; ui?: QuillFieldUi; properties?: Record; items?: QuillFieldSchema; /** The element count past which an `array` overflows the page it is laid * out on. Valid only on an `array`. Never gates render: a document over * the cap warns `validation::cardinality` and renders. */ max?: number; /** `true` on a `richtext` or `plaintext` field declared `inline`: the * single-paragraph, container-free, island-free constraint. */ inline?: boolean; } /** One block of a `type: "matrix"` roster: an optional display heading and the * members under it, member id to display title. Key order is display order. */ export interface QuillMatrixGroup { group?: string; values: Record; } /** Schema entry for the main card or a named card kind. */ export interface QuillCardSchema { description?: string; fields: Record; ui?: QuillCardUi; body?: QuillCardBody; } /** * Document schema returned by `Quill.schema`: the user-fillable fields only. * The quill reference (`${metadata.name}@${metadata.version}`) and card-kind * discriminators are document-level metadata, not schema fields. */ export interface QuillSchema { main: QuillCardSchema; /** Present only when the quill declares at least one named card kind. */ card_kinds?: Record; } /** * Identity snapshot mirroring the `quill:` section of `Quill.yaml`. The schema * lives on `Quill.schema`; output formats are a resolved-backend capability read * from `Quillmark.supportedFormats`, not part of this config snapshot. */ export interface QuillMetadata { name: string; version: string; backend: string; author: string; description: string; } export interface Diagnostic { severity: Severity; code?: string; message: string; location?: Location; /** * Document-model path anchor (e.g. `"cards.indorsement[0].signature_block"`), * set on schema validation diagnostics and `undefined` otherwise. */ path?: string; hint?: string; /** * The facts `message` interpolates, keyed by name. With `code`, enough to * word this diagnostic in another language. * * Declared optional explicitly: `tsify` does not read * `skip_serializing_if`, so an omitted field would be declared required. */ args?: Record; } export interface Location { file: string; line: number; column: number; } export type Severity = "error" | "warning"; export class Document { free(): void; [Symbol.dispose](): void; /** * **Apply** a committed content edit `bundle` at `addr`, the editor splice: * text delta first, then island ops, then line ops, then mark ops (mark * ranges in final-text coordinates), all-or-nothing. An absent `addr.field` * targets the body, an absent `addr.card` the main card. The island channel * moves an island alone, so anchors elsewhere in the field survive an edit * `overwrite` would clear. * * Throws on an out-of-range card, a field that is not richtext, a malformed * bundle, or an op that applies out of bounds; the value is unchanged on a * failed apply. * * Each text-moving channel rebases the marks already in the field, by the * rule on `ChangeBundle`; `mapMarks` answers where they land, so a caller * building `markOps` need not predict it. */ applyChange(addr: Addr | string, bundle: ChangeBundle): void; /** * A blueprint's fill obligation for the given `quillName`, re-exposed from * core. Carries no tool name: pair it with your own next-step directive. */ static blueprintInstruction(quill_name: string): string; /** * The **body** markdown projection: an on-demand, lossy export (content-only * marks do not survive markdown). A body's type is a format fact, not a * schema fact, so this read stays quill-free, and a body is never absent. * * `addr` is an optional card address (absent = main). A present `field` * throws: read a field's markdown through `quill.reader(doc).get(field)`, * which interprets by declared type. An out-of-range `addr.card` throws. */ bodyMarkdown(addr?: CardAddr): string; /** * The composable card's own path, `cards.[index]`: the root * [`pathFor`](Self::path_for) extends, for anchoring the card rather than * one of its fields. Total on the index axis; out of range renders * `cards[index]`. */ cardPath(index: number): string; /** * A single composable card by index, so reading one need not materialize * every card via [`cards`](Self::cards). An out-of-range `index` throws * `edit::index_out_of_range`. */ card(index: number): Card; clone(): Document; /** * Storage version this build writes via [`toStored`](Document::to_stored). The * tag advances only when the wire format changes, not on every release. */ static currentStorageVersion(): string; /** * Structural equality, excluding parse-time `warnings`. */ equals(other: Document): boolean; /** * Authoring-format rules for the card-yaml markdown surface, re-exposed from * core. Constant across calls; read once and cache. */ static formatRules(): string; /** * Parse markdown into a typed Document. Throws on parse errors. */ static fromMarkdown(markdown: string): Document; /** * Reconstruct a `Document` from a versioned storage DTO string produced by * [`toStored`](Document::to_stored). The result carries no parse-time warnings. * Throws if `json` is not a valid storage DTO (malformed JSON, unknown * `schema`, missing fields, or unparseable quill reference). */ static fromStored(json: string): Document; /** * The whole `$ext` map at `addr` (a card address, absent `card` = main), or * `undefined` when the card carries none: the `$ext` read that avoids * serializing the whole card. Throws on a present `field` or an * out-of-range card. */ getExt(addr?: CardAddr): Record | undefined; /** * Read the **verbatim stored value** at `addr`: a field's raw payload value, * or the body content when `addr.field` is absent. A bare string is `Addr` * shorthand for `{ field }`. Needs no schema: the read echo of the verbatim * `store*` write, distinct from the interpreted * [`reader.get`](Self::reader_get). Reads are total over the field axis — an * absent field is `undefined` — and only an out-of-range `addr.card` throws * `edit::index_out_of_range`. * * A content field at rest has one stored form per codec: a `richtext` field * holds the canonical content object, a `plaintext` field its literal * string. A document from the bound door (`quill.parse` / `quill.conform`) * is at rest; one from the transport door may rest as authored until it is * conformed, and this read reports what is there. For the `Content` either * way use `reader.getContent`. * * The body arm is typed `Content`; a field arm echoes the stored bytes * unread, which is the contract and why it is `unknown`. */ getStored(addr: Addr | string): unknown; /** * Insert a card: `at` absent appends, a number inserts at that index (in * `0..=cards.length`). Accepts any `CardInput`, including a card read back * out of a document. Throws if `card.kind` is not a valid kind name, or if * `at` is out of range. */ insertCard(card: CardInput, at?: number): void; /** * Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr` * shorthand for `{ field }`. `false` for an absent field and for a body * address; only an out-of-range `addr.card` throws. */ isFill(addr: Addr | string): boolean; /** * Replace this document's contents **in place** from a versioned storage DTO * string: the mutating twin of [`fromStored`](Document::from_stored). * Parse-time `warnings` are cleared. Throws on an invalid DTO, leaving the * document unchanged. A caller holding the document need not re-bind its * variable. */ loadStored(json: string): void; /** * Move the card at `from` to position `to`. `from == to` is a no-op. */ moveCard(from: number, to: number): void; /** * A blank document: a main card carrying only `$quill`, an empty body, and * no composable cards. Absent fields resolve at render time (`default`, else * the field's blank), so nothing the caller did not set reaches the output. * For an example-filled starter use `Quill.seedDocument()`. Throws on an * invalid quill reference. */ constructor(quill_ref: string); /** * **Overwrite** the content value at `addr` with exactly `rt`: value * semantics, so the identity anchors of any previous value are gone. By * anchor fate `overwrite` destroys, [`revise`](Document::revise) rebases, * and [`applyChange`](Document::apply_change) preserves. An absent * `addr.field` targets the body, an absent `addr.card` the main card. * * Throws on an out-of-range card, a malformed field name, or an `rt` that is * not a canonical content object. */ overwrite(addr: Addr | string, rt: Content): void; /** * `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path` carries: * `pathFor()` is `main.body`, `pathFor("intro")` `main.intro`, * `pathFor({card: 2})` `cards.[2].body`. * * The kind is the card's stored `$kind` verbatim, not `validate`'s * declared-kind filter, since a `Document` holds a `$quill` reference and no * schema. That is the one edge where this path and a `validate` diagnostic * path differ for the same card. * * **Total on the index axis**, unlike the `Addr` reads, which throw there: * an out-of-range `{card: 7, field: "from"}` renders `cards[7].from`, which * parses back and resolves to nothing rather than mis-targeting. Only a * malformed address throws. */ pathFor(addr: Addr | string): string; /** * The canonical `$quill` reference grammar as author-facing text: the same * text the `parse::invalid_quill_reference` hint carries. Drive validation * messages from this instead of re-stating the rule. */ static quillRefHint(): string; removeCard(index: number): Card | undefined; /** * Remove the `$ext` map on the card `addr` targets entirely, returning the * previous map or `undefined`. Discards every namespace at once. Throws on * a present `field` or an out-of-range card. */ removeExt(addr?: CardAddr): Record | undefined; /** * Remove a field at `addr`, returning the removed value or `undefined`. A * bare string is `Addr` shorthand for `{ field }`. A body address throws, as * does an out-of-range card or a malformed name. */ removeField(addr: Addr | string): any; /** * Remove `cardKind` from the main card's `$seed` map, returning its overlay * or `undefined`; drops `$seed` entirely once empty. Sibling kinds survive. */ removeSeedOverlay(card_kind: string): any; /** * **Revise** the richtext value at `addr` from a markdown string: the * default write path. Imports the markdown, diffs it against the current * value, rebases surviving identity anchors, and returns the text `Delta` an * editor bridge maps its own positions through (`mapPos`). An absent * `addr.field` targets the body, an absent `addr.card` the main card; an * absent field cold-imports from empty. * * Throws on an out-of-range card, a malformed field name, a present * non-content field value, or an over-nested markdown input. */ revise(addr: Addr | string, markdown: string): Delta; /** * The main card's `$seed[kind]` overlay object, or `undefined`. Feeds * `quill.seedCard(kind, overlay)` without serializing the whole main card, * and keeps `seedCard` pure: the quill never reads the document. */ seedOverlay(kind: string): Record | undefined; /** * Replace the QUILL reference string. Throws if `ref_str` is invalid. */ setQuillRef(ref_str: string): void; /** * Read the storage version tag from a raw storage DTO string without a full * parse, or `undefined`. Unknown future versions come back as-is, which * distinguishes "build too old" from "payload corrupt" when `fromStored` * throws. This is the storage version, not a field schema, though the JSON * key is spelled `"schema"`: that is the DTO's serde tag. */ static storageVersionOf(json: string): string | undefined; /** * Replace the opaque `$ext` map on the card `addr` targets (absent `card` = * main). `value` must be a plain object. `$ext` carries out-of-band consumer * state and never reaches the rendered output. The whole map is the write, * so a consumer holding one namespace merges the rest: * `{...doc.getExt(addr), [ns]: v}`. Throws on a present `field` or an * out-of-range card. */ storeExt(addr: CardAddr, value: any): void; /** * Store a field verbatim at `addr`, deferring coercion to render; the typed * write is [`commitField`](Document::commit_field). A bare string is `Addr` * shorthand for `{ field }`; `{ card: 2, field: "qty" }` targets a * composable card. Clears any `!must_fill` marker. A body address throws: * write a body with `revise` / `overwrite`. Throws on an out-of-range card * or a malformed name. */ storeField(addr: Addr | string, value: any): void; /** * Store several fields verbatim and atomically on the card `addr` targets. * `addr` is a **card address** (`{ card }`, absent = main) and comes first * because `card` is itself a legal field name; a present `field` throws. * Nothing is applied on error, and the thrown error's `diagnostics` carry * one entry per offending field. Throws on an out-of-range card. */ storeFields(addr: CardAddr, fields: Record): void; /** * Store a field verbatim at `addr` and mark it `!must_fill`. A body address * throws; same validation as [`storeField`](Document::store_field). */ storeFill(addr: Addr | string, value: any): void; /** * Merge a card-kind's seed `overlay` into the **main** card's `$seed` map * under `cardKind`, preserving sibling kinds; `$seed` is main-only, so this * takes no address. Sets the starting values new cards of that kind spawn * with. Throws if `overlay` cannot be serialized or nests too deep. */ storeSeedOverlay(card_kind: string, overlay: any): void; /** * Emit canonical Quillmark Markdown. Round-trip safe: re-parsing the * result produces a `Document` equal to `self` by value and by type. */ toMarkdown(): string; /** * Serialize this document to a versioned storage DTO string. Prefer it over * `toMarkdown` for persistence: the wire format is frozen per `schema` * version and the output is byte-deterministic within one, so equal * documents hash equal. Parse-time `warnings` are excluded. */ toStored(): string; /** * Number of composable cards, excluding the main card. */ readonly cardCount: number; readonly cards: Card[]; /** * The document's main (entry) card. Allocates and serializes on each call. */ readonly main: Card; readonly quillRef: string; /** * The non-fatal diagnostics of the load that produced this document: parse * warnings, plus `conform::*` warnings when it came through `quill.parse`. * Session state, not document value: `equals` and the storage DTO exclude * it, and `fromStored` / `loadStored` clear it. */ readonly warnings: Diagnostic[]; } export class Quill { private constructor(); free(): void; [Symbol.dispose](): void; /** * Land `doc`'s declared content fields at their canonical rest **in * place**, returning the `conform::*` diagnostics for values that would not * commit. The read-repair verb for a document that arrived through the * transport door (`fromMarkdown`, `fromStored`, a stored row). * * Idempotent: an equal value is not rewritten, so YAML comments and stored * bytes survive. A `!must_fill` marker anywhere in a field's value skips * that field, and a value the strict write refuses stays as authored with a * diagnostic. Throws when `doc` declares a different `$quill`, before any * mutation. */ conform(doc: Document): Diagnostic[]; /** * Build a quill from a file tree. Pure: the declared backend is resolved * later, at render time. Accepts a `Map` or a plain * object. */ static fromTree(tree: Map): Quill; /** * Parse `markdown` and conform it against this quill: the primary ingestion * path, and the bound twin of the schema-free `Document.fromMarkdown`. The * returned document rests at its canonical form (a `richtext` field as a * content object, a `plaintext` field as its literal string), so `getStored` * answers by the field's declared codec, not by how the document was built. * * Parse warnings and the `conform::*` diagnostics both land on * `doc.warnings`. Throws on a parse failure, or when `markdown` declares a * `$quill` this quill does not answer to. To open a document whose `$quill` * is stale, use `Document.fromMarkdown`, `setQuillRef`, then `quill.conform`. */ parse(markdown: string): Document; /** * Seed a starter composable `Card` of the given kind (carries `$kind`), * layering an optional per-kind seed `overlay` over the schema-example base * (`overlay › example › absent`). `undefined` when `cardKind` is not * declared in this quill's schema. * * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a * template-derived document inherits its curated starting values; omit it * for the bare schema seed. */ seedCard(card_kind: string, overlay: Record | undefined): Card | undefined; /** * Seed a starter `Document` from the schema: the main card plus one instance * of each composable card kind, each committing its fields' `example:` * values and leaving every other field absent (interpolated at render as * `default:`, else the field's blank). A field with both renders its example. */ seedDocument(): Document; /** * Seed a starter main `Card` (carries `$quill`) from the schema: the * `$kind: main` card of [`seedDocument`](Self::seed_document) alone. */ seedMain(): Card; /** * Flatten this quill back into its canonical file tree, the inverse of * [`fromTree`](Self::from_tree). Keys are `"/"`-joined relative paths. * * This is how a quill crosses a WASM linear-memory boundary as data: a * `Quill` built in one build cannot be passed to an engine in another, so * the `@quillmark/wasm` runtime layer re-feeds this tree to the backend * build's `Quill.fromTree` on demand. */ toTree(): Map; /** * Validate `doc` against this quill's schema, returning every diagnostic * (empty when the document is valid). Forwards the canonical * `validation::*` diagnostics the engine emits, including the non-fatal * `validation::must_fill` warning per `!must_fill` marker left behind. */ validate(doc: Document): Diagnostic[]; /** * The *declared* backend identifier (e.g. `"typst"`): intent, not a * resolved capability. Capability is read from the engine. */ readonly backendId: string; readonly blueprint: string; /** * Identity snapshot of the `quill:` section of `Quill.yaml`. Pure config: * output formats are a resolved-backend capability read from * `Quillmark.supportedFormats`, not part of this. */ readonly metadata: QuillMetadata; /** * Document schema for the quill: the user-fillable fields plus their `ui` * hints. Key order in `fields`/`properties` is declaration order, the * ordering contract. */ readonly schema: QuillSchema; /** * The advisory diagnostics of the load that produced this quill: what is * wrong with it short of refusing it. A quill that loads clean answers * `[]`. */ readonly warnings: Diagnostic[]; } /** * Export canonical `Content` to its markdown projection. Throws if `rt` is not * canonical content. */ export function exportMarkdown(rt: Content): string; /** * Render a diagnostic as the CLI and Python's `str(diagnostic)` render it: * the severity tag and the message, the code parenthesised after them, then * location, path and hint each on an indented line of its own. The engine * owns the one printer, so a consumer surfacing diagnostics reads it here * rather than keeping a copy of the layout that drifts from the CLI's. * * Takes the `Diagnostic` shape every read hands back. Throws on a value that * is not one — a missing `severity` or `message`, or a `severity` outside the * two-value ladder. */ export function formatDiagnostic(diagnostic: Diagnostic): string; /** * Serialize structured [`DocPathSeg`] segments back to the canonical path * string: the inverse of `parseDocPath`. Throws on a segment array the * deserializer rejects, and on an empty one. */ export function formatDocPath(segs: DocPathSeg[]): string; /** * Import a markdown string to canonical `Content`: the pure, document-free * codec. `overwrite(addr, importMarkdown(md))` spells the cold, anchor-losing * write; prefer `revise` for edit semantics. Throws on an over-nested input. */ export function importMarkdown(markdown: string): Content; /** * Where `bundle`'s text-moving channels (`delta`, then `islandOps`, then * `lineOps`) leave `content`'s marks: the final-text coordinates the bundle's * `markOps` are written in, under the rebase rule stated on `ChangeBundle`. * The document-free read an editor diffs against to decide which `markOps` to * emit, rather than reproducing that rule in its own language. * * `bundle.markOps` are ignored. The answer is normalized, as the store's is: * marks a text move drops (out of range, zero-width formatting) are absent, * and same-kind runs a move left adjacent arrive already unioned, so a bundle * carrying no `markOps` names the marks the field will hold. * Throws on a non-content `content`, a malformed bundle, or an op that applies * out of bounds: `applyChange`'s errors on the same ops. */ export function mapMarks(content: Content, bundle: ChangeBundle): ContentMark[]; /** * Map a base content position (a USV index into `Content.text`, not a UTF-16 * offset) through a `delta` to its new position, holding a caret stable across * a `revise`. `assoc` decides the side of a same-position insertion (`"after"` * moves past it). Throws on a malformed `delta`. * * This maps a position the *caller* holds. For the marks already in a field, * `mapMarks` applies the store's own assoc rule across every channel of a * `ChangeBundle`. */ export function mapPos(delta: Delta, pos: number, assoc: Assoc): number; /** * Parse a canonical document-model `Diagnostic.path` (`cards.[].`, * `main.body`, `recipients[0].name`) into structured [`DocPathSeg`] segments, so * a consumer routes on segments instead of regexing the string. Throws on a * malformed path. */ export function parseDocPath(path: string): DocPathSeg[]; /** * Rebase `markdown` onto a `base` content: the document-free twin of `revise`, * returning the new `content` and the text `delta` (offsets are USV indices into * `Content.text`, surviving anchors rebased). Throws on an over-nested markdown * input or a non-content `base`. */ export function rebase(base: Content, markdown: string): { content: Content; delta: Delta }; /** * Runs at instantiation, so a Rust panic reaches the console as a stack trace * rather than `unreachable`. Not the package's `init` — that name belongs to * the hand-written runtime, which owns instantiation itself. */ export function start(): void; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_document_free: (a: number, b: number) => void; readonly __wbg_quill_free: (a: number, b: number) => void; readonly document__addCard: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void; readonly document__commitField: (a: number, b: number, c: number, d: number, e: number) => void; readonly document__commitFields: (a: number, b: number, c: number, d: number, e: number) => void; readonly document__readerGet: (a: number, b: number, c: number, d: number) => void; readonly document__readerGetContent: (a: number, b: number, c: number, d: number) => void; readonly document__readerGetContentAt: (a: number, b: number, c: number, d: number, e: number) => void; readonly document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly document_applyChange: (a: number, b: number, c: number, d: number) => void; readonly document_blueprintInstruction: (a: number, b: number, c: number) => void; readonly document_bodyMarkdown: (a: number, b: number, c: number) => void; readonly document_card: (a: number, b: number, c: number) => void; readonly document_cardCount: (a: number) => number; readonly document_cardPath: (a: number, b: number, c: number) => void; readonly document_cards: (a: number, b: number) => void; readonly document_clone: (a: number) => number; readonly document_currentStorageVersion: (a: number) => void; readonly document_equals: (a: number, b: number) => number; readonly document_formatRules: (a: number) => void; readonly document_fromMarkdown: (a: number, b: number, c: number) => void; readonly document_fromStored: (a: number, b: number, c: number) => void; readonly document_getExt: (a: number, b: number, c: number) => void; readonly document_getStored: (a: number, b: number, c: number) => void; readonly document_insertCard: (a: number, b: number, c: number, d: number) => void; readonly document_isFill: (a: number, b: number, c: number) => void; readonly document_loadStored: (a: number, b: number, c: number, d: number) => void; readonly document_main: (a: number, b: number) => void; readonly document_moveCard: (a: number, b: number, c: number, d: number) => void; readonly document_new: (a: number, b: number, c: number) => void; readonly document_overwrite: (a: number, b: number, c: number, d: number) => void; readonly document_pathFor: (a: number, b: number, c: number) => void; readonly document_quillRef: (a: number, b: number) => void; readonly document_quillRefHint: (a: number) => void; readonly document_removeCard: (a: number, b: number, c: number) => void; readonly document_removeExt: (a: number, b: number, c: number) => void; readonly document_removeField: (a: number, b: number, c: number) => void; readonly document_removeSeedOverlay: (a: number, b: number, c: number, d: number) => void; readonly document_revise: (a: number, b: number, c: number, d: number, e: number) => void; readonly document_seedOverlay: (a: number, b: number, c: number, d: number) => void; readonly document_setQuillRef: (a: number, b: number, c: number, d: number) => void; readonly document_storageVersionOf: (a: number, b: number, c: number) => void; readonly document_storeExt: (a: number, b: number, c: number, d: number) => void; readonly document_storeField: (a: number, b: number, c: number, d: number) => void; readonly document_storeFields: (a: number, b: number, c: number, d: number) => void; readonly document_storeFill: (a: number, b: number, c: number, d: number) => void; readonly document_storeSeedOverlay: (a: number, b: number, c: number, d: number, e: number) => void; readonly document_toMarkdown: (a: number, b: number) => void; readonly document_toStored: (a: number, b: number) => void; readonly document_warnings: (a: number, b: number) => void; readonly exportMarkdown: (a: number, b: number) => void; readonly formatDiagnostic: (a: number, b: number) => void; readonly formatDocPath: (a: number, b: number) => void; readonly importMarkdown: (a: number, b: number, c: number) => void; readonly mapMarks: (a: number, b: number, c: number) => void; readonly mapPos: (a: number, b: number, c: number, d: number) => void; readonly parseDocPath: (a: number, b: number, c: number) => void; readonly quill__resolve: (a: number, b: number, c: number) => void; readonly quill_backendId: (a: number, b: number) => void; readonly quill_blueprint: (a: number, b: number) => void; readonly quill_conform: (a: number, b: number, c: number) => void; readonly quill_fromTree: (a: number, b: number) => void; readonly quill_metadata: (a: number, b: number) => void; readonly quill_parse: (a: number, b: number, c: number, d: number) => void; readonly quill_schema: (a: number, b: number) => void; readonly quill_seedCard: (a: number, b: number, c: number, d: number, e: number) => void; readonly quill_seedDocument: (a: number) => number; readonly quill_seedMain: (a: number, b: number) => void; readonly quill_toTree: (a: number) => number; readonly quill_validate: (a: number, b: number, c: number) => void; readonly quill_warnings: (a: number, b: number) => void; readonly rebase: (a: number, b: number, c: number, d: number) => void; readonly start: () => void; readonly __wbindgen_export: (a: number, b: number) => number; readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_export3: (a: number) => void; readonly __wbindgen_export4: (a: number, b: number, c: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_start: () => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise;