gentle-pi 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +6 -6
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +79 -4
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +40 -19
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -878
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +11 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +11 -10
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller.test.ts +2 -1
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator.test.ts +271 -4
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +184 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
// Designs and artboards: the design list, each board's sandboxed iframe, header
|
|
2
|
+
// and Implement this control (with the ⋯ menu of canvas-export.js beside it),
|
|
3
|
+
// manifest loading, the system board, the show event and the first load.
|
|
4
|
+
// design/system.html, when present, is the first board of every design; it is
|
|
5
|
+
// kept out of state.boards so comments never apply to it.
|
|
6
|
+
|
|
7
|
+
// Every string the boards show, in English; canvas-i18n-es.js has the Spanish. Artboard titles and tradeoffs stay as written.
|
|
8
|
+
const TEXT = Object.freeze({
|
|
9
|
+
systemTitle: "Design system",
|
|
10
|
+
systemTradeoff: "Project tokens (design/system.md)",
|
|
11
|
+
systemNote: "Comments apply to design artboards only. To change the system, update the project's design sources and run /gentle:design sync.",
|
|
12
|
+
systemOff: "Comments off on this board",
|
|
13
|
+
invalidDesign: (slug) => `${slug} (invalid design.json)`,
|
|
14
|
+
frameTitle: (title) => `${title} artboard`,
|
|
15
|
+
viewSystem: (title) => `View ${title} (read-only)`,
|
|
16
|
+
use: (title) => `Use ${title}`,
|
|
17
|
+
systemHint: "Click to view the design system",
|
|
18
|
+
useHint: "Click to use this design",
|
|
19
|
+
implement: "Implement this",
|
|
20
|
+
implementAria: (title) => `Implement ${title} in the project`,
|
|
21
|
+
confirmAria: (title) => `Confirm implementing ${title}`,
|
|
22
|
+
question: "Send it to the session to implement?",
|
|
23
|
+
send: "Send",
|
|
24
|
+
cancel: "Cancel",
|
|
25
|
+
queued: (title) => `Queued: the session will implement ${title} after its current task.`,
|
|
26
|
+
sent: (title) => `Sent: the session is implementing ${title} now.`,
|
|
27
|
+
notSent: (reason) => `Not sent: ${reason}`,
|
|
28
|
+
error: "error",
|
|
29
|
+
feature: (feature) => `Feature: ${feature}`,
|
|
30
|
+
noDesigns: "No designs yet. Run /gentle:design with a brief to create one.",
|
|
31
|
+
cannotShow: (slug, reason) => `Design "${slug}" cannot be shown: ${reason}`,
|
|
32
|
+
invalidManifest: (slug) => `design.json for ${slug} is invalid`,
|
|
33
|
+
noArtboards: "This design has no artboards yet.",
|
|
34
|
+
cannotList: (reason) => `Designs cannot be listed: ${reason}`,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export function init(ctx) {
|
|
38
|
+
const { win, doc, els, store, api, ui, actions } = ctx;
|
|
39
|
+
const { state } = store;
|
|
40
|
+
const { base, fileUrl, getJson, postJson, isFiniteNumber } = api;
|
|
41
|
+
const { setStatus, showToast } = ui;
|
|
42
|
+
const T = ctx.i18n.text("boards", TEXT);
|
|
43
|
+
// What relabel rewrites: each board's own labels, the empty notice shown (a function of the language) and the invalid designs' options.
|
|
44
|
+
const labelers = new WeakMap();
|
|
45
|
+
let emptyText = null;
|
|
46
|
+
let invalidOptions = [];
|
|
47
|
+
|
|
48
|
+
/** text: the notice, as a function so a new language writes it again. */
|
|
49
|
+
function showEmpty(text) {
|
|
50
|
+
actions.exitFocus();
|
|
51
|
+
els.world.replaceChildren();
|
|
52
|
+
store.setDesign({ boards: [] });
|
|
53
|
+
actions.hideGoneInspector();
|
|
54
|
+
actions.refreshChecks();
|
|
55
|
+
actions.clearLayout();
|
|
56
|
+
actions.renderMinimap();
|
|
57
|
+
emptyText = text;
|
|
58
|
+
els.empty.textContent = text();
|
|
59
|
+
els.empty.hidden = false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function renderDesignOptions(designs) {
|
|
63
|
+
invalidOptions = [];
|
|
64
|
+
const options = designs.map((design) => {
|
|
65
|
+
const option = doc.createElement("option");
|
|
66
|
+
option.value = design.slug;
|
|
67
|
+
option.textContent = design.valid ? design.title : T.invalidDesign(design.slug);
|
|
68
|
+
if (!design.valid) invalidOptions.push([option, design.slug]);
|
|
69
|
+
return option;
|
|
70
|
+
});
|
|
71
|
+
els.design.replaceChildren(...options);
|
|
72
|
+
store.setDesign({ designCount: designs.length });
|
|
73
|
+
els.design.disabled = designs.length === 0 || Boolean(state.focus);
|
|
74
|
+
els.designField.hidden = designs.length === 0;
|
|
75
|
+
if (state.slug) els.design.value = state.slug;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** pickLatest: with no design selected, select the most recent one (not for the system-only view). */
|
|
79
|
+
async function refreshDesigns(pickLatest = true) {
|
|
80
|
+
const { designs } = await getJson("api/designs");
|
|
81
|
+
if (pickLatest && !state.slug && designs.length > 0) store.setDesign({ slug: designs[0].slug });
|
|
82
|
+
renderDesignOptions(designs);
|
|
83
|
+
return designs;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A board's frame or one of its size frames (canvas-sizes.js): comment mode never reaches the system board.
|
|
88
|
+
* `inspect`: Technical details is on, so the frame measures the hovered element for the token inspector.
|
|
89
|
+
*/
|
|
90
|
+
function sendMode(surface) {
|
|
91
|
+
surface.frame.contentWindow?.postMessage({ type: "gd:mode", enabled: state.commenting && !actions.ownerOf(surface).system, inspect: state.technical }, "*");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function boardUrl(board) {
|
|
95
|
+
return board.system ? `${base}system.html` : fileUrl(board.slug, board.artboard.file);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function createBoard(slug, artboard, system = false) {
|
|
99
|
+
const wrapper = doc.createElement("section");
|
|
100
|
+
wrapper.className = system ? "gd-artboard gd-system-board" : "gd-artboard";
|
|
101
|
+
const label = doc.createElement("div");
|
|
102
|
+
label.className = "gd-artboard-label";
|
|
103
|
+
const title = doc.createElement("h2");
|
|
104
|
+
title.className = "gd-artboard-title";
|
|
105
|
+
label.append(title);
|
|
106
|
+
const tradeoff = artboard.tradeoff ? doc.createElement("p") : null;
|
|
107
|
+
if (tradeoff) {
|
|
108
|
+
tradeoff.className = "gd-artboard-tradeoff";
|
|
109
|
+
label.append(tradeoff);
|
|
110
|
+
}
|
|
111
|
+
// The handoff state, the chosen badge and Compare (rendered by renderHandoff) stack above
|
|
112
|
+
// Implement this, at screen size, so neither covers the other at any zoom.
|
|
113
|
+
const handoff = doc.createElement("div");
|
|
114
|
+
handoff.className = "gd-handoff";
|
|
115
|
+
handoff.hidden = true;
|
|
116
|
+
let boardActions = null;
|
|
117
|
+
const implement = system ? null : createImplementControl(slug, artboard);
|
|
118
|
+
if (implement) {
|
|
119
|
+
boardActions = doc.createElement("div");
|
|
120
|
+
boardActions.className = "gd-board-actions";
|
|
121
|
+
boardActions.append(handoff, implement.box);
|
|
122
|
+
label.append(boardActions);
|
|
123
|
+
}
|
|
124
|
+
const note = system ? doc.createElement("p") : null;
|
|
125
|
+
if (note) {
|
|
126
|
+
note.className = "gd-system-note";
|
|
127
|
+
label.append(note);
|
|
128
|
+
}
|
|
129
|
+
const frame = doc.createElement("iframe");
|
|
130
|
+
frame.className = "gd-artboard-frame";
|
|
131
|
+
frame.setAttribute("sandbox", "allow-scripts");
|
|
132
|
+
frame.setAttribute("referrerpolicy", "no-referrer");
|
|
133
|
+
const box = doc.createElement("div");
|
|
134
|
+
box.className = "gd-frame-box";
|
|
135
|
+
const shield = doc.createElement("div");
|
|
136
|
+
shield.className = "gd-shield";
|
|
137
|
+
shield.setAttribute("role", "button");
|
|
138
|
+
shield.tabIndex = 0;
|
|
139
|
+
const hint = doc.createElement("span");
|
|
140
|
+
hint.className = "gd-shield-hint";
|
|
141
|
+
hint.setAttribute("aria-hidden", "true");
|
|
142
|
+
shield.append(hint);
|
|
143
|
+
// Every text of the board, written again in place for a new language (the system board's title is the canvas's).
|
|
144
|
+
const labelBoard = () => {
|
|
145
|
+
wrapper.setAttribute("aria-label", artboard.title);
|
|
146
|
+
title.textContent = artboard.title;
|
|
147
|
+
if (tradeoff) tradeoff.textContent = artboard.tradeoff;
|
|
148
|
+
if (note) {
|
|
149
|
+
label.title = T.systemNote;
|
|
150
|
+
note.title = T.systemNote;
|
|
151
|
+
note.textContent = T.systemOff;
|
|
152
|
+
}
|
|
153
|
+
frame.title = T.frameTitle(artboard.title);
|
|
154
|
+
shield.setAttribute("aria-label", system ? T.viewSystem(artboard.title) : T.use(artboard.title));
|
|
155
|
+
hint.textContent = system ? T.systemHint : T.useHint;
|
|
156
|
+
if (implement) implement.label();
|
|
157
|
+
};
|
|
158
|
+
labelBoard();
|
|
159
|
+
const pins = doc.createElement("div");
|
|
160
|
+
pins.className = "gd-pins";
|
|
161
|
+
// The Overflows chip (canvas-sizes.js) on the frame.
|
|
162
|
+
const flag = actions.overflowFlag();
|
|
163
|
+
// The size the layout places (canvas-layout.js layoutSize): the frame at its manifest size.
|
|
164
|
+
wrapper.layoutSize = { width: artboard.width, height: artboard.height };
|
|
165
|
+
// rects: null until the artboard reports where each commented element is.
|
|
166
|
+
// viewWidth and viewHeight: the frame's size, the manifest's or the focused screen size (canvas-focus.js).
|
|
167
|
+
// overflow, sizeFrames and sizesView: the page's overflow report and the All sizes frames (canvas-sizes.js).
|
|
168
|
+
// checks: the artboard's last accessibility checks, null until its frame reports them (canvas-checks.js).
|
|
169
|
+
// generation: how many sizes the frame has had, which its page tags its picks with (canvas-sizes.js resized).
|
|
170
|
+
const board = { slug, artboard, frame, wrapper, shield, pins, flag, handoff, rects: null, system, viewWidth: 0, viewHeight: 0, overflow: null, generation: 0, sizeFrames: [], sizesView: null, checks: null };
|
|
171
|
+
labelers.set(board, labelBoard);
|
|
172
|
+
actions.setFrameSize(board, artboard.width, artboard.height);
|
|
173
|
+
actions.renderHandoff(board);
|
|
174
|
+
// The ⋯ menu (export) sits beside Implement this; the system board has none.
|
|
175
|
+
if (boardActions) boardActions.append(actions.boardMenuButton(board));
|
|
176
|
+
shield.addEventListener("keydown", (event) => {
|
|
177
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
actions.enterFocus(board);
|
|
180
|
+
});
|
|
181
|
+
frame.addEventListener("load", () => {
|
|
182
|
+
actions.surfaceLoaded(board);
|
|
183
|
+
// A live reload of the focused artboard keeps focus mode and its keyboard focus.
|
|
184
|
+
if (state.focus === board && els.popover.hidden && (doc.activeElement === frame || doc.activeElement === doc.body)) frame.focus();
|
|
185
|
+
});
|
|
186
|
+
frame.src = boardUrl(board);
|
|
187
|
+
box.append(frame, shield, pins, flag);
|
|
188
|
+
wrapper.append(label, box);
|
|
189
|
+
return board;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** "Implement this" with an inline confirm step, and `label`, which writes its text; the system board never gets one. */
|
|
193
|
+
function createImplementControl(slug, artboard) {
|
|
194
|
+
const box = doc.createElement("div");
|
|
195
|
+
box.className = "gd-implement";
|
|
196
|
+
const start = doc.createElement("button");
|
|
197
|
+
start.type = "button";
|
|
198
|
+
start.className = "gd-implement-start";
|
|
199
|
+
const confirm = doc.createElement("div");
|
|
200
|
+
confirm.className = "gd-implement-confirm";
|
|
201
|
+
confirm.setAttribute("role", "group");
|
|
202
|
+
confirm.hidden = true;
|
|
203
|
+
const question = doc.createElement("span");
|
|
204
|
+
const yes = doc.createElement("button");
|
|
205
|
+
yes.type = "button";
|
|
206
|
+
yes.className = "gd-primary";
|
|
207
|
+
const no = doc.createElement("button");
|
|
208
|
+
no.type = "button";
|
|
209
|
+
const label = () => {
|
|
210
|
+
start.textContent = T.implement;
|
|
211
|
+
start.setAttribute("aria-label", T.implementAria(artboard.title));
|
|
212
|
+
confirm.setAttribute("aria-label", T.confirmAria(artboard.title));
|
|
213
|
+
question.textContent = T.question;
|
|
214
|
+
yes.textContent = T.send;
|
|
215
|
+
no.textContent = T.cancel;
|
|
216
|
+
};
|
|
217
|
+
confirm.append(question, yes, no);
|
|
218
|
+
const close = (focus) => {
|
|
219
|
+
confirm.hidden = true;
|
|
220
|
+
start.hidden = false;
|
|
221
|
+
if (focus) start.focus();
|
|
222
|
+
};
|
|
223
|
+
start.addEventListener("click", () => {
|
|
224
|
+
start.hidden = true;
|
|
225
|
+
confirm.hidden = false;
|
|
226
|
+
yes.disabled = false;
|
|
227
|
+
yes.focus();
|
|
228
|
+
});
|
|
229
|
+
no.addEventListener("click", () => close(true));
|
|
230
|
+
confirm.addEventListener("keydown", (event) => {
|
|
231
|
+
if (event.key !== "Escape") return;
|
|
232
|
+
event.preventDefault();
|
|
233
|
+
event.stopPropagation();
|
|
234
|
+
close(true);
|
|
235
|
+
});
|
|
236
|
+
yes.addEventListener("click", async () => {
|
|
237
|
+
yes.disabled = true;
|
|
238
|
+
const reply = await postJson(`api/designs/${encodeURIComponent(slug)}/implement`, { file: artboard.file }).catch((error) => ({ ok: false, body: { error: error.message } }));
|
|
239
|
+
if (reply.ok) {
|
|
240
|
+
const queued = reply.body.queued === true;
|
|
241
|
+
const text = queued ? T.queued(artboard.title) : T.sent(artboard.title);
|
|
242
|
+
setStatus(text, false);
|
|
243
|
+
showToast(text, false);
|
|
244
|
+
// The server recorded it before answering; the handoffs.json change event confirms it.
|
|
245
|
+
actions.noteHandoff(slug, artboard.file, queued);
|
|
246
|
+
} else {
|
|
247
|
+
const text = T.notSent(reply.body.reason || reply.body.error || T.error);
|
|
248
|
+
setStatus(text, true);
|
|
249
|
+
showToast(text, true);
|
|
250
|
+
}
|
|
251
|
+
close(true);
|
|
252
|
+
});
|
|
253
|
+
box.append(start, confirm);
|
|
254
|
+
return { box, label };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function showFeature(manifest) {
|
|
258
|
+
const feature = manifest && typeof manifest.feature === "string" ? manifest.feature : "";
|
|
259
|
+
els.feature.textContent = feature ? T.feature(feature) : "";
|
|
260
|
+
els.feature.hidden = !feature;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** No design selected: only the system board, or the empty notice. */
|
|
264
|
+
function showSystemOnly() {
|
|
265
|
+
store.setDesign({ manifest: null, boards: [] });
|
|
266
|
+
actions.clearLayout();
|
|
267
|
+
showFeature(null);
|
|
268
|
+
els.title.textContent = "Gentle Design";
|
|
269
|
+
if (!state.systemBoard) {
|
|
270
|
+
showEmpty(() => T.noDesigns);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
els.empty.hidden = true;
|
|
274
|
+
placeBoards();
|
|
275
|
+
setStatus("", false);
|
|
276
|
+
win.requestAnimationFrame(actions.fit);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// The latest loadManifest: an older load, of this design too, that answers after it changes nothing.
|
|
280
|
+
let loads = 0;
|
|
281
|
+
|
|
282
|
+
async function loadManifest(slug, keepView) {
|
|
283
|
+
const load = ++loads;
|
|
284
|
+
let manifest;
|
|
285
|
+
try {
|
|
286
|
+
manifest = await getJson(`api/designs/${encodeURIComponent(slug)}`);
|
|
287
|
+
} catch (error) {
|
|
288
|
+
if (load !== loads || slug !== state.slug) return;
|
|
289
|
+
showEmpty(() => T.cannotShow(slug, error.message));
|
|
290
|
+
setStatus(T.invalidManifest(slug), true);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (load !== loads || slug !== state.slug) return;
|
|
294
|
+
// Where the boards sit, before they are placed.
|
|
295
|
+
const layout = await actions.readLayoutNow(slug);
|
|
296
|
+
if (load !== loads || slug !== state.slug) return;
|
|
297
|
+
actions.takeLayout(slug, layout);
|
|
298
|
+
actions.closePopover();
|
|
299
|
+
store.setDesign({ manifest });
|
|
300
|
+
showFeature(manifest);
|
|
301
|
+
els.title.textContent = manifest.title;
|
|
302
|
+
doc.title = `${manifest.title} · Gentle Design`;
|
|
303
|
+
win.history.replaceState(null, "", `${base}d/${encodeURIComponent(slug)}/`);
|
|
304
|
+
if (manifest.artboards.length === 0 && !state.systemBoard) {
|
|
305
|
+
showEmpty(() => T.noArtboards);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
els.empty.hidden = true;
|
|
309
|
+
const focusFile = state.focus && !state.focus.system ? state.focus.artboard.file : null;
|
|
310
|
+
// The boards are built again: the old ones' All sizes frames go with them (the focused one gets new ones).
|
|
311
|
+
for (const board of state.boards) actions.removeSizeFrames(board);
|
|
312
|
+
store.setDesign({ boards: manifest.artboards.map((artboard) => createBoard(slug, artboard)) });
|
|
313
|
+
// A manifest reload keeps focus mode on the same artboard file while it still exists.
|
|
314
|
+
if (focusFile) store.setFocus({ focus: state.boards.find((board) => board.artboard.file === focusFile) ?? state.focus });
|
|
315
|
+
placeBoards();
|
|
316
|
+
if (state.focus) win.requestAnimationFrame(actions.centerFocus);
|
|
317
|
+
const warnings = Array.isArray(manifest.warnings) ? manifest.warnings.filter((warning) => typeof warning === "string") : [];
|
|
318
|
+
// A layout error that still holds (a failed save while the layout is unsaved, a failed read) stays first.
|
|
319
|
+
const layoutError = actions.layoutError();
|
|
320
|
+
const notice = warnings.length > 0 ? `design.json: ${warnings.join("; ")}` : "";
|
|
321
|
+
if (layoutError || notice) setStatus([layoutError, notice].filter(Boolean).join("; "), true);
|
|
322
|
+
else setStatus(state.boards.length === 0 ? T.noArtboards : "", false);
|
|
323
|
+
if (!keepView) win.requestAnimationFrame(actions.fit);
|
|
324
|
+
await actions.loadHandoffs();
|
|
325
|
+
await actions.loadComments();
|
|
326
|
+
await actions.loadParts();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** Reloads the artboard in its own frame and in every size frame of All sizes. */
|
|
330
|
+
function reloadBoard(board) {
|
|
331
|
+
const url = `${boardUrl(board)}?v=${Date.now()}`;
|
|
332
|
+
for (const surface of actions.surfacesOf(board)) {
|
|
333
|
+
surface.rects = null;
|
|
334
|
+
surface.frame.src = url;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** The system board first, then the design's artboards, each where the layout puts it. */
|
|
339
|
+
function placeBoards() {
|
|
340
|
+
// An open artboard menu belongs to a board this may replace.
|
|
341
|
+
actions.closeBoardMenu();
|
|
342
|
+
const boards = actions.allBoards();
|
|
343
|
+
els.world.replaceChildren(...boards.map((board) => board.wrapper));
|
|
344
|
+
// The token inspector's frame may be one this replaced, and Quality lists the boards placed now.
|
|
345
|
+
actions.hideGoneInspector();
|
|
346
|
+
actions.refreshChecks();
|
|
347
|
+
actions.layoutBoards(boards);
|
|
348
|
+
if (state.focus && !boards.includes(state.focus)) actions.exitFocus();
|
|
349
|
+
else actions.applyFocusState();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Reads api/system and creates or drops the system board; true when it appeared or went away. */
|
|
353
|
+
async function refreshSystem() {
|
|
354
|
+
let info = null;
|
|
355
|
+
try { info = await getJson("api/system"); } catch { info = null; }
|
|
356
|
+
const exists = Boolean(info && info.exists === true && isFiniteNumber(info.width) && isFiniteNumber(info.height));
|
|
357
|
+
if (exists === Boolean(state.systemBoard)) return false;
|
|
358
|
+
if (state.systemBoard) actions.removeSizeFrames(state.systemBoard);
|
|
359
|
+
// Its title and tradeoff are the canvas's, so they read in the current language.
|
|
360
|
+
const artboard = exists ? { file: String(info.file), get title() { return T.systemTitle; }, get tradeoff() { return T.systemTradeoff; }, width: info.width, height: info.height } : null;
|
|
361
|
+
store.setDesign({ systemBoard: artboard ? createBoard(null, artboard, true) : null });
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function onSystemChange() {
|
|
366
|
+
if (!(await refreshSystem())) {
|
|
367
|
+
if (state.systemBoard) reloadBoard(state.systemBoard);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (state.focus && !actions.allBoards().includes(state.focus)) actions.exitFocus();
|
|
371
|
+
if (!state.slug) {
|
|
372
|
+
showSystemOnly();
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (!state.manifest || state.manifest.slug !== state.slug) return;
|
|
376
|
+
if (state.boards.length === 0 && !state.systemBoard) showEmpty(() => T.noArtboards);
|
|
377
|
+
else {
|
|
378
|
+
els.empty.hidden = true;
|
|
379
|
+
placeBoards();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
els.design.addEventListener("change", () => {
|
|
384
|
+
actions.exitCompare(false);
|
|
385
|
+
store.setDesign({ slug: els.design.value });
|
|
386
|
+
actions.hideInspector();
|
|
387
|
+
// The old design's checks and ring go at once too.
|
|
388
|
+
actions.refreshChecks();
|
|
389
|
+
// The old design's parts go at once: loadManifest may never reach loadParts (a failed or empty design.json).
|
|
390
|
+
actions.clearParts();
|
|
391
|
+
loadManifest(state.slug, false);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* The server's show event (S14): `open` while this page is connected switches it to
|
|
396
|
+
* that design (null: the system-only view) and reloads every board from the server, so
|
|
397
|
+
* a change event this page missed is caught up. The same design refreshes in place and
|
|
398
|
+
* keeps zoom, pan and focus mode on the same artboard; another design leaves focus mode
|
|
399
|
+
* first, since its artboards differ.
|
|
400
|
+
*/
|
|
401
|
+
async function showDesign(slug) {
|
|
402
|
+
const same = slug === state.slug;
|
|
403
|
+
if (!same) {
|
|
404
|
+
actions.exitCompare(false);
|
|
405
|
+
actions.exitFocus();
|
|
406
|
+
store.setDesign({ slug });
|
|
407
|
+
actions.hideInspector();
|
|
408
|
+
actions.refreshChecks();
|
|
409
|
+
store.setComments({ comments: [], activeId: null });
|
|
410
|
+
actions.renderComments();
|
|
411
|
+
// The old design's parts go with it, before the new design's parts.json is read.
|
|
412
|
+
actions.clearParts();
|
|
413
|
+
}
|
|
414
|
+
if (!(await refreshSystem()) && state.systemBoard) reloadBoard(state.systemBoard);
|
|
415
|
+
if (slug !== state.slug) return;
|
|
416
|
+
try {
|
|
417
|
+
await refreshDesigns(false);
|
|
418
|
+
} catch (error) {
|
|
419
|
+
setStatus(T.cannotList(error.message), true);
|
|
420
|
+
}
|
|
421
|
+
if (slug !== state.slug) return;
|
|
422
|
+
if (slug === null) {
|
|
423
|
+
win.history.replaceState(null, "", base);
|
|
424
|
+
doc.title = "Gentle Design";
|
|
425
|
+
if (!same || !state.systemBoard) showSystemOnly();
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
await loadManifest(slug, same);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async function start() {
|
|
432
|
+
actions.applyView();
|
|
433
|
+
await refreshSystem();
|
|
434
|
+
try {
|
|
435
|
+
await refreshDesigns();
|
|
436
|
+
} catch (error) {
|
|
437
|
+
showEmpty(() => T.cannotList(error.message));
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (!state.slug) {
|
|
441
|
+
showSystemOnly();
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
await loadManifest(state.slug, false);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** A new language: every board's labels in place (no frame reloads), the feature line, the empty notice and the invalid designs' names. */
|
|
448
|
+
function relabel() {
|
|
449
|
+
for (const board of actions.allBoards()) labelers.get(board)?.();
|
|
450
|
+
showFeature(state.manifest);
|
|
451
|
+
if (emptyText && !els.empty.hidden) els.empty.textContent = emptyText();
|
|
452
|
+
for (const [option, slug] of invalidOptions) option.textContent = T.invalidDesign(slug);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return { refreshDesigns, sendMode, boardUrl, loadManifest, reloadBoard, onSystemChange, showDesign, start, relabel };
|
|
456
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Gentle Design canvas: artboards side by side with pan, zoom, live reload,
|
|
2
|
+
// and comments persisted in design/<slug>/comments.json (pins, list, send modes).
|
|
3
|
+
// design/system.html, when present, is the first board of every design; it is
|
|
4
|
+
// kept out of state.boards so comments never apply to it.
|
|
5
|
+
// Artboards run in iframes sandboxed with scripts only, so each one has an opaque
|
|
6
|
+
// origin; messages are trusted only by matching event.source to a known artboard.
|
|
7
|
+
// Navigation mode (the default) covers every artboard with a shield, so the wheel,
|
|
8
|
+
// drags and clicks always reach the canvas; a click on a shield enters focus mode,
|
|
9
|
+
// which shows that artboard at 100% and lets it own the pointer and the keyboard
|
|
10
|
+
// until "Back to canvas" or Shift+Esc restores the previous view.
|
|
11
|
+
// Handoffs (design/<slug>/handoffs.json) show live on each artboard's header: the
|
|
12
|
+
// handoff state, the chosen artboard and its alternatives, and, once implemented
|
|
13
|
+
// with a loopback previewUrl, a Compare view of the artboard next to the running app.
|
|
14
|
+
// Parts (design/<slug>/parts.json): Implement only this hands one element to the session
|
|
15
|
+
// without choosing a direction; Partial implementations lists them at the panel's bottom.
|
|
16
|
+
// Tokens (design/system.md): with Technical details on, Comment mode shows the token inspector
|
|
17
|
+
// beside the hovered element's frame (canvas-tokens.js).
|
|
18
|
+
// Accessibility checks: each artboard's own frame checks its page; the panel's Quality tab lists the
|
|
19
|
+
// findings, with Show (a ring on the canvas) and Ask the agent to fix (canvas-checks.js).
|
|
20
|
+
//
|
|
21
|
+
// Modules: each canvas-*.js module exports init(ctx) and returns its public
|
|
22
|
+
// functions; ctx is { win, doc, els, store, api, ui, i18n, actions }. Modules reach the
|
|
23
|
+
// browser only through ctx.win and ctx.doc, change state only through the store's
|
|
24
|
+
// mutators (canvas-store.js), and never import each other: this file is the only
|
|
25
|
+
// one that imports the others, so no module touches the DOM or window when it is
|
|
26
|
+
// imported, and the cross-module calls cannot form an import cycle.
|
|
27
|
+
//
|
|
28
|
+
// The ctx.actions rule: boot() fills ctx.actions with the functions every init
|
|
29
|
+
// returns. Actions are only complete once every `init` has returned, so no `init`
|
|
30
|
+
// may call another module's action synchronously, nor keep one by value: inside
|
|
31
|
+
// an init, pass `() => actions.fit()`, never `actions.fit` itself. Inits only
|
|
32
|
+
// define functions and register listeners; the first actions run at the end of
|
|
33
|
+
// boot().
|
|
34
|
+
//
|
|
35
|
+
// The relabel rule: ctx.i18n (canvas-i18n.js) is ready before any init. A module reads its
|
|
36
|
+
// strings through `const T = ctx.i18n.text("<module>", TEXT)`, made in its init, and may
|
|
37
|
+
// return a `relabel` function from init, which boot() keeps apart from ctx.actions. The
|
|
38
|
+
// language starts before the first action, so the first render is in it; when it changes,
|
|
39
|
+
// boot() rewrites index.html's keyed text, then runs every relabel in MODULES order. A
|
|
40
|
+
// relabel rewrites in place the text its module built (never rebuilding a board, so no
|
|
41
|
+
// artboard reloads); transient text (the status line, a toast) keeps the language it had.
|
|
42
|
+
|
|
43
|
+
import * as api from "./canvas-api.js";
|
|
44
|
+
import * as boards from "./canvas-boards.js";
|
|
45
|
+
import * as checks from "./canvas-checks.js";
|
|
46
|
+
import * as comments from "./canvas-comments.js";
|
|
47
|
+
import * as compare from "./canvas-compare.js";
|
|
48
|
+
import * as events from "./canvas-events.js";
|
|
49
|
+
import * as exporter from "./canvas-export.js";
|
|
50
|
+
import * as focus from "./canvas-focus.js";
|
|
51
|
+
import * as handoffs from "./canvas-handoffs.js";
|
|
52
|
+
import * as i18n from "./canvas-i18n.js";
|
|
53
|
+
import { ES } from "./canvas-i18n-es.js";
|
|
54
|
+
import * as layout from "./canvas-layout.js";
|
|
55
|
+
import * as menu from "./canvas-menu.js";
|
|
56
|
+
import * as messages from "./canvas-messages.js";
|
|
57
|
+
import * as minimap from "./canvas-minimap.js";
|
|
58
|
+
import * as parts from "./canvas-parts.js";
|
|
59
|
+
import * as popover from "./canvas-popover.js";
|
|
60
|
+
import * as rail from "./canvas-rail.js";
|
|
61
|
+
import * as sizes from "./canvas-sizes.js";
|
|
62
|
+
import { createStore } from "./canvas-store.js";
|
|
63
|
+
import * as tokens from "./canvas-tokens.js";
|
|
64
|
+
import * as ui from "./canvas-ui.js";
|
|
65
|
+
import * as view from "./canvas-view.js";
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The modules whose functions become ctx.actions, in their listener registration order.
|
|
69
|
+
* The rail comes before the popover: its keydown listener that takes the next key for a
|
|
70
|
+
* shortcut runs in the capture phase, ahead of the popover's Esc. The layout comes before
|
|
71
|
+
* the popover too: its Esc clears the selected artboard first, and the next Esc reaches
|
|
72
|
+
* the popover's (leave Comment mode). The checks come before the layout: their Esc clears
|
|
73
|
+
* the ring of Show before the selected artboard.
|
|
74
|
+
*/
|
|
75
|
+
const MODULES = [view, focus, boards, handoffs, parts, tokens, compare, events, comments, menu, rail, sizes, exporter, checks, layout, minimap, popover, messages];
|
|
76
|
+
|
|
77
|
+
export function boot(win, doc) {
|
|
78
|
+
const config = JSON.parse(doc.getElementById("gd-config").textContent);
|
|
79
|
+
const base = String(config.base);
|
|
80
|
+
|
|
81
|
+
const $ = (id) => doc.getElementById(id);
|
|
82
|
+
const els = {
|
|
83
|
+
title: $("gd-title"),
|
|
84
|
+
design: $("gd-design"),
|
|
85
|
+
designField: $("gd-design-field"),
|
|
86
|
+
feature: $("gd-feature"),
|
|
87
|
+
zoomOut: $("gd-zoom-out"),
|
|
88
|
+
zoomIn: $("gd-zoom-in"),
|
|
89
|
+
zoomLevel: $("gd-zoom-level"),
|
|
90
|
+
fit: $("gd-fit"),
|
|
91
|
+
arrange: { row: $("gd-arrange-row"), column: $("gd-arrange-column"), grid: $("gd-arrange-grid") },
|
|
92
|
+
device: $("gd-device"),
|
|
93
|
+
deviceIcon: $("gd-device-icon"),
|
|
94
|
+
deviceName: $("gd-device-name"),
|
|
95
|
+
deviceSize: $("gd-device-size"),
|
|
96
|
+
deviceMenu: $("gd-device-menu"),
|
|
97
|
+
sprite: $("gd-sprite"),
|
|
98
|
+
rail: $("gd-rail"),
|
|
99
|
+
toolNavigate: $("gd-tool-navigate"),
|
|
100
|
+
railFit: $("gd-rail-fit"),
|
|
101
|
+
railSettings: $("gd-rail-settings"),
|
|
102
|
+
menu: $("gd-menu"),
|
|
103
|
+
shortcuts: $("gd-shortcuts"),
|
|
104
|
+
shortcutsClose: $("gd-shortcuts-close"),
|
|
105
|
+
keysCustom: $("gd-keys-custom"),
|
|
106
|
+
keysMessage: $("gd-keys-message"),
|
|
107
|
+
keysRestore: $("gd-keys-restore"),
|
|
108
|
+
navMode: $("gd-nav-mode"),
|
|
109
|
+
back: $("gd-back"),
|
|
110
|
+
comment: $("gd-comment"),
|
|
111
|
+
status: $("gd-status"),
|
|
112
|
+
viewport: $("gd-viewport"),
|
|
113
|
+
world: $("gd-world"),
|
|
114
|
+
empty: $("gd-empty"),
|
|
115
|
+
minimap: $("gd-minimap"),
|
|
116
|
+
minimapMap: $("gd-minimap-map"),
|
|
117
|
+
minimapView: $("gd-minimap-view"),
|
|
118
|
+
minimapKey: $("gd-minimap-key"),
|
|
119
|
+
inspector: $("gd-inspector"),
|
|
120
|
+
inspectorTitle: $("gd-inspector-title"),
|
|
121
|
+
inspectorSelector: $("gd-inspector-selector"),
|
|
122
|
+
inspectorList: $("gd-inspector-list"),
|
|
123
|
+
inspectorNote: $("gd-inspector-note"),
|
|
124
|
+
inspectorFix: $("gd-inspector-fix"),
|
|
125
|
+
inspectorCopy: $("gd-inspector-copy"),
|
|
126
|
+
popover: $("gd-popover"),
|
|
127
|
+
form: $("gd-popover-form"),
|
|
128
|
+
target: $("gd-popover-target"),
|
|
129
|
+
text: $("gd-popover-text"),
|
|
130
|
+
message: $("gd-popover-message"),
|
|
131
|
+
cancel: $("gd-popover-cancel"),
|
|
132
|
+
partAdd: $("gd-popover-part"),
|
|
133
|
+
send: $("gd-popover-send"),
|
|
134
|
+
shotInput: $("gd-shot-input"),
|
|
135
|
+
shotAttach: $("gd-shot-attach"),
|
|
136
|
+
shotPreview: $("gd-shot-preview"),
|
|
137
|
+
shotImage: $("gd-shot-image"),
|
|
138
|
+
shotRemove: $("gd-shot-remove"),
|
|
139
|
+
modeSend: $("gd-mode-send"),
|
|
140
|
+
modeCollect: $("gd-mode-collect"),
|
|
141
|
+
sendAll: $("gd-send-all"),
|
|
142
|
+
panelToggle: $("gd-panel-toggle"),
|
|
143
|
+
panel: $("gd-panel"),
|
|
144
|
+
tabs: $("gd-tabs"),
|
|
145
|
+
tabComments: $("gd-tab-comments"),
|
|
146
|
+
tabQuality: $("gd-tab-quality"),
|
|
147
|
+
countComments: $("gd-count-comments"),
|
|
148
|
+
countQuality: $("gd-count-quality"),
|
|
149
|
+
tabpanelComments: $("gd-tabpanel-comments"),
|
|
150
|
+
quality: $("gd-quality"),
|
|
151
|
+
filterOpen: $("gd-filter-open"),
|
|
152
|
+
filterResolved: $("gd-filter-resolved"),
|
|
153
|
+
panelEmpty: $("gd-panel-empty"),
|
|
154
|
+
list: $("gd-comment-list"),
|
|
155
|
+
parts: $("gd-parts"),
|
|
156
|
+
partsTitle: $("gd-parts-title"),
|
|
157
|
+
partsList: $("gd-parts-list"),
|
|
158
|
+
toast: $("gd-toast"),
|
|
159
|
+
compare: $("gd-compare"),
|
|
160
|
+
compareTitle: $("gd-compare-title"),
|
|
161
|
+
compareFit: $("gd-compare-fit"),
|
|
162
|
+
compareFitField: $("gd-compare-fit-field"),
|
|
163
|
+
compareOpen: $("gd-compare-open"),
|
|
164
|
+
compareBack: $("gd-compare-back"),
|
|
165
|
+
compareMessage: $("gd-compare-message"),
|
|
166
|
+
compareStage: $("gd-compare-stage"),
|
|
167
|
+
compareSizer: $("gd-compare-sizer"),
|
|
168
|
+
comparePanes: $("gd-compare-panes"),
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const store = createStore({ slug: config.slug });
|
|
172
|
+
const actions = {};
|
|
173
|
+
const ctx = { win, doc, els, store, api: null, ui: null, i18n: null, actions };
|
|
174
|
+
ctx.api = api.init(ctx, base, config.delivery);
|
|
175
|
+
ctx.ui = ui.init(ctx);
|
|
176
|
+
const relabels = [];
|
|
177
|
+
ctx.i18n = i18n.init(ctx, ES, () => {
|
|
178
|
+
ctx.i18n.applyMarkup();
|
|
179
|
+
for (const relabel of relabels) relabel();
|
|
180
|
+
// A longer or shorter label changes the room above the focused artboard: place it again.
|
|
181
|
+
ctx.actions.centerFocus({ keepInspector: true });
|
|
182
|
+
});
|
|
183
|
+
for (const module of MODULES) {
|
|
184
|
+
const { relabel, ...functions } = module.init(ctx);
|
|
185
|
+
if (relabel) relabels.push(relabel);
|
|
186
|
+
addActions(actions, functions);
|
|
187
|
+
}
|
|
188
|
+
addActions(actions, { viewportResized });
|
|
189
|
+
Object.freeze(actions);
|
|
190
|
+
|
|
191
|
+
win.addEventListener("resize", actions.closePopover);
|
|
192
|
+
win.addEventListener("resize", actions.layoutCompare);
|
|
193
|
+
// The viewport also changes size when the comments panel opens or closes (setPanel).
|
|
194
|
+
function viewportResized() {
|
|
195
|
+
actions.centerFocus();
|
|
196
|
+
actions.refit();
|
|
197
|
+
actions.measureMinimap();
|
|
198
|
+
}
|
|
199
|
+
if (typeof win.ResizeObserver === "function") new win.ResizeObserver(viewportResized).observe(els.viewport);
|
|
200
|
+
else win.addEventListener("resize", viewportResized);
|
|
201
|
+
|
|
202
|
+
ctx.i18n.startLanguage();
|
|
203
|
+
actions.setMode(actions.storedMode());
|
|
204
|
+
actions.startRail();
|
|
205
|
+
actions.startSizes();
|
|
206
|
+
actions.startTokens();
|
|
207
|
+
actions.start();
|
|
208
|
+
actions.connectEvents();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Adds one module's functions to ctx.actions; two modules never share a name. */
|
|
212
|
+
function addActions(actions, functions) {
|
|
213
|
+
for (const [name, action] of Object.entries(functions)) {
|
|
214
|
+
if (Object.hasOwn(actions, name)) throw new Error(`canvas: ${name} is exported by two modules`);
|
|
215
|
+
actions[name] = action;
|
|
216
|
+
}
|
|
217
|
+
}
|