pixelweaver 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.development +1 -0
- package/.github/workflows/ci.yml +22 -0
- package/.github/workflows/publish.yml +18 -0
- package/.prettierignore +5 -0
- package/.prettierrc +16 -0
- package/.python-version +1 -0
- package/.rlsbl/bases/.github/workflows/ci.yml +21 -0
- package/.rlsbl/bases/.github/workflows/publish.yml +18 -0
- package/.rlsbl/bases/.rlsbl/changes/unreleased.jsonl +0 -0
- package/.rlsbl/bases/.rlsbl/hooks/post-release.sh +8 -0
- package/.rlsbl/bases/.rlsbl/hooks/pre-checks.sh +5 -0
- package/.rlsbl/bases/.rlsbl/hooks/pre-release.sh +8 -0
- package/.rlsbl/bases/.rlsbl/lint/go.toml +17 -0
- package/.rlsbl/bases/.rlsbl/lint/npm.toml +19 -0
- package/.rlsbl/bases/.rlsbl/lint/python.toml +25 -0
- package/.rlsbl/bases/CHANGELOG.md +5 -0
- package/.rlsbl/bases/LICENSE +21 -0
- package/.rlsbl/changes/.validated +1 -0
- package/.rlsbl/changes/0.1.0.jsonl +85 -0
- package/.rlsbl/changes/0.1.0.md +13 -0
- package/.rlsbl/changes/unreleased.jsonl +0 -0
- package/.rlsbl/config.json +6 -0
- package/.rlsbl/hashes.json +14 -0
- package/.rlsbl/hooks/post-release.sh +8 -0
- package/.rlsbl/hooks/pre-checks.sh +5 -0
- package/.rlsbl/hooks/pre-release.sh +8 -0
- package/.rlsbl/lint/go.toml +17 -0
- package/.rlsbl/lint/npm.toml +19 -0
- package/.rlsbl/lint/python.toml +25 -0
- package/.rlsbl/releases/unreleased.toml +0 -0
- package/.rlsbl/releases/v0.1.0.toml +3 -0
- package/.rlsbl/version +1 -0
- package/.selfdoc/hashes/hashes.json +146 -0
- package/.strictcli/schema.json +227 -0
- package/CHANGELOG.md +17 -0
- package/CLAUDE.md +100 -0
- package/LICENSE +21 -0
- package/README.md +116 -0
- package/assets/icon.png +0 -0
- package/docs/_README.md +117 -0
- package/docs/cli-config.md +35 -0
- package/docs/cli-dev.md +21 -0
- package/docs/cli-diagnose.md +12 -0
- package/docs/cli-index.md +30 -0
- package/docs/cli-list.md +18 -0
- package/docs/cli-mcp.md +18 -0
- package/docs/cli-new.md +26 -0
- package/docs/cli-open.md +21 -0
- package/docs/cli-serve.md +21 -0
- package/docs/cli-stop.md +12 -0
- package/docs/gen-index.md +36 -0
- package/docs/index.md +13 -0
- package/docs/server-src-pixelweaver-__main__.md +12 -0
- package/docs/server-src-pixelweaver-autosave.md +12 -0
- package/docs/server-src-pixelweaver-bridge.md +12 -0
- package/docs/server-src-pixelweaver-cli.md +12 -0
- package/docs/server-src-pixelweaver-config.md +12 -0
- package/docs/server-src-pixelweaver-connections.md +12 -0
- package/docs/server-src-pixelweaver-main.md +12 -0
- package/docs/server-src-pixelweaver-mcp_bridge.md +12 -0
- package/docs/server-src-pixelweaver-mcp_drawing_tools.md +12 -0
- package/docs/server-src-pixelweaver-mcp_export_tools.md +12 -0
- package/docs/server-src-pixelweaver-mcp_frame_tools.md +12 -0
- package/docs/server-src-pixelweaver-mcp_history_tools.md +12 -0
- package/docs/server-src-pixelweaver-mcp_layer_tools.md +12 -0
- package/docs/server-src-pixelweaver-mcp_lock.md +12 -0
- package/docs/server-src-pixelweaver-mcp_project_tools.md +12 -0
- package/docs/server-src-pixelweaver-mcp_read_tools.md +12 -0
- package/docs/server-src-pixelweaver-mcp_registry.md +12 -0
- package/docs/server-src-pixelweaver-mcp_resources.md +12 -0
- package/docs/server-src-pixelweaver-mcp_server.md +12 -0
- package/docs/server-src-pixelweaver-protocol.md +12 -0
- package/docs/server-src-pixelweaver-state.md +12 -0
- package/docs/server-src-pixelweaver-storage.md +12 -0
- package/docs/server-src-pixelweaver-websocket.md +12 -0
- package/docs/server-src-pixelweaver.md +12 -0
- package/e2e/app-launch.test.ts +35 -0
- package/e2e/menus.test.ts +26 -0
- package/e2e/tools.test.ts +27 -0
- package/e2e/undo-redo.test.ts +11 -0
- package/eslint.config.js +62 -0
- package/index.html +13 -0
- package/package.json +48 -0
- package/playwright.config.ts +19 -0
- package/plugins/builtin/.gitkeep +0 -0
- package/plugins/builtin/advanced-fill-tool.ts +146 -0
- package/plugins/builtin/circle-tool.ts +186 -0
- package/plugins/builtin/diamond-tool.ts +182 -0
- package/plugins/builtin/dither-tool.ts +186 -0
- package/plugins/builtin/drawing-primitives-plugin.ts +362 -0
- package/plugins/builtin/drawing-utils.test.ts +495 -0
- package/plugins/builtin/drawing-utils.ts +431 -0
- package/plugins/builtin/effects/blur.ts +97 -0
- package/plugins/builtin/effects/color-effects.ts +278 -0
- package/plugins/builtin/effects/flip.ts +83 -0
- package/plugins/builtin/effects/glow.ts +118 -0
- package/plugins/builtin/effects/outline.ts +110 -0
- package/plugins/builtin/effects/rotate.ts +357 -0
- package/plugins/builtin/effects/scale.ts +258 -0
- package/plugins/builtin/effects/shadow.ts +111 -0
- package/plugins/builtin/effects/sharpen.ts +102 -0
- package/plugins/builtin/effects.test.ts +715 -0
- package/plugins/builtin/eraser-tool.ts +23 -0
- package/plugins/builtin/eyedropper-tool.ts +83 -0
- package/plugins/builtin/fill-tool.ts +93 -0
- package/plugins/builtin/gradient-tool.ts +204 -0
- package/plugins/builtin/gradient.test.ts +142 -0
- package/plugins/builtin/importers/aseprite-importer-plugin.ts +174 -0
- package/plugins/builtin/importers/aseprite-parser.ts +497 -0
- package/plugins/builtin/importers/piskel-importer-plugin.ts +222 -0
- package/plugins/builtin/importers/sky-spec-plugin.ts +409 -0
- package/plugins/builtin/line-tool.ts +267 -0
- package/plugins/builtin/make-stroke-tool.ts +271 -0
- package/plugins/builtin/noise-dither.test.ts +151 -0
- package/plugins/builtin/noise-tool.ts +131 -0
- package/plugins/builtin/pattern-stamp-tool.ts +162 -0
- package/plugins/builtin/pencil-tool.ts +25 -0
- package/plugins/builtin/rect-tool.ts +179 -0
- package/plugins/builtin/selection-tool.ts +388 -0
- package/plugins/builtin/selection.test.ts +195 -0
- package/plugins/builtin/tool-plugins.test.ts +529 -0
- package/public/favicon.svg +7 -0
- package/public/sw.js +91 -0
- package/pyproject.toml +49 -0
- package/scripts/eslint-wave-a-list.sh +24 -0
- package/scripts/eslint-wave-a-status.sh +25 -0
- package/scripts/fix-index-signature-access.py +127 -0
- package/scripts/fix-unchecked-index.py +128 -0
- package/scripts/fix-unchecked-vars.py +127 -0
- package/scripts/fix-wave-a-bangs.py +36 -0
- package/scripts/fix-wave-a-templates.py +108 -0
- package/scripts/fix-wave-b-void-expr.py +167 -0
- package/scripts/generate-command-params.py +540 -0
- package/scripts/migrate-single-frame-to-multi.py +171 -0
- package/scripts/smoke-test.sh +77 -0
- package/selfdoc.json +10 -0
- package/server/README.md +0 -0
- package/server/src/pixelweaver/__init__.py +1 -0
- package/server/src/pixelweaver/__main__.py +4 -0
- package/server/src/pixelweaver/autosave.py +114 -0
- package/server/src/pixelweaver/bridge.py +127 -0
- package/server/src/pixelweaver/cli.py +199 -0
- package/server/src/pixelweaver/config.py +24 -0
- package/server/src/pixelweaver/connections.py +54 -0
- package/server/src/pixelweaver/main.py +271 -0
- package/server/src/pixelweaver/mcp_bridge.py +189 -0
- package/server/src/pixelweaver/mcp_drawing_tools.py +178 -0
- package/server/src/pixelweaver/mcp_export_tools.py +291 -0
- package/server/src/pixelweaver/mcp_frame_tools.py +423 -0
- package/server/src/pixelweaver/mcp_history_tools.py +106 -0
- package/server/src/pixelweaver/mcp_layer_tools.py +64 -0
- package/server/src/pixelweaver/mcp_lock.py +37 -0
- package/server/src/pixelweaver/mcp_project_tools.py +302 -0
- package/server/src/pixelweaver/mcp_read_tools.py +163 -0
- package/server/src/pixelweaver/mcp_registry.py +247 -0
- package/server/src/pixelweaver/mcp_resources.py +312 -0
- package/server/src/pixelweaver/mcp_server.py +234 -0
- package/server/src/pixelweaver/protocol.py +219 -0
- package/server/src/pixelweaver/state.py +267 -0
- package/server/src/pixelweaver/storage.py +293 -0
- package/server/src/pixelweaver/websocket.py +282 -0
- package/server/tests/__init__.py +0 -0
- package/server/tests/conftest.py +17 -0
- package/server/tests/test_api.py +96 -0
- package/server/tests/test_bridge.py +161 -0
- package/server/tests/test_health.py +9 -0
- package/server/tests/test_integration.py +86 -0
- package/server/tests/test_mcp_bridge.py +293 -0
- package/server/tests/test_mcp_lock.py +34 -0
- package/server/tests/test_mcp_registry.py +679 -0
- package/server/tests/test_mcp_resources.py +648 -0
- package/server/tests/test_protocol.py +125 -0
- package/server/tests/test_state.py +87 -0
- package/server/tests/test_storage.py +306 -0
- package/server/tests/test_websocket.py +275 -0
- package/src/App.svelte +107 -0
- package/src/app.css +215 -0
- package/src/lib/animation/AnimationPreviewPanel.svelte +667 -0
- package/src/lib/animation/animation-commands.test.ts +228 -0
- package/src/lib/animation/animation-commands.ts +540 -0
- package/src/lib/animation/animation-preview-panel-plugin.ts +25 -0
- package/src/lib/animation/animation-preview.svelte.ts +151 -0
- package/src/lib/animation/clipboard.ts +134 -0
- package/src/lib/animation/frame-model.svelte.ts +437 -0
- package/src/lib/animation/frame-model.test.ts +314 -0
- package/src/lib/animation/frame-selection.svelte.ts +77 -0
- package/src/lib/animation/frame-tags.svelte.ts +238 -0
- package/src/lib/animation/frame-tags.test.ts +136 -0
- package/src/lib/animation/import.test.ts +141 -0
- package/src/lib/animation/import.ts +112 -0
- package/src/lib/animation/spritesheet-export.test.ts +239 -0
- package/src/lib/animation/spritesheet-export.ts +314 -0
- package/src/lib/canvas/CanvasViewport.svelte +216 -0
- package/src/lib/canvas/canvas-init-plugin.ts +178 -0
- package/src/lib/canvas/canvas-renderer.ts +408 -0
- package/src/lib/canvas/canvas-state.svelte.ts +232 -0
- package/src/lib/canvas/canvas-state.test.ts +139 -0
- package/src/lib/canvas/input-handler.ts +221 -0
- package/src/lib/canvas/input-plugin.ts +150 -0
- package/src/lib/canvas/onion-skin.ts +94 -0
- package/src/lib/canvas/pixel-buffer.test.ts +249 -0
- package/src/lib/canvas/pixel-buffer.ts +151 -0
- package/src/lib/canvas/render-state.svelte.ts +18 -0
- package/src/lib/canvas/shape-preview-state.svelte.ts +36 -0
- package/src/lib/canvas/tile-mode.test.ts +53 -0
- package/src/lib/canvas/tile-mode.ts +92 -0
- package/src/lib/canvas/viewport-utils.ts +24 -0
- package/src/lib/canvas/zoom-utils.ts +31 -0
- package/src/lib/color/.gitkeep +0 -0
- package/src/lib/color/color-commands.ts +87 -0
- package/src/lib/color/color-state.svelte.ts +98 -0
- package/src/lib/color/color-state.test.ts +91 -0
- package/src/lib/color/color-utils.test.ts +220 -0
- package/src/lib/color/color-utils.ts +243 -0
- package/src/lib/color/palette-state.svelte.ts +127 -0
- package/src/lib/color/palette-state.test.ts +154 -0
- package/src/lib/color/palette.ts +79 -0
- package/src/lib/core/bootstrap.ts +66 -0
- package/src/lib/core/command-params.generated.ts +1549 -0
- package/src/lib/core/command-params.ts +20 -0
- package/src/lib/core/command-runner.ts +79 -0
- package/src/lib/core/commands.ts +134 -0
- package/src/lib/core/dispatcher.test.ts +548 -0
- package/src/lib/core/dispatcher.ts +361 -0
- package/src/lib/core/index.test.ts +7 -0
- package/src/lib/core/notification-state.svelte.ts +119 -0
- package/src/lib/core/plugin-api.ts +210 -0
- package/src/lib/core/plugin-discovery.test.ts +53 -0
- package/src/lib/core/plugin-discovery.ts +65 -0
- package/src/lib/core/plugin-loader.test.ts +159 -0
- package/src/lib/core/plugin-loader.ts +240 -0
- package/src/lib/core/plugin-types.ts +286 -0
- package/src/lib/core/registries.svelte.ts +74 -0
- package/src/lib/core/tool-options-state.svelte.ts +61 -0
- package/src/lib/dock/DockLayout.svelte +375 -0
- package/src/lib/dock/TabAddMenu.svelte +90 -0
- package/src/lib/dock/dock-persistence.ts +46 -0
- package/src/lib/dock/dock-plugin.ts +49 -0
- package/src/lib/dock/dock-presets.ts +156 -0
- package/src/lib/dock/dock-state.svelte.ts +77 -0
- package/src/lib/dock/dock-types.ts +2 -0
- package/src/lib/dock/dockview-theme.css +226 -0
- package/src/lib/dock/dockview-theme.ts +17 -0
- package/src/lib/dock/header-action-renderer.ts +77 -0
- package/src/lib/edit/clipboard-state.ts +34 -0
- package/src/lib/export/download.ts +201 -0
- package/src/lib/export/png-metadata.ts +181 -0
- package/src/lib/history/ActionLogPanel.svelte +418 -0
- package/src/lib/history/action-log-panel-plugin.ts +24 -0
- package/src/lib/history/action-log.svelte.ts +172 -0
- package/src/lib/history/action-log.test.ts +168 -0
- package/src/lib/history/history-commands.ts +403 -0
- package/src/lib/history/macros.svelte.ts +320 -0
- package/src/lib/history/macros.test.ts +224 -0
- package/src/lib/history/replay-engine.test.ts +241 -0
- package/src/lib/history/replay-engine.ts +149 -0
- package/src/lib/history/spec-format.test.ts +250 -0
- package/src/lib/history/spec-format.ts +210 -0
- package/src/lib/iso/SeamCheckerPanel.svelte +251 -0
- package/src/lib/iso/iso-math.test.ts +77 -0
- package/src/lib/iso/iso-math.ts +77 -0
- package/src/lib/iso/seam-checker-panel-plugin.ts +25 -0
- package/src/lib/iso/seam-checker.test.ts +126 -0
- package/src/lib/iso/seam-checker.ts +93 -0
- package/src/lib/iso/tessellation.ts +67 -0
- package/src/lib/layers/compositor.test.ts +193 -0
- package/src/lib/layers/compositor.ts +175 -0
- package/src/lib/layers/layer-commands.test.ts +263 -0
- package/src/lib/layers/layer-commands.ts +429 -0
- package/src/lib/layers/layer-tree.svelte.ts +516 -0
- package/src/lib/layers/layer-tree.test.ts +383 -0
- package/src/lib/layers/layer-types.ts +56 -0
- package/src/lib/leveleditor/LevelEditorViewport.svelte +1808 -0
- package/src/lib/leveleditor/MapPropertiesPanel.svelte +266 -0
- package/src/lib/leveleditor/TilePickerPanel.svelte +324 -0
- package/src/lib/leveleditor/depth-sort.test.ts +70 -0
- package/src/lib/leveleditor/depth-sort.ts +39 -0
- package/src/lib/leveleditor/level-editor-commands.ts +353 -0
- package/src/lib/leveleditor/level-editor-viewport-plugin.ts +25 -0
- package/src/lib/leveleditor/map-properties-panel-plugin.ts +25 -0
- package/src/lib/leveleditor/map-state.svelte.ts +372 -0
- package/src/lib/leveleditor/map-state.test.ts +243 -0
- package/src/lib/leveleditor/tile-picker-panel-plugin.ts +25 -0
- package/src/lib/leveleditor/tile-source-registry.svelte.ts +91 -0
- package/src/lib/leveleditor/tiled-export.test.ts +144 -0
- package/src/lib/leveleditor/tiled-export.ts +374 -0
- package/src/lib/pywebview.d.ts +15 -0
- package/src/lib/recovery/.gitkeep +0 -0
- package/src/lib/recovery/idb-store.ts +118 -0
- package/src/lib/recovery/recovery-manager.test.ts +321 -0
- package/src/lib/recovery/recovery-manager.ts +115 -0
- package/src/lib/recovery/recovery-plugin.ts +55 -0
- package/src/lib/recovery/recovery-state.svelte.ts +21 -0
- package/src/lib/recovery/sw-plugin.ts +18 -0
- package/src/lib/recovery/sw-register.ts +17 -0
- package/src/lib/save/directory-format.ts +42 -0
- package/src/lib/save/project-snapshot.ts +139 -0
- package/src/lib/save/recent-projects.ts +56 -0
- package/src/lib/save/save-state.svelte.ts +35 -0
- package/src/lib/save/storage.ts +167 -0
- package/src/lib/save/zip-format.ts +45 -0
- package/src/lib/shortcuts/.gitkeep +0 -0
- package/src/lib/shortcuts/ShortcutEditorPanel.svelte +690 -0
- package/src/lib/shortcuts/default-bindings.ts +61 -0
- package/src/lib/shortcuts/shortcut-editor-panel-plugin.ts +25 -0
- package/src/lib/shortcuts/shortcut-init.ts +380 -0
- package/src/lib/shortcuts/shortcut-manager.test.ts +466 -0
- package/src/lib/shortcuts/shortcut-manager.ts +281 -0
- package/src/lib/shortcuts/shortcut-state.svelte.ts +78 -0
- package/src/lib/shortcuts/shortcuts-plugin.ts +17 -0
- package/src/lib/sync/patch-applicator.ts +300 -0
- package/src/lib/sync/patch-types.ts +65 -0
- package/src/lib/sync/project-manager.ts +108 -0
- package/src/lib/sync/sync-init.ts +152 -0
- package/src/lib/sync/sync-plugin.ts +19 -0
- package/src/lib/sync/sync-state.svelte.ts +56 -0
- package/src/lib/sync/ws-client.test.ts +604 -0
- package/src/lib/sync/ws-client.ts +574 -0
- package/src/lib/tools/.gitkeep +0 -0
- package/src/lib/ui/.gitkeep +0 -0
- package/src/lib/ui/AboutDialog.svelte +113 -0
- package/src/lib/ui/ColorPicker.svelte +761 -0
- package/src/lib/ui/ContextMenu.svelte +216 -0
- package/src/lib/ui/ExportDialog.svelte +747 -0
- package/src/lib/ui/FrameStrip.svelte +854 -0
- package/src/lib/ui/LayerPanel.svelte +810 -0
- package/src/lib/ui/MenuBar.svelte +590 -0
- package/src/lib/ui/NewProjectDialog.svelte +803 -0
- package/src/lib/ui/PluginManagerPanel.svelte +475 -0
- package/src/lib/ui/PromptDialog.svelte +252 -0
- package/src/lib/ui/RecoveryDialog.svelte +295 -0
- package/src/lib/ui/ResizeDialog.svelte +416 -0
- package/src/lib/ui/StatusBar.svelte +145 -0
- package/src/lib/ui/ToolbarPanel.svelte +488 -0
- package/src/lib/ui/animation-menu-commands.ts +194 -0
- package/src/lib/ui/command-palette/CommandPalette.svelte +232 -0
- package/src/lib/ui/command-palette/command-palette-plugin.ts +30 -0
- package/src/lib/ui/command-palette/command-palette-state.svelte.ts +190 -0
- package/src/lib/ui/command-palette/command-palette.test.ts +129 -0
- package/src/lib/ui/dialog-state.svelte.ts +70 -0
- package/src/lib/ui/edit-commands.ts +271 -0
- package/src/lib/ui/file-commands.ts +275 -0
- package/src/lib/ui/file-open.ts +99 -0
- package/src/lib/ui/help-commands.ts +93 -0
- package/src/lib/ui/image-commands.ts +181 -0
- package/src/lib/ui/layer-menu-commands.ts +420 -0
- package/src/lib/ui/menu-builder.ts +224 -0
- package/src/lib/ui/notifications/NotificationBanner.svelte +137 -0
- package/src/lib/ui/notifications/notification-plugin.ts +29 -0
- package/src/lib/ui/notifications/notification-state.svelte.ts +9 -0
- package/src/lib/ui/plugin-manager-panel-plugin.ts +26 -0
- package/src/lib/ui/plugin-state.svelte.ts +62 -0
- package/src/lib/ui/select-commands.ts +75 -0
- package/src/lib/ui/theme-plugin.ts +18 -0
- package/src/lib/ui/theme.svelte.ts +45 -0
- package/src/lib/ui/theme.test.ts +51 -0
- package/src/lib/ui/toolbar-config.ts +90 -0
- package/src/lib/ui/toolbar-plugin.ts +39 -0
- package/src/lib/ui/view-commands.ts +629 -0
- package/src/lib/variants/BisectionExportDialog.svelte +500 -0
- package/src/lib/variants/VariantPanel.svelte +822 -0
- package/src/lib/variants/bisection-export.test.ts +113 -0
- package/src/lib/variants/bisection-export.ts +148 -0
- package/src/lib/variants/palette-extraction.test.ts +111 -0
- package/src/lib/variants/palette-extraction.ts +84 -0
- package/src/lib/variants/palette-interpolation.test.ts +113 -0
- package/src/lib/variants/palette-interpolation.ts +87 -0
- package/src/lib/variants/palette-swap.test.ts +101 -0
- package/src/lib/variants/palette-swap.ts +114 -0
- package/src/lib/variants/variant-commands.ts +594 -0
- package/src/lib/variants/variant-panel-plugin.ts +27 -0
- package/src/lib/variants/variant-randomizer.ts +101 -0
- package/src/lib/variants/variant-state.svelte.ts +166 -0
- package/src/lib/variants/variant-state.test.ts +138 -0
- package/src/main.ts +14 -0
- package/src/vite-env.d.ts +3 -0
- package/svelte.config.js +2 -0
- package/todo/.done/audit-design-decisions.md +812 -0
- package/todo/.done/audit-implementation-plan.md +1235 -0
- package/todo/.done/happy-path-polish.md +177 -0
- package/todo/.done/pixelweaver-full-build.md +937 -0
- package/todo/.done/server-multi-frame-design.md +405 -0
- package/todo/.done/typed-dispatcher-design.md +435 -0
- package/todo/.done/unified-toolbar-and-action-system.md +323 -0
- package/todo/.obsolete/comprehensive-audit-obsolete-items.md +33 -0
- package/todo/.obsolete/tauri-desktop-bundle.md +424 -0
- package/todo/comprehensive-audit.md +1085 -0
- package/tsconfig.app.json +26 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +20 -0
- package/uv.lock +1167 -0
- package/vite.config.ts +32 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
+
import { PixelBuffer } from '../canvas/pixel-buffer.js';
|
|
3
|
+
import { dispatch, undoLast, redoLast, _resetForTesting as resetDispatcher } from '../core/dispatcher.js';
|
|
4
|
+
import { createPluginAPI } from '../core/plugin-api.js';
|
|
5
|
+
import { layerCommandsPlugin } from '../layers/layer-commands.js';
|
|
6
|
+
import { animationCommandsPlugin } from './animation-commands.js';
|
|
7
|
+
import * as tree from '../layers/layer-tree.svelte.js';
|
|
8
|
+
import * as fm from './frame-model.svelte.js';
|
|
9
|
+
import * as ft from './frame-tags.svelte.js';
|
|
10
|
+
import type { Command } from '../core/commands.js';
|
|
11
|
+
import type { CommandType, ParamsOf } from '../core/command-params.js';
|
|
12
|
+
|
|
13
|
+
// --- Helpers ---
|
|
14
|
+
|
|
15
|
+
// Typed overload: validates params when type is a known command literal
|
|
16
|
+
function makeCommand<T extends CommandType>(type: T, params: ParamsOf<T>): Command;
|
|
17
|
+
// String fallback: for dynamic/unknown command types in tests
|
|
18
|
+
function makeCommand(type: string, params?: Record<string, unknown>): Command;
|
|
19
|
+
function makeCommand(type: string, params: Record<string, unknown> = {}): Command {
|
|
20
|
+
return {
|
|
21
|
+
type,
|
|
22
|
+
plugin: 'builtin/animation',
|
|
23
|
+
version: '1.0.0',
|
|
24
|
+
params,
|
|
25
|
+
timestamp: Date.now(),
|
|
26
|
+
id: crypto.randomUUID(),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// --- Setup ---
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
tree._resetForTesting();
|
|
34
|
+
fm._resetForTesting();
|
|
35
|
+
ft._resetForTesting();
|
|
36
|
+
resetDispatcher();
|
|
37
|
+
|
|
38
|
+
// Register dependencies first, then animation commands
|
|
39
|
+
const layerApi = createPluginAPI('builtin/layers');
|
|
40
|
+
layerCommandsPlugin.register(layerApi);
|
|
41
|
+
const animApi = createPluginAPI('builtin/animation');
|
|
42
|
+
animationCommandsPlugin.register(animApi);
|
|
43
|
+
|
|
44
|
+
// Seed with one frame so operations work
|
|
45
|
+
fm.addFrame();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// --- Tests ---
|
|
49
|
+
|
|
50
|
+
describe('add_frame command', () => {
|
|
51
|
+
it('should add a frame', () => {
|
|
52
|
+
dispatch(makeCommand('add_frame', {}));
|
|
53
|
+
expect(fm.getFrames()).toHaveLength(2);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should undo by removing the added frame', () => {
|
|
57
|
+
dispatch(makeCommand('add_frame', {}));
|
|
58
|
+
expect(fm.getFrames()).toHaveLength(2);
|
|
59
|
+
undoLast();
|
|
60
|
+
expect(fm.getFrames()).toHaveLength(1);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('remove_frame command', () => {
|
|
65
|
+
it('should remove a frame', () => {
|
|
66
|
+
fm.addFrame(); // now 2 frames
|
|
67
|
+
dispatch(makeCommand('remove_frame', { index: 0 }));
|
|
68
|
+
expect(fm.getFrames()).toHaveLength(1);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should undo by restoring the removed frame', () => {
|
|
72
|
+
const frame = fm.addFrame(); // now 2 frames
|
|
73
|
+
const buf = new PixelBuffer(4, 4);
|
|
74
|
+
buf.setPixel(0, 0, 42, 0, 0, 255);
|
|
75
|
+
frame.pixelData.set('test-layer', buf);
|
|
76
|
+
|
|
77
|
+
dispatch(makeCommand('remove_frame', { index: 1 }));
|
|
78
|
+
expect(fm.getFrames()).toHaveLength(1);
|
|
79
|
+
|
|
80
|
+
undoLast();
|
|
81
|
+
expect(fm.getFrames()).toHaveLength(2);
|
|
82
|
+
// Pixel data should be restored
|
|
83
|
+
const restored = fm.getFrames()[1]?.pixelData.get('test-layer');
|
|
84
|
+
expect(restored).toBeDefined();
|
|
85
|
+
expect(restored?.getPixel(0, 0)).toEqual([42, 0, 0, 255]);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('duplicate_frame command', () => {
|
|
90
|
+
it('should duplicate a frame', () => {
|
|
91
|
+
dispatch(makeCommand('duplicate_frame', { index: 0 }));
|
|
92
|
+
expect(fm.getFrames()).toHaveLength(2);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should undo by removing the duplicate', () => {
|
|
96
|
+
dispatch(makeCommand('duplicate_frame', { index: 0 }));
|
|
97
|
+
expect(fm.getFrames()).toHaveLength(2);
|
|
98
|
+
undoLast();
|
|
99
|
+
expect(fm.getFrames()).toHaveLength(1);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('reorder_frame command', () => {
|
|
104
|
+
it('should reorder frames and undo', () => {
|
|
105
|
+
fm.addFrame(); // now 2 frames
|
|
106
|
+
const id0 = fm.getFrames()[0]?.id;
|
|
107
|
+
const id1 = fm.getFrames()[1]?.id;
|
|
108
|
+
|
|
109
|
+
dispatch(makeCommand('reorder_frame', { fromIndex: 0, toIndex: 1 }));
|
|
110
|
+
expect(fm.getFrames()[0]?.id).toBe(id1);
|
|
111
|
+
expect(fm.getFrames()[1]?.id).toBe(id0);
|
|
112
|
+
|
|
113
|
+
undoLast();
|
|
114
|
+
expect(fm.getFrames()[0]?.id).toBe(id0);
|
|
115
|
+
expect(fm.getFrames()[1]?.id).toBe(id1);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('reorder_frames command', () => {
|
|
120
|
+
it('should reorder multiple frames via command', () => {
|
|
121
|
+
fm.addFrame(); // now 2 frames
|
|
122
|
+
fm.addFrame(); // now 3
|
|
123
|
+
fm.addFrame(); // now 4 (indices 0-3)
|
|
124
|
+
const id0 = fm.getFrames()[0]?.id;
|
|
125
|
+
const id1 = fm.getFrames()[1]?.id;
|
|
126
|
+
const id2 = fm.getFrames()[2]?.id;
|
|
127
|
+
const id3 = fm.getFrames()[3]?.id;
|
|
128
|
+
|
|
129
|
+
// Move frames [0,1] to position 3
|
|
130
|
+
dispatch(makeCommand('reorder_frames', { fromIndices: [0, 1], toIndex: 3 }));
|
|
131
|
+
const ids = fm.getFrames().map((f) => f.id);
|
|
132
|
+
// sorted=[0,1], extracted=[id0,id1], remaining=[id2,id3]
|
|
133
|
+
// adjustedTarget = 3 - 2 = 1
|
|
134
|
+
// splice(1, 0, id0, id1) => [id2, id0, id1, id3]
|
|
135
|
+
expect(ids).toEqual([id2, id0, id1, id3]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should undo to restore original order', () => {
|
|
139
|
+
fm.addFrame();
|
|
140
|
+
fm.addFrame();
|
|
141
|
+
fm.addFrame(); // 4 frames total
|
|
142
|
+
const originalIds = fm.getFrames().map((f) => f.id);
|
|
143
|
+
|
|
144
|
+
dispatch(makeCommand('reorder_frames', { fromIndices: [0, 1], toIndex: 3 }));
|
|
145
|
+
// Verify order changed
|
|
146
|
+
expect(fm.getFrames().map((f) => f.id)).not.toEqual(originalIds);
|
|
147
|
+
|
|
148
|
+
undoLast();
|
|
149
|
+
expect(fm.getFrames().map((f) => f.id)).toEqual(originalIds);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should redo to re-apply the reorder', () => {
|
|
153
|
+
fm.addFrame();
|
|
154
|
+
fm.addFrame();
|
|
155
|
+
fm.addFrame(); // 4 frames total
|
|
156
|
+
const originalIds = fm.getFrames().map((f) => f.id);
|
|
157
|
+
|
|
158
|
+
dispatch(makeCommand('reorder_frames', { fromIndices: [0, 1], toIndex: 3 }));
|
|
159
|
+
const reorderedIds = fm.getFrames().map((f) => f.id);
|
|
160
|
+
|
|
161
|
+
undoLast();
|
|
162
|
+
expect(fm.getFrames().map((f) => f.id)).toEqual(originalIds);
|
|
163
|
+
|
|
164
|
+
redoLast();
|
|
165
|
+
expect(fm.getFrames().map((f) => f.id)).toEqual(reorderedIds);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('set_frame_duration command', () => {
|
|
170
|
+
it('should change frame duration', () => {
|
|
171
|
+
dispatch(makeCommand('set_frame_duration', { index: 0, durationMs: 200 }));
|
|
172
|
+
expect(fm.getFrames()[0]?.durationMs).toBe(200);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should undo to restore old duration', () => {
|
|
176
|
+
dispatch(makeCommand('set_frame_duration', { index: 0, durationMs: 200 }));
|
|
177
|
+
undoLast();
|
|
178
|
+
expect(fm.getFrames()[0]?.durationMs).toBeNull();
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('set_global_fps command', () => {
|
|
183
|
+
it('should change global FPS and undo', () => {
|
|
184
|
+
dispatch(makeCommand('set_global_fps', { fps: 24 }));
|
|
185
|
+
expect(fm.getGlobalFps()).toBe(24);
|
|
186
|
+
|
|
187
|
+
undoLast();
|
|
188
|
+
expect(fm.getGlobalFps()).toBe(12); // default
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('add_tag command', () => {
|
|
193
|
+
it('should add a tag', () => {
|
|
194
|
+
dispatch(makeCommand('add_tag', { name: 'Walk', startFrame: 0, endFrame: 3 }));
|
|
195
|
+
expect(ft.getTags()).toHaveLength(1);
|
|
196
|
+
expect(ft.getTags()[0]?.name).toBe('Walk');
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should undo by removing the tag', () => {
|
|
200
|
+
dispatch(makeCommand('add_tag', { name: 'Walk', startFrame: 0, endFrame: 3 }));
|
|
201
|
+
undoLast();
|
|
202
|
+
expect(ft.getTags()).toHaveLength(0);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('remove_tag command', () => {
|
|
207
|
+
it('should remove a tag and undo to restore it', () => {
|
|
208
|
+
const tag = ft.addTag('Idle', 0, 2);
|
|
209
|
+
dispatch(makeCommand('remove_tag', { id: tag.id }));
|
|
210
|
+
expect(ft.getTags()).toHaveLength(0);
|
|
211
|
+
|
|
212
|
+
undoLast();
|
|
213
|
+
expect(ft.getTags()).toHaveLength(1);
|
|
214
|
+
expect(ft.getTags()[0]?.name).toBe('Idle');
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe('set_origin command', () => {
|
|
219
|
+
it('should set origin and undo', () => {
|
|
220
|
+
dispatch(makeCommand('set_origin', { x: 16, y: 32 }));
|
|
221
|
+
expect(fm.getOriginX()).toBe(16);
|
|
222
|
+
expect(fm.getOriginY()).toBe(32);
|
|
223
|
+
|
|
224
|
+
undoLast();
|
|
225
|
+
expect(fm.getOriginX()).toBe(0);
|
|
226
|
+
expect(fm.getOriginY()).toBe(0);
|
|
227
|
+
});
|
|
228
|
+
});
|