AI-native design editor. Open-source Figma alternative.
build: publish node-compatible packages
Danila Poyarkov3850be951239
diff --git a/AGENTS.md b/AGENTS.mdindex 0a1aed874..4775bb181 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -375,8 +375,9 @@ Self-review checklist:## Publishing- `bun publish` from package dirs — resolves `workspace:*` → actual versions-- Core: `prepublishOnly` runs `tsc` to build `dist/` for Node.js consumers-- CLI requires Bun runtime (`#!/usr/bin/env bun`)+- Public packages publish built `dist/` output, not runtime TypeScript entrypoints+- Core, Vue, MCP, and CLI build with tsdown before publishing+- CLI publishes a Node-compatible `bin/openpencil.js` wrapper; do not point package `bin` entries at TypeScript source## Referencediff --git a/README.md b/README.mdindex 98ea8cecd..4355392b0 100644--- a/README.md+++ b/README.md@@ -36,7 +36,8 @@ Or download from the [releases page](https://github.com/open-pencil/open-pencil/## CLI```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli+# or: bun add -g @open-pencil/cli```### Inspect design filesdiff --git a/bun.lock b/bun.lockindex cb11e1ad4..71e6c6035 100644--- a/bun.lock+++ b/bun.lock@@ -98,9 +98,9 @@},"packages/cli": {"name": "@open-pencil/cli",- "version": "0.12.0",+ "version": "0.12.2","bin": {- "openpencil": "./src/index.ts",+ "openpencil": "./bin/openpencil.js",},"dependencies": {"@open-pencil/core": "workspace:*",@@ -114,9 +114,11 @@},"packages/core": {"name": "@open-pencil/core",- "version": "0.12.0",+ "version": "0.12.2","dependencies": {+ "@chenglou/pretext": "^0.0.7","@iconify/utils": "^3.1.0",+ "@tauri-apps/api": "^2","acorn": "^8.16.0","canvaskit-wasm": "^0.40.0","culori": "^4.0.2",@@ -126,9 +128,11 @@"fflate": "^0.8.2","fontoxpath": "^3.34.0","fzstd": "^0.1.1",+ "jspdf": "^4.2.1","nanoevents": "^9.1.0","opentype.js": "^1.3.4","sucrase": "^3.35.1",+ "svg2pdf.js": "^2.7.0","svgpath": "^2.6.0","twirlwind": "^0.3.0","yoga-layout": "npm:@open-pencil/[email protected]",@@ -152,10 +156,10 @@},"packages/mcp": {"name": "@open-pencil/mcp",- "version": "0.12.0",+ "version": "0.12.2","bin": {- "openpencil-mcp": "./dist/stdio.js",- "openpencil-mcp-http": "./dist/index.js",+ "openpencil-mcp": "./bin/openpencil-mcp.js",+ "openpencil-mcp-http": "./bin/openpencil-mcp-http.js",},"dependencies": {"@hono/node-server": "^1.19.9",@@ -173,12 +177,16 @@},"packages/vue": {"name": "@open-pencil/vue",- "version": "0.12.0",+ "version": "0.12.2","dependencies": {+ "@atlaskit/pragmatic-drag-and-drop": "^1.7.9",+ "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0","@nanostores/i18n": "^1.2.2","@nanostores/vue": "^1.1.0",+ "@tanstack/vue-table": "^8.21.3","@vueuse/core": "^14.2.1","nanostores": "^1.2.0",+ "reka-ui": "^2.9.0",},"devDependencies": {"tsdown": "^0.21.7",diff --git a/package.json b/package.jsonindex 535ab93ad..9eb7c1026 100644--- a/package.json+++ b/package.json@@ -15,8 +15,9 @@"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/","lint:structure": "oxlint -c oxlint.json vite.config.ts vite/ src/ packages/core/src/ packages/vue/src/ packages/cli/src/ packages/mcp/src/ tests/ scripts/","format": "oxfmt --write .oxfmtrc.json vite.config.ts vite/ src/ packages/core/src/ packages/cli/src/ packages/mcp/src/ packages/vue/src/ tests scripts/",- "check": "bun run lint && tsgo --noEmit && bun run check:vue && bun run check:i18n && bun run check:arch && bun run test:dupes",+ "check": "bun run lint && tsgo --noEmit && bun run check:vue && bun run check:i18n && bun run check:packages && bun run check:arch && bun run test:dupes","check:i18n": "bun scripts/check-locales.ts",+ "check:packages": "bun scripts/check-package-metadata.ts","check:arch": "steiger .","check:vue": "vue-tsc --noEmit -p tsconfig.json && vue-tsc --noEmit -p packages/vue/tsconfig.json","test": "playwright test --project=openpencil",@@ -26,6 +27,8 @@"test:unit": "bun test ./tests/engine","test:coverage": "bun test --coverage ./tests/engine","test:dupes": "jscpd packages/core/src packages/cli/src src --min-lines 5 --min-tokens 50 --format typescript --threshold 0",+ "test:packages": "bun scripts/check-package-metadata.ts && bun scripts/smoke-packages.ts",+ "build:packages": "bun --filter @open-pencil/core 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",diff --git a/packages/cli/bin/openpencil.js b/packages/cli/bin/openpencil.jsnew file mode 100755index 000000000..201d2cec3--- /dev/null+++ b/packages/cli/bin/openpencil.js@@ -0,0 +1,2 @@+#!/usr/bin/env node+import '../dist/index.mjs'diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex bf99556e7..bdb25abdf 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -7,9 +7,16 @@"#cli/*": "./src/*"},"bin": {- "openpencil": "./src/index.ts"+ "openpencil": "./bin/openpencil.js"+ },+ "files": [+ "bin",+ "dist"+ ],+ "scripts": {+ "build": "bunx tsdown --config tsdown.config.ts",+ "prepublishOnly": "bun run build"},- "files": ["src"],"repository": {"type": "git","url": "git+https://github.com/open-pencil/open-pencil.git",diff --git a/packages/cli/tsdown.config.ts b/packages/cli/tsdown.config.tsnew file mode 100644index 000000000..94fbc9440--- /dev/null+++ b/packages/cli/tsdown.config.ts@@ -0,0 +1,17 @@+import { defineConfig } from 'tsdown'++export default defineConfig({+ entry: {+ index: './src/index.ts'+ },+ platform: 'node',+ format: ['esm'],+ sourcemap: true,+ clean: true,+ outDir: './dist',+ treeshake: false,+ deps: {+ neverBundle: ['@open-pencil/core', /^@open-pencil\/core\//, 'canvaskit-wasm', /^node:/],+ onlyBundle: false+ }+})diff --git a/packages/core/package.json b/packages/core/package.jsonindex dde4794c0..0e6f83a0d 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -9,150 +9,149 @@"sideEffects": false,"exports": {".": {- "types": "./src/index.ts",- "bun": "./src/index.ts",- "default": "./src/index.ts"+ "types": "./dist/index.d.ts",+ "default": "./dist/index.js",+ "import": "./dist/index.js"},"./scene-graph": {- "types": "./src/scene-graph/index.ts",- "bun": "./src/scene-graph/index.ts",- "default": "./src/scene-graph/index.ts"+ "types": "./dist/scene-graph/index.d.ts",+ "default": "./dist/scene-graph/index.js",+ "import": "./dist/scene-graph/index.js"},"./color": {- "types": "./src/color/index.ts",- "bun": "./src/color/index.ts",- "default": "./src/color/index.ts"+ "types": "./dist/color/index.d.ts",+ "default": "./dist/color/index.js",+ "import": "./dist/color/index.js"},"./text": {- "types": "./src/text/index.ts",- "bun": "./src/text/index.ts",- "default": "./src/text/index.ts"+ "types": "./dist/text/index.d.ts",+ "default": "./dist/text/index.js",+ "import": "./dist/text/index.js"},"./vector": {- "types": "./src/vector/index.ts",- "bun": "./src/vector/index.ts",- "default": "./src/vector/index.ts"+ "types": "./dist/vector/index.d.ts",+ "default": "./dist/vector/index.js",+ "import": "./dist/vector/index.js"},"./figma-api": {- "types": "./src/figma-api/index.ts",- "bun": "./src/figma-api/index.ts",- "default": "./src/figma-api/index.ts"+ "types": "./dist/figma-api/index.d.ts",+ "default": "./dist/figma-api/index.js",+ "import": "./dist/figma-api/index.js"},"./icons": {- "types": "./src/icons/index.ts",- "bun": "./src/icons/index.ts",- "default": "./src/icons/index.ts"+ "types": "./dist/icons/index.d.ts",+ "default": "./dist/icons/index.js",+ "import": "./dist/icons/index.js"},"./canvas": {- "types": "./src/canvas/index.ts",- "bun": "./src/canvas/index.ts",- "default": "./src/canvas/index.ts"+ "types": "./dist/canvas/index.d.ts",+ "default": "./dist/canvas/index.js",+ "import": "./dist/canvas/index.js"},"./design-jsx": {- "types": "./src/design-jsx/index.ts",- "bun": "./src/design-jsx/index.ts",- "default": "./src/design-jsx/index.ts"+ "types": "./dist/design-jsx/index.d.ts",+ "default": "./dist/design-jsx/index.js",+ "import": "./dist/design-jsx/index.js"},"./editor": {- "types": "./src/editor/index.ts",- "bun": "./src/editor/index.ts",- "default": "./src/editor/index.ts"+ "types": "./dist/editor/index.d.ts",+ "default": "./dist/editor/index.js",+ "import": "./dist/editor/index.js"},"./tools": {- "types": "./src/tools/index.ts",- "bun": "./src/tools/index.ts",- "default": "./src/tools/index.ts"+ "types": "./dist/tools/index.d.ts",+ "default": "./dist/tools/index.js",+ "import": "./dist/tools/index.js"},"./profiler": {- "types": "./src/profiler/index.ts",- "bun": "./src/profiler/index.ts",- "default": "./src/profiler/index.ts"+ "types": "./dist/profiler/index.d.ts",+ "default": "./dist/profiler/index.js",+ "import": "./dist/profiler/index.js"},"./rpc": {- "types": "./src/rpc/index.ts",- "bun": "./src/rpc/index.ts",- "default": "./src/rpc/index.ts"+ "types": "./dist/rpc/index.d.ts",+ "default": "./dist/rpc/index.js",+ "import": "./dist/rpc/index.js"},"./lint": {- "types": "./src/lint/index.ts",- "bun": "./src/lint/index.ts",- "default": "./src/lint/index.ts"+ "types": "./dist/lint/index.d.ts",+ "default": "./dist/lint/index.js",+ "import": "./dist/lint/index.js"},"./io": {- "types": "./src/io/index.ts",- "bun": "./src/io/index.ts",- "default": "./src/io/index.ts"+ "types": "./dist/io/index.d.ts",+ "default": "./dist/io/index.js",+ "import": "./dist/io/index.js"},"./io/formats/fig": {- "types": "./src/io/formats/fig/index.ts",- "bun": "./src/io/formats/fig/index.ts",- "default": "./src/io/formats/fig/index.ts"+ "types": "./dist/io/formats/fig/index.d.ts",+ "default": "./dist/io/formats/fig/index.js",+ "import": "./dist/io/formats/fig/index.js"},"./io/formats/pen": {- "types": "./src/io/formats/pen/index.ts",- "bun": "./src/io/formats/pen/index.ts",- "default": "./src/io/formats/pen/index.ts"+ "types": "./dist/io/formats/pen/index.d.ts",+ "default": "./dist/io/formats/pen/index.js",+ "import": "./dist/io/formats/pen/index.js"},"./io/formats/jsx": {- "types": "./src/io/formats/jsx/index.ts",- "bun": "./src/io/formats/jsx/index.ts",- "default": "./src/io/formats/jsx/index.ts"+ "types": "./dist/io/formats/jsx/index.d.ts",+ "default": "./dist/io/formats/jsx/index.js",+ "import": "./dist/io/formats/jsx/index.js"},"./io/formats/raster": {- "types": "./src/io/formats/raster/index.ts",- "bun": "./src/io/formats/raster/index.ts",- "default": "./src/io/formats/raster/index.ts"+ "types": "./dist/io/formats/raster/index.d.ts",+ "default": "./dist/io/formats/raster/index.js",+ "import": "./dist/io/formats/raster/index.js"},"./io/formats/svg": {- "types": "./src/io/formats/svg/index.ts",- "bun": "./src/io/formats/svg/index.ts",- "default": "./src/io/formats/svg/index.ts"+ "types": "./dist/io/formats/svg/index.d.ts",+ "default": "./dist/io/formats/svg/index.js",+ "import": "./dist/io/formats/svg/index.js"},"./kiwi": {- "types": "./src/kiwi/index.ts",- "bun": "./src/kiwi/index.ts",- "default": "./src/kiwi/index.ts"+ "types": "./dist/kiwi/index.d.ts",+ "default": "./dist/kiwi/index.js",+ "import": "./dist/kiwi/index.js"},"./constants": {- "types": "./src/constants.ts",- "bun": "./src/constants.ts",- "default": "./src/constants.ts"+ "types": "./dist/constants.d.ts",+ "default": "./dist/constants.js",+ "import": "./dist/constants.js"},"./random": {- "types": "./src/random.ts",- "bun": "./src/random.ts",- "default": "./src/random.ts"+ "types": "./dist/random.d.ts",+ "default": "./dist/random.js",+ "import": "./dist/random.js"},"./xpath": {- "types": "./src/xpath.ts",- "bun": "./src/xpath.ts",- "default": "./src/xpath.ts"+ "types": "./dist/xpath.d.ts",+ "default": "./dist/xpath.js",+ "import": "./dist/xpath.js"},"./types": {- "types": "./src/types.ts",- "bun": "./src/types.ts",- "default": "./src/types.ts"+ "types": "./dist/types.d.ts",+ "default": "./dist/types.js",+ "import": "./dist/types.js"},"./canvaskit": {- "types": "./src/canvaskit.ts",- "bun": "./src/canvaskit.ts",- "default": "./src/canvaskit.ts"+ "types": "./dist/canvaskit.d.ts",+ "default": "./dist/canvaskit.js",+ "import": "./dist/canvaskit.js"},"./layout": {- "types": "./src/layout.ts",- "bun": "./src/layout.ts",- "default": "./src/layout.ts"+ "types": "./dist/layout.d.ts",+ "default": "./dist/layout.js",+ "import": "./dist/layout.js"},"./geometry": {- "types": "./src/geometry.ts",- "bun": "./src/geometry.ts",- "default": "./src/geometry.ts"+ "types": "./dist/geometry.d.ts",+ "default": "./dist/geometry.js",+ "import": "./dist/geometry.js"}},- "main": "./src/index.ts",- "types": "./src/index.ts",+ "main": "./dist/index.js",+ "types": "./dist/index.d.ts","files": [- "src","dist","assets"],@@ -167,154 +166,12 @@},"publishConfig": {"access": "public",- "provenance": true,- "exports": {- ".": {- "types": "./dist/index.d.ts",- "import": "./dist/index.js",- "default": "./dist/index.js"- },- "./scene-graph": {- "types": "./dist/scene-graph/index.d.ts",- "import": "./dist/scene-graph/index.js",- "default": "./dist/scene-graph/index.js"- },- "./color": {- "types": "./dist/color/index.d.ts",- "import": "./dist/color/index.js",- "default": "./dist/color/index.js"- },- "./text": {- "types": "./dist/text/index.d.ts",- "import": "./dist/text/index.js",- "default": "./dist/text/index.js"- },- "./vector": {- "types": "./dist/vector/index.d.ts",- "import": "./dist/vector/index.js",- "default": "./dist/vector/index.js"- },- "./figma-api": {- "types": "./dist/figma-api/index.d.ts",- "import": "./dist/figma-api/index.js",- "default": "./dist/figma-api/index.js"- },- "./icons": {- "types": "./dist/icons/index.d.ts",- "import": "./dist/icons/index.js",- "default": "./dist/icons/index.js"- },- "./canvas": {- "types": "./dist/canvas/index.d.ts",- "import": "./dist/canvas/index.js",- "default": "./dist/canvas/index.js"- },- "./design-jsx": {- "types": "./dist/design-jsx/index.d.ts",- "import": "./dist/design-jsx/index.js",- "default": "./dist/design-jsx/index.js"- },- "./editor": {- "types": "./dist/editor/index.d.ts",- "import": "./dist/editor/index.js",- "default": "./dist/editor/index.js"- },- "./tools": {- "types": "./dist/tools/index.d.ts",- "import": "./dist/tools/index.js",- "default": "./dist/tools/index.js"- },- "./profiler": {- "types": "./dist/profiler/index.d.ts",- "import": "./dist/profiler/index.js",- "default": "./dist/profiler/index.js"- },- "./rpc": {- "types": "./dist/rpc/index.d.ts",- "import": "./dist/rpc/index.js",- "default": "./dist/rpc/index.js"- },- "./lint": {- "types": "./dist/lint/index.d.ts",- "import": "./dist/lint/index.js",- "default": "./dist/lint/index.js"- },- "./io": {- "types": "./dist/io/index.d.ts",- "import": "./dist/io/index.js",- "default": "./dist/io/index.js"- },- "./io/formats/fig": {- "types": "./dist/io/formats/fig/index.d.ts",- "import": "./dist/io/formats/fig/index.js",- "default": "./dist/io/formats/fig/index.js"- },- "./io/formats/pen": {- "types": "./dist/io/formats/pen/index.d.ts",- "import": "./dist/io/formats/pen/index.js",- "default": "./dist/io/formats/pen/index.js"- },- "./io/formats/jsx": {- "types": "./dist/io/formats/jsx/index.d.ts",- "import": "./dist/io/formats/jsx/index.js",- "default": "./dist/io/formats/jsx/index.js"- },- "./io/formats/raster": {- "types": "./dist/io/formats/raster/index.d.ts",- "import": "./dist/io/formats/raster/index.js",- "default": "./dist/io/formats/raster/index.js"- },- "./io/formats/svg": {- "types": "./dist/io/formats/svg/index.d.ts",- "import": "./dist/io/formats/svg/index.js",- "default": "./dist/io/formats/svg/index.js"- },- "./kiwi": {- "types": "./dist/kiwi/index.d.ts",- "import": "./dist/kiwi/index.js",- "default": "./dist/kiwi/index.js"- },- "./constants": {- "types": "./dist/constants.d.ts",- "import": "./dist/constants.js",- "default": "./dist/constants.js"- },- "./random": {- "types": "./dist/random.d.ts",- "import": "./dist/random.js",- "default": "./dist/random.js"- },- "./xpath": {- "types": "./dist/xpath.d.ts",- "import": "./dist/xpath.js",- "default": "./dist/xpath.js"- },- "./types": {- "types": "./dist/types.d.ts",- "import": "./dist/types.js",- "default": "./dist/types.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"- },- "./geometry": {- "types": "./dist/geometry.d.ts",- "import": "./dist/geometry.js",- "default": "./dist/geometry.js"- }- },- "main": "./dist/index.js",- "types": "./dist/index.d.ts"+ "provenance": true},"dependencies": {+ "@chenglou/pretext": "^0.0.7","@iconify/utils": "^3.1.0",+ "@tauri-apps/api": "^2","acorn": "^8.16.0","canvaskit-wasm": "^0.40.0","culori": "^4.0.2",@@ -324,9 +181,11 @@"fflate": "^0.8.2","fontoxpath": "^3.34.0","fzstd": "^0.1.1",+ "jspdf": "^4.2.1","nanoevents": "^9.1.0","opentype.js": "^1.3.4","sucrase": "^3.35.1",+ "svg2pdf.js": "^2.7.0","svgpath": "^2.6.0","twirlwind": "^0.3.0","yoga-layout": "npm:@open-pencil/[email protected]"diff --git a/packages/core/tsdown.config.ts b/packages/core/tsdown.config.tsindex 5f54ce3da..e47c842b0 100644--- a/packages/core/tsdown.config.ts+++ b/packages/core/tsdown.config.ts@@ -1,9 +1,21 @@+import { readFileSync } from 'node:fs'+import { defineConfig } from 'tsdown'import type { Plugin } from 'rolldown'-function rawMd(): Plugin {+const packageJson = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')) as {+ dependencies?: Record<string, string>+}++function rawText(): Plugin {return {- name: 'raw-md',+ name: 'raw-text',+ load(id) {+ if (id.endsWith('?raw')) {+ const path = id.slice(0, -'?raw'.length)+ return `export default ${JSON.stringify(readFileSync(path, 'utf8'))}`+ }+ },transform(code, id) {if (id.endsWith('.md')) {return { code: `export default ${JSON.stringify(code)}`, map: null }@@ -14,7 +26,7 @@ function rawMd(): Plugin {export default defineConfig({entry: ['src/**/*.ts', '!src/**/*.d.ts'],- plugins: [rawMd()],+ plugins: [rawText()],unbundle: true,platform: 'neutral',format: ['esm'],@@ -23,22 +35,7 @@ export default defineConfig({clean: true,outDir: './dist',deps: {- neverBundle: [- '@iconify/utils',- 'canvaskit-wasm',- 'culori',- 'diff',- 'expr-eval',- 'fflate',- 'fontoxpath',- 'fzstd',- 'nanoevents',- 'opentype.js',- 'sucrase',- 'svgpath',- 'yoga-layout',- /^node:/- ],+ neverBundle: [...Object.keys(packageJson.dependencies ?? {}), /^node:/],onlyBundle: false}})diff --git a/packages/docs/de/guide/features.md b/packages/docs/de/guide/features.mdindex 446fabc39..6bd874c38 100644--- a/packages/docs/de/guide/features.md+++ b/packages/docs/de/guide/features.md@@ -111,7 +111,7 @@ open-pencil tree # Live-Dokumentopen-pencil export -f png # Canvas-Screenshot```-Alle Befehle unterstützen `--json`. Installation: `bun add -g @open-pencil/cli`+Alle Befehle unterstützen `--json`. Installation: `npm install -g @open-pencil/cli`## Echtzeit-Kollaborationdiff --git a/packages/docs/de/programmable/cli/inspecting.md b/packages/docs/de/programmable/cli/inspecting.mdindex 1adcfd525..9bdc0b636 100644--- a/packages/docs/de/programmable/cli/inspecting.md+++ b/packages/docs/de/programmable/cli/inspecting.md@@ -9,7 +9,7 @@ Das CLI ermöglicht es, `.fig`-Dateien zu erkunden, ohne den Editor zu öffnen.::: tip Installation```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli# oderbrew install open-pencil/tap/open-pencil```diff --git a/packages/docs/es/guide/features.md b/packages/docs/es/guide/features.mdindex caa106921..5a413239a 100644--- a/packages/docs/es/guide/features.md+++ b/packages/docs/es/guide/features.md@@ -111,7 +111,7 @@ open-pencil tree # Documento en vivoopen-pencil export -f png # Captura del canvas```-Todos los comandos soportan `--json`. Instalar: `bun add -g @open-pencil/cli`+Todos los comandos soportan `--json`. Instalar: `npm install -g @open-pencil/cli`## Colaboración en tiempo realdiff --git a/packages/docs/es/programmable/cli/inspecting.md b/packages/docs/es/programmable/cli/inspecting.mdindex c576a1831..e27a5fa55 100644--- a/packages/docs/es/programmable/cli/inspecting.md+++ b/packages/docs/es/programmable/cli/inspecting.md@@ -9,7 +9,7 @@ El CLI te permite explorar archivos `.fig` sin abrir el editor. Cada comando tam::: tip Instalar```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli# obrew install open-pencil/tap/open-pencil```diff --git a/packages/docs/fr/guide/features.md b/packages/docs/fr/guide/features.mdindex 37bfddd0d..a6aca21a3 100644--- a/packages/docs/fr/guide/features.md+++ b/packages/docs/fr/guide/features.md@@ -111,7 +111,7 @@ open-pencil tree # Document en directopen-pencil export -f png # Capture du canevas```-Toutes les commandes supportent `--json`. Installation : `bun add -g @open-pencil/cli`+Toutes les commandes supportent `--json`. Installation : `npm install -g @open-pencil/cli`## Collaboration en temps réeldiff --git a/packages/docs/fr/programmable/cli/inspecting.md b/packages/docs/fr/programmable/cli/inspecting.mdindex 2236c0cd1..bceab0d12 100644--- a/packages/docs/fr/programmable/cli/inspecting.md+++ b/packages/docs/fr/programmable/cli/inspecting.md@@ -9,7 +9,7 @@ Le CLI vous permet d'explorer des fichiers `.fig` sans ouvrir l'éditeur. Chaque::: tip Installation```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli# oubrew install open-pencil/tap/open-pencil```diff --git a/packages/docs/guide/features.md b/packages/docs/guide/features.mdindex 38d490803..09a0d9ad9 100644--- a/packages/docs/guide/features.md+++ b/packages/docs/guide/features.md@@ -111,7 +111,7 @@ open-pencil tree # Live documentopen-pencil export -f png # Screenshot canvas```-All commands support `--json`. Install: `bun add -g @open-pencil/cli`+All commands support `--json`. Install: `npm install -g @open-pencil/cli` (or `bun add -g @open-pencil/cli`).## Real-Time Collaborationdiff --git a/packages/docs/it/guide/features.md b/packages/docs/it/guide/features.mdindex 206aa7e5f..9cc8ee158 100644--- a/packages/docs/it/guide/features.md+++ b/packages/docs/it/guide/features.md@@ -111,7 +111,7 @@ open-pencil tree # Documento liveopen-pencil export -f png # Screenshot del canvas```-Tutti i comandi supportano `--json`. Installazione: `bun add -g @open-pencil/cli`+Tutti i comandi supportano `--json`. Installazione: `npm install -g @open-pencil/cli`## Collaborazione in Tempo Realediff --git a/packages/docs/it/programmable/cli/inspecting.md b/packages/docs/it/programmable/cli/inspecting.mdindex 877a96369..6064ab5fc 100644--- a/packages/docs/it/programmable/cli/inspecting.md+++ b/packages/docs/it/programmable/cli/inspecting.md@@ -9,7 +9,7 @@ La CLI ti permette di esplorare file `.fig` senza aprire l'editor. Ogni comando::: tip Installazione```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli# oppurebrew install open-pencil/tap/open-pencil```diff --git a/packages/docs/pl/guide/features.md b/packages/docs/pl/guide/features.mdindex b782abd4c..63e9c3660 100644--- a/packages/docs/pl/guide/features.md+++ b/packages/docs/pl/guide/features.md@@ -111,7 +111,7 @@ open-pencil tree # Aktywny dokumentopen-pencil export -f png # Zrzut ekranu canvasu```-Wszystkie komendy obsługują `--json`. Instalacja: `bun add -g @open-pencil/cli`+Wszystkie komendy obsługują `--json`. Instalacja: `npm install -g @open-pencil/cli`## Współpraca w czasie rzeczywistymdiff --git a/packages/docs/pl/programmable/cli/inspecting.md b/packages/docs/pl/programmable/cli/inspecting.mdindex c5c8f24ed..0087ce587 100644--- a/packages/docs/pl/programmable/cli/inspecting.md+++ b/packages/docs/pl/programmable/cli/inspecting.md@@ -9,7 +9,7 @@ CLI pozwala eksplorować pliki `.fig` bez otwierania edytora. Każde polecenie d::: tip Instalacja```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli# lubbrew install open-pencil/tap/open-pencil```diff --git a/packages/docs/programmable/cli/inspecting.md b/packages/docs/programmable/cli/inspecting.mdindex 1d649326f..8aaddf815 100644--- a/packages/docs/programmable/cli/inspecting.md+++ b/packages/docs/programmable/cli/inspecting.md@@ -9,7 +9,7 @@ The CLI lets you explore design documents without opening the editor. Every comm::: tip Install```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli# orbrew install open-pencil/tap/open-pencil```diff --git a/packages/docs/ru/guide/features.md b/packages/docs/ru/guide/features.mdindex 3c06e1d69..3b91bc54c 100644--- a/packages/docs/ru/guide/features.md+++ b/packages/docs/ru/guide/features.md@@ -111,7 +111,7 @@ open-pencil tree # Текущий документopen-pencil export -f png # Скриншот канваса```-Все команды поддерживают `--json`. Установка: `bun add -g @open-pencil/cli`+Все команды поддерживают `--json`. Установка: `npm install -g @open-pencil/cli`## Совместная работа в реальном времениdiff --git a/packages/docs/ru/programmable/cli/inspecting.md b/packages/docs/ru/programmable/cli/inspecting.mdindex 2ac5043c4..e1d5cf2c5 100644--- a/packages/docs/ru/programmable/cli/inspecting.md+++ b/packages/docs/ru/programmable/cli/inspecting.md@@ -9,7 +9,7 @@ CLI позволяет исследовать дизайн-документы б::: tip Установка```sh-bun add -g @open-pencil/cli+npm install -g @open-pencil/cli# илиbrew install open-pencil/tap/open-pencil```diff --git a/packages/mcp/bin/openpencil-mcp-http.js b/packages/mcp/bin/openpencil-mcp-http.jsnew file mode 100755index 000000000..201d2cec3--- /dev/null+++ b/packages/mcp/bin/openpencil-mcp-http.js@@ -0,0 +1,2 @@+#!/usr/bin/env node+import '../dist/index.mjs'diff --git a/packages/mcp/bin/openpencil-mcp.js b/packages/mcp/bin/openpencil-mcp.jsnew file mode 100755index 000000000..b97f8bcea--- /dev/null+++ b/packages/mcp/bin/openpencil-mcp.js@@ -0,0 +1,2 @@+#!/usr/bin/env node+import '../dist/stdio.mjs'diff --git a/packages/mcp/package.json b/packages/mcp/package.jsonindex 2cb709677..cbf10e8fd 100644--- a/packages/mcp/package.json+++ b/packages/mcp/package.json@@ -7,19 +7,32 @@"#mcp/*": {"types": "./src/*.ts","bun": "./src/*.ts",- "default": "./dist/*.js"+ "default": "./dist/*.mjs"+ }+ },+ "main": "./dist/server.mjs",+ "exports": {+ ".": {+ "types": "./dist/server.d.mts",+ "import": "./dist/server.mjs",+ "default": "./dist/server.mjs"+ },+ "./stdio": {+ "types": "./dist/stdio.d.mts",+ "import": "./dist/stdio.mjs",+ "default": "./dist/stdio.mjs"}},- "main": "./dist/server.js","bin": {- "openpencil-mcp": "./dist/stdio.js",- "openpencil-mcp-http": "./dist/index.js"+ "openpencil-mcp": "./bin/openpencil-mcp.js",+ "openpencil-mcp-http": "./bin/openpencil-mcp-http.js"},"files": [+ "bin","dist"],"scripts": {- "build": "bunx tsgo && bunx fix-esm-import-path dist",+ "build": "bunx tsdown --config tsdown.config.ts","prepublishOnly": "bun run build"},"repository": {diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.tsindex 7e4ae290e..d30de022c 100644--- a/packages/mcp/src/index.ts+++ b/packages/mcp/src/index.ts@@ -3,6 +3,11 @@ import { serve } from '@hono/node-server'import { startServer } from './server.js'+if (process.argv.includes('--help') || process.argv.includes('-h')) {+ process.stdout.write(`openpencil-mcp-http\n\nStart the OpenPencil MCP HTTP and WebSocket server.\n\nOptions:\n --help, -h Show this help message\n`)+ process.exit(0)+}+const port = Number.parseInt(process.env.PORT ?? '7600', 10)const wsPort = Number.parseInt(process.env.WS_PORT ?? '7601', 10)const host = process.env.HOST ?? '127.0.0.1'diff --git a/packages/mcp/src/stdio.ts b/packages/mcp/src/stdio.tsindex 0e61949ee..6ef903b1d 100644--- a/packages/mcp/src/stdio.ts+++ b/packages/mcp/src/stdio.ts@@ -5,6 +5,11 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'import { MCP_VERSION, registerTools } from './server.js'import { createStdioRpcBridge } from './stdio-bridge.js'+if (process.argv.includes('--help') || process.argv.includes('-h')) {+ process.stdout.write(`openpencil-mcp\n\nStart the OpenPencil MCP stdio bridge.\n\nOptions:\n --help, -h Show this help message\n`)+ process.exit(0)+}+const wsPort = Number.parseInt(process.env.WS_PORT ?? '7601', 10)const wsHost = process.env.HOST ?? '127.0.0.1'const enableEval = process.env.OPENPENCIL_MCP_EVAL === '1'diff --git a/packages/mcp/tsdown.config.ts b/packages/mcp/tsdown.config.tsnew file mode 100644index 000000000..e6b950653--- /dev/null+++ b/packages/mcp/tsdown.config.ts@@ -0,0 +1,32 @@+import { defineConfig } from 'tsdown'++export default defineConfig({+ entry: {+ index: './src/index.ts',+ server: './src/server.ts',+ stdio: './src/stdio.ts'+ },+ platform: 'node',+ format: ['esm'],+ dts: true,+ sourcemap: true,+ clean: true,+ outDir: './dist',+ treeshake: false,+ deps: {+ neverBundle: [+ '@hono/node-server',+ '@modelcontextprotocol/sdk',+ '@open-pencil/core',+ /^@open-pencil\/core\//,+ 'hono',+ /^hono\//,+ 'package-manager-detector',+ /^package-manager-detector\//,+ 'ws',+ 'zod',+ /^node:/+ ],+ onlyBundle: false+ }+})diff --git a/packages/vue/package.json b/packages/vue/package.jsonindex 630ba0895..7a171050d 100644--- a/packages/vue/package.json+++ b/packages/vue/package.json@@ -48,10 +48,14 @@}},"dependencies": {+ "@atlaskit/pragmatic-drag-and-drop": "^1.7.9",+ "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0","@nanostores/i18n": "^1.2.2","@nanostores/vue": "^1.1.0",+ "@tanstack/vue-table": "^8.21.3","@vueuse/core": "^14.2.1",- "nanostores": "^1.2.0"+ "nanostores": "^1.2.0",+ "reka-ui": "^2.9.0"},"devDependencies": {"tsdown": "^0.21.7",diff --git a/packages/vue/src/i18n/locale.ts b/packages/vue/src/i18n/locale.tsindex 3b0a1040f..bca201b54 100644--- a/packages/vue/src/i18n/locale.ts+++ b/packages/vue/src/i18n/locale.ts@@ -21,16 +21,19 @@ export const localeSetting = atom<Locale | undefined>(undefined)export const locale = localeFrom(localeSetting, browser({ available: AVAILABLE_LOCALES }))+function getLocalStorage(): Storage | null {+ if (typeof localStorage === 'undefined') return null+ if (typeof localStorage.getItem !== 'function') return null+ if (typeof localStorage.setItem !== 'function') return null+ return localStorage+}+export function setLocale(code: Locale) {localeSetting.set(code)- if (typeof localStorage !== 'undefined') {- localStorage.setItem(LOCALE_STORAGE_KEY, code)- }+ getLocalStorage()?.setItem(LOCALE_STORAGE_KEY, code)}-if (typeof localStorage !== 'undefined') {- const saved = localStorage.getItem(LOCALE_STORAGE_KEY) as Locale | null- if (saved && AVAILABLE_LOCALES.includes(saved)) {- localeSetting.set(saved)- }+const saved = getLocalStorage()?.getItem(LOCALE_STORAGE_KEY) as Locale | null | undefined+if (saved && AVAILABLE_LOCALES.includes(saved)) {+ localeSetting.set(saved)}diff --git a/packages/vue/tsdown.config.ts b/packages/vue/tsdown.config.tsindex f80dd7fd9..e92a16932 100644--- a/packages/vue/tsdown.config.ts+++ b/packages/vue/tsdown.config.ts@@ -1,12 +1,41 @@+import { createRequire } from 'node:module'+import raw from 'unplugin-raw/rolldown'import vue from 'unplugin-vue/rolldown'import { defineConfig } from 'tsdown'+const require = createRequire(import.meta.url)++function atlaskitSubpathResolver() {+ const aliases = new Map([+ [+ '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item',+ '@atlaskit/pragmatic-drag-and-drop-hitbox/dist/esm/tree-item.js'+ ],+ [+ '@atlaskit/pragmatic-drag-and-drop/combine',+ '@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/combine.js'+ ],+ [+ '@atlaskit/pragmatic-drag-and-drop/element/adapter',+ '@atlaskit/pragmatic-drag-and-drop/dist/esm/adapter/element-adapter.js'+ ]+ ])++ return {+ name: 'atlaskit-subpath-resolver',+ resolveId(id) {+ const target = aliases.get(id)+ return target ? require.resolve(target) : null+ }+ }+}+export default defineConfig({entry: {index: './src/index.ts'},- platform: 'neutral',+ platform: 'browser',format: ['esm'],dts: {vue: true,@@ -21,6 +50,12 @@ export default defineConfig({moduleSideEffects: false},deps: {+ alwaysBundle: [+ '@atlaskit/pragmatic-drag-and-drop',+ /^@atlaskit\/pragmatic-drag-and-drop\//,+ '@atlaskit/pragmatic-drag-and-drop-hitbox',+ /^@atlaskit\/pragmatic-drag-and-drop-hitbox\//+ ],neverBundle: ['vue',/^vue\//,@@ -33,15 +68,11 @@ export default defineConfig({'@nanostores/i18n','nanostores','@tanstack/vue-table',- 'reka-ui',- '@atlaskit/pragmatic-drag-and-drop',- /^@atlaskit\/pragmatic-drag-and-drop\//,- '@atlaskit/pragmatic-drag-and-drop-hitbox',- /^@atlaskit\/pragmatic-drag-and-drop-hitbox\//+ 'reka-ui'],onlyBundle: false},- plugins: [raw(), vue()],+ plugins: [atlaskitSubpathResolver(), raw(), vue()],inputOptions: {preserveEntrySignatures: 'allow-extension',checks: {diff --git a/scripts/check-package-metadata.ts b/scripts/check-package-metadata.tsnew file mode 100644index 000000000..fc06abbbf--- /dev/null+++ b/scripts/check-package-metadata.ts@@ -0,0 +1,72 @@+import { readFileSync } from 'node:fs'+import { join } from 'node:path'++const publicPackages = ['packages/core', 'packages/cli', 'packages/mcp', 'packages/vue']++interface PackageJson {+ name: string+ main?: string+ types?: string+ files?: string[]+ bin?: Record<string, string> | string+ exports?: unknown+ publishConfig?: Record<string, unknown>+}++const errors: string[] = []++function readPackageJson(packageDir: string): PackageJson {+ return JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8'))+}++function checkRuntimePath(packageName: string, field: string, value: string): void {+ if (value.endsWith('.ts') && !value.endsWith('.d.ts')) {+ errors.push(`${packageName}: ${field} must not point to runtime TypeScript (${value})`)+ }+ if (value.startsWith('./src/')) {+ errors.push(`${packageName}: ${field} must not point to source files (${value})`)+ }+}++function walkExports(packageName: string, value: unknown, path: string[] = []): void {+ if (typeof value === 'string') {+ const key = path.at(-1)+ if (key !== 'types' && key !== 'bun') checkRuntimePath(packageName, `exports.${path.join('.')}`, value)+ return+ }+ if (!value || typeof value !== 'object') return+ for (const [key, child] of Object.entries(value)) {+ walkExports(packageName, child, [...path, key])+ }+}++for (const packageDir of publicPackages) {+ const pkg = readPackageJson(packageDir)++ if (!pkg.files?.includes('dist')) {+ errors.push(`${pkg.name}: files must include dist`)+ }++ if (pkg.main) checkRuntimePath(pkg.name, 'main', pkg.main)++ if (typeof pkg.bin === 'string') {+ checkRuntimePath(pkg.name, 'bin', pkg.bin)+ } else if (pkg.bin) {+ for (const [name, target] of Object.entries(pkg.bin)) {+ checkRuntimePath(pkg.name, `bin.${name}`, target)+ }+ }++ walkExports(pkg.name, pkg.exports)++ if (pkg.publishConfig && ('exports' in pkg.publishConfig || 'main' in pkg.publishConfig || 'types' in pkg.publishConfig)) {+ errors.push(`${pkg.name}: publishConfig must not rewrite runtime entrypoints`)+ }+}++if (errors.length > 0) {+ console.error(errors.join('\n'))+ process.exit(1)+}++console.log('Package metadata is publish-safe.')diff --git a/scripts/smoke-packages.ts b/scripts/smoke-packages.tsnew file mode 100644index 000000000..895bac93e--- /dev/null+++ b/scripts/smoke-packages.ts@@ -0,0 +1,67 @@+import { mkdtempSync, rmSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { basename, join } from 'node:path'+import { fileURLToPath } from 'node:url'++const rootDir = fileURLToPath(new URL('..', import.meta.url))+const packageDirs = ['packages/core', 'packages/vue', 'packages/mcp', 'packages/cli']++function run(command: string[], cwd = rootDir): string {+ const proc = Bun.spawnSync(command, { cwd, stdout: 'pipe', stderr: 'pipe' })+ const stdout = proc.stdout.toString()+ const stderr = proc.stderr.toString()+ if (!proc.success) {+ console.error(`$ ${command.join(' ')}`)+ if (stdout) console.error(stdout)+ if (stderr) console.error(stderr)+ process.exit(proc.exitCode || 1)+ }+ return stdout.trim()+}++function nodeEval(code: string, cwd: string): void {+ run(['node', '--input-type=module', '--eval', code], cwd)+}++const tempDir = mkdtempSync(join(tmpdir(), 'open-pencil-package-smoke-'))++try {+ run(['bun', 'run', 'build:packages'])++ const tarballs: string[] = []+ for (const packageDir of packageDirs) {+ const output = run(['bun', 'pm', 'pack', '--destination', tempDir, '--quiet'], join(rootDir, packageDir))+ const filename = output+ .split('\n')+ .map((line) => line.trim())+ .findLast((line) => line.length > 0)+ if (!filename) throw new Error(`No tarball produced for ${packageDir}`)+ const tarball = filename.startsWith('/') ? filename : join(tempDir, filename)+ tarballs.push(tarball)++ const contents = run(['tar', '-tf', tarball])+ const runtimeTs = contents+ .split('\n')+ .filter((entry) => /package\/src\/.*\.ts$/.test(entry) && !entry.endsWith('.d.ts'))+ if (runtimeTs.length > 0) {+ console.error(`${basename(tarball)} includes runtime TypeScript:\n${runtimeTs.join('\n')}`)+ process.exit(1)+ }+ }++ run(['npm', 'init', '-y'], tempDir)+ run(['npm', 'install', '--ignore-scripts', '--no-audit', '--no-fund', ...tarballs], tempDir)++ nodeEval("await import('@open-pencil/core')", tempDir)+ nodeEval("await import('@open-pencil/core/scene-graph')", tempDir)+ nodeEval("await import('@open-pencil/vue')", tempDir)+ nodeEval("await import('@open-pencil/mcp')", tempDir)++ run(['node', 'node_modules/.bin/openpencil', '--help'], tempDir)+ run(['node', 'node_modules/.bin/openpencil-mcp', '--help'], tempDir)+ run(['node', 'node_modules/.bin/openpencil-mcp-http', '--help'], tempDir)++ console.log('Packed package smoke tests passed.')+} finally {+ rmSync(tempDir, { recursive: true, force: true })+}