@ku0/lfcc-native-view
v0.1.0
Published
LFCC native editor view layer - model-first projection system
Downloads
10
Maintainers
Readme
@ku0/lfcc-native-view
Projection view layer for the LFCC native editor.
Overview
This package applies model-first projection patches to platform views. The model remains the single source of truth, and the view consumes deterministic patch streams.
Features
- Deterministic patch applicator interfaces (
PatchApplicator,BasePatchApplicator). - DOM applicator with:
- block index caching for faster block lookup,
- guarded block identity (
data-lfcc-block-idprotection), - atomic batch pre-validation (fail before mutation),
- selection metadata + best-effort DOM Selection projection.
- Native applicator with deterministic in-memory projection snapshots.
- Terminal applicator with deterministic in-memory state + text frame renderer.
Usage
import { DOMPatchApplicator } from "@ku0/lfcc-native-view";
import type { Patch } from "@ku0/lfcc-native-view";
const applicator = new DOMPatchApplicator(document.getElementById("editor-root")!);
const patches: Patch[] = [
{
type: "insert_block",
target: "block-1",
blockId: "block-1",
node: {
id: "node-1",
tag: "p",
attrs: {},
children: ["Hello LFCC"],
},
},
{
type: "update_selection",
target: "selection",
selection: {
anchorBlock: "block-1",
anchorOffset: 0,
focusBlock: "block-1",
focusOffset: 5,
},
scrollIntoView: true,
},
];
const results = applicator.applyBatch(patches);Native/terminal can be used without a DOM:
import { NativePatchApplicator, TerminalPatchApplicator } from "@ku0/lfcc-native-view";
const native = new NativePatchApplicator();
const terminal = new TerminalPatchApplicator();
native.applyPatch(/* ... */);
terminal.applyPatch(/* ... */);
const snapshot = native.snapshot();
const frame = terminal.renderFrame({ includeMarks: true });Validation
pnpm --filter @ku0/lfcc-native-view check
pnpm --filter @ku0/lfcc-native-view test:run
pnpm --filter @ku0/lfcc-native-view build