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,466 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the keyboard shortcut system.
|
|
3
|
+
*
|
|
4
|
+
* Covers parsing, normalization, event matching, bind/unbind, rebind,
|
|
5
|
+
* conflict detection, enable/disable, profile export/import, and
|
|
6
|
+
* integration with default bindings.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
10
|
+
import {
|
|
11
|
+
parseShortcut,
|
|
12
|
+
normalizeShortcut,
|
|
13
|
+
matchesEvent,
|
|
14
|
+
ShortcutManager,
|
|
15
|
+
} from './shortcut-manager.js';
|
|
16
|
+
import { DEFAULT_BINDINGS } from './default-bindings.js';
|
|
17
|
+
|
|
18
|
+
// --- Helpers ---
|
|
19
|
+
|
|
20
|
+
/** Create a synthetic KeyboardEvent for testing. */
|
|
21
|
+
function makeKeyEvent(
|
|
22
|
+
key: string,
|
|
23
|
+
modifiers: {
|
|
24
|
+
ctrlKey?: boolean;
|
|
25
|
+
shiftKey?: boolean;
|
|
26
|
+
altKey?: boolean;
|
|
27
|
+
metaKey?: boolean;
|
|
28
|
+
} = {},
|
|
29
|
+
): KeyboardEvent {
|
|
30
|
+
return new KeyboardEvent('keydown', {
|
|
31
|
+
key,
|
|
32
|
+
ctrlKey: modifiers.ctrlKey ?? false,
|
|
33
|
+
shiftKey: modifiers.shiftKey ?? false,
|
|
34
|
+
altKey: modifiers.altKey ?? false,
|
|
35
|
+
metaKey: modifiers.metaKey ?? false,
|
|
36
|
+
bubbles: true,
|
|
37
|
+
cancelable: true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// --- parseShortcut ---
|
|
42
|
+
|
|
43
|
+
describe('parseShortcut', () => {
|
|
44
|
+
it('parses a single letter key', () => {
|
|
45
|
+
const parsed = parseShortcut('B');
|
|
46
|
+
expect(parsed).toEqual({
|
|
47
|
+
key: 'b',
|
|
48
|
+
ctrl: false,
|
|
49
|
+
shift: false,
|
|
50
|
+
alt: false,
|
|
51
|
+
meta: false,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('parses Ctrl+Z', () => {
|
|
56
|
+
const parsed = parseShortcut('Ctrl+Z');
|
|
57
|
+
expect(parsed).toEqual({
|
|
58
|
+
key: 'z',
|
|
59
|
+
ctrl: true,
|
|
60
|
+
shift: false,
|
|
61
|
+
alt: false,
|
|
62
|
+
meta: false,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('parses Ctrl+Shift+Z', () => {
|
|
67
|
+
const parsed = parseShortcut('Ctrl+Shift+Z');
|
|
68
|
+
expect(parsed).toEqual({
|
|
69
|
+
key: 'z',
|
|
70
|
+
ctrl: true,
|
|
71
|
+
shift: true,
|
|
72
|
+
alt: false,
|
|
73
|
+
meta: false,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('parses Alt+F4', () => {
|
|
78
|
+
const parsed = parseShortcut('Alt+F4');
|
|
79
|
+
expect(parsed).toEqual({
|
|
80
|
+
key: 'f4',
|
|
81
|
+
ctrl: false,
|
|
82
|
+
shift: false,
|
|
83
|
+
alt: true,
|
|
84
|
+
meta: false,
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('parses Meta/Cmd modifier aliases', () => {
|
|
89
|
+
expect(parseShortcut('Meta+S').meta).toBe(true);
|
|
90
|
+
expect(parseShortcut('Cmd+S').meta).toBe(true);
|
|
91
|
+
expect(parseShortcut('Command+S').meta).toBe(true);
|
|
92
|
+
expect(parseShortcut('Win+S').meta).toBe(true);
|
|
93
|
+
expect(parseShortcut('Super+S').meta).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('parses Control as alias for Ctrl', () => {
|
|
97
|
+
const parsed = parseShortcut('Control+C');
|
|
98
|
+
expect(parsed.ctrl).toBe(true);
|
|
99
|
+
expect(parsed.key).toBe('c');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('handles extra whitespace around parts', () => {
|
|
103
|
+
const parsed = parseShortcut(' Ctrl + Shift + Z ');
|
|
104
|
+
expect(parsed.ctrl).toBe(true);
|
|
105
|
+
expect(parsed.shift).toBe(true);
|
|
106
|
+
expect(parsed.key).toBe('z');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('parses special key names', () => {
|
|
110
|
+
expect(parseShortcut('Escape').key).toBe('escape');
|
|
111
|
+
expect(parseShortcut('Enter').key).toBe('enter');
|
|
112
|
+
expect(parseShortcut('=').key).toBe('=');
|
|
113
|
+
expect(parseShortcut('-').key).toBe('-');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// --- normalizeShortcut ---
|
|
118
|
+
|
|
119
|
+
describe('normalizeShortcut', () => {
|
|
120
|
+
it('normalizes a single key to lowercase', () => {
|
|
121
|
+
expect(normalizeShortcut('B')).toBe('b');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('normalizes modifiers to fixed order: ctrl+alt+shift+meta+key', () => {
|
|
125
|
+
// Regardless of input order, output should be ctrl+shift+z
|
|
126
|
+
expect(normalizeShortcut('Ctrl+Shift+Z')).toBe('ctrl+shift+z');
|
|
127
|
+
expect(normalizeShortcut('Shift+Ctrl+Z')).toBe('ctrl+shift+z');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('normalizes modifier aliases', () => {
|
|
131
|
+
expect(normalizeShortcut('Cmd+S')).toBe('meta+s');
|
|
132
|
+
expect(normalizeShortcut('Control+Z')).toBe('ctrl+z');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('produces consistent output for equivalent inputs', () => {
|
|
136
|
+
const a = normalizeShortcut('Ctrl+Alt+Shift+X');
|
|
137
|
+
const b = normalizeShortcut('shift+alt+ctrl+x');
|
|
138
|
+
const c = normalizeShortcut('Alt+Ctrl+Shift+X');
|
|
139
|
+
expect(a).toBe(b);
|
|
140
|
+
expect(b).toBe(c);
|
|
141
|
+
expect(a).toBe('ctrl+alt+shift+x');
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// --- matchesEvent ---
|
|
146
|
+
|
|
147
|
+
describe('matchesEvent', () => {
|
|
148
|
+
it('matches a simple key', () => {
|
|
149
|
+
const parsed = parseShortcut('B');
|
|
150
|
+
const event = makeKeyEvent('b');
|
|
151
|
+
expect(matchesEvent(parsed, event)).toBe(true);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('does not match when modifiers differ', () => {
|
|
155
|
+
const parsed = parseShortcut('B');
|
|
156
|
+
const event = makeKeyEvent('b', { ctrlKey: true });
|
|
157
|
+
expect(matchesEvent(parsed, event)).toBe(false);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('matches Ctrl+Z', () => {
|
|
161
|
+
const parsed = parseShortcut('Ctrl+Z');
|
|
162
|
+
const event = makeKeyEvent('z', { ctrlKey: true });
|
|
163
|
+
expect(matchesEvent(parsed, event)).toBe(true);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('does not match Ctrl+Z when Shift is also pressed', () => {
|
|
167
|
+
const parsed = parseShortcut('Ctrl+Z');
|
|
168
|
+
const event = makeKeyEvent('z', { ctrlKey: true, shiftKey: true });
|
|
169
|
+
expect(matchesEvent(parsed, event)).toBe(false);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('matches Ctrl+Shift+Z exactly', () => {
|
|
173
|
+
const parsed = parseShortcut('Ctrl+Shift+Z');
|
|
174
|
+
const event = makeKeyEvent('z', { ctrlKey: true, shiftKey: true });
|
|
175
|
+
expect(matchesEvent(parsed, event)).toBe(true);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('is case-insensitive for the key', () => {
|
|
179
|
+
const parsed = parseShortcut('B');
|
|
180
|
+
const eventUpper = makeKeyEvent('B');
|
|
181
|
+
// event.key is case-sensitive in the browser, but our matchesEvent
|
|
182
|
+
// lowercases it, so uppercase 'B' should still match parsed 'b'
|
|
183
|
+
// However, the browser sends 'B' for Shift+b, which would have shiftKey=true.
|
|
184
|
+
// For a plain 'b' press, the browser sends lowercase 'b'.
|
|
185
|
+
// Our matching lowercases event.key, so 'B' -> 'b' matches parsed.key 'b'.
|
|
186
|
+
// But if event also has shiftKey=false, it should match.
|
|
187
|
+
expect(matchesEvent(parsed, eventUpper)).toBe(true);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// --- ShortcutManager: bind/unbind ---
|
|
192
|
+
|
|
193
|
+
describe('ShortcutManager', () => {
|
|
194
|
+
let manager: ShortcutManager;
|
|
195
|
+
|
|
196
|
+
beforeEach(() => {
|
|
197
|
+
manager = new ShortcutManager();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('bind and unbind', () => {
|
|
201
|
+
it('binds a shortcut and fires the action on handleKeyDown', () => {
|
|
202
|
+
const action = vi.fn();
|
|
203
|
+
manager.bind('B', action, 'Test action');
|
|
204
|
+
|
|
205
|
+
const event = makeKeyEvent('b');
|
|
206
|
+
const handled = manager.handleKeyDown(event);
|
|
207
|
+
|
|
208
|
+
expect(handled).toBe(true);
|
|
209
|
+
expect(action).toHaveBeenCalledOnce();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('returns false for unbound keys', () => {
|
|
213
|
+
const handled = manager.handleKeyDown(makeKeyEvent('q'));
|
|
214
|
+
expect(handled).toBe(false);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('unbinds a shortcut', () => {
|
|
218
|
+
const action = vi.fn();
|
|
219
|
+
manager.bind('B', action, 'Test');
|
|
220
|
+
manager.unbind('B');
|
|
221
|
+
|
|
222
|
+
const handled = manager.handleKeyDown(makeKeyEvent('b'));
|
|
223
|
+
expect(handled).toBe(false);
|
|
224
|
+
expect(action).not.toHaveBeenCalled();
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('getBindings returns all current bindings', () => {
|
|
228
|
+
const action1 = vi.fn();
|
|
229
|
+
const action2 = vi.fn();
|
|
230
|
+
manager.bind('B', action1, 'Action 1');
|
|
231
|
+
manager.bind('Ctrl+Z', action2, 'Action 2');
|
|
232
|
+
|
|
233
|
+
const bindings = manager.getBindings();
|
|
234
|
+
expect(bindings.size).toBe(2);
|
|
235
|
+
expect(bindings.get('b')?.description).toBe('Action 1');
|
|
236
|
+
expect(bindings.get('ctrl+z')?.description).toBe('Action 2');
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
describe('handleKeyDown', () => {
|
|
241
|
+
it('calls preventDefault on matched shortcuts', () => {
|
|
242
|
+
manager.bind('Ctrl+S', vi.fn(), 'Save');
|
|
243
|
+
const event = makeKeyEvent('s', { ctrlKey: true });
|
|
244
|
+
|
|
245
|
+
// spy on preventDefault
|
|
246
|
+
const preventSpy = vi.spyOn(event, 'preventDefault');
|
|
247
|
+
manager.handleKeyDown(event);
|
|
248
|
+
|
|
249
|
+
expect(preventSpy).toHaveBeenCalledOnce();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('does NOT call preventDefault on unmatched keys', () => {
|
|
253
|
+
const event = makeKeyEvent('q');
|
|
254
|
+
const preventSpy = vi.spyOn(event, 'preventDefault');
|
|
255
|
+
manager.handleKeyDown(event);
|
|
256
|
+
|
|
257
|
+
expect(preventSpy).not.toHaveBeenCalled();
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('distinguishes Ctrl+Z from Ctrl+Shift+Z', () => {
|
|
261
|
+
const undoAction = vi.fn();
|
|
262
|
+
const redoAction = vi.fn();
|
|
263
|
+
manager.bind('Ctrl+Z', undoAction, 'Undo');
|
|
264
|
+
manager.bind('Ctrl+Shift+Z', redoAction, 'Redo');
|
|
265
|
+
|
|
266
|
+
manager.handleKeyDown(makeKeyEvent('z', { ctrlKey: true }));
|
|
267
|
+
expect(undoAction).toHaveBeenCalledOnce();
|
|
268
|
+
expect(redoAction).not.toHaveBeenCalled();
|
|
269
|
+
|
|
270
|
+
manager.handleKeyDown(makeKeyEvent('z', { ctrlKey: true, shiftKey: true }));
|
|
271
|
+
expect(redoAction).toHaveBeenCalledOnce();
|
|
272
|
+
expect(undoAction).toHaveBeenCalledOnce(); // still 1 from before
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
describe('conflict detection', () => {
|
|
277
|
+
it('returns null when no conflict exists', () => {
|
|
278
|
+
expect(manager.getConflict('B')).toBeNull();
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('returns description of conflicting binding', () => {
|
|
282
|
+
manager.bind('B', vi.fn(), 'Pencil tool');
|
|
283
|
+
expect(manager.getConflict('B')).toBe('Pencil tool');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('normalizes before checking for conflicts', () => {
|
|
287
|
+
manager.bind('Ctrl+Shift+Z', vi.fn(), 'Redo');
|
|
288
|
+
// Same shortcut written differently
|
|
289
|
+
expect(manager.getConflict('Shift+Ctrl+Z')).toBe('Redo');
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe('rebind', () => {
|
|
294
|
+
it('moves an action from one key to another', () => {
|
|
295
|
+
const action = vi.fn();
|
|
296
|
+
manager.bind('B', action, 'Pencil tool', 'tool.pencil');
|
|
297
|
+
|
|
298
|
+
manager.rebind('B', 'P');
|
|
299
|
+
|
|
300
|
+
// Old key should no longer fire
|
|
301
|
+
expect(manager.handleKeyDown(makeKeyEvent('b'))).toBe(false);
|
|
302
|
+
|
|
303
|
+
// New key should fire
|
|
304
|
+
expect(manager.handleKeyDown(makeKeyEvent('p'))).toBe(true);
|
|
305
|
+
expect(action).toHaveBeenCalledOnce();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('preserves description and name after rebind', () => {
|
|
309
|
+
manager.bind('B', vi.fn(), 'Pencil tool', 'tool.pencil');
|
|
310
|
+
manager.rebind('B', 'P');
|
|
311
|
+
|
|
312
|
+
const bindings = manager.getBindings();
|
|
313
|
+
expect(bindings.get('p')?.description).toBe('Pencil tool');
|
|
314
|
+
expect(bindings.has('b')).toBe(false);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('updates the name-to-shortcut mapping after rebind', () => {
|
|
318
|
+
manager.bind('B', vi.fn(), 'Pencil tool', 'tool.pencil');
|
|
319
|
+
manager.rebind('B', 'P');
|
|
320
|
+
|
|
321
|
+
expect(manager.getShortcutForName('tool.pencil')).toBe('p');
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('does nothing for a non-existent old shortcut', () => {
|
|
325
|
+
// Should not throw
|
|
326
|
+
manager.rebind('Q', 'W');
|
|
327
|
+
expect(manager.getBindings().size).toBe(0);
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe('setEnabled', () => {
|
|
332
|
+
it('prevents shortcuts from firing when disabled', () => {
|
|
333
|
+
const action = vi.fn();
|
|
334
|
+
manager.bind('B', action, 'Test');
|
|
335
|
+
|
|
336
|
+
manager.setEnabled(false);
|
|
337
|
+
const handled = manager.handleKeyDown(makeKeyEvent('b'));
|
|
338
|
+
|
|
339
|
+
expect(handled).toBe(false);
|
|
340
|
+
expect(action).not.toHaveBeenCalled();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('re-enables shortcuts after being disabled', () => {
|
|
344
|
+
const action = vi.fn();
|
|
345
|
+
manager.bind('B', action, 'Test');
|
|
346
|
+
|
|
347
|
+
manager.setEnabled(false);
|
|
348
|
+
manager.setEnabled(true);
|
|
349
|
+
|
|
350
|
+
const handled = manager.handleKeyDown(makeKeyEvent('b'));
|
|
351
|
+
expect(handled).toBe(true);
|
|
352
|
+
expect(action).toHaveBeenCalledOnce();
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
describe('reset', () => {
|
|
357
|
+
it('removes all bindings', () => {
|
|
358
|
+
manager.bind('B', vi.fn(), 'Test');
|
|
359
|
+
manager.bind('Ctrl+Z', vi.fn(), 'Test2');
|
|
360
|
+
manager.reset();
|
|
361
|
+
|
|
362
|
+
expect(manager.getBindings().size).toBe(0);
|
|
363
|
+
expect(manager.handleKeyDown(makeKeyEvent('b'))).toBe(false);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it('re-enables the manager after reset', () => {
|
|
367
|
+
manager.setEnabled(false);
|
|
368
|
+
manager.reset();
|
|
369
|
+
expect(manager.isEnabled()).toBe(true);
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
describe('profile export/import', () => {
|
|
374
|
+
it('exports named bindings as a profile', () => {
|
|
375
|
+
manager.bind('B', vi.fn(), 'Pencil tool', 'tool.pencil');
|
|
376
|
+
manager.bind('E', vi.fn(), 'Eraser tool', 'tool.eraser');
|
|
377
|
+
manager.bind('Ctrl+Z', vi.fn(), 'Undo', 'edit.undo');
|
|
378
|
+
|
|
379
|
+
const profile = manager.exportProfile();
|
|
380
|
+
expect(profile).toEqual({
|
|
381
|
+
'tool.pencil': 'b',
|
|
382
|
+
'tool.eraser': 'e',
|
|
383
|
+
'edit.undo': 'ctrl+z',
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('does not export unnamed bindings', () => {
|
|
388
|
+
manager.bind('B', vi.fn(), 'Anonymous binding'); // no name
|
|
389
|
+
const profile = manager.exportProfile();
|
|
390
|
+
expect(Object.keys(profile)).toHaveLength(0);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('roundtrips export/import without changing bindings', () => {
|
|
394
|
+
const action1 = vi.fn();
|
|
395
|
+
const action2 = vi.fn();
|
|
396
|
+
manager.bind('B', action1, 'Pencil', 'tool.pencil');
|
|
397
|
+
manager.bind('Ctrl+Z', action2, 'Undo', 'edit.undo');
|
|
398
|
+
|
|
399
|
+
const profile = manager.exportProfile();
|
|
400
|
+
manager.importProfile(profile);
|
|
401
|
+
|
|
402
|
+
// Bindings should be unchanged
|
|
403
|
+
expect(manager.handleKeyDown(makeKeyEvent('b'))).toBe(true);
|
|
404
|
+
expect(action1).toHaveBeenCalledOnce();
|
|
405
|
+
expect(manager.handleKeyDown(makeKeyEvent('z', { ctrlKey: true }))).toBe(true);
|
|
406
|
+
expect(action2).toHaveBeenCalledOnce();
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('imports a modified profile and rebinds actions', () => {
|
|
410
|
+
const action = vi.fn();
|
|
411
|
+
manager.bind('B', action, 'Pencil', 'tool.pencil');
|
|
412
|
+
|
|
413
|
+
// Import a profile that changes pencil from B to P
|
|
414
|
+
manager.importProfile({ 'tool.pencil': 'P' });
|
|
415
|
+
|
|
416
|
+
expect(manager.handleKeyDown(makeKeyEvent('b'))).toBe(false);
|
|
417
|
+
expect(manager.handleKeyDown(makeKeyEvent('p'))).toBe(true);
|
|
418
|
+
expect(action).toHaveBeenCalledOnce();
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it('ignores profile entries for unknown action names', () => {
|
|
422
|
+
manager.bind('B', vi.fn(), 'Pencil', 'tool.pencil');
|
|
423
|
+
|
|
424
|
+
// 'tool.unknown' doesn't exist, should be silently ignored
|
|
425
|
+
manager.importProfile({ 'tool.unknown': 'Q' });
|
|
426
|
+
expect(manager.getBindings().size).toBe(1);
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
describe('default bindings', () => {
|
|
431
|
+
it('loads all default bindings without errors', () => {
|
|
432
|
+
for (const binding of DEFAULT_BINDINGS) {
|
|
433
|
+
// Using a noop action since we're just testing that binding works
|
|
434
|
+
manager.bind(binding.key, () => {}, binding.description, binding.name);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
expect(manager.getBindings().size).toBe(DEFAULT_BINDINGS.length);
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
it('all default binding names are unique', () => {
|
|
441
|
+
const names = DEFAULT_BINDINGS.map((b) => b.name);
|
|
442
|
+
const uniqueNames = new Set(names);
|
|
443
|
+
expect(uniqueNames.size).toBe(names.length);
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
it('all default binding keys are unique (no collisions)', () => {
|
|
447
|
+
const keys = DEFAULT_BINDINGS.map((b) => normalizeShortcut(b.key));
|
|
448
|
+
const uniqueKeys = new Set(keys);
|
|
449
|
+
expect(uniqueKeys.size).toBe(keys.length);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
it('exports default bindings profile correctly', () => {
|
|
453
|
+
for (const binding of DEFAULT_BINDINGS) {
|
|
454
|
+
manager.bind(binding.key, () => {}, binding.description, binding.name);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const profile = manager.exportProfile();
|
|
458
|
+
expect(Object.keys(profile).length).toBe(DEFAULT_BINDINGS.length);
|
|
459
|
+
|
|
460
|
+
// Spot check a few entries
|
|
461
|
+
expect(profile['tool.pencil']).toBe('b');
|
|
462
|
+
expect(profile['edit.undo']).toBe('ctrl+z');
|
|
463
|
+
expect(profile['edit.redo']).toBe('ctrl+shift+z');
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
});
|