mdz_stream_state.svelte.ts

Reactive state for the mdz streaming renderer.

Maintains a reactive tree of MdzStreamNode objects that Svelte 5 can efficiently update. Opcodes from MdzStreamParser are applied via apply() or apply_batch(), mutating the tree in place.

view source

Declarations
#

2 declarations

MdzStreamNode
#

mdz_stream_state.svelte.ts view source

import {MdzStreamNode} from '@fuzdev/mdz/mdz_stream_state.svelte.js';

A reactive node in the stream renderer tree. Fields are $state so Svelte re-renders only what changes.

id

type MdzNodeId

type

type MdzNodeType

content

type string

$state

children

type Array<MdzStreamNode>

$state

level?

type 1 | 2 | 3 | 4 | 5 | 6

reference?

type string

$state

link_type?

type 'external' | 'internal'

$state

name?

type string

lang?

type string | null

heading_id?

type string

$state

ordered?

type boolean

start_number?

type number

number?

type number

constructor

type new (id: number, type: MdzNodeType): MdzStreamNode

id

type number

type

MdzStreamState
#

mdz_stream_state.svelte.ts view source

import {MdzStreamState} from '@fuzdev/mdz/mdz_stream_state.svelte.js';

Reactive state manager for streaming mdz content. Apply opcodes to incrementally build and update the render tree.

Lifecycle: one state instance per stream, paired with one MdzStreamParser. Opcodes must be applied exactly once, in emission order — take_opcodes() batches can be split or concatenated freely, but never reordered, skipped, or replayed. There is no reset(); to restart a stream, construct a new parser and a new state.

root

type Array<MdzStreamNode>

$state

apply

Apply a single opcode.

type (opcode: MdzOpcode): void

opcode

returns void

apply_batch

Apply a batch of opcodes.

type (opcodes: MdzOpcode[]): void

opcodes

type MdzOpcode[]
returns void

Depends on
#

Imported by
#