@1agh/maude 0.28.1 → 0.30.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/README.md +3 -3
- package/{plugins/design/dev-server → apps/studio}/ai-banner.tsx +1 -2
- package/apps/studio/annotations-align.ts +149 -0
- package/apps/studio/annotations-bindings.ts +197 -0
- package/{plugins/design/dev-server → apps/studio}/annotations-context-toolbar.tsx +681 -151
- package/apps/studio/annotations-groups.ts +270 -0
- package/apps/studio/annotations-layer.tsx +4537 -0
- package/apps/studio/annotations-model.ts +2077 -0
- package/apps/studio/annotations-snap.ts +125 -0
- package/{plugins/design/dev-server → apps/studio}/api.ts +616 -70
- package/{plugins/design/dev-server → apps/studio}/artboard-activity-overlay.tsx +1 -1
- package/{plugins/design/dev-server → apps/studio}/artboard-marquee.tsx +1 -1
- package/apps/studio/bin/_motion-sample-playwright.mjs +129 -0
- package/{plugins/design/dev-server → apps/studio}/bin/_png-playwright.mjs +1 -1
- package/apps/studio/bin/annotate.mjs +732 -0
- package/apps/studio/bin/annotate.sh +17 -0
- package/{plugins/design/dev-server → apps/studio}/bin/canvas-edit.sh +1 -1
- package/{plugins/design/dev-server → apps/studio}/bin/draw-proof.sh +37 -2
- package/{plugins/design/dev-server → apps/studio}/bin/preflight.sh +1 -1
- package/apps/studio/bin/read-annotations.mjs +573 -0
- package/apps/studio/bin/read-annotations.sh +11 -0
- package/{plugins/design/dev-server → apps/studio}/bin/runtime-health.sh +1 -1
- package/{plugins/design/dev-server → apps/studio}/bin/screenshot.sh +62 -2
- package/{plugins/design/dev-server → apps/studio}/bin/server-up.sh +9 -3
- package/apps/studio/bin/to-lottie-verify.html +68 -0
- package/apps/studio/bin/to-lottie.sh +128 -0
- package/{plugins/design/dev-server → apps/studio}/build.ts +6 -4
- package/{plugins/design/dev-server → apps/studio}/canvas-arrowheads.ts +79 -10
- package/{plugins/design/dev-server → apps/studio}/canvas-comment-mount.tsx +1 -1
- package/apps/studio/canvas-create.ts +104 -0
- package/{plugins/design/dev-server → apps/studio}/canvas-cursors.ts +48 -12
- package/{plugins/design/dev-server → apps/studio}/canvas-edit.ts +257 -7
- package/{plugins/design/dev-server → apps/studio}/canvas-icons.tsx +165 -1
- package/{plugins/design/dev-server → apps/studio}/canvas-lib-inline.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/canvas-lib-resolver.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/canvas-lib.tsx +31 -12
- package/{plugins/design/dev-server → apps/studio}/canvas-shell.tsx +360 -48
- package/apps/studio/client/app.jsx +6742 -0
- package/apps/studio/client/canvas-url.js +81 -0
- package/{plugins/design/dev-server → apps/studio}/client/comments-overlay.css +41 -27
- package/apps/studio/client/index.html +16 -0
- package/apps/studio/client/styles/1-tokens-maude.css +296 -0
- package/apps/studio/client/styles/3-shell-maude.css +1161 -0
- package/{plugins/design/dev-server → apps/studio}/client/styles/3-shell.css +129 -0
- package/apps/studio/client/styles/4-components-maude.css +74 -0
- package/{plugins/design/dev-server → apps/studio}/client/styles/4-components.css +396 -34
- package/apps/studio/client/styles/5-maude-overrides.css +137 -0
- package/{plugins/design/dev-server → apps/studio}/client/styles/_index.css +9 -0
- package/{plugins/design/dev-server → apps/studio}/client/styles.css +1 -1
- package/apps/studio/client/tour/overlay.jsx +279 -0
- package/apps/studio/client/tour/usage-tour.js +48 -0
- package/apps/studio/client/whats-new-seen.js +52 -0
- package/apps/studio/client/whats-new.jsx +250 -0
- package/{plugins/design/dev-server → apps/studio}/commands/annotation-strokes-command.ts +2 -2
- package/{plugins/design/dev-server → apps/studio}/commands/equal-spacing-command.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/commands/move-artboards-command.ts +2 -2
- package/{plugins/design/dev-server → apps/studio}/comments-overlay.tsx +32 -11
- package/{plugins/design/dev-server → apps/studio}/context-menu.tsx +5 -4
- package/{plugins/design/dev-server → apps/studio}/contextual-toolbar.tsx +18 -7
- package/{plugins/design/dev-server → apps/studio}/cursors-overlay.tsx +21 -21
- package/apps/studio/dist/client.bundle.js +25545 -0
- package/apps/studio/dist/comment-mount.js +2046 -0
- package/apps/studio/dist/styles.css +8018 -0
- package/apps/studio/dom-selection.ts +342 -0
- package/apps/studio/draw/animate.ts +333 -0
- package/{plugins/design/dev-server → apps/studio}/draw/brush.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/draw/composition.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/draw/geometry.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/draw/index.ts +4 -1
- package/{plugins/design/dev-server → apps/studio}/draw/layout.ts +1 -1
- package/apps/studio/draw/morph.ts +204 -0
- package/{plugins/design/dev-server → apps/studio}/draw/optimize.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/draw/palette.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/draw/primitives.ts +1 -1
- package/apps/studio/draw/serialize-animate.ts +324 -0
- package/{plugins/design/dev-server → apps/studio}/draw/serialize.ts +9 -3
- package/apps/studio/draw/test/animate.test.ts +172 -0
- package/apps/studio/draw/test/morph.test.ts +107 -0
- package/apps/studio/draw/test/serialize-animate.test.ts +142 -0
- package/{plugins/design/dev-server → apps/studio}/equal-spacing-detector.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/equal-spacing-handles.tsx +7 -29
- package/{plugins/design/dev-server → apps/studio}/export-dialog.tsx +16 -4
- package/{plugins/design/dev-server → apps/studio}/history.ts +20 -3
- package/{plugins/design/dev-server → apps/studio}/http.ts +226 -6
- package/{plugins/design/dev-server → apps/studio}/input-router.tsx +15 -1
- package/{plugins/design/dev-server → apps/studio}/inspect.ts +50 -4
- package/{plugins/design/dev-server → apps/studio}/marquee-overlay.tsx +5 -2
- package/{plugins/design/dev-server → apps/studio}/participants-chrome.tsx +2 -8
- package/{plugins/design/dev-server → apps/studio}/paths.ts +15 -11
- package/{plugins/design/dev-server → apps/studio}/server.ts +23 -2
- package/{plugins/design/dev-server → apps/studio}/sync/agent.ts +231 -57
- package/{plugins/design/dev-server → apps/studio}/sync/codec.ts +45 -0
- package/apps/studio/sync/cold-start.ts +158 -0
- package/{plugins/design/dev-server → apps/studio}/sync/connection-state.ts +58 -2
- package/{plugins/design/dev-server → apps/studio}/sync/index.ts +563 -221
- package/apps/studio/sync/journal.ts +190 -0
- package/apps/studio/sync/migrate-seed.ts +321 -0
- package/{plugins/design/dev-server → apps/studio}/sync/projection.ts +22 -3
- package/{plugins/design/dev-server → apps/studio}/sync/status.ts +15 -4
- package/{plugins/design/dev-server → apps/studio}/test/activity.test.ts +1 -7
- package/apps/studio/test/annotate-write.test.ts +184 -0
- package/apps/studio/test/annotations-align.test.ts +88 -0
- package/apps/studio/test/annotations-bindings.test.ts +124 -0
- package/apps/studio/test/annotations-groups.test.ts +231 -0
- package/{plugins/design/dev-server → apps/studio}/test/annotations-layer.test.ts +63 -0
- package/{plugins/design/dev-server → apps/studio}/test/annotations-roundtrip.test.ts +97 -0
- package/apps/studio/test/annotations-snap.test.ts +79 -0
- package/apps/studio/test/annotations-text-format.test.ts +396 -0
- package/apps/studio/test/asset-api.test.ts +149 -0
- package/apps/studio/test/canvas-create-api.test.ts +361 -0
- package/{plugins/design/dev-server → apps/studio}/test/canvas-cursors.test.ts +2 -0
- package/apps/studio/test/canvas-edit.test.ts +319 -0
- package/{plugins/design/dev-server → apps/studio}/test/canvas-lib-resolver.test.ts +1 -1
- package/apps/studio/test/canvas-media-drop.test.ts +158 -0
- package/{plugins/design/dev-server → apps/studio}/test/canvas-origin-gate.test.ts +25 -1
- package/apps/studio/test/canvas-url.test.ts +99 -0
- package/{plugins/design/dev-server → apps/studio}/test/collab-bridge.test.ts +0 -2
- package/{plugins/design/dev-server → apps/studio}/test/collab-room.test.ts +2 -7
- package/{plugins/design/dev-server → apps/studio}/test/csp-canvas-shell.test.ts +5 -0
- package/apps/studio/test/csrf-write-guard.test.ts +52 -0
- package/apps/studio/test/figjam-v3-model.test.ts +342 -0
- package/apps/studio/test/fixtures/figjam-v3-groups-bindings.svg +1 -0
- package/apps/studio/test/index-data-canvas-ds.test.ts +97 -0
- package/apps/studio/test/motion-sample.test.ts +35 -0
- package/{plugins/design/dev-server → apps/studio}/test/perf-harness.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/test/phase-3.6-smoke.test.ts +3 -1
- package/apps/studio/test/read-annotations.test.ts +409 -0
- package/{plugins/design/dev-server → apps/studio}/test/sanitize-annotation-svg.test.ts +108 -2
- package/{plugins/design/dev-server → apps/studio}/test/shared-doc-convergence.test.ts +1 -1
- package/apps/studio/test/shared-doc-migrate.test.ts +369 -0
- package/apps/studio/test/sync-agent.test.ts +575 -0
- package/{plugins/design/dev-server → apps/studio}/test/sync-codec.test.ts +65 -0
- package/apps/studio/test/sync-cold-start.test.ts +244 -0
- package/{plugins/design/dev-server → apps/studio}/test/sync-connection-state.test.ts +68 -0
- package/{plugins/design/dev-server → apps/studio}/test/sync-hardening.test.ts +0 -8
- package/{plugins/design/dev-server → apps/studio}/test/sync-hubs-config.test.ts +0 -1
- package/apps/studio/test/sync-incident-replay.test.ts +211 -0
- package/apps/studio/test/sync-journal.test.ts +176 -0
- package/{plugins/design/dev-server → apps/studio}/test/sync-runtime.test.ts +360 -5
- package/{plugins/design/dev-server → apps/studio}/test/sync-status.test.ts +66 -0
- package/apps/studio/test/tour-overlay.test.tsx +56 -0
- package/apps/studio/test/use-annotation-resize.test.ts +402 -0
- package/{plugins/design/dev-server → apps/studio}/test/use-artboard-drag.test.ts +0 -1
- package/{plugins/design/dev-server → apps/studio}/test/use-collab.test.ts +0 -0
- package/{plugins/design/dev-server → apps/studio}/test/use-tool-mode.test.tsx +8 -2
- package/apps/studio/test/whats-new.test.ts +101 -0
- package/apps/studio/text-imports.d.ts +9 -0
- package/{plugins/design/dev-server → apps/studio}/tool-palette.tsx +15 -70
- package/{plugins/design/dev-server → apps/studio}/undo-hud.tsx +1 -2
- package/{plugins/design/dev-server → apps/studio}/undo-stack.ts +1 -1
- package/{plugins/design/dev-server → apps/studio}/use-agent-presence.tsx +5 -3
- package/apps/studio/use-annotation-resize.tsx +912 -0
- package/{plugins/design/dev-server → apps/studio}/use-annotation-selection.tsx +17 -5
- package/{plugins/design/dev-server → apps/studio}/use-annotations-visibility.tsx +1 -1
- package/{plugins/design/dev-server → apps/studio}/use-artboard-drag.tsx +1 -1
- package/{plugins/design/dev-server → apps/studio}/use-canvas-activity.tsx +3 -3
- package/apps/studio/use-canvas-media-drop.tsx +343 -0
- package/{plugins/design/dev-server → apps/studio}/use-collab.tsx +21 -16
- package/{plugins/design/dev-server → apps/studio}/use-cursor-modifiers.tsx +1 -1
- package/{plugins/design/dev-server → apps/studio}/use-keyboard-discipline.tsx +5 -2
- package/{plugins/design/dev-server → apps/studio}/use-selection-set.tsx +18 -1
- package/{plugins/design/dev-server → apps/studio}/use-snap-guides.tsx +1 -1
- package/{plugins/design/dev-server → apps/studio}/use-tool-mode.tsx +8 -2
- package/{plugins/design/dev-server → apps/studio}/use-undo-stack.tsx +1 -1
- package/apps/studio/whats-new.json +264 -0
- package/apps/studio/whats-new.schema.json +86 -0
- package/apps/studio/whats-new.ts +87 -0
- package/cli/bin/maude.mjs +10 -0
- package/cli/commands/design-link.test.mjs +84 -0
- package/cli/commands/design.mjs +16 -7
- package/cli/commands/design.test.mjs +40 -0
- package/cli/commands/help.mjs +8 -2
- package/cli/commands/hub.mjs +3 -3
- package/cli/commands/hub.test.mjs +1 -1
- package/cli/commands/scenario-report.mjs +2 -9
- package/cli/lib/design-link.mjs +51 -1
- package/cli/lib/flow-design-integration.test.mjs +1 -1
- package/cli/lib/gitignore-block.mjs +1 -0
- package/cli/lib/plugin-cli-reachability.test.mjs +8 -7
- package/cli/lib/preflight.mjs +1 -1
- package/package.json +15 -15
- package/plugins/design/templates/_shell.html +28 -4
- package/plugins/design/templates/brief-board.tsx.template +61 -0
- package/plugins/design/templates/canvas.tsx.template +1 -1
- package/plugins/design/templates/design-system-inspiration/core/config.json.tpl +1 -1
- package/plugins/design/templates/design-system-inspiration/core/preview/_motion-readme.md.tpl +1 -1
- package/plugins/flow/.claude-plugin/config.schema.json +16 -0
- package/plugins/design/dev-server/annotations-layer.tsx +0 -3402
- package/plugins/design/dev-server/client/app.jsx +0 -2985
- package/plugins/design/dev-server/client/index.html +0 -15
- package/plugins/design/dev-server/dist/client.bundle.js +0 -20692
- package/plugins/design/dev-server/dist/comment-mount.js +0 -1924
- package/plugins/design/dev-server/dist/styles.css +0 -2710
- package/plugins/design/dev-server/dom-selection.ts +0 -156
- package/plugins/design/dev-server/sync/migrate-seed.ts +0 -163
- package/plugins/design/dev-server/test/canvas-edit.test.ts +0 -139
- package/plugins/design/dev-server/test/shared-doc-migrate.test.ts +0 -159
- package/plugins/design/dev-server/test/sync-agent.test.ts +0 -305
- package/plugins/design/dev-server/test/use-annotation-resize.test.ts +0 -200
- package/plugins/design/dev-server/use-annotation-resize.tsx +0 -449
- /package/{plugins/design/dev-server → apps/studio}/activity.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_enumerate-artboards-playwright.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_html-playwright.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_pdf-playwright.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_pptx-playwright.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_pw-launch.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_screenshot-playwright.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_svg-optimize.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/_svg-playwright.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/asset-sweep.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/bootstrap-check.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/check-runtime-bundles.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/draw-build.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/handoff.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/prep.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/scenario-report.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/slug.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/smoke.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/svg-optimize.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/bin/visual-sanity.sh +0 -0
- /package/{plugins/design/dev-server → apps/studio}/boot-self-heal.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/canvas-build.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/canvas-header.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/canvas-meta.schema.json +0 -0
- /package/{plugins/design/dev-server → apps/studio}/canvas-pipeline.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/client/hmr.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/client/iframe-lazy.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/client/styles/0-reset.css +0 -0
- /package/{plugins/design/dev-server → apps/studio}/client/styles/1-tokens.css +0 -0
- /package/{plugins/design/dev-server → apps/studio}/client/styles/2-layout.css +0 -0
- /package/{plugins/design/dev-server → apps/studio}/client/styles/5-utilities.css +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/ai-activity.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/awareness-bridge.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/git-lifecycle.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/index.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/persistence.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/protocol.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/registry.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/collab/room.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/config.schema.json +0 -0
- /package/{plugins/design/dev-server → apps/studio}/context.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/.min-sizes.json +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/lib0_decoding.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/lib0_encoding.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/motion.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/motion_react.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/pixi-js.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/react-dom.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/react-dom_client.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/react.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/react_jsx-dev-runtime.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/react_jsx-runtime.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/y-protocols_awareness.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/y-protocols_sync.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/dist/runtime/yjs.js +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/brush.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/composition.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/geometry.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/gradient.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/layout.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/optimize.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/palette.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/primitives.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/draw/test/serialize.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/examples/README.md +0 -0
- /package/{plugins/design/dev-server → apps/studio}/examples/perf-100-artboards.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/_browser-bundles.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/canva-handoff-prompt.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/canva.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/html.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/index.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/pdf.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/png.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/pptx.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/scope.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/svg.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/exporters/zip.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/fs-watch.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/handoff.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/hmr-broadcast.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/locator.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/mem.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/runtime-bundle.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/server.mjs +0 -0
- /package/{plugins/design/dev-server → apps/studio}/sync/atomic-write.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/sync/echo-guard.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/sync/fs-mirror.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/sync/hubs-config.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/sync/materialize.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/sync/origins.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/sync/untrusted.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/_helpers.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/active-state.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/ai-activity.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/annotation-strokes-command.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/annotations-api.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/annotations-draw-modifiers.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/artboard-activity-overlay.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/binary-smoke.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/boot-self-heal.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/bundle-smoke.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-build.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-header.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-hmr-runtime.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-lib-inline.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-lib-motion.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-meta-api.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-pipeline.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/canvas-route.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/collab-annotations-bridge.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/collab-awareness-bridge.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/collab-loopback.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/collab-protocol.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/collab-reseed-guard.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/collab-stress.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/comment-mount.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/comments-api.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/compile-entry.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/context-resolve-tokens.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/equal-spacing-detector.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/canva.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/endpoint.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/history.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/html.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/pdf.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/png.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/pptx-deck.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/pptx.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/pw-launch.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/scope.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/svg.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/exporters/zip.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/fixtures/phase-20-annotations.svg +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/fixtures/phase-21-annotations.svg +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/fs-watch.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/git-lifecycle.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/handoff-static-frames.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/handoff.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/history-rollback.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/hmr-broadcast.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/hmr-classify.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/input-router.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/locator.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/marquee-overlay.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/move-artboards-command.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/participants-chrome.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/paths.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/runtime-bundle-error-mapping.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/runtime-bundle.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/server-lifecycle.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/shared-doc-foundation.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/shared-doc-projection.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/snap-distance-pill.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/sync-atomic-write.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/sync-echo-guard.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/sync-fs-mirror.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/sync-meta-codec.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/sync-untrusted.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/system-endpoint.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/tool-palette.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/undo-stack.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-agent-presence.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-annotation-selection.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-canvas-activity.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-cursor-modifiers.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-keyboard-discipline.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-selection-set.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-snap-guides.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/use-undo-stack.test.tsx +0 -0
- /package/{plugins/design/dev-server → apps/studio}/test/ws-handshake.test.ts +0 -0
- /package/{plugins/design/dev-server → apps/studio}/tsconfig.json +0 -0
- /package/{plugins/design/dev-server → apps/studio}/ws.ts +0 -0
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
type ArrowStroke,
|
|
14
14
|
arrowHeadPoints,
|
|
15
15
|
type EllipseStroke,
|
|
16
|
+
type ImageStroke,
|
|
17
|
+
type LinkStroke,
|
|
16
18
|
type PenStroke,
|
|
17
19
|
type PolygonStroke,
|
|
18
20
|
penPathD,
|
|
@@ -696,6 +698,67 @@ describe('annotations-layer / Phase 21 sticky + standalone-text geometry', () =>
|
|
|
696
698
|
});
|
|
697
699
|
});
|
|
698
700
|
|
|
701
|
+
describe('annotations-layer / Phase 23 image + link geometry', () => {
|
|
702
|
+
const image: ImageStroke = {
|
|
703
|
+
id: 'im',
|
|
704
|
+
tool: 'image',
|
|
705
|
+
x: 30,
|
|
706
|
+
y: 40,
|
|
707
|
+
w: 200,
|
|
708
|
+
h: 150,
|
|
709
|
+
href: 'assets/deadbeef.png',
|
|
710
|
+
};
|
|
711
|
+
const link: LinkStroke = {
|
|
712
|
+
id: 'lk',
|
|
713
|
+
tool: 'link',
|
|
714
|
+
x: 30,
|
|
715
|
+
y: 40,
|
|
716
|
+
w: 260,
|
|
717
|
+
h: 76,
|
|
718
|
+
url: 'https://example.com',
|
|
719
|
+
title: 'Example',
|
|
720
|
+
domain: 'example.com',
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
test('image bbox is its rect extent (normalizes negative extent)', () => {
|
|
724
|
+
expect(strokeBBox(image)).toEqual({ x: 30, y: 40, w: 200, h: 150 });
|
|
725
|
+
expect(strokeBBox({ ...image, x: 230, y: 190, w: -200, h: -150 })).toEqual({
|
|
726
|
+
x: 30,
|
|
727
|
+
y: 40,
|
|
728
|
+
w: 200,
|
|
729
|
+
h: 150,
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
test('link bbox is its card extent', () => {
|
|
734
|
+
expect(strokeBBox(link)).toEqual({ x: 30, y: 40, w: 260, h: 76 });
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
test('image + link are filled-card hits anywhere inside', () => {
|
|
738
|
+
expect(strokeHitTest(image, 100, 100, 4)).toBe(true); // interior
|
|
739
|
+
expect(strokeHitTest(image, 30, 40, 4)).toBe(true); // corner
|
|
740
|
+
expect(strokeHitTest(image, 999, 999, 4)).toBe(false); // far outside
|
|
741
|
+
expect(strokeHitTest(link, 100, 60, 4)).toBe(true);
|
|
742
|
+
expect(strokeHitTest(link, 999, 999, 4)).toBe(false);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
test('image serializes a same-origin <image> with preserveAspectRatio', () => {
|
|
746
|
+
const svg = strokesToSvg([image]);
|
|
747
|
+
expect(svg).toContain('<image');
|
|
748
|
+
expect(svg).toContain('data-tool="image"');
|
|
749
|
+
expect(svg).toContain('preserveAspectRatio="xMidYMid meet"');
|
|
750
|
+
expect(svg).toContain('href="assets/deadbeef.png"');
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
test('link serializes a card <g> carrying its data-* payload', () => {
|
|
754
|
+
const svg = strokesToSvg([link]);
|
|
755
|
+
expect(svg).toContain('data-tool="link"');
|
|
756
|
+
expect(svg).toContain('data-url="https://example.com"');
|
|
757
|
+
expect(svg).toContain('data-domain="example.com"');
|
|
758
|
+
expect(svg).toContain('<rect');
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
|
|
699
762
|
describe('annotations-layer / Phase 24 polygon geometry', () => {
|
|
700
763
|
test('polygonVertices span the full bbox for every shape', () => {
|
|
701
764
|
for (const shape of ['diamond', 'triangle', 'triangle-down'] as const) {
|
|
@@ -14,6 +14,8 @@ import { GlobalRegistrator } from '@happy-dom/global-registrator';
|
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
type ArrowStroke,
|
|
17
|
+
type ImageStroke,
|
|
18
|
+
type LinkStroke,
|
|
17
19
|
type RectStroke,
|
|
18
20
|
type StickyStroke,
|
|
19
21
|
type Stroke,
|
|
@@ -217,6 +219,101 @@ describe('annotations round-trip / arrow heads + dash (4 dirs × 2 dash)', () =>
|
|
|
217
219
|
}
|
|
218
220
|
});
|
|
219
221
|
|
|
222
|
+
describe('annotations round-trip / image (Phase 23)', () => {
|
|
223
|
+
const image: ImageStroke = {
|
|
224
|
+
id: 'im1',
|
|
225
|
+
tool: 'image',
|
|
226
|
+
x: 120,
|
|
227
|
+
y: 80,
|
|
228
|
+
w: 320,
|
|
229
|
+
h: 240,
|
|
230
|
+
href: 'assets/a1b2c3d4.png',
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
test('image survives serialize → parse with all fields intact', () => {
|
|
234
|
+
const [parsed] = svgToStrokes(strokesToSvg([image])) as ImageStroke[];
|
|
235
|
+
expect(parsed).toEqual(image);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test('image alt text round-trips via data-alt', () => {
|
|
239
|
+
const withAlt: ImageStroke = { ...image, alt: 'competitor pricing page' };
|
|
240
|
+
const svg = strokesToSvg([withAlt]);
|
|
241
|
+
expect(svg).toContain('data-alt="competitor pricing page"');
|
|
242
|
+
const [parsed] = svgToStrokes(svg) as ImageStroke[];
|
|
243
|
+
expect(parsed?.alt).toBe('competitor pricing page');
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('image with no alt omits data-alt (no phantom default)', () => {
|
|
247
|
+
const svg = strokesToSvg([image]);
|
|
248
|
+
expect(svg).not.toContain('data-alt');
|
|
249
|
+
const [parsed] = svgToStrokes(svg) as ImageStroke[];
|
|
250
|
+
expect(parsed?.alt).toBeUndefined();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('image persists a relative assets href (never a data: URL)', () => {
|
|
254
|
+
const svg = strokesToSvg([image]);
|
|
255
|
+
expect(svg).toContain('href="assets/a1b2c3d4.png"');
|
|
256
|
+
expect(svg).not.toContain('data:');
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test('image serialize → parse is idempotent', () => {
|
|
260
|
+
const once = strokesToSvg([{ ...image, alt: 'x' }]);
|
|
261
|
+
expect(reparse(once)).toBe(once);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test('image SVG survives sanitizeAnnotationSvg byte-intact (PUT-path)', () => {
|
|
265
|
+
// The assets href must SURVIVE the sanitizer (Task 4 relaxation), so the
|
|
266
|
+
// persisted form comes back unchanged on every PUT.
|
|
267
|
+
const svg = strokesToSvg([image]);
|
|
268
|
+
expect(sanitizeAnnotationSvg(svg)).toBe(svg);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('annotations round-trip / link chip (Phase 23)', () => {
|
|
273
|
+
const link: LinkStroke = {
|
|
274
|
+
id: 'lk1',
|
|
275
|
+
tool: 'link',
|
|
276
|
+
x: 60,
|
|
277
|
+
y: 40,
|
|
278
|
+
w: 260,
|
|
279
|
+
h: 76,
|
|
280
|
+
url: 'https://example.com/blog/post?ref=maude',
|
|
281
|
+
title: 'A reference post worth reacting to',
|
|
282
|
+
domain: 'example.com',
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
test('link survives serialize → parse with all fields intact', () => {
|
|
286
|
+
const [parsed] = svgToStrokes(strokesToSvg([link])) as LinkStroke[];
|
|
287
|
+
expect(parsed).toEqual(link);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test('link never persists an <a href> (click-to-open is client-only)', () => {
|
|
291
|
+
const svg = strokesToSvg([link]);
|
|
292
|
+
expect(svg).not.toContain('<a ');
|
|
293
|
+
expect(svg).toContain('data-url="https://example.com/blog/post?ref=maude"');
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test('link serialize → parse is idempotent (even with a long title)', () => {
|
|
297
|
+
const once = strokesToSvg([{ ...link, title: 'x'.repeat(200) }]);
|
|
298
|
+
expect(reparse(once)).toBe(once);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test('link SVG survives sanitizeAnnotationSvg byte-intact (PUT-path)', () => {
|
|
302
|
+
// rect/svg/path/text/data-* are all allowlisted; no on*/style/href → unchanged.
|
|
303
|
+
const svg = strokesToSvg([link]);
|
|
304
|
+
expect(sanitizeAnnotationSvg(svg)).toBe(svg);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test('link missing data-title falls back to the domain', () => {
|
|
308
|
+
const svg =
|
|
309
|
+
'<svg xmlns="http://www.w3.org/2000/svg" data-mdcc-annotations="1">' +
|
|
310
|
+
'<g data-id="lk2" data-tool="link" data-url="https://x.io" data-domain="x.io">' +
|
|
311
|
+
'<rect x="0" y="0" width="260" height="76" rx="8" ry="8"/></g></svg>';
|
|
312
|
+
const [parsed] = svgToStrokes(svg) as LinkStroke[];
|
|
313
|
+
expect(parsed?.title).toBe('x.io');
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
220
317
|
describe('annotations round-trip / standalone vs anchored text', () => {
|
|
221
318
|
test('standalone text round-trips its world (x, y) and stays unanchored', () => {
|
|
222
319
|
const t: TextStroke = {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// annotations-snap — FigJam v3 drag snapping + smart guides (pure, DOM-free).
|
|
2
|
+
|
|
3
|
+
import { describe, expect, test } from 'bun:test';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
computeSnap,
|
|
7
|
+
GRID_PITCH_PX,
|
|
8
|
+
SNAP_THRESHOLD_PX,
|
|
9
|
+
type SnapBox,
|
|
10
|
+
} from '../annotations-snap.ts';
|
|
11
|
+
|
|
12
|
+
const box = (x: number, y: number, w = 100, h = 100): SnapBox => ({ x, y, w, h });
|
|
13
|
+
|
|
14
|
+
describe('computeSnap', () => {
|
|
15
|
+
test('snaps left edge to a candidate left edge within the threshold', () => {
|
|
16
|
+
const res = computeSnap(box(104, 300), [box(100, 0)], SNAP_THRESHOLD_PX);
|
|
17
|
+
expect(res.dx).toBe(-4);
|
|
18
|
+
expect(res.dy).toBe(0);
|
|
19
|
+
expect(res.guides).toHaveLength(1);
|
|
20
|
+
const guide = res.guides[0];
|
|
21
|
+
expect(guide?.axis).toBe('x');
|
|
22
|
+
expect(guide?.at).toBe(100);
|
|
23
|
+
// The guide spans from the candidate to the (snapped) moving box.
|
|
24
|
+
expect(guide?.from).toBe(0);
|
|
25
|
+
expect(guide?.to).toBe(400);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('centers participate — center-to-center snap', () => {
|
|
29
|
+
// moving center x = 153, candidate center x = 150 → dx -3.
|
|
30
|
+
const res = computeSnap(box(103, 0), [box(100, 300)], SNAP_THRESHOLD_PX);
|
|
31
|
+
expect(res.dx).toBe(-3);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('axes resolve independently against different candidates', () => {
|
|
35
|
+
const res = computeSnap(box(104, 203), [box(100, 500), box(500, 200)], SNAP_THRESHOLD_PX);
|
|
36
|
+
expect(res.dx).toBe(-4); // left edge → first candidate
|
|
37
|
+
expect(res.dy).toBe(-3); // top edge → second candidate
|
|
38
|
+
expect(res.guides).toHaveLength(2);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('nearest line wins; outside the threshold = no snap', () => {
|
|
42
|
+
const res = computeSnap(box(104, 0), [box(100, 0), box(105, 0)], SNAP_THRESHOLD_PX);
|
|
43
|
+
expect(res.dx).toBe(1); // 105 is 1 away vs 100 being 4 away
|
|
44
|
+
const none = computeSnap(box(120, 0), [box(100, 300)], SNAP_THRESHOLD_PX);
|
|
45
|
+
expect(none.dx).toBe(0);
|
|
46
|
+
expect(none.guides).toHaveLength(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('empty candidates / zero threshold → no snap', () => {
|
|
50
|
+
expect(computeSnap(box(0, 0), [], SNAP_THRESHOLD_PX).guides).toHaveLength(0);
|
|
51
|
+
expect(computeSnap(box(101, 0), [box(100, 0)], 0).dx).toBe(0);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('grid fallback — leading edge snaps to the 24px lattice with no candidates', () => {
|
|
55
|
+
// x=98 → nearest grid line 96 (4·24), 2 away; y=50 → nearest 48, 2 away.
|
|
56
|
+
const res = computeSnap(box(98, 50), [], SNAP_THRESHOLD_PX, { grid: GRID_PITCH_PX });
|
|
57
|
+
expect(res.dx).toBe(-2);
|
|
58
|
+
expect(res.dy).toBe(-2);
|
|
59
|
+
// Grid snap is silent — the dots themselves are the visual, no guide lines.
|
|
60
|
+
expect(res.guides).toHaveLength(0);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('grid fallback is per-axis — a smart-guide axis keeps its candidate snap', () => {
|
|
64
|
+
// x snaps to the candidate edge (dx -4 → x=100, NOT the 96 grid line);
|
|
65
|
+
// y has no candidate within reach → grid line 48 wins (dy -2).
|
|
66
|
+
const res = computeSnap(box(104, 50), [box(100, 500)], SNAP_THRESHOLD_PX, {
|
|
67
|
+
grid: GRID_PITCH_PX,
|
|
68
|
+
});
|
|
69
|
+
expect(res.dx).toBe(-4);
|
|
70
|
+
expect(res.dy).toBe(-2);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('grid outside the threshold → no correction', () => {
|
|
74
|
+
// x=84 sits 12 from both 72 and 96 — beyond the 6px threshold.
|
|
75
|
+
const res = computeSnap(box(84, 84), [], SNAP_THRESHOLD_PX, { grid: GRID_PITCH_PX });
|
|
76
|
+
expect(res.dx).toBe(0);
|
|
77
|
+
expect(res.dy).toBe(0);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
// annotations text-format polish — multi-line tspans, italic / underline,
|
|
2
|
+
// ordered + unordered lists, dashed shapes, and the highlighter pen. The PARSE
|
|
3
|
+
// side needs a DOMParser (happy-dom, registered per-file). The load-bearing
|
|
4
|
+
// assertions: every NEW field serializes ONLY when set (the byte-identical
|
|
5
|
+
// round-trip canary holds for legacy/unstyled strokes), and multi-line text
|
|
6
|
+
// reconstructs its `\n` from tspans (list markers stripped).
|
|
7
|
+
|
|
8
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
9
|
+
import { GlobalRegistrator } from '@happy-dom/global-registrator';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
type EllipseStroke,
|
|
13
|
+
listPrefixedBody,
|
|
14
|
+
type PenStroke,
|
|
15
|
+
type RectStroke,
|
|
16
|
+
type StickyStroke,
|
|
17
|
+
splitTextLines,
|
|
18
|
+
stickyCornerPath,
|
|
19
|
+
stripEditorMarkers,
|
|
20
|
+
strokeBBox,
|
|
21
|
+
strokesToSvg,
|
|
22
|
+
svgToStrokes,
|
|
23
|
+
type TextStroke,
|
|
24
|
+
} from '../annotations-layer.tsx';
|
|
25
|
+
import { sanitizeAnnotationSvg } from '../api.ts';
|
|
26
|
+
|
|
27
|
+
beforeAll(() => {
|
|
28
|
+
GlobalRegistrator.register();
|
|
29
|
+
});
|
|
30
|
+
afterAll(async () => {
|
|
31
|
+
await GlobalRegistrator.unregister();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/** Re-serialize a freshly-parsed SVG. Idempotency helper. */
|
|
35
|
+
function reparse(svg: string): string {
|
|
36
|
+
return strokesToSvg(svgToStrokes(svg));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const baseStandalone: TextStroke = {
|
|
40
|
+
id: 't1',
|
|
41
|
+
tool: 'text',
|
|
42
|
+
color: '#1f1f1f',
|
|
43
|
+
fontSize: 14,
|
|
44
|
+
text: 'one line',
|
|
45
|
+
x: 40,
|
|
46
|
+
y: 60,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
50
|
+
// Multi-line text (item 4a)
|
|
51
|
+
|
|
52
|
+
describe('text-format / multi-line tspans', () => {
|
|
53
|
+
test('single-line text emits NO tspan and round-trips byte-identical', () => {
|
|
54
|
+
const svg = strokesToSvg([baseStandalone]);
|
|
55
|
+
expect(svg).not.toContain('<tspan');
|
|
56
|
+
expect(reparse(svg)).toBe(svg);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('standalone multi-line text emits one tspan per line and recovers \\n', () => {
|
|
60
|
+
const multi: TextStroke = { ...baseStandalone, text: 'line one\nline two\nline three' };
|
|
61
|
+
const svg = strokesToSvg([multi]);
|
|
62
|
+
expect((svg.match(/<tspan/g) ?? []).length).toBe(3);
|
|
63
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
64
|
+
expect(parsed?.text).toBe('line one\nline two\nline three');
|
|
65
|
+
expect(reparse(svg)).toBe(svg); // idempotent
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('anchored multi-line text round-trips its \\n', () => {
|
|
69
|
+
const anchored: TextStroke = {
|
|
70
|
+
id: 'ta',
|
|
71
|
+
tool: 'text',
|
|
72
|
+
color: '#1f1f1f',
|
|
73
|
+
fontSize: 16,
|
|
74
|
+
text: 'top\nbottom',
|
|
75
|
+
anchorId: 'host-1',
|
|
76
|
+
};
|
|
77
|
+
const svg = strokesToSvg([anchored]);
|
|
78
|
+
expect(svg).toContain('<tspan');
|
|
79
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
80
|
+
expect(parsed?.anchorId).toBe('host-1');
|
|
81
|
+
expect(parsed?.text).toBe('top\nbottom');
|
|
82
|
+
expect(reparse(svg)).toBe(svg);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('multi-line text survives the PUT-path sanitizer byte-intact (tspan allowlisted)', () => {
|
|
86
|
+
const svg = strokesToSvg([{ ...baseStandalone, text: 'a\nb' }]);
|
|
87
|
+
expect(sanitizeAnnotationSvg(svg)).toBe(svg);
|
|
88
|
+
const [parsed] = svgToStrokes(sanitizeAnnotationSvg(svg)) as TextStroke[];
|
|
89
|
+
expect(parsed?.text).toBe('a\nb');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
94
|
+
// Italic + underline (item 4b)
|
|
95
|
+
|
|
96
|
+
describe('text-format / italic + underline', () => {
|
|
97
|
+
test('italic serializes font-style only when set; round-trips', () => {
|
|
98
|
+
const plain = strokesToSvg([baseStandalone]);
|
|
99
|
+
expect(plain).not.toContain('font-style');
|
|
100
|
+
const svg = strokesToSvg([{ ...baseStandalone, italic: true }]);
|
|
101
|
+
expect(svg).toContain('font-style="italic"');
|
|
102
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
103
|
+
expect(parsed?.italic).toBe(true);
|
|
104
|
+
expect(reparse(svg)).toBe(svg);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('underline serializes text-decoration only when set; round-trips', () => {
|
|
108
|
+
const svg = strokesToSvg([{ ...baseStandalone, underline: true }]);
|
|
109
|
+
expect(svg).toContain('text-decoration="underline"');
|
|
110
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
111
|
+
expect(parsed?.underline).toBe(true);
|
|
112
|
+
expect(parsed?.strike).toBeUndefined();
|
|
113
|
+
expect(reparse(svg)).toBe(svg);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('strike + underline combine into one text-decoration (order stable)', () => {
|
|
117
|
+
const svg = strokesToSvg([{ ...baseStandalone, strike: true, underline: true }]);
|
|
118
|
+
expect(svg).toContain('text-decoration="line-through underline"');
|
|
119
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
120
|
+
expect(parsed?.strike).toBe(true);
|
|
121
|
+
expect(parsed?.underline).toBe(true);
|
|
122
|
+
expect(reparse(svg)).toBe(svg);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('strike-only stays byte-identical to the legacy line-through form', () => {
|
|
126
|
+
const svg = strokesToSvg([{ ...baseStandalone, strike: true }]);
|
|
127
|
+
expect(svg).toContain('text-decoration="line-through"');
|
|
128
|
+
expect(svg).not.toContain('underline');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('all four formats (bold+italic+strike+underline) combine + round-trip', () => {
|
|
132
|
+
// The editors commit bold/italic/underline (Cmd+B/I/U) + strike together;
|
|
133
|
+
// assert every flag serializes and survives the round-trip.
|
|
134
|
+
const svg = strokesToSvg([
|
|
135
|
+
{ ...baseStandalone, bold: true, italic: true, strike: true, underline: true },
|
|
136
|
+
]);
|
|
137
|
+
expect(svg).toContain('font-weight="700"');
|
|
138
|
+
expect(svg).toContain('font-style="italic"');
|
|
139
|
+
expect(svg).toContain('text-decoration="line-through underline"');
|
|
140
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
141
|
+
expect(parsed?.bold).toBe(true);
|
|
142
|
+
expect(parsed?.italic).toBe(true);
|
|
143
|
+
expect(parsed?.strike).toBe(true);
|
|
144
|
+
expect(parsed?.underline).toBe(true);
|
|
145
|
+
expect(reparse(svg)).toBe(svg);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('sticky italic + underline round-trip; a plain sticky gains no attrs', () => {
|
|
149
|
+
const plain: StickyStroke = {
|
|
150
|
+
id: 'st',
|
|
151
|
+
tool: 'sticky',
|
|
152
|
+
color: '#fce8a6',
|
|
153
|
+
x: 0,
|
|
154
|
+
y: 0,
|
|
155
|
+
w: 200,
|
|
156
|
+
h: 200,
|
|
157
|
+
text: 'note',
|
|
158
|
+
fontSize: 16,
|
|
159
|
+
};
|
|
160
|
+
expect(strokesToSvg([plain])).not.toContain('data-italic');
|
|
161
|
+
const svg = strokesToSvg([{ ...plain, italic: true, underline: true }]);
|
|
162
|
+
expect(svg).toContain('data-italic="1"');
|
|
163
|
+
expect(svg).toContain('data-underline="1"');
|
|
164
|
+
const [parsed] = svgToStrokes(svg) as StickyStroke[];
|
|
165
|
+
expect(parsed?.italic).toBe(true);
|
|
166
|
+
expect(parsed?.underline).toBe(true);
|
|
167
|
+
expect(reparse(svg)).toBe(svg);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
172
|
+
// Lists (item 4c)
|
|
173
|
+
|
|
174
|
+
describe('text-format / ordered + unordered lists', () => {
|
|
175
|
+
test('bullet list: data-list set, markers render-only, stored text clean', () => {
|
|
176
|
+
const svg = strokesToSvg([{ ...baseStandalone, text: 'apple\npear', listType: 'bullet' }]);
|
|
177
|
+
expect(svg).toContain('data-list="bullet"');
|
|
178
|
+
expect(svg).toContain('• apple');
|
|
179
|
+
expect(svg).toContain('• pear');
|
|
180
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
181
|
+
// Stored text has NO marker — markers are presentation only.
|
|
182
|
+
expect(parsed?.text).toBe('apple\npear');
|
|
183
|
+
expect(parsed?.listType).toBe('bullet');
|
|
184
|
+
expect(reparse(svg)).toBe(svg);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('numbered list: per-line N. markers, re-numbered from stored text', () => {
|
|
188
|
+
const svg = strokesToSvg([
|
|
189
|
+
{ ...baseStandalone, text: 'first\nsecond\nthird', listType: 'number' },
|
|
190
|
+
]);
|
|
191
|
+
expect(svg).toContain('1. first');
|
|
192
|
+
expect(svg).toContain('2. second');
|
|
193
|
+
expect(svg).toContain('3. third');
|
|
194
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
195
|
+
expect(parsed?.text).toBe('first\nsecond\nthird');
|
|
196
|
+
expect(parsed?.listType).toBe('number');
|
|
197
|
+
expect(reparse(svg)).toBe(svg);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('a single-line list item still round-trips (forces a tspan)', () => {
|
|
201
|
+
const svg = strokesToSvg([{ ...baseStandalone, text: 'solo', listType: 'bullet' }]);
|
|
202
|
+
expect(svg).toContain('<tspan');
|
|
203
|
+
expect(svg).toContain('• solo');
|
|
204
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
205
|
+
expect(parsed?.text).toBe('solo');
|
|
206
|
+
expect(parsed?.listType).toBe('bullet');
|
|
207
|
+
expect(reparse(svg)).toBe(svg);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test('a line that literally starts with the marker is not double-stripped', () => {
|
|
211
|
+
const svg = strokesToSvg([{ ...baseStandalone, text: '• already', listType: 'bullet' }]);
|
|
212
|
+
const [parsed] = svgToStrokes(svg) as TextStroke[];
|
|
213
|
+
expect(parsed?.text).toBe('• already');
|
|
214
|
+
expect(reparse(svg)).toBe(svg);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('no list ⇒ no data-list attribute (canary)', () => {
|
|
218
|
+
expect(strokesToSvg([baseStandalone])).not.toContain('data-list');
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('sticky list round-trips with markers render-only (body text stays raw)', () => {
|
|
222
|
+
const svg = strokesToSvg([
|
|
223
|
+
{
|
|
224
|
+
id: 'sl',
|
|
225
|
+
tool: 'sticky',
|
|
226
|
+
color: '#fce8a6',
|
|
227
|
+
x: 0,
|
|
228
|
+
y: 0,
|
|
229
|
+
w: 200,
|
|
230
|
+
h: 200,
|
|
231
|
+
text: 'buy milk\nbuy eggs',
|
|
232
|
+
fontSize: 16,
|
|
233
|
+
listType: 'bullet',
|
|
234
|
+
},
|
|
235
|
+
]);
|
|
236
|
+
expect(svg).toContain('data-list="bullet"');
|
|
237
|
+
// The persisted sticky body <text> keeps RAW text (no marker).
|
|
238
|
+
expect(svg).toContain('>buy milk\nbuy eggs<');
|
|
239
|
+
const [parsed] = svgToStrokes(svg) as StickyStroke[];
|
|
240
|
+
expect(parsed?.text).toBe('buy milk\nbuy eggs');
|
|
241
|
+
expect(parsed?.listType).toBe('bullet');
|
|
242
|
+
expect(reparse(svg)).toBe(svg);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
247
|
+
// Dashed rect / ellipse (item 7)
|
|
248
|
+
|
|
249
|
+
describe('text-format / dashed shapes', () => {
|
|
250
|
+
const rect: RectStroke = {
|
|
251
|
+
id: 'r',
|
|
252
|
+
tool: 'rect',
|
|
253
|
+
color: '#1f1f1f',
|
|
254
|
+
width: 2,
|
|
255
|
+
x: 0,
|
|
256
|
+
y: 0,
|
|
257
|
+
w: 80,
|
|
258
|
+
h: 60,
|
|
259
|
+
fill: null,
|
|
260
|
+
};
|
|
261
|
+
const ellipse: EllipseStroke = {
|
|
262
|
+
id: 'e',
|
|
263
|
+
tool: 'ellipse',
|
|
264
|
+
color: '#1f1f1f',
|
|
265
|
+
width: 2,
|
|
266
|
+
cx: 40,
|
|
267
|
+
cy: 30,
|
|
268
|
+
rx: 30,
|
|
269
|
+
ry: 20,
|
|
270
|
+
fill: null,
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
test('solid rect / ellipse emit no dash attr (canary)', () => {
|
|
274
|
+
expect(strokesToSvg([rect])).not.toContain('data-dash');
|
|
275
|
+
expect(strokesToSvg([ellipse])).not.toContain('data-dash');
|
|
276
|
+
expect(reparse(strokesToSvg([rect]))).toBe(strokesToSvg([rect]));
|
|
277
|
+
expect(reparse(strokesToSvg([ellipse]))).toBe(strokesToSvg([ellipse]));
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test('dashed rect round-trips data-dash + stroke-dasharray', () => {
|
|
281
|
+
const svg = strokesToSvg([{ ...rect, dashed: true }]);
|
|
282
|
+
expect(svg).toContain('data-dash="1"');
|
|
283
|
+
expect(svg).toContain('stroke-dasharray="6 4"');
|
|
284
|
+
const [parsed] = svgToStrokes(svg) as RectStroke[];
|
|
285
|
+
expect(parsed?.dashed).toBe(true);
|
|
286
|
+
expect(reparse(svg)).toBe(svg);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('dashed ellipse round-trips data-dash', () => {
|
|
290
|
+
const svg = strokesToSvg([{ ...ellipse, dashed: true }]);
|
|
291
|
+
expect(svg).toContain('data-dash="1"');
|
|
292
|
+
const [parsed] = svgToStrokes(svg) as EllipseStroke[];
|
|
293
|
+
expect(parsed?.dashed).toBe(true);
|
|
294
|
+
expect(reparse(svg)).toBe(svg);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
299
|
+
// Highlighter pen (item 8) — appended after Task 9.
|
|
300
|
+
|
|
301
|
+
describe('text-format / highlighter pen', () => {
|
|
302
|
+
const pen: PenStroke = {
|
|
303
|
+
id: 'p',
|
|
304
|
+
tool: 'pen',
|
|
305
|
+
color: '#1f1f1f',
|
|
306
|
+
width: 3,
|
|
307
|
+
points: [
|
|
308
|
+
[0, 0],
|
|
309
|
+
[10, 0],
|
|
310
|
+
],
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
test('a normal pen emits no data-highlighter (canary)', () => {
|
|
314
|
+
const svg = strokesToSvg([pen]);
|
|
315
|
+
expect(svg).not.toContain('data-highlighter');
|
|
316
|
+
expect(reparse(svg)).toBe(svg);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test('a highlighter pen round-trips data-highlighter + wide translucent stroke', () => {
|
|
320
|
+
const hl: PenStroke = { ...pen, highlighter: true, width: 16, color: '#ffe40066' };
|
|
321
|
+
const svg = strokesToSvg([hl]);
|
|
322
|
+
expect(svg).toContain('data-highlighter="1"');
|
|
323
|
+
const [parsed] = svgToStrokes(svg) as PenStroke[];
|
|
324
|
+
expect(parsed?.highlighter).toBe(true);
|
|
325
|
+
expect(parsed?.width).toBe(16);
|
|
326
|
+
expect(parsed?.color).toBe('#ffe40066');
|
|
327
|
+
expect(reparse(svg)).toBe(svg);
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
332
|
+
// Render-contract helpers (item 1 sticky corner + item 4a bbox)
|
|
333
|
+
|
|
334
|
+
describe('text-format / sticky sharp-corner path (item 1)', () => {
|
|
335
|
+
test('stickyCornerPath rounds TL/TR/BL and keeps the bottom-right SHARP', () => {
|
|
336
|
+
const d = stickyCornerPath(0, 0, 100, 80, 8);
|
|
337
|
+
// The BR corner is a straight L to the exact corner (no Q arc there): the
|
|
338
|
+
// right edge drops to (100,80) then the bottom edge runs to the BL arc.
|
|
339
|
+
expect(d).toContain('L100 80'); // sharp bottom-right corner vertex
|
|
340
|
+
// Three rounded corners ⇒ exactly three quadratic arcs (TR, BL, TL).
|
|
341
|
+
expect((d.match(/Q/g) ?? []).length).toBe(3);
|
|
342
|
+
expect(d.endsWith('Z')).toBe(true);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
test('radius clamps to half the smaller side (never self-overlaps)', () => {
|
|
346
|
+
const d = stickyCornerPath(0, 0, 10, 200, 999);
|
|
347
|
+
// r clamps to min(999, 5, 100) = 5; the first move starts at x = r = 5.
|
|
348
|
+
expect(d.startsWith('M5 0')).toBe(true);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
describe('text-format / editor list markers (item 4c — show while editing)', () => {
|
|
353
|
+
test('listPrefixedBody adds markers; stripEditorMarkers removes them (round-trip)', () => {
|
|
354
|
+
expect(listPrefixedBody('a\nb', 'bullet')).toBe('• a\n• b');
|
|
355
|
+
expect(listPrefixedBody('a\nb\nc', 'number')).toBe('1. a\n2. b\n3. c');
|
|
356
|
+
expect(listPrefixedBody('a\nb', undefined)).toBe('a\nb');
|
|
357
|
+
for (const list of ['bullet', 'number'] as const) {
|
|
358
|
+
const raw = 'milk\neggs\nbread';
|
|
359
|
+
// The editor shows markers; on commit they strip back to the raw text.
|
|
360
|
+
expect(stripEditorMarkers(listPrefixedBody(raw, list), list)).toBe(raw);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test('stripEditorMarkers removes a numbered prefix regardless of the typed number', () => {
|
|
365
|
+
// A user who edits/reorders lines may leave stale numbers; strip is generic.
|
|
366
|
+
expect(stripEditorMarkers('1. x\n5. y\nz', 'number')).toBe('x\ny\nz');
|
|
367
|
+
expect(stripEditorMarkers('• keep\nno marker', 'bullet')).toBe('keep\nno marker');
|
|
368
|
+
expect(stripEditorMarkers('untouched', undefined)).toBe('untouched');
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
describe('text-format / multi-line bbox (item 4a)', () => {
|
|
373
|
+
test('a standalone multi-line text bbox grows with line count', () => {
|
|
374
|
+
const single = strokeBBox({
|
|
375
|
+
id: 't',
|
|
376
|
+
tool: 'text',
|
|
377
|
+
color: '#000',
|
|
378
|
+
fontSize: 20,
|
|
379
|
+
text: 'one',
|
|
380
|
+
x: 0,
|
|
381
|
+
y: 0,
|
|
382
|
+
});
|
|
383
|
+
const triple = strokeBBox({
|
|
384
|
+
id: 't',
|
|
385
|
+
tool: 'text',
|
|
386
|
+
color: '#000',
|
|
387
|
+
fontSize: 20,
|
|
388
|
+
text: 'one\ntwo\nthree',
|
|
389
|
+
x: 0,
|
|
390
|
+
y: 0,
|
|
391
|
+
});
|
|
392
|
+
expect(single?.h).toBeCloseTo(20 * 1.2, 4); // single-line keeps legacy height
|
|
393
|
+
expect(triple?.h).toBeGreaterThan((single?.h ?? 0) * 2); // ~3 lines tall
|
|
394
|
+
expect(splitTextLines('one\ntwo\nthree')).toEqual(['one', 'two', 'three']);
|
|
395
|
+
});
|
|
396
|
+
});
|