# Vue and extension API

Signatures and descriptions generated from the public TypeScript exports.

`QuireMarkdown` props are described by `QuireMarkdownProps` below. Its event is `error(failure: MarkdownReadingError)`.

## Public contracts

### QuireMarkdownProps

`@quirekit/incremark/vue` · MIT

Vue reader supporting ordinary static text, streamed text and existing parser snapshots.

```ts
export interface QuireMarkdownProps extends MarkdownRenderOptions {
    readonly content?: string;
    readonly state?: EditorState;
    readonly identity?: string;
    readonly status?: MarkdownStatus;
    readonly options?: MarkdownOptions;
    readonly locale?: MarkdownLocale;
    readonly ssr?: "semantic" | "source";
}
```

**content** — Full Markdown string, including the received prefix while streaming.

**state** — Advanced accepted source snapshot; mutually exclusive with content.

**identity** — Document/message identity, independent of its source.

**status** — Transport status only; completing or stopping keeps all source.

**options** — Fixed source extensions for this session; replace the object to reconfigure.

**locale** — Copy, task and disclosure control language.

**ssr** — Semantic SSR by default; source is an explicit deferred-parse option.

**cache** — Disable block reuse for diagnostics; parsing remains incremental. Defaults to true in MarkdownRenderer.

**components** — Local overrides layered over native reading defaults.

**html** — Explicit safe HTML opt-in; default false preserves source.

**renderNode** — Trusted product adapter; custom source authors normally use withMarkdownReading.

**renderNodeKey** — @param state - Current snapshot.
@returns Identity covering adapter reads outside each unchanged block, including external state; omit to conservatively reproject.

### MarkdownComponents

`@quirekit/incremark/vue` · MIT

Instance-local semantic tag replacements; application components are trusted code.

```ts
export type MarkdownComponents = Readonly<Partial<Record<string, Component | string>>>;
```

### MarkdownNodeInfo

`@quirekit/incremark/vue` · MIT

Source metadata supplied to registered framework components.

```ts
interface MarkdownNodeInfo {
    readonly type: string;
    readonly from: number;
    readonly to: number;
}
```

**type** — Canonical Lezer syntax name.

**from** — Inclusive UTF-16 offset.

**to** — Exclusive UTF-16 offset.

### MarkdownHtmlOptions

`@quirekit/incremark/vue` · MIT

Additional restrictions over the fixed HTML sanitizer; executable tags cannot be enabled.

```ts
interface MarkdownHtmlOptions {
    readonly styles?: "safe";
    readonly allowedElements?: readonly string[];
    readonly allowLink?: (url: string) => boolean;
    readonly allowImage?: (url: string) => boolean;
}
```

**styles** — Opt into a resource-free CSS subset; style tags remain forbidden.

**allowedElements** — Optional subset of sanitized tags; excluded wrappers are unwrapped.

**allowLink** — @param url - Sanitized destination.
@returns Whether the host permits this link.

**allowImage** — @param url - Sanitized image destination.
@returns Whether the host permits loading it.

### MarkdownRenderOptions

`@quirekit/incremark/vue` · MIT

Rendering configuration does not alter source parsing.

```ts
export interface MarkdownRenderOptions {
    readonly cache?: boolean;
    readonly components?: MarkdownComponents;
    readonly html?: boolean | MarkdownHtmlOptions;
    readonly renderNode?: MarkdownNodeRenderer;
    readonly renderNodeKey?: (state: EditorState) => unknown;
}
```

**cache** — Disable block reuse for diagnostics; parsing remains incremental. Defaults to true in MarkdownRenderer.

**components** — Local overrides layered over native reading defaults.

**html** — Explicit safe HTML opt-in; default false preserves source.

**renderNode** — Trusted product adapter; custom source authors normally use withMarkdownReading.

**renderNodeKey** — @param state - Current snapshot.
@returns Identity covering adapter reads outside each unchanged block, including external state; omit to conservatively reproject.

### MarkdownReadingContext

`@quirekit/incremark/vue` · MIT

Validated Vue reading inputs with bounded recursive helpers.

```ts
export interface MarkdownReadingContext<Attrs extends object = Readonly<Record<string, unknown>>> extends CoreContext<VNodeChild, Attrs> {
}
```

**name** — Installed semantic owner.

**attrs** — Fields validated by the extension's existing source codec.

**node** — Confirmed UTF-16 source syntax.

**document** — Canonical read-only source and shared reference resolution.

**locale** — Host control language.

**renderInline** — @param from - Inclusive content start without splitting a child.
@param to - Exclusive content end.
@returns Ordered projected inline children.

**renderBlocks** — @param omitted - Direct syntax markers excluded from content.
@returns Projected direct blocks.

### MarkdownReadingDefinition

`@quirekit/incremark/vue` · MIT

Vue presentation attached to a source extension.

```ts
export interface MarkdownReadingDefinition<Attrs extends object = Readonly<Record<string, unknown>>, Resource = unknown> extends CoreDefinition<VNodeChild, Attrs, Resource> {
}
```

**cacheKey** — @param document - Current accepted source.
@returns Identity covering codec/render/load reads outside the node; absence disables block reuse.

**load** — @param context - Captured immutable inputs.
@param signal - Aborted on replacement/unmount.
@returns Owned resource; late leases are released, and SSR never loads.

**render** — @param context - Validated source.
@param resource - Accepted resource or undefined without a loader.
@returns Trusted presentation; undefined preserves source.

### withMarkdownReading

`@quirekit/incremark/vue` · MIT

Adds snapshot reading to a fully configured source extension without altering its editing behavior.
@param extension - Existing Node, Mark or source-bearing descriptor; configure/extend it first.
@param definition - Trusted Vue presentation and optional abortable resource acquisition.
@returns An ordinary installable MSFE definition using the original semantic codec and lifecycle.

```ts
function withMarkdownReading<Attrs extends object = Readonly<Record<string, unknown>>, Resource = unknown>(extension: AnyExtension, definition: MarkdownReadingDefinition<Attrs, Resource>): AnyExtension
```

### MarkdownCacheLimits

`@quirekit/incremark/vue` · MIT

Per-reader retention limits; exceeding a limit falls back to ordinary projection.

```ts
interface MarkdownCacheLimits {
    readonly maxBlocks?: number;
    readonly maxSourceUnits?: number;
}
```

**maxBlocks** — Maximum retained top-level blocks; defaults to 2048. Zero disables retention.

**maxSourceUnits** — Maximum sum of cached source spans in UTF-16 units; defaults to 2,000,000. This is not a heap-byte bound.

### MarkdownRenderWork

`@quirekit/incremark/vue` · MIT

Actual work in the most recent projection; excludes parsing, DOM diff and painting.

```ts
interface MarkdownRenderWork {
    visitedBlocks: number;
    reusedBlocks: number;
    projectedNodes: number;
    dependencyNodes: number;
    semanticChecks: number;
    cachedBlocks: number;
    cachedSourceUnits: number;
}
```

**visitedBlocks** — Top-level candidates reached by the reader.

**reusedBlocks** — Candidates whose previous framework output was reused.

**projectedNodes** — Node dispatches actually projected, including deferred custom child helpers.

**dependencyNodes** — Syntax nodes visited to establish new dependency summaries.

**semanticChecks** — Recorded reference, footnote and custom-key values checked on cache hits.

**cachedBlocks** — Blocks retained after the current projection.

**cachedSourceUnits** — Sum of retained block spans in UTF-16 units.

## Advanced projection

### MarkdownRenderer

`@quirekit/incremark/vue` · MIT

Vue-compatible cache owner; all reuse proofs and retention live in core.

```ts
export class MarkdownRenderer extends CoreRenderer<VNodeChild> {
    constructor(limits?: MarkdownCacheLimits);
    override get work(): Readonly<MarkdownRenderWork>;
    override clear(): void;
    override prepare(state: EditorState, locale: MarkdownLocale, prefix?: string, onError?: (error: MarkdownReadingError) => void, options?: MarkdownRenderOptions): MarkdownRenderFrame<VNodeChild>;
    override render(state: EditorState, locale: MarkdownLocale, prefix?: string, onError?: (error: MarkdownReadingError) => void, options?: MarkdownRenderOptions): VNodeChild;
}
```

### renderMarkdown

`@quirekit/incremark/vue` · MIT

@param state - Accepted source.
@param locale - Control language.
@param prefix - Instance namespace.
@param onError - Failure observer.
@param options - Presentation configuration.
@returns Ordinary safe Vue projection over the shared core walker.

```ts
function renderMarkdown(state: EditorState, locale: MarkdownLocale, prefix?: string, onError?: (error: MarkdownReadingError) => void, options?: MarkdownRenderOptions): VNodeChild
```
