openplanr 3.4.0 → 3.5.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 +28 -0
- package/dist/cli/commands/design.d.ts +3 -0
- package/dist/cli/commands/design.d.ts.map +1 -0
- package/dist/cli/commands/design.js +137 -0
- package/dist/cli/commands/design.js.map +1 -0
- package/dist/cli/commands/groups/operations.d.ts.map +1 -1
- package/dist/cli/commands/groups/operations.js +2 -0
- package/dist/cli/commands/groups/operations.js.map +1 -1
- package/dist/dashboard/.vite/manifest.json +1 -1
- package/dist/dashboard/assets/{index-CvQAlBy3.js → index-B-l_941W.js} +2 -2
- package/dist/dashboard/assets/{index-CvQAlBy3.js.map → index-B-l_941W.js.map} +1 -1
- package/dist/dashboard/dashboard-manifest.json +13 -13
- package/dist/dashboard/index.html +1 -1
- package/dist/services/design-artifact-service.d.ts +22 -0
- package/dist/services/design-artifact-service.d.ts.map +1 -1
- package/dist/services/design-artifact-service.js +76 -16
- package/dist/services/design-artifact-service.js.map +1 -1
- package/dist/services/runtime-manager/runtime-package.js +1 -1
- package/dist/services/runtime-manager/runtime-package.js.map +1 -1
- package/docs/CLI.md +29 -0
- 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 +24 -340
- package/lib/host-packages/claude/openplanr/README.md +8 -8
- package/lib/host-packages/claude/openplanr/skills/artifact/references/design-sharing.md +2 -2
- package/lib/host-packages/claude/openplanr/skills/design/SKILL.md +23 -12
- package/lib/host-packages/claude/openplanr/skills/design/references/design-system.md +2 -2
- package/lib/host-packages/claude/openplanr/skills/design/references/generation.md +3 -3
- package/lib/host-packages/claude/openplanr/skills/design/references/hosted-canvas.md +6 -3
- package/lib/host-packages/claude/openplanr/skills/design/references/review.md +6 -6
- package/lib/host-packages/claude/openplanr/skills/design/references/team-review.md +3 -4
- package/lib/host-packages/claude/openplanr/skills/design/references/utilities.md +78 -38
- package/lib/host-packages/claude/openplanr/skills/design-loop/SKILL.md +15 -7
- package/lib/host-packages/claude/openplanr/skills/design-loop/references/design-system.md +2 -2
- package/lib/host-packages/claude/openplanr/skills/design-loop/references/generation.md +3 -3
- package/lib/host-packages/claude/openplanr/skills/design-loop/references/review.md +6 -6
- package/lib/host-packages/claude/openplanr/skills/design-loop/references/team-review.md +3 -4
- package/lib/host-packages/claude/openplanr/skills/design-loop/references/utilities.md +78 -38
- package/lib/host-packages/claude/openplanr/skills/design-review/SKILL.md +25 -5
- package/lib/host-packages/claude/openplanr/skills/design-review/references/design-system.md +2 -2
- package/lib/host-packages/claude/openplanr/skills/design-review/references/generation.md +3 -3
- package/lib/host-packages/claude/openplanr/skills/design-review/references/review.md +6 -6
- package/lib/host-packages/claude/openplanr/skills/design-review/references/team-review.md +3 -4
- package/lib/host-packages/claude/openplanr/skills/design-review/references/utilities.md +78 -38
- package/lib/host-packages/claude/openplanr/skills/plan/SKILL.md +7 -3
- package/lib/host-packages/cursor/openplanr/.openplanr-content.json +23 -339
- package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
- package/lib/host-packages/cursor/openplanr/rules/planr-artifact/references/design-sharing.md +2 -2
- package/lib/host-packages/cursor/openplanr/rules/planr-design/references/design-system.md +2 -2
- package/lib/host-packages/cursor/openplanr/rules/planr-design/references/generation.md +3 -3
- package/lib/host-packages/cursor/openplanr/rules/planr-design/references/hosted-canvas.md +6 -3
- package/lib/host-packages/cursor/openplanr/rules/planr-design/references/review.md +6 -6
- package/lib/host-packages/cursor/openplanr/rules/planr-design/references/team-review.md +3 -4
- package/lib/host-packages/cursor/openplanr/rules/planr-design/references/utilities.md +78 -38
- package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/design-system.md +2 -2
- package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/generation.md +3 -3
- package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/review.md +6 -6
- package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/team-review.md +3 -4
- package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/utilities.md +78 -38
- package/lib/host-packages/cursor/openplanr/rules/planr-design-loop.mdc +15 -7
- package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/design-system.md +2 -2
- package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/generation.md +3 -3
- package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/review.md +6 -6
- package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/team-review.md +3 -4
- package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/utilities.md +78 -38
- package/lib/host-packages/cursor/openplanr/rules/planr-design-review.mdc +25 -5
- package/lib/host-packages/cursor/openplanr/rules/planr-design.mdc +23 -12
- package/lib/host-packages/cursor/openplanr/rules/planr-plan.mdc +7 -3
- 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 +27 -343
- package/lib/host-packages/openai/openplanr/skills/artifact/references/design-sharing.md +2 -2
- package/lib/host-packages/openai/openplanr/skills/design/SKILL.md +23 -12
- package/lib/host-packages/openai/openplanr/skills/design/openplanr.skill.json +0 -11
- package/lib/host-packages/openai/openplanr/skills/design/references/design-system.md +2 -2
- package/lib/host-packages/openai/openplanr/skills/design/references/generation.md +3 -3
- package/lib/host-packages/openai/openplanr/skills/design/references/hosted-canvas.md +6 -3
- package/lib/host-packages/openai/openplanr/skills/design/references/review.md +6 -6
- package/lib/host-packages/openai/openplanr/skills/design/references/team-review.md +3 -4
- package/lib/host-packages/openai/openplanr/skills/design/references/utilities.md +78 -38
- package/lib/host-packages/openai/openplanr/skills/design-loop/SKILL.md +15 -7
- package/lib/host-packages/openai/openplanr/skills/design-loop/openplanr.skill.json +0 -11
- package/lib/host-packages/openai/openplanr/skills/design-loop/references/design-system.md +2 -2
- package/lib/host-packages/openai/openplanr/skills/design-loop/references/generation.md +3 -3
- package/lib/host-packages/openai/openplanr/skills/design-loop/references/review.md +6 -6
- package/lib/host-packages/openai/openplanr/skills/design-loop/references/team-review.md +3 -4
- package/lib/host-packages/openai/openplanr/skills/design-loop/references/utilities.md +78 -38
- package/lib/host-packages/openai/openplanr/skills/design-review/SKILL.md +25 -5
- package/lib/host-packages/openai/openplanr/skills/design-review/openplanr.skill.json +0 -11
- package/lib/host-packages/openai/openplanr/skills/design-review/references/design-system.md +2 -2
- package/lib/host-packages/openai/openplanr/skills/design-review/references/generation.md +3 -3
- package/lib/host-packages/openai/openplanr/skills/design-review/references/review.md +6 -6
- package/lib/host-packages/openai/openplanr/skills/design-review/references/team-review.md +3 -4
- package/lib/host-packages/openai/openplanr/skills/design-review/references/utilities.md +78 -38
- package/lib/host-packages/openai/openplanr/skills/plan/SKILL.md +7 -3
- package/lib/host-packages/openai/openplanr/skills/plan/openplanr.skill.json +0 -11
- package/package.json +2 -2
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-artifact-shell.mjs +0 -1772
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-document.mjs +0 -2937
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-entities.mjs +0 -439
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-handoff.mjs +0 -2370
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-loopback-server.mjs +0 -359
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-parse5-parser.mjs +0 -3970
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-parse5-tokenizer.mjs +0 -3501
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review-state-store.mjs +0 -45
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review.mjs +0 -3376
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -38
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-sandbox-guards.mjs +0 -1102
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +0 -321
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +0 -1652
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs +0 -1037
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +0 -137
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/design.mjs +0 -1500
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -2023
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +0 -2
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +0 -18
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +0 -814
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +0 -10
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +0 -2568
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +0 -60
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +0 -65
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/enhancements.css +0 -388
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/handoff-center.css +0 -81
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.css +0 -1
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +0 -139
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +0 -1159
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +0 -30
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +0 -900
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +0 -2261
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +0 -1595
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +0 -1467
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +0 -1860
- 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 +0 -914
- 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 +0 -2578
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +0 -582
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +0 -17
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +0 -12
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +0 -285
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +0 -2773
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-studio-shell.js +0 -134
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +0 -2207
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-design-review-experience.js +0 -16
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-studio-shell.js +0 -8
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/18-interface-primitives.js +0 -3883
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/19-interface-primitives.js +0 -966
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/20-studio-shell.js +0 -520
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +0 -1597
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +0 -311
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +0 -163
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/registries/artifact-theme.json +0 -64
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.0.0/design-manifest.schema.json +0 -90
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-envelope.schema.json +0 -142
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-bundle.schema.json +0 -584
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-context.schema.json +0 -191
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-handoff.schema.json +0 -407
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-metadata-payload.schema.json +0 -106
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-handoff-readiness.schema.json +0 -398
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-implementation-handoff.schema.json +0 -518
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-planning-lineage.schema.json +0 -106
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-review-metadata-payload.schema.json +0 -107
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.14.0/artifact-theme.schema.json +0 -316
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/artifact-envelope.schema.json +0 -408
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/design-review-bundle.schema.json +0 -590
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-document.schema.json +0 -506
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +0 -822
- package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-bundle.schema.json +0 -346
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +0 -1232
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design.mjs +0 -2611
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -21
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +0 -163
- package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
- package/lib/host-packages/claude/openplanr/skills/design/scripts/design.mjs +0 -12
- package/lib/host-packages/claude/openplanr/skills/design-loop/scripts/design.mjs +0 -12
- package/lib/host-packages/claude/openplanr/skills/design-review/scripts/design.mjs +0 -12
- package/lib/host-packages/claude/openplanr/skills/plan/scripts/design.mjs +0 -12
- package/lib/host-packages/cursor/openplanr/rules/planr-design/scripts/design.mjs +0 -12
- package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/scripts/design.mjs +0 -12
- package/lib/host-packages/cursor/openplanr/rules/planr-design-review/scripts/design.mjs +0 -12
- package/lib/host-packages/cursor/openplanr/rules/planr-plan/scripts/design.mjs +0 -12
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-artifact-shell.mjs +0 -1772
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-document.mjs +0 -2937
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-entities.mjs +0 -439
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-handoff.mjs +0 -2370
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-loopback-server.mjs +0 -359
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-parse5-parser.mjs +0 -3970
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-parse5-tokenizer.mjs +0 -3501
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review-state-store.mjs +0 -45
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review.mjs +0 -3376
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -38
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-sandbox-guards.mjs +0 -1102
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +0 -321
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +0 -1652
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs +0 -1037
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +0 -137
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design.mjs +0 -1500
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -2023
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +0 -2
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +0 -18
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +0 -814
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +0 -10
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +0 -2568
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +0 -60
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +0 -65
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/enhancements.css +0 -388
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/handoff-center.css +0 -81
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.css +0 -1
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +0 -139
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +0 -1159
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +0 -30
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +0 -900
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +0 -2261
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +0 -1595
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +0 -1467
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +0 -1860
- 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 +0 -914
- 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 +0 -2578
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +0 -582
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +0 -17
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +0 -12
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +0 -285
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +0 -2773
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-studio-shell.js +0 -134
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +0 -2207
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-design-review-experience.js +0 -16
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-studio-shell.js +0 -8
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/18-interface-primitives.js +0 -3883
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/19-interface-primitives.js +0 -966
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/20-studio-shell.js +0 -520
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +0 -1597
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +0 -311
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +0 -163
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/registries/artifact-theme.json +0 -64
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.0.0/design-manifest.schema.json +0 -90
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-envelope.schema.json +0 -142
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-bundle.schema.json +0 -584
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-context.schema.json +0 -191
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-handoff.schema.json +0 -407
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-metadata-payload.schema.json +0 -106
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-handoff-readiness.schema.json +0 -398
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-implementation-handoff.schema.json +0 -518
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-planning-lineage.schema.json +0 -106
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-review-metadata-payload.schema.json +0 -107
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.14.0/artifact-theme.schema.json +0 -316
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/artifact-envelope.schema.json +0 -408
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/design-review-bundle.schema.json +0 -590
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-document.schema.json +0 -506
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +0 -822
- package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-bundle.schema.json +0 -346
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +0 -1232
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design.mjs +0 -2611
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -21
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +0 -163
- package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-artifact-shell.mjs +0 -1772
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-document.mjs +0 -2937
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-entities.mjs +0 -439
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-handoff.mjs +0 -2370
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-loopback-server.mjs +0 -359
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-parse5-parser.mjs +0 -3970
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-parse5-tokenizer.mjs +0 -3501
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review-state-store.mjs +0 -45
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review.mjs +0 -3376
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -38
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-sandbox-guards.mjs +0 -1102
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +0 -321
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +0 -1652
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs +0 -1037
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +0 -137
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/design.mjs +0 -1500
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -2023
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +0 -2
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +0 -18
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +0 -814
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +0 -10
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +0 -2568
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +0 -60
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +0 -65
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/enhancements.css +0 -388
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/handoff-center.css +0 -81
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.css +0 -1
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +0 -139
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +0 -1159
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +0 -30
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +0 -900
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +0 -2261
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +0 -1595
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +0 -1467
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +0 -1860
- 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 +0 -914
- 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 +0 -2578
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +0 -582
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +0 -17
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +0 -12
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +0 -285
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +0 -2773
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-studio-shell.js +0 -134
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +0 -2207
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-design-review-experience.js +0 -16
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-studio-shell.js +0 -8
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/18-interface-primitives.js +0 -3883
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/19-interface-primitives.js +0 -966
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/20-studio-shell.js +0 -520
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +0 -1597
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +0 -311
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +0 -163
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/registries/artifact-theme.json +0 -64
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.0.0/design-manifest.schema.json +0 -90
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-envelope.schema.json +0 -142
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-bundle.schema.json +0 -584
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-context.schema.json +0 -191
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-handoff.schema.json +0 -407
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-metadata-payload.schema.json +0 -106
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-handoff-readiness.schema.json +0 -398
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-implementation-handoff.schema.json +0 -518
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-planning-lineage.schema.json +0 -106
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-review-metadata-payload.schema.json +0 -107
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.14.0/artifact-theme.schema.json +0 -316
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/artifact-envelope.schema.json +0 -408
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/design-review-bundle.schema.json +0 -590
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-document.schema.json +0 -506
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +0 -822
- package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-bundle.schema.json +0 -346
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +0 -1232
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design.mjs +0 -2611
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -21
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +0 -163
- package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
- package/lib/host-packages/openai/openplanr/skills/design/scripts/design.mjs +0 -12
- package/lib/host-packages/openai/openplanr/skills/design-loop/scripts/design.mjs +0 -12
- package/lib/host-packages/openai/openplanr/skills/design-review/scripts/design.mjs +0 -12
- package/lib/host-packages/openai/openplanr/skills/plan/scripts/design.mjs +0 -12
|
@@ -1,1102 +0,0 @@
|
|
|
1
|
-
// packages/artifact/lib/artifact/ui/generated/sandbox-guards.mjs
|
|
2
|
-
var ARTIFACT_WORKER_GUARD_SOURCE = '// lib/artifact/ui/sandbox/worker-guard.mjs\n(() => {\n "use strict";\n const blocked = () => new DOMException("Blocked by OpenPlanr artifact sandbox", "SecurityError");\n const replace = (owner, key, value) => {\n try {\n Object.defineProperty(owner, key, { value, writable: false, configurable: false });\n } catch {\n try {\n owner[key] = value;\n } catch {\n }\n }\n };\n const reject = () => Promise.reject(blocked());\n replace(globalThis, "fetch", reject);\n for (const key of [\n "XMLHttpRequest",\n "WebSocket",\n "EventSource",\n "WebTransport",\n "RTCPeerConnection",\n "webkitRTCPeerConnection"\n ]) {\n if (key in globalThis)\n replace(\n globalThis,\n key,\n class {\n constructor() {\n throw blocked();\n }\n }\n );\n }\n for (const key of ["indexedDB", "caches", "cookieStore"]) {\n try {\n Object.defineProperty(globalThis, key, {\n get() {\n throw blocked();\n },\n configurable: false\n });\n } catch {\n }\n }\n try {\n replace(Navigator.prototype, "sendBeacon", () => false);\n } catch {\n }\n try {\n Object.defineProperty(Navigator.prototype, "serviceWorker", {\n get() {\n throw blocked();\n },\n configurable: false\n });\n } catch {\n }\n try {\n Object.defineProperty(Navigator.prototype, "clipboard", {\n get() {\n throw blocked();\n },\n configurable: false\n });\n } catch {\n }\n try {\n if (typeof StorageManager === "function" && "getDirectory" in StorageManager.prototype)\n replace(StorageManager.prototype, "getDirectory", reject);\n } catch {\n }\n try {\n if (typeof StorageManager === "function" && "persist" in StorageManager.prototype)\n replace(StorageManager.prototype, "persist", reject);\n } catch {\n }\n for (const key of ["Worker", "SharedWorker"]) {\n if (key in globalThis)\n replace(\n globalThis,\n key,\n class {\n constructor() {\n throw blocked();\n }\n }\n );\n }\n const nativeImportScripts = typeof importScripts === "function" ? importScripts.bind(globalThis) : null;\n if (nativeImportScripts)\n replace(globalThis, "importScripts", (...urls) => {\n if (!urls.every((value) => /^(?:blob:|data:)/i.test(String(value)))) throw blocked();\n return nativeImportScripts(...urls);\n });\n})();\n';
|
|
3
|
-
var ARTIFACT_FRAME_GUARD_TEMPLATE = `// lib/artifact/ui/sandbox/frame-guard.mjs
|
|
4
|
-
(() => {
|
|
5
|
-
"use strict";
|
|
6
|
-
const injectedScript = document.currentScript;
|
|
7
|
-
injectedScript?.remove();
|
|
8
|
-
const contract = __PLANR_SANDBOX_CONTRACT__;
|
|
9
|
-
__PLANR_SANDBOX_BRIDGE_TOOLS__;
|
|
10
|
-
const inspectionTools = createArtifactBridgeTools(document, globalThis);
|
|
11
|
-
const postToParent = parent.postMessage.bind(parent);
|
|
12
|
-
const elementFromPoint = document.elementFromPoint.bind(document);
|
|
13
|
-
const queryAll = document.querySelectorAll.bind(document);
|
|
14
|
-
const elementClosest = Element.prototype.closest;
|
|
15
|
-
const elementGetAttribute = Element.prototype.getAttribute;
|
|
16
|
-
const elementSetAttribute = Element.prototype.setAttribute;
|
|
17
|
-
const elementRect = Element.prototype.getBoundingClientRect;
|
|
18
|
-
const nativeCloneNode = Node.prototype.cloneNode;
|
|
19
|
-
const nativeAppendChild = Node.prototype.appendChild;
|
|
20
|
-
const nativeCreateElement = Document.prototype.createElement;
|
|
21
|
-
const nativeGetComputedStyle = globalThis.getComputedStyle.bind(globalThis);
|
|
22
|
-
const nativeSerializeToString = XMLSerializer.prototype.serializeToString;
|
|
23
|
-
const NativeImage = globalThis.Image;
|
|
24
|
-
const nativeExecCommand = Document.prototype.execCommand;
|
|
25
|
-
const nativeDocumentWrite = Document.prototype.write;
|
|
26
|
-
const nativeDocumentWriteln = Document.prototype.writeln;
|
|
27
|
-
const NativeWorker = globalThis.Worker;
|
|
28
|
-
const NativeSharedWorker = globalThis.SharedWorker;
|
|
29
|
-
const NativeBlob = globalThis.Blob;
|
|
30
|
-
const NativeResizeObserver = globalThis.ResizeObserver;
|
|
31
|
-
const nativeCreateObjectURL = URL.createObjectURL.bind(URL);
|
|
32
|
-
const nativeRevokeObjectURL = URL.revokeObjectURL.bind(URL);
|
|
33
|
-
const workerGuard = __PLANR_SANDBOX_WORKER_GUARD__;
|
|
34
|
-
const blocked = () => new DOMException("Blocked by OpenPlanr artifact sandbox", "SecurityError");
|
|
35
|
-
const replace = (owner, key, value) => {
|
|
36
|
-
try {
|
|
37
|
-
Object.defineProperty(owner, key, { value, writable: false, configurable: false });
|
|
38
|
-
} catch {
|
|
39
|
-
try {
|
|
40
|
-
owner[key] = value;
|
|
41
|
-
} catch {
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const reject = () => Promise.reject(blocked());
|
|
46
|
-
const workerUrls = /* @__PURE__ */ new Set();
|
|
47
|
-
let liveWorkerCount = 0;
|
|
48
|
-
replace(globalThis, "fetch", reject);
|
|
49
|
-
for (const key of [
|
|
50
|
-
"XMLHttpRequest",
|
|
51
|
-
"WebSocket",
|
|
52
|
-
"EventSource",
|
|
53
|
-
"WebTransport",
|
|
54
|
-
"RTCPeerConnection",
|
|
55
|
-
"webkitRTCPeerConnection"
|
|
56
|
-
]) {
|
|
57
|
-
if (key in globalThis)
|
|
58
|
-
replace(
|
|
59
|
-
globalThis,
|
|
60
|
-
key,
|
|
61
|
-
class {
|
|
62
|
-
constructor() {
|
|
63
|
-
throw blocked();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
replace(globalThis, "open", () => null);
|
|
69
|
-
try {
|
|
70
|
-
replace(Navigator.prototype, "sendBeacon", () => false);
|
|
71
|
-
} catch {
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
Object.defineProperty(Navigator.prototype, "serviceWorker", {
|
|
75
|
-
get() {
|
|
76
|
-
throw blocked();
|
|
77
|
-
},
|
|
78
|
-
configurable: false
|
|
79
|
-
});
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
Object.defineProperty(Navigator.prototype, "clipboard", {
|
|
84
|
-
get() {
|
|
85
|
-
throw blocked();
|
|
86
|
-
},
|
|
87
|
-
configurable: false
|
|
88
|
-
});
|
|
89
|
-
} catch {
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
if ("share" in Navigator.prototype) replace(Navigator.prototype, "share", reject);
|
|
93
|
-
} catch {
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
if (typeof StorageManager === "function" && "getDirectory" in StorageManager.prototype)
|
|
97
|
-
replace(StorageManager.prototype, "getDirectory", reject);
|
|
98
|
-
} catch {
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
if (typeof StorageManager === "function" && "persist" in StorageManager.prototype)
|
|
102
|
-
replace(StorageManager.prototype, "persist", reject);
|
|
103
|
-
} catch {
|
|
104
|
-
}
|
|
105
|
-
for (const key of ["localStorage", "sessionStorage", "indexedDB", "caches", "cookieStore"]) {
|
|
106
|
-
try {
|
|
107
|
-
Object.defineProperty(globalThis, key, {
|
|
108
|
-
get() {
|
|
109
|
-
throw blocked();
|
|
110
|
-
},
|
|
111
|
-
configurable: false
|
|
112
|
-
});
|
|
113
|
-
} catch {
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
replace(HTMLFormElement.prototype, "submit", () => {
|
|
118
|
-
throw blocked();
|
|
119
|
-
});
|
|
120
|
-
replace(HTMLFormElement.prototype, "requestSubmit", () => {
|
|
121
|
-
throw blocked();
|
|
122
|
-
});
|
|
123
|
-
} catch {
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
replace(Document.prototype, "open", () => {
|
|
127
|
-
throw blocked();
|
|
128
|
-
});
|
|
129
|
-
} catch {
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
if (typeof nativeDocumentWrite === "function")
|
|
133
|
-
replace(Document.prototype, "write", function(...values) {
|
|
134
|
-
if (this.readyState !== "loading") throw blocked();
|
|
135
|
-
return nativeDocumentWrite.apply(this, values);
|
|
136
|
-
});
|
|
137
|
-
} catch {
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
if (typeof nativeDocumentWriteln === "function")
|
|
141
|
-
replace(Document.prototype, "writeln", function(...values) {
|
|
142
|
-
if (this.readyState !== "loading") throw blocked();
|
|
143
|
-
return nativeDocumentWriteln.apply(this, values);
|
|
144
|
-
});
|
|
145
|
-
} catch {
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
if (typeof nativeExecCommand === "function")
|
|
149
|
-
replace(Document.prototype, "execCommand", function(command, ...args) {
|
|
150
|
-
if (["copy", "cut", "paste"].includes(String(command).toLowerCase())) throw blocked();
|
|
151
|
-
return nativeExecCommand.call(this, command, ...args);
|
|
152
|
-
});
|
|
153
|
-
} catch {
|
|
154
|
-
}
|
|
155
|
-
const workerWrapper = (url, options, Shared) => {
|
|
156
|
-
if (liveWorkerCount >= 32) throw blocked();
|
|
157
|
-
const source = String(url);
|
|
158
|
-
if (!/^(?:blob:|data:)/i.test(source)) throw blocked();
|
|
159
|
-
const module = options && options.type === "module";
|
|
160
|
-
if (module) throw blocked();
|
|
161
|
-
const loader = "__planrLoadWorker(" + JSON.stringify(source) + ")";
|
|
162
|
-
const body = "(function(__planrLoadWorker){" + workerGuard + ";" + loader + "})(globalThis.importScripts.bind(globalThis));";
|
|
163
|
-
const wrapper = nativeCreateObjectURL(new NativeBlob([body], { type: "text/javascript" }));
|
|
164
|
-
workerUrls.add(wrapper);
|
|
165
|
-
liveWorkerCount += 1;
|
|
166
|
-
try {
|
|
167
|
-
const instance = Shared ? new NativeSharedWorker(wrapper, options) : new NativeWorker(wrapper, options);
|
|
168
|
-
let released = false;
|
|
169
|
-
const release = () => {
|
|
170
|
-
if (released) return;
|
|
171
|
-
released = true;
|
|
172
|
-
liveWorkerCount = Math.max(0, liveWorkerCount - 1);
|
|
173
|
-
workerUrls.delete(wrapper);
|
|
174
|
-
nativeRevokeObjectURL(wrapper);
|
|
175
|
-
};
|
|
176
|
-
if (!Shared && typeof instance.terminate === "function") {
|
|
177
|
-
const terminate = instance.terminate.bind(instance);
|
|
178
|
-
replace(instance, "terminate", () => {
|
|
179
|
-
release();
|
|
180
|
-
return terminate();
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (Shared && instance.port && typeof instance.port.close === "function") {
|
|
184
|
-
const close = instance.port.close.bind(instance.port);
|
|
185
|
-
replace(instance.port, "close", () => {
|
|
186
|
-
release();
|
|
187
|
-
return close();
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
return instance;
|
|
191
|
-
} catch (error) {
|
|
192
|
-
liveWorkerCount = Math.max(0, liveWorkerCount - 1);
|
|
193
|
-
workerUrls.delete(wrapper);
|
|
194
|
-
nativeRevokeObjectURL(wrapper);
|
|
195
|
-
throw error;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
const installWorker = (name, Native, Shared) => {
|
|
199
|
-
if (typeof Native !== "function") return;
|
|
200
|
-
const Wrapped = function(url, options) {
|
|
201
|
-
return workerWrapper(url, options, Shared);
|
|
202
|
-
};
|
|
203
|
-
try {
|
|
204
|
-
Object.defineProperty(Wrapped, "name", { value: name });
|
|
205
|
-
Object.setPrototypeOf(Wrapped, Native);
|
|
206
|
-
Object.defineProperty(Wrapped, "prototype", { value: Native.prototype });
|
|
207
|
-
} catch {
|
|
208
|
-
}
|
|
209
|
-
replace(globalThis, name, Wrapped);
|
|
210
|
-
};
|
|
211
|
-
try {
|
|
212
|
-
installWorker("Worker", NativeWorker, false);
|
|
213
|
-
} catch {
|
|
214
|
-
}
|
|
215
|
-
try {
|
|
216
|
-
installWorker("SharedWorker", NativeSharedWorker, true);
|
|
217
|
-
} catch {
|
|
218
|
-
}
|
|
219
|
-
try {
|
|
220
|
-
replace(Location.prototype, "assign", () => {
|
|
221
|
-
throw blocked();
|
|
222
|
-
});
|
|
223
|
-
replace(Location.prototype, "replace", () => {
|
|
224
|
-
throw blocked();
|
|
225
|
-
});
|
|
226
|
-
} catch {
|
|
227
|
-
}
|
|
228
|
-
try {
|
|
229
|
-
navigation?.addEventListener("navigate", (event) => {
|
|
230
|
-
if (event.cancelable) event.preventDefault();
|
|
231
|
-
});
|
|
232
|
-
} catch {
|
|
233
|
-
}
|
|
234
|
-
addEventListener(
|
|
235
|
-
"click",
|
|
236
|
-
(event) => {
|
|
237
|
-
if (event.target?.closest?.("a,[formaction]")) event.preventDefault();
|
|
238
|
-
},
|
|
239
|
-
true
|
|
240
|
-
);
|
|
241
|
-
addEventListener("submit", (event) => event.preventDefault(), true);
|
|
242
|
-
for (const type of ["copy", "cut", "paste"])
|
|
243
|
-
addEventListener(
|
|
244
|
-
type,
|
|
245
|
-
(event) => {
|
|
246
|
-
event.preventDefault();
|
|
247
|
-
event.stopImmediatePropagation();
|
|
248
|
-
},
|
|
249
|
-
true
|
|
250
|
-
);
|
|
251
|
-
addEventListener(
|
|
252
|
-
"pagehide",
|
|
253
|
-
() => {
|
|
254
|
-
for (const url of workerUrls) nativeRevokeObjectURL(url);
|
|
255
|
-
workerUrls.clear();
|
|
256
|
-
liveWorkerCount = 0;
|
|
257
|
-
},
|
|
258
|
-
{ once: true }
|
|
259
|
-
);
|
|
260
|
-
const plain = (value) => {
|
|
261
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
262
|
-
const prototype = Object.getPrototypeOf(value);
|
|
263
|
-
return prototype === Object.prototype || prototype === null;
|
|
264
|
-
};
|
|
265
|
-
const own = (value, key) => {
|
|
266
|
-
const descriptor = plain(value) ? Object.getOwnPropertyDescriptor(value, key) : null;
|
|
267
|
-
return descriptor && Object.hasOwn(descriptor, "value") ? descriptor.value : void 0;
|
|
268
|
-
};
|
|
269
|
-
const exact = (value, keys) => plain(value) && Object.keys(value).length === keys.length && Object.keys(value).every((key) => keys.includes(key));
|
|
270
|
-
const validText = (value, max) => typeof value === "string" && value.length > 0 && value.length <= max;
|
|
271
|
-
const validId = (value) => validText(value, 512) && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,511}$/.test(value);
|
|
272
|
-
const validScreen = (value) => (
|
|
273
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: a screen name must not contain control characters.
|
|
274
|
-
typeof value === "string" && /^[^\\u0000-\\u001f\\u007f]{1,128}$/.test(value)
|
|
275
|
-
);
|
|
276
|
-
const validRequestId = (value) => validText(value, 128) && /^[A-Za-z0-9][A-Za-z0-9._:-]{7,127}$/.test(value);
|
|
277
|
-
const validBase = (data, type, keys) => exact(data, keys) && own(data, "channel") === contract.channel && own(data, "schemaVersion") === contract.schemaVersion && own(data, "type") === type && own(data, "artifactId") === contract.artifactId && validRequestId(own(data, "requestId"));
|
|
278
|
-
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
279
|
-
const closest = (element, selector) => element ? elementClosest.call(element, selector) : null;
|
|
280
|
-
const attribute = (element, name) => element ? elementGetAttribute.call(element, name) : null;
|
|
281
|
-
const screenFor = (element) => attribute(closest(element, "[data-planr-screen]"), "data-planr-screen") || void 0;
|
|
282
|
-
const anchorFor = (element) => {
|
|
283
|
-
const anchor = closest(element, "[data-planr-id]");
|
|
284
|
-
if (!anchor) return null;
|
|
285
|
-
const planrId = attribute(anchor, "data-planr-id");
|
|
286
|
-
if (!validText(planrId, 512)) return null;
|
|
287
|
-
const rect = elementRect.call(anchor);
|
|
288
|
-
const width = Math.max(1, innerWidth), height = Math.max(1, innerHeight);
|
|
289
|
-
const x = clamp(rect.left, 0, width), y = clamp(rect.top, 0, height);
|
|
290
|
-
const right = clamp(rect.right, 0, width), bottom = clamp(rect.bottom, 0, height);
|
|
291
|
-
const screen = screenFor(anchor);
|
|
292
|
-
return {
|
|
293
|
-
planrId,
|
|
294
|
-
...screen === void 0 ? {} : { screen },
|
|
295
|
-
rect: { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) },
|
|
296
|
-
viewport: { width, height }
|
|
297
|
-
};
|
|
298
|
-
};
|
|
299
|
-
const findById = (id, screen) => {
|
|
300
|
-
for (const element of queryAll("[data-planr-id]")) {
|
|
301
|
-
if (attribute(element, "data-planr-id") !== id) continue;
|
|
302
|
-
if (screen !== void 0 && screenFor(element) !== screen) continue;
|
|
303
|
-
return element;
|
|
304
|
-
}
|
|
305
|
-
return null;
|
|
306
|
-
};
|
|
307
|
-
const exportTarget = (target) => {
|
|
308
|
-
if (target === "full") return { node: document.body, label: "full" };
|
|
309
|
-
let node = elementFromPoint(innerWidth / 2, innerHeight / 2);
|
|
310
|
-
node = closest(node, "[data-planr-id],[data-dc-slot],[data-planr-screen],section[id]") || document.body;
|
|
311
|
-
const label = attribute(node, "data-planr-screen") || attribute(node, "data-dc-slot") || attribute(node, "data-planr-id") || attribute(node, "id") || "screen";
|
|
312
|
-
return { node, label };
|
|
313
|
-
};
|
|
314
|
-
const exportPng = async (target) => {
|
|
315
|
-
const selected = exportTarget(target), node = selected.node;
|
|
316
|
-
const width = Math.ceil(
|
|
317
|
-
Math.max(node.scrollWidth || 0, node.clientWidth || 0, elementRect.call(node).width || 0)
|
|
318
|
-
);
|
|
319
|
-
const height = Math.ceil(
|
|
320
|
-
Math.max(node.scrollHeight || 0, node.clientHeight || 0, elementRect.call(node).height || 0)
|
|
321
|
-
);
|
|
322
|
-
if (!Number.isInteger(width) || !Number.isInteger(height) || width < 1 || height < 1 || width > __PLANR_SANDBOX_EXPORT_MAX_EDGE__ || height > __PLANR_SANDBOX_EXPORT_MAX_EDGE__ || width * height > 4e7)
|
|
323
|
-
throw new Error("export dimensions are unavailable or too large");
|
|
324
|
-
let count = 0;
|
|
325
|
-
const cloneStyled = (src) => {
|
|
326
|
-
if (++count > 1e4) throw new Error("export node limit exceeded");
|
|
327
|
-
if (src.nodeType === 8 || src.nodeType === 1 && src.tagName === "SCRIPT")
|
|
328
|
-
return document.createTextNode("");
|
|
329
|
-
const dst = nativeCloneNode.call(src, false);
|
|
330
|
-
if (src.nodeType === 1) {
|
|
331
|
-
const style = nativeGetComputedStyle(src);
|
|
332
|
-
let css = "";
|
|
333
|
-
for (let index = 0; index < style.length; index += 1) {
|
|
334
|
-
const name = style[index];
|
|
335
|
-
css += name + ":" + style.getPropertyValue(name) + ";";
|
|
336
|
-
}
|
|
337
|
-
elementSetAttribute.call(dst, "style", css + "animation:none;transition:none;");
|
|
338
|
-
if (src.tagName === "CANVAS") {
|
|
339
|
-
try {
|
|
340
|
-
const image2 = nativeCreateElement.call(document, "img");
|
|
341
|
-
image2.src = src.toDataURL("image/png");
|
|
342
|
-
elementSetAttribute.call(image2, "style", css);
|
|
343
|
-
return image2;
|
|
344
|
-
} catch {
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
for (let child = src.firstChild; child; child = child.nextSibling)
|
|
349
|
-
nativeAppendChild.call(dst, cloneStyled(child));
|
|
350
|
-
return dst;
|
|
351
|
-
};
|
|
352
|
-
await (document.fonts?.ready?.catch(() => {
|
|
353
|
-
}) ?? Promise.resolve());
|
|
354
|
-
const clone = cloneStyled(node);
|
|
355
|
-
if (clone.nodeType === 1) {
|
|
356
|
-
elementSetAttribute.call(clone, "xmlns", "http://www.w3.org/1999/xhtml");
|
|
357
|
-
clone.style.boxShadow = "none";
|
|
358
|
-
clone.style.borderRadius = "0";
|
|
359
|
-
}
|
|
360
|
-
const markup = nativeSerializeToString.call(new XMLSerializer(), clone);
|
|
361
|
-
if (markup.length > 10 * 1024 * 1024) throw new Error("export markup limit exceeded");
|
|
362
|
-
const scale = clamp(
|
|
363
|
-
Math.floor(__PLANR_SANDBOX_EXPORT_MAX_EDGE__ / Math.max(width, height)) || 1,
|
|
364
|
-
1,
|
|
365
|
-
3
|
|
366
|
-
);
|
|
367
|
-
const outputWidth = width * scale, outputHeight = height * scale;
|
|
368
|
-
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="' + outputWidth + '" height="' + outputHeight + '" viewBox="0 0 ' + width + " " + height + '"><foreignObject width="' + width + '" height="' + height + '">' + markup + "</foreignObject></svg>";
|
|
369
|
-
const image = new NativeImage();
|
|
370
|
-
await new Promise((resolve, reject2) => {
|
|
371
|
-
image.onload = resolve;
|
|
372
|
-
image.onerror = () => reject2(new Error("render failed"));
|
|
373
|
-
image.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg);
|
|
374
|
-
});
|
|
375
|
-
const canvas = nativeCreateElement.call(document, "canvas");
|
|
376
|
-
canvas.width = outputWidth;
|
|
377
|
-
canvas.height = outputHeight;
|
|
378
|
-
canvas.getContext("2d").drawImage(
|
|
379
|
-
image,
|
|
380
|
-
0,
|
|
381
|
-
0,
|
|
382
|
-
outputWidth,
|
|
383
|
-
outputHeight
|
|
384
|
-
);
|
|
385
|
-
const dataUrl = canvas.toDataURL("image/png");
|
|
386
|
-
if (typeof dataUrl !== "string" || dataUrl.length > __PLANR_SANDBOX_EXPORT_MAX_DATA_URL__)
|
|
387
|
-
throw new Error("export PNG limit exceeded");
|
|
388
|
-
return {
|
|
389
|
-
dataUrl,
|
|
390
|
-
width: outputWidth,
|
|
391
|
-
height: outputHeight,
|
|
392
|
-
label: String(selected.label).slice(0, 128)
|
|
393
|
-
};
|
|
394
|
-
};
|
|
395
|
-
const send = (type, requestId, anchor) => {
|
|
396
|
-
const message = {
|
|
397
|
-
channel: contract.channel,
|
|
398
|
-
schemaVersion: contract.schemaVersion,
|
|
399
|
-
type,
|
|
400
|
-
nonce: contract.nonce,
|
|
401
|
-
artifactId: contract.artifactId
|
|
402
|
-
};
|
|
403
|
-
if (requestId) message.requestId = requestId;
|
|
404
|
-
if (anchor) message.anchor = anchor;
|
|
405
|
-
postToParent(message, contract.parentOrigin === "null" ? "*" : contract.parentOrigin);
|
|
406
|
-
};
|
|
407
|
-
const sendExport = (type, requestId, value) => {
|
|
408
|
-
const message = {
|
|
409
|
-
channel: contract.channel,
|
|
410
|
-
schemaVersion: contract.schemaVersion,
|
|
411
|
-
type,
|
|
412
|
-
nonce: contract.nonce,
|
|
413
|
-
artifactId: contract.artifactId,
|
|
414
|
-
requestId
|
|
415
|
-
};
|
|
416
|
-
if (type === "export.result") Object.assign(message, value);
|
|
417
|
-
else message.reason = String(value || "export failed").slice(0, 256);
|
|
418
|
-
postToParent(message, contract.parentOrigin === "null" ? "*" : contract.parentOrigin);
|
|
419
|
-
};
|
|
420
|
-
const viewportGestures = createArtifactViewportGestures(
|
|
421
|
-
window,
|
|
422
|
-
(type, value) => postToParent(
|
|
423
|
-
{
|
|
424
|
-
channel: contract.channel,
|
|
425
|
-
schemaVersion: contract.schemaVersion,
|
|
426
|
-
type,
|
|
427
|
-
nonce: contract.nonce,
|
|
428
|
-
artifactId: contract.artifactId,
|
|
429
|
-
...value
|
|
430
|
-
},
|
|
431
|
-
contract.parentOrigin === "null" ? "*" : contract.parentOrigin
|
|
432
|
-
)
|
|
433
|
-
);
|
|
434
|
-
let lastLayout = "";
|
|
435
|
-
let layoutTimer = 0;
|
|
436
|
-
const measureLayout = () => {
|
|
437
|
-
layoutTimer = 0;
|
|
438
|
-
const root = document.documentElement, body = document.body;
|
|
439
|
-
const width = Math.ceil(
|
|
440
|
-
Math.max(
|
|
441
|
-
root?.scrollWidth || 0,
|
|
442
|
-
root?.clientWidth || 0,
|
|
443
|
-
body?.scrollWidth || 0,
|
|
444
|
-
body?.clientWidth || 0,
|
|
445
|
-
innerWidth || 0
|
|
446
|
-
)
|
|
447
|
-
);
|
|
448
|
-
const height = Math.ceil(
|
|
449
|
-
Math.max(
|
|
450
|
-
root?.scrollHeight || 0,
|
|
451
|
-
root?.clientHeight || 0,
|
|
452
|
-
body?.scrollHeight || 0,
|
|
453
|
-
body?.clientHeight || 0,
|
|
454
|
-
innerHeight || 0
|
|
455
|
-
)
|
|
456
|
-
);
|
|
457
|
-
if (!Number.isInteger(width) || !Number.isInteger(height) || width < 1 || height < 1 || width > __PLANR_SANDBOX_LAYOUT_MAX_WIDTH__ || height > __PLANR_SANDBOX_LAYOUT_MAX_HEIGHT__)
|
|
458
|
-
return;
|
|
459
|
-
const signature = width + "x" + height;
|
|
460
|
-
if (signature === lastLayout) return;
|
|
461
|
-
lastLayout = signature;
|
|
462
|
-
postToParent(
|
|
463
|
-
{
|
|
464
|
-
channel: contract.channel,
|
|
465
|
-
schemaVersion: contract.schemaVersion,
|
|
466
|
-
type: "layout.measurement",
|
|
467
|
-
nonce: contract.nonce,
|
|
468
|
-
artifactId: contract.artifactId,
|
|
469
|
-
layout: { width, height }
|
|
470
|
-
},
|
|
471
|
-
contract.parentOrigin === "null" ? "*" : contract.parentOrigin
|
|
472
|
-
);
|
|
473
|
-
};
|
|
474
|
-
const scheduleLayout = () => {
|
|
475
|
-
if (layoutTimer) return;
|
|
476
|
-
layoutTimer = setTimeout(measureLayout, 80);
|
|
477
|
-
};
|
|
478
|
-
try {
|
|
479
|
-
if (typeof NativeResizeObserver === "function") {
|
|
480
|
-
const observer = new NativeResizeObserver(scheduleLayout);
|
|
481
|
-
observer.observe(document.documentElement);
|
|
482
|
-
if (document.body) observer.observe(document.body);
|
|
483
|
-
}
|
|
484
|
-
} catch {
|
|
485
|
-
}
|
|
486
|
-
let windowStart = performance.now(), messageCount = 0;
|
|
487
|
-
addEventListener("message", (event) => {
|
|
488
|
-
if (event.source !== parent || event.origin !== contract.parentOrigin) return;
|
|
489
|
-
const now = performance.now();
|
|
490
|
-
if (now - windowStart > 1e3) {
|
|
491
|
-
windowStart = now;
|
|
492
|
-
messageCount = 0;
|
|
493
|
-
}
|
|
494
|
-
if (++messageCount > 60) return;
|
|
495
|
-
const data = event.data;
|
|
496
|
-
if (validBase(data, "bridge.challenge", [
|
|
497
|
-
"channel",
|
|
498
|
-
"schemaVersion",
|
|
499
|
-
"type",
|
|
500
|
-
"artifactId",
|
|
501
|
-
"requestId"
|
|
502
|
-
])) {
|
|
503
|
-
send("bridge.challenge-ack", data.requestId);
|
|
504
|
-
scheduleLayout();
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
if (validBase(data, "viewport.gestures", [
|
|
508
|
-
"channel",
|
|
509
|
-
"schemaVersion",
|
|
510
|
-
"type",
|
|
511
|
-
"artifactId",
|
|
512
|
-
"requestId",
|
|
513
|
-
"enabled"
|
|
514
|
-
]) && typeof own(data, "enabled") === "boolean") {
|
|
515
|
-
viewportGestures.setEnabled(own(data, "enabled"));
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
const toolReply = (type, value = {}) => postToParent(
|
|
519
|
-
{
|
|
520
|
-
channel: contract.channel,
|
|
521
|
-
schemaVersion: contract.schemaVersion,
|
|
522
|
-
type,
|
|
523
|
-
nonce: contract.nonce,
|
|
524
|
-
artifactId: contract.artifactId,
|
|
525
|
-
requestId: data.requestId,
|
|
526
|
-
...value
|
|
527
|
-
},
|
|
528
|
-
contract.parentOrigin === "null" ? "*" : contract.parentOrigin
|
|
529
|
-
);
|
|
530
|
-
if (validBase(data, "thumbnail.request", [
|
|
531
|
-
"channel",
|
|
532
|
-
"schemaVersion",
|
|
533
|
-
"type",
|
|
534
|
-
"artifactId",
|
|
535
|
-
"requestId"
|
|
536
|
-
])) {
|
|
537
|
-
inspectionTools.thumbnail().then((value) => toolReply("thumbnail.result", value)).catch(() => toolReply("thumbnail.error", { reason: "Thumbnail capture unavailable." }));
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
if (validBase(data, "inspect.point", [
|
|
541
|
-
"channel",
|
|
542
|
-
"schemaVersion",
|
|
543
|
-
"type",
|
|
544
|
-
"artifactId",
|
|
545
|
-
"requestId",
|
|
546
|
-
"x",
|
|
547
|
-
"y"
|
|
548
|
-
])) {
|
|
549
|
-
const inspection = inspectionTools.inspectAt(own(data, "x"), own(data, "y"));
|
|
550
|
-
toolReply(inspection ? "inspect.result" : "inspect.miss", inspection ? { inspection } : {});
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
const inspectionKeys = own(data, "screen") === void 0 ? ["channel", "schemaVersion", "type", "artifactId", "requestId", "planrId"] : ["channel", "schemaVersion", "type", "artifactId", "requestId", "planrId", "screen"];
|
|
554
|
-
if (validBase(data, "inspect.anchor", inspectionKeys)) {
|
|
555
|
-
const inspection = inspectionTools.inspect({
|
|
556
|
-
planrId: own(data, "planrId"),
|
|
557
|
-
...own(data, "screen") === void 0 ? {} : { screen: own(data, "screen") }
|
|
558
|
-
});
|
|
559
|
-
toolReply(inspection ? "inspect.result" : "inspect.miss", inspection ? { inspection } : {});
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
if (validBase(data, "export.request", [
|
|
563
|
-
"channel",
|
|
564
|
-
"schemaVersion",
|
|
565
|
-
"type",
|
|
566
|
-
"artifactId",
|
|
567
|
-
"requestId",
|
|
568
|
-
"target"
|
|
569
|
-
]) && ["screen", "full"].includes(own(data, "target"))) {
|
|
570
|
-
exportPng(own(data, "target")).then((value) => sendExport("export.result", data.requestId, value)).catch((error) => sendExport("export.error", data.requestId, error?.message));
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
if (validBase(data, "anchor.hit-test", [
|
|
574
|
-
"channel",
|
|
575
|
-
"schemaVersion",
|
|
576
|
-
"type",
|
|
577
|
-
"artifactId",
|
|
578
|
-
"requestId",
|
|
579
|
-
"x",
|
|
580
|
-
"y"
|
|
581
|
-
])) {
|
|
582
|
-
const x = own(data, "x"), y = own(data, "y");
|
|
583
|
-
if (!Number.isFinite(x) || !Number.isFinite(y) || x < 0 || y < 0 || x > innerWidth || y > innerHeight)
|
|
584
|
-
return;
|
|
585
|
-
const anchor = anchorFor(elementFromPoint(x, y));
|
|
586
|
-
send(anchor ? "anchor.result" : "anchor.miss", data.requestId, anchor);
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
const resolveKeys = own(data, "screen") === void 0 ? ["channel", "schemaVersion", "type", "artifactId", "requestId", "planrId"] : ["channel", "schemaVersion", "type", "artifactId", "requestId", "planrId", "screen"];
|
|
590
|
-
if (validBase(data, "anchor.resolve", resolveKeys)) {
|
|
591
|
-
const planrId = own(data, "planrId"), screen = own(data, "screen");
|
|
592
|
-
if (!validId(planrId) || screen !== void 0 && !validScreen(screen)) return;
|
|
593
|
-
const anchor = anchorFor(findById(planrId, screen));
|
|
594
|
-
send(anchor ? "anchor.result" : "anchor.miss", data.requestId, anchor);
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
const ready = () => send("bridge.ready");
|
|
598
|
-
if (document.readyState === "loading")
|
|
599
|
-
document.addEventListener(
|
|
600
|
-
"DOMContentLoaded",
|
|
601
|
-
() => {
|
|
602
|
-
ready();
|
|
603
|
-
scheduleLayout();
|
|
604
|
-
},
|
|
605
|
-
{ once: true }
|
|
606
|
-
);
|
|
607
|
-
else
|
|
608
|
-
queueMicrotask(() => {
|
|
609
|
-
ready();
|
|
610
|
-
scheduleLayout();
|
|
611
|
-
});
|
|
612
|
-
})();
|
|
613
|
-
`;
|
|
614
|
-
var ARTIFACT_HOST_GUARD_TEMPLATE = `// lib/artifact/ui/sandbox/host-guard.mjs
|
|
615
|
-
(() => {
|
|
616
|
-
"use strict";
|
|
617
|
-
const config = __PLANR_SANDBOX_CONFIG__;
|
|
618
|
-
__PLANR_SANDBOX_BRIDGE_TOOLS__;
|
|
619
|
-
const requestId = () => crypto.randomUUID?.() || "request-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2);
|
|
620
|
-
const bridgeClient = {
|
|
621
|
-
attach({ artifact, frame, getState }) {
|
|
622
|
-
const pending = /* @__PURE__ */ new Map();
|
|
623
|
-
let windowStart = performance.now(), messageCount = 0;
|
|
624
|
-
let immutableSource = "", trustedLoad = false, recovering = false, navigationAttempts = 0, failedClosed = false;
|
|
625
|
-
let inertSource = "";
|
|
626
|
-
let prototypeGeneration = null;
|
|
627
|
-
let pendingChallenge = null;
|
|
628
|
-
let measuredLayout = null;
|
|
629
|
-
let viewportGesturesEnabled = false, disposed = false;
|
|
630
|
-
const syncViewportGestures = () => {
|
|
631
|
-
if (trustedLoad && !disposed)
|
|
632
|
-
frame.contentWindow?.postMessage(
|
|
633
|
-
{
|
|
634
|
-
channel: config.channel,
|
|
635
|
-
schemaVersion: config.schemaVersion,
|
|
636
|
-
type: "viewport.gestures",
|
|
637
|
-
artifactId: artifact.id,
|
|
638
|
-
requestId: requestId(),
|
|
639
|
-
enabled: viewportGesturesEnabled
|
|
640
|
-
},
|
|
641
|
-
"*"
|
|
642
|
-
);
|
|
643
|
-
};
|
|
644
|
-
const plain = (value) => {
|
|
645
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
646
|
-
const prototype = Object.getPrototypeOf(value);
|
|
647
|
-
return prototype === Object.prototype || prototype === null;
|
|
648
|
-
};
|
|
649
|
-
const own = (value, key) => {
|
|
650
|
-
const descriptor = plain(value) ? Object.getOwnPropertyDescriptor(value, key) : null;
|
|
651
|
-
return descriptor && Object.hasOwn(descriptor, "value") ? descriptor.value : void 0;
|
|
652
|
-
};
|
|
653
|
-
const exact = (value, keys) => plain(value) && Object.keys(value).length === keys.length && Object.keys(value).every((key) => keys.includes(key));
|
|
654
|
-
const validText = (value, max) => typeof value === "string" && value.length > 0 && value.length <= max;
|
|
655
|
-
const validId = (value) => validText(value, 512) && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,511}$/.test(value);
|
|
656
|
-
const validScreen = (value) => (
|
|
657
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: a screen name must not contain control characters.
|
|
658
|
-
typeof value === "string" && /^[^\\u0000-\\u001f\\u007f]{1,128}$/.test(value)
|
|
659
|
-
);
|
|
660
|
-
const validRequestId = (value) => validText(value, 128) && /^[A-Za-z0-9][A-Za-z0-9._:-]{7,127}$/.test(value);
|
|
661
|
-
const validNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
662
|
-
const originalPointerEvents = frame.style.pointerEvents;
|
|
663
|
-
const originalInert = frame.inert;
|
|
664
|
-
const quarantine = (active) => {
|
|
665
|
-
if (active) prototypeGeneration = null;
|
|
666
|
-
frame.inert = active ? true : originalInert;
|
|
667
|
-
frame.style.pointerEvents = active ? "none" : originalPointerEvents;
|
|
668
|
-
if (active) frame.setAttribute("aria-busy", "true");
|
|
669
|
-
else frame.removeAttribute("aria-busy");
|
|
670
|
-
frame.dataset.planrBridgeTrusted = String(!active);
|
|
671
|
-
};
|
|
672
|
-
frame.setAttribute("csp", config.frameCsp);
|
|
673
|
-
quarantine(true);
|
|
674
|
-
const receive = (event) => {
|
|
675
|
-
if (event.source !== frame.contentWindow || event.origin !== "null") return;
|
|
676
|
-
const now = performance.now();
|
|
677
|
-
if (now - windowStart > 1e3) {
|
|
678
|
-
windowStart = now;
|
|
679
|
-
messageCount = 0;
|
|
680
|
-
}
|
|
681
|
-
if (++messageCount > 120) return;
|
|
682
|
-
const data = event.data;
|
|
683
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) return;
|
|
684
|
-
if (own(data, "channel") !== config.channel || own(data, "schemaVersion") !== config.schemaVersion || own(data, "nonce") !== config.nonce || own(data, "artifactId") !== artifact.id)
|
|
685
|
-
return;
|
|
686
|
-
const type = own(data, "type");
|
|
687
|
-
if (type === "bridge.ready") {
|
|
688
|
-
if (!exact(data, ["channel", "schemaVersion", "type", "nonce", "artifactId"])) return;
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
if (type === "bridge.challenge-ack") {
|
|
692
|
-
if (!exact(data, [
|
|
693
|
-
"channel",
|
|
694
|
-
"schemaVersion",
|
|
695
|
-
"type",
|
|
696
|
-
"nonce",
|
|
697
|
-
"artifactId",
|
|
698
|
-
"requestId"
|
|
699
|
-
]) || !validRequestId(own(data, "requestId")) || !pendingChallenge || own(data, "requestId") !== pendingChallenge.id)
|
|
700
|
-
return;
|
|
701
|
-
prototypeGeneration = pendingChallenge.id;
|
|
702
|
-
clearTimeout(pendingChallenge.timer);
|
|
703
|
-
pendingChallenge = null;
|
|
704
|
-
trustedLoad = true;
|
|
705
|
-
recovering = false;
|
|
706
|
-
quarantine(false);
|
|
707
|
-
syncViewportGestures();
|
|
708
|
-
frame.dispatchEvent(
|
|
709
|
-
new CustomEvent(config.readyEvent, {
|
|
710
|
-
detail: { artifactId: artifact.id, authenticated: true }
|
|
711
|
-
})
|
|
712
|
-
);
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
if (type === "viewport.zoom") {
|
|
716
|
-
if (!trustedLoad || !viewportGesturesEnabled || disposed || !exact(data, [
|
|
717
|
-
"channel",
|
|
718
|
-
"schemaVersion",
|
|
719
|
-
"type",
|
|
720
|
-
"nonce",
|
|
721
|
-
"artifactId",
|
|
722
|
-
"x",
|
|
723
|
-
"y",
|
|
724
|
-
"deltaY"
|
|
725
|
-
]))
|
|
726
|
-
return;
|
|
727
|
-
const value2 = normalizeArtifactViewportZoom(
|
|
728
|
-
{ x: own(data, "x"), y: own(data, "y"), deltaY: own(data, "deltaY") },
|
|
729
|
-
artifact.viewport
|
|
730
|
-
);
|
|
731
|
-
if (value2)
|
|
732
|
-
frame.dispatchEvent(
|
|
733
|
-
new CustomEvent(config.viewportZoomEvent, { bubbles: true, detail: value2 })
|
|
734
|
-
);
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
if (type === "viewport.pan") {
|
|
738
|
-
if (!trustedLoad || !viewportGesturesEnabled || disposed || !exact(data, [
|
|
739
|
-
"channel",
|
|
740
|
-
"schemaVersion",
|
|
741
|
-
"type",
|
|
742
|
-
"nonce",
|
|
743
|
-
"artifactId",
|
|
744
|
-
"deltaX",
|
|
745
|
-
"deltaY"
|
|
746
|
-
]))
|
|
747
|
-
return;
|
|
748
|
-
const value2 = normalizeArtifactViewportPan({
|
|
749
|
-
deltaX: own(data, "deltaX"),
|
|
750
|
-
deltaY: own(data, "deltaY")
|
|
751
|
-
});
|
|
752
|
-
if (value2)
|
|
753
|
-
frame.dispatchEvent(
|
|
754
|
-
new CustomEvent(config.viewportPanEvent, { bubbles: true, detail: value2 })
|
|
755
|
-
);
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
if (type === "layout.measurement") {
|
|
759
|
-
const layout = own(data, "layout");
|
|
760
|
-
if (!trustedLoad || !exact(data, ["channel", "schemaVersion", "type", "nonce", "artifactId", "layout"]) || !exact(layout, ["width", "height"]) || !Number.isInteger(layout.width) || !Number.isInteger(layout.height) || layout.width < 1 || layout.width > __PLANR_SANDBOX_LAYOUT_MAX_WIDTH__ || layout.height < 1 || layout.height > __PLANR_SANDBOX_LAYOUT_MAX_HEIGHT__)
|
|
761
|
-
return;
|
|
762
|
-
measuredLayout = Object.freeze({ width: layout.width, height: layout.height });
|
|
763
|
-
frame.dispatchEvent(new CustomEvent(config.layoutEvent, { detail: measuredLayout }));
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
const receivedRequestId = own(data, "requestId");
|
|
767
|
-
if (!trustedLoad || !validRequestId(receivedRequestId) || !pending.has(receivedRequestId))
|
|
768
|
-
return;
|
|
769
|
-
const settle = pending.get(receivedRequestId);
|
|
770
|
-
if (["inspect.point", "inspect.anchor", "thumbnail.request"].includes(settle.type)) {
|
|
771
|
-
const result = normalizeArtifactBridgeToolResult(settle.type, data, artifact.viewport);
|
|
772
|
-
if (!result.valid) return;
|
|
773
|
-
pending.delete(receivedRequestId);
|
|
774
|
-
clearTimeout(settle.timer);
|
|
775
|
-
settle.resolve(result.value);
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
if (settle.type === "export.request") {
|
|
779
|
-
if (type === "export.error") {
|
|
780
|
-
if (!exact(data, [
|
|
781
|
-
"channel",
|
|
782
|
-
"schemaVersion",
|
|
783
|
-
"type",
|
|
784
|
-
"nonce",
|
|
785
|
-
"artifactId",
|
|
786
|
-
"requestId",
|
|
787
|
-
"reason"
|
|
788
|
-
]) || typeof own(data, "reason") !== "string" || own(data, "reason").length > 256)
|
|
789
|
-
return;
|
|
790
|
-
pending.delete(receivedRequestId);
|
|
791
|
-
clearTimeout(settle.timer);
|
|
792
|
-
settle.resolve(null);
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
if (type !== "export.result" || !exact(data, [
|
|
796
|
-
"channel",
|
|
797
|
-
"schemaVersion",
|
|
798
|
-
"type",
|
|
799
|
-
"nonce",
|
|
800
|
-
"artifactId",
|
|
801
|
-
"requestId",
|
|
802
|
-
"dataUrl",
|
|
803
|
-
"width",
|
|
804
|
-
"height",
|
|
805
|
-
"label"
|
|
806
|
-
]))
|
|
807
|
-
return;
|
|
808
|
-
const dataUrl = own(data, "dataUrl"), width = own(data, "width"), height = own(data, "height"), label = own(data, "label");
|
|
809
|
-
pending.delete(receivedRequestId);
|
|
810
|
-
clearTimeout(settle.timer);
|
|
811
|
-
if (typeof dataUrl !== "string" || dataUrl.length > __PLANR_SANDBOX_EXPORT_MAX_DATA_URL__ || !/^data:image\\/png;base64,[A-Za-z0-9+/]+=*$/.test(dataUrl) || !Number.isInteger(width) || !Number.isInteger(height) || width < 1 || height < 1 || width > __PLANR_SANDBOX_EXPORT_MAX_EDGE__ || height > __PLANR_SANDBOX_EXPORT_MAX_EDGE__ || !validText(label, 128)) {
|
|
812
|
-
settle.resolve(null);
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
settle.resolve(Object.freeze({ dataUrl, width, height, label }));
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
if (!["anchor.result", "anchor.miss"].includes(type)) return;
|
|
819
|
-
if (type === "anchor.miss" && !exact(data, ["channel", "schemaVersion", "type", "nonce", "artifactId", "requestId"]))
|
|
820
|
-
return;
|
|
821
|
-
if (type === "anchor.result" && !exact(data, [
|
|
822
|
-
"channel",
|
|
823
|
-
"schemaVersion",
|
|
824
|
-
"type",
|
|
825
|
-
"nonce",
|
|
826
|
-
"artifactId",
|
|
827
|
-
"requestId",
|
|
828
|
-
"anchor"
|
|
829
|
-
]))
|
|
830
|
-
return;
|
|
831
|
-
pending.delete(receivedRequestId);
|
|
832
|
-
clearTimeout(settle.timer);
|
|
833
|
-
if (type === "anchor.miss") {
|
|
834
|
-
settle.resolve(null);
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
const anchor = data.anchor, rect = anchor?.rect, viewport = anchor?.viewport;
|
|
838
|
-
const frozen = getState?.()?.presentation === "document" && measuredLayout ? measuredLayout : artifact.viewport;
|
|
839
|
-
const anchorKeys = anchor?.screen === void 0 ? ["planrId", "rect", "viewport"] : ["planrId", "screen", "rect", "viewport"];
|
|
840
|
-
if (!exact(anchor, anchorKeys) || !exact(rect, ["x", "y", "width", "height"]) || !exact(viewport, ["width", "height"]) || !validId(anchor?.planrId) || anchor.screen !== void 0 && !validScreen(anchor.screen) || !["x", "y", "width", "height"].every((key) => validNumber(rect?.[key])) || viewport?.width !== frozen.width || viewport?.height !== frozen.height || rect.x < 0 || rect.y < 0 || rect.width < 0 || rect.height < 0 || rect.x + rect.width > frozen.width || rect.y + rect.height > frozen.height) {
|
|
841
|
-
settle.resolve(null);
|
|
842
|
-
return;
|
|
843
|
-
}
|
|
844
|
-
const value = Object.freeze({
|
|
845
|
-
artifactId: artifact.id,
|
|
846
|
-
planrId: anchor.planrId,
|
|
847
|
-
...anchor.screen === void 0 ? {} : { screen: anchor.screen },
|
|
848
|
-
rect: Object.freeze({ ...rect }),
|
|
849
|
-
viewport: frozen
|
|
850
|
-
});
|
|
851
|
-
settle.resolve(value);
|
|
852
|
-
frame.dispatchEvent(new CustomEvent(config.anchorEvent, { detail: value }));
|
|
853
|
-
};
|
|
854
|
-
addEventListener("message", receive);
|
|
855
|
-
const rememberSource = () => {
|
|
856
|
-
if (immutableSource) return;
|
|
857
|
-
const html = frame.getAttribute("srcdoc") || "";
|
|
858
|
-
if (html) {
|
|
859
|
-
immutableSource = { type: "srcdoc", value: html };
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
const value = frame.getAttribute("src") || "";
|
|
863
|
-
if (value.startsWith("blob:")) immutableSource = { type: "url", value };
|
|
864
|
-
};
|
|
865
|
-
const sourceObserver = new MutationObserver(rememberSource);
|
|
866
|
-
sourceObserver.observe(frame, { attributes: true, attributeFilter: ["src", "srcdoc"] });
|
|
867
|
-
const settlePending = () => {
|
|
868
|
-
for (const value of pending.values()) {
|
|
869
|
-
clearTimeout(value.timer);
|
|
870
|
-
value.resolve(null);
|
|
871
|
-
}
|
|
872
|
-
pending.clear();
|
|
873
|
-
};
|
|
874
|
-
const clearChallenge = () => {
|
|
875
|
-
if (pendingChallenge) {
|
|
876
|
-
clearTimeout(pendingChallenge.timer);
|
|
877
|
-
pendingChallenge = null;
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
const failClosed = () => {
|
|
881
|
-
if (failedClosed) return;
|
|
882
|
-
failedClosed = true;
|
|
883
|
-
recovering = false;
|
|
884
|
-
clearChallenge();
|
|
885
|
-
settlePending();
|
|
886
|
-
quarantine(true);
|
|
887
|
-
const inertPolicy = config.frameCsp.replaceAll("&", "&").replaceAll('"', """);
|
|
888
|
-
inertSource = URL.createObjectURL(
|
|
889
|
-
new Blob(
|
|
890
|
-
[
|
|
891
|
-
'<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="' + inertPolicy + '"><meta name="referrer" content="no-referrer"><title>Artifact blocked</title><p>Artifact navigation was blocked.</p>'
|
|
892
|
-
],
|
|
893
|
-
{ type: "text/html" }
|
|
894
|
-
)
|
|
895
|
-
);
|
|
896
|
-
frame.dispatchEvent(
|
|
897
|
-
new CustomEvent(config.navigationEvent, {
|
|
898
|
-
detail: {
|
|
899
|
-
artifactId: artifact.id,
|
|
900
|
-
recovered: false,
|
|
901
|
-
failedClosed: true,
|
|
902
|
-
attempts: navigationAttempts
|
|
903
|
-
}
|
|
904
|
-
})
|
|
905
|
-
);
|
|
906
|
-
frame.removeAttribute("srcdoc");
|
|
907
|
-
frame.src = inertSource;
|
|
908
|
-
};
|
|
909
|
-
const recoverNavigation = () => {
|
|
910
|
-
if (failedClosed || !immutableSource) return;
|
|
911
|
-
navigationAttempts += 1;
|
|
912
|
-
if (navigationAttempts >= 3) {
|
|
913
|
-
failClosed();
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
|
-
recovering = true;
|
|
917
|
-
trustedLoad = false;
|
|
918
|
-
quarantine(true);
|
|
919
|
-
clearChallenge();
|
|
920
|
-
frame.dispatchEvent(
|
|
921
|
-
new CustomEvent(config.navigationEvent, {
|
|
922
|
-
detail: {
|
|
923
|
-
artifactId: artifact.id,
|
|
924
|
-
recovered: true,
|
|
925
|
-
failedClosed: false,
|
|
926
|
-
attempts: navigationAttempts
|
|
927
|
-
}
|
|
928
|
-
})
|
|
929
|
-
);
|
|
930
|
-
if (immutableSource.type === "srcdoc") {
|
|
931
|
-
frame.removeAttribute("src");
|
|
932
|
-
frame.removeAttribute("srcdoc");
|
|
933
|
-
frame.srcdoc = immutableSource.value;
|
|
934
|
-
} else {
|
|
935
|
-
frame.removeAttribute("srcdoc");
|
|
936
|
-
frame.src = immutableSource.value;
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
const challengeCurrentDocument = () => {
|
|
940
|
-
if (failedClosed) return;
|
|
941
|
-
clearChallenge();
|
|
942
|
-
const id = requestId();
|
|
943
|
-
const timer = setTimeout(() => {
|
|
944
|
-
if (pendingChallenge?.id !== id) return;
|
|
945
|
-
pendingChallenge = null;
|
|
946
|
-
recoverNavigation();
|
|
947
|
-
}, 750);
|
|
948
|
-
pendingChallenge = { id, timer };
|
|
949
|
-
frame.contentWindow?.postMessage(
|
|
950
|
-
{
|
|
951
|
-
channel: config.channel,
|
|
952
|
-
schemaVersion: config.schemaVersion,
|
|
953
|
-
type: "bridge.challenge",
|
|
954
|
-
artifactId: artifact.id,
|
|
955
|
-
requestId: id
|
|
956
|
-
},
|
|
957
|
-
"*"
|
|
958
|
-
);
|
|
959
|
-
};
|
|
960
|
-
const onFrameLoad = () => {
|
|
961
|
-
rememberSource();
|
|
962
|
-
trustedLoad = false;
|
|
963
|
-
measuredLayout = null;
|
|
964
|
-
quarantine(true);
|
|
965
|
-
challengeCurrentDocument();
|
|
966
|
-
};
|
|
967
|
-
frame.addEventListener("load", onFrameLoad);
|
|
968
|
-
const send = (type, payload = {}) => new Promise((resolve) => {
|
|
969
|
-
if (!trustedLoad || pending.size >= 32) {
|
|
970
|
-
resolve(null);
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
const id = requestId();
|
|
974
|
-
const timer = setTimeout(() => {
|
|
975
|
-
pending.delete(id);
|
|
976
|
-
resolve(null);
|
|
977
|
-
}, ARTIFACT_BRIDGE_OPERATION_TIMEOUTS[type] || 750);
|
|
978
|
-
pending.set(id, { resolve, timer, type });
|
|
979
|
-
frame.contentWindow?.postMessage(
|
|
980
|
-
{
|
|
981
|
-
channel: config.channel,
|
|
982
|
-
schemaVersion: config.schemaVersion,
|
|
983
|
-
type,
|
|
984
|
-
artifactId: artifact.id,
|
|
985
|
-
requestId: id,
|
|
986
|
-
...payload
|
|
987
|
-
},
|
|
988
|
-
"*"
|
|
989
|
-
);
|
|
990
|
-
});
|
|
991
|
-
Object.defineProperty(frame, "__openPlanrBridge", {
|
|
992
|
-
value: Object.freeze({
|
|
993
|
-
getPrototypeNonce: () => trustedLoad && !disposed ? config.nonce : null,
|
|
994
|
-
getPrototypeGeneration: () => trustedLoad && !disposed ? prototypeGeneration : null,
|
|
995
|
-
setViewportGestures: (enabled) => {
|
|
996
|
-
if (typeof enabled !== "boolean" || disposed) return false;
|
|
997
|
-
if (enabled === viewportGesturesEnabled) return true;
|
|
998
|
-
viewportGesturesEnabled = enabled;
|
|
999
|
-
syncViewportGestures();
|
|
1000
|
-
return true;
|
|
1001
|
-
},
|
|
1002
|
-
hitTest: (x, y) => Number.isFinite(x) && Number.isFinite(y) ? send("anchor.hit-test", { x, y }) : Promise.resolve(null),
|
|
1003
|
-
resolve: (planrId, screen) => validText(planrId, 512) ? send("anchor.resolve", { planrId, ...screen ? { screen } : {} }) : Promise.resolve(null),
|
|
1004
|
-
inspectAt: (x, y) => Number.isFinite(x) && Number.isFinite(y) && x >= 0 && y >= 0 ? send("inspect.point", { x, y }) : Promise.resolve(null),
|
|
1005
|
-
inspect: (anchor) => validId(anchor?.planrId) && (anchor.screen === void 0 || validScreen(anchor.screen)) ? send("inspect.anchor", {
|
|
1006
|
-
planrId: anchor.planrId,
|
|
1007
|
-
...anchor.screen === void 0 ? {} : { screen: anchor.screen }
|
|
1008
|
-
}) : Promise.resolve(null),
|
|
1009
|
-
thumbnail: () => send("thumbnail.request"),
|
|
1010
|
-
exportPng: (target) => ["screen", "full"].includes(target) ? send("export.request", { target }) : Promise.resolve(null)
|
|
1011
|
-
}),
|
|
1012
|
-
configurable: true
|
|
1013
|
-
});
|
|
1014
|
-
return () => {
|
|
1015
|
-
viewportGesturesEnabled = false;
|
|
1016
|
-
syncViewportGestures();
|
|
1017
|
-
disposed = true;
|
|
1018
|
-
removeEventListener("message", receive);
|
|
1019
|
-
frame.removeEventListener("load", onFrameLoad);
|
|
1020
|
-
sourceObserver.disconnect();
|
|
1021
|
-
clearChallenge();
|
|
1022
|
-
settlePending();
|
|
1023
|
-
if (inertSource) URL.revokeObjectURL(inertSource);
|
|
1024
|
-
frame.inert = originalInert;
|
|
1025
|
-
frame.style.pointerEvents = originalPointerEvents;
|
|
1026
|
-
frame.removeAttribute("aria-busy");
|
|
1027
|
-
frame.removeAttribute("csp");
|
|
1028
|
-
delete frame.dataset.planrBridgeTrusted;
|
|
1029
|
-
try {
|
|
1030
|
-
delete frame.__openPlanrBridge;
|
|
1031
|
-
} catch {
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
globalThis.__OPENPLANR_ARTIFACT_STAGE_OPTIONS__ = Object.freeze({
|
|
1037
|
-
sourceTransport: config.sourceTransport,
|
|
1038
|
-
...config.frameBudget === void 0 ? {} : { frameBudget: config.frameBudget },
|
|
1039
|
-
async resolveArtifactSource(artifact, context) {
|
|
1040
|
-
if (config.inlineSources) {
|
|
1041
|
-
const sourceId = config.inlineArtifactSources?.[artifact.id];
|
|
1042
|
-
const source = Object.hasOwn(config.inlineSources, sourceId ?? "") ? config.inlineSources[sourceId] : null;
|
|
1043
|
-
if (!source || typeof source.html !== "string" || typeof source.artifactIdToken !== "string" || source.html.split(source.artifactIdToken).length !== 2)
|
|
1044
|
-
throw new Error("Artifact source unavailable");
|
|
1045
|
-
return new Blob(
|
|
1046
|
-
[
|
|
1047
|
-
source.html.replace(
|
|
1048
|
-
source.artifactIdToken,
|
|
1049
|
-
\`"artifactId":\${JSON.stringify(artifact.id)}\`
|
|
1050
|
-
)
|
|
1051
|
-
],
|
|
1052
|
-
{ type: "text/html" }
|
|
1053
|
-
);
|
|
1054
|
-
}
|
|
1055
|
-
if (config.inlineArtifacts) {
|
|
1056
|
-
const html = config.inlineArtifacts[artifact.id];
|
|
1057
|
-
if (typeof html !== "string") throw new Error("Artifact source unavailable");
|
|
1058
|
-
return new Blob([html], { type: "text/html" });
|
|
1059
|
-
}
|
|
1060
|
-
const response = await fetch(config.artifactBaseUrl + encodeURIComponent(artifact.id), {
|
|
1061
|
-
cache: "no-store",
|
|
1062
|
-
credentials: "omit",
|
|
1063
|
-
referrerPolicy: "no-referrer",
|
|
1064
|
-
signal: context?.signal
|
|
1065
|
-
});
|
|
1066
|
-
if (!response.ok || !(response.headers.get("content-type") || "").toLowerCase().startsWith("application/octet-stream"))
|
|
1067
|
-
throw new Error("Artifact source unavailable");
|
|
1068
|
-
return new Blob([await response.arrayBuffer()], { type: "text/html" });
|
|
1069
|
-
},
|
|
1070
|
-
bridgeClient,
|
|
1071
|
-
onState(state) {
|
|
1072
|
-
dispatchEvent(new CustomEvent("planr:artifact-state", { detail: state }));
|
|
1073
|
-
}
|
|
1074
|
-
});
|
|
1075
|
-
const loadStage = () => {
|
|
1076
|
-
const stage = document.createElement("script");
|
|
1077
|
-
stage.src = config.stageRuntimeUrl;
|
|
1078
|
-
stage.async = false;
|
|
1079
|
-
document.head.append(stage);
|
|
1080
|
-
};
|
|
1081
|
-
if (config.adapterRuntimeUrl) {
|
|
1082
|
-
const adapter = document.createElement("script");
|
|
1083
|
-
adapter.src = config.adapterRuntimeUrl;
|
|
1084
|
-
adapter.async = false;
|
|
1085
|
-
adapter.addEventListener("load", loadStage, { once: true });
|
|
1086
|
-
adapter.addEventListener(
|
|
1087
|
-
"error",
|
|
1088
|
-
() => {
|
|
1089
|
-
document.documentElement.dataset.planrAdapterError = "true";
|
|
1090
|
-
},
|
|
1091
|
-
{ once: true }
|
|
1092
|
-
);
|
|
1093
|
-
document.head.append(adapter);
|
|
1094
|
-
} else loadStage();
|
|
1095
|
-
})();
|
|
1096
|
-
`;
|
|
1097
|
-
|
|
1098
|
-
export {
|
|
1099
|
-
ARTIFACT_WORKER_GUARD_SOURCE,
|
|
1100
|
-
ARTIFACT_FRAME_GUARD_TEMPLATE,
|
|
1101
|
-
ARTIFACT_HOST_GUARD_TEMPLATE
|
|
1102
|
-
};
|