Add subpath exports to @open-pencil/core
12 domain-specific subpath exports for targeted imports: scene-graph, kiwi, tools, renderer, render, rpc, figma-api, canvaskit, layout, color, render-image, profiler. - Create kiwi/index.ts barrel (codec, fig-file, fig-import, protocol) - Route main index.ts kiwi re-exports through the new barrel - Add exports map + publishConfig mirror for npm consumers - Mark package as sideEffects: false for tree-shaking - Document subpath exports in AGENTS.md
This commit is contained in:
parent
bc7a687aef
commit
2a740a01ff
22
AGENTS.md
22
AGENTS.md
|
|
@ -15,6 +15,28 @@ Bun workspace with three packages:
|
|||
|
||||
The root app (`src/`) is the Tauri/Vite desktop editor. Its `src/engine/` files are thin re-export shims from `@open-pencil/core`.
|
||||
|
||||
### Core subpath exports
|
||||
|
||||
`@open-pencil/core` exposes domain-specific subpath exports for targeted imports. The main `"."` entry re-exports everything for backward compatibility.
|
||||
|
||||
| Subpath | What | Heavy dep isolated |
|
||||
|---|---|---|
|
||||
| `@open-pencil/core` | everything (barrel) | all |
|
||||
| `@open-pencil/core/scene-graph` | SceneGraph, node types, events | — |
|
||||
| `@open-pencil/core/kiwi` | .fig parse/serialize, codec, protocol | fflate, fzstd |
|
||||
| `@open-pencil/core/tools` | ToolDef, ALL_TOOLS, AI adapter | diff |
|
||||
| `@open-pencil/core/renderer` | SkiaRenderer | — |
|
||||
| `@open-pencil/core/render` | JSX-to-design renderer | sucrase |
|
||||
| `@open-pencil/core/rpc` | RPC commands for CLI | — |
|
||||
| `@open-pencil/core/figma-api` | FigmaAPI, FigmaNodeProxy | — |
|
||||
| `@open-pencil/core/canvaskit` | getCanvasKit loader | canvaskit-wasm |
|
||||
| `@open-pencil/core/layout` | computeLayout | yoga-layout |
|
||||
| `@open-pencil/core/color` | parseColor, colorToHex, etc. | — |
|
||||
| `@open-pencil/core/render-image` | renderNodesToImage | — |
|
||||
| `@open-pencil/core/profiler` | render profiling | — |
|
||||
|
||||
Runtime `canvaskit-wasm` import exists only in `canvaskit.ts` — all other files use `import type`. CanvasKit instance is passed as a parameter everywhere.
|
||||
|
||||
## Commands
|
||||
|
||||
- `bun run check` — type-aware lint + typecheck via oxlint + tsgo (run before committing)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,72 @@
|
|||
"version": "0.9.0",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"bun": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
},
|
||||
"./scene-graph": {
|
||||
"types": "./src/scene-graph.ts",
|
||||
"bun": "./src/scene-graph.ts",
|
||||
"default": "./src/scene-graph.ts"
|
||||
},
|
||||
"./kiwi": {
|
||||
"types": "./src/kiwi/index.ts",
|
||||
"bun": "./src/kiwi/index.ts",
|
||||
"default": "./src/kiwi/index.ts"
|
||||
},
|
||||
"./tools": {
|
||||
"types": "./src/tools/index.ts",
|
||||
"bun": "./src/tools/index.ts",
|
||||
"default": "./src/tools/index.ts"
|
||||
},
|
||||
"./renderer": {
|
||||
"types": "./src/renderer/index.ts",
|
||||
"bun": "./src/renderer/index.ts",
|
||||
"default": "./src/renderer/index.ts"
|
||||
},
|
||||
"./render": {
|
||||
"types": "./src/render/index.ts",
|
||||
"bun": "./src/render/index.ts",
|
||||
"default": "./src/render/index.ts"
|
||||
},
|
||||
"./rpc": {
|
||||
"types": "./src/rpc/index.ts",
|
||||
"bun": "./src/rpc/index.ts",
|
||||
"default": "./src/rpc/index.ts"
|
||||
},
|
||||
"./figma-api": {
|
||||
"types": "./src/figma-api.ts",
|
||||
"bun": "./src/figma-api.ts",
|
||||
"default": "./src/figma-api.ts"
|
||||
},
|
||||
"./canvaskit": {
|
||||
"types": "./src/canvaskit.ts",
|
||||
"bun": "./src/canvaskit.ts",
|
||||
"default": "./src/canvaskit.ts"
|
||||
},
|
||||
"./layout": {
|
||||
"types": "./src/layout.ts",
|
||||
"bun": "./src/layout.ts",
|
||||
"default": "./src/layout.ts"
|
||||
},
|
||||
"./color": {
|
||||
"types": "./src/color.ts",
|
||||
"bun": "./src/color.ts",
|
||||
"default": "./src/color.ts"
|
||||
},
|
||||
"./render-image": {
|
||||
"types": "./src/render-image.ts",
|
||||
"bun": "./src/render-image.ts",
|
||||
"default": "./src/render-image.ts"
|
||||
},
|
||||
"./profiler": {
|
||||
"types": "./src/profiler/index.ts",
|
||||
"bun": "./src/profiler/index.ts",
|
||||
"default": "./src/profiler/index.ts"
|
||||
}
|
||||
},
|
||||
"main": "./src/index.ts",
|
||||
|
|
@ -28,8 +89,68 @@
|
|||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"node": "./dist/index.js",
|
||||
"import": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./scene-graph": {
|
||||
"types": "./dist/scene-graph.d.ts",
|
||||
"import": "./dist/scene-graph.js",
|
||||
"default": "./dist/scene-graph.js"
|
||||
},
|
||||
"./kiwi": {
|
||||
"types": "./dist/kiwi/index.d.ts",
|
||||
"import": "./dist/kiwi/index.js",
|
||||
"default": "./dist/kiwi/index.js"
|
||||
},
|
||||
"./tools": {
|
||||
"types": "./dist/tools/index.d.ts",
|
||||
"import": "./dist/tools/index.js",
|
||||
"default": "./dist/tools/index.js"
|
||||
},
|
||||
"./renderer": {
|
||||
"types": "./dist/renderer/index.d.ts",
|
||||
"import": "./dist/renderer/index.js",
|
||||
"default": "./dist/renderer/index.js"
|
||||
},
|
||||
"./render": {
|
||||
"types": "./dist/render/index.d.ts",
|
||||
"import": "./dist/render/index.js",
|
||||
"default": "./dist/render/index.js"
|
||||
},
|
||||
"./rpc": {
|
||||
"types": "./dist/rpc/index.d.ts",
|
||||
"import": "./dist/rpc/index.js",
|
||||
"default": "./dist/rpc/index.js"
|
||||
},
|
||||
"./figma-api": {
|
||||
"types": "./dist/figma-api.d.ts",
|
||||
"import": "./dist/figma-api.js",
|
||||
"default": "./dist/figma-api.js"
|
||||
},
|
||||
"./canvaskit": {
|
||||
"types": "./dist/canvaskit.d.ts",
|
||||
"import": "./dist/canvaskit.js",
|
||||
"default": "./dist/canvaskit.js"
|
||||
},
|
||||
"./layout": {
|
||||
"types": "./dist/layout.d.ts",
|
||||
"import": "./dist/layout.js",
|
||||
"default": "./dist/layout.js"
|
||||
},
|
||||
"./color": {
|
||||
"types": "./dist/color.d.ts",
|
||||
"import": "./dist/color.js",
|
||||
"default": "./dist/color.js"
|
||||
},
|
||||
"./render-image": {
|
||||
"types": "./dist/render-image.d.ts",
|
||||
"import": "./dist/render-image.js",
|
||||
"default": "./dist/render-image.js"
|
||||
},
|
||||
"./profiler": {
|
||||
"types": "./dist/profiler/index.d.ts",
|
||||
"import": "./dist/profiler/index.js",
|
||||
"default": "./dist/profiler/index.js"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
|
|
|
|||
|
|
@ -197,9 +197,10 @@ export {
|
|||
type OpenPencilClipboardData
|
||||
} from './clipboard'
|
||||
|
||||
export { readFigFile, parseFigFile } from './kiwi/fig-file'
|
||||
export { importNodeChanges } from './kiwi/fig-import'
|
||||
export {
|
||||
readFigFile,
|
||||
parseFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
|
|
@ -207,6 +208,8 @@ export {
|
|||
decompress,
|
||||
getCompiledSchema,
|
||||
getSchemaBytes,
|
||||
isCodecReady,
|
||||
peekMessageType,
|
||||
createNodeChangesMessage,
|
||||
createNodeChange,
|
||||
parseVariableId,
|
||||
|
|
@ -219,10 +222,7 @@ export {
|
|||
type Effect as KiwiEffect,
|
||||
type VariableBinding,
|
||||
type ParentIndex,
|
||||
type FigmaMessage
|
||||
} from './kiwi/codec'
|
||||
|
||||
export {
|
||||
type FigmaMessage,
|
||||
MESSAGE_TYPES,
|
||||
NODE_TYPES,
|
||||
NODE_PHASES,
|
||||
|
|
@ -240,4 +240,4 @@ export {
|
|||
getKiwiMessageType,
|
||||
parseVarint,
|
||||
FIG_WIRE_MAGIC
|
||||
} from './kiwi/protocol'
|
||||
} from './kiwi'
|
||||
|
|
|
|||
49
packages/core/src/kiwi/index.ts
Normal file
49
packages/core/src/kiwi/index.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
export { readFigFile, parseFigFile } from './fig-file'
|
||||
export { importNodeChanges } from './fig-import'
|
||||
export {
|
||||
initCodec,
|
||||
encodeMessage,
|
||||
decodeMessage,
|
||||
compress,
|
||||
decompress,
|
||||
getCompiledSchema,
|
||||
getSchemaBytes,
|
||||
isCodecReady,
|
||||
peekMessageType,
|
||||
createNodeChangesMessage,
|
||||
createNodeChange,
|
||||
parseVariableId,
|
||||
encodePaintWithVariableBinding,
|
||||
encodeNodeChangeWithVariables,
|
||||
type NodeChange,
|
||||
type GUID,
|
||||
type Color,
|
||||
type Paint,
|
||||
type Effect,
|
||||
type VariableBinding,
|
||||
type VariableAnyValue,
|
||||
type VariableDataEntry,
|
||||
type VariableConsumptionEntry,
|
||||
type VariableDataValuesEntry,
|
||||
type ParentIndex,
|
||||
type FigmaMessage
|
||||
} from './codec'
|
||||
export {
|
||||
MESSAGE_TYPES,
|
||||
NODE_TYPES,
|
||||
NODE_PHASES,
|
||||
BLEND_MODES,
|
||||
PAINT_TYPES,
|
||||
PROTOCOL_VERSION,
|
||||
KIWI,
|
||||
SESSION_ID,
|
||||
ZSTD_MAGIC,
|
||||
buildMultiplayerUrl,
|
||||
isZstdCompressed,
|
||||
hasFigWireHeader,
|
||||
skipFigWireHeader,
|
||||
isKiwiMessage,
|
||||
getKiwiMessageType,
|
||||
parseVarint,
|
||||
FIG_WIRE_MAGIC
|
||||
} from './protocol'
|
||||
Loading…
Reference in a new issue