openpencil/packages/pen-types
Fini 2aabe494f5 fix(core): design.md lives on PenDocument — kill cross-document leak
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).
2026-04-20 00:37:31 +08:00
..
src fix(core): design.md lives on PenDocument — kill cross-document leak 2026-04-20 00:37:31 +08:00
CLAUDE.md V0.7.1 (#102) 2026-04-13 21:30:23 +08:00
LICENSE V0.7.1 (#102) 2026-04-13 21:30:23 +08:00
package.json chore(release): bump to v0.7.4 2026-04-17 19:20:19 +08:00
README.md V0.7.1 (#102) 2026-04-13 21:30:23 +08:00
tsconfig.json V0.5.0 (#67) 2026-03-22 09:44:04 +08:00

@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, PenNode and 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