Skip to content

AI-native design editor. Open-source Figma alternative.

feat: split SceneGraph and Pen packages

Danila Poyarkov898431e64640
diff --git a/bun.lock b/bun.lock
index 55f9c5755..4dde25f69 100644
--- a/bun.lock
+++ b/bun.lock
@@ -19,6 +19,8 @@
"@open-pencil/dom-css": "workspace:*",
"@open-pencil/fig": "workspace:*",
"@open-pencil/kiwi": "workspace:*",
+ "@open-pencil/pen": "workspace:*",
+ "@open-pencil/scene-graph": "workspace:*",
"@open-pencil/vue": "workspace:*",
"@openrouter/ai-sdk-provider": "^2.9.0",
"@tailwindcss/vite": "^4.2.1",
@@ -108,6 +110,7 @@
"dependencies": {
"@open-pencil/core": "workspace:*",
"@open-pencil/dom-css": "workspace:*",
+ "@open-pencil/scene-graph": "workspace:*",
"agentfmt": "^0.1.3",
"canvaskit-wasm": "^0.40.0",
"citty": "^0.1.6",
@@ -123,6 +126,8 @@
"@chenglou/pretext": "^0.0.7",
"@iconify/utils": "^3.1.0",
"@open-pencil/kiwi": "workspace:*",
+ "@open-pencil/pen": "workspace:*",
+ "@open-pencil/scene-graph": "workspace:*",
"@tauri-apps/api": "^2",
"acorn": "^8.16.0",
"canvaskit-wasm": "^0.40.0",
@@ -176,6 +181,7 @@
},
"peerDependencies": {
"@open-pencil/core": "workspace:*",
+ "@open-pencil/scene-graph": "workspace:*",
},
},
"packages/fig": {
@@ -187,7 +193,6 @@
"typescript": "~5.8.3",
},
"peerDependencies": {
- "@open-pencil/core": "workspace:*",
"@open-pencil/kiwi": "workspace:*",
},
},
@@ -225,6 +230,36 @@
"@types/ws": "^8.18.1",
},
},
+ "packages/pen": {
+ "name": "@open-pencil/pen",
+ "version": "0.13.2",
+ "dependencies": {
+ "culori": "^4.0.2",
+ },
+ "devDependencies": {
+ "@types/bun": "^1.3.14",
+ "@types/culori": "^4.0.1",
+ "tsdown": "^0.21.7",
+ "typescript": "~5.8.3",
+ },
+ "peerDependencies": {
+ "@open-pencil/scene-graph": "workspace:*",
+ },
+ },
+ "packages/scene-graph": {
+ "name": "@open-pencil/scene-graph",
+ "version": "0.13.2",
+ "dependencies": {
+ "es-toolkit": "^1.46.1",
+ "nanoevents": "^9.1.0",
+ "svgpath": "^2.6.0",
+ },
+ "devDependencies": {
+ "@types/bun": "^1.3.14",
+ "tsdown": "^0.21.7",
+ "typescript": "~5.8.3",
+ },
+ },
"packages/vue": {
"name": "@open-pencil/vue",
"version": "0.13.2",
@@ -233,6 +268,7 @@
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
"@nanostores/i18n": "^1.2.2",
"@nanostores/vue": "^1.1.0",
+ "@open-pencil/scene-graph": "workspace:*",
"@tanstack/vue-table": "^8.21.3",
"@vueuse/core": "^14.2.1",
"nanostores": "^1.2.0",
@@ -819,6 +855,10 @@
"@open-pencil/mcp": ["@open-pencil/mcp@workspace:packages/mcp"],
+ "@open-pencil/pen": ["@open-pencil/pen@workspace:packages/pen"],
+
+ "@open-pencil/scene-graph": ["@open-pencil/scene-graph@workspace:packages/scene-graph"],
+
"@open-pencil/vue": ["@open-pencil/vue@workspace:packages/vue"],
"@openrouter/ai-sdk-provider": ["@openrouter/[email protected]", "", { "peerDependencies": { "ai": "^6.0.0", "zod": "^3.25.0 || ^4.0.0" } }, "sha512-Seva+NCa0WUQnJIUE5GzHsUv1WTIeyqwz0ELl2VtS6NP+eF+77yCXGFVOMbvoCM7QMjlnhv7931e89R+8pJdcQ=="],
diff --git a/oxlint.json b/oxlint.json
index 3fb9f7c00..da4cf9c76 100644
--- a/oxlint.json
+++ b/oxlint.json
@@ -472,6 +472,22 @@
"no-console": "off"
}
},
+ {
+ "files": [
+ "packages/scene-graph/src/constants.ts"
+ ],
+ "rules": {
+ "open-pencil/no-hardcoded-color-constants": "off"
+ }
+ },
+ {
+ "files": [
+ "packages/scene-graph/src/index.ts"
+ ],
+ "rules": {
+ "open-pencil/no-direct-graph-emitter-subscriptions": "off"
+ }
+ },
{
"files": [
"packages/core/src/io/formats/fig/export.ts",
diff --git a/package.json b/package.json
index 9929430a4..f8a5fb92c 100644
--- a/package.json
+++ b/package.json
@@ -12,9 +12,9 @@
"build": "bun run build:packages && bun run lint && vite build",
"preview": "vite preview",
"tauri": "tauri",
- "lint": "bun run lint:structure && oxlint -c oxlint.json --type-aware --type-check src/ packages/core/src/ packages/vue/src/ packages/cli/src/ packages/mcp/src/ packages/dom-css/src/ packages/kiwi/src/ packages/fig/src/",
- "lint:structure": "oxlint -c oxlint.json vite.config.ts vite/ src/ packages/core/src/ packages/vue/src/ packages/cli/src/ packages/mcp/src/ packages/dom-css/src/ packages/dom-css/tests/ packages/dom-css/scripts/ packages/kiwi/src/ packages/kiwi/tests/ packages/kiwi/scripts/ packages/fig/src/ packages/fig/tests/ packages/fig/scripts/ tests/ scripts/ tools/",
- "format": "oxfmt --write .oxfmtrc.json vite.config.ts vite/ src/ packages/core/src/ packages/cli/src/ packages/mcp/src/ packages/vue/src/ packages/dom-css/src/ packages/dom-css/tests/ packages/dom-css/scripts/ packages/kiwi/src/ packages/kiwi/tests/ packages/kiwi/scripts/ packages/fig/src/ packages/fig/tests/ packages/fig/scripts/ tests scripts/ tools/",
+ "lint": "bun run lint:structure && oxlint -c oxlint.json --type-aware --type-check src/ packages/scene-graph/src/ packages/core/src/ packages/vue/src/ packages/cli/src/ packages/mcp/src/ packages/dom-css/src/ packages/pen/src/ packages/kiwi/src/ packages/fig/src/",
+ "lint:structure": "oxlint -c oxlint.json vite.config.ts vite/ src/ packages/scene-graph/src/ packages/scene-graph/scripts/ packages/core/src/ packages/vue/src/ packages/cli/src/ packages/mcp/src/ packages/dom-css/src/ packages/dom-css/tests/ packages/dom-css/scripts/ packages/pen/src/ packages/pen/scripts/ packages/kiwi/src/ packages/kiwi/tests/ packages/kiwi/scripts/ packages/fig/src/ packages/fig/tests/ packages/fig/scripts/ tests/ scripts/ tools/",
+ "format": "oxfmt --write .oxfmtrc.json vite.config.ts vite/ src/ packages/scene-graph/src/ packages/scene-graph/scripts/ packages/core/src/ packages/cli/src/ packages/mcp/src/ packages/vue/src/ packages/dom-css/src/ packages/dom-css/tests/ packages/dom-css/scripts/ packages/pen/src/ packages/pen/scripts/ packages/kiwi/src/ packages/kiwi/tests/ packages/kiwi/scripts/ packages/fig/src/ packages/fig/tests/ packages/fig/scripts/ tests scripts/ tools/",
"format:check": "bun run format && status=$(git status --porcelain -uall) && test -z \"$status\" || (echo \"$status\" && exit 1)",
"check": "bun run build:packages && bun run lint && tsgo --noEmit && bun run check:vue && bun run check:i18n && bun run check:packages && bun run check:arch && bun run test:type-shapes && bun run test:tools && bun run test:dupes",
"check:i18n": "bun tools/i18n/src/check-locales.ts",
@@ -29,9 +29,9 @@
"test:coverage": "bun test --coverage ./tests/engine",
"test:type-shapes": "bun tools/type-shapes/src/index.ts",
"test:tools": "bun tools/test.ts",
- "test:dupes": "jscpd packages/core/src packages/cli/src packages/dom-css/src src --min-lines 5 --min-tokens 50 --format typescript --threshold 0",
+ "test:dupes": "jscpd packages/scene-graph/src packages/pen/src packages/core/src packages/cli/src packages/dom-css/src src --min-lines 5 --min-tokens 50 --format typescript --threshold 0",
"test:packages": "bun tools/package-quality/src/check-metadata.ts && bun tools/package-quality/src/smoke.ts",
- "build:packages": "bun --filter @open-pencil/kiwi build && bun --filter @open-pencil/fig build && bun --filter @open-pencil/core build && bun --filter @open-pencil/dom-css build && bun --filter @open-pencil/vue build && bun --filter @open-pencil/mcp build && bun --filter @open-pencil/cli build",
+ "build:packages": "bun --filter @open-pencil/scene-graph build && bun --filter @open-pencil/pen build && bun --filter @open-pencil/kiwi build && bun --filter @open-pencil/fig build && bun --filter @open-pencil/core build && bun --filter @open-pencil/dom-css build && bun --filter @open-pencil/vue build && bun --filter @open-pencil/mcp build && bun --filter @open-pencil/cli build",
"open-pencil": "bun packages/cli/src/index.ts",
"docs:dev": "bun --filter @open-pencil/docs dev",
"docs:build": "bun --filter @open-pencil/docs build",
@@ -93,7 +93,9 @@
"y-protocols": "^1.0.7",
"yjs": "^13.6.29",
"yoga-layout": "npm:@open-pencil/[email protected]",
- "zod": "^4.3.6"
+ "zod": "^4.3.6",
+ "@open-pencil/scene-graph": "workspace:*",
+ "@open-pencil/pen": "workspace:*"
},
"overrides": {
"brace-expansion": "5.0.6"
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 1b7f99036..892f1a363 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -29,6 +29,7 @@
"dependencies": {
"@open-pencil/core": "workspace:*",
"@open-pencil/dom-css": "workspace:*",
+ "@open-pencil/scene-graph": "workspace:*",
"agentfmt": "^0.1.3",
"canvaskit-wasm": "^0.40.0",
"citty": "^0.1.6"
diff --git a/packages/cli/src/commands/node.ts b/packages/cli/src/commands/node.ts
index c09462466..422e25b05 100644
--- a/packages/cli/src/commands/node.ts
+++ b/packages/cli/src/commands/node.ts
@@ -2,7 +2,7 @@ import { defineCommand } from 'citty'
import { colorToHex } from '@open-pencil/core/color'
import type { NodeResult } from '@open-pencil/core/rpc'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import { fmtNode, printError, formatType } from '#cli/format'
import { loadRpcData } from '#cli/rpc-data'
diff --git a/packages/cli/src/format.ts b/packages/cli/src/format.ts
index 72018c599..f6cff82f7 100644
--- a/packages/cli/src/format.ts
+++ b/packages/cli/src/format.ts
@@ -15,7 +15,7 @@ import {
} from 'agentfmt'
import type { TreeNode, ListItem, NodeData } from 'agentfmt'
-import type { SceneGraph, SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export {
ok,
diff --git a/packages/cli/src/headless.ts b/packages/cli/src/headless.ts
index f6cae27c8..4ec11c262 100644
--- a/packages/cli/src/headless.ts
+++ b/packages/cli/src/headless.ts
@@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises'
import { BUILTIN_IO_FORMATS, IORegistry, initCanvasKit } from '@open-pencil/core/io'
import { computeAllLayouts } from '@open-pencil/core/layout'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
export { initCanvasKit }
diff --git a/packages/core/package.json b/packages/core/package.json
index ec79a9e35..6bba49a94 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -14,11 +14,6 @@
"default": "./dist/index.js",
"import": "./dist/index.js"
},
- "./scene-graph": {
- "types": "./dist/scene-graph/index.d.ts",
- "default": "./dist/scene-graph/index.js",
- "import": "./dist/scene-graph/index.js"
- },
"./color": {
"types": "./dist/color/index.d.ts",
"default": "./dist/color/index.js",
@@ -134,11 +129,6 @@
"default": "./dist/xpath.js",
"import": "./dist/xpath.js"
},
- "./types": {
- "types": "./dist/types.d.ts",
- "default": "./dist/types.js",
- "import": "./dist/types.js"
- },
"./canvaskit": {
"types": "./dist/canvaskit.d.ts",
"default": "./dist/canvaskit.js",
@@ -148,11 +138,6 @@
"types": "./dist/layout.d.ts",
"default": "./dist/layout.js",
"import": "./dist/layout.js"
- },
- "./geometry": {
- "types": "./dist/geometry.d.ts",
- "default": "./dist/geometry.js",
- "import": "./dist/geometry.js"
}
},
"main": "./dist/index.js",
@@ -195,7 +180,9 @@
"svg2pdf.js": "^2.7.0",
"svgpath": "^2.6.0",
"twirlwind": "^0.3.0",
- "yoga-layout": "npm:@open-pencil/[email protected]"
+ "yoga-layout": "npm:@open-pencil/[email protected]",
+ "@open-pencil/scene-graph": "workspace:*",
+ "@open-pencil/pen": "workspace:*"
},
"devDependencies": {
"@types/culori": "^4.0.1",
diff --git a/packages/core/src/canvas/blend.ts b/packages/core/src/canvas/blend.ts
index c72eff7c7..0c7c7dbdd 100644
--- a/packages/core/src/canvas/blend.ts
+++ b/packages/core/src/canvas/blend.ts
@@ -1,6 +1,6 @@
import type { BlendMode as SkBlendMode, CanvasKit } from 'canvaskit-wasm'
-import type { BlendMode } from '#core/scene-graph'
+import type { BlendMode } from '@open-pencil/scene-graph'
export function figmaBlendModeToSkia(ck: CanvasKit, mode?: BlendMode): SkBlendMode {
switch (mode) {
diff --git a/packages/core/src/canvas/boolean.ts b/packages/core/src/canvas/boolean.ts
index a8bcd1fe7..4d8feab82 100644
--- a/packages/core/src/canvas/boolean.ts
+++ b/packages/core/src/canvas/boolean.ts
@@ -1,6 +1,7 @@
import type { Canvas, Path, PathOp } from 'canvaskit-wasm'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { getTextOutlineSupport } from '#core/text/outlines'
import { makeArcPath } from './fills'
diff --git a/packages/core/src/canvas/effects.ts b/packages/core/src/canvas/effects.ts
index ad1ee3a8d..05281dc34 100644
--- a/packages/core/src/canvas/effects.ts
+++ b/packages/core/src/canvas/effects.ts
@@ -1,6 +1,6 @@
import type { Canvas, ImageFilter, MaskFilter } from 'canvaskit-wasm'
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/fills.ts b/packages/core/src/canvas/fills.ts
index 9e220f19a..6e8369676 100644
--- a/packages/core/src/canvas/fills.ts
+++ b/packages/core/src/canvas/fills.ts
@@ -1,7 +1,7 @@
import type { Canvas, Paint } from 'canvaskit-wasm'
-import type { SceneNode, SceneGraph, Fill } from '#core/scene-graph'
-import type { Rect, Vector } from '#core/types'
+import type { SceneNode, SceneGraph, Fill } from '@open-pencil/scene-graph'
+import type { Rect, Vector } from '@open-pencil/scene-graph/primitives'
import type { SkiaRenderer } from './renderer'
import { makeSmoothRRectPath, nodeHasSmoothCorners } from './shapes'
diff --git a/packages/core/src/canvas/flatten.ts b/packages/core/src/canvas/flatten.ts
index db36a25dd..f935ea84a 100644
--- a/packages/core/src/canvas/flatten.ts
+++ b/packages/core/src/canvas/flatten.ts
@@ -1,6 +1,7 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import { copyFills } from '@open-pencil/scene-graph/copy'
+
import { parseSVGPath } from '#core/io/formats/svg/parse-path'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import { copyFills } from '#core/scene-graph/copy'
import { makeBooleanSourcePath, makeStrokeOutlinePath, nodePathTransform } from './boolean'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/highlight-rect.ts b/packages/core/src/canvas/highlight-rect.ts
index cabc3be2d..46d62afe0 100644
--- a/packages/core/src/canvas/highlight-rect.ts
+++ b/packages/core/src/canvas/highlight-rect.ts
@@ -1,7 +1,8 @@
import type { Canvas, Paint } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { FLASH_PADDING, FLASH_STROKE_WIDTH, FLASH_RADIUS } from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/index.ts b/packages/core/src/canvas/index.ts
index 9e4fa651c..ceb2c0287 100644
--- a/packages/core/src/canvas/index.ts
+++ b/packages/core/src/canvas/index.ts
@@ -5,4 +5,3 @@ export {
nodeHasVisibleStroke
} from './boolean'
export { SkiaRenderer, type RenderOverlays, type RulerTheme } from './renderer'
-export { getAbsolutePositionFull, getAbsoluteRotation, getWorldHandles } from './coordinate'
diff --git a/packages/core/src/canvas/labels/cache.ts b/packages/core/src/canvas/labels/cache.ts
index 752a4a90c..ef416bbfd 100644
--- a/packages/core/src/canvas/labels/cache.ts
+++ b/packages/core/src/canvas/labels/cache.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export interface CachedSection {
nodeId: string
diff --git a/packages/core/src/canvas/labels/draw.ts b/packages/core/src/canvas/labels/draw.ts
index 7893013d9..d05cef959 100644
--- a/packages/core/src/canvas/labels/draw.ts
+++ b/packages/core/src/canvas/labels/draw.ts
@@ -1,5 +1,7 @@
import type { Canvas, Font } from 'canvaskit-wasm'
+import type { SceneNode, SceneGraph } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import {
SECTION_TITLE_HEIGHT,
@@ -11,7 +13,6 @@ import {
COMPONENT_LABEL_ICON_SIZE,
COMPONENT_LABEL_ICON_GAP
} from '#core/constants'
-import type { SceneNode, SceneGraph } from '#core/scene-graph'
import { ellipsizeLabelText } from './text'
diff --git a/packages/core/src/canvas/labels/hit-test.ts b/packages/core/src/canvas/labels/hit-test.ts
index c9263bf3e..008c701ae 100644
--- a/packages/core/src/canvas/labels/hit-test.ts
+++ b/packages/core/src/canvas/labels/hit-test.ts
@@ -1,5 +1,8 @@
import type { Font } from 'canvaskit-wasm'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import {
COMPONENT_LABEL_FONT_SIZE,
COMPONENT_LABEL_GAP,
@@ -11,8 +14,6 @@ import {
SECTION_TITLE_HEIGHT,
SECTION_TITLE_PADDING_X
} from '#core/constants'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Vector } from '#core/types'
import type { CachedComponent, CachedSection, LabelCache } from './cache'
diff --git a/packages/core/src/canvas/labels/selection.ts b/packages/core/src/canvas/labels/selection.ts
index 0de992a5c..a3dee423b 100644
--- a/packages/core/src/canvas/labels/selection.ts
+++ b/packages/core/src/canvas/labels/selection.ts
@@ -1,6 +1,9 @@
import type { Canvas } from 'canvaskit-wasm'
-import { getAbsolutePosition, getWorldMatrix } from '#core/canvas/coordinate'
+import type { SceneNode, SceneGraph } from '@open-pencil/scene-graph'
+import { getAbsolutePosition, getWorldMatrix } from '@open-pencil/scene-graph/coordinate'
+import { rotatedCorners } from '@open-pencil/scene-graph/geometry'
+
import type { SkiaRenderer, RenderOverlays } from '#core/canvas/renderer'
import {
LABEL_OFFSET_Y,
@@ -10,8 +13,6 @@ import {
SIZE_PILL_RADIUS,
SIZE_PILL_TEXT_OFFSET_Y
} from '#core/constants'
-import { rotatedCorners } from '#core/geometry'
-import type { SceneNode, SceneGraph } from '#core/scene-graph'
import { ellipsizeLabelText } from './text'
diff --git a/packages/core/src/canvas/layout-grids.ts b/packages/core/src/canvas/layout-grids.ts
index 920fb558d..645a3383d 100644
--- a/packages/core/src/canvas/layout-grids.ts
+++ b/packages/core/src/canvas/layout-grids.ts
@@ -1,8 +1,9 @@
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { SELECTION_COLOR } from '#core/constants'
-import type { SceneNode } from '#core/scene-graph'
-import type { Color } from '#core/types'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/masks.ts b/packages/core/src/canvas/masks.ts
index 7454c3efc..6ddd07959 100644
--- a/packages/core/src/canvas/masks.ts
+++ b/packages/core/src/canvas/masks.ts
@@ -1,7 +1,7 @@
import type { Canvas } from 'canvaskit-wasm'
-import type { MaskType } from '#core/scene-graph'
-import type { Rect } from '#core/types'
+import type { MaskType } from '@open-pencil/scene-graph'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/node-edit-overlay.ts b/packages/core/src/canvas/node-edit-overlay.ts
index 9b8f1c03c..c03c63d00 100644
--- a/packages/core/src/canvas/node-edit-overlay.ts
+++ b/packages/core/src/canvas/node-edit-overlay.ts
@@ -1,8 +1,14 @@
import type { Canvas, Paint } from 'canvaskit-wasm'
+import type {
+ VectorVertex,
+ VectorSegment,
+ VectorRegion,
+ SceneGraph
+} from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import { PEN_HANDLE_RADIUS, PEN_VERTEX_RADIUS } from '#core/constants'
-import type { VectorVertex, VectorSegment, VectorRegion, SceneGraph } from '#core/scene-graph'
-import type { Vector } from '#core/types'
import { vectorNetworkToPath } from '#core/vector'
import { computeAccurateBounds } from '#core/vector/bezier'
diff --git a/packages/core/src/canvas/overlays/ai.ts b/packages/core/src/canvas/overlays/ai.ts
index beb2d8826..575b2cb1d 100644
--- a/packages/core/src/canvas/overlays/ai.ts
+++ b/packages/core/src/canvas/overlays/ai.ts
@@ -1,5 +1,7 @@
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { drawNodeHighlightRect } from '#core/canvas/highlight-rect'
import type { SkiaRenderer } from '#core/canvas/renderer'
import {
@@ -8,7 +10,6 @@ import {
AI_PULSE_PERIOD_MS,
AI_DONE_DURATION_MS
} from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
export function drawAiOverlays(r: SkiaRenderer, canvas: Canvas, graph: SceneGraph): void {
const now = performance.now()
diff --git a/packages/core/src/canvas/overlays/auto-layout-hover.ts b/packages/core/src/canvas/overlays/auto-layout-hover.ts
index 74a982c58..a6b4d6177 100644
--- a/packages/core/src/canvas/overlays/auto-layout-hover.ts
+++ b/packages/core/src/canvas/overlays/auto-layout-hover.ts
@@ -1,5 +1,8 @@
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'
import {
AUTO_LAYOUT_HOVER_BLUE,
@@ -16,8 +19,6 @@ import {
AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X,
AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS
} from '#core/constants'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Color } from '#core/types'
type Hover = NonNullable<RenderOverlays['autoLayoutHover']>
type RectTuple = [x: number, y: number, width: number, height: number]
diff --git a/packages/core/src/canvas/overlays/feedback.ts b/packages/core/src/canvas/overlays/feedback.ts
index 59004d3e6..ba2a302ce 100644
--- a/packages/core/src/canvas/overlays/feedback.ts
+++ b/packages/core/src/canvas/overlays/feedback.ts
@@ -1,5 +1,9 @@
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
+import type { SnapGuide } from '@open-pencil/scene-graph/snap'
+
import { drawNodeHighlightRect } from '#core/canvas/highlight-rect'
import type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'
import {
@@ -11,9 +15,6 @@ import {
LAYOUT_INDICATOR_STROKE,
MARQUEE_FILL_ALPHA
} from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
-import type { SnapGuide } from '#core/scene-graph/snap'
-import type { Rect } from '#core/types'
export function drawSnapGuides(r: SkiaRenderer, canvas: Canvas, guides?: SnapGuide[]): void {
if (!guides || guides.length === 0) return
diff --git a/packages/core/src/canvas/overlays/selection.ts b/packages/core/src/canvas/overlays/selection.ts
index 04dafad92..69579a4c9 100644
--- a/packages/core/src/canvas/overlays/selection.ts
+++ b/packages/core/src/canvas/overlays/selection.ts
@@ -1,12 +1,13 @@
import type { Canvas } from 'canvaskit-wasm'
-import { getWorldMatrix } from '#core/canvas/coordinate'
-import Matrix from '#core/canvas/matrix'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import { getWorldMatrix } from '@open-pencil/scene-graph/coordinate'
+import { rotatedCorners } from '@open-pencil/scene-graph/geometry'
+import Matrix from '@open-pencil/scene-graph/matrix'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'
import { HANDLE_HALF_SIZE, SELECTION_DASH_ALPHA } from '#core/constants'
-import { rotatedCorners } from '#core/geometry'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Vector } from '#core/types'
function getNodeTransformChain(graph: SceneGraph, node: SceneNode): SceneNode[] {
const chain: SceneNode[] = []
diff --git a/packages/core/src/canvas/overlays/text-edit.ts b/packages/core/src/canvas/overlays/text-edit.ts
index 80c5c925e..3a468e1be 100644
--- a/packages/core/src/canvas/overlays/text-edit.ts
+++ b/packages/core/src/canvas/overlays/text-edit.ts
@@ -1,8 +1,9 @@
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import { TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_COLOR } from '#core/constants'
-import type { SceneNode } from '#core/scene-graph'
import type { TextEditor } from '#core/text/editor'
export function drawTextEditOverlay(
diff --git a/packages/core/src/canvas/page-guides.ts b/packages/core/src/canvas/page-guides.ts
index 8474b2e9c..f26522699 100644
--- a/packages/core/src/canvas/page-guides.ts
+++ b/packages/core/src/canvas/page-guides.ts
@@ -1,7 +1,8 @@
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { SELECTION_COLOR } from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/pen-overlay.ts b/packages/core/src/canvas/pen-overlay.ts
index 855af2573..84f9589c7 100644
--- a/packages/core/src/canvas/pen-overlay.ts
+++ b/packages/core/src/canvas/pen-overlay.ts
@@ -1,8 +1,9 @@
import type { Canvas, Paint } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import { PEN_HANDLE_RADIUS, PEN_VERTEX_RADIUS, PEN_CLOSE_RADIUS_BOOST } from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
-import type { Vector } from '#core/types'
import type { SkiaRenderer, RenderOverlays } from './renderer'
diff --git a/packages/core/src/canvas/renderer.ts b/packages/core/src/canvas/renderer.ts
index db7aab00b..3df299c87 100644
--- a/packages/core/src/canvas/renderer.ts
+++ b/packages/core/src/canvas/renderer.ts
@@ -1,3 +1,7 @@
+import type { SceneNode, SceneGraph, Fill, Stroke } from '@open-pencil/scene-graph'
+import type { Color, Rect, Vector } from '@open-pencil/scene-graph/primitives'
+import type { SnapGuide } from '@open-pencil/scene-graph/snap'
+
import type { ResolvedRenderColor } from '#core/color/management'
/* eslint-disable max-lines -- SkiaRenderer facade owns CanvasKit state and delegates domain drawing */
import {
@@ -12,10 +16,7 @@ import {
} from '#core/constants'
import type { EditorState } from '#core/editor/types'
import { RenderProfiler } from '#core/profiler'
-import type { SceneNode, SceneGraph, Fill, Stroke } from '#core/scene-graph'
-import type { SnapGuide } from '#core/scene-graph/snap'
import type { TextEditor } from '#core/text/editor'
-import type { Color, Rect, Vector } from '#core/types'
import { LabelCache } from './labels/cache'
import * as LabelHitTest from './labels/hit-test'
diff --git a/packages/core/src/canvas/renderer/colors.ts b/packages/core/src/canvas/renderer/colors.ts
index 9055ac26d..a21b17e54 100644
--- a/packages/core/src/canvas/renderer/colors.ts
+++ b/packages/core/src/canvas/renderer/colors.ts
@@ -1,9 +1,10 @@
+import type { Fill, SceneGraph, SceneNode, Stroke } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { resolveNodeFillColor, resolveNodeStrokeColor } from '#core/color/management'
import type { ResolvedRenderColor } from '#core/color/management'
import { normalizeColor } from '#core/color/normalize'
import { getFillOkHCL, getStrokeOkHCL } from '#core/color/okhcl'
-import type { Fill, SceneGraph, SceneNode, Stroke } from '#core/scene-graph'
-import type { Color } from '#core/types'
function resolvedVariableColor(color: Color, graph: SceneGraph): ResolvedRenderColor {
return {
diff --git a/packages/core/src/canvas/renderer/fonts.ts b/packages/core/src/canvas/renderer/fonts.ts
index 7baa6247c..5f40085a4 100644
--- a/packages/core/src/canvas/renderer/fonts.ts
+++ b/packages/core/src/canvas/renderer/fonts.ts
@@ -1,3 +1,5 @@
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import {
COMPONENT_LABEL_FONT_SIZE,
@@ -7,7 +9,6 @@ import {
SECTION_TITLE_FONT_SIZE,
SIZE_FONT_SIZE
} from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
import { fontManager } from '#core/text/fonts'
export function getFontProvider(r: SkiaRenderer) {
diff --git a/packages/core/src/canvas/renderer/methods.ts b/packages/core/src/canvas/renderer/methods.ts
index 5dc17eef5..47ca3d8b0 100644
--- a/packages/core/src/canvas/renderer/methods.ts
+++ b/packages/core/src/canvas/renderer/methods.ts
@@ -1,5 +1,9 @@
import type { ImageFilter, MaskFilter, Canvas, Paint, Path } from 'canvaskit-wasm'
+import type { Fill, SceneGraph, SceneNode, Stroke } from '@open-pencil/scene-graph'
+import type { Rect, Vector } from '@open-pencil/scene-graph/primitives'
+import type { SnapGuide } from '@open-pencil/scene-graph/snap'
+
import * as Effects from '#core/canvas/effects'
import * as Fills from '#core/canvas/fills'
import * as Labels from '#core/canvas/labels/draw'
@@ -15,10 +19,7 @@ import * as SceneRender from '#core/canvas/scene'
import { renderEffects as renderShadowEffects } from '#core/canvas/shadows'
import * as Shapes from '#core/canvas/shapes'
import * as Strokes from '#core/canvas/strokes'
-import type { Fill, SceneGraph, SceneNode, Stroke } from '#core/scene-graph'
-import type { SnapGuide } from '#core/scene-graph/snap'
import type { TextEditor } from '#core/text/editor'
-import type { Rect, Vector } from '#core/types'
const rendererMethods: ThisType<SkiaRenderer> = {
drawHoverHighlight(canvas: Canvas, graph: SceneGraph, hoveredNodeId?: string | null): void {
diff --git a/packages/core/src/canvas/renderer/pipeline.ts b/packages/core/src/canvas/renderer/pipeline.ts
index 234aae62c..00a5290a4 100644
--- a/packages/core/src/canvas/renderer/pipeline.ts
+++ b/packages/core/src/canvas/renderer/pipeline.ts
@@ -1,10 +1,11 @@
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import { computeDescendantVisualBounds } from '@open-pencil/scene-graph/geometry'
+
import { drawPageGuides } from '#core/canvas/page-guides'
import type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'
import type { EditorState } from '#core/editor/types'
-import { computeDescendantVisualBounds } from '#core/geometry'
-import type { SceneGraph } from '#core/scene-graph'
import { renderSceneBacking, updateSceneBackingPreviewState } from './retained-backing'
diff --git a/packages/core/src/canvas/renderer/retained-backing.ts b/packages/core/src/canvas/renderer/retained-backing.ts
index d256d5579..d94fc26bc 100644
--- a/packages/core/src/canvas/renderer/retained-backing.ts
+++ b/packages/core/src/canvas/renderer/retained-backing.ts
@@ -1,9 +1,10 @@
import type { Canvas, Image as CKImage, Surface } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import { computeDescendantVisualBounds } from '@open-pencil/scene-graph/geometry'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import { clearSubtreePictureCache } from '#core/canvas/renderer/state'
-import { computeDescendantVisualBounds } from '#core/geometry'
-import type { SceneGraph } from '#core/scene-graph'
import type { RenderLayer } from './pipeline'
diff --git a/packages/core/src/canvas/renderer/types.ts b/packages/core/src/canvas/renderer/types.ts
index 8f2cc9322..49e7bff4e 100644
--- a/packages/core/src/canvas/renderer/types.ts
+++ b/packages/core/src/canvas/renderer/types.ts
@@ -1,7 +1,8 @@
-import type { VectorRegion, VectorVertex } from '#core/scene-graph'
-import type { SnapGuide } from '#core/scene-graph/snap'
+import type { VectorRegion, VectorVertex } from '@open-pencil/scene-graph'
+import type { Color, Rect, Vector } from '@open-pencil/scene-graph/primitives'
+import type { SnapGuide } from '@open-pencil/scene-graph/snap'
+
import type { TextEditor } from '#core/text/editor'
-import type { Color, Rect, Vector } from '#core/types'
export interface RulerTheme {
background: Color
diff --git a/packages/core/src/canvas/rulers.ts b/packages/core/src/canvas/rulers.ts
index 1966d83bf..8d287b67e 100644
--- a/packages/core/src/canvas/rulers.ts
+++ b/packages/core/src/canvas/rulers.ts
@@ -1,5 +1,8 @@
import type { Canvas, CanvasKit } from 'canvaskit-wasm'
+import type { SceneNode, SceneGraph } from '@open-pencil/scene-graph'
+import { computeAbsoluteBounds } from '@open-pencil/scene-graph/geometry'
+
import {
RULER_SIZE,
RULER_BADGE_HEIGHT,
@@ -13,8 +16,6 @@ import {
RULER_TARGET_PIXEL_SPACING,
RULER_MAJOR_TOLERANCE
} from '#core/constants'
-import { computeAbsoluteBounds } from '#core/geometry'
-import type { SceneNode, SceneGraph } from '#core/scene-graph'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/scene.ts b/packages/core/src/canvas/scene.ts
index 77c7e1fff..efb9041cb 100644
--- a/packages/core/src/canvas/scene.ts
+++ b/packages/core/src/canvas/scene.ts
@@ -1,10 +1,11 @@
/* eslint-disable max-lines -- scene dispatch stays together while shape domains live in sibling modules */
import type { Canvas, Path } from 'canvaskit-wasm'
+import type { SceneNode, SceneGraph, Fill } from '@open-pencil/scene-graph'
+import { computeDescendantVisualBounds } from '@open-pencil/scene-graph/geometry'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, SECTION_CORNER_RADIUS } from '#core/constants'
-import { computeDescendantVisualBounds } from '#core/geometry'
-import type { SceneNode, SceneGraph, Fill } from '#core/scene-graph'
-import type { Color } from '#core/types'
import { vectorNetworkToCenterlinePath } from '#core/vector'
import { figmaBlendModeToSkia, needsIsolatedBlendLayer } from './blend'
diff --git a/packages/core/src/canvas/shadows.ts b/packages/core/src/canvas/shadows.ts
index e0c512db1..ce633ef52 100644
--- a/packages/core/src/canvas/shadows.ts
+++ b/packages/core/src/canvas/shadows.ts
@@ -1,8 +1,9 @@
import type { Canvas, Path } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import type { Color, Vector } from '@open-pencil/scene-graph/primitives'
+
import { BLACK } from '#core/constants'
-import type { SceneNode } from '#core/scene-graph'
-import type { Color, Vector } from '#core/types'
import { figmaBlendModeToSkia } from './blend'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/shapes.ts b/packages/core/src/canvas/shapes.ts
index 8747c9a0e..83537ac1b 100644
--- a/packages/core/src/canvas/shapes.ts
+++ b/packages/core/src/canvas/shapes.ts
@@ -1,7 +1,8 @@
import type { Canvas, Path } from 'canvaskit-wasm'
-import { polygonVertices } from '#core/geometry'
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { polygonVertices } from '@open-pencil/scene-graph/geometry'
+
import { vectorNetworkToPath, geometryBlobToPath } from '#core/vector'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/strokes.ts b/packages/core/src/canvas/strokes.ts
index 3b9b85d67..0794c3f39 100644
--- a/packages/core/src/canvas/strokes.ts
+++ b/packages/core/src/canvas/strokes.ts
@@ -1,7 +1,7 @@
import type { Canvas, EmbindEnumEntity, Paint } from 'canvaskit-wasm'
-import type { SceneNode, Stroke } from '#core/scene-graph'
-import type { Color } from '#core/types'
+import type { SceneNode, Stroke } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { SkiaRenderer } from './renderer'
import { makeSmoothRRectPath, nodeHasSmoothCorners } from './shapes'
diff --git a/packages/core/src/canvas/text-derived.ts b/packages/core/src/canvas/text-derived.ts
index 4f44b3ad6..63f1f5000 100644
--- a/packages/core/src/canvas/text-derived.ts
+++ b/packages/core/src/canvas/text-derived.ts
@@ -1,6 +1,7 @@
import type { Canvas, Paint } from 'canvaskit-wasm'
-import type { Fill, SceneNode, StyleRun, TextDecorationStyle } from '#core/scene-graph'
+import type { Fill, SceneNode, StyleRun, TextDecorationStyle } from '@open-pencil/scene-graph'
+
import { geometryBlobToPath } from '#core/vector'
import type { SkiaRenderer } from './renderer'
diff --git a/packages/core/src/canvas/text-outlines.ts b/packages/core/src/canvas/text-outlines.ts
index fdac751e3..823013101 100644
--- a/packages/core/src/canvas/text-outlines.ts
+++ b/packages/core/src/canvas/text-outlines.ts
@@ -1,6 +1,7 @@
import type { Path } from 'canvaskit-wasm'
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { OutlineCommand } from '#core/text/opentype'
import { textNodeToOutlineLayout } from '#core/text/outlines'
diff --git a/packages/core/src/canvas/text.ts b/packages/core/src/canvas/text.ts
index cb8b77d4e..aa0e2587b 100644
--- a/packages/core/src/canvas/text.ts
+++ b/packages/core/src/canvas/text.ts
@@ -9,11 +9,11 @@ import type {
import { uniq } from 'es-toolkit/array'
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { getCanvasKit } from '#core/canvaskit'
import { resolveRGBAForPreview } from '#core/color/management'
import { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE } from '#core/constants'
-import type { SceneNode } from '#core/scene-graph'
import { resolveNodeTextDirection } from '#core/text/direction'
import { fontManager, weightToStyle } from '#core/text/fonts'
diff --git a/packages/core/src/clipboard.ts b/packages/core/src/clipboard.ts
index 513129553..3961c500c 100644
--- a/packages/core/src/clipboard.ts
+++ b/packages/core/src/clipboard.ts
@@ -3,6 +3,7 @@ import { inflateSync, deflateSync } from 'fflate'
import { initCodec, getCompiledSchema, getSchemaBytes } from '@open-pencil/kiwi/fig/codec'
import type { NodeChange as KiwiNodeChange } from '@open-pencil/kiwi/fig/codec'
import { decodeBinarySchema, compileSchema, ByteBuffer } from '@open-pencil/kiwi/schema-runtime'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import { shapeTextForClipboard } from './canvas/text'
import { populateAndApplyOverrides } from './kiwi/fig/instance-overrides'
@@ -18,7 +19,6 @@ import {
buildFontDigestMap
} from './kiwi/fig/node-change/serialize'
import { randomInt } from './random'
-import type { SceneGraph, SceneNode } from './scene-graph'
import { buildDerivedTextDataV4 } from './text/derived-text/clipboard'
interface FigmaClipboardMeta {
diff --git a/packages/core/src/clipboard/openpencil.ts b/packages/core/src/clipboard/openpencil.ts
index 86db448b6..bd42f5627 100644
--- a/packages/core/src/clipboard/openpencil.ts
+++ b/packages/core/src/clipboard/openpencil.ts
@@ -1,7 +1,7 @@
import { deflateSync, inflateSync } from 'fflate'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { JsonObject } from '#core/types'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
// --- Internal copy/paste (OpenPencil ↔ OpenPencil) ---
diff --git a/packages/core/src/color/analysis.ts b/packages/core/src/color/analysis.ts
index e09c0e675..73083a715 100644
--- a/packages/core/src/color/analysis.ts
+++ b/packages/core/src/color/analysis.ts
@@ -1,4 +1,4 @@
-import type { Color } from '#core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export interface ColorUsageEntry {
hex: string
diff --git a/packages/core/src/color/index.ts b/packages/core/src/color/index.ts
index da1f9c44b..482f72b40 100644
--- a/packages/core/src/color/index.ts
+++ b/packages/core/src/color/index.ts
@@ -4,8 +4,9 @@ export * from './okhcl'
import { parse, formatHex, formatHex8, formatRgb, converter, differenceEuclidean } from 'culori'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { BLACK } from '#core/constants'
-import type { Color } from '#core/types'
const toRgb = converter('rgb')
diff --git a/packages/core/src/color/management.ts b/packages/core/src/color/management.ts
index 9338ca3bb..5532dc79f 100644
--- a/packages/core/src/color/management.ts
+++ b/packages/core/src/color/management.ts
@@ -1,7 +1,7 @@
import { converter, formatCss, formatRgb, inGamut, toGamut } from 'culori'
-import type { DocumentColorSpace, Fill, SceneNode, Stroke } from '#core/scene-graph'
-import type { Color } from '#core/types'
+import type { DocumentColorSpace, Fill, SceneNode, Stroke } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import { normalizeColor } from './normalize'
import { getFillOkHCL, getStrokeOkHCL, type OkHCLColor } from './okhcl'
diff --git a/packages/core/src/color/normalize.ts b/packages/core/src/color/normalize.ts
index 4e5af8fc1..452b67579 100644
--- a/packages/core/src/color/normalize.ts
+++ b/packages/core/src/color/normalize.ts
@@ -1,5 +1,6 @@
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { BLACK } from '#core/constants'
-import type { Color } from '#core/types'
export function normalizeColor(color?: Partial<Color>): Color {
if (!color) return { ...BLACK }
diff --git a/packages/core/src/color/okhcl.ts b/packages/core/src/color/okhcl.ts
index fecbb9efc..1c91f1b87 100644
--- a/packages/core/src/color/okhcl.ts
+++ b/packages/core/src/color/okhcl.ts
@@ -1,8 +1,8 @@
import { converter, toGamut } from 'culori'
-import type { SceneNode } from '#core/scene-graph'
-import { copyFill, copyStroke } from '#core/scene-graph/copy'
-import type { Color } from '#core/types'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { copyFill, copyStroke } from '@open-pencil/scene-graph/copy'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import { normalizeColor } from './normalize'
diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts
index ee83891cb..c2493f759 100644
--- a/packages/core/src/constants.ts
+++ b/packages/core/src/constants.ts
@@ -1,5 +1,5 @@
-import type { Fill, Stroke } from './scene-graph'
-import type { Color } from './types'
+import type { Fill, Stroke } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export const IS_BROWSER = typeof window !== 'undefined'
export const IS_TAURI = IS_BROWSER && '__TAURI_INTERNALS__' in window
diff --git a/packages/core/src/design-jsx/effects.ts b/packages/core/src/design-jsx/effects.ts
index 0036452c1..bdb63169a 100644
--- a/packages/core/src/design-jsx/effects.ts
+++ b/packages/core/src/design-jsx/effects.ts
@@ -1,7 +1,8 @@
+import type { BlendMode, Effect } from '@open-pencil/scene-graph'
+import type { Color, Vector } from '@open-pencil/scene-graph/primitives'
+
import { parseColor } from '#core/color'
import { TRANSPARENT } from '#core/constants'
-import type { BlendMode, Effect } from '#core/scene-graph'
-import type { Color, Vector } from '#core/types'
export type EffectColor = string | Color
diff --git a/packages/core/src/design-jsx/paints.ts b/packages/core/src/design-jsx/paints.ts
index e98449ef2..2cdeda833 100644
--- a/packages/core/src/design-jsx/paints.ts
+++ b/packages/core/src/design-jsx/paints.ts
@@ -1,7 +1,14 @@
+import type {
+ BlendMode,
+ Fill,
+ FillType,
+ GradientStop,
+ GradientTransform
+} from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { colorToFill, parseColor } from '#core/color'
import { TRANSPARENT } from '#core/constants'
-import type { BlendMode, Fill, FillType, GradientStop, GradientTransform } from '#core/scene-graph'
-import type { Color } from '#core/types'
export type PaintColor = string | Color
export type PaintStop = readonly [PaintColor, number] | { color: PaintColor; position: number }
diff --git a/packages/core/src/design-jsx/props-overrides.ts b/packages/core/src/design-jsx/props-overrides.ts
index 65546ffa7..034fdc3cb 100644
--- a/packages/core/src/design-jsx/props-overrides.ts
+++ b/packages/core/src/design-jsx/props-overrides.ts
@@ -1,7 +1,15 @@
+import type {
+ Effect,
+ Fill,
+ GridTrack,
+ LayoutMode,
+ SceneNode,
+ Stroke
+} from '@open-pencil/scene-graph'
+import type { Color, JsonObject } from '@open-pencil/scene-graph/primitives'
+
import { colorToFill, parseColor } from '#core/color'
import { TRANSPARENT } from '#core/constants'
-import type { Effect, Fill, GridTrack, LayoutMode, SceneNode, Stroke } from '#core/scene-graph'
-import type { Color, JsonObject } from '#core/types'
const WEIGHT_MAP: Record<string, number> = {
normal: 400,
diff --git a/packages/core/src/design-jsx/render.ts b/packages/core/src/design-jsx/render.ts
index ea2908cfb..393e411a9 100644
--- a/packages/core/src/design-jsx/render.ts
+++ b/packages/core/src/design-jsx/render.ts
@@ -1,7 +1,8 @@
import { transform } from 'sucrase'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import type { RenderOptions as RenderJSXOptions } from '#core/design-jsx/types'
-import type { SceneGraph } from '#core/scene-graph'
import { backgroundBlur, dropShadow, foregroundBlur, innerShadow, layerBlur } from './effects'
import * as React from './mini-react'
diff --git a/packages/core/src/design-jsx/renderer.ts b/packages/core/src/design-jsx/renderer.ts
index 8b0362c28..9470feabe 100644
--- a/packages/core/src/design-jsx/renderer.ts
+++ b/packages/core/src/design-jsx/renderer.ts
@@ -1,16 +1,17 @@
+import type {
+ ComponentPropertyDefinition,
+ SceneGraph,
+ SceneNode,
+ NodeType
+} from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { parseColor } from '#core/color'
import type { RenderOptions } from '#core/design-jsx/types'
import { fetchIcons } from '#core/icons'
import { createIconFromPaths } from '#core/icons/render'
import { computeAllLayouts } from '#core/layout'
import { randomHex } from '#core/random'
-import type {
- ComponentPropertyDefinition,
- SceneGraph,
- SceneNode,
- NodeType
-} from '#core/scene-graph'
-import type { Color } from '#core/types'
import { applySizeOverrides, propsToOverrides } from './props-overrides'
import { isTreeNode } from './tree'
diff --git a/packages/core/src/design-jsx/tree.ts b/packages/core/src/design-jsx/tree.ts
index 08d5fb4a2..94ab174dd 100644
--- a/packages/core/src/design-jsx/tree.ts
+++ b/packages/core/src/design-jsx/tree.ts
@@ -1,5 +1,5 @@
-import type { Effect, Fill } from '#core/scene-graph'
-import type { Color } from '#core/types'
+import type { Effect, Fill } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { DesignVariable } from './vars'
diff --git a/packages/core/src/design-jsx/vars.ts b/packages/core/src/design-jsx/vars.ts
index 4bc5ded03..543281d63 100644
--- a/packages/core/src/design-jsx/vars.ts
+++ b/packages/core/src/design-jsx/vars.ts
@@ -1,4 +1,4 @@
-import type { Color } from '#core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
const VAR_SYMBOL = Symbol.for('open-pencil.variable')
diff --git a/packages/core/src/editor/alignment.ts b/packages/core/src/editor/alignment.ts
index 41ab3f335..a516558da 100644
--- a/packages/core/src/editor/alignment.ts
+++ b/packages/core/src/editor/alignment.ts
@@ -1,7 +1,8 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { computeAbsoluteBounds } from '@open-pencil/scene-graph/geometry'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import { createFlipRotateActions } from '#core/editor/alignment/flip-rotate'
-import { computeAbsoluteBounds } from '#core/geometry'
-import type { SceneNode } from '#core/scene-graph'
-import type { Vector } from '#core/types'
import { collectNodePositions, pushPositionUndo } from './history/position'
import type { EditorContext } from './types'
diff --git a/packages/core/src/editor/clipboard.ts b/packages/core/src/editor/clipboard.ts
index 104e75af9..3176aa6c3 100644
--- a/packages/core/src/editor/clipboard.ts
+++ b/packages/core/src/editor/clipboard.ts
@@ -1,11 +1,12 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import {
importClipboardNodes,
parseFigmaClipboard,
parseOpenPencilClipboard
} from '#core/clipboard'
import { computeAllLayouts } from '#core/layout'
-import type { SceneNode } from '#core/scene-graph'
-import type { Vector } from '#core/types'
import { createClipboardCopyActions } from './clipboard/copy'
import { createClipboardExportActions } from './clipboard/export'
diff --git a/packages/core/src/editor/clipboard/copy.ts b/packages/core/src/editor/clipboard/copy.ts
index 5ad24c737..fa8e77dcf 100644
--- a/packages/core/src/editor/clipboard/copy.ts
+++ b/packages/core/src/editor/clipboard/copy.ts
@@ -1,6 +1,7 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { buildFigmaClipboardHTML, buildOpenPencilClipboardHTML } from '#core/clipboard'
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
export function createClipboardCopyActions(ctx: EditorContext) {
async function writeCopyData(clipboardData: DataTransfer, selectedNodes: SceneNode[]) {
diff --git a/packages/core/src/editor/clipboard/history.ts b/packages/core/src/editor/clipboard/history.ts
index ea7299dad..21a77c212 100644
--- a/packages/core/src/editor/clipboard/history.ts
+++ b/packages/core/src/editor/clipboard/history.ts
@@ -1,5 +1,6 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
import { restoreSubtree } from './subtree-history'
diff --git a/packages/core/src/editor/clipboard/images.ts b/packages/core/src/editor/clipboard/images.ts
index 9cf5e0774..e00ba3a9e 100644
--- a/packages/core/src/editor/clipboard/images.ts
+++ b/packages/core/src/editor/clipboard/images.ts
@@ -1,8 +1,9 @@
+import type { Fill } from '@open-pencil/scene-graph'
+
import { TRANSPARENT } from '#core/constants'
import { resolvePasteTarget } from '#core/editor/clipboard/paste-target'
import type { EditorContext } from '#core/editor/types'
import { computeImageHash } from '#core/figma-api'
-import type { Fill } from '#core/scene-graph'
const IMAGE_MAX_DIMENSION = 4096
const IMAGE_GAP = 20
diff --git a/packages/core/src/editor/clipboard/paste-replace.ts b/packages/core/src/editor/clipboard/paste-replace.ts
index 76556f2ea..ce712085e 100644
--- a/packages/core/src/editor/clipboard/paste-replace.ts
+++ b/packages/core/src/editor/clipboard/paste-replace.ts
@@ -1,7 +1,8 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { computeAbsoluteBounds } from '@open-pencil/scene-graph/geometry'
+
import type { EditorContext } from '#core/editor/types'
-import { computeAbsoluteBounds } from '#core/geometry'
import { computeAllLayouts } from '#core/layout'
-import type { SceneNode } from '#core/scene-graph'
import { deleteIds, type DeletedEntry, recreateSnapshots, restoreDeletedEntries } from './history'
import { collectSubtrees, snapshotSubtree } from './subtree-history'
diff --git a/packages/core/src/editor/clipboard/paste-target.ts b/packages/core/src/editor/clipboard/paste-target.ts
index 5a8cf656a..0ca0aa019 100644
--- a/packages/core/src/editor/clipboard/paste-target.ts
+++ b/packages/core/src/editor/clipboard/paste-target.ts
@@ -1,5 +1,6 @@
+import { CONTAINER_TYPES } from '@open-pencil/scene-graph/node-defaults'
+
import type { EditorContext } from '#core/editor/types'
-import { CONTAINER_TYPES } from '#core/scene-graph/node-defaults'
export function resolvePasteTarget(ctx: EditorContext): string {
if (ctx.state.enteredContainerId) return ctx.state.enteredContainerId
diff --git a/packages/core/src/editor/clipboard/placement.ts b/packages/core/src/editor/clipboard/placement.ts
index c10b97ba9..df0740b1a 100644
--- a/packages/core/src/editor/clipboard/placement.ts
+++ b/packages/core/src/editor/clipboard/placement.ts
@@ -1,7 +1,8 @@
import { isNotNil } from 'es-toolkit/predicate'
+import { computeBounds } from '@open-pencil/scene-graph/geometry'
+
import type { EditorContext } from '#core/editor/types'
-import { computeBounds } from '#core/geometry'
export function createClipboardPlacementActions(ctx: EditorContext) {
function centerNodesAt(nodeIds: string[], cx: number, cy: number) {
diff --git a/packages/core/src/editor/clipboard/subtree-history.ts b/packages/core/src/editor/clipboard/subtree-history.ts
index 9bfee65ad..62034f78a 100644
--- a/packages/core/src/editor/clipboard/subtree-history.ts
+++ b/packages/core/src/editor/clipboard/subtree-history.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export function collectSubtrees(graph: SceneGraph, rootIds: string[]): SceneNode[] {
const result: SceneNode[] = []
diff --git a/packages/core/src/editor/color-space.ts b/packages/core/src/editor/color-space.ts
index 4a352cf48..7a73be7e0 100644
--- a/packages/core/src/editor/color-space.ts
+++ b/packages/core/src/editor/color-space.ts
@@ -1,7 +1,8 @@
+import type { DocumentColorSpace, SceneNode } from '@open-pencil/scene-graph'
+import { copyEffects, copyFill, copyStyleRuns, copyStroke } from '@open-pencil/scene-graph/copy'
+
import { resolveOkHCLForPreview } from '#core/color/management'
import { rgbaToOkHCL } from '#core/color/okhcl'
-import type { DocumentColorSpace, SceneNode } from '#core/scene-graph'
-import { copyEffects, copyFill, copyStyleRuns, copyStroke } from '#core/scene-graph/copy'
import type { EditorContext } from './types'
diff --git a/packages/core/src/editor/component-sync.ts b/packages/core/src/editor/component-sync.ts
index 93ec73096..664bde1d6 100644
--- a/packages/core/src/editor/component-sync.ts
+++ b/packages/core/src/editor/component-sync.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
export function createComponentSyncScheduler(
getGraph: () => SceneGraph,
diff --git a/packages/core/src/editor/components.ts b/packages/core/src/editor/components.ts
index b17ba0894..f8a743919 100644
--- a/packages/core/src/editor/components.ts
+++ b/packages/core/src/editor/components.ts
@@ -1,5 +1,6 @@
+import type { ComponentPropertyDefinition, SceneNode } from '@open-pencil/scene-graph'
+
import { randomHex } from '#core/random'
-import type { ComponentPropertyDefinition, SceneNode } from '#core/scene-graph'
import { createComponentFocusActions } from './components/focus'
import { createComponentInstanceActions } from './components/instances'
diff --git a/packages/core/src/editor/components/focus.ts b/packages/core/src/editor/components/focus.ts
index 977b1f957..6f078d885 100644
--- a/packages/core/src/editor/components/focus.ts
+++ b/packages/core/src/editor/components/focus.ts
@@ -1,5 +1,6 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
export function createComponentFocusActions(ctx: EditorContext) {
function goToMainComponent(
diff --git a/packages/core/src/editor/components/instances.ts b/packages/core/src/editor/components/instances.ts
index 97a5cdadb..fba9f583c 100644
--- a/packages/core/src/editor/components/instances.ts
+++ b/packages/core/src/editor/components/instances.ts
@@ -1,5 +1,6 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
type InstanceCreateSnapshot = Partial<SceneNode> & { id: string }
diff --git a/packages/core/src/editor/components/variants.ts b/packages/core/src/editor/components/variants.ts
index 6652eec38..96a8055d2 100644
--- a/packages/core/src/editor/components/variants.ts
+++ b/packages/core/src/editor/components/variants.ts
@@ -1,13 +1,14 @@
import { omit } from 'es-toolkit/object'
-import type { EditorContext } from '#core/editor/types'
-import { randomHex } from '#core/random'
import type {
ComponentPropertyDefinition,
ComponentPropertyType,
SceneNode
-} from '#core/scene-graph'
-import { buildVariantName, parseVariantName } from '#core/scene-graph/variant-name'
+} from '@open-pencil/scene-graph'
+import { buildVariantName, parseVariantName } from '@open-pencil/scene-graph/variant-name'
+
+import type { EditorContext } from '#core/editor/types'
+import { randomHex } from '#core/random'
export type VariantConflict = {
values: Record<string, string>
diff --git a/packages/core/src/editor/create.ts b/packages/core/src/editor/create.ts
index 758f16cf9..f36dbc5b6 100644
--- a/packages/core/src/editor/create.ts
+++ b/packages/core/src/editor/create.ts
@@ -2,12 +2,13 @@ import type { CanvasKit } from 'canvaskit-wasm'
import { createNanoEvents } from 'nanoevents'
import type { Emitter } from 'nanoevents'
+import { SceneGraph } from '@open-pencil/scene-graph'
+import { UndoManager } from '@open-pencil/scene-graph/undo'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import { prefetchFigmaSchema } from '#core/clipboard'
import { IS_BROWSER } from '#core/constants'
import { setTextMeasurer } from '#core/layout'
-import { SceneGraph } from '#core/scene-graph'
-import { UndoManager } from '#core/scene-graph/undo'
import { TextEditor } from '#core/text/editor'
import { fontManager } from '#core/text/fonts'
diff --git a/packages/core/src/editor/graph-events.ts b/packages/core/src/editor/graph-events.ts
index ebe74b501..86c40c6df 100644
--- a/packages/core/src/editor/graph-events.ts
+++ b/packages/core/src/editor/graph-events.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph, SceneGraphEvents, SceneNode } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
-import type { SceneGraph, SceneGraphEvents, SceneNode } from '#core/scene-graph'
type EmittedGraphEventName = Exclude<keyof SceneGraphEvents, 'node:previewUpdated'>
diff --git a/packages/core/src/editor/graph-reads.ts b/packages/core/src/editor/graph-reads.ts
index 8bc138bf4..dadd69b0c 100644
--- a/packages/core/src/editor/graph-reads.ts
+++ b/packages/core/src/editor/graph-reads.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
export function createGraphReadActions(getGraph: () => SceneGraph) {
return {
diff --git a/packages/core/src/editor/history/position.ts b/packages/core/src/editor/history/position.ts
index f94d7e132..1e6aefb24 100644
--- a/packages/core/src/editor/history/position.ts
+++ b/packages/core/src/editor/history/position.ts
@@ -1,5 +1,6 @@
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import type { EditorContext } from '#core/editor/types'
-import type { Vector } from '#core/types'
export function collectNodePositions(
ctx: EditorContext,
diff --git a/packages/core/src/editor/history/snapshot.ts b/packages/core/src/editor/history/snapshot.ts
index 0cbf940a5..94e11a617 100644
--- a/packages/core/src/editor/history/snapshot.ts
+++ b/packages/core/src/editor/history/snapshot.ts
@@ -1,6 +1,7 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import type { EditorContext } from '#core/editor/types'
import { computeAllLayouts } from '#core/layout'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
export type PageSnapshot = Map<string, SceneNode>
diff --git a/packages/core/src/editor/layout-mode.ts b/packages/core/src/editor/layout-mode.ts
index 8a15028ce..42f7e9c5f 100644
--- a/packages/core/src/editor/layout-mode.ts
+++ b/packages/core/src/editor/layout-mode.ts
@@ -1,7 +1,8 @@
import { pick } from 'es-toolkit/object'
+import type { LayoutMode, SceneNode } from '@open-pencil/scene-graph'
+
import { computeLayout } from '#core/layout'
-import type { LayoutMode, SceneNode } from '#core/scene-graph'
import type { EditorContext } from './types'
diff --git a/packages/core/src/editor/layout-runner.ts b/packages/core/src/editor/layout-runner.ts
index 517667420..e4582ac17 100644
--- a/packages/core/src/editor/layout-runner.ts
+++ b/packages/core/src/editor/layout-runner.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { computeAllLayouts, computeLayout } from '#core/layout'
-import type { SceneGraph } from '#core/scene-graph'
export function createLayoutRunner(getGraph: () => SceneGraph) {
function runLayoutForNode(id: string) {
diff --git a/packages/core/src/editor/nodes.ts b/packages/core/src/editor/nodes.ts
index b5b769473..6d31cca33 100644
--- a/packages/core/src/editor/nodes.ts
+++ b/packages/core/src/editor/nodes.ts
@@ -1,6 +1,6 @@
import { pick } from 'es-toolkit/object'
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { createLayoutModeActions } from './layout-mode'
import { createNudgeActions } from './nudge'
diff --git a/packages/core/src/editor/nudge.ts b/packages/core/src/editor/nudge.ts
index cbc5aea60..136b9b662 100644
--- a/packages/core/src/editor/nudge.ts
+++ b/packages/core/src/editor/nudge.ts
@@ -1,4 +1,4 @@
-import type { Vector } from '#core/types'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import { collectNodePositions, pushPositionUndo } from './history/position'
import type { EditorContext } from './types'
diff --git a/packages/core/src/editor/page-viewports.ts b/packages/core/src/editor/page-viewports.ts
index 552718528..59a46e16e 100644
--- a/packages/core/src/editor/page-viewports.ts
+++ b/packages/core/src/editor/page-viewports.ts
@@ -1,5 +1,6 @@
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { CANVAS_BG_COLOR } from '#core/constants'
-import type { Color } from '#core/types'
import type { EditorContext } from './types'
diff --git a/packages/core/src/editor/pages.ts b/packages/core/src/editor/pages.ts
index ccbd036b1..f7c3b5534 100644
--- a/packages/core/src/editor/pages.ts
+++ b/packages/core/src/editor/pages.ts
@@ -1,7 +1,8 @@
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { populateLazyFigImportRoots } from '#core/kiwi/fig/lazy-import'
import { computeAllLayouts } from '#core/layout'
import { fontManager } from '#core/text/fonts'
-import type { Color } from '#core/types'
import { createPageViewportStore } from './page-viewports'
import type { EditorContext } from './types'
diff --git a/packages/core/src/editor/selection/hit-test.ts b/packages/core/src/editor/selection/hit-test.ts
index 0aeaa0c61..8013e9c68 100644
--- a/packages/core/src/editor/selection/hit-test.ts
+++ b/packages/core/src/editor/selection/hit-test.ts
@@ -1,5 +1,6 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
export function createSelectionHitTestActions(
ctx: EditorContext,
diff --git a/packages/core/src/editor/selection/overlays.ts b/packages/core/src/editor/selection/overlays.ts
index 09cbff454..c28a7a0f6 100644
--- a/packages/core/src/editor/selection/overlays.ts
+++ b/packages/core/src/editor/selection/overlays.ts
@@ -1,6 +1,7 @@
+import type { Rect } from '@open-pencil/scene-graph/primitives'
+import type { SnapGuide } from '@open-pencil/scene-graph/snap'
+
import type { EditorContext } from '#core/editor/types'
-import type { SnapGuide } from '#core/scene-graph/snap'
-import type { Rect } from '#core/types'
export function createSelectionOverlayActions(ctx: EditorContext) {
function setMarquee(rect: Rect | null) {
diff --git a/packages/core/src/editor/shapes.ts b/packages/core/src/editor/shapes.ts
index f8b00f88c..3951ed240 100644
--- a/packages/core/src/editor/shapes.ts
+++ b/packages/core/src/editor/shapes.ts
@@ -1,3 +1,5 @@
+import type { Fill, NodeType, SceneNode } from '@open-pencil/scene-graph'
+
import {
BLACK,
DEFAULT_FRAME_FILL,
@@ -5,7 +7,6 @@ import {
SECTION_DEFAULT_FILL,
SECTION_DEFAULT_STROKE
} from '#core/constants'
-import type { Fill, NodeType, SceneNode } from '#core/scene-graph'
import { createPenActions } from './shapes/pen'
import { adoptNodesIntoSection as adoptNodesIntoSectionImpl } from './shapes/section-adopt'
diff --git a/packages/core/src/editor/shapes/pen.ts b/packages/core/src/editor/shapes/pen.ts
index 9befdf2bb..929e92569 100644
--- a/packages/core/src/editor/shapes/pen.ts
+++ b/packages/core/src/editor/shapes/pen.ts
@@ -1,7 +1,13 @@
+import type {
+ SceneNode,
+ VectorNetwork,
+ VectorRegion,
+ VectorSegment
+} from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
import { BLACK } from '#core/constants'
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode, VectorNetwork, VectorRegion, VectorSegment } from '#core/scene-graph'
-import type { Vector } from '#core/types'
import { computeAccurateBounds } from '#core/vector'
export interface PenDragOptions {
diff --git a/packages/core/src/editor/structure.ts b/packages/core/src/editor/structure.ts
index 27d3a34cf..85f434322 100644
--- a/packages/core/src/editor/structure.ts
+++ b/packages/core/src/editor/structure.ts
@@ -1,5 +1,6 @@
+import type { NodeType, SceneNode } from '@open-pencil/scene-graph'
+
import { DEFAULT_FRAME_FILL } from '#core/constants'
-import type { NodeType, SceneNode } from '#core/scene-graph'
import { wrapInAutoLayout as wrapInAutoLayoutImpl } from './structure/auto-layout-wrap'
import {
diff --git a/packages/core/src/editor/structure/auto-layout-wrap.ts b/packages/core/src/editor/structure/auto-layout-wrap.ts
index 7efe4f338..8c92d808a 100644
--- a/packages/core/src/editor/structure/auto-layout-wrap.ts
+++ b/packages/core/src/editor/structure/auto-layout-wrap.ts
@@ -1,7 +1,8 @@
+import type { LayoutMode, SceneNode } from '@open-pencil/scene-graph'
+import { computeAbsoluteBounds } from '@open-pencil/scene-graph/geometry'
+
import type { EditorContext } from '#core/editor/types'
-import { computeAbsoluteBounds } from '#core/geometry'
import { computeLayout } from '#core/layout'
-import type { LayoutMode, SceneNode } from '#core/scene-graph'
export function wrapInAutoLayout(
ctx: EditorContext,
diff --git a/packages/core/src/editor/structure/boolean.ts b/packages/core/src/editor/structure/boolean.ts
index e2cd29c81..c3bae096b 100644
--- a/packages/core/src/editor/structure/boolean.ts
+++ b/packages/core/src/editor/structure/boolean.ts
@@ -1,9 +1,10 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { copyFills, copyStrokes } from '@open-pencil/scene-graph/copy'
+import { computeAbsoluteBounds } from '@open-pencil/scene-graph/geometry'
+
import { canMakeBooleanSourceNode } from '#core/canvas/boolean'
import { restoreSubtree, snapshotSubtree } from '#core/editor/clipboard/subtree-history'
import type { EditorContext } from '#core/editor/types'
-import { computeAbsoluteBounds } from '#core/geometry'
-import type { SceneNode } from '#core/scene-graph'
-import { copyFills, copyStrokes } from '#core/scene-graph/copy'
import { selectedNodesInSharedParent } from './selection'
diff --git a/packages/core/src/editor/structure/container-wrap.ts b/packages/core/src/editor/structure/container-wrap.ts
index 1391aee25..349350305 100644
--- a/packages/core/src/editor/structure/container-wrap.ts
+++ b/packages/core/src/editor/structure/container-wrap.ts
@@ -1,6 +1,7 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { computeAbsoluteBounds } from '@open-pencil/scene-graph/geometry'
+
import type { EditorContext } from '#core/editor/types'
-import { computeAbsoluteBounds } from '#core/geometry'
-import type { SceneNode } from '#core/scene-graph'
export function wrapSelectionInContainer(
ctx: EditorContext,
diff --git a/packages/core/src/editor/structure/flatten.ts b/packages/core/src/editor/structure/flatten.ts
index ee1b67984..f7a540ec8 100644
--- a/packages/core/src/editor/structure/flatten.ts
+++ b/packages/core/src/editor/structure/flatten.ts
@@ -1,8 +1,9 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { canMakeBooleanSourceNode, hasVisibleStrokeSourceNode } from '#core/canvas/boolean'
import { flattenNodesToVectorProps, outlineStrokeNodesToVectorProps } from '#core/canvas/flatten'
import { restoreSubtree, snapshotSubtree } from '#core/editor/clipboard/subtree-history'
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
import { selectedNodesInSharedParent } from './selection'
diff --git a/packages/core/src/editor/structure/group.ts b/packages/core/src/editor/structure/group.ts
index 3561e4350..4d0506905 100644
--- a/packages/core/src/editor/structure/group.ts
+++ b/packages/core/src/editor/structure/group.ts
@@ -1,5 +1,6 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
export function ungroupSelected(ctx: EditorContext, selectedNode: SceneNode | undefined) {
if (selectedNode?.type !== 'GROUP') return
diff --git a/packages/core/src/editor/structure/selection.ts b/packages/core/src/editor/structure/selection.ts
index 10bc51663..0854c35a2 100644
--- a/packages/core/src/editor/structure/selection.ts
+++ b/packages/core/src/editor/structure/selection.ts
@@ -1,5 +1,6 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { EditorContext } from '#core/editor/types'
-import type { SceneNode } from '#core/scene-graph'
export function topLevelSelectedNodes(selectedNodes: SceneNode[]): SceneNode[] {
const selectedSet = new Set(selectedNodes.map((node) => node.id))
diff --git a/packages/core/src/editor/text/session.ts b/packages/core/src/editor/text/session.ts
index 6e34355fd..e15a7cb7f 100644
--- a/packages/core/src/editor/text/session.ts
+++ b/packages/core/src/editor/text/session.ts
@@ -1,8 +1,8 @@
import type { Paragraph } from 'canvaskit-wasm'
-import type { SceneNode, StyleRun } from '#core/scene-graph'
-import { copyStyleRuns } from '#core/scene-graph/copy'
-import type { JsonObject } from '#core/types'
+import type { SceneNode, StyleRun } from '@open-pencil/scene-graph'
+import { copyStyleRuns } from '@open-pencil/scene-graph/copy'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
export type TextEditSizeSnapshot = Partial<Pick<SceneNode, 'width' | 'height'>>
diff --git a/packages/core/src/editor/types.ts b/packages/core/src/editor/types.ts
index f7910bb26..ee6de93b8 100644
--- a/packages/core/src/editor/types.ts
+++ b/packages/core/src/editor/types.ts
@@ -1,18 +1,19 @@
import type { CanvasKit } from 'canvaskit-wasm'
-import type { RulerTheme, SkiaRenderer } from '#core/canvas/renderer'
-import type { RenderOverlays } from '#core/canvas/renderer/types'
import type {
SceneGraph,
SceneGraphEvents,
SceneNode,
VectorSegment,
VectorVertex
-} from '#core/scene-graph'
-import type { SnapGuide } from '#core/scene-graph/snap'
-import type { UndoManager } from '#core/scene-graph/undo'
+} from '@open-pencil/scene-graph'
+import type { Color, Rect, Vector } from '@open-pencil/scene-graph/primitives'
+import type { SnapGuide } from '@open-pencil/scene-graph/snap'
+import type { UndoManager } from '@open-pencil/scene-graph/undo'
+
+import type { RulerTheme, SkiaRenderer } from '#core/canvas/renderer'
+import type { RenderOverlays } from '#core/canvas/renderer/types'
import type { TextEditor } from '#core/text/editor'
-import type { Color, Rect, Vector } from '#core/types'
export type Tool =
| 'SELECT'
diff --git a/packages/core/src/editor/undo.ts b/packages/core/src/editor/undo.ts
index 388e4dae6..4002f935f 100644
--- a/packages/core/src/editor/undo.ts
+++ b/packages/core/src/editor/undo.ts
@@ -1,9 +1,8 @@
import { pick } from 'es-toolkit/object'
-import { cloneVectorNetwork } from '#core/scene-graph'
-import type { SceneNode } from '#core/scene-graph'
-import type { UndoEntry } from '#core/scene-graph/undo'
-import type { Rect, Vector } from '#core/types'
+import { cloneVectorNetwork, type SceneNode } from '@open-pencil/scene-graph'
+import type { Rect, Vector } from '@open-pencil/scene-graph/primitives'
+import type { UndoEntry } from '@open-pencil/scene-graph/undo'
import { restoreSubtree, snapshotSubtree } from './clipboard/subtree-history'
import { collectNodePositions, pushPositionUndo } from './history/position'
diff --git a/packages/core/src/editor/variables.ts b/packages/core/src/editor/variables.ts
index d74deb01e..33e63331c 100644
--- a/packages/core/src/editor/variables.ts
+++ b/packages/core/src/editor/variables.ts
@@ -1,5 +1,11 @@
+import type {
+ Variable,
+ VariableCollection,
+ VariableType,
+ VariableValue
+} from '@open-pencil/scene-graph'
+
import { randomHex } from '#core/random'
-import type { Variable, VariableCollection, VariableType, VariableValue } from '#core/scene-graph'
import type { EditorContext } from './types'
diff --git a/packages/core/src/editor/viewport.ts b/packages/core/src/editor/viewport.ts
index 444de0059..f66ba7ca9 100644
--- a/packages/core/src/editor/viewport.ts
+++ b/packages/core/src/editor/viewport.ts
@@ -1,5 +1,6 @@
+import { computeBounds, computeAbsoluteBounds } from '@open-pencil/scene-graph/geometry'
+
import { ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN } from '#core/constants'
-import { computeBounds, computeAbsoluteBounds } from '#core/geometry'
import type { EditorContext } from './types'
diff --git a/packages/core/src/figma-api/accessor-utils.ts b/packages/core/src/figma-api/accessor-utils.ts
index e4b1d40ff..7adb135bb 100644
--- a/packages/core/src/figma-api/accessor-utils.ts
+++ b/packages/core/src/figma-api/accessor-utils.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export interface NodeProxyInternals {
id: symbol
diff --git a/packages/core/src/figma-api/accessors/basic.ts b/packages/core/src/figma-api/accessors/basic.ts
index bf7ab6775..c04286367 100644
--- a/packages/core/src/figma-api/accessors/basic.ts
+++ b/packages/core/src/figma-api/accessors/basic.ts
@@ -1,3 +1,6 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
+
import {
graph,
nodeId,
@@ -6,8 +9,6 @@ import {
type ProxyThis
} from '#core/figma-api/accessor-utils'
import type { NodeProxyHost } from '#core/figma-api/proxy'
-import type { SceneNode } from '#core/scene-graph'
-import type { Rect } from '#core/types'
export function installBasicNodeProxyAccessors(
prototype: object,
diff --git a/packages/core/src/figma-api/accessors/layout.ts b/packages/core/src/figma-api/accessors/layout.ts
index ad8dcef14..7c299f013 100644
--- a/packages/core/src/figma-api/accessors/layout.ts
+++ b/packages/core/src/figma-api/accessors/layout.ts
@@ -1,10 +1,11 @@
+import type { LayoutMode, SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import {
raw,
updateNode,
type NodeProxyInternals,
type ProxyThis
} from '#core/figma-api/accessor-utils'
-import type { LayoutMode, SceneGraph, SceneNode } from '#core/scene-graph'
function graph(target: ProxyThis, internals: NodeProxyInternals): SceneGraph {
return target[internals.graph] as SceneGraph
diff --git a/packages/core/src/figma-api/accessors/visual.ts b/packages/core/src/figma-api/accessors/visual.ts
index 91f5c63c0..76d80f5f4 100644
--- a/packages/core/src/figma-api/accessors/visual.ts
+++ b/packages/core/src/figma-api/accessors/visual.ts
@@ -1,3 +1,6 @@
+import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/scene-graph'
+import { copyEffects, copyFills, copyStrokes } from '@open-pencil/scene-graph/copy'
+
import { normalizeColor } from '#core/color'
import {
raw,
@@ -5,8 +8,6 @@ import {
type NodeProxyInternals,
type ProxyThis
} from '#core/figma-api/accessor-utils'
-import type { Effect, Fill, SceneNode, Stroke } from '#core/scene-graph'
-import { copyEffects, copyFills, copyStrokes } from '#core/scene-graph/copy'
export function installVisualNodeProxyAccessors(
prototype: object,
diff --git a/packages/core/src/figma-api/index.ts b/packages/core/src/figma-api/index.ts
index 4ea7acbfb..029e7c279 100644
--- a/packages/core/src/figma-api/index.ts
+++ b/packages/core/src/figma-api/index.ts
@@ -1,9 +1,3 @@
-import type { SkiaRenderer } from '#core/canvas'
-import { canMakeBooleanSourceNode } from '#core/canvas/boolean'
-import { flattenNodesToVectorProps } from '#core/canvas/flatten'
-import { IS_BROWSER } from '#core/constants'
-import { computeBounds } from '#core/geometry'
-import type { RasterExportFormat } from '#core/io/formats/raster'
import type {
SceneGraph,
SceneNode as CoreSceneNode,
@@ -12,9 +6,17 @@ import type {
VariableCollection,
VariableType,
VariableValue
-} from '#core/scene-graph'
-import { copyFills, copyStrokes, copyEffects } from '#core/scene-graph/copy'
-import type { Rect, Vector } from '#core/types'
+} from '@open-pencil/scene-graph'
+import { copyFills, copyStrokes, copyEffects } from '@open-pencil/scene-graph/copy'
+import { computeBounds } from '@open-pencil/scene-graph/geometry'
+import { computeImageHash } from '@open-pencil/scene-graph/images'
+import type { Rect, Vector } from '@open-pencil/scene-graph/primitives'
+
+import type { SkiaRenderer } from '#core/canvas'
+import { canMakeBooleanSourceNode } from '#core/canvas/boolean'
+import { flattenNodesToVectorProps } from '#core/canvas/flatten'
+import { IS_BROWSER } from '#core/constants'
+import type { RasterExportFormat } from '#core/io/formats/raster'
import type {
FigmaBooleanOperationNode,
@@ -58,39 +60,7 @@ export type {
} from './node-types'
export type { FigmaFont, FigmaFontName } from './proxy'
-export function computeImageHash(data: Uint8Array): string {
- let h1 = 0x811c9dc5 >>> 0
- let h2 = 0x811c9dc5 >>> 0
- let h3 = 0x811c9dc5 >>> 0
- let h4 = 0x811c9dc5 >>> 0
- let h5 = 0x811c9dc5 >>> 0
- for (let i = 0; i < data.length; i++) {
- const b = data[i]
- switch (i % 5) {
- case 0:
- h1 ^= b
- h1 = Math.imul(h1, 0x01000193) >>> 0
- break
- case 1:
- h2 ^= b
- h2 = Math.imul(h2, 0x01000193) >>> 0
- break
- case 2:
- h3 ^= b
- h3 = Math.imul(h3, 0x01000193) >>> 0
- break
- case 3:
- h4 ^= b
- h4 = Math.imul(h4, 0x01000193) >>> 0
- break
- case 4:
- h5 ^= b
- h5 = Math.imul(h5, 0x01000193) >>> 0
- break
- }
- }
- return [h1, h2, h3, h4, h5].map((h) => h.toString(16).padStart(8, '0')).join('')
-}
+export { computeImageHash }
// TODO(figma-api): Implement the full official PluginAPI interface once our compatibility
// layer covers all required node-specific return types and unsupported APIs are modeled explicitly.
diff --git a/packages/core/src/figma-api/plugin-data.ts b/packages/core/src/figma-api/plugin-data.ts
index 40e6b539e..9e0699323 100644
--- a/packages/core/src/figma-api/plugin-data.ts
+++ b/packages/core/src/figma-api/plugin-data.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export const OPEN_PENCIL_PLUGIN_DATA_NAMESPACE = 'open-pencil'
diff --git a/packages/core/src/figma-api/proxy.ts b/packages/core/src/figma-api/proxy.ts
index e82c0297a..4b063b823 100644
--- a/packages/core/src/figma-api/proxy.ts
+++ b/packages/core/src/figma-api/proxy.ts
@@ -1,10 +1,3 @@
-import {
- getFillOkHCL,
- getStrokeOkHCL,
- setNodeFillOkHCL,
- setNodeStrokeOkHCL
-} from '#core/color/okhcl'
-import type { OkHCLColor, OkHCLPayload } from '#core/color/okhcl'
import type {
SceneGraph,
SceneNode,
@@ -13,8 +6,16 @@ import type {
Stroke,
Effect,
LayoutMode
-} from '#core/scene-graph'
-import type { Rect } from '#core/types'
+} from '@open-pencil/scene-graph'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
+
+import {
+ getFillOkHCL,
+ getStrokeOkHCL,
+ setNodeFillOkHCL,
+ setNodeStrokeOkHCL
+} from '#core/color/okhcl'
+import type { OkHCLColor, OkHCLPayload } from '#core/color/okhcl'
import { installBasicNodeProxyAccessors } from './accessors/basic'
import { installLayoutNodeProxyAccessors } from './accessors/layout'
diff --git a/packages/core/src/figma-api/serialization.ts b/packages/core/src/figma-api/serialization.ts
index d53f1acc4..67f29fb38 100644
--- a/packages/core/src/figma-api/serialization.ts
+++ b/packages/core/src/figma-api/serialization.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import type { NodeProxyHost } from './proxy'
diff --git a/packages/core/src/figma-api/strokes.ts b/packages/core/src/figma-api/strokes.ts
index c32dface7..3287aa226 100644
--- a/packages/core/src/figma-api/strokes.ts
+++ b/packages/core/src/figma-api/strokes.ts
@@ -1,5 +1,5 @@
-import type { SceneGraph, SceneNode, Stroke } from '#core/scene-graph'
-import { copyStrokes } from '#core/scene-graph/copy'
+import type { SceneGraph, SceneNode, Stroke } from '@open-pencil/scene-graph'
+import { copyStrokes } from '@open-pencil/scene-graph/copy'
export function setFirstStrokeWeight(graph: SceneGraph, node: SceneNode, weight: number): void {
if (node.strokes.length === 0) return
diff --git a/packages/core/src/figma-api/text.ts b/packages/core/src/figma-api/text.ts
index df3bf2dfe..ed66a42f1 100644
--- a/packages/core/src/figma-api/text.ts
+++ b/packages/core/src/figma-api/text.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import { styleNameToWeight, weightToStyleName, type FigmaFontName } from './fonts'
diff --git a/packages/core/src/figma-api/traversal.ts b/packages/core/src/figma-api/traversal.ts
index 27a555be7..730a46c40 100644
--- a/packages/core/src/figma-api/traversal.ts
+++ b/packages/core/src/figma-api/traversal.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import type { FigmaNodeProxy, NodeProxyHost } from './proxy'
diff --git a/packages/core/src/icons/path-style.ts b/packages/core/src/icons/path-style.ts
index 33e698339..caf072386 100644
--- a/packages/core/src/icons/path-style.ts
+++ b/packages/core/src/icons/path-style.ts
@@ -1,5 +1,5 @@
-import type { SceneNode, Stroke } from '#core/scene-graph'
-import type { Color } from '#core/types'
+import type { SceneNode, Stroke } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
const STROKE_CAP_MAP: Record<string, SceneNode['strokeCap']> = {
butt: 'NONE',
diff --git a/packages/core/src/icons/render.ts b/packages/core/src/icons/render.ts
index 81f1e49ce..ff3a9b047 100644
--- a/packages/core/src/icons/render.ts
+++ b/packages/core/src/icons/render.ts
@@ -1,7 +1,8 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { parseColor } from '#core/color'
import { createPathStroke } from '#core/icons/path-style'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Color } from '#core/types'
import type { IconData } from './types'
diff --git a/packages/core/src/icons/types.ts b/packages/core/src/icons/types.ts
index 3ed0e0244..e84a854b6 100644
--- a/packages/core/src/icons/types.ts
+++ b/packages/core/src/icons/types.ts
@@ -1,4 +1,4 @@
-import type { VectorNetwork, WindingRule } from '#core/scene-graph'
+import type { VectorNetwork, WindingRule } from '@open-pencil/scene-graph'
export interface IconPath {
vectorNetwork: VectorNetwork
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index db06545fc..ddc28a9e6 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -1,13 +1,3 @@
-export type { GUID, Color, Vector, Matrix, Rect } from './types'
-export {
- computeBounds,
- computeAbsoluteBounds,
- degToRad,
- radToDeg,
- rotatePoint,
- rotatedCorners,
- rotatedBBox
-} from './geometry'
export { randomHex, randomInt, randomIndex } from './random'
export * from './constants'
@@ -74,7 +64,7 @@ export {
type StyleRun,
type SceneGraphEvents,
type DocumentColorSpace
-} from './scene-graph'
+} from '@open-pencil/scene-graph'
export { FigmaAPI, FigmaNodeProxy, computeImageHash, type FigmaFontName } from './figma-api'
export {
@@ -248,8 +238,8 @@ export {
type NearestResult,
type NetworkNearestResult
} from './vector/bezier'
-export { computeSelectionBounds, computeSnap, type SnapGuide } from './scene-graph/snap'
-export { UndoManager, type UndoEntry, type UndoManagerOptions } from './scene-graph/undo'
+export { computeSelectionBounds, computeSnap, type SnapGuide } from '@open-pencil/scene-graph/snap'
+export { UndoManager, type UndoEntry, type UndoManagerOptions } from '@open-pencil/scene-graph/undo'
export { TextEditor, type TextCaret, type TextEditorState } from './text/editor'
export {
getStyleAt,
@@ -438,11 +428,3 @@ export {
getStockPhotoProviders
} from './tools/stock-photo'
export type { StockPhotoProvider, StockPhotoResult } from './tools/stock-photo'
-
-export {
- getAbsoluteRotation,
- getWorldHandles,
- getWorldMatrix,
- getAbsolutePosition
-} from './canvas/coordinate'
-export { default as TransformMatrix } from './canvas/matrix'
diff --git a/packages/core/src/io/formats/fig/export.ts b/packages/core/src/io/formats/fig/export.ts
index 7576a21b9..b3495ac9e 100644
--- a/packages/core/src/io/formats/fig/export.ts
+++ b/packages/core/src/io/formats/fig/export.ts
@@ -4,6 +4,8 @@ import { deflateSync, inflateSync } from 'fflate'
import { initCodec, getCompiledSchema, getSchemaBytes } from '@open-pencil/kiwi/fig/codec'
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
import { decodeBinarySchema, compileSchema, ByteBuffer } from '@open-pencil/kiwi/schema-runtime'
+import type { SceneGraph, VariableValue } from '@open-pencil/scene-graph'
+import type { GUID } from '@open-pencil/scene-graph/primitives'
import type { SkiaRenderer } from '#core/canvas'
import { CANVAS_BG_COLOR, IS_BROWSER, IS_TAURI } from '#core/constants'
@@ -18,8 +20,6 @@ import {
makeDocumentNodeChange,
makeCanvasNodeChange
} from '#core/kiwi/fig/node-change/serialize'
-import type { SceneGraph, VariableValue } from '#core/scene-graph'
-import type { GUID } from '#core/types'
import { compressFigDataSync } from './compress'
diff --git a/packages/core/src/io/formats/fig/read.ts b/packages/core/src/io/formats/fig/read.ts
index 107d5c7b3..1eba5fb3d 100644
--- a/packages/core/src/io/formats/fig/read.ts
+++ b/packages/core/src/io/formats/fig/read.ts
@@ -1,10 +1,10 @@
import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import { IS_BROWSER } from '#core/constants'
import { importNodeChanges } from '#core/kiwi/fig/import'
import { deserializeSceneGraph } from '#core/kiwi/fig/parse/transfer'
import type { SerializedSceneGraph } from '#core/kiwi/fig/parse/transfer'
-import type { SceneGraph } from '#core/scene-graph'
export interface ParseFigFileOptions {
populate?: 'all' | 'first-page'
diff --git a/packages/core/src/io/formats/jsx/export.ts b/packages/core/src/io/formats/jsx/export.ts
index 39064f449..80f3a882b 100644
--- a/packages/core/src/io/formats/jsx/export.ts
+++ b/packages/core/src/io/formats/jsx/export.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph, SceneNode, NodeType } from '@open-pencil/scene-graph'
+
import { DEFAULT_FONT_FAMILY } from '#core/constants'
-import type { SceneGraph, SceneNode, NodeType } from '#core/scene-graph'
import { resolveNodeTextDirection } from '#core/text/direction'
import {
diff --git a/packages/core/src/io/formats/jsx/helpers.ts b/packages/core/src/io/formats/jsx/helpers.ts
index a31ac431b..4e021ceeb 100644
--- a/packages/core/src/io/formats/jsx/helpers.ts
+++ b/packages/core/src/io/formats/jsx/helpers.ts
@@ -1,4 +1,3 @@
-import { colorToHex8 } from '#core/color'
import type {
SceneGraph,
SceneNode,
@@ -7,7 +6,9 @@ import type {
Effect,
Color,
GridTrack
-} from '#core/scene-graph'
+} from '@open-pencil/scene-graph'
+
+import { colorToHex8 } from '#core/color'
export function formatColor(color: Color, opacity = 1): string {
return colorToHex8(color, opacity)
diff --git a/packages/core/src/io/formats/jsx/tailwind-classes.ts b/packages/core/src/io/formats/jsx/tailwind-classes.ts
index 87e919fdd..4efcebad0 100644
--- a/packages/core/src/io/formats/jsx/tailwind-classes.ts
+++ b/packages/core/src/io/formats/jsx/tailwind-classes.ts
@@ -1,8 +1,9 @@
import { twirl } from 'twirlwind'
+import type { GridTrack, SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { colorToCSSCompact } from '#core/color'
import { DEFAULT_FONT_FAMILY } from '#core/constants'
-import type { GridTrack, SceneGraph, SceneNode } from '#core/scene-graph'
import { resolveNodeTextDirection } from '#core/text/direction'
import { formatTrack, getNodeContext, solidFillColor, solidStroke } from './helpers'
diff --git a/packages/core/src/io/formats/pdf/export.ts b/packages/core/src/io/formats/pdf/export.ts
index 6c1864c90..5f5c942ac 100644
--- a/packages/core/src/io/formats/pdf/export.ts
+++ b/packages/core/src/io/formats/pdf/export.ts
@@ -1,6 +1,7 @@
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { computeContentBounds } from '#core/io/formats/raster'
import { renderNodesToSVG } from '#core/io/formats/svg'
-import type { SceneGraph } from '#core/scene-graph'
export interface PDFExportOptions {
title?: string
diff --git a/packages/core/src/io/formats/pen/convert.ts b/packages/core/src/io/formats/pen/convert.ts
index 276fb0067..a6da212be 100644
--- a/packages/core/src/io/formats/pen/convert.ts
+++ b/packages/core/src/io/formats/pen/convert.ts
@@ -1,473 +1 @@
-import { parseColor } from '#core/color'
-import { BLACK } from '#core/constants'
-import { generateId } from '#core/scene-graph'
-import type {
- Color,
- Effect,
- Fill,
- LayoutAlign,
- LayoutCounterAlign,
- LayoutMode,
- LayoutSizing,
- NodeType,
- SceneGraph,
- SceneNode,
- Stroke,
- StrokeCap,
- StrokeJoin,
- TextAlignVertical,
- Variable,
- VariableCollection,
- VariableCollectionMode,
- VariableType,
- VariableValue
-} from '#core/scene-graph'
-import type { Vector } from '#core/types'
-
-export interface PenDocument {
- version: string
- children: PenNode[]
- themes?: Record<string, string[]>
- variables?: Record<string, PenVariable>
-}
-
-export interface PenVariable {
- type: 'color' | 'string' | 'number'
- value: PenVariableValue[] | PenVariableValue | string | number
-}
-
-interface PenVariableValue {
- value: string | number
- theme?: Record<string, string>
-}
-
-interface PenStroke {
- align: 'inside' | 'center' | 'outside'
- thickness: number | { top?: number; right?: number; bottom?: number; left?: number }
- fill?: string
- join?: string
- cap?: string
-}
-
-interface PenEffect {
- type: string
- shadowType?: string
- color?: string
- offset?: Vector
- blur?: number
- spread?: number
-}
-
-interface PenFillObject {
- type: string
- color: string
- enabled?: boolean
-}
-
-type PenFill = string | PenFillObject | PenFillObject[]
-
-export interface PenNode {
- type: string
- id: string
- name?: string
- x?: number
- y?: number
- width?: number | string
- height?: number | string
- fill?: PenFill
- opacity?: number
- enabled?: boolean
- clip?: boolean
- rotation?: number
- flipX?: boolean
- flipY?: boolean
- reusable?: boolean
- cornerRadius?: number | string | (number | string)[]
- stroke?: PenStroke
- effect?: PenEffect | PenEffect[]
- layout?: string
- gap?: number | string
- padding?: number | string | (number | string)[]
- justifyContent?: string
- alignItems?: string
- children?: PenNode[]
- content?: string
- fontFamily?: string
- fontSize?: number
- fontWeight?: string | number
- lineHeight?: number
- letterSpacing?: number
- textAlign?: string
- textAlignVertical?: string
- textGrowth?: string
- ref?: string
- descendants?: Record<string, Partial<PenNode>>
- slot?: string[]
- geometry?: string
- iconFontName?: string
- iconFontFamily?: string
- weight?: number
- model?: string
- theme?: Record<string, string>
-}
-
-export interface VarContext {
- byName: Map<string, { id: string; variable: Variable }>
- activeModeId: string
- collectionId: string
- modeByThemeName: Map<string, string>
- resolveColor(ref: string): Color
- resolveNumber(ref: string): number
- resolveString(ref: string): string
- setActiveTheme(themeName: string): void
-}
-
-function penVarTypeToSceneType(t: string): VariableType {
- if (t === 'color') return 'COLOR'
- if (t === 'number') return 'FLOAT'
- return 'STRING'
-}
-
-function penValueToSceneValue(raw: string | number, type: VariableType): VariableValue {
- if (type === 'COLOR' && typeof raw === 'string') return parseColor(raw)
- if (type === 'FLOAT' && typeof raw === 'number') return raw
- if (type === 'STRING') return String(raw)
- if (typeof raw === 'number') return raw
- return String(raw)
-}
-
-function defaultForType(type: VariableType): VariableValue {
- if (type === 'COLOR') return { ...BLACK }
- if (type === 'FLOAT') return 0
- if (type === 'BOOLEAN') return false
- return ''
-}
-
-export function isVarRef(val: unknown): val is string {
- return typeof val === 'string' && val.startsWith('$--')
-}
-
-function varName(ref: string): string {
- return ref.replace(/^\$/, '')
-}
-
-export function bindIfVar(node: SceneNode, field: string, val: unknown, ctx: VarContext): void {
- if (!isVarRef(val)) return
- const entry = ctx.byName.get(varName(val))
- if (!entry) return
- // Directly sets boundVariables during .pen deserialization — bypasses graph.bindVariable()
- // to avoid spurious node:updated events during bulk loading and to normalize bracket
- // notation (fills[N] → fills/N/color) that the .pen format uses.
- const normalizedField = /^(fills|strokes)\[\d+]$/.test(field)
- ? field.replace(/\[(\d+)]/, '/$1/color')
- : field
- node.boundVariables[normalizedField] = entry.id
-}
-
-export function buildVarContext(
- graph: SceneGraph,
- penVars: Record<string, PenVariable>,
- themes: Record<string, string[]>
-): VarContext {
- const collectionId = generateId()
- const modes: VariableCollectionMode[] = []
- const themeKeys = Object.keys(themes)
-
- if (themeKeys.length > 0) {
- const themeKey = themeKeys[0]
- for (const modeName of themes[themeKey]) {
- modes.push({ modeId: generateId(), name: modeName })
- }
- }
- if (modes.length === 0) {
- modes.push({ modeId: generateId(), name: 'Default' })
- }
-
- const collection: VariableCollection = {
- id: collectionId,
- name: 'Variables',
- modes,
- defaultModeId: modes[0].modeId,
- variableIds: []
- }
- graph.addCollection(collection)
-
- const modeByThemeValue = new Map<string, string>()
- if (themeKeys.length > 0) {
- const themeKey = themeKeys[0]
- for (const mode of modes) {
- modeByThemeValue.set(`${themeKey}:${mode.name}`, mode.modeId)
- }
- }
-
- const byName = new Map<string, { id: string; variable: Variable }>()
-
- for (const [name, def] of Object.entries(penVars)) {
- const varId = generateId()
- const varType = penVarTypeToSceneType(def.type)
- const valuesByMode: Record<string, VariableValue> = {}
-
- if (Array.isArray(def.value)) {
- for (const entry of def.value) {
- if (entry.theme) {
- const [tKey, tVal] = Object.entries(entry.theme)[0]
- const modeId = modeByThemeValue.get(`${tKey}:${tVal}`)
- if (modeId) valuesByMode[modeId] = penValueToSceneValue(entry.value, varType)
- } else {
- valuesByMode[modes[0].modeId] = penValueToSceneValue(entry.value, varType)
- }
- }
- } else {
- valuesByMode[modes[0].modeId] = penValueToSceneValue(def.value as string | number, varType)
- }
-
- for (const mode of modes) {
- if (!(mode.modeId in valuesByMode)) {
- valuesByMode[mode.modeId] = valuesByMode[modes[0].modeId] ?? defaultForType(varType)
- }
- }
-
- const variable: Variable = {
- id: varId,
- name,
- type: varType,
- collectionId,
- valuesByMode,
- description: '',
- hiddenFromPublishing: false
- }
- graph.addVariable(variable)
- byName.set(name, { id: varId, variable })
- }
-
- let activeModeId = modes[0].modeId
-
- function resolveVal(ref: string): VariableValue | undefined {
- const entry = byName.get(ref.replace(/^\$/, ''))
- if (!entry) return undefined
- return (
- entry.variable.valuesByMode[activeModeId] ?? Object.values(entry.variable.valuesByMode)[0]
- )
- }
-
- return {
- byName,
- activeModeId,
- collectionId,
- modeByThemeName: modeByThemeValue,
- resolveColor(ref: string): Color {
- const val = resolveVal(ref)
- if (val === undefined) return parseColor(ref)
- if (typeof val === 'object' && 'r' in val) return val
- if (typeof val === 'string') return parseColor(val)
- return { ...BLACK }
- },
- resolveNumber(ref: string): number {
- const val = resolveVal(ref)
- return typeof val === 'number' ? val : 0
- },
- resolveString(ref: string): string {
- const val = resolveVal(ref)
- return typeof val === 'string' ? val : ''
- },
- setActiveTheme(themeName: string) {
- const modeId = modeByThemeValue.get(`theme:${themeName}`)
- if (modeId) {
- activeModeId = modeId
- graph.activeMode.set(collectionId, modeId)
- }
- }
- }
-}
-
-function parseFillColor(fill: string | PenFillObject, ctx: VarContext): Color {
- const raw = typeof fill === 'string' ? fill : fill.color
- return isVarRef(raw) ? ctx.resolveColor(raw) : parseColor(raw)
-}
-
-export function convertFill(fill: PenFill | undefined, ctx: VarContext, node?: SceneNode): Fill[] {
- if (fill === undefined) return []
- const fills = Array.isArray(fill) ? fill : [fill]
- return fills.map((item, index) => {
- const visible = typeof item === 'string' ? true : item.enabled !== false
- const color = parseFillColor(item, ctx)
- const result: Fill = { type: 'SOLID', visible, opacity: color.a, color }
- if (node) bindIfVar(node, `fills[${index}]`, typeof item === 'string' ? item : item.color, ctx)
- return result
- })
-}
-
-function strokeWeight(stroke: PenStroke): number {
- return typeof stroke.thickness === 'number'
- ? stroke.thickness
- : Math.max(...Object.values(stroke.thickness))
-}
-
-export function convertStroke(
- stroke: PenStroke | undefined,
- ctx: VarContext,
- node?: SceneNode
-): Stroke[] {
- if (!stroke?.fill) return []
- const color = isVarRef(stroke.fill) ? ctx.resolveColor(stroke.fill) : parseColor(stroke.fill)
- let align: Stroke['align'] = 'CENTER'
- if (stroke.align === 'inside') align = 'INSIDE'
- else if (stroke.align === 'outside') align = 'OUTSIDE'
-
- const result: Stroke = {
- visible: true,
- color,
- opacity: color.a,
- weight: strokeWeight(stroke),
- align,
- dashPattern: []
- }
- if (node) {
- bindIfVar(node, 'strokes[0]', stroke.fill, ctx)
- if (typeof stroke.thickness === 'object') {
- node.independentStrokeWeights = true
- node.borderTopWeight = stroke.thickness.top ?? 0
- node.borderRightWeight = stroke.thickness.right ?? 0
- node.borderBottomWeight = stroke.thickness.bottom ?? 0
- node.borderLeftWeight = stroke.thickness.left ?? 0
- }
- node.strokeJoin = mapStrokeJoin(stroke.join)
- node.strokeCap = mapStrokeCap(stroke.cap)
- }
- return [result]
-}
-
-function mapStrokeJoin(join: string | undefined): StrokeJoin {
- if (join === 'round') return 'ROUND'
- if (join === 'bevel') return 'BEVEL'
- return 'MITER'
-}
-
-function mapStrokeCap(cap: string | undefined): StrokeCap {
- if (cap === 'round') return 'ROUND'
- if (cap === 'square') return 'SQUARE'
- return 'NONE'
-}
-
-export function convertEffects(effect: PenEffect | PenEffect[] | undefined): Effect[] {
- if (!effect) return []
- const effects = Array.isArray(effect) ? effect : [effect]
- return effects.flatMap((item) => {
- if (item.type !== 'shadow') return []
- const color = item.color ? parseColor(item.color) : { r: 0, g: 0, b: 0, a: 0.25 }
- return [
- {
- type: item.shadowType === 'inner' ? 'INNER_SHADOW' : 'DROP_SHADOW',
- visible: true,
- blendMode: 'NORMAL',
- color,
- offset: item.offset ?? { x: 0, y: 0 },
- radius: item.blur ?? 0,
- spread: item.spread ?? 0
- } satisfies Effect
- ]
- })
-}
-
-export function applyCornerRadius(
- node: SceneNode,
- radius: PenNode['cornerRadius'],
- ctx: VarContext
-): void {
- if (radius === undefined) return
- if (Array.isArray(radius)) {
- const values = radius.map((value) => parseSize(value, 0, ctx).value)
- node.independentCorners = true
- node.topLeftRadius = values[0] ?? 0
- node.topRightRadius = values[1] ?? 0
- node.bottomRightRadius = values[2] ?? 0
- node.bottomLeftRadius = values[3] ?? 0
- return
- }
- node.cornerRadius = parseSize(radius, 0, ctx).value
-}
-
-export function applyPadding(node: SceneNode, padding: PenNode['padding'], ctx?: VarContext): void {
- if (padding === undefined) return
- const resolve = (v: number | string): number =>
- typeof v === 'string' ? (isVarRef(v) && ctx ? ctx.resolveNumber(v) : Number(v) || 0) : v
- if (Array.isArray(padding)) {
- node.paddingTop = resolve(padding[0] ?? 0)
- node.paddingRight = resolve(padding[1] ?? 0)
- node.paddingBottom = resolve(padding[2] ?? 0)
- node.paddingLeft = resolve(padding[3] ?? 0)
- return
- }
- const resolved = resolve(padding)
- node.paddingTop = resolved
- node.paddingRight = resolved
- node.paddingBottom = resolved
- node.paddingLeft = resolved
-}
-
-export function parseSize(value: number | string | undefined, fallback: number, ctx?: VarContext) {
- if (value === undefined) return { value: fallback, sizing: 'FIXED' as LayoutSizing }
- if (typeof value === 'number') return { value, sizing: 'FIXED' as LayoutSizing }
- if (value === 'fill_container') return { value: fallback, sizing: 'FILL' as LayoutSizing }
- if (value === 'hug_content') return { value: fallback, sizing: 'HUG' as LayoutSizing }
- if (isVarRef(value) && ctx)
- return { value: ctx.resolveNumber(value), sizing: 'FIXED' as LayoutSizing }
- const parsed = Number(value)
- return { value: Number.isFinite(parsed) ? parsed : fallback, sizing: 'FIXED' as LayoutSizing }
-}
-
-export function mapLayoutMode(pen: PenNode): LayoutMode {
- if (pen.layout === 'row' || pen.layout === 'horizontal') return 'HORIZONTAL'
- if (pen.layout === 'column' || pen.layout === 'vertical') return 'VERTICAL'
- return 'NONE'
-}
-
-export function mapJustifyContent(value: string | undefined): LayoutAlign {
- if (value === 'center') return 'CENTER'
- if (value === 'end') return 'MAX'
- if (value === 'space-between') return 'SPACE_BETWEEN'
- return 'MIN'
-}
-
-export function mapAlignItems(value: string | undefined): LayoutCounterAlign {
- if (value === 'center') return 'CENTER'
- if (value === 'end') return 'MAX'
- if (value === 'stretch') return 'STRETCH'
- return 'MIN'
-}
-
-export function mapTextAlign(value: string | undefined): SceneNode['textAlignHorizontal'] {
- if (value === 'center') return 'CENTER'
- if (value === 'right' || value === 'end') return 'RIGHT'
- if (value === 'justified') return 'JUSTIFIED'
- return 'LEFT'
-}
-
-export function mapTextAlignVertical(value: string | undefined): TextAlignVertical {
- if (value === 'center') return 'CENTER'
- if (value === 'bottom' || value === 'end') return 'BOTTOM'
- return 'TOP'
-}
-
-export function mapFontWeight(value: string | number | undefined): number {
- if (typeof value === 'number') return value
- if (value === 'thin') return 100
- if (value === 'extralight') return 200
- if (value === 'light') return 300
- if (value === 'medium') return 500
- if (value === 'semibold') return 600
- if (value === 'bold') return 700
- if (value === 'extrabold') return 800
- if (value === 'black') return 900
- return 400
-}
-
-export function mapNodeType(pen: PenNode): NodeType {
- if (pen.type === 'frame') return pen.reusable ? 'COMPONENT' : 'FRAME'
- if (pen.type === 'rectangle') return 'RECTANGLE'
- if (pen.type === 'ellipse') return 'ELLIPSE'
- if (pen.type === 'text' || pen.type === 'icon_font') return 'TEXT'
- if (pen.type === 'path') return 'VECTOR'
- if (pen.type === 'ref') return 'INSTANCE'
- return 'FRAME'
-}
+export * from '@open-pencil/pen'
diff --git a/packages/core/src/io/formats/pen/index.ts b/packages/core/src/io/formats/pen/index.ts
index 7a64c8910..a6da212be 100644
--- a/packages/core/src/io/formats/pen/index.ts
+++ b/packages/core/src/io/formats/pen/index.ts
@@ -1,2 +1 @@
-export { parsePenFile, readPenFile } from './read'
-export * from './convert'
+export * from '@open-pencil/pen'
diff --git a/packages/core/src/io/formats/pen/read.ts b/packages/core/src/io/formats/pen/read.ts
index c1d0fc912..d3c3f5789 100644
--- a/packages/core/src/io/formats/pen/read.ts
+++ b/packages/core/src/io/formats/pen/read.ts
@@ -1,529 +1 @@
-import { parseSVGPath } from '#core/io/formats/svg/parse-path'
-import { SceneGraph } from '#core/scene-graph'
-import type { LayoutMode, LayoutSizing, SceneNode, VectorNetwork } from '#core/scene-graph'
-import { copyEffects, copyFills, copyStrokes } from '#core/scene-graph/copy'
-import { populateInstanceChildren } from '#core/scene-graph/instances'
-
-import {
- applyCornerRadius,
- applyPadding,
- bindIfVar,
- buildVarContext,
- convertEffects,
- convertFill,
- convertStroke,
- isVarRef,
- mapAlignItems,
- mapFontWeight,
- mapJustifyContent,
- mapLayoutMode,
- mapNodeType,
- mapTextAlign,
- mapTextAlignVertical,
- parseSize,
- type PenDocument,
- type PenNode,
- type VarContext
-} from './convert'
-
-function scaleVectorNetwork(vn: VectorNetwork, targetW: number, targetH: number): void {
- if (vn.vertices.length === 0) return
- let minX = Infinity
- let maxX = -Infinity
- let minY = Infinity
- let maxY = -Infinity
- for (const v of vn.vertices) {
- minX = Math.min(minX, v.x)
- maxX = Math.max(maxX, v.x)
- minY = Math.min(minY, v.y)
- maxY = Math.max(maxY, v.y)
- }
- const vnW = maxX - minX
- const vnH = maxY - minY
- if (vnW < 0.01 || vnH < 0.01) return
- const sx = targetW / vnW
- const sy = targetH / vnH
- if (Math.abs(sx - 1) < 0.01 && Math.abs(sy - 1) < 0.01) return
- for (const v of vn.vertices) {
- v.x = (v.x - minX) * sx
- v.y = (v.y - minY) * sy
- }
- for (const s of vn.segments) {
- s.tangentStart = { x: s.tangentStart.x * sx, y: s.tangentStart.y * sy }
- s.tangentEnd = { x: s.tangentEnd.x * sx, y: s.tangentEnd.y * sy }
- }
-}
-
-function resolveFontFamily(raw: string | undefined, ctx: VarContext): string {
- if (!raw) return 'Inter'
- if (isVarRef(raw)) return ctx.resolveString(raw)
- return raw
-}
-
-function buildBaseOverrides(pen: PenNode): Partial<SceneNode> {
- return {
- id: pen.id,
- name: pen.name ?? (pen.type === 'icon_font' ? (pen.iconFontName ?? 'Icon') : pen.type),
- x: pen.x ?? 0,
- y: pen.y ?? 0,
- visible: pen.enabled !== false,
- opacity: pen.opacity ?? 1,
- rotation: pen.rotation ?? 0,
- flipX: pen.flipX ?? false,
- flipY: pen.flipY ?? false,
- clipsContent: pen.clip ?? false,
- boundVariables: {}
- }
-}
-
-function applyAutoLayout(
- overrides: Partial<SceneNode>,
- layoutMode: LayoutMode,
- pen: PenNode,
- widthSizing: LayoutSizing,
- heightSizing: LayoutSizing,
- ctx?: VarContext
-): void {
- overrides.layoutMode = layoutMode
- overrides.primaryAxisAlign = mapJustifyContent(pen.justifyContent)
- overrides.counterAxisAlign = mapAlignItems(pen.alignItems)
- overrides.itemSpacing =
- typeof pen.gap === 'string' && isVarRef(pen.gap) && ctx
- ? ctx.resolveNumber(pen.gap)
- : ((pen.gap ?? 0) as number)
-
- if (layoutMode === 'VERTICAL') {
- overrides.primaryAxisSizing = heightSizing
- overrides.counterAxisSizing = widthSizing
- } else {
- overrides.primaryAxisSizing = widthSizing
- overrides.counterAxisSizing = heightSizing
- }
-}
-
-function applyTextProps(node: SceneNode, pen: PenNode, ctx: VarContext): void {
- node.text = pen.type === 'icon_font' ? (pen.iconFontName ?? '') : (pen.content ?? '')
- node.fontFamily =
- pen.type === 'icon_font'
- ? (pen.iconFontFamily ?? 'Material Symbols Sharp')
- : resolveFontFamily(pen.fontFamily, ctx)
- node.fontSize = pen.fontSize ?? 14
- node.fontWeight = mapFontWeight(
- pen.fontWeight ?? (pen.type === 'icon_font' ? pen.weight : undefined)
- )
- node.textAlignHorizontal = mapTextAlign(pen.textAlign)
- node.textAlignVertical = mapTextAlignVertical(pen.textAlignVertical)
- if (pen.lineHeight !== undefined) {
- node.lineHeight = pen.lineHeight < 5 ? pen.lineHeight * node.fontSize : pen.lineHeight
- }
- if (pen.letterSpacing !== undefined) node.letterSpacing = pen.letterSpacing
- node.textAutoResize = pen.textGrowth === 'fixed-width' ? 'HEIGHT' : 'WIDTH_AND_HEIGHT'
- if (pen.fontFamily && isVarRef(pen.fontFamily)) {
- bindIfVar(node, 'fontFamily', pen.fontFamily, ctx)
- }
-}
-
-function resolveSizing(pen: PenNode, ctx: VarContext) {
- const isTextLike = pen.type === 'text' || pen.type === 'icon_font'
- const defaultSize = isTextLike ? 20 : 100
- const defaultW = isTextLike && pen.width === undefined ? 10_000 : defaultSize
- const w = parseSize(pen.width, defaultW, ctx)
- const h = parseSize(pen.height, defaultSize, ctx)
- const layout = mapLayoutMode(pen)
-
- if (pen.width === undefined && layout !== 'NONE') w.sizing = 'HUG'
- if (pen.height === undefined && layout !== 'NONE') h.sizing = 'HUG'
-
- return { w, h, layout, isTextLike }
-}
-
-function inheritLayoutFromComp(node: SceneNode, pen: PenNode, comp: SceneNode): void {
- const wasRow = node.layoutMode === 'HORIZONTAL'
- node.layoutMode = comp.layoutMode
- node.primaryAxisAlign = comp.primaryAxisAlign
- node.counterAxisAlign = comp.counterAxisAlign
- const isRow = node.layoutMode === 'HORIZONTAL'
- if (wasRow !== isRow) {
- const oldP = node.primaryAxisSizing
- node.primaryAxisSizing = node.counterAxisSizing
- node.counterAxisSizing = oldP
- }
- const widthAxis = isRow ? 'primaryAxisSizing' : 'counterAxisSizing'
- const heightAxis = isRow ? 'counterAxisSizing' : 'primaryAxisSizing'
- if (pen.width === undefined) node[widthAxis] = comp[widthAxis]
- if (pen.height === undefined) node[heightAxis] = comp[heightAxis]
- if (pen.gap === undefined) node.itemSpacing = comp.itemSpacing
- if (pen.padding === undefined) {
- node.paddingTop = comp.paddingTop
- node.paddingRight = comp.paddingRight
- node.paddingBottom = comp.paddingBottom
- node.paddingLeft = comp.paddingLeft
- }
- if (pen.clip === undefined) node.clipsContent = comp.clipsContent
-}
-
-function applyRefVisuals(
- node: SceneNode,
- pen: PenNode,
- compPen: PenNode | undefined,
- ctx: VarContext
-): void {
- if (!compPen) return
- if (pen.fill === undefined && compPen.fill !== undefined)
- node.fills = convertFill(compPen.fill, ctx, node)
- if (pen.stroke === undefined && compPen.stroke)
- node.strokes = convertStroke(compPen.stroke, ctx, node)
- if (pen.effect === undefined && compPen.effect) node.effects = convertEffects(compPen.effect)
- if (pen.cornerRadius === undefined) applyCornerRadius(node, compPen.cornerRadius, ctx)
-}
-
-function applyRefProps(
- node: SceneNode,
- pen: PenNode,
- graph: SceneGraph,
- componentIds: Map<string, string>,
- penSources: Map<string, PenNode>,
- ctx: VarContext
-): void {
- if (!pen.ref) return
- const componentId = componentIds.get(pen.ref) ?? pen.ref
- node.componentId = componentId
- const comp = graph.getNode(componentId)
- if (!comp) return
- if (pen.width === undefined) node.width = comp.width
- if (pen.height === undefined) node.height = comp.height
- if (pen.layout === undefined) inheritLayoutFromComp(node, pen, comp)
- applyRefVisuals(node, pen, penSources.get(pen.ref), ctx)
-}
-
-function applyAllRefProps(
- penNodes: PenNode[],
- graph: SceneGraph,
- componentIds: Map<string, string>,
- penSources: Map<string, PenNode>,
- ctx: VarContext
-): void {
- for (const pen of penNodes) {
- if (pen.type === 'ref') {
- const node = graph.getNode(pen.id)
- if (node) applyRefProps(node, pen, graph, componentIds, penSources, ctx)
- }
- if (pen.children) applyAllRefProps(pen.children, graph, componentIds, penSources, ctx)
- }
-}
-
-function applyTheme(theme: Record<string, string>, ctx: VarContext): void {
- const themeName = Object.values(theme)[0]
- if (themeName) ctx.setActiveTheme(themeName)
-}
-
-// eslint-disable-next-line complexity -- .pen node mapping touches many format-specific fields
-function createSceneNode(
- pen: PenNode,
- parentId: string,
- graph: SceneGraph,
- ctx: VarContext,
- componentIds: Map<string, string>,
- penSources: Map<string, PenNode>
-): string | null {
- if (pen.type === 'prompt') return null
- if (pen.theme) applyTheme(pen.theme, ctx)
-
- const { w, h, layout, isTextLike } = resolveSizing(pen, ctx)
- const overrides = buildBaseOverrides(pen)
- overrides.width = w.value
- overrides.height = h.value
-
- const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'
- if (layout !== 'NONE') {
- const widthSizing =
- parentLayout === 'NONE' && w.sizing === 'FILL' ? ('FIXED' as LayoutSizing) : w.sizing
- const heightSizing =
- parentLayout === 'NONE' && h.sizing === 'FILL' ? ('FIXED' as LayoutSizing) : h.sizing
- applyAutoLayout(overrides, layout, pen, widthSizing, heightSizing, ctx)
- }
-
- const node = graph.createNode(mapNodeType(pen), parentId, overrides)
-
- if (pen.fill !== undefined) node.fills = convertFill(pen.fill, ctx, node)
- if (pen.stroke) node.strokes = convertStroke(pen.stroke, ctx, node)
- node.effects = convertEffects(pen.effect)
- applyCornerRadius(node, pen.cornerRadius, ctx)
- applyPadding(node, pen.padding, ctx)
-
- if (isTextLike) {
- applyTextProps(node, pen, ctx)
- if (parentLayout === 'NONE' && pen.width === undefined && !pen.textGrowth) {
- node.textAutoResize = 'NONE'
- node.width = node.text.length * node.fontSize * 0.65
- node.height = node.fontSize * (node.lineHeight ? node.lineHeight / node.fontSize : 1.2)
- }
- }
-
- if (pen.type === 'path' && pen.geometry) {
- const vectorNetwork = parseSVGPath(pen.geometry)
- node.vectorNetwork = vectorNetwork
- scaleVectorNetwork(vectorNetwork, node.width, node.height)
- }
-
- if (parentLayout !== 'NONE') {
- const parentVertical = parentLayout === 'VERTICAL'
- if (w.sizing === 'FILL') {
- if (parentVertical) node.layoutAlignSelf = 'STRETCH'
- else node.layoutGrow = 1
- }
- if (h.sizing === 'FILL') {
- if (parentVertical) node.layoutGrow = 1
- else node.layoutAlignSelf = 'STRETCH'
- }
- }
-
- if (pen.reusable) {
- componentIds.set(pen.id, node.id)
- penSources.set(pen.id, pen)
- }
-
- if (pen.children) {
- for (const child of pen.children) {
- createSceneNode(child, node.id, graph, ctx, componentIds, penSources)
- }
- }
-
- return node.id
-}
-
-function collectByNameType(
- graph: SceneGraph,
- parentId: string,
- name: string,
- type: string,
- out: SceneNode[],
- depth: number
-): void {
- if (depth > 2) return
- const parent = graph.getNode(parentId)
- if (!parent) return
- for (const childId of parent.childIds) {
- const child = graph.getNode(childId)
- if (!child) continue
- if (child.name === name && child.type === type) out.push(child)
- collectByNameType(graph, childId, name, type, out, depth + 1)
- }
-}
-
-function findCloneByComponentId(
- graph: SceneGraph,
- parentId: string,
- origId: string
-): SceneNode | undefined {
- const parent = graph.getNode(parentId)
- if (!parent) return undefined
- for (const childId of parent.childIds) {
- const child = graph.getNode(childId)
- if (!child) continue
- if (child.componentId === origId) return child
- const deep = findCloneByComponentId(graph, childId, origId)
- if (deep) return deep
- }
- return undefined
-}
-
-function findCloneByNameFallback(
- graph: SceneGraph,
- parentId: string,
- origId: string
-): SceneNode | undefined {
- const orig = graph.getNode(origId)
- if (!orig) return undefined
- const matches: SceneNode[] = []
- collectByNameType(graph, parentId, orig.name, orig.type, matches, 0)
- return matches.length === 1 ? matches[0] : undefined
-}
-
-function applyOverrideProps(
- target: SceneNode,
- overrideData: Partial<PenNode>,
- ctx: VarContext
-): void {
- if (overrideData.fill !== undefined) target.fills = convertFill(overrideData.fill, ctx, target)
- if (overrideData.content !== undefined) target.text = overrideData.content
- if (overrideData.x !== undefined) target.x = overrideData.x
- if (overrideData.y !== undefined) target.y = overrideData.y
- if (overrideData.enabled !== undefined) target.visible = overrideData.enabled
- if (overrideData.width !== undefined)
- target.width = parseSize(overrideData.width, target.width, ctx).value
- if (overrideData.height !== undefined)
- target.height = parseSize(overrideData.height, target.height, ctx).value
- if (overrideData.rotation !== undefined) target.rotation = overrideData.rotation
- if (overrideData.name !== undefined) target.name = overrideData.name
-}
-
-function populateInstances(graph: SceneGraph): void {
- for (const node of graph.getAllNodes()) {
- if (node.type === 'INSTANCE' && node.componentId && node.childIds.length === 0) {
- const component = graph.getNode(node.componentId)
- if (component) populateInstanceChildren(graph, node.id, node.componentId)
- }
- }
-}
-
-function applyDescendantOverrides(
- graph: SceneGraph,
- pen: PenNode,
- ctx: VarContext,
- componentIds: Map<string, string>,
- penSources: Map<string, PenNode>
-): void {
- if (pen.type !== 'ref' || !pen.descendants) return
- const instanceNode = graph.getNode(pen.id)
- if (!instanceNode) return
-
- for (const [origId, overrideData] of Object.entries(pen.descendants)) {
- const clone =
- findCloneByComponentId(graph, instanceNode.id, origId) ??
- findCloneByNameFallback(graph, instanceNode.id, origId)
-
- if (clone) {
- if (overrideData.children) {
- const toDelete = clone.childIds.slice()
- for (const childId of toDelete) graph.deleteNode(childId)
- for (const child of overrideData.children) {
- createSceneNode(child, clone.id, graph, ctx, componentIds, penSources)
- }
- }
- applyOverrideProps(clone, overrideData, ctx)
- continue
- }
-
- if (overrideData.type && overrideData.id) {
- createSceneNode(
- overrideData as PenNode,
- instanceNode.id,
- graph,
- ctx,
- componentIds,
- penSources
- )
- }
- }
-}
-
-function walkAndApplyOverrides(
- nodes: PenNode[],
- graph: SceneGraph,
- ctx: VarContext,
- componentIds: Map<string, string>,
- penSources: Map<string, PenNode>
-): void {
- for (const pen of nodes) {
- applyDescendantOverrides(graph, pen, ctx, componentIds, penSources)
- if (pen.children) walkAndApplyOverrides(pen.children, graph, ctx, componentIds, penSources)
- }
-}
-
-function collectComponentIds(nodes: PenNode[], map: Map<string, string>): void {
- for (const node of nodes) {
- if (node.reusable) map.set(node.id, node.id)
- if (node.children) collectComponentIds(node.children, map)
- }
-}
-
-function resolveNodeVars(node: SceneNode, graph: SceneGraph, ctx: VarContext): void {
- for (const [key, varId] of Object.entries(node.boundVariables)) {
- const variable = graph.variables.get(varId)
- if (!variable) continue
- const modeVal =
- variable.valuesByMode[ctx.activeModeId] ?? Object.values(variable.valuesByMode)[0]
- if (
- key.startsWith('fills/') &&
- key.endsWith('/color') &&
- typeof modeVal === 'object' &&
- 'r' in modeVal
- ) {
- const idx = Number.parseInt(key.split('/')[1] ?? '0', 10)
- if (node.fills[idx]) node.fills[idx].color = modeVal
- } else if (
- key.startsWith('strokes/') &&
- key.endsWith('/color') &&
- typeof modeVal === 'object' &&
- 'r' in modeVal
- ) {
- const idx = Number.parseInt(key.split('/')[1] ?? '0', 10)
- if (node.strokes[idx]) node.strokes[idx].color = modeVal
- }
- }
- for (const childId of node.childIds) {
- const child = graph.getNode(childId)
- if (child) resolveNodeVars(child, graph, ctx)
- }
-}
-
-function resolveThemeVariables(penNodes: PenNode[], graph: SceneGraph, ctx: VarContext): void {
- for (const pen of penNodes) {
- if (pen.theme) applyTheme(pen.theme, ctx)
- const node = graph.getNode(pen.id)
- if (node) resolveNodeVars(node, graph, ctx)
- if (pen.children) resolveThemeVariables(pen.children, graph, ctx)
- }
-}
-
-function fixInstanceWidths(graph: SceneGraph): void {
- for (const node of graph.getAllNodes()) {
- if (node.type !== 'INSTANCE' || !node.componentId) continue
- const comp = graph.getNode(node.componentId)
- if (!comp) continue
- if (node.width <= 100 && comp.width > 100) node.width = comp.width
- if (node.height <= 100 && comp.height > 100) node.height = comp.height
- if (comp.layoutGrow > 0) node.layoutGrow = comp.layoutGrow
- if (comp.layoutAlignSelf !== 'AUTO') node.layoutAlignSelf = comp.layoutAlignSelf
- node.fills = copyFills(node.fills)
- node.strokes = copyStrokes(node.strokes)
- node.effects = copyEffects(node.effects)
- }
-}
-
-function fixTextWidths(graph: SceneGraph): void {
- for (const node of graph.getAllNodes()) {
- if (node.type !== 'TEXT' || !node.text || node.text.length <= 1) continue
- if (node.width >= node.fontSize * 2) continue
- node.width = node.text.length * node.fontSize * 0.65
- }
-}
-
-export function parsePenFile(json: string): SceneGraph {
- const doc: PenDocument = JSON.parse(json)
- const graph = new SceneGraph()
-
- for (const page of graph.getPages(true)) {
- graph.deleteNode(page.id)
- }
-
- const ctx = buildVarContext(graph, doc.variables ?? {}, doc.themes ?? {})
- const componentIds = new Map<string, string>()
- const penSources = new Map<string, PenNode>()
-
- collectComponentIds(doc.children, componentIds)
-
- const page = graph.addPage(doc.children[0]?.name ?? 'Page 1')
- for (const child of doc.children) {
- createSceneNode(child, page.id, graph, ctx, componentIds, penSources)
- }
-
- applyAllRefProps(doc.children, graph, componentIds, penSources, ctx)
- populateInstances(graph)
- walkAndApplyOverrides(doc.children, graph, ctx, componentIds, penSources)
- populateInstances(graph)
- resolveThemeVariables(doc.children, graph, ctx)
- fixInstanceWidths(graph)
- fixTextWidths(graph)
-
- if (graph.getPages(true).length === 0) {
- graph.addPage('Page 1')
- }
-
- return graph
-}
-
-export async function readPenFile(file: File): Promise<SceneGraph> {
- return parsePenFile(await file.text())
-}
+export { parsePenFile, readPenFile } from '@open-pencil/pen'
diff --git a/packages/core/src/io/formats/raster/headless.ts b/packages/core/src/io/formats/raster/headless.ts
index 8d0bade5e..6107cb60c 100644
--- a/packages/core/src/io/formats/raster/headless.ts
+++ b/packages/core/src/io/formats/raster/headless.ts
@@ -1,7 +1,8 @@
import type { CanvasKit } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { SkiaRenderer } from '#core/canvas'
-import type { SceneGraph } from '#core/scene-graph'
import { renderNodesToImage, renderThumbnail, type ExportFormat } from './render'
diff --git a/packages/core/src/io/formats/raster/render.ts b/packages/core/src/io/formats/raster/render.ts
index a9c9efb0c..dc9c4a146 100644
--- a/packages/core/src/io/formats/raster/render.ts
+++ b/packages/core/src/io/formats/raster/render.ts
@@ -1,10 +1,11 @@
import type { CanvasKit, Canvas } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import { computeDescendantVisualBounds } from '@open-pencil/scene-graph/geometry'
+
import type { SkiaRenderer } from '#core/canvas'
import type { RenderColorSpace } from '#core/color/management'
-import { computeDescendantVisualBounds } from '#core/geometry'
import { extractExportGraph, findPageId } from '#core/io/subgraph'
-import type { SceneGraph } from '#core/scene-graph'
export type RasterExportFormat = 'PNG' | 'JPG' | 'WEBP'
export type ExportFormat = RasterExportFormat | 'SVG'
diff --git a/packages/core/src/io/formats/svg/defs.ts b/packages/core/src/io/formats/svg/defs.ts
index f0ca2fc8a..139b2b4b9 100644
--- a/packages/core/src/io/formats/svg/defs.ts
+++ b/packages/core/src/io/formats/svg/defs.ts
@@ -1,8 +1,9 @@
+import type { Effect, Fill, SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { colorToHex } from '#core/color'
import { colorToDisplayCss, getDefaultRenderColorSpace } from '#core/color/management'
import type { RenderColorSpace } from '#core/color/management'
-import type { Effect, Fill, SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Color } from '#core/types'
import { svg, type SVGNode } from './node'
import { round } from './paths'
diff --git a/packages/core/src/io/formats/svg/export.ts b/packages/core/src/io/formats/svg/export.ts
index 39638344e..01b5d67ef 100644
--- a/packages/core/src/io/formats/svg/export.ts
+++ b/packages/core/src/io/formats/svg/export.ts
@@ -22,7 +22,13 @@ import {
export { geometryBlobToSVGPath, vectorNetworkToSVGPaths } from './paths'
-import type { SceneGraph, SceneNode, Fill, Stroke, CharacterStyleOverride } from '#core/scene-graph'
+import type {
+ SceneGraph,
+ SceneNode,
+ Fill,
+ Stroke,
+ CharacterStyleOverride
+} from '@open-pencil/scene-graph'
import type { SVGExportContext } from './defs'
import { svg, renderSVGNode } from './node'
diff --git a/packages/core/src/io/formats/svg/parse-path.ts b/packages/core/src/io/formats/svg/parse-path.ts
index 05caf52fc..63f9a2ce1 100644
--- a/packages/core/src/io/formats/svg/parse-path.ts
+++ b/packages/core/src/io/formats/svg/parse-path.ts
@@ -1,148 +1 @@
-import svgpath from 'svgpath'
-
-import type {
- VectorNetwork,
- VectorVertex,
- VectorSegment,
- VectorRegion,
- WindingRule
-} from '#core/scene-graph'
-
-interface SubPath {
- startVertexIndex: number
- segmentIndices: number[]
- closed: boolean
-}
-
-/**
- * Parse an SVG path `d` attribute into a VectorNetwork.
- *
- * Uses `svgpath` to normalize all commands to absolute M/L/C/Z
- * (arcs → cubics via `.unarc()`, smooth curves → explicit via `.unshort()`).
- */
-export function parseSVGPath(d: string, windingRule: WindingRule = 'NONZERO'): VectorNetwork {
- const vertices: VectorVertex[] = []
- const segments: VectorSegment[] = []
- const subPaths: SubPath[] = []
-
- let currentSubPath: SubPath | null = null
- let cx = 0
- let cy = 0
-
- const vertexMap = new Map<string, number>()
-
- function getOrCreateVertex(x: number, y: number): number {
- const key = `${x},${y}`
- const existing = vertexMap.get(key)
- if (existing !== undefined) return existing
- const idx = vertices.length
- vertices.push({ x, y })
- vertexMap.set(key, idx)
- return idx
- }
-
- function addSegment(
- x1: number,
- y1: number,
- x2: number,
- y2: number,
- tx1: number,
- ty1: number,
- tx2: number,
- ty2: number
- ): void {
- const startIdx = getOrCreateVertex(x1, y1)
- const endIdx = getOrCreateVertex(x2, y2)
- const segIdx = segments.length
- segments.push({
- start: startIdx,
- end: endIdx,
- tangentStart: { x: tx1 - x1, y: ty1 - y1 },
- tangentEnd: { x: tx2 - x2, y: ty2 - y2 }
- })
- if (currentSubPath) {
- currentSubPath.segmentIndices.push(segIdx)
- }
- }
-
- function addLine(x1: number, y1: number, x2: number, y2: number): void {
- addSegment(x1, y1, x2, y2, x1, y1, x2, y2)
- }
-
- function addCubic(
- x1: number,
- y1: number,
- cp1x: number,
- cp1y: number,
- cp2x: number,
- cp2y: number,
- x2: number,
- y2: number
- ): void {
- addSegment(x1, y1, x2, y2, cp1x, cp1y, cp2x, cp2y)
- }
-
- const normalized = svgpath(d).abs().unshort().unarc()
-
- normalized.iterate((seg) => {
- const cmd = seg[0]
-
- if (cmd === 'M') {
- cx = seg[1]
- cy = seg[2]
- currentSubPath = {
- startVertexIndex: getOrCreateVertex(cx, cy),
- segmentIndices: [],
- closed: false
- }
- subPaths.push(currentSubPath)
- } else if (cmd === 'L') {
- addLine(cx, cy, seg[1], seg[2])
- cx = seg[1]
- cy = seg[2]
- } else if (cmd === 'H') {
- addLine(cx, cy, seg[1], cy)
- cx = seg[1]
- } else if (cmd === 'V') {
- addLine(cx, cy, cx, seg[1])
- cy = seg[1]
- } else if (cmd === 'C') {
- addCubic(cx, cy, seg[1], seg[2], seg[3], seg[4], seg[5], seg[6])
- cx = seg[5]
- cy = seg[6]
- } else if (cmd === 'Q') {
- const qx = seg[1]
- const qy = seg[2]
- const ex = seg[3]
- const ey = seg[4]
- const cp1x = cx + (2 / 3) * (qx - cx)
- const cp1y = cy + (2 / 3) * (qy - cy)
- const cp2x = ex + (2 / 3) * (qx - ex)
- const cp2y = ey + (2 / 3) * (qy - ey)
- addCubic(cx, cy, cp1x, cp1y, cp2x, cp2y, ex, ey)
- cx = ex
- cy = ey
- } else if (cmd === 'Z' || cmd === 'z') {
- if (currentSubPath) {
- const startVert = vertices[currentSubPath.startVertexIndex]
- if (Math.abs(cx - startVert.x) > 0.001 || Math.abs(cy - startVert.y) > 0.001) {
- addLine(cx, cy, startVert.x, startVert.y)
- }
- currentSubPath.closed = true
- cx = startVert.x
- cy = startVert.y
- }
- }
- })
-
- const regions: VectorRegion[] = []
- const closedPaths = subPaths.filter((sp) => sp.closed && sp.segmentIndices.length > 0)
- if (closedPaths.length > 0) {
- regions.push({
- windingRule,
- loops: closedPaths.map((sp) => sp.segmentIndices)
- })
- }
-
- return { vertices, segments, regions }
-}
+export { parseSVGPath } from '@open-pencil/scene-graph/parse-path'
diff --git a/packages/core/src/io/formats/svg/paths.ts b/packages/core/src/io/formats/svg/paths.ts
index f0b4e1b02..a2a0079df 100644
--- a/packages/core/src/io/formats/svg/paths.ts
+++ b/packages/core/src/io/formats/svg/paths.ts
@@ -1,6 +1,12 @@
+import type {
+ SceneNode,
+ VectorNetwork,
+ VectorSegment,
+ VectorVertex
+} from '@open-pencil/scene-graph'
+import { polygonVertices } from '@open-pencil/scene-graph/geometry'
+
import { nodeHasRadius } from '#core/canvas/shapes'
-import { polygonVertices } from '#core/geometry'
-import type { SceneNode, VectorNetwork, VectorSegment, VectorVertex } from '#core/scene-graph'
const CMD_CLOSE = 0
const CMD_MOVE_TO = 1
diff --git a/packages/core/src/io/registry.ts b/packages/core/src/io/registry.ts
index e0863bba3..2c1135cd2 100644
--- a/packages/core/src/io/registry.ts
+++ b/packages/core/src/io/registry.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import type { ExportRequest, IOContext, IOFormatAdapter, ReadDocumentInput } from './types'
diff --git a/packages/core/src/io/subgraph.ts b/packages/core/src/io/subgraph.ts
index c9f59c44e..b57ed0a81 100644
--- a/packages/core/src/io/subgraph.ts
+++ b/packages/core/src/io/subgraph.ts
@@ -1,4 +1,4 @@
-import { SceneGraph } from '#core/scene-graph'
+import { SceneGraph } from '@open-pencil/scene-graph'
import type { ExportTarget } from './types'
diff --git a/packages/core/src/io/types.ts b/packages/core/src/io/types.ts
index 2bda9d279..38934a493 100644
--- a/packages/core/src/io/types.ts
+++ b/packages/core/src/io/types.ts
@@ -1,9 +1,10 @@
import type { CanvasKit } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas'
import type { RenderColorSpace } from '#core/color/management'
import type { JSXFormat } from '#core/design-jsx'
-import type { SceneGraph } from '#core/scene-graph'
import type { RasterExportFormat } from './formats/raster'
diff --git a/packages/core/src/kiwi/fig/import.ts b/packages/core/src/kiwi/fig/import.ts
index deaf6f423..8650eba65 100644
--- a/packages/core/src/kiwi/fig/import.ts
+++ b/packages/core/src/kiwi/fig/import.ts
@@ -1,6 +1,8 @@
import { isNotNil } from 'es-toolkit/predicate'
import type { NodeChange, VariableDataValuesEntry, Color, GUID } from '@open-pencil/kiwi/fig/codec'
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type { VariableType, VariableValue } from '@open-pencil/scene-graph'
import { BLACK } from '#core/constants'
import { populateAndApplyOverrides } from '#core/kiwi/fig/instance-overrides'
@@ -14,8 +16,6 @@ import {
VARIABLE_BINDING_FIELDS_INVERSE
} from '#core/kiwi/fig/node-change/convert'
import { applyStyleRefsToFields } from '#core/kiwi/fig/node-change/style-refs'
-import { SceneGraph } from '#core/scene-graph'
-import type { VariableType, VariableValue } from '#core/scene-graph'
type AssetRef = { key: string; version?: string }
type AliasRef = { guid?: GUID; assetRef?: AssetRef }
diff --git a/packages/core/src/kiwi/fig/instance-overrides/component-props/apply.ts b/packages/core/src/kiwi/fig/instance-overrides/component-props/apply.ts
index effd6384f..9bfd984e5 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/component-props/apply.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/component-props/apply.ts
@@ -1,3 +1,5 @@
+import { copyFills, copyStyleRuns } from '@open-pencil/scene-graph/copy'
+
import { applyOverridePatch, type OverridePatch } from '#core/kiwi/fig/instance-overrides/patches'
import { getComponentRoot } from '#core/kiwi/fig/instance-overrides/resolve'
import type {
@@ -6,7 +8,6 @@ import type {
OverrideContext
} from '#core/kiwi/fig/instance-overrides/types'
import { guidToString } from '#core/kiwi/fig/node-change/convert'
-import { copyFills, copyStyleRuns } from '#core/scene-graph/copy'
import { propTextCharacters } from './values'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/component-props/assignments.ts b/packages/core/src/kiwi/fig/instance-overrides/component-props/assignments.ts
index 16d9d1372..5b59c6858 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/component-props/assignments.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/component-props/assignments.ts
@@ -1,3 +1,5 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { buildCloneIndex, instanceAndClones } from '#core/kiwi/fig/instance-overrides/clone-index'
import { applyComponentPropRef } from '#core/kiwi/fig/instance-overrides/component-props/apply'
import {
@@ -13,7 +15,6 @@ import type {
ComponentPropValue,
OverrideContext
} from '#core/kiwi/fig/instance-overrides/types'
-import type { SceneNode } from '#core/scene-graph'
function applyChildPropRefs(
ctx: OverrideContext,
diff --git a/packages/core/src/kiwi/fig/instance-overrides/constraints.ts b/packages/core/src/kiwi/fig/instance-overrides/constraints.ts
index 4f1cb7bcb..43703baaa 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/constraints.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/constraints.ts
@@ -1,5 +1,5 @@
-import type { GeometryPath, SceneGraph, SceneNode, VectorNetwork } from '#core/scene-graph'
-import { copyGeometryPaths } from '#core/scene-graph/copy'
+import type { GeometryPath, SceneGraph, SceneNode, VectorNetwork } from '@open-pencil/scene-graph'
+import { copyGeometryPaths } from '@open-pencil/scene-graph/copy'
import { buildClonesMap } from './sync'
import type { OverrideContext } from './types'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/geometry.ts b/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/geometry.ts
index 8f0dea145..6d2d80a6b 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/geometry.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/geometry.ts
@@ -1,6 +1,7 @@
+import type { GeometryPath, SceneNode } from '@open-pencil/scene-graph'
+
import type { DerivedSymbolOverride } from '#core/kiwi/fig/instance-overrides/types'
import { resolveGeometryPaths } from '#core/kiwi/fig/node-change/convert'
-import type { GeometryPath, SceneNode } from '#core/scene-graph'
function scaleGeometryBlobs(geom: GeometryPath[], sx: number, sy: number): GeometryPath[] {
if (sx === 1 && sy === 1) return geom
diff --git a/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/layout.ts b/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/layout.ts
index a046c7c80..f991eabb6 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/layout.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/layout.ts
@@ -1,10 +1,11 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type {
DerivedSymbolOverride,
OverrideContext
} from '#core/kiwi/fig/instance-overrides/types'
import { convertLetterSpacing, convertLineHeight } from '#core/kiwi/fig/node-change/convert'
import { convertFigmaDerivedTextGlyphs } from '#core/kiwi/fig/node-change/derived-text-glyphs'
-import type { SceneNode } from '#core/scene-graph'
import { resolveDsdGeometry } from './geometry'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/propagate.ts b/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/propagate.ts
index a8e1830a2..9dd66836e 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/propagate.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/derived-symbol-data/propagate.ts
@@ -1,7 +1,8 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { copyGeometryPaths } from '@open-pencil/scene-graph/copy'
+
import { buildClonesMap } from '#core/kiwi/fig/instance-overrides/sync'
import type { OverrideContext } from '#core/kiwi/fig/instance-overrides/types'
-import type { SceneNode } from '#core/scene-graph'
-import { copyGeometryPaths } from '#core/scene-graph/copy'
function buildCloneUpdates(
ctx: OverrideContext,
diff --git a/packages/core/src/kiwi/fig/instance-overrides/index.ts b/packages/core/src/kiwi/fig/instance-overrides/index.ts
index 8c853d09f..df3dde039 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/index.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/index.ts
@@ -10,10 +10,11 @@ export type {
SymbolOverride
} from './types'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import { copyFills, copyStyleRuns } from '@open-pencil/scene-graph/copy'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
+
import { guidToString } from '#core/kiwi/fig/node-change/convert'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import { copyFills, copyStyleRuns } from '#core/scene-graph/copy'
-import type { JsonObject } from '#core/types'
import { applyComponentProperties } from './component-props'
import { applyConstraintScaling } from './constraints'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/patches/apply.ts b/packages/core/src/kiwi/fig/instance-overrides/patches/apply.ts
index 8a468ae89..16758414d 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/patches/apply.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/patches/apply.ts
@@ -1,6 +1,7 @@
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { repopulateInstance } from '#core/kiwi/fig/instance-overrides/resolve'
import type { OverrideContext } from '#core/kiwi/fig/instance-overrides/types'
-import type { SceneNode } from '#core/scene-graph'
import { protectField, protectPatchProps } from './protection'
import type { OverridePatch } from './types'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/patches/protection.ts b/packages/core/src/kiwi/fig/instance-overrides/patches/protection.ts
index 808c8ba39..098d18d2e 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/patches/protection.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/patches/protection.ts
@@ -1,4 +1,4 @@
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
export type ProtectedField =
| 'text'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/patches/types.ts b/packages/core/src/kiwi/fig/instance-overrides/patches/types.ts
index 56eb37915..ee54d3fbb 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/patches/types.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/patches/types.ts
@@ -1,4 +1,4 @@
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
export type OverridePatchSource = 'symbol-override' | 'component-prop' | 'derived-symbol-data'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/populate.ts b/packages/core/src/kiwi/fig/instance-overrides/populate.ts
index 31a1189c4..0f227b078 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/populate.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/populate.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
/**
* Populate empty INSTANCE nodes from their source components.
diff --git a/packages/core/src/kiwi/fig/instance-overrides/resolve.ts b/packages/core/src/kiwi/fig/instance-overrides/resolve.ts
index 41054df86..f89c36d5f 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/resolve.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/resolve.ts
@@ -1,8 +1,8 @@
import type { GUID } from '@open-pencil/kiwi/fig/codec'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { copyStrokes } from '@open-pencil/scene-graph/copy'
import { guidToString } from '#core/kiwi/fig/node-change/convert'
-import type { SceneNode } from '#core/scene-graph'
-import { copyStrokes } from '#core/scene-graph/copy'
import type { InstanceNodeChange, OverrideContext } from './types'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/symbol/props.ts b/packages/core/src/kiwi/fig/instance-overrides/symbol/props.ts
index e8d16347b..8b700fb52 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/symbol/props.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/symbol/props.ts
@@ -1,4 +1,6 @@
import type { NodeChange, Paint, Effect as KiwiEffect } from '@open-pencil/kiwi/fig/codec'
+import type { SceneNode, ArcData, TextAutoResize } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import {
convertFills,
@@ -14,9 +16,7 @@ import {
convertStrokes,
convertEffects
} from '#core/kiwi/fig/node-change/convert'
-import type { SceneNode, ArcData, TextAutoResize } from '#core/scene-graph'
import { styleToWeight } from '#core/text/fonts'
-import type { Vector } from '#core/types'
function applyOverridePaints(ov: Record<string, unknown>, updates: Partial<SceneNode>): void {
if (ov.textData != null) {
diff --git a/packages/core/src/kiwi/fig/instance-overrides/sync/clones.ts b/packages/core/src/kiwi/fig/instance-overrides/sync/clones.ts
index 38fe218bf..aff320919 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/sync/clones.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/sync/clones.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import type { ProtectionMap } from '#core/kiwi/fig/instance-overrides/patches'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
import { syncNodeProps } from './fields'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/sync/fields.ts b/packages/core/src/kiwi/fig/instance-overrides/sync/fields.ts
index 473651dca..3b8eb0d03 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/sync/fields.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/sync/fields.ts
@@ -1,7 +1,8 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import { copyFills, copyStrokes, copyEffects, copyStyleRuns } from '@open-pencil/scene-graph/copy'
+
import type { ProtectionMap, ProtectedField } from '#core/kiwi/fig/instance-overrides/patches'
import { isFieldProtected } from '#core/kiwi/fig/instance-overrides/patches'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import { copyFills, copyStrokes, copyEffects, copyStyleRuns } from '#core/scene-graph/copy'
function canSync(
protections: ProtectionMap | undefined,
diff --git a/packages/core/src/kiwi/fig/instance-overrides/sync/propagate.ts b/packages/core/src/kiwi/fig/instance-overrides/sync/propagate.ts
index 3c7782e1a..e69d5768f 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/sync/propagate.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/sync/propagate.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import type { ProtectionMap } from '#core/kiwi/fig/instance-overrides/patches'
-import type { SceneGraph } from '#core/scene-graph'
import { buildClonesMap, syncChildrenDeep } from './clones'
import { syncNodeProps } from './fields'
diff --git a/packages/core/src/kiwi/fig/instance-overrides/types.ts b/packages/core/src/kiwi/fig/instance-overrides/types.ts
index 7021487fa..31addf80d 100644
--- a/packages/core/src/kiwi/fig/instance-overrides/types.ts
+++ b/packages/core/src/kiwi/fig/instance-overrides/types.ts
@@ -1,7 +1,6 @@
import type { GUID, NodeChange, VariableConsumptionEntry } from '@open-pencil/kiwi/fig/codec'
-
-import type { SceneGraph } from '#core/scene-graph'
-import type { Matrix, Vector } from '#core/types'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import type { Matrix, Vector } from '@open-pencil/scene-graph/primitives'
import type { ProtectionMap } from './patches'
diff --git a/packages/core/src/kiwi/fig/lazy-import.ts b/packages/core/src/kiwi/fig/lazy-import.ts
index 406d62172..d9b252a19 100644
--- a/packages/core/src/kiwi/fig/lazy-import.ts
+++ b/packages/core/src/kiwi/fig/lazy-import.ts
@@ -1,6 +1,7 @@
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { populateAndApplyOverrides } from '#core/kiwi/fig/instance-overrides'
import type { InstanceNodeChange } from '#core/kiwi/fig/instance-overrides'
-import type { SceneGraph } from '#core/scene-graph'
export interface LazyFigImportContext {
changeMap: Map<string, InstanceNodeChange>
diff --git a/packages/core/src/kiwi/fig/node-change/convert.ts b/packages/core/src/kiwi/fig/node-change/convert.ts
index 3496b9b02..69fd425ed 100644
--- a/packages/core/src/kiwi/fig/node-change/convert.ts
+++ b/packages/core/src/kiwi/fig/node-change/convert.ts
@@ -1,8 +1,8 @@
import { guidToString } from '@open-pencil/kiwi/fig/guid'
+import { parseVariantName } from '@open-pencil/scene-graph/variant-name'
/* eslint-disable max-lines -- kiwi↔scene conversion helpers are tightly coupled */
import { DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT } from '#core/constants'
-import { parseVariantName } from '#core/scene-graph/variant-name'
import { styleToWeight } from '#core/text/fonts'
import { convertEffects, convertFills, convertStrokes } from './paint'
@@ -28,7 +28,6 @@ import { resolveGeometryPaths, resolveVectorNetwork } from './vector-geometry'
export { resolveGeometryPaths } from './vector-geometry'
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
-
import type {
SceneNode,
NodeType,
@@ -50,8 +49,8 @@ import type {
ComponentPropertyType,
SymbolLink,
VariantPropSpec
-} from '#core/scene-graph'
-import type { GUID } from '#core/types'
+} from '@open-pencil/scene-graph'
+import type { GUID } from '@open-pencil/scene-graph/primitives'
export { guidToString, stringToGuid } from '@open-pencil/kiwi/fig/guid'
diff --git a/packages/core/src/kiwi/fig/node-change/derived-text-glyphs.ts b/packages/core/src/kiwi/fig/node-change/derived-text-glyphs.ts
index 0c447e40d..7a55bc48f 100644
--- a/packages/core/src/kiwi/fig/node-change/derived-text-glyphs.ts
+++ b/packages/core/src/kiwi/fig/node-change/derived-text-glyphs.ts
@@ -1,6 +1,5 @@
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
-
-import type { FigmaDerivedTextGlyph } from '#core/scene-graph'
+import type { FigmaDerivedTextGlyph } from '@open-pencil/scene-graph'
export function convertFigmaDerivedTextGlyphs(
derivedTextData: NodeChange['derivedTextData'],
diff --git a/packages/core/src/kiwi/fig/node-change/export-node.ts b/packages/core/src/kiwi/fig/node-change/export-node.ts
index dc1689572..64089f046 100644
--- a/packages/core/src/kiwi/fig/node-change/export-node.ts
+++ b/packages/core/src/kiwi/fig/node-change/export-node.ts
@@ -1,10 +1,10 @@
import type { NodeChange, Paint } from '@open-pencil/kiwi/fig/codec'
import { stringToGuid } from '@open-pencil/kiwi/fig/guid'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color, GUID, Matrix, Vector } from '@open-pencil/scene-graph/primitives'
/* eslint-disable max-lines */
import { bytesToHex } from '#core/bytes/hex'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Color, GUID, Matrix, Vector } from '#core/types'
import {
applyExportSettingsPluginData,
diff --git a/packages/core/src/kiwi/fig/node-change/font/digests.ts b/packages/core/src/kiwi/fig/node-change/font/digests.ts
index 406b47566..f5b57daf1 100644
--- a/packages/core/src/kiwi/fig/node-change/font/digests.ts
+++ b/packages/core/src/kiwi/fig/node-change/font/digests.ts
@@ -1,4 +1,5 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { fontManager, weightToStyle } from '#core/text/fonts'
const fontDigestCache = new Map<string, Uint8Array>()
diff --git a/packages/core/src/kiwi/fig/node-change/font/features.ts b/packages/core/src/kiwi/fig/node-change/font/features.ts
index d02ce35da..cffb1db09 100644
--- a/packages/core/src/kiwi/fig/node-change/font/features.ts
+++ b/packages/core/src/kiwi/fig/node-change/font/features.ts
@@ -1,6 +1,5 @@
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
-
-import type { FontFeature } from '#core/scene-graph'
+import type { FontFeature } from '@open-pencil/scene-graph'
const BOOLEAN_FEATURES = [
['fontVariantCommonLigatures', 'LIGA'],
diff --git a/packages/core/src/kiwi/fig/node-change/font/variations.ts b/packages/core/src/kiwi/fig/node-change/font/variations.ts
index 858abd227..76671c40b 100644
--- a/packages/core/src/kiwi/fig/node-change/font/variations.ts
+++ b/packages/core/src/kiwi/fig/node-change/font/variations.ts
@@ -1,6 +1,5 @@
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
-
-import type { FontVariation } from '#core/scene-graph'
+import type { FontVariation } from '@open-pencil/scene-graph'
export function figmaAxisTagToString(axisTag: number): string {
return String.fromCharCode(
diff --git a/packages/core/src/kiwi/fig/node-change/paint.ts b/packages/core/src/kiwi/fig/node-change/paint.ts
index e1df2c97b..e0576b9c0 100644
--- a/packages/core/src/kiwi/fig/node-change/paint.ts
+++ b/packages/core/src/kiwi/fig/node-change/paint.ts
@@ -1,7 +1,5 @@
import type { Paint, Effect as KiwiEffect } from '@open-pencil/kiwi/fig/codec'
import { guidToString } from '@open-pencil/kiwi/fig/guid'
-
-import { normalizeColor } from '#core/color'
import type {
Fill,
FillType,
@@ -12,8 +10,10 @@ import type {
GradientTransform,
StrokeCap,
StrokeJoin
-} from '#core/scene-graph'
-import type { Color, Matrix } from '#core/types'
+} from '@open-pencil/scene-graph'
+import type { Color, Matrix } from '@open-pencil/scene-graph/primitives'
+
+import { normalizeColor } from '#core/color'
const convertColor = normalizeColor
diff --git a/packages/core/src/kiwi/fig/node-change/serialize.ts b/packages/core/src/kiwi/fig/node-change/serialize.ts
index 55bda5cb0..68e174f68 100644
--- a/packages/core/src/kiwi/fig/node-change/serialize.ts
+++ b/packages/core/src/kiwi/fig/node-change/serialize.ts
@@ -14,9 +14,8 @@ export {
export { buildFontDigestMap } from './font/digests'
import type { NodeChange, Paint, VariableConsumptionEntry } from '@open-pencil/kiwi/fig/codec'
-
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Color, GUID, JsonObject, Matrix } from '#core/types'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color, GUID, JsonObject, Matrix } from '@open-pencil/scene-graph/primitives'
import { guidToString, stringToGuid, VARIABLE_BINDING_FIELDS } from './convert'
import {
diff --git a/packages/core/src/kiwi/fig/node-change/style-runs.ts b/packages/core/src/kiwi/fig/node-change/style-runs.ts
index 8dcc7fc0e..8aa27c649 100644
--- a/packages/core/src/kiwi/fig/node-change/style-runs.ts
+++ b/packages/core/src/kiwi/fig/node-change/style-runs.ts
@@ -1,6 +1,6 @@
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
+import type { CharacterStyleOverride, StyleRun } from '@open-pencil/scene-graph'
-import type { CharacterStyleOverride, StyleRun } from '#core/scene-graph'
import { styleToWeight } from '#core/text/fonts'
import { convertFontFeatures } from './font/features'
diff --git a/packages/core/src/kiwi/fig/node-change/text-data-export.ts b/packages/core/src/kiwi/fig/node-change/text-data-export.ts
index fbee1fe08..820921cca 100644
--- a/packages/core/src/kiwi/fig/node-change/text-data-export.ts
+++ b/packages/core/src/kiwi/fig/node-change/text-data-export.ts
@@ -1,6 +1,6 @@
import type { NodeChange, Paint } from '@open-pencil/kiwi/fig/codec'
+import type { CharacterStyleOverride, SceneNode } from '@open-pencil/scene-graph'
-import type { CharacterStyleOverride, SceneNode } from '#core/scene-graph'
import { normalizeFontFamily, weightToFigmaStyle } from '#core/text/fonts'
import { applyFontFeaturesToKiwi } from './font/features'
diff --git a/packages/core/src/kiwi/fig/node-change/text-values.ts b/packages/core/src/kiwi/fig/node-change/text-values.ts
index b14ffb383..3a7fdfda7 100644
--- a/packages/core/src/kiwi/fig/node-change/text-values.ts
+++ b/packages/core/src/kiwi/fig/node-change/text-values.ts
@@ -1,4 +1,4 @@
-import type { TextDecoration } from '#core/scene-graph'
+import type { TextDecoration } from '@open-pencil/scene-graph'
export function mapTextDecoration(d?: string): TextDecoration {
switch (d) {
diff --git a/packages/core/src/kiwi/fig/node-change/vector-geometry.ts b/packages/core/src/kiwi/fig/node-change/vector-geometry.ts
index 3e207c784..f9956374a 100644
--- a/packages/core/src/kiwi/fig/node-change/vector-geometry.ts
+++ b/packages/core/src/kiwi/fig/node-change/vector-geometry.ts
@@ -1,7 +1,7 @@
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
+import type { GeometryPath, VectorNetwork, WindingRule } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
-import type { GeometryPath, VectorNetwork, WindingRule } from '#core/scene-graph'
-import type { Vector } from '#core/types'
import { decodeVectorNetworkBlob } from '#core/vector'
export function resolveVectorNetwork(nc: NodeChange, blobs: Uint8Array[]): VectorNetwork | null {
diff --git a/packages/core/src/kiwi/fig/parse/transfer.ts b/packages/core/src/kiwi/fig/parse/transfer.ts
index e1c8c63eb..054e8f0b6 100644
--- a/packages/core/src/kiwi/fig/parse/transfer.ts
+++ b/packages/core/src/kiwi/fig/parse/transfer.ts
@@ -1,7 +1,13 @@
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type {
+ SceneNode,
+ Variable,
+ VariableCollection,
+ DocumentColorSpace
+} from '@open-pencil/scene-graph'
+
import type { InstanceNodeChange } from '#core/kiwi/fig/instance-overrides'
import { getLazyFigImportContext, setLazyFigImportContext } from '#core/kiwi/fig/lazy-import'
-import { SceneGraph } from '#core/scene-graph'
-import type { SceneNode, Variable, VariableCollection, DocumentColorSpace } from '#core/scene-graph'
export interface SerializedLazyFigImportContext {
changeMap: Array<[string, InstanceNodeChange]>
diff --git a/packages/core/src/layout.ts b/packages/core/src/layout.ts
index c4d6ddbdb..a688ea424 100644
--- a/packages/core/src/layout.ts
+++ b/packages/core/src/layout.ts
@@ -20,6 +20,8 @@ export {
setTextMeasurer,
type TextMeasurer
} from './layout/text-measurement'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { estimateTextSize, getTextMeasurer } from './layout/text-measurement'
import {
applyMinMaxConstraints,
@@ -31,7 +33,6 @@ import {
mapGridTrack,
mapJustify
} from './layout/yoga-helpers'
-import type { SceneGraph, SceneNode } from './scene-graph'
export function computeLayout(graph: SceneGraph, frameId: string): void {
const frame = graph.getNode(frameId)
diff --git a/packages/core/src/layout/apply.ts b/packages/core/src/layout/apply.ts
index 99a6965a6..0c3806b8f 100644
--- a/packages/core/src/layout/apply.ts
+++ b/packages/core/src/layout/apply.ts
@@ -1,6 +1,6 @@
import type { Node as YogaNode } from 'yoga-layout'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export type ComputeLayoutFn = (graph: SceneGraph, frameId: string) => void
diff --git a/packages/core/src/layout/grid.ts b/packages/core/src/layout/grid.ts
index 863aecbec..7bc53d1f2 100644
--- a/packages/core/src/layout/grid.ts
+++ b/packages/core/src/layout/grid.ts
@@ -1,6 +1,7 @@
import { Direction, Display, Gutter, Edge, type Node as YogaNode } from 'yoga-layout'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { resolveNodeLayoutDirection } from '#core/text/direction'
import { configureAbsoluteChild, createYogaNode, mapGridTrack } from './yoga-helpers'
diff --git a/packages/core/src/layout/text-measurement.ts b/packages/core/src/layout/text-measurement.ts
index 1a9ab6a64..aba5bb991 100644
--- a/packages/core/src/layout/text-measurement.ts
+++ b/packages/core/src/layout/text-measurement.ts
@@ -1,4 +1,5 @@
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { weightToStyle } from '#core/text/fonts'
import { measureTextWithOpenType } from '#core/text/opentype'
diff --git a/packages/core/src/layout/yoga-helpers.ts b/packages/core/src/layout/yoga-helpers.ts
index 0b8f6e06f..7d6fa5e0f 100644
--- a/packages/core/src/layout/yoga-helpers.ts
+++ b/packages/core/src/layout/yoga-helpers.ts
@@ -7,7 +7,7 @@ import Yoga, {
type Node as YogaNode
} from 'yoga-layout'
-import type { GridTrack, SceneNode } from '#core/scene-graph'
+import type { GridTrack, SceneNode } from '@open-pencil/scene-graph'
const yogaConfig = Yoga.Config.create()
yogaConfig.setPointScaleFactor(0)
diff --git a/packages/core/src/lint/linter.ts b/packages/core/src/lint/linter.ts
index 989162d04..3aaef2439 100644
--- a/packages/core/src/lint/linter.ts
+++ b/packages/core/src/lint/linter.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import { presets } from './presets'
import { allRules } from './rules'
diff --git a/packages/core/src/rpc/analyze-commands.ts b/packages/core/src/rpc/analyze-commands.ts
index 1a9439860..c5708d7ce 100644
--- a/packages/core/src/rpc/analyze-commands.ts
+++ b/packages/core/src/rpc/analyze-commands.ts
@@ -1,14 +1,15 @@
import { orderBy, sortBy } from 'es-toolkit/array'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { colorToHex, colorDistance as colorDist } from '#core/color'
import type { ColorUsageEntry } from '#core/color/analysis'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
import {
computeOverlaps,
type AnalyzeOverlapsArgs,
type AnalyzeOverlapsResult
} from '#core/tools/analyze/overlaps'
-import type { Color } from '#core/types'
import type { RpcCommand } from './types'
diff --git a/packages/core/src/rpc/commands.ts b/packages/core/src/rpc/commands.ts
index fa9c1f741..59a77d642 100644
--- a/packages/core/src/rpc/commands.ts
+++ b/packages/core/src/rpc/commands.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import {
analyzeClustersCommand,
diff --git a/packages/core/src/rpc/read-commands.ts b/packages/core/src/rpc/read-commands.ts
index bdb790059..6a79325e9 100644
--- a/packages/core/src/rpc/read-commands.ts
+++ b/packages/core/src/rpc/read-commands.ts
@@ -1,4 +1,5 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { queryByXPath } from '#core/xpath'
import type { RpcCommand } from './types'
diff --git a/packages/core/src/rpc/types.ts b/packages/core/src/rpc/types.ts
index 99814523d..335f9ef36 100644
--- a/packages/core/src/rpc/types.ts
+++ b/packages/core/src/rpc/types.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '#core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
export interface RpcCommand<A = unknown, R = unknown> {
name: string
diff --git a/packages/core/src/rpc/variables-command.ts b/packages/core/src/rpc/variables-command.ts
index 7e5873aad..86ebb2159 100644
--- a/packages/core/src/rpc/variables-command.ts
+++ b/packages/core/src/rpc/variables-command.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph, Variable } from '@open-pencil/scene-graph'
+
import { colorToHex } from '#core/color'
-import type { SceneGraph, Variable } from '#core/scene-graph'
import type { RpcCommand } from './types'
diff --git a/packages/core/src/text/derived-text/clipboard.ts b/packages/core/src/text/derived-text/clipboard.ts
index b5c84ed4f..9088c368d 100644
--- a/packages/core/src/text/derived-text/clipboard.ts
+++ b/packages/core/src/text/derived-text/clipboard.ts
@@ -1,9 +1,9 @@
import { prepareWithSegments, layoutWithLines } from '@chenglou/pretext'
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { encodePathCommandsBlob } from '#core/kiwi/fig/node-change/path-commands'
-import type { SceneNode } from '#core/scene-graph'
import { normalizeFontFamily, weightToFigmaStyle, weightToStyle } from '#core/text/fonts'
import { type GlyphOutlineMetrics, getGlyphOutlineMetricsSync } from '#core/text/opentype'
diff --git a/packages/core/src/text/derived-text/data.ts b/packages/core/src/text/derived-text/data.ts
index 78c914f06..a6f8e44a3 100644
--- a/packages/core/src/text/derived-text/data.ts
+++ b/packages/core/src/text/derived-text/data.ts
@@ -1,6 +1,5 @@
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
-
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
interface DerivedTextDataOptions {
node: SceneNode
diff --git a/packages/core/src/text/direction.ts b/packages/core/src/text/direction.ts
index d1ec1d087..86e603dd8 100644
--- a/packages/core/src/text/direction.ts
+++ b/packages/core/src/text/direction.ts
@@ -1,4 +1,4 @@
-import type { LayoutDirection, SceneNode, TextDirection } from '#core/scene-graph'
+import type { LayoutDirection, SceneNode, TextDirection } from '@open-pencil/scene-graph'
const RTL_CHAR_RE =
/\p{Script=Arabic}|\p{Script=Hebrew}|\p{Script=Syriac}|\p{Script=Thaana}|\p{Script=Nko}|\p{Script=Adlam}/u
diff --git a/packages/core/src/text/editor.ts b/packages/core/src/text/editor.ts
index 10d11eb50..062c6db66 100644
--- a/packages/core/src/text/editor.ts
+++ b/packages/core/src/text/editor.ts
@@ -1,8 +1,9 @@
import type { CanvasKit, Paragraph } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
+
import type { SkiaRenderer } from '#core/canvas'
-import type { SceneNode } from '#core/scene-graph'
-import type { Rect } from '#core/types'
import { resolveNodeTextDirection } from './direction'
diff --git a/packages/core/src/text/fonts.ts b/packages/core/src/text/fonts.ts
index cada408ee..16ba5b08c 100644
--- a/packages/core/src/text/fonts.ts
+++ b/packages/core/src/text/fonts.ts
@@ -1,8 +1,9 @@
import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'
import { uniq } from 'es-toolkit/array'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import { DEFAULT_FONT_FAMILY, IS_BROWSER, GOOGLE_FONTS_API_KEY } from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
import { fontFaceRenderFamily, parseFontStyle } from '#core/text/face'
import { fontFallbackEntry } from '#core/text/fallbacks'
import type { FontFallbackScript } from '#core/text/fallbacks'
diff --git a/packages/core/src/text/outlines.ts b/packages/core/src/text/outlines.ts
index aed765e6b..690c5ca27 100644
--- a/packages/core/src/text/outlines.ts
+++ b/packages/core/src/text/outlines.ts
@@ -1,6 +1,7 @@
import { prepareWithSegments, layoutWithLines } from '@chenglou/pretext'
-import type { CharacterStyleOverride, SceneNode } from '#core/scene-graph'
+import type { CharacterStyleOverride, SceneNode } from '@open-pencil/scene-graph'
+
import { fontManager, weightToStyle } from '#core/text/fonts'
import {
fontHasGlyphSync,
diff --git a/packages/core/src/text/style-runs.ts b/packages/core/src/text/style-runs.ts
index 975d62605..87bc5ee6b 100644
--- a/packages/core/src/text/style-runs.ts
+++ b/packages/core/src/text/style-runs.ts
@@ -1,6 +1,6 @@
import { omit } from 'es-toolkit/object'
-import type { CharacterStyleOverride, StyleRun, TextDecoration } from '#core/scene-graph'
+import type { CharacterStyleOverride, StyleRun, TextDecoration } from '@open-pencil/scene-graph'
export function getStyleAt(runs: StyleRun[], index: number): CharacterStyleOverride {
for (const run of runs) {
diff --git a/packages/core/src/tools/ai-adapter.ts b/packages/core/src/tools/ai-adapter.ts
index ef639e25f..23121443e 100644
--- a/packages/core/src/tools/ai-adapter.ts
+++ b/packages/core/src/tools/ai-adapter.ts
@@ -9,8 +9,9 @@ import type { valibotSchema as createValibotSchema } from '@ai-sdk/valibot'
import type { ToolSet, tool as createTool } from 'ai'
import type * as valibot from 'valibot'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
+
import type { FigmaAPI } from '#core/figma-api'
-import type { JsonObject } from '#core/types'
import type { ToolDef, ParamDef, ParamType } from './schema'
diff --git a/packages/core/src/tools/analyze/colors.ts b/packages/core/src/tools/analyze/colors.ts
index 3e51e21ef..db6cf80a9 100644
--- a/packages/core/src/tools/analyze/colors.ts
+++ b/packages/core/src/tools/analyze/colors.ts
@@ -1,9 +1,10 @@
import { orderBy } from 'es-toolkit/array'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { colorDistance, colorToHex } from '#core/color'
import type { ColorUsageEntry } from '#core/color/analysis'
import { defineTool } from '#core/tools/schema'
-import type { Color } from '#core/types'
type ColorEntry = ColorUsageEntry
diff --git a/packages/core/src/tools/analyze/diff.ts b/packages/core/src/tools/analyze/diff.ts
index e82a75f91..4db862eb9 100644
--- a/packages/core/src/tools/analyze/diff.ts
+++ b/packages/core/src/tools/analyze/diff.ts
@@ -1,8 +1,9 @@
import { createTwoFilesPatch } from 'diff'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { colorToHex, parseColor } from '#core/color'
import type { FigmaAPI } from '#core/figma-api'
-import type { SceneNode } from '#core/scene-graph'
import { defineTool } from '#core/tools/schema'
function serializePaintProps(raw: SceneNode, lines: string[]): void {
diff --git a/packages/core/src/tools/codegen/component-map.ts b/packages/core/src/tools/codegen/component-map.ts
index 04e259d1c..2ec934578 100644
--- a/packages/core/src/tools/codegen/component-map.ts
+++ b/packages/core/src/tools/codegen/component-map.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import type { FigmaAPI } from '#core/figma-api'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
import { defineTool } from '#core/tools/schema'
interface ComponentInfo {
diff --git a/packages/core/src/tools/codegen/tokens.ts b/packages/core/src/tools/codegen/tokens.ts
index 036d9e487..0ff7641d6 100644
--- a/packages/core/src/tools/codegen/tokens.ts
+++ b/packages/core/src/tools/codegen/tokens.ts
@@ -1,7 +1,8 @@
+import type { Variable, VariableCollection, VariableValue } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { colorToHex } from '#core/color'
-import type { Variable, VariableCollection, VariableValue } from '#core/scene-graph'
import { defineTool } from '#core/tools/schema'
-import type { Color } from '#core/types'
function slugify(name: string): string {
return name
diff --git a/packages/core/src/tools/create/svg.ts b/packages/core/src/tools/create/svg.ts
index 0cc5f71ff..9d771b396 100644
--- a/packages/core/src/tools/create/svg.ts
+++ b/packages/core/src/tools/create/svg.ts
@@ -1,10 +1,11 @@
+import type { Rect } from '@open-pencil/scene-graph/primitives'
+
import { parseColor } from '#core/color'
import { createPathStroke } from '#core/icons/path-style'
import { extractPaths } from '#core/icons/svg'
import type { IconPathInfo } from '#core/icons/types'
import { parseSVGPath } from '#core/io/formats/svg/parse-path'
import { defineTool } from '#core/tools/schema'
-import type { Rect } from '#core/types'
function parseSvgViewBox(svg: string): Rect | null {
const match = svg.match(/viewBox="([^"]+)"/)
diff --git a/packages/core/src/tools/create/vector.ts b/packages/core/src/tools/create/vector.ts
index ea3de0265..d486e95bc 100644
--- a/packages/core/src/tools/create/vector.ts
+++ b/packages/core/src/tools/create/vector.ts
@@ -1,6 +1,7 @@
+import { normalizeVectorNetwork, validateVectorNetwork } from '@open-pencil/scene-graph'
+import type { VectorNetwork } from '@open-pencil/scene-graph'
+
import { parseColor } from '#core/color'
-import { normalizeVectorNetwork, validateVectorNetwork } from '#core/scene-graph'
-import type { VectorNetwork } from '#core/scene-graph'
import { defineTool, nodeSummary } from '#core/tools/schema'
export const createVector = defineTool({
diff --git a/packages/core/src/tools/describe/issues.ts b/packages/core/src/tools/describe/issues.ts
index 488d4b5ea..74ffbac73 100644
--- a/packages/core/src/tools/describe/issues.ts
+++ b/packages/core/src/tools/describe/issues.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { colorDistance, colorToHex } from '#core/color'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
import { detectLayoutIssues } from './layout-issues'
import { CONTAINER_TYPES, findAncestorBackground, looksLikeButton } from './shared'
diff --git a/packages/core/src/tools/describe/layout-issues.ts b/packages/core/src/tools/describe/layout-issues.ts
index ddf14b617..fcffb1ee6 100644
--- a/packages/core/src/tools/describe/layout-issues.ts
+++ b/packages/core/src/tools/describe/layout-issues.ts
@@ -1,8 +1,9 @@
import { wcagLuminance } from 'culori'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
import { colorToHex } from '#core/color'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Color } from '#core/types'
import type { DescribeIssue } from './issues'
import { CONTAINER_TYPES, findAncestorBackground } from './shared'
diff --git a/packages/core/src/tools/describe/roles.ts b/packages/core/src/tools/describe/roles.ts
index 6ef37be34..d28dc8b75 100644
--- a/packages/core/src/tools/describe/roles.ts
+++ b/packages/core/src/tools/describe/roles.ts
@@ -1,4 +1,4 @@
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { looksLikeButton } from './shared'
diff --git a/packages/core/src/tools/describe/shared.ts b/packages/core/src/tools/describe/shared.ts
index 227c0de1b..bfc1b7305 100644
--- a/packages/core/src/tools/describe/shared.ts
+++ b/packages/core/src/tools/describe/shared.ts
@@ -1,5 +1,5 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Color } from '#core/types'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export const CONTAINER_TYPES = new Set(['FRAME', 'COMPONENT', 'INSTANCE'])
diff --git a/packages/core/src/tools/describe/summaries.ts b/packages/core/src/tools/describe/summaries.ts
index e846126e5..b25c3928f 100644
--- a/packages/core/src/tools/describe/summaries.ts
+++ b/packages/core/src/tools/describe/summaries.ts
@@ -1,5 +1,6 @@
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { colorToHex } from '#core/color'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
function boundFillSuffix(node: SceneNode, fillIndex: number, graph?: SceneGraph): string {
const varId = node.boundVariables[`fills/${fillIndex}/color`]
diff --git a/packages/core/src/tools/describe/tree.ts b/packages/core/src/tools/describe/tree.ts
index 50f78f34c..8a8c26d5e 100644
--- a/packages/core/src/tools/describe/tree.ts
+++ b/packages/core/src/tools/describe/tree.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import { detectIssues } from './issues'
import type { DescribeIssue } from './issues'
diff --git a/packages/core/src/tools/modify/effects.ts b/packages/core/src/tools/modify/effects.ts
index d17471b38..090ad0028 100644
--- a/packages/core/src/tools/modify/effects.ts
+++ b/packages/core/src/tools/modify/effects.ts
@@ -1,6 +1,7 @@
+import type { Effect } from '@open-pencil/scene-graph'
+
import { parseColor } from '#core/color'
import { DEFAULT_SHADOW_COLOR, TRANSPARENT } from '#core/constants'
-import type { Effect } from '#core/scene-graph'
import { defineTool, nodeNotFound } from '#core/tools/schema'
export const setEffects = defineTool({
diff --git a/packages/core/src/tools/modify/layout.ts b/packages/core/src/tools/modify/layout.ts
index 4ecd9d5c2..cd73ea7bb 100644
--- a/packages/core/src/tools/modify/layout.ts
+++ b/packages/core/src/tools/modify/layout.ts
@@ -1,4 +1,5 @@
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { defineTool, nodeNotFound } from '#core/tools/schema'
export const setLayout = defineTool({
diff --git a/packages/core/src/tools/modify/paint.ts b/packages/core/src/tools/modify/paint.ts
index a747e020a..4e6865a29 100644
--- a/packages/core/src/tools/modify/paint.ts
+++ b/packages/core/src/tools/modify/paint.ts
@@ -1,7 +1,8 @@
+import type { Matrix } from '@open-pencil/scene-graph/primitives'
+
import { parseColor } from '#core/color'
import { BLACK } from '#core/constants'
import { defineTool } from '#core/tools/schema'
-import type { Matrix } from '#core/types'
export const setFill = defineTool({
name: 'set_fill',
diff --git a/packages/core/src/tools/modify/text.ts b/packages/core/src/tools/modify/text.ts
index 6ffb3ebe0..e933312ce 100644
--- a/packages/core/src/tools/modify/text.ts
+++ b/packages/core/src/tools/modify/text.ts
@@ -1,5 +1,6 @@
+import type { CharacterStyleOverride, SceneNode } from '@open-pencil/scene-graph'
+
import { parseColor } from '#core/color'
-import type { CharacterStyleOverride, SceneNode } from '#core/scene-graph'
import { styleToWeight } from '#core/text/fonts'
import { applyStyleToRange } from '#core/text/style-runs'
import { defineTool, nodeNotFound } from '#core/tools/schema'
diff --git a/packages/core/src/tools/modify/update.ts b/packages/core/src/tools/modify/update.ts
index e2e1b776c..66b1284eb 100644
--- a/packages/core/src/tools/modify/update.ts
+++ b/packages/core/src/tools/modify/update.ts
@@ -1,4 +1,5 @@
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { defineTool, nodeNotFound } from '#core/tools/schema'
export const updateNode = defineTool({
diff --git a/packages/core/src/tools/read/pages.ts b/packages/core/src/tools/read/pages.ts
index cdd0007a5..2c298a1b9 100644
--- a/packages/core/src/tools/read/pages.ts
+++ b/packages/core/src/tools/read/pages.ts
@@ -1,4 +1,5 @@
-import { computeBounds } from '#core/geometry'
+import { computeBounds } from '@open-pencil/scene-graph/geometry'
+
import { defineTool } from '#core/tools/schema'
export const listPages = defineTool({
diff --git a/packages/core/src/tools/schema.ts b/packages/core/src/tools/schema.ts
index 5bf6990d3..97853f73b 100644
--- a/packages/core/src/tools/schema.ts
+++ b/packages/core/src/tools/schema.ts
@@ -6,8 +6,9 @@
* and MCP (JSON Schema) are generated from these definitions.
*/
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'
-import type { SceneNode } from '#core/scene-graph'
export type ParamType = 'string' | 'number' | 'boolean' | 'color' | 'string[]'
diff --git a/packages/core/src/tools/variables/values.ts b/packages/core/src/tools/variables/values.ts
index 4bb31db51..30451b03c 100644
--- a/packages/core/src/tools/variables/values.ts
+++ b/packages/core/src/tools/variables/values.ts
@@ -1,5 +1,6 @@
+import type { VariableType, VariableValue } from '@open-pencil/scene-graph'
+
import { parseColor } from '#core/color'
-import type { VariableType, VariableValue } from '#core/scene-graph'
import { defineTool } from '#core/tools/schema'
function parseVariableValue(type: VariableType, value: string): VariableValue {
diff --git a/packages/core/src/tools/vector/path.ts b/packages/core/src/tools/vector/path.ts
index 6f40eff4f..c5763db90 100644
--- a/packages/core/src/tools/vector/path.ts
+++ b/packages/core/src/tools/vector/path.ts
@@ -1,6 +1,7 @@
+import { cloneVectorNetwork } from '@open-pencil/scene-graph'
+import type { SceneNode, VectorNetwork } from '@open-pencil/scene-graph'
+
import type { FigmaAPI } from '#core/figma-api'
-import { cloneVectorNetwork } from '#core/scene-graph'
-import type { SceneNode, VectorNetwork } from '#core/scene-graph'
import { defineTool } from '#core/tools/schema'
function getVectorNode(
diff --git a/packages/core/src/vector/bezier.ts b/packages/core/src/vector/bezier.ts
index 6340f7671..847e6894c 100644
--- a/packages/core/src/vector/bezier.ts
+++ b/packages/core/src/vector/bezier.ts
@@ -14,8 +14,8 @@ export {
type NetworkNearestResult
} from './curve-math'
-import type { VectorNetwork, VectorSegment, VectorVertex } from '#core/scene-graph'
-import type { Vector } from '#core/types'
+import type { VectorNetwork, VectorSegment, VectorVertex } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
function finishSplitSegment(
network: VectorNetwork,
diff --git a/packages/core/src/vector/centerline.ts b/packages/core/src/vector/centerline.ts
index 2aa14d135..349915df6 100644
--- a/packages/core/src/vector/centerline.ts
+++ b/packages/core/src/vector/centerline.ts
@@ -1,7 +1,7 @@
import type { CanvasKit, Path } from 'canvaskit-wasm'
-import type { VectorNetwork } from '#core/scene-graph'
-import type { Vector } from '#core/types'
+import type { VectorNetwork } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import { addOpenSegmentsToPath } from './path-helpers'
diff --git a/packages/core/src/vector/connectivity.ts b/packages/core/src/vector/connectivity.ts
index 1736a59a2..a86f8230f 100644
--- a/packages/core/src/vector/connectivity.ts
+++ b/packages/core/src/vector/connectivity.ts
@@ -1,4 +1,9 @@
-import type { VectorNetwork, VectorRegion, VectorSegment, VectorVertex } from '#core/scene-graph'
+import type {
+ VectorNetwork,
+ VectorRegion,
+ VectorSegment,
+ VectorVertex
+} from '@open-pencil/scene-graph'
export function findConnectedComponents(network: VectorNetwork): number[][] {
const n = network.vertices.length
diff --git a/packages/core/src/vector/curve-math.ts b/packages/core/src/vector/curve-math.ts
index e7d02c670..6e0555b05 100644
--- a/packages/core/src/vector/curve-math.ts
+++ b/packages/core/src/vector/curve-math.ts
@@ -1,5 +1,5 @@
-import type { VectorNetwork, VectorSegment } from '#core/scene-graph'
-import type { Vector, Rect } from '#core/types'
+import type { VectorNetwork, VectorSegment } from '@open-pencil/scene-graph'
+import type { Vector, Rect } from '@open-pencil/scene-graph/primitives'
export interface CubicPoints {
p0: Vector
diff --git a/packages/core/src/vector/index.ts b/packages/core/src/vector/index.ts
index b286fc7d5..d73726a1b 100644
--- a/packages/core/src/vector/index.ts
+++ b/packages/core/src/vector/index.ts
@@ -19,7 +19,7 @@ import type {
VectorSegment,
VectorVertex,
WindingRule
-} from '#core/scene-graph'
+} from '@open-pencil/scene-graph'
import { addOpenSegmentsToPath, addSegmentDirected } from './path-helpers'
export { vectorNetworkToCenterlinePath, fitCircleArc, isClosedThinCrescent } from './centerline'
diff --git a/packages/core/src/vector/path-helpers.ts b/packages/core/src/vector/path-helpers.ts
index c28294f61..c84978b89 100644
--- a/packages/core/src/vector/path-helpers.ts
+++ b/packages/core/src/vector/path-helpers.ts
@@ -1,6 +1,6 @@
import type { Path } from 'canvaskit-wasm'
-import type { VectorSegment, VectorVertex } from '#core/scene-graph'
+import type { VectorSegment, VectorVertex } from '@open-pencil/scene-graph'
export function addSegmentDirected(
path: Path,
diff --git a/packages/core/src/vector/regions.ts b/packages/core/src/vector/regions.ts
index 07699e792..fad56ed38 100644
--- a/packages/core/src/vector/regions.ts
+++ b/packages/core/src/vector/regions.ts
@@ -1,4 +1,4 @@
-import type { VectorRegion, VectorSegment } from '#core/scene-graph'
+import type { VectorRegion, VectorSegment } from '@open-pencil/scene-graph'
export function remapRegions(
regions: VectorRegion[],
diff --git a/packages/core/src/xpath.ts b/packages/core/src/xpath.ts
index c7a54c2c8..c267816d8 100644
--- a/packages/core/src/xpath.ts
+++ b/packages/core/src/xpath.ts
@@ -1,6 +1,6 @@
import type { IDomFacade } from 'fontoxpath'
-import type { SceneGraph, SceneNode } from './scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
const NODE_TYPES = {
ELEMENT_NODE: 1,
diff --git a/packages/dom-css/package.json b/packages/dom-css/package.json
index e18175577..7a85b93e9 100644
--- a/packages/dom-css/package.json
+++ b/packages/dom-css/package.json
@@ -61,7 +61,8 @@
"provenance": true
},
"peerDependencies": {
- "@open-pencil/core": "workspace:*"
+ "@open-pencil/core": "workspace:*",
+ "@open-pencil/scene-graph": "workspace:*"
},
"devDependencies": {
"@types/bun": "^1.3.14",
diff --git a/packages/dom-css/src/browser.ts b/packages/dom-css/src/browser.ts
index 0e0376f85..f70d2c65a 100644
--- a/packages/dom-css/src/browser.ts
+++ b/packages/dom-css/src/browser.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import { jsxToDesignDocument, type JSXChild } from './jsx/runtime'
diff --git a/packages/dom-css/src/convert.ts b/packages/dom-css/src/convert.ts
index 573f570e4..80e2ed8e1 100644
--- a/packages/dom-css/src/convert.ts
+++ b/packages/dom-css/src/convert.ts
@@ -1,6 +1,6 @@
import { parse, type DefaultTreeAdapterTypes } from 'parse5'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import { mergeCSSText } from './css-text'
import { createCSSRuntime } from './runtime'
diff --git a/packages/dom-css/src/css-values.ts b/packages/dom-css/src/css-values.ts
index ca359dec3..facec3efe 100644
--- a/packages/dom-css/src/css-values.ts
+++ b/packages/dom-css/src/css-values.ts
@@ -1,8 +1,8 @@
import valueParser, { type ParsedNode } from 'postcss-value-parser'
import { colorToCSS, parseColor } from '@open-pencil/core/color'
-import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/core/scene-graph'
-import type { Color } from '@open-pencil/core/types'
+import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { DesignStyleDeclaration } from './types'
diff --git a/packages/dom-css/src/from-scene-graph.ts b/packages/dom-css/src/from-scene-graph.ts
index 0bd872174..5a8eef4d4 100644
--- a/packages/dom-css/src/from-scene-graph.ts
+++ b/packages/dom-css/src/from-scene-graph.ts
@@ -1,6 +1,6 @@
import { colorToCSS } from '@open-pencil/core/color'
-import { BLACK } from '@open-pencil/core/constants'
-import type { SceneGraph, SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import { BLACK } from '@open-pencil/scene-graph/constants'
import {
dropShadowToCSS,
diff --git a/packages/dom-css/src/jsx/runtime.ts b/packages/dom-css/src/jsx/runtime.ts
index 717be781f..dc222f10d 100644
--- a/packages/dom-css/src/jsx/runtime.ts
+++ b/packages/dom-css/src/jsx/runtime.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import { compileTailwindCSS, type CompileTailwindCSSOptions } from '../tailwind'
import { designDocumentToSceneGraph, type ToSceneGraphOptions } from '../to-scene-graph'
diff --git a/packages/dom-css/src/to-scene-graph.ts b/packages/dom-css/src/to-scene-graph.ts
index f5820b0f3..07fa01405 100644
--- a/packages/dom-css/src/to-scene-graph.ts
+++ b/packages/dom-css/src/to-scene-graph.ts
@@ -1,12 +1,12 @@
-import { TRANSPARENT } from '@open-pencil/core/constants'
-import { computeImageHash } from '@open-pencil/core/figma-api'
import {
SceneGraph,
type Fill,
type ImageScaleMode,
type SceneNode,
type Stroke
-} from '@open-pencil/core/scene-graph'
+} from '@open-pencil/scene-graph'
+import { TRANSPARENT } from '@open-pencil/scene-graph/constants'
+import { computeImageHash } from '@open-pencil/scene-graph/images'
import {
colorToFillFromCSS,
diff --git a/packages/dom-css/src/types.ts b/packages/dom-css/src/types.ts
index d15ff524a..e2a056499 100644
--- a/packages/dom-css/src/types.ts
+++ b/packages/dom-css/src/types.ts
@@ -1,4 +1,4 @@
-import type { SceneGraph, SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export type DesignNode = DesignElement | DesignText
diff --git a/packages/dom-css/tests/conversion.test.ts b/packages/dom-css/tests/conversion.test.ts
index 7c872ff19..d3d4cacf3 100644
--- a/packages/dom-css/tests/conversion.test.ts
+++ b/packages/dom-css/tests/conversion.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'bun:test'
-import type { SceneGraph, SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import type { DesignElement } from '../src/index'
import {
diff --git a/packages/fig/package.json b/packages/fig/package.json
index 1bab148ba..b99cf6d11 100644
--- a/packages/fig/package.json
+++ b/packages/fig/package.json
@@ -36,7 +36,6 @@
"provenance": true
},
"peerDependencies": {
- "@open-pencil/core": "workspace:*",
"@open-pencil/kiwi": "workspace:*"
},
"devDependencies": {
diff --git a/packages/pen/README.md b/packages/pen/README.md
new file mode 100644
index 000000000..0dca39694
--- /dev/null
+++ b/packages/pen/README.md
@@ -0,0 +1,5 @@
+# @open-pencil/pen
+
+Pencil.dev `.pen` document parser and SceneGraph adapter.
+
+This package owns the `.pen` document model and import policy. It depends on `@open-pencil/scene-graph` for the shared editable design model and does not depend on `@open-pencil/core`.
diff --git a/packages/pen/package.json b/packages/pen/package.json
new file mode 100644
index 000000000..e2cd3d199
--- /dev/null
+++ b/packages/pen/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "@open-pencil/pen",
+ "version": "0.13.2",
+ "license": "MIT",
+ "type": "module",
+ "exports": {
+ ".": {
+ "types": "./dist/src/index.d.ts",
+ "bun": "./src/index.ts",
+ "import": "./dist/index.js",
+ "default": "./dist/index.js"
+ }
+ },
+ "main": "./dist/index.js",
+ "types": "./dist/src/index.d.ts",
+ "sideEffects": false,
+ "files": [
+ "dist",
+ "README.md"
+ ],
+ "scripts": {
+ "build": "bunx tsdown --config tsdown.config.ts && bunx tsc --emitDeclarationOnly -p tsconfig.json",
+ "check": "bun run typecheck && bun run build && bun run smoke:dist",
+ "prepack": "bun run build",
+ "smoke:dist": "bun scripts/smoke-dist.ts",
+ "typecheck": "bunx tsc --noEmit -p tsconfig.json"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/open-pencil/open-pencil.git",
+ "directory": "packages/pen"
+ },
+ "publishConfig": {
+ "access": "public",
+ "provenance": true
+ },
+ "peerDependencies": {
+ "@open-pencil/scene-graph": "workspace:*"
+ },
+ "dependencies": {
+ "culori": "^4.0.2"
+ },
+ "devDependencies": {
+ "@types/bun": "^1.3.14",
+ "@types/culori": "^4.0.1",
+ "tsdown": "^0.21.7",
+ "typescript": "~5.8.3"
+ }
+}
diff --git a/packages/pen/scripts/smoke-dist.ts b/packages/pen/scripts/smoke-dist.ts
new file mode 100644
index 000000000..99ae854d6
--- /dev/null
+++ b/packages/pen/scripts/smoke-dist.ts
@@ -0,0 +1,14 @@
+export {}
+
+const mod = await import('../dist/index.js')
+
+const graph = mod.parsePenFile(
+ JSON.stringify({
+ version: '1',
+ children: [{ id: 'frame', type: 'frame', name: 'Frame', width: 100, height: 50 }]
+ })
+)
+
+if (graph.getPages()[0]?.childIds.length !== 1) {
+ throw new Error('Expected built Pen package to parse a document')
+}
diff --git a/packages/pen/src/color.ts b/packages/pen/src/color.ts
new file mode 100644
index 000000000..d1c6b1632
--- /dev/null
+++ b/packages/pen/src/color.ts
@@ -0,0 +1,20 @@
+import { converter, parse } from 'culori'
+
+import { BLACK } from '@open-pencil/scene-graph/constants'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
+const rgbConverter = converter('rgb')
+
+export function parseColor(input: string): Color {
+ const parsedColor = parse(input)
+ const rgbColor = parsedColor ? rgbConverter(parsedColor) : null
+
+ return rgbColor
+ ? {
+ r: rgbColor.r,
+ g: rgbColor.g,
+ b: rgbColor.b,
+ a: parsedColor?.alpha ?? 1
+ }
+ : structuredClone(BLACK)
+}
diff --git a/packages/pen/src/convert.ts b/packages/pen/src/convert.ts
new file mode 100644
index 000000000..137b1f90e
--- /dev/null
+++ b/packages/pen/src/convert.ts
@@ -0,0 +1,467 @@
+import { generateId } from '@open-pencil/scene-graph'
+import type {
+ Color,
+ Effect,
+ Fill,
+ LayoutAlign,
+ LayoutCounterAlign,
+ LayoutMode,
+ LayoutSizing,
+ NodeType,
+ SceneGraph,
+ SceneNode,
+ Stroke,
+ StrokeCap,
+ StrokeJoin,
+ TextAlignVertical,
+ Variable,
+ VariableCollection,
+ VariableCollectionMode,
+ VariableType,
+ VariableValue
+} from '@open-pencil/scene-graph'
+import { BLACK } from '@open-pencil/scene-graph/constants'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
+
+import { parseColor } from './color'
+
+export interface PenDocument {
+ version: string
+ children: PenNode[]
+ themes?: Record<string, string[]>
+ variables?: Record<string, PenVariable>
+}
+
+export interface PenVariable {
+ type: 'color' | 'string' | 'number'
+ value: PenVariableValue[] | PenVariableValue | string | number
+}
+
+interface PenVariableValue {
+ value: string | number
+ theme?: Record<string, string>
+}
+
+interface PenStroke {
+ align: 'inside' | 'center' | 'outside'
+ thickness: number | { top?: number; right?: number; bottom?: number; left?: number }
+ fill?: string
+ join?: string
+ cap?: string
+}
+
+interface PenEffect {
+ type: string
+ shadowType?: string
+ color?: string
+ offset?: Vector
+ blur?: number
+ spread?: number
+}
+
+interface PenFillObject {
+ type: string
+ color: string
+ enabled?: boolean
+}
+
+type PenFill = string | PenFillObject | PenFillObject[]
+
+export interface PenNode {
+ type: string
+ id: string
+ name?: string
+ x?: number
+ y?: number
+ width?: number | string
+ height?: number | string
+ fill?: PenFill
+ opacity?: number
+ enabled?: boolean
+ clip?: boolean
+ rotation?: number
+ flipX?: boolean
+ flipY?: boolean
+ reusable?: boolean
+ cornerRadius?: number | string | (number | string)[]
+ stroke?: PenStroke
+ effect?: PenEffect | PenEffect[]
+ layout?: string
+ gap?: number | string
+ padding?: number | string | (number | string)[]
+ justifyContent?: string
+ alignItems?: string
+ children?: PenNode[]
+ content?: string
+ fontFamily?: string
+ fontSize?: number
+ fontWeight?: string | number
+ lineHeight?: number
+ letterSpacing?: number
+ textAlign?: string
+ textAlignVertical?: string
+ textGrowth?: string
+ ref?: string
+ descendants?: Record<string, Partial<PenNode>>
+ slot?: string[]
+ geometry?: string
+ iconFontName?: string
+ iconFontFamily?: string
+ weight?: number
+ model?: string
+ theme?: Record<string, string>
+}
+
+export interface VarContext {
+ byName: Map<string, { id: string; variable: Variable }>
+ activeModeId: string
+ collectionId: string
+ modeByThemeName: Map<string, string>
+ resolveColor(ref: string): Color
+ resolveNumber(ref: string): number
+ resolveString(ref: string): string
+ setActiveTheme(themeName: string): void
+}
+
+function penVarTypeToSceneType(t: string): VariableType {
+ if (t === 'color') return 'COLOR'
+ if (t === 'number') return 'FLOAT'
+ return 'STRING'
+}
+
+function penValueToSceneValue(raw: string | number, type: VariableType): VariableValue {
+ if (type === 'COLOR' && typeof raw === 'string') return parseColor(raw)
+ if (type === 'FLOAT' && typeof raw === 'number') return raw
+ if (type === 'STRING') return String(raw)
+ if (typeof raw === 'number') return raw
+ return String(raw)
+}
+
+function defaultForType(type: VariableType): VariableValue {
+ if (type === 'COLOR') return { ...BLACK }
+ if (type === 'FLOAT') return 0
+ if (type === 'BOOLEAN') return false
+ return ''
+}
+
+export function isVarRef(val: unknown): val is string {
+ return typeof val === 'string' && val.startsWith('$--')
+}
+
+function varName(ref: string): string {
+ return ref.replace(/^\$/, '')
+}
+
+export function bindIfVar(node: SceneNode, field: string, val: unknown, ctx: VarContext): void {
+ if (!isVarRef(val)) return
+ const entry = ctx.byName.get(varName(val))
+ if (entry) node.boundVariables[field] = entry.id
+}
+
+export function buildVarContext(
+ graph: SceneGraph,
+ penVars: Record<string, PenVariable>,
+ themes: Record<string, string[]>
+): VarContext {
+ const collectionId = generateId()
+ const modes: VariableCollectionMode[] = []
+ const themeKeys = Object.keys(themes)
+
+ if (themeKeys.length > 0) {
+ const themeKey = themeKeys[0]
+ for (const modeName of themes[themeKey]) {
+ modes.push({ modeId: generateId(), name: modeName })
+ }
+ }
+ if (modes.length === 0) {
+ modes.push({ modeId: generateId(), name: 'Default' })
+ }
+
+ const collection: VariableCollection = {
+ id: collectionId,
+ name: 'Variables',
+ modes,
+ defaultModeId: modes[0].modeId,
+ variableIds: []
+ }
+ graph.addCollection(collection)
+
+ const modeByThemeValue = new Map<string, string>()
+ if (themeKeys.length > 0) {
+ const themeKey = themeKeys[0]
+ for (const mode of modes) {
+ modeByThemeValue.set(`${themeKey}:${mode.name}`, mode.modeId)
+ }
+ }
+
+ const byName = new Map<string, { id: string; variable: Variable }>()
+
+ for (const [name, def] of Object.entries(penVars)) {
+ const varId = generateId()
+ const varType = penVarTypeToSceneType(def.type)
+ const valuesByMode: Record<string, VariableValue> = {}
+
+ if (Array.isArray(def.value)) {
+ for (const entry of def.value) {
+ if (entry.theme) {
+ const [tKey, tVal] = Object.entries(entry.theme)[0]
+ const modeId = modeByThemeValue.get(`${tKey}:${tVal}`)
+ if (modeId) valuesByMode[modeId] = penValueToSceneValue(entry.value, varType)
+ } else {
+ valuesByMode[modes[0].modeId] = penValueToSceneValue(entry.value, varType)
+ }
+ }
+ } else {
+ valuesByMode[modes[0].modeId] = penValueToSceneValue(def.value as string | number, varType)
+ }
+
+ for (const mode of modes) {
+ if (!(mode.modeId in valuesByMode)) {
+ valuesByMode[mode.modeId] = valuesByMode[modes[0].modeId] ?? defaultForType(varType)
+ }
+ }
+
+ const variable: Variable = {
+ id: varId,
+ name,
+ type: varType,
+ collectionId,
+ valuesByMode,
+ description: '',
+ hiddenFromPublishing: false
+ }
+ graph.addVariable(variable)
+ byName.set(name, { id: varId, variable })
+ }
+
+ let activeModeId = modes[0].modeId
+
+ function resolveVal(ref: string): VariableValue | undefined {
+ const entry = byName.get(ref.replace(/^\$/, ''))
+ if (!entry) return undefined
+ return (
+ entry.variable.valuesByMode[activeModeId] ?? Object.values(entry.variable.valuesByMode)[0]
+ )
+ }
+
+ return {
+ byName,
+ activeModeId,
+ collectionId,
+ modeByThemeName: modeByThemeValue,
+ resolveColor(ref: string): Color {
+ const val = resolveVal(ref)
+ if (val === undefined) return parseColor(ref)
+ if (typeof val === 'object' && 'r' in val) return val
+ if (typeof val === 'string') return parseColor(val)
+ return { ...BLACK }
+ },
+ resolveNumber(ref: string): number {
+ const val = resolveVal(ref)
+ return typeof val === 'number' ? val : 0
+ },
+ resolveString(ref: string): string {
+ const val = resolveVal(ref)
+ return typeof val === 'string' ? val : ''
+ },
+ setActiveTheme(themeName: string) {
+ const modeId = modeByThemeValue.get(`theme:${themeName}`)
+ if (modeId) {
+ activeModeId = modeId
+ graph.activeMode.set(collectionId, modeId)
+ }
+ }
+ }
+}
+
+function parseFillColor(fill: string | PenFillObject, ctx: VarContext): Color {
+ const raw = typeof fill === 'string' ? fill : fill.color
+ return isVarRef(raw) ? ctx.resolveColor(raw) : parseColor(raw)
+}
+
+export function convertFill(fill: PenFill | undefined, ctx: VarContext, node?: SceneNode): Fill[] {
+ if (fill === undefined) return []
+ const fills = Array.isArray(fill) ? fill : [fill]
+ return fills.map((item, index) => {
+ const visible = typeof item === 'string' ? true : item.enabled !== false
+ const color = parseFillColor(item, ctx)
+ const result: Fill = { type: 'SOLID', visible, opacity: color.a, color }
+ if (node) bindIfVar(node, `fills[${index}]`, typeof item === 'string' ? item : item.color, ctx)
+ return result
+ })
+}
+
+function strokeWeight(stroke: PenStroke): number {
+ return typeof stroke.thickness === 'number'
+ ? stroke.thickness
+ : Math.max(...Object.values(stroke.thickness))
+}
+
+export function convertStroke(
+ stroke: PenStroke | undefined,
+ ctx: VarContext,
+ node?: SceneNode
+): Stroke[] {
+ if (!stroke?.fill) return []
+ const color = isVarRef(stroke.fill) ? ctx.resolveColor(stroke.fill) : parseColor(stroke.fill)
+ let align: Stroke['align'] = 'CENTER'
+ if (stroke.align === 'inside') align = 'INSIDE'
+ else if (stroke.align === 'outside') align = 'OUTSIDE'
+
+ const result: Stroke = {
+ visible: true,
+ color,
+ opacity: color.a,
+ weight: strokeWeight(stroke),
+ align,
+ dashPattern: []
+ }
+ if (node) {
+ bindIfVar(node, 'strokes[0]', stroke.fill, ctx)
+ if (typeof stroke.thickness === 'object') {
+ node.independentStrokeWeights = true
+ node.borderTopWeight = stroke.thickness.top ?? 0
+ node.borderRightWeight = stroke.thickness.right ?? 0
+ node.borderBottomWeight = stroke.thickness.bottom ?? 0
+ node.borderLeftWeight = stroke.thickness.left ?? 0
+ }
+ node.strokeJoin = mapStrokeJoin(stroke.join)
+ node.strokeCap = mapStrokeCap(stroke.cap)
+ }
+ return [result]
+}
+
+function mapStrokeJoin(join: string | undefined): StrokeJoin {
+ if (join === 'round') return 'ROUND'
+ if (join === 'bevel') return 'BEVEL'
+ return 'MITER'
+}
+
+function mapStrokeCap(cap: string | undefined): StrokeCap {
+ if (cap === 'round') return 'ROUND'
+ if (cap === 'square') return 'SQUARE'
+ return 'NONE'
+}
+
+export function convertEffects(effect: PenEffect | PenEffect[] | undefined): Effect[] {
+ if (!effect) return []
+ const effects = Array.isArray(effect) ? effect : [effect]
+ return effects.flatMap((item) => {
+ if (item.type !== 'shadow') return []
+ const color = item.color ? parseColor(item.color) : { r: 0, g: 0, b: 0, a: 0.25 }
+ return [
+ {
+ type: item.shadowType === 'inner' ? 'INNER_SHADOW' : 'DROP_SHADOW',
+ visible: true,
+ blendMode: 'NORMAL',
+ color,
+ offset: item.offset ?? { x: 0, y: 0 },
+ radius: item.blur ?? 0,
+ spread: item.spread ?? 0
+ } satisfies Effect
+ ]
+ })
+}
+
+export function applyCornerRadius(
+ node: SceneNode,
+ radius: PenNode['cornerRadius'],
+ ctx: VarContext
+): void {
+ if (radius === undefined) return
+ if (Array.isArray(radius)) {
+ const values = radius.map((value) => parseSize(value, 0, ctx).value)
+ node.independentCorners = true
+ node.topLeftRadius = values[0] ?? 0
+ node.topRightRadius = values[1] ?? 0
+ node.bottomRightRadius = values[2] ?? 0
+ node.bottomLeftRadius = values[3] ?? 0
+ return
+ }
+ node.cornerRadius = parseSize(radius, 0, ctx).value
+}
+
+export function applyPadding(node: SceneNode, padding: PenNode['padding'], ctx?: VarContext): void {
+ if (padding === undefined) return
+ const resolve = (v: number | string): number =>
+ typeof v === 'string' ? (isVarRef(v) && ctx ? ctx.resolveNumber(v) : Number(v) || 0) : v
+ if (Array.isArray(padding)) {
+ node.paddingTop = resolve(padding[0] ?? 0)
+ node.paddingRight = resolve(padding[1] ?? 0)
+ node.paddingBottom = resolve(padding[2] ?? 0)
+ node.paddingLeft = resolve(padding[3] ?? 0)
+ return
+ }
+ const resolved = resolve(padding)
+ node.paddingTop = resolved
+ node.paddingRight = resolved
+ node.paddingBottom = resolved
+ node.paddingLeft = resolved
+}
+
+export function parseSize(value: number | string | undefined, fallback: number, ctx?: VarContext) {
+ if (value === undefined) return { value: fallback, sizing: 'FIXED' as LayoutSizing }
+ if (typeof value === 'number') return { value, sizing: 'FIXED' as LayoutSizing }
+ if (value === 'fill_container') return { value: fallback, sizing: 'FILL' as LayoutSizing }
+ if (value === 'hug_content') return { value: fallback, sizing: 'HUG' as LayoutSizing }
+ if (isVarRef(value) && ctx)
+ return { value: ctx.resolveNumber(value), sizing: 'FIXED' as LayoutSizing }
+ const parsed = Number(value)
+ return { value: Number.isFinite(parsed) ? parsed : fallback, sizing: 'FIXED' as LayoutSizing }
+}
+
+export function mapLayoutMode(pen: PenNode): LayoutMode {
+ if (pen.layout === 'row' || pen.layout === 'horizontal') return 'HORIZONTAL'
+ if (pen.layout === 'column' || pen.layout === 'vertical') return 'VERTICAL'
+ return 'NONE'
+}
+
+export function mapJustifyContent(value: string | undefined): LayoutAlign {
+ if (value === 'center') return 'CENTER'
+ if (value === 'end') return 'MAX'
+ if (value === 'space-between') return 'SPACE_BETWEEN'
+ return 'MIN'
+}
+
+export function mapAlignItems(value: string | undefined): LayoutCounterAlign {
+ if (value === 'center') return 'CENTER'
+ if (value === 'end') return 'MAX'
+ if (value === 'stretch') return 'STRETCH'
+ return 'MIN'
+}
+
+export function mapTextAlign(value: string | undefined): SceneNode['textAlignHorizontal'] {
+ if (value === 'center') return 'CENTER'
+ if (value === 'right' || value === 'end') return 'RIGHT'
+ if (value === 'justified') return 'JUSTIFIED'
+ return 'LEFT'
+}
+
+export function mapTextAlignVertical(value: string | undefined): TextAlignVertical {
+ if (value === 'center') return 'CENTER'
+ if (value === 'bottom' || value === 'end') return 'BOTTOM'
+ return 'TOP'
+}
+
+export function mapFontWeight(value: string | number | undefined): number {
+ if (typeof value === 'number') return value
+ if (value === 'thin') return 100
+ if (value === 'extralight') return 200
+ if (value === 'light') return 300
+ if (value === 'medium') return 500
+ if (value === 'semibold') return 600
+ if (value === 'bold') return 700
+ if (value === 'extrabold') return 800
+ if (value === 'black') return 900
+ return 400
+}
+
+export function mapNodeType(pen: PenNode): NodeType {
+ if (pen.type === 'frame') return pen.reusable ? 'COMPONENT' : 'FRAME'
+ if (pen.type === 'rectangle') return 'RECTANGLE'
+ if (pen.type === 'ellipse') return 'ELLIPSE'
+ if (pen.type === 'text' || pen.type === 'icon_font') return 'TEXT'
+ if (pen.type === 'path') return 'VECTOR'
+ if (pen.type === 'ref') return 'INSTANCE'
+ return 'FRAME'
+}
diff --git a/packages/pen/src/index.ts b/packages/pen/src/index.ts
new file mode 100644
index 000000000..7a64c8910
--- /dev/null
+++ b/packages/pen/src/index.ts
@@ -0,0 +1,2 @@
+export { parsePenFile, readPenFile } from './read'
+export * from './convert'
diff --git a/packages/pen/src/parse-path.ts b/packages/pen/src/parse-path.ts
new file mode 100644
index 000000000..63f9a2ce1
--- /dev/null
+++ b/packages/pen/src/parse-path.ts
@@ -0,0 +1 @@
+export { parseSVGPath } from '@open-pencil/scene-graph/parse-path'
diff --git a/packages/pen/src/read.ts b/packages/pen/src/read.ts
new file mode 100644
index 000000000..f77fb005c
--- /dev/null
+++ b/packages/pen/src/read.ts
@@ -0,0 +1,519 @@
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type { LayoutMode, LayoutSizing, SceneNode, VectorNetwork } from '@open-pencil/scene-graph'
+import { copyEffects, copyFills, copyStrokes } from '@open-pencil/scene-graph/copy'
+import { populateInstanceChildren } from '@open-pencil/scene-graph/instances'
+
+import {
+ applyCornerRadius,
+ applyPadding,
+ bindIfVar,
+ buildVarContext,
+ convertEffects,
+ convertFill,
+ convertStroke,
+ isVarRef,
+ mapAlignItems,
+ mapFontWeight,
+ mapJustifyContent,
+ mapLayoutMode,
+ mapNodeType,
+ mapTextAlign,
+ mapTextAlignVertical,
+ parseSize,
+ type PenDocument,
+ type PenNode,
+ type VarContext
+} from './convert'
+import { parseSVGPath } from './parse-path'
+
+function scaleVectorNetwork(vn: VectorNetwork, targetW: number, targetH: number): void {
+ if (vn.vertices.length === 0) return
+ let minX = Infinity
+ let maxX = -Infinity
+ let minY = Infinity
+ let maxY = -Infinity
+ for (const v of vn.vertices) {
+ minX = Math.min(minX, v.x)
+ maxX = Math.max(maxX, v.x)
+ minY = Math.min(minY, v.y)
+ maxY = Math.max(maxY, v.y)
+ }
+ const vnW = maxX - minX
+ const vnH = maxY - minY
+ if (vnW < 0.01 || vnH < 0.01) return
+ const sx = targetW / vnW
+ const sy = targetH / vnH
+ if (Math.abs(sx - 1) < 0.01 && Math.abs(sy - 1) < 0.01) return
+ for (const v of vn.vertices) {
+ v.x = (v.x - minX) * sx
+ v.y = (v.y - minY) * sy
+ }
+ for (const s of vn.segments) {
+ s.tangentStart = { x: s.tangentStart.x * sx, y: s.tangentStart.y * sy }
+ s.tangentEnd = { x: s.tangentEnd.x * sx, y: s.tangentEnd.y * sy }
+ }
+}
+
+function resolveFontFamily(raw: string | undefined, ctx: VarContext): string {
+ if (!raw) return 'Inter'
+ if (isVarRef(raw)) return ctx.resolveString(raw)
+ return raw
+}
+
+function buildBaseOverrides(pen: PenNode): Partial<SceneNode> {
+ return {
+ id: pen.id,
+ name: pen.name ?? (pen.type === 'icon_font' ? (pen.iconFontName ?? 'Icon') : pen.type),
+ x: pen.x ?? 0,
+ y: pen.y ?? 0,
+ visible: pen.enabled !== false,
+ opacity: pen.opacity ?? 1,
+ rotation: pen.rotation ?? 0,
+ flipX: pen.flipX ?? false,
+ flipY: pen.flipY ?? false,
+ clipsContent: pen.clip ?? false,
+ boundVariables: {}
+ }
+}
+
+function applyAutoLayout(
+ overrides: Partial<SceneNode>,
+ layoutMode: LayoutMode,
+ pen: PenNode,
+ widthSizing: LayoutSizing,
+ heightSizing: LayoutSizing,
+ ctx?: VarContext
+): void {
+ overrides.layoutMode = layoutMode
+ overrides.primaryAxisAlign = mapJustifyContent(pen.justifyContent)
+ overrides.counterAxisAlign = mapAlignItems(pen.alignItems)
+ overrides.itemSpacing =
+ typeof pen.gap === 'string' && isVarRef(pen.gap) && ctx
+ ? ctx.resolveNumber(pen.gap)
+ : ((pen.gap ?? 0) as number)
+
+ if (layoutMode === 'VERTICAL') {
+ overrides.primaryAxisSizing = heightSizing
+ overrides.counterAxisSizing = widthSizing
+ } else {
+ overrides.primaryAxisSizing = widthSizing
+ overrides.counterAxisSizing = heightSizing
+ }
+}
+
+function applyTextProps(node: SceneNode, pen: PenNode, ctx: VarContext): void {
+ node.text = pen.type === 'icon_font' ? (pen.iconFontName ?? '') : (pen.content ?? '')
+ node.fontFamily =
+ pen.type === 'icon_font'
+ ? (pen.iconFontFamily ?? 'Material Symbols Sharp')
+ : resolveFontFamily(pen.fontFamily, ctx)
+ node.fontSize = pen.fontSize ?? 14
+ node.fontWeight = mapFontWeight(
+ pen.fontWeight ?? (pen.type === 'icon_font' ? pen.weight : undefined)
+ )
+ node.textAlignHorizontal = mapTextAlign(pen.textAlign)
+ node.textAlignVertical = mapTextAlignVertical(pen.textAlignVertical)
+ if (pen.lineHeight !== undefined) {
+ node.lineHeight = pen.lineHeight < 5 ? pen.lineHeight * node.fontSize : pen.lineHeight
+ }
+ if (pen.letterSpacing !== undefined) node.letterSpacing = pen.letterSpacing
+ node.textAutoResize = pen.textGrowth === 'fixed-width' ? 'HEIGHT' : 'WIDTH_AND_HEIGHT'
+ if (pen.fontFamily && isVarRef(pen.fontFamily)) {
+ bindIfVar(node, 'fontFamily', pen.fontFamily, ctx)
+ }
+}
+
+function resolveSizing(pen: PenNode, ctx: VarContext) {
+ const isTextLike = pen.type === 'text' || pen.type === 'icon_font'
+ const defaultSize = isTextLike ? 20 : 100
+ const defaultW = isTextLike && pen.width === undefined ? 10_000 : defaultSize
+ const w = parseSize(pen.width, defaultW, ctx)
+ const h = parseSize(pen.height, defaultSize, ctx)
+ const layout = mapLayoutMode(pen)
+
+ if (pen.width === undefined && layout !== 'NONE') w.sizing = 'HUG'
+ if (pen.height === undefined && layout !== 'NONE') h.sizing = 'HUG'
+
+ return { w, h, layout, isTextLike }
+}
+
+function inheritLayoutFromComp(node: SceneNode, pen: PenNode, comp: SceneNode): void {
+ const wasRow = node.layoutMode === 'HORIZONTAL'
+ node.layoutMode = comp.layoutMode
+ node.primaryAxisAlign = comp.primaryAxisAlign
+ node.counterAxisAlign = comp.counterAxisAlign
+ const isRow = node.layoutMode === 'HORIZONTAL'
+ if (wasRow !== isRow) {
+ const oldP = node.primaryAxisSizing
+ node.primaryAxisSizing = node.counterAxisSizing
+ node.counterAxisSizing = oldP
+ }
+ const widthAxis = isRow ? 'primaryAxisSizing' : 'counterAxisSizing'
+ const heightAxis = isRow ? 'counterAxisSizing' : 'primaryAxisSizing'
+ if (pen.width === undefined) node[widthAxis] = comp[widthAxis]
+ if (pen.height === undefined) node[heightAxis] = comp[heightAxis]
+ if (pen.gap === undefined) node.itemSpacing = comp.itemSpacing
+ if (pen.padding === undefined) {
+ node.paddingTop = comp.paddingTop
+ node.paddingRight = comp.paddingRight
+ node.paddingBottom = comp.paddingBottom
+ node.paddingLeft = comp.paddingLeft
+ }
+ if (pen.clip === undefined) node.clipsContent = comp.clipsContent
+}
+
+function applyRefVisuals(
+ node: SceneNode,
+ pen: PenNode,
+ compPen: PenNode | undefined,
+ ctx: VarContext
+): void {
+ if (!compPen) return
+ if (pen.fill === undefined && compPen.fill !== undefined)
+ node.fills = convertFill(compPen.fill, ctx, node)
+ if (pen.stroke === undefined && compPen.stroke)
+ node.strokes = convertStroke(compPen.stroke, ctx, node)
+ if (pen.effect === undefined && compPen.effect) node.effects = convertEffects(compPen.effect)
+ if (pen.cornerRadius === undefined) applyCornerRadius(node, compPen.cornerRadius, ctx)
+}
+
+function applyRefProps(
+ node: SceneNode,
+ pen: PenNode,
+ graph: SceneGraph,
+ componentIds: Map<string, string>,
+ penSources: Map<string, PenNode>,
+ ctx: VarContext
+): void {
+ if (!pen.ref) return
+ const componentId = componentIds.get(pen.ref) ?? pen.ref
+ node.componentId = componentId
+ const comp = graph.getNode(componentId)
+ if (!comp) return
+ if (pen.width === undefined) node.width = comp.width
+ if (pen.height === undefined) node.height = comp.height
+ if (pen.layout === undefined) inheritLayoutFromComp(node, pen, comp)
+ applyRefVisuals(node, pen, penSources.get(pen.ref), ctx)
+}
+
+function applyAllRefProps(
+ penNodes: PenNode[],
+ graph: SceneGraph,
+ componentIds: Map<string, string>,
+ penSources: Map<string, PenNode>,
+ ctx: VarContext
+): void {
+ for (const pen of penNodes) {
+ if (pen.type === 'ref') {
+ const node = graph.getNode(pen.id)
+ if (node) applyRefProps(node, pen, graph, componentIds, penSources, ctx)
+ }
+ if (pen.children) applyAllRefProps(pen.children, graph, componentIds, penSources, ctx)
+ }
+}
+
+function applyTheme(theme: Record<string, string>, ctx: VarContext): void {
+ const themeName = Object.values(theme)[0]
+ if (themeName) ctx.setActiveTheme(themeName)
+}
+
+// eslint-disable-next-line complexity -- .pen node mapping touches many format-specific fields
+function createSceneNode(
+ pen: PenNode,
+ parentId: string,
+ graph: SceneGraph,
+ ctx: VarContext,
+ componentIds: Map<string, string>,
+ penSources: Map<string, PenNode>
+): string | null {
+ if (pen.type === 'prompt') return null
+ if (pen.theme) applyTheme(pen.theme, ctx)
+
+ const { w, h, layout, isTextLike } = resolveSizing(pen, ctx)
+ const overrides = buildBaseOverrides(pen)
+ overrides.width = w.value
+ overrides.height = h.value
+
+ const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'
+ if (layout !== 'NONE') {
+ const widthSizing =
+ parentLayout === 'NONE' && w.sizing === 'FILL' ? ('FIXED' as LayoutSizing) : w.sizing
+ const heightSizing =
+ parentLayout === 'NONE' && h.sizing === 'FILL' ? ('FIXED' as LayoutSizing) : h.sizing
+ applyAutoLayout(overrides, layout, pen, widthSizing, heightSizing, ctx)
+ }
+
+ const node = graph.createNode(mapNodeType(pen), parentId, overrides)
+
+ if (pen.fill !== undefined) node.fills = convertFill(pen.fill, ctx, node)
+ if (pen.stroke) node.strokes = convertStroke(pen.stroke, ctx, node)
+ node.effects = convertEffects(pen.effect)
+ applyCornerRadius(node, pen.cornerRadius, ctx)
+ applyPadding(node, pen.padding, ctx)
+
+ if (isTextLike) {
+ applyTextProps(node, pen, ctx)
+ if (parentLayout === 'NONE' && pen.width === undefined && !pen.textGrowth) {
+ node.textAutoResize = 'NONE'
+ node.width = node.text.length * node.fontSize * 0.65
+ node.height = node.fontSize * (node.lineHeight ? node.lineHeight / node.fontSize : 1.2)
+ }
+ }
+
+ if (pen.type === 'path' && pen.geometry) {
+ const vectorNetwork = parseSVGPath(pen.geometry)
+ node.vectorNetwork = vectorNetwork
+ scaleVectorNetwork(vectorNetwork, node.width, node.height)
+ }
+
+ if (parentLayout !== 'NONE') {
+ const parentVertical = parentLayout === 'VERTICAL'
+ if (w.sizing === 'FILL') {
+ if (parentVertical) node.layoutAlignSelf = 'STRETCH'
+ else node.layoutGrow = 1
+ }
+ if (h.sizing === 'FILL') {
+ if (parentVertical) node.layoutGrow = 1
+ else node.layoutAlignSelf = 'STRETCH'
+ }
+ }
+
+ if (pen.reusable) {
+ componentIds.set(pen.id, node.id)
+ penSources.set(pen.id, pen)
+ }
+
+ if (pen.children) {
+ for (const child of pen.children) {
+ createSceneNode(child, node.id, graph, ctx, componentIds, penSources)
+ }
+ }
+
+ return node.id
+}
+
+function collectByNameType(
+ graph: SceneGraph,
+ parentId: string,
+ name: string,
+ type: string,
+ out: SceneNode[],
+ depth: number
+): void {
+ if (depth > 2) return
+ const parent = graph.getNode(parentId)
+ if (!parent) return
+ for (const childId of parent.childIds) {
+ const child = graph.getNode(childId)
+ if (!child) continue
+ if (child.name === name && child.type === type) out.push(child)
+ collectByNameType(graph, childId, name, type, out, depth + 1)
+ }
+}
+
+function findCloneByComponentId(
+ graph: SceneGraph,
+ parentId: string,
+ origId: string
+): SceneNode | undefined {
+ const parent = graph.getNode(parentId)
+ if (!parent) return undefined
+ for (const childId of parent.childIds) {
+ const child = graph.getNode(childId)
+ if (!child) continue
+ if (child.componentId === origId) return child
+ const deep = findCloneByComponentId(graph, childId, origId)
+ if (deep) return deep
+ }
+ return undefined
+}
+
+function findCloneByNameFallback(
+ graph: SceneGraph,
+ parentId: string,
+ origId: string
+): SceneNode | undefined {
+ const orig = graph.getNode(origId)
+ if (!orig) return undefined
+ const matches: SceneNode[] = []
+ collectByNameType(graph, parentId, orig.name, orig.type, matches, 0)
+ return matches.length === 1 ? matches[0] : undefined
+}
+
+function applyOverrideProps(
+ target: SceneNode,
+ overrideData: Partial<PenNode>,
+ ctx: VarContext
+): void {
+ if (overrideData.fill !== undefined) target.fills = convertFill(overrideData.fill, ctx, target)
+ if (overrideData.content !== undefined) target.text = overrideData.content
+ if (overrideData.x !== undefined) target.x = overrideData.x
+ if (overrideData.y !== undefined) target.y = overrideData.y
+ if (overrideData.enabled !== undefined) target.visible = overrideData.enabled
+ if (overrideData.width !== undefined)
+ target.width = parseSize(overrideData.width, target.width, ctx).value
+ if (overrideData.height !== undefined)
+ target.height = parseSize(overrideData.height, target.height, ctx).value
+ if (overrideData.rotation !== undefined) target.rotation = overrideData.rotation
+ if (overrideData.name !== undefined) target.name = overrideData.name
+}
+
+function populateInstances(graph: SceneGraph): void {
+ for (const node of graph.getAllNodes()) {
+ if (node.type === 'INSTANCE' && node.componentId && node.childIds.length === 0) {
+ const component = graph.getNode(node.componentId)
+ if (component) populateInstanceChildren(graph, node.id, node.componentId)
+ }
+ }
+}
+
+function applyDescendantOverrides(
+ graph: SceneGraph,
+ pen: PenNode,
+ ctx: VarContext,
+ componentIds: Map<string, string>,
+ penSources: Map<string, PenNode>
+): void {
+ if (pen.type !== 'ref' || !pen.descendants) return
+ const instanceNode = graph.getNode(pen.id)
+ if (!instanceNode) return
+
+ for (const [origId, overrideData] of Object.entries(pen.descendants)) {
+ const clone =
+ findCloneByComponentId(graph, instanceNode.id, origId) ??
+ findCloneByNameFallback(graph, instanceNode.id, origId)
+
+ if (clone) {
+ if (overrideData.children) {
+ const toDelete = clone.childIds.slice()
+ for (const childId of toDelete) graph.deleteNode(childId)
+ for (const child of overrideData.children) {
+ createSceneNode(child, clone.id, graph, ctx, componentIds, penSources)
+ }
+ }
+ applyOverrideProps(clone, overrideData, ctx)
+ continue
+ }
+
+ if (overrideData.type && overrideData.id) {
+ createSceneNode(
+ overrideData as PenNode,
+ instanceNode.id,
+ graph,
+ ctx,
+ componentIds,
+ penSources
+ )
+ }
+ }
+}
+
+function walkAndApplyOverrides(
+ nodes: PenNode[],
+ graph: SceneGraph,
+ ctx: VarContext,
+ componentIds: Map<string, string>,
+ penSources: Map<string, PenNode>
+): void {
+ for (const pen of nodes) {
+ applyDescendantOverrides(graph, pen, ctx, componentIds, penSources)
+ if (pen.children) walkAndApplyOverrides(pen.children, graph, ctx, componentIds, penSources)
+ }
+}
+
+function collectComponentIds(nodes: PenNode[], map: Map<string, string>): void {
+ for (const node of nodes) {
+ if (node.reusable) map.set(node.id, node.id)
+ if (node.children) collectComponentIds(node.children, map)
+ }
+}
+
+function resolveNodeVars(node: SceneNode, graph: SceneGraph, ctx: VarContext): void {
+ for (const [key, varId] of Object.entries(node.boundVariables)) {
+ const variable = graph.variables.get(varId)
+ if (!variable) continue
+ const modeVal =
+ variable.valuesByMode[ctx.activeModeId] ?? Object.values(variable.valuesByMode)[0]
+ if (key.startsWith('fills[') && typeof modeVal === 'object' && 'r' in modeVal) {
+ const idx = Number.parseInt(key.match(/\d+/)?.[0] ?? '0', 10)
+ if (node.fills[idx]) node.fills[idx].color = modeVal
+ } else if (key.startsWith('strokes[') && typeof modeVal === 'object' && 'r' in modeVal) {
+ const idx = Number.parseInt(key.match(/\d+/)?.[0] ?? '0', 10)
+ if (node.strokes[idx]) node.strokes[idx].color = modeVal
+ }
+ }
+ for (const childId of node.childIds) {
+ const child = graph.getNode(childId)
+ if (child) resolveNodeVars(child, graph, ctx)
+ }
+}
+
+function resolveThemeVariables(penNodes: PenNode[], graph: SceneGraph, ctx: VarContext): void {
+ for (const pen of penNodes) {
+ if (pen.theme) applyTheme(pen.theme, ctx)
+ const node = graph.getNode(pen.id)
+ if (node) resolveNodeVars(node, graph, ctx)
+ if (pen.children) resolveThemeVariables(pen.children, graph, ctx)
+ }
+}
+
+function fixInstanceWidths(graph: SceneGraph): void {
+ for (const node of graph.getAllNodes()) {
+ if (node.type !== 'INSTANCE' || !node.componentId) continue
+ const comp = graph.getNode(node.componentId)
+ if (!comp) continue
+ if (node.width <= 100 && comp.width > 100) node.width = comp.width
+ if (node.height <= 100 && comp.height > 100) node.height = comp.height
+ if (comp.layoutGrow > 0) node.layoutGrow = comp.layoutGrow
+ if (comp.layoutAlignSelf !== 'AUTO') node.layoutAlignSelf = comp.layoutAlignSelf
+ node.fills = copyFills(node.fills)
+ node.strokes = copyStrokes(node.strokes)
+ node.effects = copyEffects(node.effects)
+ }
+}
+
+function fixTextWidths(graph: SceneGraph): void {
+ for (const node of graph.getAllNodes()) {
+ if (node.type !== 'TEXT' || !node.text || node.text.length <= 1) continue
+ if (node.width >= node.fontSize * 2) continue
+ node.width = node.text.length * node.fontSize * 0.65
+ }
+}
+
+export function parsePenFile(json: string): SceneGraph {
+ const doc: PenDocument = JSON.parse(json)
+ const graph = new SceneGraph()
+
+ for (const page of graph.getPages(true)) {
+ graph.deleteNode(page.id)
+ }
+
+ const ctx = buildVarContext(graph, doc.variables ?? {}, doc.themes ?? {})
+ const componentIds = new Map<string, string>()
+ const penSources = new Map<string, PenNode>()
+
+ collectComponentIds(doc.children, componentIds)
+
+ const page = graph.addPage(doc.children[0]?.name ?? 'Page 1')
+ for (const child of doc.children) {
+ createSceneNode(child, page.id, graph, ctx, componentIds, penSources)
+ }
+
+ applyAllRefProps(doc.children, graph, componentIds, penSources, ctx)
+ populateInstances(graph)
+ walkAndApplyOverrides(doc.children, graph, ctx, componentIds, penSources)
+ populateInstances(graph)
+ resolveThemeVariables(doc.children, graph, ctx)
+ fixInstanceWidths(graph)
+ fixTextWidths(graph)
+
+ if (graph.getPages(true).length === 0) {
+ graph.addPage('Page 1')
+ }
+
+ return graph
+}
+
+export async function readPenFile(file: File): Promise<SceneGraph> {
+ return parsePenFile(await file.text())
+}
diff --git a/packages/pen/tsconfig.json b/packages/pen/tsconfig.json
new file mode 100644
index 000000000..0268fb9cb
--- /dev/null
+++ b/packages/pen/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "strict": true,
+ "declaration": true,
+ "declarationDir": "./dist/src",
+ "declarationMap": true,
+ "outDir": "./dist",
+ "rootDir": "./src",
+ "skipLibCheck": true,
+ "esModuleInterop": true,
+ "resolveJsonModule": true,
+ "types": ["bun"],
+ "paths": {
+ "#pen/*": ["./src/*"],
+ "@open-pencil/pen": ["./src/index.ts"]
+ }
+ },
+ "include": ["src/**/*.ts"],
+ "exclude": ["node_modules", "dist"]
+}
diff --git a/packages/pen/tsdown.config.ts b/packages/pen/tsdown.config.ts
new file mode 100644
index 000000000..56a3f31c5
--- /dev/null
+++ b/packages/pen/tsdown.config.ts
@@ -0,0 +1,38 @@
+import { defineConfig } from 'tsdown'
+
+export default defineConfig({
+ entry: {
+ index: './src/index.ts'
+ },
+ platform: 'neutral',
+ format: ['esm'],
+ dts: false,
+ sourcemap: true,
+ hash: false,
+ clean: true,
+ outDir: './dist',
+ treeshake: {
+ moduleSideEffects: false
+ },
+ deps: {
+ neverBundle: ['@open-pencil/scene-graph', /^@open-pencil\/scene-graph\//, /^node:/],
+ onlyBundle: false
+ },
+ outputOptions: {
+ minifyInternalExports: false,
+ codeSplitting: {
+ groups: [
+ {
+ test: /(?<!\.d\.c?ts)$/,
+ name: (id) => {
+ const cleanId = id.split('?')[0]
+ const parts = cleanId.split(/[\\/]/g)
+ const srcIndex = parts.lastIndexOf('src')
+ const file = srcIndex >= 0 ? parts.slice(srcIndex + 1).join('/') : parts.at(-1) ?? 'chunk'
+ return `chunks/${file.replace(/\.(ts|tsx)$/, '')}`
+ }
+ }
+ ]
+ }
+ }
+})
diff --git a/packages/scene-graph/README.md b/packages/scene-graph/README.md
new file mode 100644
index 000000000..96880684e
--- /dev/null
+++ b/packages/scene-graph/README.md
@@ -0,0 +1,5 @@
+# @open-pencil/scene-graph
+
+Shared OpenPencil design document model.
+
+This package owns `SceneGraph`, `SceneNode`, paint/effect/layout/variable types, graph mutation helpers, source metadata, and model-level utilities. It does not own editor state, UI, file format policy, rendering, or app document I/O.
diff --git a/packages/scene-graph/package.json b/packages/scene-graph/package.json
new file mode 100644
index 000000000..b828093c6
--- /dev/null
+++ b/packages/scene-graph/package.json
@@ -0,0 +1,167 @@
+{
+ "name": "@open-pencil/scene-graph",
+ "version": "0.13.2",
+ "license": "MIT",
+ "type": "module",
+ "exports": {
+ ".": {
+ "types": "./dist/src/index.d.ts",
+ "bun": "./src/index.ts",
+ "import": "./dist/index.js",
+ "default": "./dist/index.js"
+ },
+ "./copy": {
+ "types": "./dist/src/copy.d.ts",
+ "bun": "./src/copy.ts",
+ "import": "./dist/copy.js",
+ "default": "./dist/copy.js"
+ },
+ "./node-defaults": {
+ "types": "./dist/src/node-defaults.d.ts",
+ "bun": "./src/node-defaults.ts",
+ "import": "./dist/node-defaults.js",
+ "default": "./dist/node-defaults.js"
+ },
+ "./instances": {
+ "types": "./dist/src/instances.d.ts",
+ "bun": "./src/instances.ts",
+ "import": "./dist/instances.js",
+ "default": "./dist/instances.js"
+ },
+ "./snap": {
+ "types": "./dist/src/snap.d.ts",
+ "bun": "./src/snap.ts",
+ "import": "./dist/snap.js",
+ "default": "./dist/snap.js"
+ },
+ "./source-metadata": {
+ "types": "./dist/src/source-metadata.d.ts",
+ "bun": "./src/source-metadata.ts",
+ "import": "./dist/source-metadata.js",
+ "default": "./dist/source-metadata.js"
+ },
+ "./undo": {
+ "types": "./dist/src/undo.d.ts",
+ "bun": "./src/undo.ts",
+ "import": "./dist/undo.js",
+ "default": "./dist/undo.js"
+ },
+ "./variant-name": {
+ "types": "./dist/src/variant-name.d.ts",
+ "bun": "./src/variant-name.ts",
+ "import": "./dist/variant-name.js",
+ "default": "./dist/variant-name.js"
+ },
+ "./vector-network": {
+ "types": "./dist/src/vector-network.d.ts",
+ "bun": "./src/vector-network.ts",
+ "import": "./dist/vector-network.js",
+ "default": "./dist/vector-network.js"
+ },
+ "./types": {
+ "types": "./dist/src/types.d.ts",
+ "bun": "./src/types.ts",
+ "import": "./dist/types.js",
+ "default": "./dist/types.js"
+ },
+ "./primitives": {
+ "types": "./dist/src/primitives.d.ts",
+ "bun": "./src/primitives.ts",
+ "import": "./dist/primitives.js",
+ "default": "./dist/primitives.js"
+ },
+ "./constants": {
+ "types": "./dist/src/constants.d.ts",
+ "bun": "./src/constants.ts",
+ "import": "./dist/constants.js",
+ "default": "./dist/constants.js"
+ },
+ "./hit-test": {
+ "types": "./dist/src/hit-test.d.ts",
+ "bun": "./src/hit-test.ts",
+ "import": "./dist/hit-test.js",
+ "default": "./dist/hit-test.js"
+ },
+ "./preview": {
+ "types": "./dist/src/preview.d.ts",
+ "bun": "./src/preview.ts",
+ "import": "./dist/preview.js",
+ "default": "./dist/preview.js"
+ },
+ "./text-picture": {
+ "types": "./dist/src/text-picture.d.ts",
+ "bun": "./src/text-picture.ts",
+ "import": "./dist/text-picture.js",
+ "default": "./dist/text-picture.js"
+ },
+ "./variables": {
+ "types": "./dist/src/variables.d.ts",
+ "bun": "./src/variables.ts",
+ "import": "./dist/variables.js",
+ "default": "./dist/variables.js"
+ },
+ "./images": {
+ "types": "./dist/src/images.d.ts",
+ "bun": "./src/images.ts",
+ "import": "./dist/images.js",
+ "default": "./dist/images.js"
+ },
+ "./coordinate": {
+ "types": "./dist/src/coordinate.d.ts",
+ "bun": "./src/coordinate.ts",
+ "import": "./dist/coordinate.js",
+ "default": "./dist/coordinate.js"
+ },
+ "./matrix": {
+ "types": "./dist/src/matrix.d.ts",
+ "bun": "./src/matrix.ts",
+ "import": "./dist/matrix.js",
+ "default": "./dist/matrix.js"
+ },
+ "./geometry": {
+ "types": "./dist/src/geometry.d.ts",
+ "bun": "./src/geometry.ts",
+ "import": "./dist/geometry.js",
+ "default": "./dist/geometry.js"
+ },
+ "./parse-path": {
+ "types": "./dist/src/parse-path.d.ts",
+ "bun": "./src/parse-path.ts",
+ "import": "./dist/parse-path.js",
+ "default": "./dist/parse-path.js"
+ }
+ },
+ "main": "./dist/index.js",
+ "types": "./dist/src/index.d.ts",
+ "sideEffects": false,
+ "files": [
+ "dist",
+ "README.md"
+ ],
+ "scripts": {
+ "build": "bunx tsdown --config tsdown.config.ts && bunx tsc --emitDeclarationOnly -p tsconfig.json",
+ "check": "bun run typecheck && bun run build && bun run smoke:dist",
+ "prepack": "bun run build",
+ "smoke:dist": "bun scripts/smoke-dist.ts",
+ "typecheck": "bunx tsc --noEmit -p tsconfig.json"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/open-pencil/open-pencil.git",
+ "directory": "packages/scene-graph"
+ },
+ "publishConfig": {
+ "access": "public",
+ "provenance": true
+ },
+ "dependencies": {
+ "es-toolkit": "^1.46.1",
+ "nanoevents": "^9.1.0",
+ "svgpath": "^2.6.0"
+ },
+ "devDependencies": {
+ "@types/bun": "^1.3.14",
+ "tsdown": "^0.21.7",
+ "typescript": "~5.8.3"
+ }
+}
diff --git a/packages/scene-graph/scripts/smoke-dist.ts b/packages/scene-graph/scripts/smoke-dist.ts
new file mode 100644
index 000000000..8ee0f7e6c
--- /dev/null
+++ b/packages/scene-graph/scripts/smoke-dist.ts
@@ -0,0 +1,11 @@
+export {}
+
+const mod = await import('../dist/index.js')
+
+const graph = new mod.SceneGraph()
+const page = graph.getPages()[0]
+const node = graph.createNode('RECTANGLE', page.id, { width: 10, height: 20 })
+
+if (graph.getNode(node.id)?.width !== 10) {
+ throw new Error('Expected built SceneGraph package to create nodes')
+}
diff --git a/packages/scene-graph/src/constants.ts b/packages/scene-graph/src/constants.ts
new file mode 100644
index 000000000..c7499159b
--- /dev/null
+++ b/packages/scene-graph/src/constants.ts
@@ -0,0 +1,6 @@
+import type { Color } from './primitives'
+
+export const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }
+export const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }
+export const DEFAULT_FONT_FAMILY = 'Inter'
+export const DEFAULT_STROKE_MITER_LIMIT = 4
diff --git a/packages/core/src/canvas/coordinate.ts b/packages/scene-graph/src/coordinate.ts
similarity index 97%
rename from packages/core/src/canvas/coordinate.ts
rename to packages/scene-graph/src/coordinate.ts
index 148d22759..559bda1b4 100644
--- a/packages/core/src/canvas/coordinate.ts
+++ b/packages/scene-graph/src/coordinate.ts
@@ -1,7 +1,6 @@
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
-import type { Vector } from '#core/types'
-
+import type { SceneGraph, SceneNode } from './index'
import Matrix, { type Mat3 } from './matrix'
+import type { Vector } from './primitives'
export function getWorldMatrix(node: SceneNode, graph: SceneGraph): Mat3 {
const chain: SceneNode[] = []
diff --git a/packages/core/src/scene-graph/copy.ts b/packages/scene-graph/src/copy.ts
similarity index 100%
rename from packages/core/src/scene-graph/copy.ts
rename to packages/scene-graph/src/copy.ts
diff --git a/packages/core/src/scene-graph/events.ts b/packages/scene-graph/src/events.ts
similarity index 100%
rename from packages/core/src/scene-graph/events.ts
rename to packages/scene-graph/src/events.ts
diff --git a/packages/core/src/scene-graph/export-scale.ts b/packages/scene-graph/src/export-scale.ts
similarity index 100%
rename from packages/core/src/scene-graph/export-scale.ts
rename to packages/scene-graph/src/export-scale.ts
diff --git a/packages/core/src/geometry.ts b/packages/scene-graph/src/geometry.ts
similarity index 99%
rename from packages/core/src/geometry.ts
rename to packages/scene-graph/src/geometry.ts
index 7355d90a0..e34cbb5c1 100644
--- a/packages/core/src/geometry.ts
+++ b/packages/scene-graph/src/geometry.ts
@@ -1,5 +1,5 @@
-import type { Effect, Stroke } from './scene-graph'
-import type { Rect, Vector } from './types'
+import type { Effect, Stroke } from './index'
+import type { Rect, Vector } from './primitives'
export function degToRad(degrees: number): number {
return (degrees * Math.PI) / 180
diff --git a/packages/core/src/scene-graph/hit-test.ts b/packages/scene-graph/src/hit-test.ts
similarity index 97%
rename from packages/core/src/scene-graph/hit-test.ts
rename to packages/scene-graph/src/hit-test.ts
index 301ca0995..11bb7ebb2 100644
--- a/packages/core/src/scene-graph/hit-test.ts
+++ b/packages/scene-graph/src/hit-test.ts
@@ -1,7 +1,6 @@
-import { getWorldMatrix } from '#core/canvas/coordinate'
-import Matrix from '#core/canvas/matrix'
-
import type { SceneGraph, SceneNode, NodeType } from './'
+import { getWorldMatrix } from './coordinate'
+import Matrix from './matrix'
const CONTAINER_TYPES = new Set<NodeType>([
'CANVAS',
diff --git a/packages/scene-graph/src/images.ts b/packages/scene-graph/src/images.ts
new file mode 100644
index 000000000..4d22ce443
--- /dev/null
+++ b/packages/scene-graph/src/images.ts
@@ -0,0 +1,33 @@
+export function computeImageHash(data: Uint8Array): string {
+ let h1 = 0x811c9dc5 >>> 0
+ let h2 = 0x811c9dc5 >>> 0
+ let h3 = 0x811c9dc5 >>> 0
+ let h4 = 0x811c9dc5 >>> 0
+ let h5 = 0x811c9dc5 >>> 0
+ for (let i = 0; i < data.length; i++) {
+ const b = data[i]
+ switch (i % 5) {
+ case 0:
+ h1 ^= b
+ h1 = Math.imul(h1, 0x01000193) >>> 0
+ break
+ case 1:
+ h2 ^= b
+ h2 = Math.imul(h2, 0x01000193) >>> 0
+ break
+ case 2:
+ h3 ^= b
+ h3 = Math.imul(h3, 0x01000193) >>> 0
+ break
+ case 3:
+ h4 ^= b
+ h4 = Math.imul(h4, 0x01000193) >>> 0
+ break
+ default:
+ h5 ^= b
+ h5 = Math.imul(h5, 0x01000193) >>> 0
+ break
+ }
+ }
+ return `img_${h1.toString(36)}${h2.toString(36)}${h3.toString(36)}${h4.toString(36)}${h5.toString(36)}_${data.length}`
+}
diff --git a/packages/core/src/scene-graph/index.ts b/packages/scene-graph/src/index.ts
similarity index 98%
rename from packages/core/src/scene-graph/index.ts
rename to packages/scene-graph/src/index.ts
index f67c9f0e9..a90d60d3d 100644
--- a/packages/core/src/scene-graph/index.ts
+++ b/packages/scene-graph/src/index.ts
@@ -1,3 +1,4 @@
+export * from './images'
export * from './snap'
export * from './export-scale'
export { UndoManager, type UndoEntry, type UndoManagerOptions } from './undo'
@@ -16,14 +17,13 @@ import { TEXT_PICTURE_KEYS } from './text-picture'
import * as Variables from './variables'
import { normalizeVectorNetwork } from './vector-network'
-export type { GUID, Color } from '#core/types'
+export type { GUID, Color } from './primitives'
export * from './types'
import type { Emitter } from 'nanoevents'
-import { getAbsolutePosition } from '#core/canvas/coordinate'
-import type { Color, Rect, Vector } from '#core/types'
-
+import { getAbsolutePosition } from './coordinate'
+import type { Color, Rect, Vector } from './primitives'
import type {
DocumentColorSpace,
NodeType,
diff --git a/packages/core/src/scene-graph/instances.ts b/packages/scene-graph/src/instances.ts
similarity index 100%
rename from packages/core/src/scene-graph/instances.ts
rename to packages/scene-graph/src/instances.ts
diff --git a/packages/core/src/canvas/matrix.ts b/packages/scene-graph/src/matrix.ts
similarity index 98%
rename from packages/core/src/canvas/matrix.ts
rename to packages/scene-graph/src/matrix.ts
index 4b4a3a286..157b67218 100644
--- a/packages/core/src/canvas/matrix.ts
+++ b/packages/scene-graph/src/matrix.ts
@@ -1,4 +1,4 @@
-import type { Vector } from '#core/types'
+import type { Vector } from './primitives'
export type Mat3 = number[]
diff --git a/packages/core/src/scene-graph/node-defaults.ts b/packages/scene-graph/src/node-defaults.ts
similarity index 99%
rename from packages/core/src/scene-graph/node-defaults.ts
rename to packages/scene-graph/src/node-defaults.ts
index 56fde04ac..e34fea4e1 100644
--- a/packages/core/src/scene-graph/node-defaults.ts
+++ b/packages/scene-graph/src/node-defaults.ts
@@ -1,5 +1,4 @@
-import { BLACK, DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT } from '#core/constants'
-
+import { BLACK, DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT } from './constants'
import type { NodeType, SceneNode } from './types'
export function createDefaultNode(
diff --git a/packages/scene-graph/src/parse-path.ts b/packages/scene-graph/src/parse-path.ts
new file mode 100644
index 000000000..60fa27884
--- /dev/null
+++ b/packages/scene-graph/src/parse-path.ts
@@ -0,0 +1,142 @@
+import svgpath from 'svgpath'
+
+import type { VectorNetwork, VectorVertex, VectorSegment, VectorRegion, WindingRule } from './index'
+
+interface SubPath {
+ startVertexIndex: number
+ segmentIndices: number[]
+ closed: boolean
+}
+
+/**
+ * Parse an SVG path `d` attribute into a VectorNetwork.
+ *
+ * Uses `svgpath` to normalize all commands to absolute M/L/C/Z
+ * (arcs → cubics via `.unarc()`, smooth curves → explicit via `.unshort()`).
+ */
+export function parseSVGPath(d: string, windingRule: WindingRule = 'NONZERO'): VectorNetwork {
+ const vertices: VectorVertex[] = []
+ const segments: VectorSegment[] = []
+ const subPaths: SubPath[] = []
+
+ let currentSubPath: SubPath | null = null
+ let cx = 0
+ let cy = 0
+
+ const vertexMap = new Map<string, number>()
+
+ function getOrCreateVertex(x: number, y: number): number {
+ const key = `${x},${y}`
+ const existing = vertexMap.get(key)
+ if (existing !== undefined) return existing
+ const idx = vertices.length
+ vertices.push({ x, y })
+ vertexMap.set(key, idx)
+ return idx
+ }
+
+ function addSegment(
+ x1: number,
+ y1: number,
+ x2: number,
+ y2: number,
+ tx1: number,
+ ty1: number,
+ tx2: number,
+ ty2: number
+ ): void {
+ const startIdx = getOrCreateVertex(x1, y1)
+ const endIdx = getOrCreateVertex(x2, y2)
+ const segIdx = segments.length
+ segments.push({
+ start: startIdx,
+ end: endIdx,
+ tangentStart: { x: tx1 - x1, y: ty1 - y1 },
+ tangentEnd: { x: tx2 - x2, y: ty2 - y2 }
+ })
+ if (currentSubPath) {
+ currentSubPath.segmentIndices.push(segIdx)
+ }
+ }
+
+ function addLine(x1: number, y1: number, x2: number, y2: number): void {
+ addSegment(x1, y1, x2, y2, x1, y1, x2, y2)
+ }
+
+ function addCubic(
+ x1: number,
+ y1: number,
+ cp1x: number,
+ cp1y: number,
+ cp2x: number,
+ cp2y: number,
+ x2: number,
+ y2: number
+ ): void {
+ addSegment(x1, y1, x2, y2, cp1x, cp1y, cp2x, cp2y)
+ }
+
+ const normalized = svgpath(d).abs().unshort().unarc()
+
+ normalized.iterate((seg) => {
+ const cmd = seg[0]
+
+ if (cmd === 'M') {
+ cx = seg[1]
+ cy = seg[2]
+ currentSubPath = {
+ startVertexIndex: getOrCreateVertex(cx, cy),
+ segmentIndices: [],
+ closed: false
+ }
+ subPaths.push(currentSubPath)
+ } else if (cmd === 'L') {
+ addLine(cx, cy, seg[1], seg[2])
+ cx = seg[1]
+ cy = seg[2]
+ } else if (cmd === 'H') {
+ addLine(cx, cy, seg[1], cy)
+ cx = seg[1]
+ } else if (cmd === 'V') {
+ addLine(cx, cy, cx, seg[1])
+ cy = seg[1]
+ } else if (cmd === 'C') {
+ addCubic(cx, cy, seg[1], seg[2], seg[3], seg[4], seg[5], seg[6])
+ cx = seg[5]
+ cy = seg[6]
+ } else if (cmd === 'Q') {
+ const qx = seg[1]
+ const qy = seg[2]
+ const ex = seg[3]
+ const ey = seg[4]
+ const cp1x = cx + (2 / 3) * (qx - cx)
+ const cp1y = cy + (2 / 3) * (qy - cy)
+ const cp2x = ex + (2 / 3) * (qx - ex)
+ const cp2y = ey + (2 / 3) * (qy - ey)
+ addCubic(cx, cy, cp1x, cp1y, cp2x, cp2y, ex, ey)
+ cx = ex
+ cy = ey
+ } else if (cmd === 'Z' || cmd === 'z') {
+ if (currentSubPath) {
+ const startVert = vertices[currentSubPath.startVertexIndex]
+ if (Math.abs(cx - startVert.x) > 0.001 || Math.abs(cy - startVert.y) > 0.001) {
+ addLine(cx, cy, startVert.x, startVert.y)
+ }
+ currentSubPath.closed = true
+ cx = startVert.x
+ cy = startVert.y
+ }
+ }
+ })
+
+ const regions: VectorRegion[] = []
+ const closedPaths = subPaths.filter((sp) => sp.closed && sp.segmentIndices.length > 0)
+ if (closedPaths.length > 0) {
+ regions.push({
+ windingRule,
+ loops: closedPaths.map((sp) => sp.segmentIndices)
+ })
+ }
+
+ return { vertices, segments, regions }
+}
diff --git a/packages/core/src/scene-graph/preview.ts b/packages/scene-graph/src/preview.ts
similarity index 100%
rename from packages/core/src/scene-graph/preview.ts
rename to packages/scene-graph/src/preview.ts
diff --git a/packages/core/src/types.ts b/packages/scene-graph/src/primitives.ts
similarity index 100%
rename from packages/core/src/types.ts
rename to packages/scene-graph/src/primitives.ts
diff --git a/packages/core/src/scene-graph/snap.ts b/packages/scene-graph/src/snap.ts
similarity index 97%
rename from packages/core/src/scene-graph/snap.ts
rename to packages/scene-graph/src/snap.ts
index 870323443..273388721 100644
--- a/packages/core/src/scene-graph/snap.ts
+++ b/packages/scene-graph/src/snap.ts
@@ -1,7 +1,6 @@
-import { rotatedBBox } from '#core/geometry'
-import type { Rect } from '#core/types'
-
import type { SceneNode } from './'
+import { rotatedBBox } from './geometry'
+import type { Rect } from './primitives'
const SNAP_THRESHOLD = 5
diff --git a/packages/core/src/scene-graph/source-metadata.ts b/packages/scene-graph/src/source-metadata.ts
similarity index 100%
rename from packages/core/src/scene-graph/source-metadata.ts
rename to packages/scene-graph/src/source-metadata.ts
diff --git a/packages/core/src/scene-graph/text-picture.ts b/packages/scene-graph/src/text-picture.ts
similarity index 100%
rename from packages/core/src/scene-graph/text-picture.ts
rename to packages/scene-graph/src/text-picture.ts
diff --git a/packages/core/src/scene-graph/types.ts b/packages/scene-graph/src/types.ts
similarity index 99%
rename from packages/core/src/scene-graph/types.ts
rename to packages/scene-graph/src/types.ts
index 896e66c18..882898094 100644
--- a/packages/core/src/scene-graph/types.ts
+++ b/packages/scene-graph/src/types.ts
@@ -1,4 +1,4 @@
-import type { Color, Matrix, Rect, Vector } from '#core/types'
+import type { Color, Matrix, Rect, Vector } from './primitives'
export interface SceneGraphEvents {
'node:created': (node: SceneNode) => void
diff --git a/packages/core/src/scene-graph/undo.ts b/packages/scene-graph/src/undo.ts
similarity index 100%
rename from packages/core/src/scene-graph/undo.ts
rename to packages/scene-graph/src/undo.ts
diff --git a/packages/core/src/scene-graph/variables.ts b/packages/scene-graph/src/variables.ts
similarity index 99%
rename from packages/core/src/scene-graph/variables.ts
rename to packages/scene-graph/src/variables.ts
index 2b60fdc9b..4d62e9540 100644
--- a/packages/core/src/scene-graph/variables.ts
+++ b/packages/scene-graph/src/variables.ts
@@ -1,9 +1,8 @@
import { omit, omitBy } from 'es-toolkit/object'
-import { BLACK } from '#core/constants'
-import type { Color } from '#core/types'
-
+import { BLACK } from './constants'
import type { SceneGraph } from './index'
+import type { Color } from './primitives'
import type { Variable, VariableCollection, VariableType, VariableValue } from './types'
export function addVariable(graph: SceneGraph, variable: Variable): void {
diff --git a/packages/core/src/scene-graph/variant-name.ts b/packages/scene-graph/src/variant-name.ts
similarity index 100%
rename from packages/core/src/scene-graph/variant-name.ts
rename to packages/scene-graph/src/variant-name.ts
diff --git a/packages/core/src/scene-graph/vector-network.ts b/packages/scene-graph/src/vector-network.ts
similarity index 98%
rename from packages/core/src/scene-graph/vector-network.ts
rename to packages/scene-graph/src/vector-network.ts
index 79b53892d..f2ca9046e 100644
--- a/packages/core/src/scene-graph/vector-network.ts
+++ b/packages/scene-graph/src/vector-network.ts
@@ -1,5 +1,4 @@
-import type { Vector } from '#core/types'
-
+import type { Vector } from './primitives'
import type { VectorNetwork, VectorSegment } from './types'
/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */
diff --git a/packages/scene-graph/tsconfig.json b/packages/scene-graph/tsconfig.json
new file mode 100644
index 000000000..f78bbb1ae
--- /dev/null
+++ b/packages/scene-graph/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "rootDir": ".",
+ "outDir": "dist",
+ "declaration": true,
+ "declarationMap": true,
+ "emitDeclarationOnly": true,
+ "noEmit": false,
+ "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
+ "types": ["bun"]
+ },
+ "include": ["src"]
+}
diff --git a/packages/scene-graph/tsdown.config.ts b/packages/scene-graph/tsdown.config.ts
new file mode 100644
index 000000000..f6d56b130
--- /dev/null
+++ b/packages/scene-graph/tsdown.config.ts
@@ -0,0 +1,58 @@
+import { defineConfig } from 'tsdown'
+
+export default defineConfig({
+ entry: {
+ index: './src/index.ts',
+ copy: './src/copy.ts',
+ 'node-defaults': './src/node-defaults.ts',
+ 'hit-test': './src/hit-test.ts',
+ images: './src/images.ts',
+ instances: './src/instances.ts',
+ snap: './src/snap.ts',
+ 'source-metadata': './src/source-metadata.ts',
+ preview: './src/preview.ts',
+ 'text-picture': './src/text-picture.ts',
+ undo: './src/undo.ts',
+ variables: './src/variables.ts',
+ 'variant-name': './src/variant-name.ts',
+ 'vector-network': './src/vector-network.ts',
+ types: './src/types.ts',
+ primitives: './src/primitives.ts',
+ constants: './src/constants.ts',
+ coordinate: './src/coordinate.ts',
+ matrix: './src/matrix.ts',
+ geometry: './src/geometry.ts',
+ 'parse-path': './src/parse-path.ts'
+ },
+ platform: 'neutral',
+ format: ['esm'],
+ dts: false,
+ sourcemap: true,
+ hash: false,
+ clean: true,
+ outDir: './dist',
+ treeshake: {
+ moduleSideEffects: false
+ },
+ deps: {
+ neverBundle: [/^node:/],
+ onlyBundle: false
+ },
+ outputOptions: {
+ minifyInternalExports: false,
+ codeSplitting: {
+ groups: [
+ {
+ test: /(?<!\.d\.c?ts)$/,
+ name: (id) => {
+ const cleanId = id.split('?')[0]
+ const parts = cleanId.split(/[\\/]/g)
+ const srcIndex = parts.lastIndexOf('src')
+ const file = srcIndex >= 0 ? parts.slice(srcIndex + 1).join('/') : parts.at(-1) ?? 'chunk'
+ return `chunks/${file.replace(/\.(ts|tsx)$/, '')}`
+ }
+ }
+ ]
+ }
+ }
+})
diff --git a/packages/vue/package.json b/packages/vue/package.json
index b84b52f60..1578045a8 100644
--- a/packages/vue/package.json
+++ b/packages/vue/package.json
@@ -52,6 +52,7 @@
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
"@nanostores/i18n": "^1.2.2",
"@nanostores/vue": "^1.1.0",
+ "@open-pencil/scene-graph": "workspace:*",
"@tanstack/vue-table": "^8.21.3",
"@vueuse/core": "^14.2.1",
"nanostores": "^1.2.0",
diff --git a/packages/vue/src/canvas/context/index.ts b/packages/vue/src/canvas/context/index.ts
index 8686d2a15..6288c2675 100644
--- a/packages/vue/src/canvas/context/index.ts
+++ b/packages/vue/src/canvas/context/index.ts
@@ -1,6 +1,6 @@
import { type InjectionKey, type Ref, inject, provide } from 'vue'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
export interface CanvasContext {
canvasRef: Ref<HTMLCanvasElement | null>
diff --git a/packages/vue/src/canvas/node-edit-input/bend.ts b/packages/vue/src/canvas/node-edit-input/bend.ts
index 190f1b9ed..3ec44aacb 100644
--- a/packages/vue/src/canvas/node-edit-input/bend.ts
+++ b/packages/vue/src/canvas/node-edit-input/bend.ts
@@ -1,6 +1,6 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { VectorSegment } from '@open-pencil/core/scene-graph'
-import type { Vector } from '@open-pencil/core/types'
+import type { VectorSegment } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import type { DragState } from '#vue/shared/input/types'
diff --git a/packages/vue/src/canvas/overlays/useCanvasVirtualReference.ts b/packages/vue/src/canvas/overlays/useCanvasVirtualReference.ts
index 75e9a3571..e7422c063 100644
--- a/packages/vue/src/canvas/overlays/useCanvasVirtualReference.ts
+++ b/packages/vue/src/canvas/overlays/useCanvasVirtualReference.ts
@@ -1,7 +1,7 @@
import { computed, type ComputedRef, type Ref } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { Vector } from '@open-pencil/core/types'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
type CanvasVirtualReference = {
getBoundingClientRect: () => DOMRect
diff --git a/packages/vue/src/canvas/pen-input/drag.ts b/packages/vue/src/canvas/pen-input/drag.ts
index a73f3bb72..9ac3c5ae1 100644
--- a/packages/vue/src/canvas/pen-input/drag.ts
+++ b/packages/vue/src/canvas/pen-input/drag.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { Vector } from '@open-pencil/core/types'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import type { DragState } from '#vue/shared/input/types'
diff --git a/packages/vue/src/canvas/pointer/use.ts b/packages/vue/src/canvas/pointer/use.ts
index 287e08147..8576c152e 100644
--- a/packages/vue/src/canvas/pointer/use.ts
+++ b/packages/vue/src/canvas/pointer/use.ts
@@ -1,7 +1,7 @@
import type { Ref } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import {
canvasToLocalPoint,
diff --git a/packages/vue/src/canvas/text-edit/clipboard.ts b/packages/vue/src/canvas/text-edit/clipboard.ts
index 3d924cc0c..f14813b77 100644
--- a/packages/vue/src/canvas/text-edit/clipboard.ts
+++ b/packages/vue/src/canvas/text-edit/clipboard.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
type TextClipboardOptions = {
store: Editor
diff --git a/packages/vue/src/canvas/text-edit/editing.ts b/packages/vue/src/canvas/text-edit/editing.ts
index 58e709be0..dd15fecd4 100644
--- a/packages/vue/src/canvas/text-edit/editing.ts
+++ b/packages/vue/src/canvas/text-edit/editing.ts
@@ -2,8 +2,8 @@ import { useIntervalFn } from '@vueuse/core'
import type { ShallowRef } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import { adjustRunsForDelete, adjustRunsForInsert } from '@open-pencil/core/text'
+import type { SceneNode } from '@open-pencil/scene-graph'
const CARET_BLINK_MS = 530
diff --git a/packages/vue/src/canvas/text-edit/formatting.ts b/packages/vue/src/canvas/text-edit/formatting.ts
index b23c17e47..53ce0edcf 100644
--- a/packages/vue/src/canvas/text-edit/formatting.ts
+++ b/packages/vue/src/canvas/text-edit/formatting.ts
@@ -1,10 +1,10 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import {
toggleBoldInRange,
toggleDecorationInRange,
toggleItalicInRange
} from '@open-pencil/core/text'
+import type { SceneNode } from '@open-pencil/scene-graph'
export function createTextFormattingActions(store: Editor) {
function applyFormatting(nodeId: string, changes: Partial<SceneNode>, label: string) {
diff --git a/packages/vue/src/canvas/text-edit/input.ts b/packages/vue/src/canvas/text-edit/input.ts
index 3667e9ab4..919abfb99 100644
--- a/packages/vue/src/canvas/text-edit/input.ts
+++ b/packages/vue/src/canvas/text-edit/input.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { DragState } from '#vue/shared/input/types'
diff --git a/packages/vue/src/canvas/text-edit/keyboard.ts b/packages/vue/src/canvas/text-edit/keyboard.ts
index 2180d3f9a..c2953cd95 100644
--- a/packages/vue/src/canvas/text-edit/keyboard.ts
+++ b/packages/vue/src/canvas/text-edit/keyboard.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { extendSelectionForDeletion, handleNavigationKey } from './navigation'
diff --git a/packages/vue/src/canvas/transform-input/rotation.ts b/packages/vue/src/canvas/transform-input/rotation.ts
index ce2d69947..95e083df7 100644
--- a/packages/vue/src/canvas/transform-input/rotation.ts
+++ b/packages/vue/src/canvas/transform-input/rotation.ts
@@ -1,6 +1,6 @@
-import { getAbsolutePositionFull } from '@open-pencil/core/canvas'
import { ROTATION_SNAP_DEGREES } from '@open-pencil/core/constants'
import type { Editor } from '@open-pencil/core/editor'
+import { getAbsolutePositionFull } from '@open-pencil/scene-graph/coordinate'
import {
hitTestCornerRotationByMatrix,
diff --git a/packages/vue/src/canvas/useCanvasInput.ts b/packages/vue/src/canvas/useCanvasInput.ts
index 98e665de7..3ce362349 100644
--- a/packages/vue/src/canvas/useCanvasInput.ts
+++ b/packages/vue/src/canvas/useCanvasInput.ts
@@ -2,7 +2,7 @@ import { useEventListener } from '@vueuse/core'
import { ref, type Ref } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import {
handleBendHandleMove,
diff --git a/packages/vue/src/controls/appearance/helpers.ts b/packages/vue/src/controls/appearance/helpers.ts
index 1dd389fb4..79deaad2d 100644
--- a/packages/vue/src/controls/appearance/helpers.ts
+++ b/packages/vue/src/controls/appearance/helpers.ts
@@ -2,7 +2,7 @@ import { computed } from 'vue'
import type { ComputedRef } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { MIXED, type MixedValue } from '#vue/controls/node-props/use'
diff --git a/packages/vue/src/controls/color-variable-binding/use.ts b/packages/vue/src/controls/color-variable-binding/use.ts
index bbedd14c6..0ad0737e3 100644
--- a/packages/vue/src/controls/color-variable-binding/use.ts
+++ b/packages/vue/src/controls/color-variable-binding/use.ts
@@ -4,8 +4,8 @@ import { useVariableBinding } from '#vue/controls/variable-binding/use'
const FALLBACK_COLOR_VARIABLE_NAME = 'New color'
-import type { VariableCollection } from '@open-pencil/core/scene-graph'
-import type { Color } from '@open-pencil/core/types'
+import type { VariableCollection } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
type ColorBindingKind = 'fills' | 'strokes'
diff --git a/packages/vue/src/controls/effects/helpers.ts b/packages/vue/src/controls/effects/helpers.ts
index f8852923a..fb9b08880 100644
--- a/packages/vue/src/controls/effects/helpers.ts
+++ b/packages/vue/src/controls/effects/helpers.ts
@@ -1,8 +1,8 @@
import type { Ref } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { Effect, SceneNode } from '@open-pencil/core/scene-graph'
-import type { Color } from '@open-pencil/core/types'
+import type { Effect, SceneNode } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import { useI18n } from '#vue/i18n/useI18n.js'
diff --git a/packages/vue/src/controls/effects/use.ts b/packages/vue/src/controls/effects/use.ts
index 78b83610d..e7911b842 100644
--- a/packages/vue/src/controls/effects/use.ts
+++ b/packages/vue/src/controls/effects/use.ts
@@ -1,6 +1,6 @@
import { ref } from 'vue'
-import type { Effect } from '@open-pencil/core/scene-graph'
+import type { Effect } from '@open-pencil/scene-graph'
import {
EFFECT_OPTIONS,
diff --git a/packages/vue/src/controls/layout/helpers.ts b/packages/vue/src/controls/layout/helpers.ts
index 40f5166fa..27f598a95 100644
--- a/packages/vue/src/controls/layout/helpers.ts
+++ b/packages/vue/src/controls/layout/helpers.ts
@@ -8,7 +8,7 @@ import type {
LayoutCounterAlign,
LayoutSizing,
SceneNode
-} from '@open-pencil/core/scene-graph'
+} from '@open-pencil/scene-graph'
import type { useI18n } from '#vue/i18n'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
diff --git a/packages/vue/src/controls/node-props/helpers.ts b/packages/vue/src/controls/node-props/helpers.ts
index 16702277e..29e1b18e1 100644
--- a/packages/vue/src/controls/node-props/helpers.ts
+++ b/packages/vue/src/controls/node-props/helpers.ts
@@ -2,7 +2,7 @@ import { computed } from 'vue'
import type { ComputedRef } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/core/scene-graph'
+import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/scene-graph'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
diff --git a/packages/vue/src/controls/number-variable-binding/use.ts b/packages/vue/src/controls/number-variable-binding/use.ts
index 0320534b0..2abc6ed5c 100644
--- a/packages/vue/src/controls/number-variable-binding/use.ts
+++ b/packages/vue/src/controls/number-variable-binding/use.ts
@@ -1,5 +1,5 @@
import { randomHex } from '@open-pencil/core/random'
-import type { VariableCollection } from '@open-pencil/core/scene-graph'
+import type { VariableCollection } from '@open-pencil/scene-graph'
import { useVariableBinding } from '#vue/controls/variable-binding/use'
diff --git a/packages/vue/src/controls/okhcl/helpers.ts b/packages/vue/src/controls/okhcl/helpers.ts
index 761875b58..574d036eb 100644
--- a/packages/vue/src/controls/okhcl/helpers.ts
+++ b/packages/vue/src/controls/okhcl/helpers.ts
@@ -11,7 +11,7 @@ import {
import type { OkHCLColor } from '@open-pencil/core/color'
import { BLACK } from '@open-pencil/core/constants'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { ColorFieldFormat } from '#vue/primitives/ColorPicker/types'
diff --git a/packages/vue/src/controls/position/use.ts b/packages/vue/src/controls/position/use.ts
index b79521c9b..44d3b0c9b 100644
--- a/packages/vue/src/controls/position/use.ts
+++ b/packages/vue/src/controls/position/use.ts
@@ -1,6 +1,6 @@
import { computed } from 'vue'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { usePropScrub } from '#vue/controls/prop-scrub/use'
import { useEditor } from '#vue/editor/context'
diff --git a/packages/vue/src/controls/prop-scrub/use.ts b/packages/vue/src/controls/prop-scrub/use.ts
index 339389328..8eb3b806b 100644
--- a/packages/vue/src/controls/prop-scrub/use.ts
+++ b/packages/vue/src/controls/prop-scrub/use.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
export function usePropScrub(editor: Editor) {
const previousValues = new Map<string, Record<string, number | string>>()
diff --git a/packages/vue/src/controls/stroke/helpers.ts b/packages/vue/src/controls/stroke/helpers.ts
index c8f5b23be..c6b0eda8d 100644
--- a/packages/vue/src/controls/stroke/helpers.ts
+++ b/packages/vue/src/controls/stroke/helpers.ts
@@ -2,7 +2,7 @@ import type { Ref } from 'vue'
import { BLACK } from '@open-pencil/core/constants'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode, Stroke } from '@open-pencil/core/scene-graph'
+import type { SceneNode, Stroke } from '@open-pencil/scene-graph'
export type StrokeSides = 'ALL' | 'TOP' | 'BOTTOM' | 'LEFT' | 'RIGHT' | 'CUSTOM'
diff --git a/packages/vue/src/controls/typography/actions.ts b/packages/vue/src/controls/typography/actions.ts
index d3b59fa16..3fa9c23f6 100644
--- a/packages/vue/src/controls/typography/actions.ts
+++ b/packages/vue/src/controls/typography/actions.ts
@@ -2,8 +2,8 @@ import { computed } from 'vue'
import type { ComputedRef } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode, TextDecoration } from '@open-pencil/core/scene-graph'
import { FONT_WEIGHT_NAMES, weightToStyle } from '@open-pencil/core/text'
+import type { SceneNode, TextDecoration } from '@open-pencil/scene-graph'
import type { UseTypographyOptions } from '#vue/controls/typography/use'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
diff --git a/packages/vue/src/controls/undo-batch/use.ts b/packages/vue/src/controls/undo-batch/use.ts
index 631f47037..6be2c349b 100644
--- a/packages/vue/src/controls/undo-batch/use.ts
+++ b/packages/vue/src/controls/undo-batch/use.ts
@@ -1,6 +1,6 @@
import { tryOnScopeDispose, useTimeoutFn } from '@vueuse/core'
-import type { UndoManager } from '@open-pencil/core/scene-graph'
+import type { UndoManager } from '@open-pencil/scene-graph'
const BATCH_IDLE_MS = 300
diff --git a/packages/vue/src/controls/variable-binding/use.ts b/packages/vue/src/controls/variable-binding/use.ts
index 1580e40ee..14a73f8c9 100644
--- a/packages/vue/src/controls/variable-binding/use.ts
+++ b/packages/vue/src/controls/variable-binding/use.ts
@@ -1,7 +1,7 @@
import { useFilter } from 'reka-ui'
import { computed, ref } from 'vue'
-import type { Variable, VariableType } from '@open-pencil/core/scene-graph'
+import type { Variable, VariableType } from '@open-pencil/scene-graph'
import { useEditor } from '#vue/editor/context'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
diff --git a/packages/vue/src/editor/selection-state/use.ts b/packages/vue/src/editor/selection-state/use.ts
index 1b4430273..a0bed7aa8 100644
--- a/packages/vue/src/editor/selection-state/use.ts
+++ b/packages/vue/src/editor/selection-state/use.ts
@@ -1,6 +1,6 @@
import { computed } from 'vue'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { useEditor } from '#vue/editor/context'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
diff --git a/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue b/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue
index 341fe68e4..5c035881b 100644
--- a/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue
+++ b/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue
@@ -2,7 +2,7 @@
import { computed } from 'vue'
import { colorToHexRaw, parseColor } from '@open-pencil/core/color'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { OkHCLControls } from '#vue/primitives/ColorPicker/types'
const {
diff --git a/packages/vue/src/primitives/ColorPicker/ColorPickerRoot.vue b/packages/vue/src/primitives/ColorPicker/ColorPickerRoot.vue
index f9395a438..d5d8d68a1 100644
--- a/packages/vue/src/primitives/ColorPicker/ColorPickerRoot.vue
+++ b/packages/vue/src/primitives/ColorPicker/ColorPickerRoot.vue
@@ -3,7 +3,7 @@ import { computed } from 'vue'
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'
import { colorToCSS } from '@open-pencil/core/color'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export interface ColorPickerUi {
content?: string
diff --git a/packages/vue/src/primitives/ColorPicker/model.ts b/packages/vue/src/primitives/ColorPicker/model.ts
index c47a32cb0..1a68739d2 100644
--- a/packages/vue/src/primitives/ColorPicker/model.ts
+++ b/packages/vue/src/primitives/ColorPicker/model.ts
@@ -3,8 +3,8 @@ import type { Color as RekaColor, HSBColor, HSLColor, RGBColor } from 'reka-ui'
import { colorToCSS, okhclToRGBA, rgba255ToColor } from '@open-pencil/core/color'
import type { OkHCLColor } from '@open-pencil/core/color'
-import type { Fill, Stroke } from '@open-pencil/core/scene-graph'
-import type { Color } from '@open-pencil/core/types'
+import type { Fill, Stroke } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export interface ColorPickerModel {
rekaColor: RekaColor
diff --git a/packages/vue/src/primitives/FillPicker/FillPickerRoot.vue b/packages/vue/src/primitives/FillPicker/FillPickerRoot.vue
index ef6714c23..f505f9bf7 100644
--- a/packages/vue/src/primitives/FillPicker/FillPickerRoot.vue
+++ b/packages/vue/src/primitives/FillPicker/FillPickerRoot.vue
@@ -4,7 +4,7 @@ import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka
import { useFillPicker } from '#vue/primitives/FillPicker/useFillPicker'
-import type { Fill } from '@open-pencil/core/scene-graph'
+import type { Fill } from '@open-pencil/scene-graph'
export interface FillPickerUi {
content?: string
diff --git a/packages/vue/src/primitives/FillPicker/useFillPicker.ts b/packages/vue/src/primitives/FillPicker/useFillPicker.ts
index cd09b04a6..7760f76ea 100644
--- a/packages/vue/src/primitives/FillPicker/useFillPicker.ts
+++ b/packages/vue/src/primitives/FillPicker/useFillPicker.ts
@@ -1,7 +1,7 @@
import { computed, type Ref } from 'vue'
import { colorToCSS } from '@open-pencil/core/color'
-import type { Fill, GradientStop } from '@open-pencil/core/scene-graph'
+import type { Fill, GradientStop } from '@open-pencil/scene-graph'
type FillCategory = 'SOLID' | 'GRADIENT' | 'IMAGE'
diff --git a/packages/vue/src/primitives/GradientEditor/GradientEditorBar.vue b/packages/vue/src/primitives/GradientEditor/GradientEditorBar.vue
index 198b404fa..d906f050e 100644
--- a/packages/vue/src/primitives/GradientEditor/GradientEditorBar.vue
+++ b/packages/vue/src/primitives/GradientEditor/GradientEditorBar.vue
@@ -2,7 +2,7 @@
import { templateRef } from '@vueuse/core'
import { ref } from 'vue'
-import type { GradientStop } from '@open-pencil/core/scene-graph'
+import type { GradientStop } from '@open-pencil/scene-graph'
const { stops, ui } = defineProps<{
stops: GradientStop[]
diff --git a/packages/vue/src/primitives/GradientEditor/GradientEditorRoot.vue b/packages/vue/src/primitives/GradientEditor/GradientEditorRoot.vue
index 70b45a8dd..e276cbc1c 100644
--- a/packages/vue/src/primitives/GradientEditor/GradientEditorRoot.vue
+++ b/packages/vue/src/primitives/GradientEditor/GradientEditorRoot.vue
@@ -3,7 +3,7 @@ import { computed } from 'vue'
import { useGradientStops } from '#vue/primitives/GradientEditor/useGradientStops'
-import type { Fill } from '@open-pencil/core/scene-graph'
+import type { Fill } from '@open-pencil/scene-graph'
const { fill } = defineProps<{ fill: Fill }>()
const emit = defineEmits<{ update: [fill: Fill] }>()
diff --git a/packages/vue/src/primitives/GradientEditor/GradientEditorStop.vue b/packages/vue/src/primitives/GradientEditor/GradientEditorStop.vue
index 18df3da73..c0756b4b6 100644
--- a/packages/vue/src/primitives/GradientEditor/GradientEditorStop.vue
+++ b/packages/vue/src/primitives/GradientEditor/GradientEditorStop.vue
@@ -2,7 +2,7 @@
import { computed } from 'vue'
import { colorToCSS, colorToHexRaw } from '@open-pencil/core/color'
-import type { GradientStop } from '@open-pencil/core/scene-graph'
+import type { GradientStop } from '@open-pencil/scene-graph'
const { stop, index, active } = defineProps<{
stop: GradientStop
diff --git a/packages/vue/src/primitives/GradientEditor/useGradientStops.ts b/packages/vue/src/primitives/GradientEditor/useGradientStops.ts
index f2adf94d1..5669c6db2 100644
--- a/packages/vue/src/primitives/GradientEditor/useGradientStops.ts
+++ b/packages/vue/src/primitives/GradientEditor/useGradientStops.ts
@@ -1,8 +1,8 @@
import { computed, ref, type Ref } from 'vue'
import { colorToCSS, parseColor } from '@open-pencil/core/color'
-import type { Fill, GradientStop, GradientTransform } from '@open-pencil/core/scene-graph'
-import type { Color } from '@open-pencil/core/types'
+import type { Fill, GradientStop, GradientTransform } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
type GradientSubtype =
| 'GRADIENT_LINEAR'
diff --git a/packages/vue/src/primitives/LayoutControls/context.ts b/packages/vue/src/primitives/LayoutControls/context.ts
index 69be2aac7..6eebabeb8 100644
--- a/packages/vue/src/primitives/LayoutControls/context.ts
+++ b/packages/vue/src/primitives/LayoutControls/context.ts
@@ -1,7 +1,7 @@
import { inject, provide } from 'vue'
import type { InjectionKey, ShallowUnwrapRef } from 'vue'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { useLayout } from '#vue/controls/layout/use'
diff --git a/packages/vue/src/primitives/PropertyList/PropertyListRoot.vue b/packages/vue/src/primitives/PropertyList/PropertyListRoot.vue
index deb69a815..e887bf42e 100644
--- a/packages/vue/src/primitives/PropertyList/PropertyListRoot.vue
+++ b/packages/vue/src/primitives/PropertyList/PropertyListRoot.vue
@@ -7,7 +7,7 @@ import { useUndoBatch } from '#vue/controls/undo-batch/use'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
import { providePropertyList } from '#vue/primitives/PropertyList/context'
-import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/core/scene-graph'
+import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/scene-graph'
type ArrayPropKey = 'fills' | 'strokes' | 'effects'
type ArrayItemType = Fill | Stroke | Effect
diff --git a/packages/vue/src/primitives/PropertyList/context.ts b/packages/vue/src/primitives/PropertyList/context.ts
index 54456b4ab..0b10e2ef8 100644
--- a/packages/vue/src/primitives/PropertyList/context.ts
+++ b/packages/vue/src/primitives/PropertyList/context.ts
@@ -1,7 +1,7 @@
import { type ComputedRef, type InjectionKey, inject, provide } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
type ArrayPropKey = 'fills' | 'strokes' | 'effects'
diff --git a/packages/vue/src/shared/font-status/use.ts b/packages/vue/src/shared/font-status/use.ts
index 9f306155b..c720be2a9 100644
--- a/packages/vue/src/shared/font-status/use.ts
+++ b/packages/vue/src/shared/font-status/use.ts
@@ -1,8 +1,8 @@
import { computed } from 'vue'
import { DEFAULT_FONT_FAMILY } from '@open-pencil/core/constants'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import { fontManager } from '@open-pencil/core/text'
+import type { SceneNode } from '@open-pencil/scene-graph'
/**
* Returns missing-font information for a text node getter.
diff --git a/packages/vue/src/shared/input/auto-layout-hover.ts b/packages/vue/src/shared/input/auto-layout-hover.ts
index d0c4c0606..35e03e36e 100644
--- a/packages/vue/src/shared/input/auto-layout-hover.ts
+++ b/packages/vue/src/shared/input/auto-layout-hover.ts
@@ -4,7 +4,7 @@ import {
AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE
} from '@open-pencil/core/constants'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
type AutoLayoutHover = NonNullable<Editor['state']['autoLayoutHover']>
diff --git a/packages/vue/src/shared/input/auto-layout.ts b/packages/vue/src/shared/input/auto-layout.ts
index 554a8c32b..17554dd0c 100644
--- a/packages/vue/src/shared/input/auto-layout.ts
+++ b/packages/vue/src/shared/input/auto-layout.ts
@@ -1,7 +1,7 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import { resolveNodeLayoutDirection } from '@open-pencil/core/text'
-import type { Vector } from '@open-pencil/core/types'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import type { DragMove } from '#vue/shared/input/types'
diff --git a/packages/vue/src/shared/input/drop-target.ts b/packages/vue/src/shared/input/drop-target.ts
index 18e5833cf..8f2de53cb 100644
--- a/packages/vue/src/shared/input/drop-target.ts
+++ b/packages/vue/src/shared/input/drop-target.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
export function findMoveDropTarget(cx: number, cy: number, editor: Editor): SceneNode | null {
let dropTarget = editor.graph.hitTestFrame(
diff --git a/packages/vue/src/shared/input/geometry.ts b/packages/vue/src/shared/input/geometry.ts
index d058aa429..8acc28f7d 100644
--- a/packages/vue/src/shared/input/geometry.ts
+++ b/packages/vue/src/shared/input/geometry.ts
@@ -1,9 +1,9 @@
-import { getAbsoluteRotation, getWorldHandles } from '@open-pencil/core/canvas'
import { CORNER_ROTATE_ZONE, HANDLE_HIT_RADIUS } from '@open-pencil/core/constants'
import type { Editor } from '@open-pencil/core/editor'
-import { degToRad } from '@open-pencil/core/geometry'
-import type { SceneGraph, SceneNode } from '@open-pencil/core/scene-graph'
-import type { Vector } from '@open-pencil/core/types'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+import { getAbsoluteRotation, getWorldHandles } from '@open-pencil/scene-graph/coordinate'
+import { degToRad } from '@open-pencil/scene-graph/geometry'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import resizeCursorSvg from '#vue/shared/assets/resize-cursor.svg?raw'
import rotateCursorSvg from '#vue/shared/assets/rotate-cursor.svg?raw'
diff --git a/packages/vue/src/shared/input/move-snap.ts b/packages/vue/src/shared/input/move-snap.ts
index 3bec49882..3251132cc 100644
--- a/packages/vue/src/shared/input/move-snap.ts
+++ b/packages/vue/src/shared/input/move-snap.ts
@@ -1,6 +1,6 @@
import type { Editor } from '@open-pencil/core/editor'
-import { computeSelectionBounds, computeSnap } from '@open-pencil/core/scene-graph'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import { computeSelectionBounds, computeSnap } from '@open-pencil/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { DragMove } from '#vue/shared/input/types'
diff --git a/packages/vue/src/shared/input/node-edit/hit-test.ts b/packages/vue/src/shared/input/node-edit/hit-test.ts
index 2363f10ff..55a7a9351 100644
--- a/packages/vue/src/shared/input/node-edit/hit-test.ts
+++ b/packages/vue/src/shared/input/node-edit/hit-test.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { VectorSegment, VectorVertex } from '@open-pencil/core/scene-graph'
+import type { VectorSegment, VectorVertex } from '@open-pencil/scene-graph'
export type NodeEditState = {
nodeId: string
diff --git a/packages/vue/src/shared/input/node-edit/index.ts b/packages/vue/src/shared/input/node-edit/index.ts
index d2b85b04a..41483cadf 100644
--- a/packages/vue/src/shared/input/node-edit/index.ts
+++ b/packages/vue/src/shared/input/node-edit/index.ts
@@ -13,7 +13,7 @@ export {
NODE_HIT_THRESHOLD
} from '#vue/shared/input/node-edit/hit-test'
import type { Editor } from '@open-pencil/core/editor'
-import type { Vector } from '@open-pencil/core/types'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
type NodeEditEditor = Partial<{
nodeEditSelectVertex: (vertexIndex: number, addToSelection: boolean) => void
diff --git a/packages/vue/src/shared/input/resize.ts b/packages/vue/src/shared/input/resize.ts
index 9b4eb2025..cd2529ea9 100644
--- a/packages/vue/src/shared/input/resize.ts
+++ b/packages/vue/src/shared/input/resize.ts
@@ -2,7 +2,7 @@ export { constrainToAspectRatio } from '#vue/shared/input/resize/rect'
export { tryStartResize } from '#vue/shared/input/resize/start'
import type { Editor } from '@open-pencil/core/editor'
import { computeLayout } from '@open-pencil/core/layout'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { calculateResizeRect } from '#vue/shared/input/resize/rect'
import { scaleVectorNetworkForResize } from '#vue/shared/input/resize/vector'
diff --git a/packages/vue/src/shared/input/resize/rect.ts b/packages/vue/src/shared/input/resize/rect.ts
index fd3e258d9..6c612120d 100644
--- a/packages/vue/src/shared/input/resize/rect.ts
+++ b/packages/vue/src/shared/input/resize/rect.ts
@@ -1,4 +1,4 @@
-import type { Rect } from '@open-pencil/core/types'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
import type { HandlePosition } from '#vue/shared/input/types'
diff --git a/packages/vue/src/shared/input/resize/start.ts b/packages/vue/src/shared/input/resize/start.ts
index 23038c1a8..5a30711ae 100644
--- a/packages/vue/src/shared/input/resize/start.ts
+++ b/packages/vue/src/shared/input/resize/start.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import { cloneVectorNetwork } from '@open-pencil/core/scene-graph'
+import { cloneVectorNetwork } from '@open-pencil/scene-graph'
import { getHitHandleByMatrix } from '#vue/shared/input/geometry'
import type { DragResize, OrigChildState } from '#vue/shared/input/types'
diff --git a/packages/vue/src/shared/input/resize/vector.ts b/packages/vue/src/shared/input/resize/vector.ts
index 24a3869fd..5b05f0bdc 100644
--- a/packages/vue/src/shared/input/resize/vector.ts
+++ b/packages/vue/src/shared/input/resize/vector.ts
@@ -1,4 +1,4 @@
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
type VectorNetwork = NonNullable<SceneNode['vectorNetwork']>
diff --git a/packages/vue/src/shared/input/select.ts b/packages/vue/src/shared/input/select.ts
index 15df49372..30a79574f 100644
--- a/packages/vue/src/shared/input/select.ts
+++ b/packages/vue/src/shared/input/select.ts
@@ -3,7 +3,7 @@ export { resolveHit } from '#vue/shared/input/select/hit'
import { resolveHit } from '#vue/shared/input/select/hit'
export { updateHoverCursor } from '#vue/shared/input/select/hover'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { tryStartResize } from '#vue/shared/input/resize'
import { createSelectionMoveDrag, selectionIsLocked } from '#vue/shared/input/select/move'
diff --git a/packages/vue/src/shared/input/select/hit.ts b/packages/vue/src/shared/input/select/hit.ts
index 21a920787..fa2b80ea3 100644
--- a/packages/vue/src/shared/input/select/hit.ts
+++ b/packages/vue/src/shared/input/select/hit.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { HitTestFns } from '#vue/shared/input/select'
diff --git a/packages/vue/src/shared/input/select/hover.ts b/packages/vue/src/shared/input/select/hover.ts
index de5b8cf81..f8d4026b1 100644
--- a/packages/vue/src/shared/input/select/hover.ts
+++ b/packages/vue/src/shared/input/select/hover.ts
@@ -1,5 +1,5 @@
-import { getAbsoluteRotation } from '@open-pencil/core/canvas'
import type { Editor } from '@open-pencil/core/editor'
+import { getAbsoluteRotation } from '@open-pencil/scene-graph/coordinate'
import {
buildResizeCursor,
diff --git a/packages/vue/src/shared/input/types.ts b/packages/vue/src/shared/input/types.ts
index 934ac6513..63f09694a 100644
--- a/packages/vue/src/shared/input/types.ts
+++ b/packages/vue/src/shared/input/types.ts
@@ -1,6 +1,6 @@
import type { Tool } from '@open-pencil/core/editor'
-import type { NodeType, VectorNetwork } from '@open-pencil/core/scene-graph'
-import type { Rect, Vector } from '@open-pencil/core/types'
+import type { NodeType, VectorNetwork } from '@open-pencil/scene-graph'
+import type { Rect, Vector } from '@open-pencil/scene-graph/primitives'
export type HandlePosition = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
diff --git a/packages/vue/src/variables/helpers.ts b/packages/vue/src/variables/helpers.ts
index 6b51061be..b36a4d0e9 100644
--- a/packages/vue/src/variables/helpers.ts
+++ b/packages/vue/src/variables/helpers.ts
@@ -9,7 +9,7 @@ import type {
VariableCollection,
VariableType,
VariableValue
-} from '@open-pencil/core/scene-graph'
+} from '@open-pencil/scene-graph'
export function createVariableCollectionActions(editor: Editor, activeCollectionId: Ref<string>) {
function setActiveCollection(id: string) {
diff --git a/packages/vue/src/variables/table/helpers.ts b/packages/vue/src/variables/table/helpers.ts
index fc2acf3fd..fe2abd1e3 100644
--- a/packages/vue/src/variables/table/helpers.ts
+++ b/packages/vue/src/variables/table/helpers.ts
@@ -2,8 +2,8 @@ import type { ColumnDef } from '@tanstack/vue-table'
import { EditableArea, EditableInput, EditablePreview, EditableRoot } from 'reka-ui'
import { h, type Component, type ComputedRef } from 'vue'
-import type { Variable, VariableValue } from '@open-pencil/core/scene-graph'
-import type { Color } from '@open-pencil/core/types'
+import type { Variable, VariableValue } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export interface VariablesTableOptions {
activeModes: ComputedRef<{ modeId: string; name: string }[]>
diff --git a/packages/vue/src/variables/use.ts b/packages/vue/src/variables/use.ts
index 643454da8..05b6beb35 100644
--- a/packages/vue/src/variables/use.ts
+++ b/packages/vue/src/variables/use.ts
@@ -1,6 +1,6 @@
import { ref, computed, watch } from 'vue'
-import type { Variable } from '@open-pencil/core/scene-graph'
+import type { Variable } from '@open-pencil/scene-graph'
import { useEditor } from '#vue/editor/context'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
diff --git a/src/app/ai/acp/map-update.ts b/src/app/ai/acp/map-update.ts
index 7ac987a99..b2722cfb1 100644
--- a/src/app/ai/acp/map-update.ts
+++ b/src/app/ai/acp/map-update.ts
@@ -1,7 +1,7 @@
import type { SessionUpdate } from '@agentclientprotocol/sdk'
import type { UIMessageChunk } from 'ai'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
export interface MapResult {
chunks: UIMessageChunk[]
diff --git a/src/app/ai/debug/index.ts b/src/app/ai/debug/index.ts
index 41a54e3a4..d3857ac33 100644
--- a/src/app/ai/debug/index.ts
+++ b/src/app/ai/debug/index.ts
@@ -2,7 +2,7 @@ import type { UIMessage } from 'ai'
import { buildDebugLog } from '@open-pencil/core/tools'
import type { ToolDebugLog, ToolLogEntry } from '@open-pencil/core/tools'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
import { getStepUsages, getToolLogEntries } from '@/app/ai/tools'
diff --git a/src/app/ai/tools/index.ts b/src/app/ai/tools/index.ts
index 5e1cbce59..2436b37d9 100644
--- a/src/app/ai/tools/index.ts
+++ b/src/app/ai/tools/index.ts
@@ -3,9 +3,9 @@ import { tool } from 'ai'
import * as v from 'valibot'
import { computeAllLayouts } from '@open-pencil/core/layout'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import { CORE_TOOLS, toolsToAI } from '@open-pencil/core/tools'
import type { StepBudget, ToolLogEntry } from '@open-pencil/core/tools'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { makeFigmaFromStore } from '@/app/automation/bridge/figma-factory'
import { getActiveEditorStore } from '@/app/editor/active-store'
diff --git a/src/app/automation/bridge/tool-handlers.ts b/src/app/automation/bridge/tool-handlers.ts
index 5a3587cda..d5ca12889 100644
--- a/src/app/automation/bridge/tool-handlers.ts
+++ b/src/app/automation/bridge/tool-handlers.ts
@@ -2,7 +2,7 @@ import { renderTreeNode } from '@open-pencil/core/design-jsx'
import type { FigmaAPI } from '@open-pencil/core/figma-api'
import { computeAllLayouts } from '@open-pencil/core/layout'
import { ALL_TOOLS } from '@open-pencil/core/tools'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
import type { EditorStore } from '@/app/editor/active-store'
import { ensureGraphFonts } from '@/app/editor/fonts'
diff --git a/src/app/collab/awareness.ts b/src/app/collab/awareness.ts
index 4c0e4a143..8378167b3 100644
--- a/src/app/collab/awareness.ts
+++ b/src/app/collab/awareness.ts
@@ -2,7 +2,7 @@ import { ref } from 'vue'
import type * as awarenessProtocol from 'y-protocols/awareness'
import { randomIndex } from '@open-pencil/core/random'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { EditorStore } from '@/app/editor/active-store'
import { PEER_COLORS, ROOM_ID_CHARS, ROOM_ID_LENGTH } from '@/constants'
diff --git a/src/app/collab/types.ts b/src/app/collab/types.ts
index 5be403c47..ccb4ee4d8 100644
--- a/src/app/collab/types.ts
+++ b/src/app/collab/types.ts
@@ -1,4 +1,4 @@
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export interface RemotePeer {
clientId: number
diff --git a/src/app/collab/yjs-sync.ts b/src/app/collab/yjs-sync.ts
index 65d3fcdf3..be9c2195b 100644
--- a/src/app/collab/yjs-sync.ts
+++ b/src/app/collab/yjs-sync.ts
@@ -1,6 +1,6 @@
import * as Y from 'yjs'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { EditorStore } from '@/app/editor/active-store'
import { YJS_JSON_FIELDS } from '@/constants'
diff --git a/src/app/demo/colors.ts b/src/app/demo/colors.ts
index ba9bd4a3a..10c91fbb1 100644
--- a/src/app/demo/colors.ts
+++ b/src/app/demo/colors.ts
@@ -1,5 +1,5 @@
import { BLACK } from '@open-pencil/core/constants'
-import type { Color, Fill, GradientStop, Stroke } from '@open-pencil/core/scene-graph'
+import type { Color, Fill, GradientStop, Stroke } from '@open-pencil/scene-graph'
export const DEMO_COLORS = {
white: { r: 1, g: 1, b: 1, a: 1 },
diff --git a/src/app/demo/effects.ts b/src/app/demo/effects.ts
index 536f9809a..759a20db4 100644
--- a/src/app/demo/effects.ts
+++ b/src/app/demo/effects.ts
@@ -1,5 +1,5 @@
import { TRANSPARENT } from '@open-pencil/core/constants'
-import type { Color, Effect } from '@open-pencil/core/scene-graph'
+import type { Color, Effect } from '@open-pencil/scene-graph'
export function dropShadow(
ox = 0,
diff --git a/src/app/demo/sections/variables.ts b/src/app/demo/sections/variables.ts
index 8bb4d504c..47806dcd8 100644
--- a/src/app/demo/sections/variables.ts
+++ b/src/app/demo/sections/variables.ts
@@ -1,4 +1,4 @@
-import type { Color } from '@open-pencil/core/scene-graph'
+import type { Color } from '@open-pencil/scene-graph'
import { DEMO_COLORS } from '@/app/demo/colors'
import type { EditorStore } from '@/app/editor/session'
diff --git a/src/app/document/export/files.ts b/src/app/document/export/files.ts
index a6f3ce99b..407f8124c 100644
--- a/src/app/document/export/files.ts
+++ b/src/app/document/export/files.ts
@@ -8,7 +8,7 @@ import type {
RasterExportFormat
} from '@open-pencil/core/io'
import { renderNodesToImage } from '@open-pencil/core/io/formats/raster'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import type { ExportOptions } from '@/app/document/export/types'
import { isTauri } from '@/app/tauri/env'
diff --git a/src/app/document/io/imported-document.ts b/src/app/document/io/imported-document.ts
index 7a489cc23..09f734963 100644
--- a/src/app/document/io/imported-document.ts
+++ b/src/app/document/io/imported-document.ts
@@ -1,6 +1,6 @@
import type { Editor } from '@open-pencil/core/editor'
import { computeAllLayouts } from '@open-pencil/core/layout'
-import type { SceneGraph, SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
export async function applyImportedDocument(editor: Editor, imported: SceneGraph) {
const firstPage = imported.getPages()[0] as SceneNode | undefined
diff --git a/src/app/editor/fonts/index.ts b/src/app/editor/fonts/index.ts
index d715a2067..9fc624141 100644
--- a/src/app/editor/fonts/index.ts
+++ b/src/app/editor/fonts/index.ts
@@ -1,12 +1,12 @@
import { useLocalStorage } from '@vueuse/core'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
import {
fontManager,
styleToWeight,
type FontFamilyOption,
type LocalFontAccessState
} from '@open-pencil/core/text'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import {
clearDownloadedFontCache as clearTauriDownloadedFontCache,
diff --git a/src/app/editor/pen/create.ts b/src/app/editor/pen/create.ts
index 509b2fcd5..9acf24a1e 100644
--- a/src/app/editor/pen/create.ts
+++ b/src/app/editor/pen/create.ts
@@ -1,5 +1,5 @@
import type { Editor, Tool } from '@open-pencil/core/editor'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import {
absoluteVertices,
diff --git a/src/app/editor/pen/resume.ts b/src/app/editor/pen/resume.ts
index 6e15b93b3..41b248d8b 100644
--- a/src/app/editor/pen/resume.ts
+++ b/src/app/editor/pen/resume.ts
@@ -1,5 +1,5 @@
import type { EditorState } from '@open-pencil/core/editor'
-import type { SceneNode, VectorSegment, VectorVertex } from '@open-pencil/core/scene-graph'
+import type { SceneNode, VectorSegment, VectorVertex } from '@open-pencil/scene-graph'
export type PenState = EditorState
type PenStateInit = NonNullable<EditorState['penState']>
diff --git a/src/app/editor/session/create.ts b/src/app/editor/session/create.ts
index a7d983aea..90177381b 100644
--- a/src/app/editor/session/create.ts
+++ b/src/app/editor/session/create.ts
@@ -2,7 +2,7 @@ import { shallowReactive } from 'vue'
import { createEditor } from '@open-pencil/core/editor'
import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
-import { SceneGraph } from '@open-pencil/core/scene-graph'
+import { SceneGraph } from '@open-pencil/scene-graph'
import {
getActiveEditorStore,
diff --git a/src/app/editor/session/modules.ts b/src/app/editor/session/modules.ts
index 634bcb2aa..8226b1d22 100644
--- a/src/app/editor/session/modules.ts
+++ b/src/app/editor/session/modules.ts
@@ -2,7 +2,7 @@ import { computed } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
import type { IORegistry } from '@open-pencil/core/io'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import { createDocumentExportActions } from '@/app/document/export'
import { createDocumentIOActions } from '@/app/document/io'
diff --git a/src/app/editor/vector-edit/create.ts b/src/app/editor/vector-edit/create.ts
index 868f61561..32b68f4a5 100644
--- a/src/app/editor/vector-edit/create.ts
+++ b/src/app/editor/vector-edit/create.ts
@@ -1,5 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import { createVectorEditHandleActions } from './handle-actions'
import { createVectorEditLifecycle } from './lifecycle'
diff --git a/src/app/editor/vector-edit/handle-actions.ts b/src/app/editor/vector-edit/handle-actions.ts
index 6f0dc92e0..a83ca190c 100644
--- a/src/app/editor/vector-edit/handle-actions.ts
+++ b/src/app/editor/vector-edit/handle-actions.ts
@@ -1,6 +1,6 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { Vector } from '@open-pencil/core/types'
import { findAllHandles, findOppositeHandle, mirrorHandle } from '@open-pencil/core/vector'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import { constrainContinuousTangent } from './handles'
import { getLiveNetwork } from './network'
diff --git a/src/app/editor/vector-edit/handles.ts b/src/app/editor/vector-edit/handles.ts
index 92481216d..4ff9a6522 100644
--- a/src/app/editor/vector-edit/handles.ts
+++ b/src/app/editor/vector-edit/handles.ts
@@ -1,5 +1,5 @@
-import type { VectorSegment, VectorVertex } from '@open-pencil/core/scene-graph'
-import type { Vector } from '@open-pencil/core/types'
+import type { VectorSegment, VectorVertex } from '@open-pencil/scene-graph'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
import type { HandleInfo, NodeEditState } from './types'
diff --git a/src/app/editor/vector-edit/lifecycle.ts b/src/app/editor/vector-edit/lifecycle.ts
index 286387ce2..56012f656 100644
--- a/src/app/editor/vector-edit/lifecycle.ts
+++ b/src/app/editor/vector-edit/lifecycle.ts
@@ -1,7 +1,7 @@
import type { Editor } from '@open-pencil/core/editor'
-import { cloneVectorNetwork } from '@open-pencil/core/scene-graph'
-import type { SceneGraph, VectorNetwork } from '@open-pencil/core/scene-graph'
import { computeAccurateBounds } from '@open-pencil/core/vector'
+import { cloneVectorNetwork } from '@open-pencil/scene-graph'
+import type { SceneGraph, VectorNetwork } from '@open-pencil/scene-graph'
import { getLiveNetwork } from './network'
import type { VectorEditState } from './types'
diff --git a/src/app/editor/vector-edit/network.ts b/src/app/editor/vector-edit/network.ts
index 7c5166017..392ed6f6e 100644
--- a/src/app/editor/vector-edit/network.ts
+++ b/src/app/editor/vector-edit/network.ts
@@ -1,6 +1,6 @@
import type { Editor } from '@open-pencil/core/editor'
-import type { VectorNetwork } from '@open-pencil/core/scene-graph'
import { nearestPointOnNetwork, removeVertex, splitSegmentAt } from '@open-pencil/core/vector'
+import type { VectorNetwork } from '@open-pencil/scene-graph'
import type { NodeEditState, VectorEditState } from './types'
diff --git a/src/app/editor/vector-edit/types.ts b/src/app/editor/vector-edit/types.ts
index b04a6d400..81462e301 100644
--- a/src/app/editor/vector-edit/types.ts
+++ b/src/app/editor/vector-edit/types.ts
@@ -4,8 +4,8 @@ import type {
VectorRegion,
VectorSegment,
VectorVertex
-} from '@open-pencil/core/scene-graph'
-import type { Rect } from '@open-pencil/core/types'
+} from '@open-pencil/scene-graph'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
export type NodeEditState = {
nodeId: string
diff --git a/src/app/shell/menu/editor-actions.ts b/src/app/shell/menu/editor-actions.ts
index 4a3767cc2..812851524 100644
--- a/src/app/shell/menu/editor-actions.ts
+++ b/src/app/shell/menu/editor-actions.ts
@@ -1,4 +1,4 @@
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { useEditorStore } from '@/app/editor/active-store'
diff --git a/src/app/tabs/index.ts b/src/app/tabs/index.ts
index 12e403a7a..5c9ef809d 100644
--- a/src/app/tabs/index.ts
+++ b/src/app/tabs/index.ts
@@ -3,7 +3,7 @@ import { shallowRef, computed, triggerRef } from 'vue'
import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
import { readFigFile } from '@open-pencil/core/io/formats/fig'
import { computeAllLayouts } from '@open-pencil/core/layout'
-import type { SceneGraph } from '@open-pencil/core/scene-graph'
+import type { SceneGraph } from '@open-pencil/scene-graph'
import { setOpenPencilStore } from '@/app/browser-bridge'
import { setActiveEditorStore } from '@/app/editor/active-store'
diff --git a/src/components/AssetsPanel.vue b/src/components/AssetsPanel.vue
index 72c631d76..bfd10439a 100644
--- a/src/components/AssetsPanel.vue
+++ b/src/components/AssetsPanel.vue
@@ -9,7 +9,7 @@ import {
DialogTitle
} from 'reka-ui'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { useI18n } from '@open-pencil/vue'
import { nodeIcon } from '@/app/editor/icons'
diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vue
index 8e5b3aee3..c67de0853 100644
--- a/src/components/ChatPanel.vue
+++ b/src/components/ChatPanel.vue
@@ -18,7 +18,7 @@ import { useI18n } from '@open-pencil/vue'
import type { Chat } from '@ai-sdk/vue'
import type { UIMessage } from 'ai'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
const IS_DEV = import.meta.env.DEV
diff --git a/src/components/ColorPicker/ColorInput.vue b/src/components/ColorPicker/ColorInput.vue
index 1ca46acf3..91e8c7f19 100644
--- a/src/components/ColorPicker/ColorInput.vue
+++ b/src/components/ColorPicker/ColorInput.vue
@@ -5,7 +5,7 @@ import { ColorInputRoot, inputValue } from '@open-pencil/vue'
import ColorPicker from '@/components/ColorPicker/ColorPicker.vue'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { OkHCLControls } from '@open-pencil/vue'
defineOptions({ inheritAttrs: false })
diff --git a/src/components/ColorPicker/ColorPicker.vue b/src/components/ColorPicker/ColorPicker.vue
index 9eeae08c3..545f213e3 100644
--- a/src/components/ColorPicker/ColorPicker.vue
+++ b/src/components/ColorPicker/ColorPicker.vue
@@ -4,7 +4,7 @@ import { ColorPickerRoot } from '@open-pencil/vue'
import ColorPickerPanel from '@/components/ColorPickerPanel/ColorPickerPanel.vue'
import { usePopoverUI } from '@/components/ui/popover'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { OkHCLControls } from '@open-pencil/vue'
const { color, okhcl = null } = defineProps<{ color: Color; okhcl?: OkHCLControls | null }>()
diff --git a/src/components/ColorPickerPanel/ColorPickerPanel.vue b/src/components/ColorPickerPanel/ColorPickerPanel.vue
index d2573f600..2e9f5baeb 100644
--- a/src/components/ColorPickerPanel/ColorPickerPanel.vue
+++ b/src/components/ColorPickerPanel/ColorPickerPanel.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import type { OkHCLControls } from '@open-pencil/vue'
import ColorAreaControl from '@/components/ColorPickerPanel/ColorAreaControl.vue'
diff --git a/src/components/ColorPickerPanel/context.ts b/src/components/ColorPickerPanel/context.ts
index 90bbf7555..b68ee477c 100644
--- a/src/components/ColorPickerPanel/context.ts
+++ b/src/components/ColorPickerPanel/context.ts
@@ -1,7 +1,7 @@
import { computed, inject, provide, proxyRefs } from 'vue'
import type { InjectionKey, ShallowUnwrapRef } from 'vue'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
import {
createColorPickerModel,
createOkHCLSliderGradientModel,
diff --git a/src/components/FillPicker.vue b/src/components/FillPicker.vue
index 7286c1210..9a47db347 100644
--- a/src/components/FillPicker.vue
+++ b/src/components/FillPicker.vue
@@ -9,7 +9,7 @@ import ImageFillPicker from './ImageFillPicker.vue'
import Tip from './ui/Tip.vue'
import { usePopoverUI } from './ui/popover'
-import type { Fill } from '@open-pencil/core/scene-graph'
+import type { Fill } from '@open-pencil/scene-graph'
import type { OkHCLControls } from '@open-pencil/vue'
const TAB_BASE =
diff --git a/src/components/GradientEditor.vue b/src/components/GradientEditor.vue
index b84f5c3fc..8784ba1b3 100644
--- a/src/components/GradientEditor.vue
+++ b/src/components/GradientEditor.vue
@@ -12,7 +12,7 @@ import {
useI18n
} from '@open-pencil/vue'
-import type { Fill } from '@open-pencil/core/scene-graph'
+import type { Fill } from '@open-pencil/scene-graph'
const { fill } = defineProps<{ fill: Fill }>()
const emit = defineEmits<{ update: [fill: Fill] }>()
diff --git a/src/components/ImageFillPicker.vue b/src/components/ImageFillPicker.vue
index 161dfc9b9..f94b99ef9 100644
--- a/src/components/ImageFillPicker.vue
+++ b/src/components/ImageFillPicker.vue
@@ -6,7 +6,7 @@ import AppSelect from './ui/AppSelect.vue'
import { useEditorStore } from '@/app/editor/active-store'
-import type { Fill, ImageScaleMode } from '@open-pencil/core/scene-graph'
+import type { Fill, ImageScaleMode } from '@open-pencil/scene-graph'
const IMAGE_SCALE_MODES: { value: ImageScaleMode; label: string }[] = [
{ value: 'FILL', label: 'Fill' },
diff --git a/src/components/VariablesDialog.vue b/src/components/VariablesDialog.vue
index edcf05e40..6aa7b9b8c 100644
--- a/src/components/VariablesDialog.vue
+++ b/src/components/VariablesDialog.vue
@@ -39,7 +39,7 @@ import Tip from './ui/Tip.vue'
import { useDialogUI } from '@/components/ui/dialog'
import { useMenuUI } from '@/components/ui/menu'
-import type { VariableType } from '@open-pencil/core/scene-graph'
+import type { VariableType } from '@open-pencil/scene-graph'
const open = defineModel<boolean>('open', { default: false })
const cls = useDialogUI({ content: 'flex h-[75vh] w-[800px] max-w-[90vw] flex-col' })
diff --git a/src/components/properties/ColorStyleRow.vue b/src/components/properties/ColorStyleRow.vue
index b5094a1aa..7985d072f 100644
--- a/src/components/properties/ColorStyleRow.vue
+++ b/src/components/properties/ColorStyleRow.vue
@@ -15,7 +15,7 @@ import {
import { colorToHexRaw } from '@open-pencil/core/color'
import type { ColorVariableBindingApi } from '@/components/properties/color-style-row'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
const {
item,
diff --git a/src/components/properties/EffectsSection.vue b/src/components/properties/EffectsSection.vue
index 6bf66443a..197e4197b 100644
--- a/src/components/properties/EffectsSection.vue
+++ b/src/components/properties/EffectsSection.vue
@@ -9,7 +9,7 @@ import { PropertyListRoot, vTestId, useEffectsControls, useI18n } from '@open-pe
import { colorToCSS } from '@open-pencil/core/color'
-import type { Effect } from '@open-pencil/core/scene-graph'
+import type { Effect } from '@open-pencil/scene-graph'
const effectsCtx = useEffectsControls()
const { panels } = useI18n()
diff --git a/src/components/properties/FillSection.vue b/src/components/properties/FillSection.vue
index b40e359fc..d5b69d069 100644
--- a/src/components/properties/FillSection.vue
+++ b/src/components/properties/FillSection.vue
@@ -14,7 +14,7 @@ import { createFillOkhclAdapter } from '@/components/properties/fill-okhcl'
import { useIconButtonUI } from '@/components/ui/icon-button'
import { useSectionUI } from '@/components/ui/section'
-import type { Fill, SceneNode } from '@open-pencil/core/scene-graph'
+import type { Fill, SceneNode } from '@open-pencil/scene-graph'
const fillCtx = useFillControls()
const okhcl = useOkHCL()
diff --git a/src/components/properties/LayoutSection/AutoLayoutControls.vue b/src/components/properties/LayoutSection/AutoLayoutControls.vue
index 0dcdb6b43..19764694f 100644
--- a/src/components/properties/LayoutSection/AutoLayoutControls.vue
+++ b/src/components/properties/LayoutSection/AutoLayoutControls.vue
@@ -2,7 +2,7 @@
import Tip from '@/components/ui/Tip.vue'
import { vTestId, useI18n, useLayoutControlsContext } from '@open-pencil/vue'
-import type { LayoutMode } from '@open-pencil/core/scene-graph'
+import type { LayoutMode } from '@open-pencil/scene-graph'
const ctx = useLayoutControlsContext()
diff --git a/src/components/properties/LayoutSection/FlexControls.vue b/src/components/properties/LayoutSection/FlexControls.vue
index 6b3a30ebe..41833341d 100644
--- a/src/components/properties/LayoutSection/FlexControls.vue
+++ b/src/components/properties/LayoutSection/FlexControls.vue
@@ -19,7 +19,7 @@ import PaddingControls from '@/components/properties/LayoutSection/PaddingContro
import { useSelectUI } from '@/components/ui/select'
import { useI18n, useLayoutControlsContext } from '@open-pencil/vue'
-import type { LayoutDirection, LayoutAlign } from '@open-pencil/core/scene-graph'
+import type { LayoutDirection, LayoutAlign } from '@open-pencil/scene-graph'
const ctx = useLayoutControlsContext()
const gapFieldRef = ref<HTMLElement | null>(null)
diff --git a/src/components/properties/LayoutSection/GridControls.vue b/src/components/properties/LayoutSection/GridControls.vue
index e382c240b..87c327797 100644
--- a/src/components/properties/LayoutSection/GridControls.vue
+++ b/src/components/properties/LayoutSection/GridControls.vue
@@ -4,7 +4,7 @@ import ScrubInput from '@/components/ScrubInput.vue'
import { useI18n, useLayoutControlsContext } from '@open-pencil/vue'
import type { GridTrackProp } from '@/components/properties/LayoutSection/types'
-import type { GridTrackSizing } from '@open-pencil/core/scene-graph'
+import type { GridTrackSizing } from '@open-pencil/scene-graph'
const ctx = useLayoutControlsContext()
diff --git a/src/components/properties/LayoutSection/SizeControls.vue b/src/components/properties/LayoutSection/SizeControls.vue
index e0073b3a5..f21651d4a 100644
--- a/src/components/properties/LayoutSection/SizeControls.vue
+++ b/src/components/properties/LayoutSection/SizeControls.vue
@@ -25,7 +25,7 @@ import {
useNumberVariableBinding
} from '@open-pencil/vue'
-import type { LayoutSizing } from '@open-pencil/core/scene-graph'
+import type { LayoutSizing } from '@open-pencil/scene-graph'
import type { SizeLimitProp, TestId } from '@open-pencil/vue'
type SizeSelectValue = LayoutSizing | `add-${SizeLimitProp}` | `remove-${SizeLimitProp}`
diff --git a/src/components/properties/StrokeSection.vue b/src/components/properties/StrokeSection.vue
index c70d4bc7b..92ca5114f 100644
--- a/src/components/properties/StrokeSection.vue
+++ b/src/components/properties/StrokeSection.vue
@@ -19,7 +19,7 @@ import Tip from '@/components/ui/Tip.vue'
import { useIconButtonUI } from '@/components/ui/icon-button'
import { useSectionUI } from '@/components/ui/section'
-import type { Color, SceneNode, Stroke } from '@open-pencil/core/scene-graph'
+import type { Color, SceneNode, Stroke } from '@open-pencil/scene-graph'
const strokeCtx = useStrokeControls()
const strokeVarCtx = useColorVariableBinding('strokes')
diff --git a/src/components/properties/VariablePickerPopover.vue b/src/components/properties/VariablePickerPopover.vue
index a3cf6fa6b..b9c908083 100644
--- a/src/components/properties/VariablePickerPopover.vue
+++ b/src/components/properties/VariablePickerPopover.vue
@@ -16,7 +16,7 @@ import { vTestId } from '@open-pencil/vue'
import { useTooltipUI } from '@/components/ui/tooltip'
-import type { Variable } from '@open-pencil/core/scene-graph'
+import type { Variable } from '@open-pencil/scene-graph'
const searchTerm = defineModel<string>('searchTerm', { default: '' })
diff --git a/src/components/properties/color-style-row.ts b/src/components/properties/color-style-row.ts
index 215b40c0e..63697dfbb 100644
--- a/src/components/properties/color-style-row.ts
+++ b/src/components/properties/color-style-row.ts
@@ -1,5 +1,5 @@
import { colorToCSS } from '@open-pencil/core/color'
-import type { Color, Fill, Variable } from '@open-pencil/core/scene-graph'
+import type { Color, Fill, Variable } from '@open-pencil/scene-graph'
export type ColorVariableBindingApi = {
store: {
diff --git a/src/components/properties/fill-label.ts b/src/components/properties/fill-label.ts
index fc46c57ec..17a735edb 100644
--- a/src/components/properties/fill-label.ts
+++ b/src/components/properties/fill-label.ts
@@ -1,5 +1,5 @@
import { colorToHexRaw } from '@open-pencil/core/color'
-import type { Fill, Variable } from '@open-pencil/core/scene-graph'
+import type { Fill, Variable } from '@open-pencil/scene-graph'
export function fillLabel(fill: Fill, boundVariable?: Variable): string {
if (boundVariable) return boundVariable.name
diff --git a/src/components/properties/fill-okhcl.ts b/src/components/properties/fill-okhcl.ts
index 13a4907c1..6a03a26cd 100644
--- a/src/components/properties/fill-okhcl.ts
+++ b/src/components/properties/fill-okhcl.ts
@@ -1,4 +1,4 @@
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import type { useOkHCL } from '@open-pencil/vue'
type OkhclControls = ReturnType<typeof useOkHCL>
diff --git a/src/constants.ts b/src/constants.ts
index d33e37c56..15f6a05fa 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -59,7 +59,7 @@ export {
RULER_MAJOR_TOLERANCE
} from '@open-pencil/core/constants'
-import type { Color } from '@open-pencil/core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
export const TRYSTERO_APP_ID = 'openpencil'
export const ROOM_ID_LENGTH = 8
diff --git a/tests/engine/app/variables-editor.test.ts b/tests/engine/app/variables-editor.test.ts
index a32118a8d..06c71c192 100644
--- a/tests/engine/app/variables-editor.test.ts
+++ b/tests/engine/app/variables-editor.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, test } from 'bun:test'
import { ref } from 'vue'
import type { Editor } from '@open-pencil/core/editor'
-import type { Variable, VariableCollection } from '@open-pencil/core/scene-graph'
+import type { Variable, VariableCollection } from '@open-pencil/scene-graph'
import { createVariableCollectionActions, createVariableValueActions } from '#vue/variables/helpers'
diff --git a/tests/engine/cli/dom.test.ts b/tests/engine/cli/dom.test.ts
index 94bbd2d5e..d004dde7c 100644
--- a/tests/engine/cli/dom.test.ts
+++ b/tests/engine/cli/dom.test.ts
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { parseFigFile } from '@open-pencil/core/io'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { cliSourcePath } from '#tests/helpers/paths'
diff --git a/tests/engine/dom-css/conversion.test.ts b/tests/engine/dom-css/conversion.test.ts
index 8e457ace0..a35a68537 100644
--- a/tests/engine/dom-css/conversion.test.ts
+++ b/tests/engine/dom-css/conversion.test.ts
@@ -1,6 +1,5 @@
import { describe, expect, it } from 'bun:test'
-import type { SceneGraph, SceneNode } from '@open-pencil/core/scene-graph'
import type { DesignElement } from '@open-pencil/dom-css'
import {
compileTailwindCSS,
@@ -12,6 +11,7 @@ import {
serializeHTML,
tailwindHTMLToSceneGraph
} from '@open-pencil/dom-css'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import {
DOM_CSS_COLORS,
diff --git a/tests/engine/editor/clipboard/paste-target.test.ts b/tests/engine/editor/clipboard/paste-target.test.ts
index 75eede56c..a6da637c2 100644
--- a/tests/engine/editor/clipboard/paste-target.test.ts
+++ b/tests/engine/editor/clipboard/paste-target.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'bun:test'
import { createEditor, type EditorState } from '@open-pencil/core/editor'
-import { SceneGraph } from '@open-pencil/core/scene-graph'
+import { SceneGraph } from '@open-pencil/scene-graph'
import { resolvePasteTarget } from '#core/editor/clipboard/paste-target'
diff --git a/tests/engine/geometry/text-visual-bounds.test.ts b/tests/engine/geometry/text-visual-bounds.test.ts
index f3621f6c3..220799909 100644
--- a/tests/engine/geometry/text-visual-bounds.test.ts
+++ b/tests/engine/geometry/text-visual-bounds.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'bun:test'
-import { nodeVisualBounds } from '#core/geometry'
-import type { SceneNode } from '#core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { nodeVisualBounds } from '@open-pencil/scene-graph/geometry'
describe('text visual bounds', () => {
test('includes decoration overflow below text nodes', () => {
diff --git a/tests/engine/geometry/visual-bounds.test.ts b/tests/engine/geometry/visual-bounds.test.ts
index 71390ea94..0257e8e21 100644
--- a/tests/engine/geometry/visual-bounds.test.ts
+++ b/tests/engine/geometry/visual-bounds.test.ts
@@ -1,8 +1,10 @@
import { describe, test, expect } from 'bun:test'
import type { Vector } from '@open-pencil/core'
-
-import { computeDescendantVisualBounds, computeVisualBounds } from '#core/geometry'
+import {
+ computeDescendantVisualBounds,
+ computeVisualBounds
+} from '@open-pencil/scene-graph/geometry'
function commandsBlobFromPoints(points: Vector[]): Uint8Array {
const blob = new Uint8Array(points.length * 9 + 1)
diff --git a/tests/engine/io/fig/export/boolean-operation.test.ts b/tests/engine/io/fig/export/boolean-operation.test.ts
index 45349af4b..8889ccf18 100644
--- a/tests/engine/io/fig/export/boolean-operation.test.ts
+++ b/tests/engine/io/fig/export/boolean-operation.test.ts
@@ -1,9 +1,9 @@
import { describe, expect, test } from 'bun:test'
import { createNodeChangesMessage, encodeMessage, initCodec } from '@open-pencil/kiwi/fig/codec'
+import { SceneGraph } from '@open-pencil/scene-graph'
import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
-import { SceneGraph } from '#core/scene-graph'
describe('Figma boolean operation export', () => {
test('exports boolean operation node type and operation', () => {
diff --git a/tests/engine/io/fig/export/font-variations.test.ts b/tests/engine/io/fig/export/font-variations.test.ts
index 06cca0e3f..d66b261eb 100644
--- a/tests/engine/io/fig/export/font-variations.test.ts
+++ b/tests/engine/io/fig/export/font-variations.test.ts
@@ -1,7 +1,8 @@
import { describe, expect, test } from 'bun:test'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
-import { SceneGraph } from '#core/scene-graph'
describe('Figma font variation export', () => {
test('exports base and styled-run variable font axes', () => {
diff --git a/tests/engine/io/fig/export/masks.test.ts b/tests/engine/io/fig/export/masks.test.ts
index 789f88b4a..eb283bb42 100644
--- a/tests/engine/io/fig/export/masks.test.ts
+++ b/tests/engine/io/fig/export/masks.test.ts
@@ -1,7 +1,8 @@
import { describe, expect, test } from 'bun:test'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
-import { SceneGraph } from '#core/scene-graph'
describe('Figma mask export', () => {
test('exports schema mask fields', () => {
diff --git a/tests/engine/io/fig/export/paint-schema-fields.test.ts b/tests/engine/io/fig/export/paint-schema-fields.test.ts
index 6d7753c57..e10f19949 100644
--- a/tests/engine/io/fig/export/paint-schema-fields.test.ts
+++ b/tests/engine/io/fig/export/paint-schema-fields.test.ts
@@ -1,7 +1,8 @@
import { describe, expect, test } from 'bun:test'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
-import { SceneGraph } from '#core/scene-graph'
describe('Figma paint schema field export', () => {
test('exports pattern, noise, and custom fill metadata', () => {
diff --git a/tests/engine/io/fig/export/text.test.ts b/tests/engine/io/fig/export/text.test.ts
index f71a327d3..b22a2d71a 100644
--- a/tests/engine/io/fig/export/text.test.ts
+++ b/tests/engine/io/fig/export/text.test.ts
@@ -7,7 +7,7 @@ import {
parseFigFile,
SceneGraph
} from '@open-pencil/core'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
import { expectDefined } from '#tests/helpers/assert'
import { parseFixture } from '#tests/helpers/fig-fixtures'
diff --git a/tests/engine/io/fig/import/derived-symbol-data.test.ts b/tests/engine/io/fig/import/derived-symbol-data.test.ts
index 41ec28726..6633369ce 100644
--- a/tests/engine/io/fig/import/derived-symbol-data.test.ts
+++ b/tests/engine/io/fig/import/derived-symbol-data.test.ts
@@ -1,9 +1,10 @@
import { describe, expect, test } from 'bun:test'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import type { OverrideContext } from '#core/kiwi/fig/instance-overrides'
import { buildDsdLayoutUpdates } from '#core/kiwi/fig/instance-overrides/derived-symbol-data/layout'
import { propagateDsdChanges } from '#core/kiwi/fig/instance-overrides/derived-symbol-data/propagate'
-import { SceneGraph } from '#core/scene-graph'
function pageId(graph: SceneGraph): string {
return graph.getPages()[0].id
diff --git a/tests/engine/io/fig/import/field-protection.test.ts b/tests/engine/io/fig/import/field-protection.test.ts
index 11acef952..b9de4844c 100644
--- a/tests/engine/io/fig/import/field-protection.test.ts
+++ b/tests/engine/io/fig/import/field-protection.test.ts
@@ -1,9 +1,10 @@
import { describe, expect, test } from 'bun:test'
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type { Fill, Stroke } from '@open-pencil/scene-graph'
+
import { protectField, type ProtectionMap } from '#core/kiwi/fig/instance-overrides/patches'
import { syncNodeProps } from '#core/kiwi/fig/instance-overrides/sync'
-import { SceneGraph } from '#core/scene-graph'
-import type { Fill, Stroke } from '#core/scene-graph'
function pageId(graph: SceneGraph): string {
return graph.getPages()[0].id
diff --git a/tests/engine/io/fig/import/lazy-pages.test.ts b/tests/engine/io/fig/import/lazy-pages.test.ts
index 54146816e..5a6f2ed1d 100644
--- a/tests/engine/io/fig/import/lazy-pages.test.ts
+++ b/tests/engine/io/fig/import/lazy-pages.test.ts
@@ -5,7 +5,7 @@ import {
populateLazyFigImportRoots,
setLazyFigImportContext
} from '@open-pencil/core/kiwi/fig/lazy-import'
-import { SceneGraph } from '@open-pencil/core/scene-graph'
+import { SceneGraph } from '@open-pencil/scene-graph'
function createLazyGraph() {
const graph = new SceneGraph()
diff --git a/tests/engine/io/fig/import/mask-oracle.test.ts b/tests/engine/io/fig/import/mask-oracle.test.ts
index b4386016b..6ee1f7df3 100644
--- a/tests/engine/io/fig/import/mask-oracle.test.ts
+++ b/tests/engine/io/fig/import/mask-oracle.test.ts
@@ -2,10 +2,10 @@ import { describe, expect, test } from 'bun:test'
import { readFileSync } from 'node:fs'
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
+import { SceneGraph, type MaskType } from '@open-pencil/scene-graph'
import { nodeChangeToProps } from '#core/kiwi/fig/node-change/convert'
import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
-import { SceneGraph, type MaskType } from '#core/scene-graph'
interface MaskOracleEntry {
isMask: boolean
diff --git a/tests/engine/io/fig/import/pattern-paint-oracle.test.ts b/tests/engine/io/fig/import/pattern-paint-oracle.test.ts
index 26863ecb5..2b92ee7c4 100644
--- a/tests/engine/io/fig/import/pattern-paint-oracle.test.ts
+++ b/tests/engine/io/fig/import/pattern-paint-oracle.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'bun:test'
import { readFileSync } from 'node:fs'
-import type { Vector } from '#core/types'
+import type { Vector } from '@open-pencil/scene-graph/primitives'
interface PatternOracleFill {
type: string
diff --git a/tests/engine/io/fig/import/raw-metadata-oracle.test.ts b/tests/engine/io/fig/import/raw-metadata-oracle.test.ts
index 910b55876..94699a8cf 100644
--- a/tests/engine/io/fig/import/raw-metadata-oracle.test.ts
+++ b/tests/engine/io/fig/import/raw-metadata-oracle.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'bun:test'
import { readFileSync } from 'node:fs'
-import type { Color } from '#core/types'
+import type { Color } from '@open-pencil/scene-graph/primitives'
interface RawMetadataOracle {
page: {
diff --git a/tests/engine/io/fig/import/rich-text-oracle.test.ts b/tests/engine/io/fig/import/rich-text-oracle.test.ts
index 6e60bc07f..1715c3f70 100644
--- a/tests/engine/io/fig/import/rich-text-oracle.test.ts
+++ b/tests/engine/io/fig/import/rich-text-oracle.test.ts
@@ -2,10 +2,10 @@ import { describe, expect, test } from 'bun:test'
import { readFileSync } from 'node:fs'
import type { NodeChange, Paint } from '@open-pencil/kiwi/fig/codec'
+import { SceneGraph } from '@open-pencil/scene-graph'
import { nodeChangeToProps } from '#core/kiwi/fig/node-change/convert'
import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
-import { SceneGraph } from '#core/scene-graph'
interface OracleColor {
r: number
diff --git a/tests/engine/io/fig/roundtrip/exhaustive.test.ts b/tests/engine/io/fig/roundtrip/exhaustive.test.ts
index 5bf0d8efe..7bd55a8f2 100644
--- a/tests/engine/io/fig/roundtrip/exhaustive.test.ts
+++ b/tests/engine/io/fig/roundtrip/exhaustive.test.ts
@@ -11,7 +11,7 @@ import {
type SceneGraph,
type SceneNode
} from '@open-pencil/core'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
import {
type Mismatch,
diff --git a/tests/engine/io/fig/roundtrip/helpers.ts b/tests/engine/io/fig/roundtrip/helpers.ts
index 198eab600..44e128893 100644
--- a/tests/engine/io/fig/roundtrip/helpers.ts
+++ b/tests/engine/io/fig/roundtrip/helpers.ts
@@ -1,5 +1,5 @@
import type { SceneGraph, SceneNode } from '@open-pencil/core'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
import { verifyComponentPropDefs, verifyDerivedTextData } from './raw-verifiers/helpers'
diff --git a/tests/engine/io/fig/roundtrip/raw-verifiers/helpers.ts b/tests/engine/io/fig/roundtrip/raw-verifiers/helpers.ts
index aeb92e739..028d35cf7 100644
--- a/tests/engine/io/fig/roundtrip/raw-verifiers/helpers.ts
+++ b/tests/engine/io/fig/roundtrip/raw-verifiers/helpers.ts
@@ -1,4 +1,4 @@
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
import type { VerifierContext } from '../helpers'
diff --git a/tests/engine/io/subgraph.test.ts b/tests/engine/io/subgraph.test.ts
index ad80c7bbd..1531fe705 100644
--- a/tests/engine/io/subgraph.test.ts
+++ b/tests/engine/io/subgraph.test.ts
@@ -3,9 +3,9 @@ import { readFileSync } from 'node:fs'
import { exportFigFile, extractExportGraph, parseFigFile } from '@open-pencil/core/io'
import { initCodec } from '@open-pencil/core/kiwi'
-import { SceneGraph } from '@open-pencil/core/scene-graph'
import { guidToString } from '@open-pencil/kiwi/fig/guid'
import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { SceneGraph } from '@open-pencil/scene-graph'
describe('export subgraph extraction', () => {
test('page extraction keeps the source root and page descendants', () => {
diff --git a/tests/engine/perf.bench.ts b/tests/engine/perf.bench.ts
index 66e7371f3..983d4c4b3 100644
--- a/tests/engine/perf.bench.ts
+++ b/tests/engine/perf.bench.ts
@@ -4,8 +4,7 @@ import { resolve } from 'node:path'
import { bench, group, run } from 'mitata'
import { parseFigFile, exportFigFile, initCodec, SceneGraph } from '@open-pencil/core'
-
-import { copyFills } from '#core/scene-graph/copy'
+import { copyFills } from '@open-pencil/scene-graph/copy'
const FIXTURES = resolve(import.meta.dir, '../fixtures')
diff --git a/tests/engine/render/canvas/blend.test.ts b/tests/engine/render/canvas/blend.test.ts
index 11bb5a000..f1a56c901 100644
--- a/tests/engine/render/canvas/blend.test.ts
+++ b/tests/engine/render/canvas/blend.test.ts
@@ -2,11 +2,12 @@ import { describe, expect, mock, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type { BlendMode, Fill, SceneNode } from '@open-pencil/scene-graph'
+
import { figmaBlendModeToSkia } from '#core/canvas/blend'
import type { SkiaRenderer } from '#core/canvas/renderer'
import { renderNode, renderSection } from '#core/canvas/scene'
-import { SceneGraph } from '#core/scene-graph'
-import type { BlendMode, Fill, SceneNode } from '#core/scene-graph'
function pageId(graph: SceneGraph) {
return graph.getPages()[0].id
diff --git a/tests/engine/render/canvas/boolean.test.ts b/tests/engine/render/canvas/boolean.test.ts
index 907bf6572..e47b8e91d 100644
--- a/tests/engine/render/canvas/boolean.test.ts
+++ b/tests/engine/render/canvas/boolean.test.ts
@@ -1,11 +1,12 @@
import { describe, expect, test } from 'bun:test'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { initCanvasKit } from '#cli/headless'
import { makeBooleanOperationPath } from '#core/canvas/boolean'
import type { SkiaRenderer } from '#core/canvas/renderer'
import { makeNodeShapePath, makePolygonPath, makeRRect } from '#core/canvas/shapes'
import { BLACK } from '#core/constants'
-import type { SceneNode } from '#core/scene-graph'
import { createAPI } from '#tests/engine/figma/api/helpers'
diff --git a/tests/engine/render/canvas/corner-smoothing.test.ts b/tests/engine/render/canvas/corner-smoothing.test.ts
index 5da92e978..5edace20e 100644
--- a/tests/engine/render/canvas/corner-smoothing.test.ts
+++ b/tests/engine/render/canvas/corner-smoothing.test.ts
@@ -2,10 +2,11 @@ import { describe, expect, mock, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import { drawNodeFill } from '#core/canvas/fills'
import type { SkiaRenderer } from '#core/canvas/renderer'
import { makeSmoothRRectPath } from '#core/canvas/shapes'
-import { SceneGraph } from '#core/scene-graph'
function pageId(graph: SceneGraph) {
return graph.getPages()[0].id
diff --git a/tests/engine/render/canvas/culling.test.ts b/tests/engine/render/canvas/culling.test.ts
index c0c58c63f..ff046e4ee 100644
--- a/tests/engine/render/canvas/culling.test.ts
+++ b/tests/engine/render/canvas/culling.test.ts
@@ -1,8 +1,9 @@
import { describe, expect, mock, test } from 'bun:test'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import { renderNode } from '#core/canvas/scene'
-import { SceneGraph } from '#core/scene-graph'
function pageId(graph: SceneGraph) {
return graph.getPages()[0].id
diff --git a/tests/engine/render/canvas/effects/edge-cases.test.ts b/tests/engine/render/canvas/effects/edge-cases.test.ts
index a6ae81584..04acaa02a 100644
--- a/tests/engine/render/canvas/effects/edge-cases.test.ts
+++ b/tests/engine/render/canvas/effects/edge-cases.test.ts
@@ -2,8 +2,9 @@ import { describe, expect, mock, test } from 'bun:test'
import type { Canvas, Path } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { renderEffects } from '#core/canvas/shadows'
-import type { SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer, mockCalls } from './helpers'
diff --git a/tests/engine/render/canvas/effects/inner-shadow.test.ts b/tests/engine/render/canvas/effects/inner-shadow.test.ts
index b6b308d40..911410544 100644
--- a/tests/engine/render/canvas/effects/inner-shadow.test.ts
+++ b/tests/engine/render/canvas/effects/inner-shadow.test.ts
@@ -2,8 +2,9 @@ import { describe, expect, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { renderEffects } from '#core/canvas/shadows'
-import type { SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer } from './helpers'
diff --git a/tests/engine/render/canvas/effects/ordering.test.ts b/tests/engine/render/canvas/effects/ordering.test.ts
index 6c44d76df..7830e794b 100644
--- a/tests/engine/render/canvas/effects/ordering.test.ts
+++ b/tests/engine/render/canvas/effects/ordering.test.ts
@@ -2,9 +2,10 @@ import { describe, expect, mock, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import { createDefaultNode } from '@open-pencil/scene-graph/node-defaults'
+
import { renderShapeUncached } from '#core/canvas/scene'
-import type { SceneGraph } from '#core/scene-graph'
-import { createDefaultNode } from '#core/scene-graph/node-defaults'
import { createMockCanvas, createMockRenderer } from './helpers'
diff --git a/tests/engine/render/canvas/effects/path-shapes.test.ts b/tests/engine/render/canvas/effects/path-shapes.test.ts
index 9b3df6e2a..6ed82a356 100644
--- a/tests/engine/render/canvas/effects/path-shapes.test.ts
+++ b/tests/engine/render/canvas/effects/path-shapes.test.ts
@@ -2,8 +2,9 @@ import { describe, expect, mock, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { renderEffects } from '#core/canvas/shadows'
-import type { SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer, mockCalls } from './helpers'
diff --git a/tests/engine/render/canvas/effects/spread.test.ts b/tests/engine/render/canvas/effects/spread.test.ts
index 288b66a3f..acbd90672 100644
--- a/tests/engine/render/canvas/effects/spread.test.ts
+++ b/tests/engine/render/canvas/effects/spread.test.ts
@@ -2,8 +2,9 @@ import { describe, expect, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { renderEffects } from '#core/canvas/shadows'
-import type { SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer } from './helpers'
diff --git a/tests/engine/render/canvas/effects/text-shadow.test.ts b/tests/engine/render/canvas/effects/text-shadow.test.ts
index c54ac4d4e..23fd3ff1c 100644
--- a/tests/engine/render/canvas/effects/text-shadow.test.ts
+++ b/tests/engine/render/canvas/effects/text-shadow.test.ts
@@ -2,8 +2,9 @@ import { describe, expect, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { renderEffects } from '#core/canvas/shadows'
-import type { SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer } from './helpers'
diff --git a/tests/engine/render/canvas/effects/types.test.ts b/tests/engine/render/canvas/effects/types.test.ts
index 1fa698ae3..ac5ac9473 100644
--- a/tests/engine/render/canvas/effects/types.test.ts
+++ b/tests/engine/render/canvas/effects/types.test.ts
@@ -2,10 +2,11 @@ import { describe, expect, mock, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { applyClippedBlur } from '#core/canvas/effects'
import { renderNode } from '#core/canvas/scene'
import { renderEffects } from '#core/canvas/shadows'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer, mockCalls } from './helpers'
diff --git a/tests/engine/render/canvas/font-readiness.test.ts b/tests/engine/render/canvas/font-readiness.test.ts
index 792d32cf1..b41378f7b 100644
--- a/tests/engine/render/canvas/font-readiness.test.ts
+++ b/tests/engine/render/canvas/font-readiness.test.ts
@@ -1,7 +1,8 @@
import { describe, expect, test } from 'bun:test'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { isNodeFontLoaded } from '#core/canvas/text'
-import type { SceneNode } from '#core/scene-graph'
import { fontManager } from '#core/text/fonts'
describe('canvas text font readiness', () => {
diff --git a/tests/engine/render/canvas/image-fill.test.ts b/tests/engine/render/canvas/image-fill.test.ts
index 18a74ca53..ddf574f28 100644
--- a/tests/engine/render/canvas/image-fill.test.ts
+++ b/tests/engine/render/canvas/image-fill.test.ts
@@ -1,8 +1,9 @@
import { describe, expect, mock, test } from 'bun:test'
+import type { Fill, SceneNode } from '@open-pencil/scene-graph'
+
import { makeImageFillLocalMatrix, patternTileLayout } from '#core/canvas/fills'
import type { SkiaRenderer } from '#core/canvas/renderer'
-import type { Fill, SceneNode } from '#core/scene-graph'
function createRenderer() {
return {
diff --git a/tests/engine/render/canvas/layout-grids.test.ts b/tests/engine/render/canvas/layout-grids.test.ts
index b3a3e94d6..fc1e01b00 100644
--- a/tests/engine/render/canvas/layout-grids.test.ts
+++ b/tests/engine/render/canvas/layout-grids.test.ts
@@ -2,8 +2,9 @@ import { describe, expect, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { drawLayoutGrids } from '#core/canvas/layout-grids'
-import type { SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer, mockCalls } from './effects/helpers'
diff --git a/tests/engine/render/canvas/masks.test.ts b/tests/engine/render/canvas/masks.test.ts
index 9e4101ca2..9647ae955 100644
--- a/tests/engine/render/canvas/masks.test.ts
+++ b/tests/engine/render/canvas/masks.test.ts
@@ -2,9 +2,10 @@ import { describe, expect, mock, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import { renderNode } from '#core/canvas/scene'
-import { SceneGraph } from '#core/scene-graph'
function pageId(graph: SceneGraph) {
return graph.getPages()[0].id
diff --git a/tests/engine/render/canvas/page-guides.test.ts b/tests/engine/render/canvas/page-guides.test.ts
index b71dbf269..a10181b82 100644
--- a/tests/engine/render/canvas/page-guides.test.ts
+++ b/tests/engine/render/canvas/page-guides.test.ts
@@ -2,8 +2,9 @@ import { describe, expect, test } from 'bun:test'
import type { Canvas } from 'canvaskit-wasm'
+import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
+
import { drawPageGuides } from '#core/canvas/page-guides'
-import type { SceneGraph, SceneNode } from '#core/scene-graph'
import { createMockCanvas, createMockRenderer, mockCalls } from './effects/helpers'
diff --git a/tests/engine/render/canvas/retained-backing.test.ts b/tests/engine/render/canvas/retained-backing.test.ts
index 9fe0e5fec..05c3dcadc 100644
--- a/tests/engine/render/canvas/retained-backing.test.ts
+++ b/tests/engine/render/canvas/retained-backing.test.ts
@@ -2,9 +2,10 @@ import { expect, mock, test } from 'bun:test'
import type { Canvas, Image as CKImage, Surface } from 'canvaskit-wasm'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
import type { SkiaRenderer } from '#core/canvas/renderer'
import { renderSceneBacking } from '#core/canvas/renderer/retained-backing'
-import type { SceneGraph } from '#core/scene-graph'
function createRenderer(surfaceFactory: () => Surface | null) {
const renderer: Partial<SkiaRenderer> = {
diff --git a/tests/engine/render/canvas/schema-fill-fallback.test.ts b/tests/engine/render/canvas/schema-fill-fallback.test.ts
index 557722c4d..31fa89da5 100644
--- a/tests/engine/render/canvas/schema-fill-fallback.test.ts
+++ b/tests/engine/render/canvas/schema-fill-fallback.test.ts
@@ -1,9 +1,10 @@
import { describe, expect, mock, test } from 'bun:test'
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type { Fill, SceneNode } from '@open-pencil/scene-graph'
+
import { applyFill } from '#core/canvas/fills'
import type { SkiaRenderer } from '#core/canvas/renderer'
-import { SceneGraph } from '#core/scene-graph'
-import type { Fill, SceneNode } from '#core/scene-graph'
function createRenderer() {
const picture = {
diff --git a/tests/engine/render/canvas/silhouette-autopsy.test.ts b/tests/engine/render/canvas/silhouette-autopsy.test.ts
index e7e38945c..2241cecc2 100644
--- a/tests/engine/render/canvas/silhouette-autopsy.test.ts
+++ b/tests/engine/render/canvas/silhouette-autopsy.test.ts
@@ -14,9 +14,10 @@
import { beforeAll, describe, expect, test } from 'bun:test'
import { readFileSync } from 'node:fs'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import { initCanvasKit } from '#cli/headless'
import { SkiaRenderer } from '#core/canvas'
-import { SceneGraph } from '#core/scene-graph'
import { fontManager } from '#core/text'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/render/canvas/text.test.ts b/tests/engine/render/canvas/text.test.ts
index a77359085..a387e7691 100644
--- a/tests/engine/render/canvas/text.test.ts
+++ b/tests/engine/render/canvas/text.test.ts
@@ -6,12 +6,12 @@ import {
SceneGraph,
SkiaRenderer as SkiaRendererClass
} from '@open-pencil/core'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { initCanvasKit } from '#cli/headless'
import type { SkiaRenderer } from '#core/canvas/renderer'
import { renderText } from '#core/canvas/scene'
import { buildParagraph } from '#core/canvas/text'
-import type { SceneNode } from '#core/scene-graph'
import { fontManager } from '#core/text/fonts'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/render/canvas/visual/boolean-matrix.ts b/tests/engine/render/canvas/visual/boolean-matrix.ts
index 6c67f1afc..7b36c8b51 100644
--- a/tests/engine/render/canvas/visual/boolean-matrix.ts
+++ b/tests/engine/render/canvas/visual/boolean-matrix.ts
@@ -1,9 +1,10 @@
import { writeFile } from 'node:fs/promises'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { initCanvasKit } from '#cli/headless'
import { SkiaRenderer } from '#core/canvas'
import { parseSVGPath } from '#core/io/formats/svg/parse-path'
-import type { SceneNode } from '#core/scene-graph'
import { createAPI } from '#tests/engine/figma/api/helpers'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/render/canvas/visual/inner-shadow-counter.ts b/tests/engine/render/canvas/visual/inner-shadow-counter.ts
index 0d049d696..d148d9030 100644
--- a/tests/engine/render/canvas/visual/inner-shadow-counter.ts
+++ b/tests/engine/render/canvas/visual/inner-shadow-counter.ts
@@ -1,10 +1,11 @@
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import { SceneGraph } from '@open-pencil/scene-graph'
+
import { initCanvasKit } from '#cli/headless'
import { SkiaRenderer } from '#core/canvas'
-import type { SceneNode } from '#core/scene-graph'
-import { SceneGraph } from '#core/scene-graph'
import { fontManager } from '#core/text'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/render/canvas/visual/sdf-test-matrix.ts b/tests/engine/render/canvas/visual/sdf-test-matrix.ts
index 965ed4fd4..d79ef6b97 100644
--- a/tests/engine/render/canvas/visual/sdf-test-matrix.ts
+++ b/tests/engine/render/canvas/visual/sdf-test-matrix.ts
@@ -1,13 +1,14 @@
import { mkdir, readFile } from 'node:fs/promises'
import { join } from 'node:path'
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+import type { Color, Vector } from '@open-pencil/scene-graph/primitives'
+
import { initCanvasKit } from '#cli/headless'
import { SkiaRenderer } from '#core/canvas'
import { renderNodesToImage } from '#core/io/formats/raster'
-import { SceneGraph } from '#core/scene-graph'
-import type { SceneNode } from '#core/scene-graph'
import { fontManager } from '#core/text'
-import type { Color, Vector } from '#core/types'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/render/canvas/visual/verify-text-inner-shadow.ts b/tests/engine/render/canvas/visual/verify-text-inner-shadow.ts
index fcf227708..6c2893449 100644
--- a/tests/engine/render/canvas/visual/verify-text-inner-shadow.ts
+++ b/tests/engine/render/canvas/visual/verify-text-inner-shadow.ts
@@ -1,11 +1,12 @@
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
+import { SceneGraph } from '@open-pencil/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
import { initCanvasKit } from '#cli/headless'
import { SkiaRenderer } from '#core/canvas'
import { renderNodesToImage } from '#core/io/formats/raster'
-import { SceneGraph } from '#core/scene-graph'
-import type { SceneNode } from '#core/scene-graph'
import { fontManager } from '#core/text'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/scene-graph/copy.test.ts b/tests/engine/scene-graph/copy.test.ts
index 8a70d7b90..7d2932200 100644
--- a/tests/engine/scene-graph/copy.test.ts
+++ b/tests/engine/scene-graph/copy.test.ts
@@ -1,7 +1,6 @@
import { describe, test, expect } from 'bun:test'
import type { Fill, Stroke, Effect, StyleRun, GeometryPath } from '@open-pencil/core'
-
import {
copyFill,
copyFills,
@@ -9,7 +8,7 @@ import {
copyEffect,
copyStyleRun,
copyGeometryPaths
-} from '#core/scene-graph/copy'
+} from '@open-pencil/scene-graph/copy'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/scene-graph/undo/mutation.test.ts b/tests/engine/scene-graph/undo/mutation.test.ts
index 4a152702e..ba05d5fe3 100644
--- a/tests/engine/scene-graph/undo/mutation.test.ts
+++ b/tests/engine/scene-graph/undo/mutation.test.ts
@@ -1,7 +1,7 @@
import { describe, test, expect } from 'bun:test'
import { SceneGraph, UndoManager } from '@open-pencil/core'
-import type { JsonObject } from '@open-pencil/core/types'
+import type { JsonObject } from '@open-pencil/scene-graph/primitives'
import { getNodeOrThrow } from '#tests/helpers/assert'
diff --git a/tests/engine/vector/centerline.test.ts b/tests/engine/vector/centerline.test.ts
index 0f3ef087e..df037d296 100644
--- a/tests/engine/vector/centerline.test.ts
+++ b/tests/engine/vector/centerline.test.ts
@@ -1,8 +1,8 @@
import { describe, test, expect } from 'bun:test'
import type { Vector } from '@open-pencil/core'
-import type { VectorNetwork } from '@open-pencil/core/scene-graph'
import { fitCircleArc, isClosedThinCrescent } from '@open-pencil/core/vector'
+import type { VectorNetwork } from '@open-pencil/scene-graph'
import { expectDefined } from '#tests/helpers/assert'
diff --git a/tests/engine/vue/input/auto-layout-hover.test.ts b/tests/engine/vue/input/auto-layout-hover.test.ts
index acc9443f2..44d25a91c 100644
--- a/tests/engine/vue/input/auto-layout-hover.test.ts
+++ b/tests/engine/vue/input/auto-layout-hover.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'bun:test'
import type { Editor } from '@open-pencil/core/editor'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import { resolveAutoLayoutHover } from '#vue/shared/input/auto-layout-hover'
diff --git a/tests/engine/vue/layout/hug-contents.test.ts b/tests/engine/vue/layout/hug-contents.test.ts
index 83873b036..059833209 100644
--- a/tests/engine/vue/layout/hug-contents.test.ts
+++ b/tests/engine/vue/layout/hug-contents.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'bun:test'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
+import type { SceneNode } from '@open-pencil/scene-graph'
import {
widthSizingForNode,
diff --git a/tests/helpers/tauri/fig-export-fixture.ts b/tests/helpers/tauri/fig-export-fixture.ts
index ab762cffd..92b3b132a 100644
--- a/tests/helpers/tauri/fig-export-fixture.ts
+++ b/tests/helpers/tauri/fig-export-fixture.ts
@@ -25,7 +25,7 @@ mockIPC((cmd, args) => {
const [{ exportFigFile }, { SceneGraph }] = await Promise.all([
import('@open-pencil/core/io/formats/fig/export'),
- import('@open-pencil/core/scene-graph')
+ import('@open-pencil/scene-graph')
])
const bytes = await exportFigFile(new SceneGraph())
if (bytes.length !== 3 || bytes[0] !== 7 || bytes[1] !== 8 || bytes[2] !== 9) {
diff --git a/tools/package-quality/src/check-metadata.ts b/tools/package-quality/src/check-metadata.ts
index 7675f9d45..3d78a25c8 100644
--- a/tools/package-quality/src/check-metadata.ts
+++ b/tools/package-quality/src/check-metadata.ts
@@ -2,6 +2,8 @@ import { readFileSync } from 'node:fs'
import { join } from 'node:path'
const publicPackages = [
+ 'packages/scene-graph',
+ 'packages/pen',
'packages/core',
'packages/dom-css',
'packages/kiwi',
diff --git a/tools/package-quality/src/smoke.ts b/tools/package-quality/src/smoke.ts
index 03ab9299d..223c45ee4 100644
--- a/tools/package-quality/src/smoke.ts
+++ b/tools/package-quality/src/smoke.ts
@@ -5,6 +5,8 @@ import { fileURLToPath } from 'node:url'
const rootDir = fileURLToPath(new URL('../../..', import.meta.url))
const packageDirs = [
+ 'packages/scene-graph',
+ 'packages/pen',
'packages/kiwi',
'packages/fig',
'packages/core',
@@ -71,8 +73,16 @@ try {
nodeEval("await import('@open-pencil/kiwi/fig/guid')", tempDir)
nodeEval("await import('@open-pencil/kiwi/fig/parse')", tempDir)
nodeEval("await import('@open-pencil/fig')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph/copy')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph/coordinate')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph/geometry')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph/images')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph/matrix')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph/parse-path')", tempDir)
+ nodeEval("await import('@open-pencil/scene-graph/primitives')", tempDir)
+ nodeEval("await import('@open-pencil/pen')", tempDir)
nodeEval("await import('@open-pencil/core')", tempDir)
- nodeEval("await import('@open-pencil/core/scene-graph')", tempDir)
nodeEval("await import('@open-pencil/dom-css')", tempDir)
nodeEval("await import('@open-pencil/dom-css/browser')", tempDir)
nodeEval("await import('@open-pencil/dom-css/jsx-runtime')", tempDir)
@@ -92,6 +102,14 @@ try {
"const { FIG_PACKAGE_STATUS, readFigContainer, writeFigContainer } = await import('@open-pencil/fig'); if (FIG_PACKAGE_STATUS !== 'container-api') throw new Error('Fig package status smoke failed'); const document = readFigContainer(writeFigContainer({ schemaDeflated: new Uint8Array([1]), dataRaw: new Uint8Array([2]) })); if (document.dataRaw[0] !== 2) throw new Error('Fig container smoke failed')",
tempDir
)
+ nodeEval(
+ "const { SceneGraph } = await import('@open-pencil/scene-graph'); const graph = new SceneGraph(); if (graph.getPages().length !== 1) throw new Error('SceneGraph package smoke failed')",
+ tempDir
+ )
+ nodeEval(
+ "const { parsePenFile } = await import('@open-pencil/pen'); const graph = parsePenFile(JSON.stringify({ version: '1', children: [{ id: 'frame', type: 'frame', width: 100, height: 50 }] })); if (graph.getPages()[0].childIds.length !== 1) throw new Error('Pen package smoke failed')",
+ tempDir
+ )
nodeEval(
"const { htmlToSceneGraph } = await import('@open-pencil/dom-css'); const graph = await htmlToSceneGraph('<div class=card>OpenPencil</div>', { cssText: '.card { width: 320px; }' }); if (graph.getPages()[0].width !== 320) throw new Error('DOM/CSS scene graph smoke failed')",
tempDir
diff --git a/tsconfig.json b/tsconfig.json
index f76c0dd0b..4635885c0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,7 +2,11 @@
"compilerOptions": {
"target": "ES2022",
"useDefineForClassFields": true,
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
+ "lib": [
+ "ESNext",
+ "DOM",
+ "DOM.Iterable"
+ ],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
@@ -17,20 +21,70 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"paths": {
- "@/*": ["./src/*"],
- "#vue/*": ["./packages/vue/src/*", "./packages/vue/src/*.vue"],
- "#core/*": ["./packages/core/src/*"],
- "#cli/*": ["./packages/cli/src/*"],
- "#mcp/*": ["./packages/mcp/src/*"],
- "#dom-css/*": ["./packages/dom-css/src/*"],
- "#tests/*": ["./tests/*"],
- "tinykeys": ["./node_modules/tinykeys/dist/tinykeys.d.ts"],
- "@open-pencil/vue": ["./packages/vue/src/index.ts"],
- "@open-pencil/core": ["./packages/core/src/index.ts"],
- "@open-pencil/core/*": ["./packages/core/src/*"],
- "@open-pencil/dom-css": ["./packages/dom-css/src/index.ts"]
+ "@/*": [
+ "./src/*"
+ ],
+ "#vue/*": [
+ "./packages/vue/src/*",
+ "./packages/vue/src/*.vue"
+ ],
+ "#core/*": [
+ "./packages/core/src/*"
+ ],
+ "#cli/*": [
+ "./packages/cli/src/*"
+ ],
+ "#mcp/*": [
+ "./packages/mcp/src/*"
+ ],
+ "#dom-css/*": [
+ "./packages/dom-css/src/*"
+ ],
+ "#tests/*": [
+ "./tests/*"
+ ],
+ "tinykeys": [
+ "./node_modules/tinykeys/dist/tinykeys.d.ts"
+ ],
+ "@open-pencil/vue": [
+ "./packages/vue/src/index.ts"
+ ],
+ "@open-pencil/core": [
+ "./packages/core/src/index.ts"
+ ],
+ "@open-pencil/core/*": [
+ "./packages/core/src/*"
+ ],
+ "@open-pencil/dom-css": [
+ "./packages/dom-css/src/index.ts"
+ ],
+ "#scene-graph/*": [
+ "./packages/scene-graph/src/*"
+ ],
+ "@open-pencil/scene-graph": [
+ "./packages/scene-graph/src/index.ts"
+ ],
+ "@open-pencil/scene-graph/*": [
+ "./packages/scene-graph/src/*"
+ ],
+ "#pen/*": [
+ "./packages/pen/src/*"
+ ],
+ "@open-pencil/pen": [
+ "./packages/pen/src/index.ts"
+ ],
+ "@open-pencil/pen/*": [
+ "./packages/pen/src/*"
+ ]
}
},
- "include": ["src/**/*.ts", "src/**/*.vue"],
- "references": [{ "path": "./tsconfig.node.json" }]
+ "include": [
+ "src/**/*.ts",
+ "src/**/*.vue"
+ ],
+ "references": [
+ {
+ "path": "./tsconfig.node.json"
+ }
+ ]
}