Commit graph

1279 commits

Author SHA1 Message Date
Danila Poyarkov 23039e0b99 fix(canvas): wait for CJK fallback fonts
- Skip CJK and Arabic text until fallback font families are ready
- Re-render after async fallback font loading completes
- Add Playwright coverage for delayed CJK fallback loading
2026-05-12 16:54:55 +03:00
Danila Poyarkov ddf415ec30 feat(tauri): support desktop file associations
- Register .fig and .pen files with desktop bundles
- Open associated files on startup and via single-instance handoff
- Reuse the existing Tauri file open flow without broad filesystem scopes
2026-05-12 16:12:16 +03:00
Tem-man 3fb2cfc7b1
update id and name of deepseek as deepseek-v4-flash and deepseek-v4-pro (#253)
Update DeepSeek model IDs to the new V4 Flash/Pro names, set V4 Flash as the default, and bump @ai-sdk/deepseek.
2026-05-12 15:23:53 +03:00
Danila Poyarkov ac5db0dc9f docs: tighten domain folder convention in AGENTS.md 2026-05-11 12:20:53 +03:00
Danila Poyarkov 5787e45117 refactor(tools): move eval modules into domain folder 2026-05-11 12:19:46 +03:00
Danila Poyarkov a1339e845b refactor(tools): use acorn AST parser for eval wrapping
Replace hand-rolled regex heuristic with proper acorn JS parsing.
The AST correctly identifies ExpressionStatement as the last node
regardless of trailing semicolons, comments, or complex syntax.

Fixes edge cases like '42;' which the regex wrongly treated as a
statement.

Co-authored-by: stiff <v.stiff@gmail.com>
Co-authored-by: Jais Pedersen <jais@pedersens.net>
2026-05-11 12:15:38 +03:00
Danila Poyarkov 9e013e60e7 fix(mcp): fix stdio handshake and eval return values
Stdio handshake:
Server now sends { type: register, token } to WebSocket clients on
connection, so the stdio bridge receives the token immediately instead
of deadlocking while both sides wait to receive.

Eval return values (REPL-style):
Add wrapEvalCode() that detects when the last non-empty line is a value
expression and promotes it to a return statement. Bare expressions like
JSON.stringify(result) now return the value instead of undefined.
Single implementation in packages/core/src/tools/analyze/eval-wrap.ts
used by both the tool and the automation bridge.

Co-authored-by: stiff <v.stiff@gmail.com>
Co-authored-by: Jais Pedersen <jais@pedersens.net>
2026-05-11 12:05:43 +03:00
Danila Poyarkov 74e550adb2 chore(i18n): sync all locale files and add CI check
- Add scripts/check-locales.ts to detect missing/extra locale keys
- Wire as 'check:i18n' in the check pipeline
- Add missing translations for de, es, fr, it, pl, ru, zh-CN:
  layout size limits, gap controls, variable modes, variants
2026-05-07 21:42:34 +03:00
Danila Poyarkov c79c9106fb feat(components): add variant inspector UI
Show variant property dropdowns in the design panel when an instance
of a component set is selected. Switching a dropdown value finds the
matching variant component and updates the instance's componentId.

- VariantSection.vue with property dropdowns using AppSelect
- Bridge variant actions to the editor return object
- i18n for en, ru, zh-CN

Ref #239
2026-05-07 19:48:59 +03:00
Danila Poyarkov fee44ebdb7 feat(components): add variant property data model and core actions
Data model:
- Add ComponentPropertyDefinition and ComponentPropertyType to SceneNode
- Add componentPropertyValues for per-variant property values
- Populate from .fig import via componentPropDefs kiwi field
- Parse variant name=value syntax from component names on import

Core actions (packages/core/src/editor/components/variants.ts):
- Add/remove/rename variant property definitions with undo
- Collect variant options from component set children
- Find variant by property values
- Switch instance variant by changing a property value
- Parse and build variant name strings

Combine as variants:
- Parse slash-naming (Button/Primary/Large) into variant properties
- Auto-detect property columns from consistent slash counts
- Populate componentPropertyValues on each variant component

Ref #239
2026-05-07 16:12:46 +03:00
Danila Poyarkov ad88364562 feat(variables): bind min/max size constraints to variables
Wire VariableScrubInput for minWidth, maxWidth, minHeight, maxHeight
in the size controls panel. Uses the after-variable slot to preserve
the existing select dropdown suffix alongside the variable binding UI.
2026-05-07 14:32:36 +03:00
Danila Poyarkov 72614fac4c fix(editor): paste into selected container
Paste now targets the selected frame/group/component/section instead of
always placing nodes on the page root, matching Figma's behavior:

- Single container selected: paste as child
- Non-container child selected: paste as sibling in its parent
- Entered container (double-click): paste inside it
- Nothing or multiple nodes selected: paste on the page

Also applies to image paste via placeImageFiles.

Fixes #79
2026-05-07 13:56:30 +03:00
Danila Poyarkov 98ce9a70ac docs: update changelog with variables and refactoring work 2026-05-07 11:41:52 +03:00
Danila Poyarkov 99d4cb8c3b docs: update changelog with variables and refactoring work 2026-05-07 10:38:37 +03:00
Danila Poyarkov 4e702799fc refactor: reuse blurTarget in inline rename 2026-05-07 10:30:27 +03:00
Danila Poyarkov a6da185e54 refactor: eliminate HTMLInputElement template casts
- Add shared DOM event helpers to Vue SDK (inputValue, inputNumberValue,
  blurTarget, selectTarget) in packages/vue/src/shared/dom-events.ts
- Export from @open-pencil/vue for app consumption
- Replace all template `as HTMLInputElement` casts with helper calls:
  ColorPickerPanel fields, PickerSlider, GradientEditor, ColorInput,
  CollabPanel, AppMenu, ScrubInputRoot
- Fix useInlineRename to use instanceof guards instead of casts
- Fix document name rename to accept Event directly
2026-05-07 10:24:46 +03:00
Danila Poyarkov 0a268f0a65 feat(variables): add inspector bindings for typography properties
- Add lineHeight, letterSpacing, fontWeight, paragraphSpacing,
  paragraphIndent to NumberBindingPath
- Wire lineHeight and letterSpacing inputs in TypographySection
  to VariableScrubInput with variable binding support
2026-05-07 09:50:52 +03:00
Danila Poyarkov 506b5f81e1 refactor(variables): reuse useInlineRename for dialog renaming
- Reuse useInlineRename composable for collection and mode renaming
- Accept Event in useInlineRename.commit to eliminate template casts
- Remove HTMLInputElement casts from PagesPanel and LayerTree blur handlers
- Remove hand-rolled rename state from dialog composable
2026-05-07 00:02:13 +03:00
Danila Poyarkov 107e9f3d51 feat(variables): add mode management and collection deletion
Core:
- Add addMode, removeMode, renameMode, setDefaultMode to SceneGraph
- Add editor actions with full undo: addMode, removeMode, renameMode,
  setDefaultMode, duplicateMode, setActiveMode

Vue SDK:
- Wire all mode and collection actions through SDK helpers
- Add mode rename state to dialog composable
- Remove HTMLInputElement casts from commit handlers

UI:
- Mode management lives in the table column headers (Figma-style):
  double-click to rename, right-click for context menu (rename,
  duplicate, set as default, delete), + button after last mode column
- Collection ⋯ dropdown menu with rename and delete
- Use shared menu UI styles throughout
- i18n for en, ru, zh-CN
2026-05-06 21:36:04 +03:00
Danila Poyarkov 2147aeb327 fix(core): resolve bundled fonts from package root
Replace fragile ../../assets relative path with createRequire-based
package.json resolution. The old path broke if the file moved or after
bundler output restructuring. The new approach resolves the package root
via require.resolve('@open-pencil/core/package.json') which works from
source, dist, and node_modules.
2026-05-06 17:07:31 +03:00
Danila Poyarkov c2afb8ddca chore(lint): enforce type safety in scripts
- Fix non-null assertions in visual-compare script
- Fix missing radix parameter
- Replace ImageMagick rgba() color with hex notation
- Remove no-non-null-assertion, no-hand-rolled-color, and radix script overrides
- Keep only no-console override for CLI scripts
2026-05-06 16:41:40 +03:00
Danila Poyarkov 541c9bd13c test: move tauri helpers into domain folder
- Move tests/helpers/tauri-mocks.ts → tests/helpers/tauri/mocks.ts
- Move tests/helpers/tauri-fig-export-fixture.ts → tests/helpers/tauri/fig-export-fixture.ts
- Update all imports
2026-05-06 16:16:08 +03:00
Danila Poyarkov 738d199e8a refactor: remove ugly type intersection casts
- Add optional nodeEditState, cursorCanvas, and pen resume fields to core EditorState
- Add parent field to LintNode instead of repeated intersection casts
- Use typed LintPathNode for node path traversal
- Replace autosave useDebounceFn cancel hack with watchDebounced
- Simplify AppEditorState to extend EditorState without Omit+intersection
- Remove PenState intersection type alias
- Use in-operator check for optional setViewportSize
2026-05-06 16:08:36 +03:00
Danila Poyarkov 7dce333200 docs: document event bus and wire app consumers
- Update CHANGELOG.md with event bus, test restructuring, and lint hardening
- Document EditorEvents table and conventions in AGENTS.md
- Wire collab graph sync to editor event bus instead of SceneGraph.onNodeEvents
- Wire collab awareness zoom to viewport:changed instead of Vue watcher
- Wire collab selection broadcasting to selection:changed instead of Vue watcher
2026-05-06 15:38:45 +03:00
Danila Poyarkov 1835903e56 feat(editor): add event bus for editor lifecycle events
Wire nanoevents-based event bus to the editor core:

- EditorEvents type with render, graph, selection, tool, page, viewport events
- All node mutations (create/update/delete/reparent/reorder) forwarded from SceneGraph
- Selection changes routed through setSelectedIds() with diff detection
- Tool changes routed through setActiveTool() with change detection
- Page switches emit page:changed
- Viewport pan/zoom/fit/zoomTo emit viewport:changed
- Graph replacement emits graph:replaced
- Typed onEditorEvent() subscription on the Editor return object
- useEditorEvent() Vue composable with automatic scope cleanup
- Replace all direct state.selectedIds/state.activeTool mutations in core, app, and SDK
2026-05-06 15:25:27 +03:00
Danila Poyarkov dfa9505805 chore(lint): enforce domain prefix folders project-wide
- Generalize sibling domain prefix linting beyond tests
- Move create icon tools under the existing create domain folder
- Keep create.ts exporting the icon tools through the domain folder
2026-05-06 14:33:17 +03:00
Danila Poyarkov aad26b535e test: move prefixed splits into domain folders
- Move newly split tests under explicit domain subfolders
- Update nested helper imports after the moves
- Add a lint guard against repeating existing sibling domains as filename prefixes
2026-05-06 14:27:21 +03:00
Danila Poyarkov b9da0dcb76 chore(lint): enforce test complexity limits
- Extract color picker fill comparison helpers
- Guard derived text assertions without optional chains
- Split resize math into smaller helper functions
- Remove the remaining complexity test exceptions
2026-05-06 14:18:29 +03:00
Danila Poyarkov 13a3475026 test(layout): split auto-layout coverage
- Move auto-layout tests into focused files by layout behavior
- Preserve sizing, wrapping, text measurement, and positioning coverage
- Remove the last max-lines test exception
2026-05-06 14:10:20 +03:00
Danila Poyarkov 5e7c042352 test(scene-graph): split basic coverage
- Move scene graph behavior tests into focused files
- Share basic scene graph helper builders from basic/helpers.ts
- Remove scene graph basic from max-lines exceptions
2026-05-06 14:05:58 +03:00
Danila Poyarkov c589818a71 test(clipboard): split node import coverage
- Move clipboard node import tests into focused files by behavior
- Preserve filtering, hierarchy, styling, component, and undo coverage
- Remove import-nodes from max-lines exceptions
2026-05-06 14:01:18 +03:00
Danila Poyarkov 9ebc61d78f test(figma): split API coverage
- Move FigmaAPI tests into focused files by feature area
- Share API construction from figma/api/helpers.ts
- Remove FigmaAPI coverage from max-lines exceptions
2026-05-06 13:37:15 +03:00
Danila Poyarkov 54ccc35e3e test(fig): split legacy import coverage
- Move legacy fig import tests into focused domain files
- Share NodeChange fixture builders from legacy/helpers.ts
- Remove legacy import from max-lines exceptions
2026-05-06 13:33:42 +03:00
Danila Poyarkov 42d346ba47 test(kiwi): split serialization regression coverage
- Move Kiwi serialization fix tests into one file per regression area
- Share codec setup and Kiwi helpers from serialize-fixes/helpers.ts
- Remove serialize fixes from max-lines exceptions
2026-05-06 13:12:53 +03:00
Danila Poyarkov 24629610a4 test(render): split canvas effect coverage
- Move canvas effect renderer tests into focused files by behavior
- Share renderer and canvas mocks from effects/helpers.ts
- Remove canvas effects from max-lines exceptions
2026-05-06 13:05:51 +03:00
Danila Poyarkov 93d5370d7d test(svg): split SVG export coverage
- Move SVG builder, path, and render export tests into focused files
- Share SVG export helpers from tests/engine/svg/export/helpers.ts
- Remove svg export from max-lines exceptions
2026-05-06 12:57:54 +03:00
Danila Poyarkov 21a3337a96 chore(tests): enforce no-empty-function
- Replace remaining empty mock callbacks with explicit undefined returns
- Remove the last no-empty-function test exceptions
- Validate check and affected renderer/text tests
2026-05-06 12:40:42 +03:00
Danila Poyarkov 432f945da6 chore(tests): narrow no-empty-function exceptions
- Replace simple no-op test callbacks with explicit undefined returns
- Remove no-empty-function exceptions for autosave, stroke picker, font settings, pen, tauri, AI adapter, and undo helper tests
- Validate check plus affected engine and E2E tests
2026-05-06 12:32:54 +03:00
Danila Poyarkov bbf122a5c5 chore(tests): route store access through browser bridge
- Expose window.openPencil.getStore() instead of a direct store property
- Update E2E helpers and specs to use the bridge getter
- Add lint coverage preventing direct window.openPencil.store access
2026-05-06 12:19:39 +03:00
Danila Poyarkov 657188b097 chore(tests): enforce non-null assertion rule
- Remove remaining test non-null assertions and delete the broad test override
- Add explicit guards for canvas, design panel, auto-layout, SVG, Kiwi, hit-test, scene graph, text editor, and clipboard tests
- Validate check plus affected engine and E2E coverage
2026-05-06 11:44:18 +03:00
Danila Poyarkov 17857f912f chore(tests): guard render text and mutation lookups
- Replace non-null assertions in canvas text rendering and mutation undo tests
- Use expectDefined for CanvasKit handles and getNodeOrThrow for graph nodes
- Validate check and affected engine tests
2026-05-06 11:27:24 +03:00
Danila Poyarkov 1367ee3b35 chore(tests): guard modify tool assertions
- Replace non-null assertions in modify tool tests
- Use expectDefined and getNodeOrThrow for graph, proxy, and style-run lookups
- Validate check and affected modify tool tests
2026-05-06 11:20:49 +03:00
Danila Poyarkov 77aede6770 chore(tests): guard image test lookups
- Replace non-null assertions in image tool, clipboard, and fig roundtrip tests
- Use expectDefined for tool lookup, clipboard parse, and restored image bytes
- Validate check and affected image/undo tests
2026-05-06 11:18:03 +03:00
Danila Poyarkov 86cb3970ff chore(tests): guard component and cache assertions
- Remove non-null assertions from component, visibility, scene cache, and redo sequence tests
- Add explicit node, store, renderer, and canvas bounds guards
- Validate check plus affected engine and E2E coverage
2026-05-06 11:07:47 +03:00
Danila Poyarkov f7b20a8f38 chore(tests): namespace browser test hooks
- Move test-only write-count, mock-handle, and saved-open globals under window.openPencil.test
- Keep external Tauri and Vite injected globals separate from app-owned browser bridge hooks
- Validate check plus autosave and chat E2E coverage
2026-05-06 10:49:46 +03:00
Danila Poyarkov 8719274cc9 chore(app): clarify browser bridge naming
- Rename window-api to browser-bridge to describe the app-to-browser test hook boundary
- Rename the chat transport hook to exposeChatTransportOverride and window.openPencil.setChatTransport
2026-05-06 10:43:15 +03:00
Danila Poyarkov 8ec70330b4 chore(lint): centralize OpenPencil window API
- Route browser globals through src/app/window-api.ts instead of private __OPEN_PENCIL fields
- Move E2E tests to the public window.openPencil test API
- Add an oxlint rule banning direct window.__OPEN_PENCIL* access
2026-05-06 10:38:03 +03:00
Danila Poyarkov c7d2d0d0ad chore(tests): guard viewport and text assertions
- Remove non-null assertions from keyboard, text editing, viewport, and legacy fig import tests
- Add explicit canvas, store, page-node, and variable guards
- Validate check, legacy fig import, keyboard, and viewport E2E coverage
2026-05-06 10:16:24 +03:00
Danila Poyarkov eba56fbe38 chore(tests): guard text and keyboard lookups
- Replace non-null assertions in keyboard, text editing, and legacy fig import coverage
- Add explicit store guards and expectDefined for optional test data
- Validate check, legacy fig import, and keyboard E2E coverage
2026-05-06 10:10:54 +03:00
Danila Poyarkov ac5bb4add3 chore(tests): guard engine node assertions
- Replace non-null assertions in effects, Figma API, and individual stroke tests
- Use expectDefined and getNodeOrThrow for optional graph/proxy lookups
- Validate affected engine tests
2026-05-06 09:48:55 +03:00