4.2 KiB
4.2 KiB
Package split plan
OpenPencil currently keeps file-format internals in @open-pencil/core while @open-pencil/dom-css is being split out as a standalone DOM/CSS compatibility layer. Future package splits should preserve the current app behavior first, then move stable surfaces into independently publishable packages.
Goals
- Keep renderer/editor core free of DOM and browser-only dependencies.
- Let
.fig, Kiwi, and DOM/CSS compatibility evolve without forcing consumers to install unrelated heavy dependencies. - Preserve import/export fidelity by moving code only after oracle coverage exists.
- Keep public APIs narrow and package-local checks available for every standalone package.
Current package boundary
@open-pencil/coreowns scene graph, renderer, editor actions, Figma API compatibility, Kiwi codec internals, and format import/export.@open-pencil/dom-cssowns DesignDOM, CSS runtimes, HTML/JSX/Tailwind projection, and SceneGraph ⇄ DesignDOM conversion.- App, CLI, MCP, and Vue SDK consume packages through public workspace exports only.
Candidate packages
@open-pencil/kiwi
Scope:
- Kiwi binary schema runtime.
- Schema-generated codec modules.
- Generic binary parse/serialize helpers.
- Low-level validation helpers that do not know about OpenPencil scene graph nodes.
Should not include:
- Figma
.figcontainer policy. - SceneGraph conversion.
- Renderer/editor code.
Minimum exit criteria:
- Package-local typecheck, unit tests, build, and dist smoke.
- Existing Kiwi serialize/parse tests passing through the package public API.
- No import cycles from
@open-pencil/coreback into the package.
@open-pencil/fig
Scope:
.figcontainer read/write.- Figma node-change import/export.
- Raw metadata preservation and invalidation policy.
- Figma oracle fixtures and compatibility helpers.
Should depend on:
@open-pencil/corescene graph types.@open-pencil/kiwionce the Kiwi split exists.
Should not include:
- Canvas rendering.
- Editor UI/actions.
- DOM/CSS compatibility.
Minimum exit criteria:
- Import/export round-trip tests moved or duplicated as package-local coverage.
- Heavy Figma fixture coverage still available at repo level.
- Public API supports CLI/MCP/app document I/O without private path imports.
Initial inventory
Likely @open-pencil/kiwi candidates:
packages/core/src/kiwi/schema-runtime/**packages/core/src/kiwi/fig/codec/**- Generated Kiwi schema modules under the Figma codec directory, as long as they stay scene-graph agnostic
Likely @open-pencil/fig candidates:
packages/core/src/kiwi/fig/file.tspackages/core/src/kiwi/fig/container/**packages/core/src/kiwi/fig/parse/**packages/core/src/kiwi/fig/import.tspackages/core/src/kiwi/fig/node-change/**packages/core/src/kiwi/fig/instance-overrides/**packages/core/src/io/formats/fig/**
Keep in @open-pencil/core unless proven otherwise:
SceneGraphand node type definitions- Renderer/editor fallback behavior
- Layout, text measurement, and canvas-specific code
- Generic IO registry contracts that other formats use
Migration checklist
- Add package-local tests before moving files.
- Confirm every moved module imports only allowed public package exports.
- Preserve existing
@open-pencil/core/kiwire-exports during the first migration step. - Move one boundary at a time: schema runtime first, generated codec second,
.figpolicy last. - Keep fixture/oracle tests in the repo-level suite even after package-local tests exist.
- Run package smoke checks from a temporary consumer project before publishing.
Migration order
- Keep
@open-pencil/dom-cssstandalone and stabilize its browser/headless runtime split. - Extract pure Kiwi runtime/codecs behind
@open-pencil/kiwiwithout moving.figpolicy. - Move
.figcontainer and node-change conversion into@open-pencil/fig. - Update core/app/CLI/MCP imports to consume public package exports.
- Keep compatibility re-exports in
@open-pencil/coreonly if existing consumers need a deprecation window.
Non-goals
- Do not guess Figma schema fields during the split.
- Do not move renderer-specific fallback behavior into file-format packages.
- Do not add browser DOM dependencies to core or file-format packages.