refactor: extract op-codegen crate

Relocate codegen.rs + codegen_targets.rs out of openpencil-shell-core
into a dedicated op-codegen crate. The code generators only depend on
jian-ops-schema + op-editor-core, so they form a clean leaf crate.
codegen.rs becomes the crate's lib.rs; crate::codegen:: paths in
codegen_targets.rs collapse to crate::. Pure relocation, no behaviour
change; tests move with their code.
This commit is contained in:
Kayshen-X 2026-05-16 23:14:45 +08:00
parent a18ca7bbfe
commit 0cb56ecd9e
4 changed files with 21 additions and 6 deletions

View file

@ -0,0 +1,15 @@
[package]
name = "op-codegen"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
description = "OpenPencil code generators — emit HTML/Vue/Svelte/React/Flutter/SwiftUI/Compose/RN from a PenDocument"
[lib]
name = "op_codegen"
path = "src/lib.rs"
[dependencies]
jian-ops-schema = { path = "../../vendor/jian/crates/jian-ops-schema" }
op-editor-core = { path = "../op-editor-core" }

View file

@ -1,13 +1,13 @@
//! Per-framework markup generators — the React / Vue / Svelte / HTML
//! / Flutter / SwiftUI / Compose / React Native targets carved off
//! `codegen.rs` to keep both files under the 800-line cap.
//! `lib.rs` to keep both files under the 800-line cap.
//!
//! All generators consume the canonical `jian_ops_schema::PenDocument`
//! and walk `PenNode` through the flat-view accessors in the parent
//! `codegen` module (`node_origin` / `node_size` / `node_fill_css` /
//! and walk `PenNode` through the flat-view accessors in the crate
//! root (`node_origin` / `node_size` / `node_fill_css` /
//! …) so the per-target emit logic stays variant-agnostic.
use crate::codegen::{
use crate::{
color_to_css, fmt_num, html_escape, node_children, node_corner_radius, node_fill_css,
node_hidden, node_is_ellipse, node_is_text, node_origin, node_rotation_deg, node_size,
node_stroke_css, node_text, parse_color, root_nodes, Codegen, CssVariables,

View file

@ -12,6 +12,8 @@
//! node-accessor helpers, and the test suite; per-framework markup
//! generators live in the sibling `codegen_targets` module.
mod codegen_targets;
pub use crate::codegen_targets::{
Compose, Flutter, Html, React, ReactNative, Svelte, SwiftUi, Vue,
};

View file

@ -19,8 +19,6 @@
pub mod agent_settings_state;
pub mod chat_models;
pub mod chat_provider;
pub mod codegen;
mod codegen_targets;
pub mod figma;
// Phase 3 strangler reorg: i18n extracted into the op-i18n crate. Re-exported
// as `i18n` so `crate::i18n::translate` / `crate::i18n::Locale` paths still resolve.