@1agh/maude 2.0.8 → 2.1.1
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 +2 -1
- package/apps/hub/src/project-transactions/kernel.mjs +13 -7
- package/apps/studio/access/closure.ts +86 -10
- package/apps/studio/access/filters.ts +18 -1
- package/apps/studio/access/request.ts +8 -0
- package/apps/studio/acp/design-write-verb.ts +12 -2
- package/apps/studio/acp/env.ts +7 -2
- package/apps/studio/acp/index.ts +15 -4
- package/apps/studio/acp/login-state.ts +22 -5
- package/apps/studio/acp/may-scope.ts +38 -1
- package/apps/studio/acp/plugin-bootstrap.ts +13 -1
- package/apps/studio/acp/probe.ts +11 -4
- package/apps/studio/actions/agents.ts +110 -28
- package/apps/studio/actions/canvas-keys.ts +4 -2
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/annotation.ts +84 -2
- package/apps/studio/actions/defs/app.ts +28 -1
- package/apps/studio/actions/defs/edit.ts +13 -0
- package/apps/studio/actions/defs/export.ts +12 -0
- package/apps/studio/actions/defs/sync.ts +18 -0
- package/apps/studio/actions/defs/video.ts +9 -0
- package/apps/studio/actions/documents.ts +6 -1
- package/apps/studio/actions/keymap.gen.ts +147 -9
- package/apps/studio/actions/menu.ts +5 -1
- package/apps/studio/actions/types.ts +4 -2
- package/apps/studio/actions/verbs.ts +9 -0
- package/apps/studio/actions.manifest.json +300 -45
- package/apps/studio/actions.parity.json +19 -1
- package/apps/studio/ai/save-hold.ts +2 -1
- package/apps/studio/ai/write-claim-scope.ts +7 -1
- package/apps/studio/ai/write-claim.ts +154 -3
- package/apps/studio/annotations/ai-read.ts +42 -6
- package/apps/studio/annotations/ai-write.ts +145 -2
- package/apps/studio/annotations/board-ops.ts +34 -3
- package/apps/studio/annotations/checklist-ops.ts +374 -0
- package/apps/studio/annotations/elements/checkitem.model.ts +129 -0
- package/apps/studio/annotations/elements/sticky.model.ts +54 -2
- package/apps/studio/annotations/ops.ts +30 -0
- package/apps/studio/annotations/registry.ts +9 -1
- package/apps/studio/annotations/templates.ts +4 -2
- package/apps/studio/annotations/text-steps.ts +114 -10
- package/apps/studio/annotations/ui/checklist-wire.ts +129 -0
- package/apps/studio/annotations/ui/checklist.tsx +429 -0
- package/apps/studio/annotations/ui/element-node.tsx +48 -2
- package/apps/studio/annotations/ui/template-place.ts +11 -1
- package/apps/studio/annotations/v1-adapter.ts +22 -3
- package/apps/studio/annotations-context-toolbar.tsx +12 -0
- package/apps/studio/annotations-layer.tsx +442 -49
- package/apps/studio/annotations-model.ts +4 -2
- package/apps/studio/api.ts +148 -21
- package/apps/studio/artboard-live-gate.tsx +54 -17
- package/apps/studio/artboard-still-persist.ts +166 -0
- package/apps/studio/artboard-still-raster.ts +6 -2
- package/apps/studio/artboard-still.ts +390 -20
- package/apps/studio/asset-added.ts +154 -0
- package/apps/studio/asset-details.ts +46 -3
- package/apps/studio/asset-origins.ts +5 -3
- package/apps/studio/asset-trash.ts +6 -1
- package/apps/studio/bin/_agent-browser-safe.mjs +3 -4
- package/apps/studio/bin/_annotate-post.mjs +14 -5
- package/apps/studio/bin/_audio-search.mjs +8 -2
- package/apps/studio/bin/_curl-local.mjs +7 -4
- package/apps/studio/bin/_desktop-locate.sh +145 -0
- package/apps/studio/bin/_ds-check-live.mjs +2 -1
- package/apps/studio/bin/_exports.mjs +38 -2
- package/apps/studio/bin/_history.mjs +79 -8
- package/apps/studio/bin/_import-asset.mjs +14 -9
- package/apps/studio/bin/_import-figma.mjs +510 -98
- package/apps/studio/bin/_index-cli.mjs +10 -21
- package/apps/studio/bin/_ingest-footage.mjs +24 -6
- package/apps/studio/bin/_media-probe.mjs +232 -0
- package/apps/studio/bin/_perf-probe-open.mjs +6 -0
- package/apps/studio/bin/_perf-probe-safari.mjs +6 -0
- package/apps/studio/bin/_perf-probe-studio.mjs +6 -1
- package/apps/studio/bin/_perf-probe.mjs +8 -3
- package/apps/studio/bin/_perf-sweep-shared.mjs +789 -0
- package/apps/studio/bin/_perf-sweep.mjs +240 -0
- package/apps/studio/bin/_record-shot.sh +33 -8
- package/apps/studio/bin/_screenshot-playwright.mjs +45 -2
- package/apps/studio/bin/_studio-verb.mjs +8 -3
- package/apps/studio/bin/_thumb-route.mjs +21 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +83 -1
- package/apps/studio/bin/_transcribe.mjs +22 -6
- package/apps/studio/bin/_unsynced-refs.mjs +22 -0
- package/apps/studio/bin/_url-guard.mjs +120 -5
- package/apps/studio/bin/_url-guard.sh +29 -7
- package/apps/studio/bin/_video-limits.mjs +104 -0
- package/apps/studio/bin/_video-playwright.mjs +119 -19
- package/apps/studio/bin/_video-proxy.mjs +130 -0
- package/apps/studio/bin/_write-claim.mjs +38 -16
- package/apps/studio/bin/annotate.mjs +12 -2
- package/apps/studio/bin/canvas-rects.sh +19 -4
- package/apps/studio/bin/chat-open.sh +7 -1
- package/apps/studio/bin/draw-proof.sh +6 -2
- package/apps/studio/bin/generate.sh +32 -10
- package/apps/studio/bin/handoff.sh +2 -2
- package/apps/studio/bin/perf.sh +96 -15
- package/apps/studio/bin/photo-adjust.sh +6 -3
- package/apps/studio/bin/photo-bg-remove.sh +2 -2
- package/apps/studio/bin/prep.sh +21 -4
- package/apps/studio/bin/read-annotations.mjs +3 -0
- package/apps/studio/bin/runtime-health.sh +27 -1
- package/apps/studio/bin/screenshot.sh +152 -12
- package/apps/studio/bin/server-up.sh +64 -6
- package/apps/studio/bin/smoke.sh +43 -8
- package/apps/studio/bin/to-lottie.sh +3 -2
- package/apps/studio/bin/video-proxy.sh +27 -0
- package/apps/studio/bin/visual-sanity.sh +3 -1
- package/apps/studio/bridge/dgn-protocol.ts +157 -1
- package/apps/studio/bridge/mode-shows.ts +8 -6
- package/apps/studio/bridge/still-webp.ts +233 -0
- package/apps/studio/build.ts +18 -0
- package/apps/studio/canvas-build.ts +93 -11
- package/apps/studio/canvas-comment-mount.tsx +53 -8
- package/apps/studio/canvas-edit.ts +34 -1
- package/apps/studio/canvas-lib-module.ts +210 -0
- package/apps/studio/canvas-lib.tsx +3 -12
- package/apps/studio/canvas-pipeline.ts +111 -5
- package/apps/studio/canvas-shell.tsx +8 -11
- package/apps/studio/canvas-theme-pill.tsx +5 -3
- package/apps/studio/check/index.ts +12 -5
- package/apps/studio/check/video.ts +18 -2
- package/apps/studio/client/app.jsx +65 -7
- package/apps/studio/client/clipboard-relay.ts +193 -16
- package/apps/studio/client/comments-overlay.css +18 -0
- package/apps/studio/client/export-center.jsx +30 -0
- package/apps/studio/client/generate-dialog.jsx +49 -4
- package/apps/studio/client/github.js +7 -0
- package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
- package/apps/studio/client/home/HomeConnection.jsx +111 -0
- package/apps/studio/client/home/home-accounts-model.js +110 -1
- package/apps/studio/client/home/home-api.js +9 -2
- package/apps/studio/client/home/home-app.jsx +126 -13
- package/apps/studio/client/home/home-model.js +69 -1
- package/apps/studio/client/home/home-where-model.js +105 -0
- package/apps/studio/client/home/home.css +239 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +173 -98
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +5 -1
- package/apps/studio/client/hooks/use-tabs.jsx +11 -4
- package/apps/studio/client/panels/DiffView.jsx +7 -1
- package/apps/studio/client/panels/TeamProjects.jsx +137 -134
- package/apps/studio/client/panels/chat-context.js +2 -0
- package/apps/studio/client/panels/slash-commands.gen.js +13 -13
- package/apps/studio/client/selection-scope.js +16 -9
- package/apps/studio/client/share-link.js +12 -0
- package/apps/studio/client/shell/viewport.jsx +11 -1
- package/apps/studio/client/shell-events.js +8 -0
- package/apps/studio/client/styles/3-kit-maude-v2.css +16 -0
- package/apps/studio/client/styles/_index.css +4 -0
- package/apps/studio/client/v2/ai/Feed.jsx +1 -1
- package/apps/studio/client/v2/ai/OfferCard.jsx +34 -0
- package/apps/studio/client/v2/ai/activity-line.js +54 -1
- package/apps/studio/client/v2/ai/ai-offer.js +21 -1
- package/apps/studio/client/v2/ai/run-model.js +3 -1
- package/apps/studio/client/v2/annotations/vote-store.js +28 -4
- package/apps/studio/client/v2/assets/asset-drop-session.js +37 -2
- package/apps/studio/client/v2/assets/canvas-drop-catcher.jsx +7 -5
- package/apps/studio/client/v2/assets/details-model.js +1 -1
- package/apps/studio/client/v2/assets/details.jsx +5 -0
- package/apps/studio/client/v2/assets/tile-drag.js +11 -7
- package/apps/studio/client/v2/comments/comments-panel.jsx +22 -3
- package/apps/studio/client/v2/create/duplicate-done.js +6 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
- package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
- package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +113 -3
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +343 -6
- package/apps/studio/client/v2/diagnostics/sync-details/unsynced-refs.js +55 -0
- package/apps/studio/client/v2/ds/review.css +1 -1
- package/apps/studio/client/v2/export/exports-model.js +7 -0
- package/apps/studio/client/v2/export/exports-panel.jsx +1 -0
- package/apps/studio/client/v2/export/job-row.jsx +32 -2
- package/apps/studio/client/v2/handoff/ready-card.jsx +1 -1
- package/apps/studio/client/v2/history/compare-view.jsx +1 -0
- package/apps/studio/client/v2/inspector/css-write.js +6 -1
- package/apps/studio/client/v2/inspector/frame.jsx +28 -4
- package/apps/studio/client/v2/inspector/kinds/clip-model.js +51 -0
- package/apps/studio/client/v2/inspector/kinds/clip.jsx +75 -2
- package/apps/studio/client/v2/inspector/model.js +21 -0
- package/apps/studio/client/v2/inspector/sections/fill.jsx +12 -3
- package/apps/studio/client/v2/inspector/sections/recent-colours.js +8 -5
- package/apps/studio/client/v2/inspector/view-mode.jsx +11 -1
- package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
- package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
- package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
- package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
- package/apps/studio/client/v2/link-server/link-server.css +109 -0
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
- package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
- package/apps/studio/client/v2/preview/link-follow.js +4 -2
- package/apps/studio/client/v2/preview/preview-chrome-host.jsx +16 -6
- package/apps/studio/client/v2/search/help-model.js +2 -0
- package/apps/studio/client/v2/search/search-keywords.js +3 -2
- package/apps/studio/client/v2/settings/account.jsx +4 -2
- package/apps/studio/client/v2/settings/advanced-section.jsx +344 -137
- package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
- package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
- package/apps/studio/client/v2/settings/general-section.jsx +155 -24
- package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
- package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
- package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
- package/apps/studio/client/v2/settings/settings-cards.js +220 -0
- package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
- package/apps/studio/client/v2/settings/settings-model.js +100 -31
- package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
- package/apps/studio/client/v2/settings/settings.css +374 -64
- package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
- package/apps/studio/client/v2/settings/this-project-model.js +172 -0
- package/apps/studio/client/v2/settings/use-connections.js +3 -2
- package/apps/studio/client/v2/settings/use-open-card.js +37 -0
- package/apps/studio/client/v2/share/share-sheet.jsx +28 -11
- package/apps/studio/client/v2/shell/api-session-boot.js +6 -0
- package/apps/studio/client/v2/shell/api-session.js +126 -0
- package/apps/studio/client/v2/shell/connection-state.js +197 -0
- package/apps/studio/client/v2/shell/floating-panels.css +31 -1
- package/apps/studio/client/v2/shell/image-pick.js +61 -8
- package/apps/studio/client/v2/shell/menu-aim.js +43 -0
- package/apps/studio/client/v2/shell/menu-runner.js +25 -7
- package/apps/studio/client/v2/shell/occlusion-insets.js +18 -1
- package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
- package/apps/studio/client/v2/shell/project-account-model.js +272 -149
- package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
- package/apps/studio/client/v2/shell/project-account.css +237 -0
- package/apps/studio/client/v2/shell/project-pill.jsx +52 -6
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
- package/apps/studio/client/v2/shell/shell-parity.js +3 -2
- package/apps/studio/client/v2/shell/shell-parity.json +71 -36
- package/apps/studio/client/v2/shell/still-bridge.js +194 -0
- package/apps/studio/client/v2/shell/still-store.js +319 -0
- package/apps/studio/client/v2/shell/use-account.js +2 -0
- package/apps/studio/client/v2/shell/use-tool-panels.js +2 -1
- package/apps/studio/client/v2/signin/use-signin.js +1 -1
- package/apps/studio/client/v2/timeline/Timeline.jsx +15 -0
- package/apps/studio/client/v2/timeline/frame-handle-model.js +142 -0
- package/apps/studio/client/v2/timeline/frame-handle.jsx +151 -0
- package/apps/studio/clip-ops.ts +126 -8
- package/apps/studio/cloud/endpoints.ts +29 -4
- package/apps/studio/collab/ai-activity.ts +10 -8
- package/apps/studio/collab/awareness-bridge.ts +34 -9
- package/apps/studio/collab/index.ts +3 -0
- package/apps/studio/collab/registry.ts +41 -10
- package/apps/studio/comment-reattach.ts +149 -0
- package/apps/studio/comments/mine-stamp.ts +15 -7
- package/apps/studio/comments/ops.ts +52 -8
- package/apps/studio/comments-overlay.tsx +146 -9
- package/apps/studio/dist/client.bundle.js +892 -885
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/dom-selection.ts +87 -18
- package/apps/studio/ds/board/directions.css +8 -0
- package/apps/studio/ds/board/outline.tsx +16 -0
- package/apps/studio/ds/canvas-check.ts +6 -0
- package/apps/studio/edit-ops/clip/reframe.ts +19 -3
- package/apps/studio/edit-ops/clip-carry.ts +602 -0
- package/apps/studio/edit-ops/clipboard.ts +318 -23
- package/apps/studio/edit-ops/dispatch.ts +20 -2
- package/apps/studio/edit-ops/scope-names.ts +249 -40
- package/apps/studio/edit-ops/slot-defaults.ts +3 -0
- package/apps/studio/edit-ops/types.ts +6 -0
- package/apps/studio/editing/align-bar.tsx +33 -9
- package/apps/studio/editing/artboard-actions.ts +5 -0
- package/apps/studio/editing/artboard-menu.tsx +6 -2
- package/apps/studio/editing/click-to-type.ts +1 -1
- package/apps/studio/editing/clip-words.ts +48 -0
- package/apps/studio/editing/clipboard.ts +21 -6
- package/apps/studio/editing/declared-background.ts +25 -0
- package/apps/studio/editing/index.tsx +3 -0
- package/apps/studio/editing/object-keys.ts +4 -4
- package/apps/studio/editing/object-menu.tsx +13 -3
- package/apps/studio/editing/pen/points.tsx +61 -0
- package/apps/studio/editing/text-in-place.tsx +11 -0
- package/apps/studio/editing/video-frame-handle.tsx +425 -0
- package/apps/studio/exporters/capture-prepass.ts +374 -0
- package/apps/studio/exporters/degraded.ts +148 -0
- package/apps/studio/exporters/hub-render-door.ts +28 -2
- package/apps/studio/exporters/index.ts +3 -1
- package/apps/studio/exporters/job-budget.ts +93 -0
- package/apps/studio/exporters/jobs.ts +215 -28
- package/apps/studio/exporters/parity-check.ts +254 -0
- package/apps/studio/exporters/remote.ts +209 -15
- package/apps/studio/exporters/svg-inline.ts +87 -0
- package/apps/studio/exporters/video-render-lib.ts +88 -26
- package/apps/studio/exporters/video.ts +29 -6
- package/apps/studio/figma/assets.ts +58 -43
- package/apps/studio/figma/codegen-fonts.ts +100 -0
- package/apps/studio/figma/fig-decode.ts +390 -25
- package/apps/studio/figma/fig-kiwi.ts +18 -4
- package/apps/studio/figma/fig-vector.ts +59 -3
- package/apps/studio/figma/sanitize.ts +2 -0
- package/apps/studio/figma/style-map.ts +293 -48
- package/apps/studio/figma/to-artboard.ts +455 -69
- package/apps/studio/figma/to-strokes.ts +44 -11
- package/apps/studio/figma/types.ts +13 -0
- package/apps/studio/footage/schema.ts +3 -3
- package/apps/studio/generation/adapters/elevenlabs.ts +7 -1
- package/apps/studio/generation/adapters/groq.ts +8 -1
- package/apps/studio/generation/spend.ts +312 -0
- package/apps/studio/generation/types.ts +12 -0
- package/apps/studio/handoff/run.ts +1 -1
- package/apps/studio/handoff/targets.ts +2 -2
- package/apps/studio/handoff/write-scopes.ts +1 -1
- package/apps/studio/history/describe-annotations.ts +4 -0
- package/apps/studio/home/accounts.ts +30 -11
- package/apps/studio/home/cloud.ts +6 -1
- package/apps/studio/home/create-local.ts +32 -3
- package/apps/studio/home/hub-health.ts +76 -0
- package/apps/studio/home/routes.ts +15 -4
- package/apps/studio/http.ts +438 -86
- package/apps/studio/imported-module-ids.ts +91 -0
- package/apps/studio/inspect.ts +2 -0
- package/apps/studio/migrate/hub.ts +8 -1
- package/apps/studio/notifications.tsx +47 -5
- package/apps/studio/paths.ts +10 -1
- package/apps/studio/port.ts +3 -2
- package/apps/studio/preview/preview-camera.tsx +15 -382
- package/apps/studio/readiness.ts +10 -1
- package/apps/studio/release-build.ts +51 -0
- package/apps/studio/routes/agent.ts +188 -9
- package/apps/studio/routes/ai.ts +43 -11
- package/apps/studio/routes/annotations.ts +27 -1
- package/apps/studio/routes/assets.ts +18 -1
- package/apps/studio/routes/canvas-origin.ts +12 -9
- package/apps/studio/routes/cloud-move.ts +15 -0
- package/apps/studio/routes/edit.ts +3 -0
- package/apps/studio/routes/export.ts +51 -0
- package/apps/studio/routes/generate.ts +42 -12
- package/apps/studio/routes/hub-link-folder.ts +334 -0
- package/apps/studio/routes/hub-signin.ts +78 -1
- package/apps/studio/routes/index.ts +9 -1
- package/apps/studio/routes/shell.ts +217 -5
- package/apps/studio/routes/sync.ts +136 -8
- package/apps/studio/routes/votes.ts +2 -1
- package/apps/studio/schema/annotations.v2.schema.json +143 -1
- package/apps/studio/schema/beats.v1.schema.json +1 -1
- package/apps/studio/schema/edl.v1.schema.json +1 -1
- package/apps/studio/schema/formats.ts +3 -3
- package/apps/studio/schema/transcript.v1.schema.json +1 -1
- package/apps/studio/server.ts +142 -43
- package/apps/studio/shell/api-key.ts +503 -0
- package/apps/studio/shell/attest.ts +59 -0
- package/apps/studio/shell/capture-url.ts +20 -0
- package/apps/studio/shell/cli-yield.ts +276 -0
- package/apps/studio/shell/clip-transfer.ts +302 -0
- package/apps/studio/shell/key-file.ts +108 -0
- package/apps/studio/shell/server-json.ts +75 -0
- package/apps/studio/shell/worktree.ts +19 -0
- package/apps/studio/spoof-chars.ts +9 -0
- package/apps/studio/studio-page-host.ts +1 -1
- package/apps/studio/sync/accepted-cold-start.ts +144 -8
- package/apps/studio/sync/accepted-link.ts +76 -29
- package/apps/studio/sync/action-stage.ts +575 -44
- package/apps/studio/sync/adopt-held.ts +85 -0
- package/apps/studio/sync/ctl-heal.ts +58 -0
- package/apps/studio/sync/file-ledger.ts +38 -4
- package/apps/studio/sync/file-membership.ts +16 -1
- package/apps/studio/sync/file-plane.ts +289 -22
- package/apps/studio/sync/held-deletes.ts +86 -5
- package/apps/studio/sync/hub-link.ts +8 -0
- package/apps/studio/sync/index.ts +196 -12
- package/apps/studio/sync/journal-client.ts +50 -4
- package/apps/studio/sync/link-consent.ts +22 -75
- package/apps/studio/sync/link-survey.ts +252 -0
- package/apps/studio/sync/local-kernel.ts +296 -8
- package/apps/studio/sync/projection.ts +22 -3
- package/apps/studio/sync/seed-progress.ts +12 -0
- package/apps/studio/sync/source-recovery.ts +59 -3
- package/apps/studio/sync/status.ts +19 -2
- package/apps/studio/sync/unsynced-refs.ts +397 -0
- package/apps/studio/sync/writer-registry.ts +20 -0
- package/apps/studio/thumbs/service.ts +4 -1
- package/apps/studio/tool-palette.tsx +23 -0
- package/apps/studio/ui-prefs.ts +40 -0
- package/apps/studio/use-agent-presence.tsx +2 -2
- package/apps/studio/use-canvas-keys.ts +6 -1
- package/apps/studio/video/format-ids.ts +2 -2
- package/apps/studio/video/inject.ts +31 -0
- package/apps/studio/video/media-risk.ts +58 -0
- package/apps/studio/video/object-fit.ts +137 -0
- package/apps/studio/video/provider-transcript.ts +141 -0
- package/apps/studio/whats-new.json +137 -0
- package/apps/studio/workspace-mode.ts +1 -0
- package/apps/studio/ws.ts +5 -0
- package/cli/commands/design.mjs +119 -8
- package/cli/lib/bash-guard.mjs +366 -6
- package/cli/lib/confine-read.mjs +1 -0
- package/cli/lib/design-help.gen.mjs +3 -2
- package/cli/lib/design-hook.mjs +387 -81
- package/cli/lib/design-link.mjs +16 -1
- package/cli/lib/design-open.mjs +49 -3
- package/cli/lib/desktop-locate.mjs +770 -0
- package/cli/lib/handoff.mjs +1 -1
- package/cli/lib/hook-state.mjs +291 -0
- package/cli/lib/pkg-root.mjs +65 -13
- package/cli/lib/studio-locate.mjs +59 -16
- package/package.json +15 -8
- package/plugins/design/templates/_shell.html +13 -0
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
- package/apps/studio/client/v2/shell/account-card-model.js +0 -114
- package/apps/studio/client/v2/shell/account-card.jsx +0 -189
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// client/v2/settings/this-project-model.js — 2.1.1 T6: Settings › General › This project (canvas 17 · 08 · 09).
|
|
2
|
+
//
|
|
3
|
+
// PURE (no DOM, no React, no fetch). The card says three things about THIS project — where it lives, which
|
|
4
|
+
// account it uses, whether it connects — and carries the one fix in its header when a sign-in broke:
|
|
5
|
+
//
|
|
6
|
+
// This project Brand site
|
|
7
|
+
// Your folder · ~/git/brand-site · also on Maude Cloud
|
|
8
|
+
// ● Connected · synced 2 min ago
|
|
9
|
+
// Lives in [Your folder ~/git/brand-site] Change…
|
|
10
|
+
// Account alice@example.com Switch…
|
|
11
|
+
// Connection ● Connected · synced 2 min ago
|
|
12
|
+
// › Sync details Project files · trash · first link
|
|
13
|
+
//
|
|
14
|
+
// The connection is the shell's one model (shell/connection-state.js, 2.1.1 T2): the same seven states and
|
|
15
|
+
// words the avatar, the save word and the toast say. Where it lives is `/_api/cloud/status` `place`
|
|
16
|
+
// (`{ kept: true }` for a copy Maude keeps, else `{ kept: false, folder }` with home as `~`).
|
|
17
|
+
|
|
18
|
+
import { syncPresentation } from '../../../sync/presentation.ts';
|
|
19
|
+
import { connectionState, connectionWords } from '../shell/connection-state.js';
|
|
20
|
+
|
|
21
|
+
/** The status dot per state (canvas 17 `StatusWord`: ok · busy · off · error · warn). */
|
|
22
|
+
const DOT = Object.freeze({
|
|
23
|
+
connected: 'ok',
|
|
24
|
+
syncing: 'busy',
|
|
25
|
+
offline: 'off',
|
|
26
|
+
'signin-missing': 'error',
|
|
27
|
+
'signin-rejected': 'error',
|
|
28
|
+
unreachable: 'warn',
|
|
29
|
+
unconfirmed: 'off',
|
|
30
|
+
local: 'off',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
|
|
34
|
+
|
|
35
|
+
/** "synced just now" · "synced 2 min ago" · "synced at 14:05" · null. */
|
|
36
|
+
export function syncedWords(ms, now = Date.now()) {
|
|
37
|
+
if (!Number.isFinite(ms) || ms <= 0) return null;
|
|
38
|
+
const age = Math.max(0, now - ms);
|
|
39
|
+
if (age < 60_000) return 'synced just now';
|
|
40
|
+
if (age < 60 * 60_000) return `synced ${Math.floor(age / 60_000)} min ago`;
|
|
41
|
+
const d = new Date(ms);
|
|
42
|
+
return `synced at ${d.getHours()}:${String(d.getMinutes()).padStart(2, '0')}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The card's status line for a connection (the header line and the Connection row say the same). */
|
|
46
|
+
export function statusLine(conn, { syncStatus = null, pending = 0, now = Date.now() } = {}) {
|
|
47
|
+
const w = connectionWords(conn, { pending });
|
|
48
|
+
switch (conn.state) {
|
|
49
|
+
case 'connected': {
|
|
50
|
+
const synced = syncedWords(syncStatus?.lastSyncAt, now);
|
|
51
|
+
return synced ? `Connected · ${synced}` : 'Connected';
|
|
52
|
+
}
|
|
53
|
+
case 'syncing':
|
|
54
|
+
return w.line;
|
|
55
|
+
default:
|
|
56
|
+
return w.word;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The whole card.
|
|
62
|
+
* @param in.status `/_api/cloud/status` json (`connected`, `email`, `url`, `project`, `linkedHub`, `place`)
|
|
63
|
+
* @param in.syncStatus the shell's sync payload
|
|
64
|
+
* @param in.hubAccount the team-server sign-in's recorded account (`/_api/connections/hub` `account`)
|
|
65
|
+
* @param in.native the desktop app (Show in Finder is the Mac app's door)
|
|
66
|
+
*/
|
|
67
|
+
export function thisProjectModel({
|
|
68
|
+
status = null,
|
|
69
|
+
syncStatus = null,
|
|
70
|
+
hubAccount = null,
|
|
71
|
+
online = true,
|
|
72
|
+
native = false,
|
|
73
|
+
now = Date.now(),
|
|
74
|
+
} = {}) {
|
|
75
|
+
const linkedHub = status?.linkedHub?.url ? status.linkedHub : null;
|
|
76
|
+
const pending = Number(syncStatus?.queuedOps) || Number(syncStatus?.docs?.pending) || 0;
|
|
77
|
+
const conn = connectionState({
|
|
78
|
+
linkedHub,
|
|
79
|
+
cloudUrl: status?.url ?? '',
|
|
80
|
+
syncStatus,
|
|
81
|
+
phase: syncPresentation(syncStatus ?? null)?.phase ?? null,
|
|
82
|
+
pending,
|
|
83
|
+
online,
|
|
84
|
+
});
|
|
85
|
+
const words = connectionWords(conn, { pending });
|
|
86
|
+
const host = conn.host ?? '';
|
|
87
|
+
const linkKind = conn.kind === 'local' ? null : conn.kind;
|
|
88
|
+
const kept = status?.place?.kept === true;
|
|
89
|
+
const folder = !kept ? (str(status?.place?.folder) ?? '') : '';
|
|
90
|
+
|
|
91
|
+
// Lives in: the person's folder, or a copy Maude keeps — of a server project it reads "On <host>".
|
|
92
|
+
let place;
|
|
93
|
+
if (kept && linkKind === 'server') place = { kind: 'server', label: `On ${host}`, path: '' };
|
|
94
|
+
else if (kept) place = { kind: 'kept', label: 'Kept by Maude', path: '' };
|
|
95
|
+
else place = { kind: 'folder', label: 'Your folder', path: folder };
|
|
96
|
+
|
|
97
|
+
const where = place.kind === 'folder' && folder ? `Your folder · ${folder}` : place.label;
|
|
98
|
+
let desc;
|
|
99
|
+
if (place.kind === 'server') desc = `${where} · copy kept by Maude`;
|
|
100
|
+
else if (linkKind === 'cloud') desc = `${where} · also on Maude Cloud`;
|
|
101
|
+
else if (linkKind === 'server') desc = `${where} · also on ${host}`;
|
|
102
|
+
else desc = `${where} · only on this Mac`;
|
|
103
|
+
|
|
104
|
+
// Account: who this project talks as — never a token, only the name the page already holds.
|
|
105
|
+
let account;
|
|
106
|
+
if (linkKind === 'cloud')
|
|
107
|
+
account = { kind: 'cloud', label: str(status?.email) ?? 'Maude Cloud', host };
|
|
108
|
+
else if (linkKind === 'server')
|
|
109
|
+
account = { kind: 'server', label: str(hubAccount) ?? host, host };
|
|
110
|
+
else account = { kind: 'local', label: 'No account', host: '' };
|
|
111
|
+
|
|
112
|
+
const bad = conn.state === 'signin-missing' || conn.state === 'signin-rejected';
|
|
113
|
+
const where2 = linkKind === 'cloud' ? 'Maude Cloud' : host || 'the server';
|
|
114
|
+
const callout =
|
|
115
|
+
conn.state === 'signin-rejected'
|
|
116
|
+
? {
|
|
117
|
+
title: `Your sign-in to ${where2} stopped working.`,
|
|
118
|
+
line: 'Changes wait on this Mac and go out after you sign in.',
|
|
119
|
+
}
|
|
120
|
+
: conn.state === 'signin-missing'
|
|
121
|
+
? {
|
|
122
|
+
title: `This project is on ${where2} — sign in to sync.`,
|
|
123
|
+
line: 'Changes wait on this Mac and go out after you sign in.',
|
|
124
|
+
}
|
|
125
|
+
: null;
|
|
126
|
+
|
|
127
|
+
// Change…: only what this Mac can do today. Moving a project between the person's folder and a copy
|
|
128
|
+
// Maude keeps has no backend yet, so those rows are listed as unavailable and never drawn.
|
|
129
|
+
const changeOptions = [
|
|
130
|
+
{
|
|
131
|
+
id: 'folder',
|
|
132
|
+
label: 'Your folder',
|
|
133
|
+
detail: place.kind === 'folder' ? folder : '',
|
|
134
|
+
current: place.kind === 'folder',
|
|
135
|
+
available: place.kind === 'folder',
|
|
136
|
+
},
|
|
137
|
+
{ id: 'another-folder', label: 'Use another folder…', current: false, available: false },
|
|
138
|
+
{
|
|
139
|
+
id: 'kept',
|
|
140
|
+
label: 'Let Maude keep it',
|
|
141
|
+
detail: 'no path',
|
|
142
|
+
current: place.kind !== 'folder',
|
|
143
|
+
available: place.kind !== 'folder',
|
|
144
|
+
},
|
|
145
|
+
{ id: 'finder', label: 'Show in Finder', current: false, available: !!native },
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
name: str(status?.project) ?? 'this project',
|
|
150
|
+
conn,
|
|
151
|
+
statusWord: statusLine(conn, { syncStatus, pending, now }),
|
|
152
|
+
sw: DOT[conn.state] ?? 'off',
|
|
153
|
+
bad,
|
|
154
|
+
fixLabel: bad ? (words.fix?.label ?? 'Sign in') : null,
|
|
155
|
+
callout,
|
|
156
|
+
place,
|
|
157
|
+
desc,
|
|
158
|
+
account,
|
|
159
|
+
linkKind,
|
|
160
|
+
// an address this Mac never confirmed is never handed to a sign-in (2.1.1 T8): Review… instead
|
|
161
|
+
unconfirmed:
|
|
162
|
+
conn.state === 'unconfirmed'
|
|
163
|
+
? { line: words.line, label: words.fix?.label ?? 'Review…' }
|
|
164
|
+
: null,
|
|
165
|
+
hubUrl: conn.state === 'unconfirmed' ? null : (linkedHub?.url ?? null),
|
|
166
|
+
host,
|
|
167
|
+
local: conn.state === 'local',
|
|
168
|
+
changeOptions,
|
|
169
|
+
// the menu is drawn only when it has something to do beyond saying where the project is
|
|
170
|
+
canChange: changeOptions.some((o) => o.available && !o.current),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -50,7 +50,8 @@ export function useCloudConnection({ onLinkedHub, onLocalProject, syncStatus } =
|
|
|
50
50
|
const [email, setEmail] = useState(null);
|
|
51
51
|
// The address this Mac signs in against (`status.url`) — never a hard-coded vendor URL.
|
|
52
52
|
const [cloudUrl, setCloudUrl] = useState('');
|
|
53
|
-
|
|
53
|
+
// `place` (2.1.1 T2): `{ kept: true }` or `{ kept: false, folder }` — where this project lives
|
|
54
|
+
const [local, setLocal] = useState({ project: '', linkedHub: null, place: null });
|
|
54
55
|
const [projects, setProjects] = useState(null);
|
|
55
56
|
const [busy, setBusy] = useState('');
|
|
56
57
|
const [error, setError] = useState('');
|
|
@@ -76,7 +77,7 @@ export function useCloudConnection({ onLinkedHub, onLocalProject, syncStatus } =
|
|
|
76
77
|
const r = await api('/_api/cloud/status');
|
|
77
78
|
if (r.json?.url) setCloudUrl(r.json.url);
|
|
78
79
|
const linkedHub = r.json?.linkedHub ?? null;
|
|
79
|
-
setLocal({ project: r.json?.project ?? '', linkedHub });
|
|
80
|
+
setLocal({ project: r.json?.project ?? '', linkedHub, place: r.json?.place ?? null });
|
|
80
81
|
liftRef.current.onLinkedHub?.(linkedHub);
|
|
81
82
|
liftRef.current.onLocalProject?.(r.json?.project ?? null);
|
|
82
83
|
if (r.ok && r.json?.connected) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// client/v2/settings/use-open-card.js — 2.1.1 T6: which card of a Settings tab is open (one at a time),
|
|
2
|
+
// remembered per tab for this session (settings-cards.js). `focus` is ⌘K's ask — `{ card, n }`, a new `n`
|
|
3
|
+
// each time — and opens the card that holds the hit even when the person had closed it.
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { openCardOf, readOpenCards, toggleCard, writeOpenCard } from './settings-cards.js';
|
|
8
|
+
|
|
9
|
+
export function useOpenCard(tab, focus = null) {
|
|
10
|
+
const [open, setOpen] = useState(() => focus?.card ?? openCardOf(tab, readOpenCards()));
|
|
11
|
+
const focusCard = focus?.card ?? null;
|
|
12
|
+
const focusN = focus?.n ?? 0;
|
|
13
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new ask (`n`) re-opens the same card
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!focusCard) return;
|
|
16
|
+
setOpen(focusCard);
|
|
17
|
+
writeOpenCard(tab, focusCard);
|
|
18
|
+
}, [tab, focusCard, focusN]);
|
|
19
|
+
const toggle = useCallback(
|
|
20
|
+
(id) =>
|
|
21
|
+
setOpen((cur) => {
|
|
22
|
+
const next = toggleCard(cur, id);
|
|
23
|
+
writeOpenCard(tab, next);
|
|
24
|
+
return next;
|
|
25
|
+
}),
|
|
26
|
+
[tab]
|
|
27
|
+
);
|
|
28
|
+
/** Open `id` (a header action that needs its card's body, e.g. Manage…). */
|
|
29
|
+
const show = useCallback(
|
|
30
|
+
(id) => {
|
|
31
|
+
setOpen(id);
|
|
32
|
+
writeOpenCard(tab, id);
|
|
33
|
+
},
|
|
34
|
+
[tab]
|
|
35
|
+
);
|
|
36
|
+
return { open, toggle, show };
|
|
37
|
+
}
|
|
@@ -128,6 +128,8 @@ export function ShareSheet({
|
|
|
128
128
|
const [lastSynced, setLastSynced] = useState(null);
|
|
129
129
|
// gate-b-sec4 — `{ host }` while the folder's committed link waits for this Mac's Connect
|
|
130
130
|
const [pendingLink, setPendingLink] = useState(null);
|
|
131
|
+
// #206 §5 — the main project's name when this tab is a git worktree of it: never linked, no Connect
|
|
132
|
+
const [worktreeOf, setWorktreeOf] = useState(null);
|
|
131
133
|
const emailRef = useRef(null);
|
|
132
134
|
const connectRef = useRef(null);
|
|
133
135
|
const sheetRef = useModalFocus({ onClose });
|
|
@@ -168,7 +170,10 @@ export function ShareSheet({
|
|
|
168
170
|
let live = true;
|
|
169
171
|
api.pendingLink().then((r) => {
|
|
170
172
|
const host = r?.ok ? r.body?.pending?.host : null;
|
|
171
|
-
|
|
173
|
+
const main = r?.ok ? r.body?.worktreeOf : null;
|
|
174
|
+
if (!live) return;
|
|
175
|
+
setPendingLink(typeof host === 'string' && host ? { host } : null);
|
|
176
|
+
setWorktreeOf(typeof main === 'string' && main ? main : null);
|
|
172
177
|
});
|
|
173
178
|
return () => {
|
|
174
179
|
live = false;
|
|
@@ -372,7 +377,8 @@ export function ShareSheet({
|
|
|
372
377
|
}
|
|
373
378
|
});
|
|
374
379
|
const adv = advancedView({ view, shell, hubUrl: posture?.hub });
|
|
375
|
-
const offerMove =
|
|
380
|
+
const offerMove =
|
|
381
|
+
posture && !view.linked && shell === 'native' && !moving && !pendingLink && !worktreeOf;
|
|
376
382
|
|
|
377
383
|
const rows = peopleRows(people, { youEmail, now });
|
|
378
384
|
const team = canvas ? teamRow(people, projectPeople, project) : null;
|
|
@@ -429,6 +435,11 @@ export function ShareSheet({
|
|
|
429
435
|
{movingWords(moving.state)}
|
|
430
436
|
</p>
|
|
431
437
|
)}
|
|
438
|
+
{posture && !view.linked && worktreeOf && (
|
|
439
|
+
<p className="v2sh-hint" data-testid="share-worktree-syncs-from">
|
|
440
|
+
Syncs from {worktreeOf}
|
|
441
|
+
</p>
|
|
442
|
+
)}
|
|
432
443
|
{posture && !view.linked && pendingLink && (
|
|
433
444
|
<div className="v2sh-arow v2sh-arow--stack" data-testid="share-link-unconfirmed">
|
|
434
445
|
<p className="v2sh-hint">
|
|
@@ -447,15 +458,21 @@ export function ShareSheet({
|
|
|
447
458
|
</div>
|
|
448
459
|
)}
|
|
449
460
|
{/* a cloud tab is never a "local project": it IS the workspace, so this line has no true form there (rc3-i) */}
|
|
450
|
-
{posture &&
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
461
|
+
{posture &&
|
|
462
|
+
!view.linked &&
|
|
463
|
+
!offerMove &&
|
|
464
|
+
!moving &&
|
|
465
|
+
!pendingLink &&
|
|
466
|
+
!worktreeOf &&
|
|
467
|
+
shell !== 'cloud' && (
|
|
468
|
+
<div className="v2sh-arow v2sh-arow--stack">
|
|
469
|
+
<p className="v2sh-hint" data-testid="share-local-note">
|
|
470
|
+
Local project — kept on this Mac. To invite people, move it to Maude Cloud in the
|
|
471
|
+
Maude app.
|
|
472
|
+
</p>
|
|
473
|
+
<ExportInstead onExport={onExport && (() => onExport())} />
|
|
474
|
+
</div>
|
|
475
|
+
)}
|
|
459
476
|
{posture && view.linked && !view.reachable && (
|
|
460
477
|
<p className="v2sh-hint" data-testid="share-unreachable">
|
|
461
478
|
{unreachableWords(shell)}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// client/v2/shell/api-session-boot.js — side-effect module, imported FIRST by app.jsx so the fetch
|
|
2
|
+
// wrapper is in place before any other module evaluates (sec-loopback-bearer §7.4). A no-op
|
|
3
|
+
// outside a project tab of the desktop app.
|
|
4
|
+
import { installApiSession } from './api-session.js';
|
|
5
|
+
|
|
6
|
+
installApiSession();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// client/v2/shell/api-session.js — a desktop project tab opens its session with its own server
|
|
2
|
+
// (contract client/v2/contracts/sec-loopback-bearer.md §7.4).
|
|
3
|
+
//
|
|
4
|
+
// A server the desktop app starts requires its per-spawn key from every caller, this page
|
|
5
|
+
// included. The tab asks the shell for the key once (`project_api_session`, caller-checked in
|
|
6
|
+
// Rust: this tab's label AND its own server's origin) and trades it for an HttpOnly session
|
|
7
|
+
// cookie (`POST /_api/shell/session`). From then on every request — fetch, images, media, fonts,
|
|
8
|
+
// WebSockets — carries the cookie by itself; the key is not kept.
|
|
9
|
+
//
|
|
10
|
+
// Until the trade settles, the fetch wrapper holds every same-origin `fetch`, so nothing the shell
|
|
11
|
+
// starts at boot races it. Outside a project tab of the app (a browser, Home, the strip, a cloud
|
|
12
|
+
// tab) it does nothing: the session is "ready" at once.
|
|
13
|
+
//
|
|
14
|
+
// A session ends after 12 h unused or 24 h in all (§7.2). When the server then answers a request
|
|
15
|
+
// `401 api-key-required`, the wrapper trades the key again — once, shared by every request that hit
|
|
16
|
+
// it at the same moment — and resends the request; the person never sees it.
|
|
17
|
+
|
|
18
|
+
export const SESSION_PATH = '/_api/shell/session';
|
|
19
|
+
export const API_KEY_HEADER = 'x-maude-api-key';
|
|
20
|
+
const ATTEMPTS = 3;
|
|
21
|
+
const RETRY_MS = 300;
|
|
22
|
+
|
|
23
|
+
/** A project tab of the desktop app (`p-<pid>`) — the only caller the shell hands a key to. */
|
|
24
|
+
export function isProjectTab(win) {
|
|
25
|
+
const meta = win?.__TAURI_INTERNALS__?.metadata;
|
|
26
|
+
const label = meta?.currentWebview?.label ?? meta?.currentWindow?.label;
|
|
27
|
+
return typeof label === 'string' && label.startsWith('p-') && !!win?.__TAURI__?.core?.invoke;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function sameOrigin(input, win) {
|
|
31
|
+
try {
|
|
32
|
+
const raw = typeof input === 'string' || input instanceof URL ? String(input) : input?.url;
|
|
33
|
+
return new URL(raw, win.location.href).origin === win.location.origin;
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Open the session once per page. Resolves true when the cookie is set, false otherwise (outside a
|
|
43
|
+
* project tab, or the shell/server said no — the page's requests then answer 401 and the shell
|
|
44
|
+
* shows its usual "can't reach the project" states). Never rejects.
|
|
45
|
+
*/
|
|
46
|
+
async function tradeKey(win, rawFetch) {
|
|
47
|
+
if (!isProjectTab(win)) return false;
|
|
48
|
+
const invoke = win.__TAURI__.core.invoke;
|
|
49
|
+
for (let i = 0; i < ATTEMPTS; i++) {
|
|
50
|
+
if (i > 0) await sleep(RETRY_MS);
|
|
51
|
+
try {
|
|
52
|
+
const answer = await invoke('project_api_session');
|
|
53
|
+
const key = typeof answer?.key === 'string' ? answer.key : '';
|
|
54
|
+
if (!key) continue;
|
|
55
|
+
const res = await rawFetch(SESSION_PATH, {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
headers: { [API_KEY_HEADER]: key },
|
|
58
|
+
credentials: 'same-origin',
|
|
59
|
+
cache: 'no-store',
|
|
60
|
+
});
|
|
61
|
+
if (res.ok) return true;
|
|
62
|
+
} catch {
|
|
63
|
+
/* the server may still be coming up — retry */
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function openApiSession(win, rawFetch) {
|
|
70
|
+
if (win.__maudeApiSession) return win.__maudeApiSession;
|
|
71
|
+
win.__maudeApiSession = tradeKey(win, rawFetch);
|
|
72
|
+
return win.__maudeApiSession;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** One re-trade at a time: every request that met the ended session waits on the same one. */
|
|
76
|
+
function renewApiSession(win, rawFetch) {
|
|
77
|
+
if (!win.__maudeApiSessionRenew) {
|
|
78
|
+
win.__maudeApiSessionRenew = tradeKey(win, rawFetch).finally(() => {
|
|
79
|
+
win.__maudeApiSessionRenew = null;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return win.__maudeApiSessionRenew;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** A request that can be sent twice: no Request object (its body is spent) and no streamed body. */
|
|
86
|
+
function resendable(input, init) {
|
|
87
|
+
if (!(typeof input === 'string' || input instanceof URL)) return false;
|
|
88
|
+
const body = init?.body;
|
|
89
|
+
return !(typeof ReadableStream !== 'undefined' && body instanceof ReadableStream);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The gate's own answer for a request with no live session (shell/api-key.ts `refuse`). */
|
|
93
|
+
async function sessionEnded(res) {
|
|
94
|
+
if (res.status !== 401) return false;
|
|
95
|
+
try {
|
|
96
|
+
const body = await res.clone().json();
|
|
97
|
+
return body?.error === 'api-key-required';
|
|
98
|
+
} catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Hold every same-origin `fetch` until the session is open. Idempotent; a no-op outside a
|
|
105
|
+
* project tab of the app.
|
|
106
|
+
*/
|
|
107
|
+
export function installApiSession(win = typeof window !== 'undefined' ? window : undefined) {
|
|
108
|
+
if (!win || win.__maudeApiSessionFetch || !isProjectTab(win)) return Promise.resolve(false);
|
|
109
|
+
const rawFetch = win.fetch.bind(win);
|
|
110
|
+
win.__maudeApiSessionFetch = true;
|
|
111
|
+
const ready = openApiSession(win, rawFetch);
|
|
112
|
+
win.fetch = (input, init) => {
|
|
113
|
+
if (!sameOrigin(input, win)) return rawFetch(input, init);
|
|
114
|
+
return ready.then(async () => {
|
|
115
|
+
const res = await rawFetch(input, init);
|
|
116
|
+
if (!resendable(input, init) || !(await sessionEnded(res))) return res;
|
|
117
|
+
return (await renewApiSession(win, rawFetch)) ? rawFetch(input, init) : res;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
return ready;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** The boot waits on this before it renders (sockets open from effects, after the first render). */
|
|
124
|
+
export function apiSessionReady(win = typeof window !== 'undefined' ? window : undefined) {
|
|
125
|
+
return win?.__maudeApiSession ?? Promise.resolve(false);
|
|
126
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// client/v2/shell/connection-state.js — 2.1.1 T2: is THIS project's connection working, and whose move
|
|
2
|
+
// is it? (canvas 17 · ac-states). PURE: one place derives the state the account chip's badge, the save
|
|
3
|
+
// word, the avatar menu's project block and the once-per-session toast all say.
|
|
4
|
+
//
|
|
5
|
+
// Eight states, from what the page already holds:
|
|
6
|
+
// local no `linkedHub` in this folder: nothing leaves this Mac (a plain laptop, never a badge)
|
|
7
|
+
// unconfirmed the folder NAMES a server this Mac never linked or confirmed (`/_api/cloud/status`
|
|
8
|
+
// `linkedHub.confirmed === false`, from this Mac's link record — gate-b-sec4 parked it).
|
|
9
|
+
// A committed address is a peer's text: no toast, no badge, no prefilled sign-in — only
|
|
10
|
+
// a neutral line and Review…, which opens the Share sheet's Connect (the consent step).
|
|
11
|
+
// signin-missing a server this Mac linked (`confirmed`) and holds no sign-in for
|
|
12
|
+
// (`linkedHub.credentialed === false`)
|
|
13
|
+
// signin-rejected the server refuses the sign-in this Mac holds: the accepted lane's
|
|
14
|
+
// `accepted.credentialRefused` (sync/status.ts), or every document refused with
|
|
15
|
+
// `invalid-token` (DDR-102's own classification, sync/index.ts `AuthFailureClass`)
|
|
16
|
+
// offline this Mac has no network (`navigator.onLine === false`) — the face greys, nothing to do
|
|
17
|
+
// unreachable the network is up but the server does not answer (the hub monitor's offline /
|
|
18
|
+
// offline-long, or syncPresentation's offline / stalled)
|
|
19
|
+
// syncing a pass is running or changes are going out
|
|
20
|
+
// connected everything else on a linked folder
|
|
21
|
+
//
|
|
22
|
+
// The badge says whose move it is (canvas 17 note 2): `broken` only for a sign-in the person can repair
|
|
23
|
+
// in one click, `warn` for the server's side, `grey` for the network, a turning `ring` while syncing.
|
|
24
|
+
|
|
25
|
+
import { isCloudHub } from '../settings/connections-model.js';
|
|
26
|
+
|
|
27
|
+
export const CONNECTION_STATES = Object.freeze([
|
|
28
|
+
'connected',
|
|
29
|
+
'syncing',
|
|
30
|
+
'offline',
|
|
31
|
+
'signin-missing',
|
|
32
|
+
'signin-rejected',
|
|
33
|
+
'unreachable',
|
|
34
|
+
'unconfirmed',
|
|
35
|
+
'local',
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const UNREACHABLE_PHASES = new Set(['offline', 'stalled']);
|
|
39
|
+
const SYNCING_PHASES = new Set(['connecting', 'syncing']);
|
|
40
|
+
|
|
41
|
+
/** host, plus the port when it is not the scheme's default — how every surface names a server */
|
|
42
|
+
export function hostOf(url) {
|
|
43
|
+
try {
|
|
44
|
+
return new URL(String(url)).host.toLowerCase();
|
|
45
|
+
} catch {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
|
|
51
|
+
const count = (n) => (Number.isFinite(n) && n > 0 ? n : 0);
|
|
52
|
+
|
|
53
|
+
/** The sign-in this Mac holds is refused (only a literal `true`, never a guess). */
|
|
54
|
+
export function signInRefused(syncStatus) {
|
|
55
|
+
const s = syncStatus && typeof syncStatus === 'object' ? syncStatus : null;
|
|
56
|
+
if (!s) return false;
|
|
57
|
+
if (s.accepted && typeof s.accepted === 'object' && s.accepted.credentialRefused === true)
|
|
58
|
+
return true;
|
|
59
|
+
// Every document refused, and refused for an invalid token: the sign-in itself stopped working.
|
|
60
|
+
const docs = s.docs && typeof s.docs === 'object' ? s.docs : null;
|
|
61
|
+
const items = Array.isArray(s.items) ? s.items : [];
|
|
62
|
+
if (!docs || count(docs.rejected) === 0 || count(docs.synced) > 0) return false;
|
|
63
|
+
return items.some((i) => i?.state === 'auth-rejected' && i?.reason === 'invalid-token');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param in.linkedHub `/_api/cloud/status` `linkedHub` — `{ url, credentialed, confirmed }` or null
|
|
68
|
+
* @param in.cloudUrl the Maude Cloud address this Mac signs in against (tells cloud from your server)
|
|
69
|
+
* @param in.syncStatus the shell's raw sync status (the hub monitor + the accepted lane)
|
|
70
|
+
* @param in.phase syncPresentation(syncStatus).phase, or null
|
|
71
|
+
* @param in.pending changes still going out (queued ops + the outbox)
|
|
72
|
+
* @param in.online false only when the browser says there is no network
|
|
73
|
+
* @returns {{ state, kind: 'cloud'|'server'|'local', host: string|null, url: string|null,
|
|
74
|
+
* (an unconfirmed claim is kind 'local' — nothing leaves this Mac — with the named host)
|
|
75
|
+
* badge: 'broken'|'warn'|'grey'|'ring'|null }}
|
|
76
|
+
*/
|
|
77
|
+
export function connectionState(input = {}) {
|
|
78
|
+
const {
|
|
79
|
+
linkedHub = null,
|
|
80
|
+
cloudUrl = '',
|
|
81
|
+
syncStatus = null,
|
|
82
|
+
phase = null,
|
|
83
|
+
pending = 0,
|
|
84
|
+
online = true,
|
|
85
|
+
} = input ?? {};
|
|
86
|
+
const url = str(linkedHub?.url);
|
|
87
|
+
if (!url) return { state: 'local', kind: 'local', host: null, url: null, badge: null };
|
|
88
|
+
// An address this Mac never confirmed: what the repo says, worded as such — never as a repair.
|
|
89
|
+
if (linkedHub?.confirmed === false)
|
|
90
|
+
return { state: 'unconfirmed', kind: 'local', host: hostOf(url) || null, url, badge: null };
|
|
91
|
+
const kind = isCloudHub(url, cloudUrl) ? 'cloud' : 'server';
|
|
92
|
+
const host = hostOf(url) || url;
|
|
93
|
+
const out = (state, badge) => ({ state, kind, host, url, badge });
|
|
94
|
+
if (linkedHub?.credentialed !== true) return out('signin-missing', 'broken');
|
|
95
|
+
if (signInRefused(syncStatus)) return out('signin-rejected', 'broken');
|
|
96
|
+
if (online === false) return out('offline', 'grey');
|
|
97
|
+
const hub = syncStatus?.state;
|
|
98
|
+
if (hub === 'offline' || hub === 'offline-long' || UNREACHABLE_PHASES.has(phase))
|
|
99
|
+
return out('unreachable', 'warn');
|
|
100
|
+
if (SYNCING_PHASES.has(phase) || count(pending) > 0) return out('syncing', 'ring');
|
|
101
|
+
return out('connected', null);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Where the sign-in lives, in the menu's words: "Maude Cloud" or the server's host. */
|
|
105
|
+
const placeName = (c) => (c.kind === 'cloud' ? 'Maude Cloud' : c.host || 'the server');
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The words each state says (canvas 17 · ac-states, CONTRACT voice): the save word beside the chip, the
|
|
109
|
+
* status line of the avatar menu, and the one-click fix.
|
|
110
|
+
* @param c connectionState()
|
|
111
|
+
* @param in.pending changes going out ("Syncing · 3 changes going out")
|
|
112
|
+
* @returns {{ word, icon, tone, line, fix: null | { id: 'sign-in'|'retry'|'move-to-cloud', label } }}
|
|
113
|
+
*/
|
|
114
|
+
export function connectionWords(c, { pending = 0 } = {}) {
|
|
115
|
+
const where = placeName(c ?? {});
|
|
116
|
+
const n = count(pending);
|
|
117
|
+
switch (c?.state) {
|
|
118
|
+
case 'signin-missing':
|
|
119
|
+
return {
|
|
120
|
+
word: 'Sign in to sync',
|
|
121
|
+
icon: 'lock',
|
|
122
|
+
tone: 'error',
|
|
123
|
+
line: `This project is on ${where} — sign in to sync.`,
|
|
124
|
+
fix: { id: 'sign-in', label: 'Sign in' },
|
|
125
|
+
};
|
|
126
|
+
case 'signin-rejected':
|
|
127
|
+
return {
|
|
128
|
+
word: 'Sign-in stopped working',
|
|
129
|
+
icon: 'lock',
|
|
130
|
+
tone: 'error',
|
|
131
|
+
line: `Your sign-in to ${where} stopped working. Changes wait on this Mac.`,
|
|
132
|
+
fix: { id: 'sign-in', label: 'Sign in again' },
|
|
133
|
+
};
|
|
134
|
+
case 'unreachable':
|
|
135
|
+
return {
|
|
136
|
+
word: `Can’t reach ${where}`,
|
|
137
|
+
icon: 'problem',
|
|
138
|
+
tone: 'warn',
|
|
139
|
+
line: `${where} doesn’t answer. Changes wait on this Mac.`,
|
|
140
|
+
fix: { id: 'retry', label: `Retry ${where}` },
|
|
141
|
+
};
|
|
142
|
+
case 'offline':
|
|
143
|
+
return {
|
|
144
|
+
word: 'Offline — changes wait on this Mac',
|
|
145
|
+
icon: 'offline',
|
|
146
|
+
tone: 'warn',
|
|
147
|
+
line: 'Offline — changes wait on this Mac. They go out when it’s back online.',
|
|
148
|
+
fix: null,
|
|
149
|
+
};
|
|
150
|
+
case 'syncing':
|
|
151
|
+
return {
|
|
152
|
+
word: 'Syncing…',
|
|
153
|
+
icon: 'sync',
|
|
154
|
+
tone: '',
|
|
155
|
+
line: n > 0 ? `Syncing · ${n} change${n === 1 ? '' : 's'} going out` : 'Syncing',
|
|
156
|
+
fix: null,
|
|
157
|
+
};
|
|
158
|
+
case 'connected':
|
|
159
|
+
return { word: 'Saved', icon: 'cloud', tone: '', line: 'Connected', fix: null };
|
|
160
|
+
case 'unconfirmed':
|
|
161
|
+
return {
|
|
162
|
+
word: 'Not linked on this Mac',
|
|
163
|
+
icon: 'laptop',
|
|
164
|
+
tone: '',
|
|
165
|
+
line: `This project names ${c.host || 'a server'}. Not linked on this Mac.`,
|
|
166
|
+
fix: { id: 'review-link', label: 'Review…' },
|
|
167
|
+
};
|
|
168
|
+
default:
|
|
169
|
+
return {
|
|
170
|
+
word: 'Only on this Mac',
|
|
171
|
+
icon: 'laptop',
|
|
172
|
+
tone: '',
|
|
173
|
+
line: 'Nothing leaves this Mac.',
|
|
174
|
+
fix: { id: 'move-to-cloud', label: 'Put on Maude Cloud…' },
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** True for the two states the person repairs with one sign-in (the broken-link badge, the toast). */
|
|
180
|
+
export const isBrokenSignIn = (c) =>
|
|
181
|
+
c?.state === 'signin-missing' || c?.state === 'signin-rejected';
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The once-per-session toast for a broken sign-in (canvas 17 · ac-toast), or null. Keyed by project and
|
|
185
|
+
* state, so a missing sign-in fixed and later rejected is told again — but never twice for the same.
|
|
186
|
+
*/
|
|
187
|
+
export function signInToast(c, { project = '' } = {}) {
|
|
188
|
+
if (!isBrokenSignIn(c)) return null;
|
|
189
|
+
const w = connectionWords(c);
|
|
190
|
+
return {
|
|
191
|
+
key: `${project || '-'}|${c.url || ''}|${c.state}`,
|
|
192
|
+
id: `signin-${c.state}`,
|
|
193
|
+
title: w.line,
|
|
194
|
+
kind: 'warning',
|
|
195
|
+
actionLabel: w.fix.label,
|
|
196
|
+
};
|
|
197
|
+
}
|