@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
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
// Sync-agent integration tests — Phase 9 Task 4.
|
|
2
|
-
//
|
|
3
|
-
// Uses an in-memory pair of Y.Docs cross-linked via Y.applyUpdate as a stand-in
|
|
4
|
-
// for HocuspocusProvider's transport. The agent under test owns docB; docA
|
|
5
|
-
// represents "another peer talking to the hub". Updates flow:
|
|
6
|
-
//
|
|
7
|
-
// docA → encode → applyUpdate(docB) → agent observes → write to disk
|
|
8
|
-
// disk → onRead → applyFromFs → applyHtmlToDoc(docB) → encode → docA
|
|
9
|
-
//
|
|
10
|
-
// This lets us validate the whole bidi loop, echo prevention, and the
|
|
11
|
-
// 100-event stress scenario from the plan without booting a real hub.
|
|
12
|
-
|
|
13
|
-
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
14
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
15
|
-
import { tmpdir } from 'node:os';
|
|
16
|
-
import { join } from 'node:path';
|
|
17
|
-
import * as Y from 'yjs';
|
|
18
|
-
|
|
19
|
-
import { type CanvasSyncAgent, createCanvasSyncAgent } from '../sync/agent.ts';
|
|
20
|
-
import { applyHtmlToDoc, htmlFromDoc, Y_SYNC_TYPES } from '../sync/codec.ts';
|
|
21
|
-
import { createEchoGuard, hashBytes } from '../sync/echo-guard.ts';
|
|
22
|
-
import { createFsReader } from '../sync/fs-mirror.ts';
|
|
23
|
-
|
|
24
|
-
let dir: string;
|
|
25
|
-
let agent: CanvasSyncAgent;
|
|
26
|
-
let docA: Y.Doc;
|
|
27
|
-
let docB: Y.Doc;
|
|
28
|
-
|
|
29
|
-
function paths() {
|
|
30
|
-
return {
|
|
31
|
-
html: join(dir, 'screen.html'),
|
|
32
|
-
comments: join(dir, '_comments', 'screen.json'),
|
|
33
|
-
annotations: join(dir, 'screen.annotations.svg'),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
dir = mkdtempSync(join(tmpdir(), 'sync-agent-'));
|
|
39
|
-
docA = new Y.Doc();
|
|
40
|
-
docB = new Y.Doc();
|
|
41
|
-
// Mirror docA→docB and docB→docA, ignoring transient origin objects from
|
|
42
|
-
// the transport itself (we use a symbol).
|
|
43
|
-
const TRANSPORT = Symbol('transport');
|
|
44
|
-
docA.on('update', (update: Uint8Array, origin: unknown) => {
|
|
45
|
-
if (origin === TRANSPORT) return;
|
|
46
|
-
Y.applyUpdate(docB, update, TRANSPORT);
|
|
47
|
-
});
|
|
48
|
-
docB.on('update', (update: Uint8Array, origin: unknown) => {
|
|
49
|
-
if (origin === TRANSPORT) return;
|
|
50
|
-
Y.applyUpdate(docA, update, TRANSPORT);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
afterEach(() => {
|
|
55
|
-
agent?.stop();
|
|
56
|
-
rmSync(dir, { recursive: true, force: true });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
function makeAgent(extra: { adopt?: boolean; flushMs?: number } = {}): CanvasSyncAgent {
|
|
60
|
-
const a = createCanvasSyncAgent({
|
|
61
|
-
slug: 'screen',
|
|
62
|
-
doc: docB,
|
|
63
|
-
paths: paths(),
|
|
64
|
-
echoGuard: createEchoGuard(),
|
|
65
|
-
flushMs: 0, // synchronous flush; the agent uses queueMicrotask
|
|
66
|
-
...extra,
|
|
67
|
-
});
|
|
68
|
-
a.start();
|
|
69
|
-
return a;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
describe('CanvasSyncAgent — hub → disk (Flow B)', () => {
|
|
73
|
-
test('writes HTML to disk when other peer mutates the doc', async () => {
|
|
74
|
-
agent = makeAgent();
|
|
75
|
-
// Other peer types into docA — propagates to docB via the in-memory
|
|
76
|
-
// transport, which our agent observes.
|
|
77
|
-
applyHtmlToDoc(docA, '<button>v1</button>');
|
|
78
|
-
await agent.flush();
|
|
79
|
-
|
|
80
|
-
expect(readFileSync(paths().html, 'utf8')).toBe('<button>v1</button>');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('debounces multiple rapid peer edits into one disk write', async () => {
|
|
84
|
-
agent = makeAgent({ flushMs: 30 });
|
|
85
|
-
for (let i = 0; i < 10; i++) {
|
|
86
|
-
applyHtmlToDoc(docA, `<button>v${i}</button>`);
|
|
87
|
-
}
|
|
88
|
-
await new Promise((res) => setTimeout(res, 80));
|
|
89
|
-
|
|
90
|
-
expect(readFileSync(paths().html, 'utf8')).toBe('<button>v9</button>');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('writes comments JSON when Y.Array changes', async () => {
|
|
94
|
-
agent = makeAgent();
|
|
95
|
-
docA.transact(() => {
|
|
96
|
-
docA.getArray('comments').push([{ id: 'c1', body: 'hello' }]);
|
|
97
|
-
});
|
|
98
|
-
await agent.flush();
|
|
99
|
-
|
|
100
|
-
const written = JSON.parse(readFileSync(paths().comments, 'utf8'));
|
|
101
|
-
expect(written).toEqual([{ id: 'c1', body: 'hello' }]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test('writes annotations SVG when Y.Map.svg changes', async () => {
|
|
105
|
-
agent = makeAgent();
|
|
106
|
-
docA.transact(() => {
|
|
107
|
-
docA.getMap('annotations').set('svg', '<svg>annot</svg>');
|
|
108
|
-
});
|
|
109
|
-
await agent.flush();
|
|
110
|
-
|
|
111
|
-
expect(readFileSync(paths().annotations, 'utf8')).toBe('<svg>annot</svg>');
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe('CanvasSyncAgent — disk → hub (Flow A)', () => {
|
|
116
|
-
test('applies disk HTML to doc when applyFromFs is called', () => {
|
|
117
|
-
agent = makeAgent();
|
|
118
|
-
const bytes = new TextEncoder().encode('<div>local-edit</div>');
|
|
119
|
-
const changed = agent.applyFromFs({
|
|
120
|
-
path: paths().html,
|
|
121
|
-
bytes,
|
|
122
|
-
hash: hashBytes(bytes),
|
|
123
|
-
});
|
|
124
|
-
expect(changed).toBe(true);
|
|
125
|
-
expect(htmlFromDoc(docA)).toBe('<div>local-edit</div>');
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('parses + applies comments JSON from disk', () => {
|
|
129
|
-
agent = makeAgent();
|
|
130
|
-
const snap = [{ id: 'c2' }];
|
|
131
|
-
const str = `${JSON.stringify(snap, null, 2)}\n`;
|
|
132
|
-
const bytes = new TextEncoder().encode(str);
|
|
133
|
-
agent.applyFromFs({ path: paths().comments, bytes, hash: hashBytes(bytes) });
|
|
134
|
-
expect(docA.getArray('comments').toArray()).toEqual(snap);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test('applies annotations SVG from disk', () => {
|
|
138
|
-
agent = makeAgent();
|
|
139
|
-
const bytes = new TextEncoder().encode('<svg>x</svg>');
|
|
140
|
-
agent.applyFromFs({ path: paths().annotations, bytes, hash: hashBytes(bytes) });
|
|
141
|
-
expect(docA.getMap<string>('annotations').get('svg')).toBe('<svg>x</svg>');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test('drops the fs-watch echo of its own atomic write', async () => {
|
|
145
|
-
agent = makeAgent();
|
|
146
|
-
// Peer edits → agent writes to disk → echo guard recorded.
|
|
147
|
-
applyHtmlToDoc(docA, '<button>hi</button>');
|
|
148
|
-
await agent.flush();
|
|
149
|
-
|
|
150
|
-
// Simulate the fs.watch firing for the path we just wrote.
|
|
151
|
-
const bytes = readFileSync(paths().html);
|
|
152
|
-
const u8 = new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
153
|
-
const changed = agent.applyFromFs({
|
|
154
|
-
path: paths().html,
|
|
155
|
-
bytes: u8,
|
|
156
|
-
hash: hashBytes(u8),
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
expect(changed).toBe(false);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('CanvasSyncAgent — cold start reconciliation', () => {
|
|
164
|
-
test('hub-wins (default): overwrites disk when doc differs', async () => {
|
|
165
|
-
// Local disk has stale content.
|
|
166
|
-
writeFileSync(paths().html, '<old>');
|
|
167
|
-
// Hub state arrives via docA (propagated to docB before reconcile runs).
|
|
168
|
-
applyHtmlToDoc(docA, '<new>');
|
|
169
|
-
|
|
170
|
-
agent = makeAgent();
|
|
171
|
-
await agent.reconcile();
|
|
172
|
-
|
|
173
|
-
expect(readFileSync(paths().html, 'utf8')).toBe('<new>');
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test('adopt mode: pushes local disk state up to the doc', async () => {
|
|
177
|
-
writeFileSync(paths().html, '<button>local</button>');
|
|
178
|
-
// Hub has stale content.
|
|
179
|
-
applyHtmlToDoc(docA, '<old-hub>');
|
|
180
|
-
|
|
181
|
-
agent = makeAgent({ adopt: true });
|
|
182
|
-
await agent.reconcile();
|
|
183
|
-
|
|
184
|
-
expect(htmlFromDoc(docA)).toBe('<button>local</button>');
|
|
185
|
-
expect(htmlFromDoc(docB)).toBe('<button>local</button>');
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
test('adopt mode is one-shot — second reconcile is hub-wins', async () => {
|
|
189
|
-
writeFileSync(paths().html, '<button>local-v1</button>');
|
|
190
|
-
agent = makeAgent({ adopt: true });
|
|
191
|
-
await agent.reconcile();
|
|
192
|
-
|
|
193
|
-
// Hub changes the value.
|
|
194
|
-
applyHtmlToDoc(docA, '<button>hub-v2</button>');
|
|
195
|
-
|
|
196
|
-
// Disk reverts to a stale local-only state.
|
|
197
|
-
writeFileSync(paths().html, '<button>local-v3</button>');
|
|
198
|
-
await agent.reconcile();
|
|
199
|
-
|
|
200
|
-
// Hub state won this time.
|
|
201
|
-
expect(htmlFromDoc(docB)).toBe('<button>hub-v2</button>');
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
test('empty hub doc does NOT clobber a non-empty local body — seeds local up instead (data-loss guard)', async () => {
|
|
205
|
-
// Local holds the real canvas body; the hub is fresh — no state for this
|
|
206
|
-
// slug yet (docB starts empty → docHtml === ''). The old behaviour wrote
|
|
207
|
-
// the empty doc over disk and emptied the file; the guard must keep local.
|
|
208
|
-
writeFileSync(paths().html, '<button>real-canvas</button>');
|
|
209
|
-
|
|
210
|
-
let conflicts = 0;
|
|
211
|
-
agent = createCanvasSyncAgent({
|
|
212
|
-
slug: 'screen',
|
|
213
|
-
doc: docB,
|
|
214
|
-
paths: paths(),
|
|
215
|
-
echoGuard: createEchoGuard(),
|
|
216
|
-
flushMs: 0,
|
|
217
|
-
onConflict: () => {
|
|
218
|
-
conflicts++;
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
agent.start();
|
|
222
|
-
await agent.reconcile();
|
|
223
|
-
|
|
224
|
-
// The local body MUST survive — an empty hub must never empty a real canvas.
|
|
225
|
-
expect(readFileSync(paths().html, 'utf8')).toBe('<button>real-canvas</button>');
|
|
226
|
-
// …and it is seeded UP to the hub instead of being discarded (local→doc).
|
|
227
|
-
expect(htmlFromDoc(docA)).toBe('<button>real-canvas</button>');
|
|
228
|
-
// An empty-hub seed is not a "hub overwrote your local" conflict.
|
|
229
|
-
expect(conflicts).toBe(0);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
test('identical disk + doc states: no disk write', async () => {
|
|
233
|
-
writeFileSync(paths().html, '<button>same</button>');
|
|
234
|
-
applyHtmlToDoc(docA, '<button>same</button>');
|
|
235
|
-
|
|
236
|
-
agent = makeAgent();
|
|
237
|
-
let writes = 0;
|
|
238
|
-
const customAgent = createCanvasSyncAgent({
|
|
239
|
-
slug: 'screen',
|
|
240
|
-
doc: docB,
|
|
241
|
-
paths: paths(),
|
|
242
|
-
echoGuard: createEchoGuard(),
|
|
243
|
-
flushMs: 0,
|
|
244
|
-
writer: () => {
|
|
245
|
-
writes++;
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
customAgent.start();
|
|
249
|
-
await customAgent.reconcile();
|
|
250
|
-
customAgent.stop();
|
|
251
|
-
|
|
252
|
-
expect(writes).toBe(0);
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
describe('CanvasSyncAgent — stress: 100 rapid disk writes converge with no echo loop', () => {
|
|
257
|
-
test('100-event scenario from plan validate', async () => {
|
|
258
|
-
// Wire up fs-mirror against the temp dir so this looks like the production
|
|
259
|
-
// flow: file writes → fs.watch → fs-mirror debounce → agent.applyFromFs.
|
|
260
|
-
agent = makeAgent({ flushMs: 20 });
|
|
261
|
-
|
|
262
|
-
const reader = createFsReader({
|
|
263
|
-
rootDir: dir,
|
|
264
|
-
quietMs: 15,
|
|
265
|
-
accept: (p) => p.endsWith('.html'),
|
|
266
|
-
onRead: async (evt) => {
|
|
267
|
-
agent.applyFromFs({
|
|
268
|
-
path: join(dir, evt.path),
|
|
269
|
-
bytes: evt.bytes,
|
|
270
|
-
hash: evt.hash,
|
|
271
|
-
});
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
// Track how many times the doc transitioned — should be bounded, no echo
|
|
276
|
-
// loop multiplying it.
|
|
277
|
-
let docUpdates = 0;
|
|
278
|
-
docB.on('update', () => {
|
|
279
|
-
docUpdates++;
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
for (let i = 0; i < 100; i++) {
|
|
283
|
-
writeFileSync(paths().html, `<button>${i}</button>`);
|
|
284
|
-
reader.notify('screen.html');
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Let everything settle: reader quiet (15ms), agent flush (20ms) + slack.
|
|
288
|
-
await new Promise((res) => setTimeout(res, 200));
|
|
289
|
-
await reader.flush();
|
|
290
|
-
await agent.flush();
|
|
291
|
-
reader.stop();
|
|
292
|
-
|
|
293
|
-
// Doc + disk + peer all converge on the last write.
|
|
294
|
-
const last = '<button>99</button>';
|
|
295
|
-
expect(htmlFromDoc(docB)).toBe(last);
|
|
296
|
-
expect(htmlFromDoc(docA)).toBe(last);
|
|
297
|
-
expect(readFileSync(paths().html, 'utf8')).toBe(last);
|
|
298
|
-
|
|
299
|
-
// Update count must be bounded — strictly < 100 transitions (debounce did
|
|
300
|
-
// its job) AND < 200 (no echo loop running 2x amplification).
|
|
301
|
-
expect(docUpdates).toBeLessThan(200);
|
|
302
|
-
// Also: it should be > 0 — we DID see real syncs.
|
|
303
|
-
expect(docUpdates).toBeGreaterThan(0);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
// use-annotation-resize — FigJam resize-modifier math (pure `resizeStroke`).
|
|
2
|
-
//
|
|
3
|
-
// Covers the no-modifier baseline (must stay algebraically identical to the
|
|
4
|
-
// pre-modifier corner math) plus Shift (aspect-lock / 45° snap), Alt
|
|
5
|
-
// (scale-from-center / mirror-from-midpoint), and Shift+Alt combined, across
|
|
6
|
-
// every resizable stroke kind. Pure function — no DOM render needed.
|
|
7
|
-
|
|
8
|
-
import { describe, expect, test } from 'bun:test';
|
|
9
|
-
|
|
10
|
-
import type {
|
|
11
|
-
ArrowStroke,
|
|
12
|
-
EllipseStroke,
|
|
13
|
-
PenStroke,
|
|
14
|
-
PolygonStroke,
|
|
15
|
-
RectStroke,
|
|
16
|
-
StickyStroke,
|
|
17
|
-
} from '../annotations-layer.tsx';
|
|
18
|
-
import { resizeStroke } from '../use-annotation-resize.tsx';
|
|
19
|
-
|
|
20
|
-
const rect: RectStroke = {
|
|
21
|
-
id: 'r1',
|
|
22
|
-
tool: 'rect',
|
|
23
|
-
color: '#000',
|
|
24
|
-
width: 2,
|
|
25
|
-
x: 0,
|
|
26
|
-
y: 0,
|
|
27
|
-
w: 100,
|
|
28
|
-
h: 50,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
describe('resizeStroke / rect — no modifiers (baseline)', () => {
|
|
32
|
-
test('se corner anchors the nw corner (back-compat)', () => {
|
|
33
|
-
expect(resizeStroke(rect, 'se', 120, 80)).toEqual({ x: 0, y: 0, w: 120, h: 80 });
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('nw corner anchors the se corner', () => {
|
|
37
|
-
expect(resizeStroke(rect, 'nw', -20, -10)).toEqual({ x: -20, y: -10, w: 120, h: 60 });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('dragging past the anchor flips the box (min/max parity)', () => {
|
|
41
|
-
// se dragged to the left of x=0 → box lives to the left of the anchor.
|
|
42
|
-
expect(resizeStroke(rect, 'se', -40, 80)).toEqual({ x: -40, y: 0, w: 40, h: 80 });
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe('resizeStroke / rect — Shift (aspect lock)', () => {
|
|
47
|
-
test('keeps the 2:1 start ratio, dominant axis drives scale', () => {
|
|
48
|
-
// raw 120×200 → scale = max(1.2, 4) = 4 → 400×200 (ratio preserved).
|
|
49
|
-
expect(resizeStroke(rect, 'se', 120, 200, { shift: true, alt: false })).toEqual({
|
|
50
|
-
x: 0,
|
|
51
|
-
y: 0,
|
|
52
|
-
w: 400,
|
|
53
|
-
h: 200,
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('resizeStroke / rect — Alt (scale from center)', () => {
|
|
59
|
-
test('center stays fixed; both sides grow symmetrically', () => {
|
|
60
|
-
const out = resizeStroke(rect, 'se', 120, 80, { shift: false, alt: true });
|
|
61
|
-
expect(out).toEqual({ x: -20, y: -30, w: 140, h: 110 });
|
|
62
|
-
// center invariant: (-20 + 140/2, -30 + 110/2) === (50, 25) === start center.
|
|
63
|
-
expect((out as RectStroke).x + (out as RectStroke).w / 2).toBe(50);
|
|
64
|
-
expect((out as RectStroke).y + (out as RectStroke).h / 2).toBe(25);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('resizeStroke / rect — Shift+Alt (ratio + center)', () => {
|
|
69
|
-
test('center-anchored and ratio-locked at once', () => {
|
|
70
|
-
expect(resizeStroke(rect, 'se', 120, 200, { shift: true, alt: true })).toEqual({
|
|
71
|
-
x: -300,
|
|
72
|
-
y: -150,
|
|
73
|
-
w: 700,
|
|
74
|
-
h: 350,
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('resizeStroke / polygon — routes through the shared bbox math', () => {
|
|
80
|
-
const poly: PolygonStroke = {
|
|
81
|
-
id: 'p1',
|
|
82
|
-
tool: 'polygon',
|
|
83
|
-
shape: 'diamond',
|
|
84
|
-
color: '#000',
|
|
85
|
-
width: 2,
|
|
86
|
-
x: 0,
|
|
87
|
-
y: 0,
|
|
88
|
-
w: 100,
|
|
89
|
-
h: 50,
|
|
90
|
-
};
|
|
91
|
-
test('Shift aspect-locks the polygon like a rect', () => {
|
|
92
|
-
expect(resizeStroke(poly, 'se', 120, 200, { shift: true, alt: false })).toEqual({
|
|
93
|
-
x: 0,
|
|
94
|
-
y: 0,
|
|
95
|
-
w: 400,
|
|
96
|
-
h: 200,
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('resizeStroke / sticky — always 1:1 square', () => {
|
|
102
|
-
const sticky: StickyStroke = {
|
|
103
|
-
id: 's1',
|
|
104
|
-
tool: 'sticky',
|
|
105
|
-
color: '#fce8a6',
|
|
106
|
-
x: 0,
|
|
107
|
-
y: 0,
|
|
108
|
-
w: 100,
|
|
109
|
-
h: 100,
|
|
110
|
-
text: '',
|
|
111
|
-
fontSize: 16,
|
|
112
|
-
};
|
|
113
|
-
test('no modifiers — larger axis becomes the side', () => {
|
|
114
|
-
expect(resizeStroke(sticky, 'se', 150, 120)).toEqual({ x: 0, y: 0, w: 150, h: 150 });
|
|
115
|
-
});
|
|
116
|
-
test('Alt — square grows from the center', () => {
|
|
117
|
-
expect(resizeStroke(sticky, 'se', 150, 120, { shift: false, alt: true })).toEqual({
|
|
118
|
-
x: -50,
|
|
119
|
-
y: -50,
|
|
120
|
-
w: 200,
|
|
121
|
-
h: 200,
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('resizeStroke / ellipse — Alt keeps the center fixed', () => {
|
|
127
|
-
const ell: EllipseStroke = {
|
|
128
|
-
id: 'e1',
|
|
129
|
-
tool: 'ellipse',
|
|
130
|
-
color: '#000',
|
|
131
|
-
width: 2,
|
|
132
|
-
cx: 50,
|
|
133
|
-
cy: 50,
|
|
134
|
-
rx: 40,
|
|
135
|
-
ry: 20,
|
|
136
|
-
};
|
|
137
|
-
test('center invariant under symmetric scale', () => {
|
|
138
|
-
expect(resizeStroke(ell, 'se', 120, 90, { shift: false, alt: true })).toEqual({
|
|
139
|
-
cx: 50,
|
|
140
|
-
cy: 50,
|
|
141
|
-
rx: 70,
|
|
142
|
-
ry: 40,
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
describe('resizeStroke / arrow', () => {
|
|
148
|
-
const arrow: ArrowStroke = {
|
|
149
|
-
id: 'a1',
|
|
150
|
-
tool: 'arrow',
|
|
151
|
-
color: '#000',
|
|
152
|
-
width: 2,
|
|
153
|
-
x1: 0,
|
|
154
|
-
y1: 0,
|
|
155
|
-
x2: 100,
|
|
156
|
-
y2: 0,
|
|
157
|
-
};
|
|
158
|
-
test('no modifiers — only the dragged endpoint moves', () => {
|
|
159
|
-
expect(resizeStroke(arrow, 'ep2', 100, 40)).toEqual({ x2: 100, y2: 40 });
|
|
160
|
-
});
|
|
161
|
-
test('Alt — the midpoint is pinned; the far end mirrors', () => {
|
|
162
|
-
expect(resizeStroke(arrow, 'ep2', 100, 40, { shift: false, alt: true })).toEqual({
|
|
163
|
-
x2: 100,
|
|
164
|
-
y2: 40,
|
|
165
|
-
x1: 0,
|
|
166
|
-
y1: -40,
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
test('Shift — shaft angle snaps to the nearest 45°', () => {
|
|
170
|
-
const out = resizeStroke(arrow, 'ep2', 50, 60, { shift: true, alt: false }) as ArrowStroke;
|
|
171
|
-
// Pointer at atan2(60,50)≈49° snaps to 45° → dx === dy along the shaft.
|
|
172
|
-
expect(out.x2).toBeCloseTo(out.y2 ?? Number.NaN, 6);
|
|
173
|
-
expect(out.x2).toBeGreaterThan(0);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
describe('resizeStroke / pen — point scaling', () => {
|
|
178
|
-
const pen: PenStroke = {
|
|
179
|
-
id: 'pen1',
|
|
180
|
-
tool: 'pen',
|
|
181
|
-
color: '#000',
|
|
182
|
-
width: 2,
|
|
183
|
-
points: [
|
|
184
|
-
[0, 0],
|
|
185
|
-
[100, 0],
|
|
186
|
-
[100, 100],
|
|
187
|
-
[0, 100],
|
|
188
|
-
],
|
|
189
|
-
};
|
|
190
|
-
test('no modifiers — scales around the opposite corner', () => {
|
|
191
|
-
const out = resizeStroke(pen, 'se', 200, 200) as PenStroke;
|
|
192
|
-
expect(out.points[0]).toEqual([0, 0]);
|
|
193
|
-
expect(out.points[2]).toEqual([200, 200]);
|
|
194
|
-
});
|
|
195
|
-
test('Alt — scales around the bbox center', () => {
|
|
196
|
-
const out = resizeStroke(pen, 'se', 150, 150, { shift: false, alt: true }) as PenStroke;
|
|
197
|
-
expect(out.points[0]).toEqual([-50, -50]);
|
|
198
|
-
expect(out.points[2]).toEqual([150, 150]);
|
|
199
|
-
});
|
|
200
|
-
});
|