openplanr 2.2640.8 → 2.2641.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/CHANGELOG.md +14 -0
- package/dist/dashboard/.vite/manifest.json +1 -1
- package/dist/dashboard/assets/{index-COZ36pFn.js → index-D7R6tnlX.js} +2 -2
- package/dist/dashboard/assets/{index-COZ36pFn.js.map → index-D7R6tnlX.js.map} +1 -1
- package/dist/dashboard/dashboard-manifest.json +8 -8
- package/dist/dashboard/index.html +1 -1
- package/lib/host-packages/adapter-registry.json +5 -5
- package/lib/host-packages/capability-map.json +1 -1
- package/lib/host-packages/claude/.claude-plugin/marketplace.json +2 -2
- package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +1 -1
- package/lib/host-packages/claude/openplanr/.openplanr-content.json +167 -35
- package/lib/host-packages/claude/openplanr/README.md +22 -1
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-artifact-shell.mjs +3 -11
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +555 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/{design-pako-esm.mjs → design-compression.mjs} +2 -1521
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-document.mjs +133 -12
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +647 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-entities.mjs +17 -67
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-handoff.mjs +14 -16
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/{design-planr-home.mjs → design-loopback-server.mjs} +15 -36
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-owner-custody.mjs +121 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-resource-pack.mjs +698 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review.mjs +798 -796
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-home.mjs +39 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-support-5cb7531bede8.mjs +24 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share.mjs +138 -765
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/{design-escape.mjs → design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs} +158 -156
- package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-artifact-sources.mjs → claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs} +1 -1
- package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-bounded-json-data.mjs → claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-31a760fc.mjs} +241 -454
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +222 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-upload-spool.mjs +198 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design.mjs +12 -5
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +18 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +809 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +5193 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +4175 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +65 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +1755 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +62 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +2600 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +123 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +3 -3
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +34 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +992 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +2513 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +1919 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +1759 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +1551 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +1121 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +2183 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +705 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +27 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +13 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-design-review-experience.js +3561 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-studio-shell.js +184 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +5045 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +1698 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +455 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-design-studio.js +1844 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +257 -0
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +1 -1
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +4966 -0
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design.mjs +240 -5192
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +1 -1
- package/lib/host-packages/claude/openplanr/skills/delegate/scripts/backend-diagnostics.mjs +6 -2
- package/lib/host-packages/cursor/openplanr/.openplanr-content.json +166 -34
- package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
- package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/backend-diagnostics.mjs +6 -2
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-artifact-shell.mjs +3 -11
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +555 -0
- package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-pako-esm.mjs → cursor/openplanr/runtime/design/scripts/design-compression.mjs} +2 -1521
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-document.mjs +133 -12
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +647 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-entities.mjs +17 -67
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-handoff.mjs +14 -16
- package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-planr-home.mjs → cursor/openplanr/runtime/design/scripts/design-loopback-server.mjs} +15 -36
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-owner-custody.mjs +121 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-resource-pack.mjs +698 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review.mjs +798 -796
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-home.mjs +39 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-support-5cb7531bede8.mjs +24 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share.mjs +138 -765
- package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-escape.mjs → cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs} +158 -156
- package/lib/host-packages/{claude/openplanr/runtime/design/scripts/design-artifact-sources.mjs → cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs} +1 -1
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/{design-bounded-json-data.mjs → design-shared-protocol-contracts-31a760fc.mjs} +241 -454
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +222 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-upload-spool.mjs +198 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design.mjs +12 -5
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +18 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +809 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +5193 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +4175 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +65 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +1755 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +62 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +2600 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +123 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +3 -3
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +34 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +992 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +2513 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +1919 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +1759 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +1551 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +1121 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +2183 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +705 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +27 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +13 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-design-review-experience.js +3561 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-studio-shell.js +184 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +5045 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +1698 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +455 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-design-studio.js +1844 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +257 -0
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +1 -1
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +4966 -0
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design.mjs +240 -5192
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +1 -1
- package/lib/host-packages/openai/.claude-plugin/marketplace.json +2 -2
- package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +1 -1
- package/lib/host-packages/openai/openplanr/.openplanr-content.json +166 -34
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-artifact-shell.mjs +3 -11
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +555 -0
- package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-pako-esm.mjs → openai/openplanr/runtime/design/scripts/design-compression.mjs} +2 -1521
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-document.mjs +133 -12
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +647 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-entities.mjs +17 -67
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-handoff.mjs +14 -16
- package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-planr-home.mjs → openai/openplanr/runtime/design/scripts/design-loopback-server.mjs} +15 -36
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-owner-custody.mjs +121 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-resource-pack.mjs +698 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review.mjs +798 -796
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-home.mjs +39 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-support-5cb7531bede8.mjs +24 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share.mjs +138 -765
- package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-escape.mjs → openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs} +158 -156
- package/lib/host-packages/{cursor/openplanr/runtime/design/scripts/design-artifact-sources.mjs → openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs} +1 -1
- package/lib/host-packages/{claude/openplanr/runtime/design/scripts/design-bounded-json-data.mjs → openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-31a760fc.mjs} +241 -454
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +222 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-upload-spool.mjs +198 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design.mjs +12 -5
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +18 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +809 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +5193 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +4175 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +65 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +1755 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +62 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +2600 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +123 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +3 -3
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +34 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +992 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +2513 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +1919 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +1759 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +1551 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +1121 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +2183 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +705 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +27 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +13 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-design-review-experience.js +3561 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-studio-shell.js +184 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +5045 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +1698 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +455 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-design-studio.js +1844 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +257 -0
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +1 -1
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +4966 -0
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design.mjs +240 -5192
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +1 -1
- package/lib/host-packages/openai/openplanr/skills/delegate/scripts/backend-diagnostics.mjs +6 -2
- package/package.json +2 -2
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-generated-b0798298053515fd.mjs +0 -18
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js +0 -5
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js +0 -25597
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-generated-b0798298053515fd.mjs +0 -18
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js +0 -5
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js +0 -25597
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-generated-b0798298053515fd.mjs +0 -18
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js +0 -5
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js +0 -25597
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// lib/artifact/ui/stage.mjs
|
|
4
|
+
var stage_exports = {};
|
|
5
|
+
__export(stage_exports, {
|
|
6
|
+
ARTIFACT_STAGE_EVENTS: () => ARTIFACT_STAGE_EVENTS,
|
|
7
|
+
ARTIFACT_STAGE_LIMITS: () => ARTIFACT_STAGE_LIMITS,
|
|
8
|
+
bootstrapArtifactStage: () => bootstrapArtifactStage,
|
|
9
|
+
clientPointToNormalized: () => clientPointToNormalized,
|
|
10
|
+
createArtifactStagePayload: () => createArtifactStagePayload,
|
|
11
|
+
createArtifactStageState: () => createArtifactStageState,
|
|
12
|
+
mountArtifactStage: () => mountArtifactStage,
|
|
13
|
+
normalizedPointToClient: () => normalizedPointToClient,
|
|
14
|
+
reduceArtifactStageState: () => reduceArtifactStageState,
|
|
15
|
+
resolveArtifactPresentation: () => resolveArtifactPresentation,
|
|
16
|
+
visibleArtifactIds: () => visibleArtifactIds
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// lib/artifact/ui/presentation.mjs
|
|
20
|
+
function resolveArtifactPresentation(value, {
|
|
21
|
+
mode,
|
|
22
|
+
viewMode = mode ?? "single",
|
|
23
|
+
artifactCount = 1
|
|
24
|
+
} = {}) {
|
|
25
|
+
if (value === "document" || value === "canvas") return value;
|
|
26
|
+
return artifactCount > 1 || viewMode === "variants" || viewMode === "split" ? "canvas" : "document";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// lib/artifact/ui/annotations.mjs
|
|
30
|
+
var ARTIFACT_ANNOTATION_EVENTS = Object.freeze({
|
|
31
|
+
draft: "planr:artifact-annotation-draft",
|
|
32
|
+
focus: "planr:artifact-annotation-focus"
|
|
33
|
+
});
|
|
34
|
+
var ARTIFACT_ANNOTATION_LIMITS = Object.freeze({
|
|
35
|
+
dragThreshold: 4,
|
|
36
|
+
maxCommentLength: 65536,
|
|
37
|
+
maxIdentityLength: 256
|
|
38
|
+
});
|
|
39
|
+
var INTENTS = Object.freeze(["fix", "improve", "question"]);
|
|
40
|
+
function finite(value, fallback = 0) {
|
|
41
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
42
|
+
}
|
|
43
|
+
function clamp(value, min = 0, max = 1) {
|
|
44
|
+
return Math.min(max, Math.max(min, finite(value)));
|
|
45
|
+
}
|
|
46
|
+
function normalized(value) {
|
|
47
|
+
return Math.round(clamp(value) * 1e6) / 1e6;
|
|
48
|
+
}
|
|
49
|
+
function assertRect(rect) {
|
|
50
|
+
if (!rect || !Number.isFinite(rect.left) || !Number.isFinite(rect.top) || !Number.isFinite(rect.width) || !Number.isFinite(rect.height) || rect.width <= 0 || rect.height <= 0) {
|
|
51
|
+
throw new RangeError("Artifact bounds must have positive finite dimensions.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function clientSelectionToNormalized(rect, start, end = start, { dragThreshold = ARTIFACT_ANNOTATION_LIMITS.dragThreshold } = {}) {
|
|
55
|
+
assertRect(rect);
|
|
56
|
+
const startX = clamp(
|
|
57
|
+
finite(start?.x ?? start?.clientX, rect.left),
|
|
58
|
+
rect.left,
|
|
59
|
+
rect.left + rect.width
|
|
60
|
+
);
|
|
61
|
+
const startY = clamp(
|
|
62
|
+
finite(start?.y ?? start?.clientY, rect.top),
|
|
63
|
+
rect.top,
|
|
64
|
+
rect.top + rect.height
|
|
65
|
+
);
|
|
66
|
+
const endX = clamp(finite(end?.x ?? end?.clientX, startX), rect.left, rect.left + rect.width);
|
|
67
|
+
const endY = clamp(finite(end?.y ?? end?.clientY, startY), rect.top, rect.top + rect.height);
|
|
68
|
+
const dragged = Math.hypot(endX - startX, endY - startY) >= Math.max(0, finite(dragThreshold, 4));
|
|
69
|
+
const left = dragged ? Math.min(startX, endX) : startX;
|
|
70
|
+
const top = dragged ? Math.min(startY, endY) : startY;
|
|
71
|
+
const right = dragged ? Math.max(startX, endX) : startX;
|
|
72
|
+
const bottom = dragged ? Math.max(startY, endY) : startY;
|
|
73
|
+
return Object.freeze({
|
|
74
|
+
x: normalized((left - rect.left) / rect.width),
|
|
75
|
+
y: normalized((top - rect.top) / rect.height),
|
|
76
|
+
w: normalized((right - left) / rect.width),
|
|
77
|
+
h: normalized((bottom - top) / rect.height)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function artifactAnchorPoint(region, viewport) {
|
|
81
|
+
const width = Number.isInteger(viewport?.width) && viewport.width > 0 ? viewport.width : 1;
|
|
82
|
+
const height = Number.isInteger(viewport?.height) && viewport.height > 0 ? viewport.height : 1;
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
x: Math.round(clamp(region?.x + finite(region?.w) / 2) * width),
|
|
85
|
+
y: Math.round(clamp(region?.y + finite(region?.h) / 2) * height)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function annotationStyle(region) {
|
|
89
|
+
const percent = (value) => `${Math.round(clamp(value) * 1e6) / 1e4}%`;
|
|
90
|
+
return Object.freeze({
|
|
91
|
+
left: percent(region?.x),
|
|
92
|
+
top: percent(region?.y),
|
|
93
|
+
width: percent(region?.w),
|
|
94
|
+
height: percent(region?.h)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function viewportRegionToAnchorRegion(region, viewport, anchorRect) {
|
|
98
|
+
const width = Number.isInteger(viewport?.width) && viewport.width > 0 ? viewport.width : 1;
|
|
99
|
+
const height = Number.isInteger(viewport?.height) && viewport.height > 0 ? viewport.height : 1;
|
|
100
|
+
const anchorWidth = Math.max(1, finite(anchorRect?.width, 1));
|
|
101
|
+
const anchorHeight = Math.max(1, finite(anchorRect?.height, 1));
|
|
102
|
+
const left = clamp(region?.x) * width;
|
|
103
|
+
const top = clamp(region?.y) * height;
|
|
104
|
+
const right = left + clamp(region?.w) * width;
|
|
105
|
+
const bottom = top + clamp(region?.h) * height;
|
|
106
|
+
const x = clamp((left - finite(anchorRect?.x)) / anchorWidth);
|
|
107
|
+
const y = clamp((top - finite(anchorRect?.y)) / anchorHeight);
|
|
108
|
+
return Object.freeze({
|
|
109
|
+
x: normalized(x),
|
|
110
|
+
y: normalized(y),
|
|
111
|
+
w: normalized(Math.max(0, Math.min(1 - x, (right - left) / anchorWidth))),
|
|
112
|
+
h: normalized(Math.max(0, Math.min(1 - y, (bottom - top) / anchorHeight)))
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function anchorRegionToViewportRegion(region, viewport, anchorRect) {
|
|
116
|
+
const width = Number.isInteger(viewport?.width) && viewport.width > 0 ? viewport.width : 1;
|
|
117
|
+
const height = Number.isInteger(viewport?.height) && viewport.height > 0 ? viewport.height : 1;
|
|
118
|
+
const anchorWidth = Math.max(0, finite(anchorRect?.width));
|
|
119
|
+
const anchorHeight = Math.max(0, finite(anchorRect?.height));
|
|
120
|
+
return Object.freeze({
|
|
121
|
+
x: normalized((finite(anchorRect?.x) + clamp(region?.x) * anchorWidth) / width),
|
|
122
|
+
y: normalized((finite(anchorRect?.y) + clamp(region?.y) * anchorHeight) / height),
|
|
123
|
+
w: normalized(clamp(region?.w) * anchorWidth / width),
|
|
124
|
+
h: normalized(clamp(region?.h) * anchorHeight / height)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function domToken(value) {
|
|
128
|
+
const source = String(value);
|
|
129
|
+
let token3 = "";
|
|
130
|
+
for (let index2 = 0; index2 < source.length; index2 += 1) {
|
|
131
|
+
token3 += source.charCodeAt(index2).toString(16).padStart(4, "0");
|
|
132
|
+
}
|
|
133
|
+
return token3;
|
|
134
|
+
}
|
|
135
|
+
function annotationDomIds(pinId) {
|
|
136
|
+
const suffix = domToken(pinId);
|
|
137
|
+
return Object.freeze({
|
|
138
|
+
pin: `planr-pin-${suffix}`,
|
|
139
|
+
thread: `planr-thread-${suffix}`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function text(value, max = ARTIFACT_ANNOTATION_LIMITS.maxCommentLength) {
|
|
143
|
+
return typeof value === "string" ? value.trim().slice(0, max) : "";
|
|
144
|
+
}
|
|
145
|
+
function make(document2, tag, { className, textContent, attributes = {} } = {}) {
|
|
146
|
+
const node2 = document2.createElement(tag);
|
|
147
|
+
if (className) node2.className = className;
|
|
148
|
+
if (textContent !== void 0) node2.textContent = textContent;
|
|
149
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
150
|
+
if (value !== void 0 && value !== null) node2.setAttribute(name, String(value));
|
|
151
|
+
}
|
|
152
|
+
return node2;
|
|
153
|
+
}
|
|
154
|
+
function setRegionStyle(node2, region) {
|
|
155
|
+
const style = annotationStyle(region);
|
|
156
|
+
if (node2.style.left !== style.left) node2.style.left = style.left;
|
|
157
|
+
if (node2.style.top !== style.top) node2.style.top = style.top;
|
|
158
|
+
if (region.w > 0 || region.h > 0) {
|
|
159
|
+
if (node2.style.width !== style.width) node2.style.width = style.width;
|
|
160
|
+
if (node2.style.height !== style.height) node2.style.height = style.height;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function announce(document2, value) {
|
|
164
|
+
const node2 = document2.querySelector('[data-planr-slot="review-announcer"]');
|
|
165
|
+
if (node2) node2.textContent = value;
|
|
166
|
+
}
|
|
167
|
+
function identityName(reviewController) {
|
|
168
|
+
return text(
|
|
169
|
+
reviewController?.getIdentity?.()?.name,
|
|
170
|
+
ARTIFACT_ANNOTATION_LIMITS.maxIdentityLength
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
function createIntentPicker(document2) {
|
|
174
|
+
const group = make(document2, "div", {
|
|
175
|
+
className: "planr-intent-picker",
|
|
176
|
+
attributes: { role: "radiogroup", "aria-label": "Feedback intent" }
|
|
177
|
+
});
|
|
178
|
+
for (const [index2, intent] of INTENTS.entries()) {
|
|
179
|
+
const button = make(document2, "button", {
|
|
180
|
+
textContent: intent[0].toUpperCase() + intent.slice(1),
|
|
181
|
+
attributes: {
|
|
182
|
+
type: "button",
|
|
183
|
+
role: "radio",
|
|
184
|
+
"aria-checked": String(index2 === 0),
|
|
185
|
+
tabindex: index2 === 0 ? 0 : -1,
|
|
186
|
+
"data-planr-intent": intent
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
group.append(button);
|
|
190
|
+
}
|
|
191
|
+
return group;
|
|
192
|
+
}
|
|
193
|
+
function mountArtifactAnnotations({
|
|
194
|
+
document: document2 = globalThis.document,
|
|
195
|
+
window = document2?.defaultView,
|
|
196
|
+
root = document2?.querySelector?.(".planr-shell"),
|
|
197
|
+
stageController,
|
|
198
|
+
reviewController,
|
|
199
|
+
onFocusPin
|
|
200
|
+
} = {}) {
|
|
201
|
+
if (!document2 || !window || !root || !stageController || !reviewController) return null;
|
|
202
|
+
const cleanup = [];
|
|
203
|
+
let draft = null;
|
|
204
|
+
let suspendedDraft = null;
|
|
205
|
+
let draftToken = 0;
|
|
206
|
+
let draftFieldCleanup = null;
|
|
207
|
+
let composerLayoutCleanup = null;
|
|
208
|
+
let composerReturnFocus = null;
|
|
209
|
+
const pinRecords = /* @__PURE__ */ new Map();
|
|
210
|
+
const anchorRequests = /* @__PURE__ */ new Map();
|
|
211
|
+
let destroyed = false;
|
|
212
|
+
function listen(target, type, handler, options) {
|
|
213
|
+
target.addEventListener(type, handler, options);
|
|
214
|
+
cleanup.push(() => target.removeEventListener(type, handler, options));
|
|
215
|
+
}
|
|
216
|
+
function review() {
|
|
217
|
+
return reviewController.getReview?.() ?? reviewController.getState?.()?.review ?? reviewController.getState?.();
|
|
218
|
+
}
|
|
219
|
+
function layerFor(artifactId) {
|
|
220
|
+
return [...document2.querySelectorAll("[data-planr-annotation-layer]")].find(
|
|
221
|
+
(node2) => node2.dataset.planrAnnotationLayer === artifactId
|
|
222
|
+
) ?? null;
|
|
223
|
+
}
|
|
224
|
+
function frameFor(artifactId) {
|
|
225
|
+
return [...document2.querySelectorAll("[data-planr-artifact-frame]")].find(
|
|
226
|
+
(node2) => node2.dataset.planrArtifactFrame === artifactId
|
|
227
|
+
) ?? null;
|
|
228
|
+
}
|
|
229
|
+
function focusThread(pinId) {
|
|
230
|
+
const pin = review()?.pins?.find((item2) => item2.id === pinId);
|
|
231
|
+
if (!pin) return;
|
|
232
|
+
reviewController.selectPin?.(pinId);
|
|
233
|
+
const state = stageController.getState();
|
|
234
|
+
if (state.activeArtifactId !== pin.artifactId) {
|
|
235
|
+
stageController.dispatch({ type: "set-active", artifactId: pin.artifactId });
|
|
236
|
+
}
|
|
237
|
+
stageController.dispatch({ type: "set-rail-open", railOpen: true });
|
|
238
|
+
queueMicrotask(() => document2.getElementById(annotationDomIds(pinId).thread)?.focus());
|
|
239
|
+
}
|
|
240
|
+
function focusPin(pinId) {
|
|
241
|
+
const pin = review()?.pins?.find((item2) => item2.id === pinId);
|
|
242
|
+
if (!pin) return;
|
|
243
|
+
reviewController.selectPin?.(pinId);
|
|
244
|
+
const state = stageController.getState();
|
|
245
|
+
if (state.activeArtifactId !== pin.artifactId) {
|
|
246
|
+
stageController.dispatch({ type: "set-active", artifactId: pin.artifactId });
|
|
247
|
+
}
|
|
248
|
+
queueMicrotask(() => {
|
|
249
|
+
const marker = document2.getElementById(annotationDomIds(pinId).pin);
|
|
250
|
+
if (marker?.hidden) {
|
|
251
|
+
announce(
|
|
252
|
+
document2,
|
|
253
|
+
"This pin’s element is not currently visible. The original comment remains in Review."
|
|
254
|
+
);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (onFocusPin) onFocusPin(pin);
|
|
258
|
+
else marker?.scrollIntoView?.({ block: "center", inline: "center", behavior: "smooth" });
|
|
259
|
+
marker?.focus?.({ preventScroll: true });
|
|
260
|
+
marker?.classList.add("planr-pin-highlight");
|
|
261
|
+
window.setTimeout(() => marker?.classList.remove("planr-pin-highlight"), 1200);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function pinGeometryKey(pin) {
|
|
265
|
+
return JSON.stringify([
|
|
266
|
+
reviewController.getReviewOf?.() ?? review()?.reviewOf,
|
|
267
|
+
pin.artifactId,
|
|
268
|
+
pin.anchor,
|
|
269
|
+
pin.region,
|
|
270
|
+
pin.viewport
|
|
271
|
+
]);
|
|
272
|
+
}
|
|
273
|
+
function setPinPosition(record2, region) {
|
|
274
|
+
const point2 = { x: region.x + region.w / 2, y: region.y + region.h / 2, w: 0, h: 0 };
|
|
275
|
+
setRegionStyle(record2.button, point2);
|
|
276
|
+
if (record2.region) setRegionStyle(record2.region, region);
|
|
277
|
+
if (record2.button.hidden) record2.button.hidden = false;
|
|
278
|
+
if (record2.region?.hidden) record2.region.hidden = false;
|
|
279
|
+
}
|
|
280
|
+
function hidePin(record2) {
|
|
281
|
+
if (!record2.button.hidden) record2.button.hidden = true;
|
|
282
|
+
if (record2.region && !record2.region.hidden) record2.region.hidden = true;
|
|
283
|
+
}
|
|
284
|
+
function removePin(record2) {
|
|
285
|
+
record2.pending = null;
|
|
286
|
+
record2.button.remove();
|
|
287
|
+
record2.region?.remove();
|
|
288
|
+
}
|
|
289
|
+
function refreshAnchors() {
|
|
290
|
+
if (destroyed) return;
|
|
291
|
+
const now = window.performance.now();
|
|
292
|
+
const frames = new Map(
|
|
293
|
+
[...document2.querySelectorAll("[data-planr-artifact-frame]")].map((frame) => [
|
|
294
|
+
frame.dataset.planrArtifactFrame,
|
|
295
|
+
frame
|
|
296
|
+
])
|
|
297
|
+
);
|
|
298
|
+
const records = [...pinRecords.values()].flatMap((records2) => [...records2.values()]).filter((record2) => record2.pin.anchor?.planrId).sort((a, b) => a.requestedAt - b.requestedAt);
|
|
299
|
+
for (const record2 of records) {
|
|
300
|
+
if (record2.pending || now - record2.requestedAt < 200 || !record2.button.isConnected) continue;
|
|
301
|
+
const frame = frames.get(record2.pin.artifactId);
|
|
302
|
+
const bridge = frame?.__openPlanrBridge;
|
|
303
|
+
if (!bridge?.resolve || frame.closest("[hidden]") || frame.dataset.planrBridgeTrusted === "false" || (anchorRequests.get(frame) ?? 0) >= 8)
|
|
304
|
+
continue;
|
|
305
|
+
const request = {}, key = record2.geometryKey, pin = record2.pin;
|
|
306
|
+
record2.pending = request;
|
|
307
|
+
record2.requestedAt = now;
|
|
308
|
+
anchorRequests.set(frame, (anchorRequests.get(frame) ?? 0) + 1);
|
|
309
|
+
Promise.resolve().then(() => bridge.resolve(pin.anchor.planrId, pin.anchor.screen)).then((anchor2) => {
|
|
310
|
+
if (destroyed || record2.pending !== request || record2.geometryKey !== key || !record2.button.isConnected || frame.__openPlanrBridge !== bridge)
|
|
311
|
+
return;
|
|
312
|
+
if (!anchor2 || anchor2.rect.width <= 0 || anchor2.rect.height <= 0) {
|
|
313
|
+
hidePin(record2);
|
|
314
|
+
if (record2.button.dataset.planrAnchorStatus !== "unavailable")
|
|
315
|
+
record2.button.dataset.planrAnchorStatus = "unavailable";
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const projected = anchorRegionToViewportRegion(
|
|
319
|
+
pin.region,
|
|
320
|
+
anchor2.viewport ?? pin.viewport,
|
|
321
|
+
anchor2.rect
|
|
322
|
+
);
|
|
323
|
+
setPinPosition(record2, projected);
|
|
324
|
+
if (record2.button.dataset.planrAnchorStatus !== "resolved")
|
|
325
|
+
record2.button.dataset.planrAnchorStatus = "resolved";
|
|
326
|
+
}).catch(() => {
|
|
327
|
+
}).finally(() => {
|
|
328
|
+
const remaining = (anchorRequests.get(frame) ?? 1) - 1;
|
|
329
|
+
if (remaining > 0) anchorRequests.set(frame, remaining);
|
|
330
|
+
else anchorRequests.delete(frame);
|
|
331
|
+
if (record2.pending === request) record2.pending = null;
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function renderPins() {
|
|
336
|
+
if (destroyed) return;
|
|
337
|
+
const pins = Array.isArray(review()?.pins) ? review().pins : [];
|
|
338
|
+
const layers = new Set(document2.querySelectorAll("[data-planr-annotation-layer]"));
|
|
339
|
+
for (const [layer, records] of pinRecords) {
|
|
340
|
+
if (layers.has(layer)) continue;
|
|
341
|
+
for (const record2 of records.values()) removePin(record2);
|
|
342
|
+
pinRecords.delete(layer);
|
|
343
|
+
}
|
|
344
|
+
for (const layer of layers) {
|
|
345
|
+
let records = pinRecords.get(layer);
|
|
346
|
+
if (!records) {
|
|
347
|
+
records = /* @__PURE__ */ new Map();
|
|
348
|
+
pinRecords.set(layer, records);
|
|
349
|
+
}
|
|
350
|
+
const current = /* @__PURE__ */ new Set();
|
|
351
|
+
for (const [index2, pin] of pins.entries()) {
|
|
352
|
+
if (pin.artifactId !== layer.dataset.planrAnnotationLayer) continue;
|
|
353
|
+
current.add(pin.id);
|
|
354
|
+
const ids2 = annotationDomIds(pin.id), ordinal = index2 + 1;
|
|
355
|
+
const hasRegion = pin.region.w > 0 || pin.region.h > 0;
|
|
356
|
+
let record2 = records.get(pin.id);
|
|
357
|
+
if (!record2) {
|
|
358
|
+
const button = make(document2, "button", {
|
|
359
|
+
attributes: {
|
|
360
|
+
type: "button",
|
|
361
|
+
id: ids2.pin,
|
|
362
|
+
"data-planr-pin-id": pin.id,
|
|
363
|
+
"aria-controls": ids2.thread
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
button.addEventListener("click", () => focusThread(pin.id));
|
|
367
|
+
layer.append(button);
|
|
368
|
+
record2 = {
|
|
369
|
+
button,
|
|
370
|
+
region: null,
|
|
371
|
+
pin,
|
|
372
|
+
geometryKey: null,
|
|
373
|
+
pending: null,
|
|
374
|
+
requestedAt: -Infinity
|
|
375
|
+
};
|
|
376
|
+
records.set(pin.id, record2);
|
|
377
|
+
}
|
|
378
|
+
record2.pin = pin;
|
|
379
|
+
if (hasRegion && !record2.region) {
|
|
380
|
+
record2.region = make(document2, "span", {
|
|
381
|
+
attributes: { "data-planr-pin-region-id": pin.id, "aria-hidden": "true" }
|
|
382
|
+
});
|
|
383
|
+
layer.insertBefore(record2.region, record2.button);
|
|
384
|
+
} else if (!hasRegion && record2.region) {
|
|
385
|
+
record2.region.remove();
|
|
386
|
+
record2.region = null;
|
|
387
|
+
}
|
|
388
|
+
const buttonClass = `planr-pin planr-pin-${pin.intent} planr-pin-${pin.status}${hasRegion ? " planr-pin-region-handle" : ""}${record2.button.classList.contains("planr-pin-highlight") ? " planr-pin-highlight" : ""}`;
|
|
389
|
+
if (record2.button.className !== buttonClass) record2.button.className = buttonClass;
|
|
390
|
+
if (record2.button.textContent !== String(ordinal))
|
|
391
|
+
record2.button.textContent = String(ordinal);
|
|
392
|
+
for (const [name, value] of Object.entries({
|
|
393
|
+
"data-planr-intent": pin.intent,
|
|
394
|
+
"data-planr-status": pin.status,
|
|
395
|
+
"aria-label": `${pin.intent} comment ${ordinal}: ${pin.comment}`
|
|
396
|
+
})) {
|
|
397
|
+
if (record2.button.getAttribute(name) !== value) record2.button.setAttribute(name, value);
|
|
398
|
+
}
|
|
399
|
+
if (record2.region) {
|
|
400
|
+
const regionClass = `planr-pin-region planr-pin-region-${pin.intent} planr-pin-region-${pin.status}`;
|
|
401
|
+
if (record2.region.className !== regionClass) record2.region.className = regionClass;
|
|
402
|
+
}
|
|
403
|
+
const key = pinGeometryKey(pin);
|
|
404
|
+
if (record2.geometryKey !== key) {
|
|
405
|
+
record2.geometryKey = key;
|
|
406
|
+
record2.pending = null;
|
|
407
|
+
record2.requestedAt = -Infinity;
|
|
408
|
+
if (pin.anchor?.planrId) hidePin(record2);
|
|
409
|
+
else {
|
|
410
|
+
delete record2.button.dataset.planrAnchorStatus;
|
|
411
|
+
setPinPosition(record2, pin.region);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
for (const [id7, record2] of records) {
|
|
416
|
+
if (!current.has(id7)) {
|
|
417
|
+
removePin(record2);
|
|
418
|
+
records.delete(id7);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
refreshAnchors();
|
|
423
|
+
}
|
|
424
|
+
function closeComposer({ restoreFocus = false, preserveDraft = false } = {}) {
|
|
425
|
+
const snapshot2 = preserveDraft ? snapshotDraft() : null;
|
|
426
|
+
draftFieldCleanup?.();
|
|
427
|
+
draftFieldCleanup = null;
|
|
428
|
+
composerLayoutCleanup?.();
|
|
429
|
+
composerLayoutCleanup = null;
|
|
430
|
+
const activeLayer = draft ? layerFor(draft.artifactId) : null;
|
|
431
|
+
const composer = root.querySelector("[data-planr-annotation-composer]");
|
|
432
|
+
try {
|
|
433
|
+
if (composer?.matches(":popover-open")) composer.hidePopover();
|
|
434
|
+
} catch {
|
|
435
|
+
}
|
|
436
|
+
composer?.remove();
|
|
437
|
+
draft = null;
|
|
438
|
+
suspendedDraft = snapshot2;
|
|
439
|
+
draftToken += 1;
|
|
440
|
+
if (activeLayer && stageController.getState().reviewMode !== "comment") {
|
|
441
|
+
activeLayer.setAttribute("aria-disabled", "true");
|
|
442
|
+
}
|
|
443
|
+
if (restoreFocus) {
|
|
444
|
+
const target = composerReturnFocus?.isConnected && composerReturnFocus !== document2.body ? composerReturnFocus : activeLayer;
|
|
445
|
+
target?.focus?.({ preventScroll: true });
|
|
446
|
+
}
|
|
447
|
+
composerReturnFocus = null;
|
|
448
|
+
}
|
|
449
|
+
async function resolveAnchor(token3, candidate) {
|
|
450
|
+
const frame = frameFor(candidate.artifactId);
|
|
451
|
+
const point2 = artifactAnchorPoint(candidate.region, candidate.viewport);
|
|
452
|
+
let result = null;
|
|
453
|
+
try {
|
|
454
|
+
const anchor2 = frame?.__openPlanrBridge?.hitTest?.(point2.x, point2.y);
|
|
455
|
+
if (anchor2) {
|
|
456
|
+
result = await Promise.race([
|
|
457
|
+
anchor2,
|
|
458
|
+
new Promise((resolve) => window.setTimeout(() => resolve(null), 800))
|
|
459
|
+
]);
|
|
460
|
+
}
|
|
461
|
+
} catch {
|
|
462
|
+
result = null;
|
|
463
|
+
}
|
|
464
|
+
if (token3 !== draftToken || !draft || draft.artifactId !== candidate.artifactId) return;
|
|
465
|
+
if (result?.planrId) {
|
|
466
|
+
draft.anchor = Object.freeze({
|
|
467
|
+
planrId: String(result.planrId).slice(0, 512),
|
|
468
|
+
...result.screen ? { screen: String(result.screen).slice(0, 128) } : {}
|
|
469
|
+
});
|
|
470
|
+
draft.region = viewportRegionToAnchorRegion(draft.region, draft.viewport, result.rect);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function positionComposer() {
|
|
474
|
+
const composer = root.querySelector("[data-planr-annotation-composer]");
|
|
475
|
+
const layer = draft && layerFor(draft.artifactId);
|
|
476
|
+
if (!composer || !layer) return;
|
|
477
|
+
const visual = window.visualViewport;
|
|
478
|
+
const viewport = {
|
|
479
|
+
x: finite(visual?.offsetLeft),
|
|
480
|
+
y: finite(visual?.offsetTop),
|
|
481
|
+
width: finite(visual?.width, window.innerWidth),
|
|
482
|
+
height: finite(visual?.height, window.innerHeight)
|
|
483
|
+
};
|
|
484
|
+
const margin = Math.min(12, viewport.width / 8, viewport.height / 8);
|
|
485
|
+
const availableWidth = Math.max(1, viewport.width - margin * 2), availableHeight = Math.max(1, viewport.height - margin * 2);
|
|
486
|
+
composer.style.width = `${Math.min(360, availableWidth)}px`;
|
|
487
|
+
composer.style.maxHeight = `${Math.min(620, availableHeight)}px`;
|
|
488
|
+
const bounds2 = layer.getBoundingClientRect();
|
|
489
|
+
const point2 = {
|
|
490
|
+
x: bounds2.left + clamp(draft.displayRegion.x + draft.displayRegion.w / 2) * bounds2.width,
|
|
491
|
+
y: bounds2.top + clamp(draft.displayRegion.y + draft.displayRegion.h / 2) * bounds2.height
|
|
492
|
+
};
|
|
493
|
+
const size = composer.getBoundingClientRect();
|
|
494
|
+
const width = Math.min(size.width || 360, availableWidth), height = Math.min(size.height || 360, availableHeight);
|
|
495
|
+
const left = point2.x + 16 + width <= viewport.x + viewport.width - margin ? point2.x + 16 : point2.x - width - 16;
|
|
496
|
+
composer.style.left = `${clamp(left, viewport.x + margin, viewport.x + viewport.width - width - margin)}px`;
|
|
497
|
+
composer.style.top = `${clamp(point2.y + 16, viewport.y + margin, viewport.y + viewport.height - height - margin)}px`;
|
|
498
|
+
}
|
|
499
|
+
function openComposer(detail, { restoredDraft = null } = {}) {
|
|
500
|
+
const opener = document2.activeElement;
|
|
501
|
+
closeComposer();
|
|
502
|
+
composerReturnFocus = opener;
|
|
503
|
+
const layer = layerFor(detail.artifactId);
|
|
504
|
+
if (!layer) return;
|
|
505
|
+
draftToken += 1;
|
|
506
|
+
const token3 = draftToken;
|
|
507
|
+
draft = {
|
|
508
|
+
artifactId: detail.artifactId,
|
|
509
|
+
region: Object.freeze({ ...detail.region }),
|
|
510
|
+
viewport: Object.freeze({ ...detail.viewport }),
|
|
511
|
+
variant: typeof detail.variant === "string" && detail.variant.length > 0 ? detail.variant : detail.artifactId,
|
|
512
|
+
anchor: restoredDraft?.anchor ?? null,
|
|
513
|
+
displayRegion: Object.freeze({ ...restoredDraft?.displayRegion ?? detail.region })
|
|
514
|
+
};
|
|
515
|
+
const composer = make(document2, "form", {
|
|
516
|
+
className: "planr-annotation-composer",
|
|
517
|
+
attributes: {
|
|
518
|
+
"data-planr-annotation-composer": "",
|
|
519
|
+
role: "dialog",
|
|
520
|
+
popover: "manual",
|
|
521
|
+
"aria-label": "Add artifact comment"
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
const header = make(document2, "header", { className: "planr-composer-header" });
|
|
525
|
+
const heading = make(document2, "strong", { textContent: "New comment" });
|
|
526
|
+
const close = make(document2, "button", {
|
|
527
|
+
textContent: "×",
|
|
528
|
+
attributes: {
|
|
529
|
+
type: "button",
|
|
530
|
+
"data-planr-composer-close": "",
|
|
531
|
+
"aria-label": "Close new comment",
|
|
532
|
+
title: "Close new comment (Escape)"
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
header.append(heading, close);
|
|
536
|
+
const identityLabel = make(document2, "label", { textContent: "Your name" });
|
|
537
|
+
const identity = make(document2, "input", {
|
|
538
|
+
attributes: {
|
|
539
|
+
type: "text",
|
|
540
|
+
maxlength: ARTIFACT_ANNOTATION_LIMITS.maxIdentityLength,
|
|
541
|
+
autocomplete: "name",
|
|
542
|
+
value: identityName(reviewController),
|
|
543
|
+
"data-planr-composer-identity": "",
|
|
544
|
+
"aria-describedby": "planr-composer-error"
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
identityLabel.append(identity);
|
|
548
|
+
const intentPicker = createIntentPicker(document2);
|
|
549
|
+
const commentLabel = make(document2, "label", { textContent: "Comment" });
|
|
550
|
+
const comment = make(document2, "textarea", {
|
|
551
|
+
attributes: {
|
|
552
|
+
maxlength: ARTIFACT_ANNOTATION_LIMITS.maxCommentLength,
|
|
553
|
+
required: "",
|
|
554
|
+
placeholder: "Describe what the coding agent should change or consider…",
|
|
555
|
+
"data-planr-composer-comment": "",
|
|
556
|
+
"aria-describedby": "planr-composer-error"
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
commentLabel.append(comment);
|
|
560
|
+
const error = make(document2, "p", {
|
|
561
|
+
className: "planr-field-error",
|
|
562
|
+
attributes: { id: "planr-composer-error", role: "alert", "data-planr-composer-error": "" }
|
|
563
|
+
});
|
|
564
|
+
const actions = make(document2, "div", { className: "planr-composer-actions" });
|
|
565
|
+
actions.append(
|
|
566
|
+
make(document2, "button", {
|
|
567
|
+
textContent: "Cancel",
|
|
568
|
+
attributes: { type: "button", "data-planr-composer-cancel": "" }
|
|
569
|
+
}),
|
|
570
|
+
make(document2, "button", {
|
|
571
|
+
textContent: "Add comment",
|
|
572
|
+
attributes: { type: "submit", "data-planr-composer-submit": "" }
|
|
573
|
+
})
|
|
574
|
+
);
|
|
575
|
+
composer.append(header, identityLabel, intentPicker, commentLabel, error, actions);
|
|
576
|
+
root.append(composer);
|
|
577
|
+
try {
|
|
578
|
+
if (typeof composer.showPopover === "function") composer.showPopover();
|
|
579
|
+
else composer.removeAttribute("popover");
|
|
580
|
+
} catch {
|
|
581
|
+
composer.removeAttribute("popover");
|
|
582
|
+
}
|
|
583
|
+
positionComposer();
|
|
584
|
+
const observer = typeof window.ResizeObserver === "function" ? new window.ResizeObserver(positionComposer) : null;
|
|
585
|
+
observer?.observe(composer);
|
|
586
|
+
composerLayoutCleanup = () => observer?.disconnect();
|
|
587
|
+
let selectedIntent = "fix";
|
|
588
|
+
listen(intentPicker, "click", (event) => {
|
|
589
|
+
const button = event.target.closest?.("[data-planr-intent]");
|
|
590
|
+
if (!button || !INTENTS.includes(button.dataset.planrIntent)) return;
|
|
591
|
+
selectedIntent = button.dataset.planrIntent;
|
|
592
|
+
for (const option of intentPicker.querySelectorAll("[data-planr-intent]")) {
|
|
593
|
+
option.setAttribute("aria-checked", String(option === button));
|
|
594
|
+
option.tabIndex = option === button ? 0 : -1;
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
listen(intentPicker, "keydown", (event) => {
|
|
598
|
+
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"].includes(event.key))
|
|
599
|
+
return;
|
|
600
|
+
const options = [...intentPicker.querySelectorAll("[data-planr-intent]")];
|
|
601
|
+
const current = options.findIndex((option) => option.getAttribute("aria-checked") === "true");
|
|
602
|
+
const delta = ["ArrowRight", "ArrowDown"].includes(event.key) ? 1 : -1;
|
|
603
|
+
const nextIndex = event.key === "Home" ? 0 : event.key === "End" ? options.length - 1 : (Math.max(0, current) + delta + options.length) % options.length;
|
|
604
|
+
event.preventDefault();
|
|
605
|
+
options[nextIndex].click();
|
|
606
|
+
options[nextIndex].focus();
|
|
607
|
+
});
|
|
608
|
+
listen(close, "click", () => closeComposer({ restoreFocus: true }));
|
|
609
|
+
listen(
|
|
610
|
+
composer.querySelector("[data-planr-composer-cancel]"),
|
|
611
|
+
"click",
|
|
612
|
+
() => {
|
|
613
|
+
closeComposer({ restoreFocus: true });
|
|
614
|
+
},
|
|
615
|
+
{ once: true }
|
|
616
|
+
);
|
|
617
|
+
listen(composer, "keydown", (event) => {
|
|
618
|
+
if (event.key === "Escape") {
|
|
619
|
+
event.preventDefault();
|
|
620
|
+
event.stopPropagation();
|
|
621
|
+
closeComposer({ restoreFocus: true });
|
|
622
|
+
} else if (event.key === "Enter" && !event.isComposing && (event.metaKey || event.ctrlKey)) {
|
|
623
|
+
event.preventDefault();
|
|
624
|
+
composer.requestSubmit();
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
listen(composer, "submit", (event) => {
|
|
628
|
+
event.preventDefault();
|
|
629
|
+
if (!draft) return;
|
|
630
|
+
const author = text(identity.value, ARTIFACT_ANNOTATION_LIMITS.maxIdentityLength);
|
|
631
|
+
const body = text(comment.value);
|
|
632
|
+
identity.setAttribute("aria-invalid", String(!author));
|
|
633
|
+
comment.setAttribute("aria-invalid", String(!body));
|
|
634
|
+
if (!author || !body) {
|
|
635
|
+
error.textContent = !author ? "Enter your name before adding a comment." : "Enter a comment before submitting.";
|
|
636
|
+
(!author ? identity : comment).focus();
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
reviewController.setIdentity?.({ name: author });
|
|
640
|
+
const existingIds = new Set(review()?.pins?.map(({ id: id7 }) => id7) ?? []);
|
|
641
|
+
const action = {
|
|
642
|
+
type: "add-pin",
|
|
643
|
+
pin: {
|
|
644
|
+
artifactId: draft.artifactId,
|
|
645
|
+
region: draft.region,
|
|
646
|
+
viewport: draft.viewport,
|
|
647
|
+
variant: draft.variant,
|
|
648
|
+
...draft.anchor ? { anchor: draft.anchor } : {},
|
|
649
|
+
intent: selectedIntent,
|
|
650
|
+
comment: body
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
const next = reviewController.dispatch(action);
|
|
654
|
+
const nextReview = next?.review ?? next;
|
|
655
|
+
const created = nextReview?.pins?.find?.(({ id: id7 }) => !existingIds.has(id7));
|
|
656
|
+
closeComposer();
|
|
657
|
+
renderPins();
|
|
658
|
+
announce(document2, `${selectedIntent} comment added.`);
|
|
659
|
+
if (created?.id) queueMicrotask(() => focusThread(created.id));
|
|
660
|
+
});
|
|
661
|
+
comment.focus();
|
|
662
|
+
root.dispatchEvent(
|
|
663
|
+
new window.CustomEvent(ARTIFACT_ANNOTATION_EVENTS.draft, {
|
|
664
|
+
bubbles: true,
|
|
665
|
+
detail: Object.freeze({ ...draft })
|
|
666
|
+
})
|
|
667
|
+
);
|
|
668
|
+
if (restoredDraft) {
|
|
669
|
+
identity.value = restoredDraft.identity;
|
|
670
|
+
comment.value = restoredDraft.comment;
|
|
671
|
+
selectedIntent = restoredDraft.intent;
|
|
672
|
+
for (const option of intentPicker.querySelectorAll("[data-planr-intent]")) {
|
|
673
|
+
const selected = option.dataset.planrIntent === selectedIntent;
|
|
674
|
+
option.setAttribute("aria-checked", String(selected));
|
|
675
|
+
option.tabIndex = selected ? 0 : -1;
|
|
676
|
+
}
|
|
677
|
+
if (Number.isInteger(restoredDraft.selectionStart))
|
|
678
|
+
comment.setSelectionRange(
|
|
679
|
+
restoredDraft.selectionStart,
|
|
680
|
+
restoredDraft.selectionEnd,
|
|
681
|
+
restoredDraft.selectionDirection
|
|
682
|
+
);
|
|
683
|
+
const fields = new Map(
|
|
684
|
+
Object.entries(restoredDraft.fields ?? {}).slice(0, 32).filter(
|
|
685
|
+
([key, value]) => key.length <= 128 && typeof value === "string" && value.length <= ARTIFACT_ANNOTATION_LIMITS.maxCommentLength
|
|
686
|
+
)
|
|
687
|
+
);
|
|
688
|
+
if (fields.size) {
|
|
689
|
+
let restoreFields = function() {
|
|
690
|
+
if (token3 !== draftToken || !composer.isConnected) {
|
|
691
|
+
finish();
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
for (const field of composer.querySelectorAll("[data-planr-draft-key]")) {
|
|
695
|
+
const key = field.dataset.planrDraftKey;
|
|
696
|
+
if (!fields.has(key) || typeof field.value !== "string") continue;
|
|
697
|
+
field.value = fields.get(key);
|
|
698
|
+
fields.delete(key);
|
|
699
|
+
field.dispatchEvent(new window.Event("change", { bubbles: true }));
|
|
700
|
+
}
|
|
701
|
+
if (!fields.size) finish();
|
|
702
|
+
};
|
|
703
|
+
let timer;
|
|
704
|
+
const observer2 = new window.MutationObserver(restoreFields);
|
|
705
|
+
const finish = () => {
|
|
706
|
+
observer2.disconnect();
|
|
707
|
+
window.clearTimeout(timer);
|
|
708
|
+
};
|
|
709
|
+
observer2.observe(composer, { childList: true, subtree: true });
|
|
710
|
+
timer = window.setTimeout(finish, 1500);
|
|
711
|
+
draftFieldCleanup = finish;
|
|
712
|
+
restoreFields();
|
|
713
|
+
}
|
|
714
|
+
} else void resolveAnchor(token3, draft);
|
|
715
|
+
}
|
|
716
|
+
function snapshotDraft() {
|
|
717
|
+
const composer = document2.querySelector("[data-planr-annotation-composer]");
|
|
718
|
+
if (!draft || !composer) return suspendedDraft;
|
|
719
|
+
const comment = composer.querySelector("[data-planr-composer-comment]");
|
|
720
|
+
return Object.freeze({
|
|
721
|
+
...draft,
|
|
722
|
+
reviewOf: reviewController.getReviewOf?.() ?? review()?.reviewOf ?? null,
|
|
723
|
+
identity: composer.querySelector("[data-planr-composer-identity]").value,
|
|
724
|
+
fields: Object.fromEntries(
|
|
725
|
+
[...composer.querySelectorAll("[data-planr-draft-key]")].slice(0, 32).filter(
|
|
726
|
+
(field) => field.dataset.planrDraftKey.length <= 128 && typeof field.value === "string"
|
|
727
|
+
).map((field) => [
|
|
728
|
+
field.dataset.planrDraftKey,
|
|
729
|
+
field.value.slice(0, ARTIFACT_ANNOTATION_LIMITS.maxCommentLength)
|
|
730
|
+
])
|
|
731
|
+
),
|
|
732
|
+
comment: comment.value,
|
|
733
|
+
intent: composer.querySelector('[data-planr-intent][aria-checked="true"]')?.dataset.planrIntent ?? "fix",
|
|
734
|
+
selectionStart: comment.selectionStart,
|
|
735
|
+
selectionEnd: comment.selectionEnd,
|
|
736
|
+
selectionDirection: comment.selectionDirection
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
function restoreDraft(snapshot2) {
|
|
740
|
+
if (!snapshot2 || snapshot2.reviewOf !== (reviewController.getReviewOf?.() ?? review()?.reviewOf ?? null))
|
|
741
|
+
return false;
|
|
742
|
+
const artifact = stageController.getState().artifacts.find((entry) => entry.id === snapshot2.artifactId);
|
|
743
|
+
if (!artifact || artifact.viewport.width !== snapshot2.viewport?.width || artifact.viewport.height !== snapshot2.viewport?.height || !["x", "y", "w", "h"].every(
|
|
744
|
+
(key) => Number.isFinite(snapshot2.region?.[key]) && snapshot2.region[key] >= 0 && snapshot2.region[key] <= 1
|
|
745
|
+
) || !["x", "y", "w", "h"].every(
|
|
746
|
+
(key) => Number.isFinite(snapshot2.displayRegion?.[key]) && snapshot2.displayRegion[key] >= 0 && snapshot2.displayRegion[key] <= 1
|
|
747
|
+
) || typeof snapshot2.comment !== "string" || snapshot2.comment.length > ARTIFACT_ANNOTATION_LIMITS.maxCommentLength || typeof snapshot2.identity !== "string" || snapshot2.identity.length > ARTIFACT_ANNOTATION_LIMITS.maxIdentityLength || !INTENTS.includes(snapshot2.intent) || snapshot2.anchor && (typeof snapshot2.anchor.planrId !== "string" || snapshot2.anchor.planrId.length > 512))
|
|
748
|
+
return false;
|
|
749
|
+
openComposer(snapshot2, { restoredDraft: snapshot2 });
|
|
750
|
+
return Boolean(draft);
|
|
751
|
+
}
|
|
752
|
+
listen(window, "resize", positionComposer);
|
|
753
|
+
if (window.visualViewport) {
|
|
754
|
+
listen(window.visualViewport, "resize", positionComposer);
|
|
755
|
+
listen(window.visualViewport, "scroll", positionComposer);
|
|
756
|
+
}
|
|
757
|
+
listen(root, "planr:artifact-region", (event) => openComposer(event.detail));
|
|
758
|
+
listen(root, "planr:stage-change", () => {
|
|
759
|
+
const state = stageController.getState();
|
|
760
|
+
const visible = state.viewMode === "split" ? [state.activeArtifactId, state.comparisonArtifactId] : [state.activeArtifactId];
|
|
761
|
+
if (!draft) {
|
|
762
|
+
if (suspendedDraft && state.status === "ready" && state.reviewMode === "comment" && visible.includes(suspendedDraft.artifactId))
|
|
763
|
+
restoreDraft(suspendedDraft);
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
if (state.status !== "ready" || state.presentation !== "document" && state.reviewMode !== "comment") {
|
|
767
|
+
closeComposer({ preserveDraft: true });
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
if (!visible.includes(draft.artifactId)) closeComposer({ preserveDraft: true });
|
|
771
|
+
else {
|
|
772
|
+
draftToken += 1;
|
|
773
|
+
positionComposer();
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
listen(root, "planr:artifact-review-change", renderPins);
|
|
777
|
+
const anchorRefresh = window.setInterval(refreshAnchors, 250);
|
|
778
|
+
cleanup.push(() => window.clearInterval(anchorRefresh));
|
|
779
|
+
listen(root, ARTIFACT_ANNOTATION_EVENTS.focus, (event) => {
|
|
780
|
+
if (event.detail?.target === "pin") focusPin(event.detail.pinId);
|
|
781
|
+
if (event.detail?.target === "thread") focusThread(event.detail.pinId);
|
|
782
|
+
});
|
|
783
|
+
listen(root, "planr:artifact-review-select", (event) => {
|
|
784
|
+
if (event.detail?.source === "thread" && typeof event.detail?.pinId === "string") {
|
|
785
|
+
focusPin(event.detail.pinId);
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
renderPins();
|
|
789
|
+
const controller = Object.freeze({
|
|
790
|
+
render: renderPins,
|
|
791
|
+
openComposer,
|
|
792
|
+
closeComposer,
|
|
793
|
+
snapshotDraft,
|
|
794
|
+
restoreDraft,
|
|
795
|
+
focusPin,
|
|
796
|
+
focusThread,
|
|
797
|
+
destroy() {
|
|
798
|
+
destroyed = true;
|
|
799
|
+
closeComposer();
|
|
800
|
+
for (const remove of cleanup.splice(0)) remove();
|
|
801
|
+
for (const records of pinRecords.values())
|
|
802
|
+
for (const record2 of records.values()) removePin(record2);
|
|
803
|
+
pinRecords.clear();
|
|
804
|
+
anchorRequests.clear();
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
window.__openPlanrArtifactAnnotations = controller;
|
|
808
|
+
return controller;
|
|
809
|
+
}
|