design.md was stored in a global Zustand store + per-file-key localStorage in apps/web, and in a module-level cache in pen-mcp. Both leaked across files: a newly-created document could pick up the previous file's dark palette (async clearForNewDocument raced with AI chat reads; hydrate() could rehydrate the last file's designMd on refresh; shared .pen files lost the spec entirely because it wasn't inside the document). Fix: - Add `designMd?: DesignMdSpec` to PenDocument (pen-types). It now serializes with .pen/.op and travels across sessions/users. - Add `setDesignMd` action to document-store. - Rewrite design-md-store as a thin mirror over document-store so the legacy hook API still works. On document load it migrates any legacy localStorage entry into the opened document and deletes the localStorage key; hydrate() wipes the orphan `openpencil-design-md-current-key`. - MCP handleGetDesignMd / handleSetDesignMd / handleExportDesignMd read `doc.designMd` directly and persist via saveDocument. Removed the process-level `_mcpDesignMd` cache. Verified via MCP live round-trip: set on file A → persists to A's .op on disk → new file B returns hasDesignMd:false (no leak). |
||
|---|---|---|
| .. | ||
| src | ||
| CLAUDE.md | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
@zseven-w/pen-types
Type definitions for the OpenPencil document model.
Install
npm install @zseven-w/pen-types
What's Included
This package provides all TypeScript types and interfaces for the OpenPencil design file format (.op):
- Document model —
PenDocument,PenPage,PenNodeand all node types (FrameNode,RectangleNode,EllipseNode,TextNode,ImageNode,PathNode, etc.) - Styles —
PenFill(solid, gradient, image),PenStroke,PenEffect(blur, shadow),BlendMode,StyledTextSegment - Variables & Themes —
VariableDefinition,VariableValue,ThemedValue - Canvas state —
ToolType,ViewportState,SelectionState,CanvasInteraction - UIKit —
UIKit,KitComponent,ComponentCategory - Theme presets —
ThemePreset,ThemePresetFile - Design spec —
DesignMdSpec,DesignMdColor,DesignMdTypography
Usage
import type { PenDocument, PenNode, FrameNode } from '@zseven-w/pen-types';
License
MIT