@ku0/lfcc-native-core
v0.1.0
Published
LFCC native editor core utilities
Downloads
50
Maintainers
Readme
@ku0/lfcc-native-core
LFCC native editor core model primitives and utility helpers.
What is included
- Base model types: Document, Block, Inline, Mark, Span, Selection, Anchor.
- UTF-16 boundary checks to prevent splitting surrogate pairs.
- Mark order normalization for deterministic output.
Determinism & UTF-16 invariants
- All validation helpers are pure and deterministic (no IO, no randomness).
- UTF-16 offsets must never split surrogate pairs; use
validateUtf16BoundaryandvalidateUtf16Rangebefore applying edits. - Marks should be normalized to a stable order (
normalizeMarkOrder) to ensure canonical output and reproducible hashes.
Usage
import {
DEFAULT_MARK_ORDER,
normalizeMarkOrder,
validateUtf16Boundary,
validateUtf16Range,
type Document,
type Mark,
} from "@ku0/lfcc-native-core";
const marks: Mark[] = [{ type: "bold" }, { type: "link", attrs: { href: "https://example.com" } }];
const normalized = normalizeMarkOrder(marks, DEFAULT_MARK_ORDER);
const boundary = validateUtf16Boundary("A\uD83D\uDE00B", 1);
const range = validateUtf16Range("A\uD83D\uDE00B", 1, 3);
const doc: Document = {
id: "doc-1",
blocks: [],
};Commands
pnpm --filter @ku0/lfcc-native-core test
pnpm --filter @ku0/lfcc-native-core build
pnpm --filter @ku0/lfcc-native-core lint:fix