Skip to main content

Module js_commands

Module js_commands 

Source
Expand description

Binary command buffer parser and mutation applicator.

Reads a command buffer produced by the JS CommandBuffer class, converts commands into arena mutations, and returns the rebuilt arena.

§Wire format

All multi-byte integers are little-endian. A command is one CMD_* byte plus [nodeId: u32]; structural commands then carry a [payloadType: u8][len: u32][payload…] sub-tree. The command, payload, op-stream, and property-kind byte values (with their operand layouts) are declared once in satteri-layout-codegen/src/schema.rs and generated into generated/wire_constants.rs here and packages/satteri/src/generated/wire-constants.ts on the JS side.

The MDAST and HAST command paths are deliberately separate functions (apply_mdast_commands, apply_hast_commands). Numeric node_type values overlap between the two arenas (e.g. mdast Paragraph=1 collides with HastNodeType::Element=1), so a single dispatcher trying to handle both kinds would silently misroute nodes. The phantom-typed Arena<K> signature on each entry point makes a cross-kind call a compile error.

Structs§

MdastCommandOptions
Options controlling how MDAST command buffers are applied.

Functions§

apply_hast_commands
Apply a command buffer to a HAST arena. Set-property mutations are applied in-place; structural mutations are collected as Patch<Hast> objects and applied in place via apply_patches_in_place. Errors if a patch is stranded inside a removed/replaced subtree; apply_hast_commands_lenient drops it instead.
apply_hast_commands_lenient
Like apply_hast_commands, but rather than erroring when a patch targets a node inside a removed/replaced subtree, drops it and returns the dropped anchors — mirroring apply_mdast_commands_lenient. Such a patch is moot: the plugin discarded that subtree. A passed-through child keeps its identity (via _ref) and so is never stranded this way.
apply_mdast_commands
Apply a command buffer to an MDAST arena. Set-property mutations are applied in-place; structural mutations are collected as Patch<Mdast> objects and applied in place via apply_patches_in_place.
apply_mdast_commands_lenient
Like apply_mdast_commands, but rather than erroring when a patch targets a node inside a removed/replaced subtree, drops it and returns the dropped anchors. Such a patch is moot — the plugin discarded that subtree. A passed-through child is not dropped: it rides a _ref placeholder that splices it back with its id intact, so a transform queued on a nested node (e.g. a :::tip inside a :::note) still applies, in the same pass.
apply_mdast_commands_lenient_with_options
Like apply_mdast_commands_lenient, with explicit command application options.
apply_mdast_commands_with_options
Like apply_mdast_commands, with explicit command application options.