rvlib-shipkit 2.29.0 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -1
- package/package.json +2 -1
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/expose.ts +5 -1
- package/src/advisors/r2.ts +7 -9
- package/src/advisors/routes.ts +29 -2
- package/src/advisors/scan.ts +11 -0
- package/src/agent-time/accounts-usage.ts +8 -0
- package/src/agent-time/claude-sessions.ts +32 -0
- package/src/agent-time/hooks.ts +1 -1
- package/src/agent-time/live.ts +5 -2
- package/src/agent-time/registry.ts +186 -89
- package/src/agent-time/store.ts +6 -4
- package/src/asks/ask-doc.ts +2 -2
- package/src/asks/ask-store.ts +22 -7
- package/src/check.ts +9 -1
- package/src/checks/SK001-package-json-shape.check.ts +1 -0
- package/src/checks/SK003-claude-md-shape.check.ts +1 -0
- package/src/checks/SK004-gitignore-policy.check.ts +12 -6
- package/src/checks/SK008-reviewer-agent.check.ts +4 -7
- package/src/checks/SK013-one-way-in-policy.check.ts +1 -0
- package/src/checks/SK017-vscode-hub-task.check.ts +1 -0
- package/src/checks/SK024-identity-colors.check.ts +1 -1
- package/src/checks/SK027-agent-wiki-links.check.ts +2 -1
- package/src/checks/SK033-global-contribution.check.ts +1 -0
- package/src/checks/SK034-commit-gates-armed.check.ts +1 -0
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -0
- package/src/checks/SK049-thread-answers-hook.check.ts +9 -5
- package/src/checks/SK050-retired-commands.check.ts +1 -0
- package/src/checks/SK051-no-formatter.check.ts +1 -0
- package/src/cli/channel-run.ts +17 -0
- package/src/cli/cmd_Advisors.ts +28 -7
- package/src/cli/cmd_Asks.ts +2 -2
- package/src/cli/cmd_Backup.ts +5 -1
- package/src/cli/cmd_CacheAudit.ts +1 -1
- package/src/cli/cmd_Channel.ts +43 -0
- package/src/cli/cmd_GlobalProcesses.ts +1 -0
- package/src/cli/cmd_Home.ts +12 -5
- package/src/cli/cmd_Hooks.ts +1 -1
- package/src/cli/cmd_Hq.ts +43 -0
- package/src/cli/cmd_Lanes.ts +15 -3
- package/src/cli/cmd_Media.ts +8 -3
- package/src/cli/cmd_Orchestrator.ts +253 -84
- package/src/cli/cmd_OrchestratorRole.ts +163 -0
- package/src/cli/cmd_Review.ts +142 -165
- package/src/cli/cmd_Secret.ts +44 -14
- package/src/cli/cmd_Shot.ts +2 -4
- package/src/cli/cmd_Sound.ts +1 -0
- package/src/cli/cmd_Urls.ts +3 -3
- package/src/cli/inbox-hook-run.ts +109 -0
- package/src/cli/registry.ts +6 -2
- package/src/cli/review-here.ts +136 -0
- package/src/cli.ts +45 -14
- package/src/collections/actions.ts +5 -4
- package/src/collections/checks.ts +5 -0
- package/src/collections/collection-types.ts +4 -3
- package/src/collections/pings.ts +4 -1
- package/src/collections/providers.ts +6 -4
- package/src/collections/tests.ts +7 -4
- package/src/core/app-icon-frame.ts +62 -0
- package/src/core/app-icon.ts +179 -17
- package/src/core/archived.ts +10 -7
- package/src/core/check-ctx.ts +38 -4
- package/src/core/check-pass.ts +7 -0
- package/src/core/foreign.ts +87 -0
- package/src/core/gui-color.ts +75 -0
- package/src/core/hub-theme.ts +1 -3
- package/src/core/layout.ts +3 -0
- package/src/core/machine-commit.ts +9 -1
- package/src/core/one-lib.ts +2 -1
- package/src/core/one-way-in-policy.ts +17 -12
- package/src/core/owner-word-policy.ts +123 -0
- package/src/core/panel-shades.ts +140 -0
- package/src/core/repo-gui-color.ts +16 -0
- package/src/core/role-policy.ts +17 -0
- package/src/core/scope.ts +6 -3
- package/src/core/tmux-policy.ts +264 -0
- package/src/core/unit-icon.ts +43 -0
- package/src/fleet/push-fleet.ts +2 -0
- package/src/fleet/scan-fleet.ts +3 -0
- package/src/gate/cache-audit.ts +7 -1
- package/src/gate/gate-checks.ts +14 -9
- package/src/gate/run-fix.ts +30 -5
- package/src/gate/run-fixers.ts +8 -3
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +2 -1
- package/src/home/daemon-guard.ts +20 -2
- package/src/home/daemon-jobs.ts +26 -18
- package/src/home/gui-app/ShipkitGui.swift +2012 -144
- package/src/home/gui-app/icon.svg +8 -0
- package/src/home/gui-app.ts +94 -30
- package/src/home/home-routes.ts +53 -9
- package/src/home/home-start.ts +27 -3
- package/src/home/inbox-shape.ts +7 -3
- package/src/home/log-follow.ts +117 -0
- package/src/home/machine-fold.ts +1 -1
- package/src/home/open-app.ts +9 -3
- package/src/home/page-build.ts +5 -1
- package/src/home/page-held.ts +1 -1
- package/src/home/pm-config.ts +0 -8
- package/src/home/pm.ts +62 -5
- package/src/home/process-apps.ts +70 -23
- package/src/home/process-rows.ts +16 -1
- package/src/home/push-sources.ts +18 -13
- package/src/home/resources.ts +16 -7
- package/src/home/run-daemon.ts +4 -1
- package/src/home/run-pm.ts +1 -1
- package/src/home/serve-daemon.ts +13 -4
- package/src/home/serve-web.ts +141 -17
- package/src/home/space-page.ts +3 -3
- package/src/home/space-route.ts +2 -2
- package/src/home/supervise.ts +2 -1
- package/src/home/vault-page.ts +2 -1
- package/src/home/web-places.ts +239 -0
- package/src/home/widgets.ts +16 -2
- package/src/hooks/commit-message.ts +11 -9
- package/src/hooks/one-way-in-guard.ts +145 -68
- package/src/hooks/run-hooks.ts +15 -5
- package/src/hooks/shared-file.ts +273 -83
- package/src/hooks/shell-writes.ts +620 -0
- package/src/hooks/write-log.ts +149 -0
- package/src/hq/door-route.ts +63 -7
- package/src/hq/door.ts +45 -12
- package/src/hq/history-send.ts +3 -1
- package/src/hq/hq-db.ts +10 -3
- package/src/hq/hq-local.ts +24 -5
- package/src/hq/hq-routes.ts +3 -1
- package/src/hq/hq-store.ts +9 -3
- package/src/hq/kinds/index.ts +2 -1
- package/src/hq/kinds/kind.ts +9 -4
- package/src/hq/kinds/presence-rule.ts +56 -0
- package/src/hq/kinds/presence.ts +210 -0
- package/src/hq/kinds/report.ts +8 -5
- package/src/hq/lead-order.ts +68 -0
- package/src/hq/outbox.ts +7 -0
- package/src/hq/replica.ts +5 -7
- package/src/hq/report-facts.ts +14 -7
- package/src/hq/report.ts +47 -2
- package/src/hq/switch.ts +1 -0
- package/src/hq/terminal-hop.ts +64 -0
- package/src/hq/thread-sync.ts +13 -6
- package/src/http/door-forward.ts +10 -12
- package/src/http/door-names.ts +9 -0
- package/src/http/hop-caller.ts +23 -0
- package/src/http/hop-names.ts +14 -0
- package/src/http/loopback-serve.ts +28 -6
- package/src/http/owner-word.ts +128 -0
- package/src/http/same-origin.ts +12 -0
- package/src/{serve → http}/secret-gate.ts +3 -3
- package/src/ledger/run-log.ts +25 -1
- package/src/media-store/backup/sources.ts +53 -6
- package/src/media-store/backup/thread-copy.ts +9 -5
- package/src/media-store/copy/config.ts +10 -9
- package/src/media-store/daemon.ts +5 -2
- package/src/media-store/put.ts +3 -0
- package/src/media-store/space.ts +14 -16
- package/src/media-store/upload.ts +4 -0
- package/src/messages/collection.ts +2 -2
- package/src/messages/model.ts +6 -1
- package/src/messages/routes.ts +3 -0
- package/src/orchestrator/brief.md +8 -6
- package/src/orchestrator/channel-declare.ts +58 -0
- package/src/orchestrator/channel.ts +226 -0
- package/src/orchestrator/guards.ts +12 -3
- package/src/orchestrator/host.ts +35 -0
- package/src/orchestrator/lead-shape.ts +86 -0
- package/src/orchestrator/now.ts +88 -0
- package/src/orchestrator/phone.ts +4 -1
- package/src/orchestrator/places-file.ts +38 -0
- package/src/orchestrator/places-look.ts +180 -0
- package/src/orchestrator/places-shape.ts +151 -0
- package/src/orchestrator/places.ts +50 -0
- package/src/orchestrator/presence-shape.ts +13 -2
- package/src/orchestrator/presence.ts +26 -15
- package/src/orchestrator/push.ts +5 -10
- package/src/orchestrator/role-shape.ts +270 -0
- package/src/orchestrator/role.ts +242 -0
- package/src/orchestrator/routes.ts +136 -31
- package/src/orchestrator/sessions-shape.ts +78 -0
- package/src/orchestrator/sessions.ts +86 -0
- package/src/orchestrator/share.ts +71 -0
- package/src/orchestrator/start-notice.ts +61 -0
- package/src/orchestrator/start.ts +137 -0
- package/src/orchestrator/started.ts +55 -0
- package/src/orchestrator/stuck.ts +196 -0
- package/src/orchestrator/unheard.ts +18 -7
- package/src/pages/frame-client.ts +44 -6
- package/src/problems/failure-words.ts +80 -0
- package/src/release/run-bump.ts +26 -5
- package/src/release/run-release.ts +34 -14
- package/src/repo-config.ts +37 -9
- package/src/review/aside-at.ts +19 -0
- package/src/review/band.ts +3 -3
- package/src/review/doc-save.ts +1 -1
- package/src/review/inbox-hook.ts +12 -4
- package/src/review/inbox-read.ts +20 -7
- package/src/review/instruction-guards.ts +137 -0
- package/src/review/instructions.ts +14 -2
- package/src/review/item-db.ts +52 -2
- package/src/review/mentions.ts +6 -4
- package/src/review/model.ts +3 -2
- package/src/review/parties.ts +88 -19
- package/src/review/push.ts +32 -15
- package/src/review/routes.ts +12 -4
- package/src/review/secret-route.ts +5 -5
- package/src/review/snooze.ts +1 -16
- package/src/review/store-parties.ts +4 -2
- package/src/review/take-back.ts +2 -1
- package/src/review/threads.ts +13 -2
- package/src/review/unit.ts +3 -2
- package/src/review/view-layout.ts +8 -1
- package/src/review/watchers.ts +25 -4
- package/src/secrets/key-pair.ts +14 -0
- package/src/secrets/lapse.ts +3 -3
- package/src/secrets/manager.ts +5 -1
- package/src/secrets/name-template.ts +83 -0
- package/src/secrets/name.ts +3 -0
- package/src/secrets/read.ts +10 -6
- package/src/secrets/secrets-view.ts +299 -0
- package/src/secrets/who-reads.ts +2 -1
- package/src/serve/frame-part.ts +49 -0
- package/src/serve/hub-app/accounts-line.tsx +33 -45
- package/src/serve/hub-app/activity-st.ts +6 -5
- package/src/serve/hub-app/activity-view.tsx +10 -9
- package/src/serve/hub-app/advice-box.tsx +6 -5
- package/src/serve/hub-app/advisor-app.tsx +2 -0
- package/src/serve/hub-app/advisor-face.tsx +3 -2
- package/src/serve/hub-app/advisor.html +1 -0
- package/src/serve/hub-app/advisors-view.tsx +52 -10
- package/src/serve/hub-app/advisors.css +4 -0
- package/src/serve/hub-app/app-bridge.ts +31 -5
- package/src/serve/hub-app/asked-page.ts +24 -0
- package/src/serve/hub-app/asks-page.tsx +10 -6
- package/src/serve/hub-app/auto-text.tsx +7 -5
- package/src/serve/hub-app/card-head.tsx +3 -2
- package/src/serve/hub-app/check-view.tsx +10 -9
- package/src/serve/hub-app/checks-svc.ts +96 -32
- package/src/serve/hub-app/clock-svc.ts +24 -8
- package/src/serve/hub-app/code-copy.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +2 -1
- package/src/serve/hub-app/col-list-page.tsx +12 -6
- package/src/serve/hub-app/col-list-st.ts +12 -2
- package/src/serve/hub-app/col-tables-view.tsx +8 -44
- package/src/serve/hub-app/col-tables.ts +0 -14
- package/src/serve/hub-app/cols-svc.ts +6 -12
- package/src/serve/hub-app/columns.ts +94 -0
- package/src/serve/hub-app/comfy-view.tsx +8 -7
- package/src/serve/hub-app/commands/commands-page.tsx +4 -3
- package/src/serve/hub-app/commands/commands-st.ts +2 -2
- package/src/serve/hub-app/controls.css +69 -23
- package/src/serve/hub-app/cycle-button.tsx +2 -1
- package/src/serve/hub-app/database-st.ts +1 -1
- package/src/serve/hub-app/database-view.tsx +4 -2
- package/src/serve/hub-app/deaf.tsx +27 -0
- package/src/serve/hub-app/dock-st.ts +21 -16
- package/src/serve/hub-app/dock-view.tsx +19 -12
- package/src/serve/hub-app/empty-section.tsx +30 -0
- package/src/serve/hub-app/entry-bar.css +1 -1
- package/src/serve/hub-app/entry-bar.tsx +11 -6
- package/src/serve/hub-app/entry-list.css +32 -0
- package/src/serve/hub-app/entry-list.tsx +123 -0
- package/src/serve/hub-app/entry-pick.ts +1 -1
- package/src/serve/hub-app/entry-sections.ts +140 -0
- package/src/serve/hub-app/event-stream-reader.ts +56 -0
- package/src/serve/hub-app/floating.tsx +68 -14
- package/src/serve/hub-app/geometry-view.tsx +3 -2
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/hash-route.ts +14 -2
- package/src/serve/hub-app/header-bar.tsx +53 -36
- package/src/serve/hub-app/home-st.ts +131 -14
- package/src/serve/hub-app/home-strip.css +24 -13
- package/src/serve/hub-app/home-strip.tsx +131 -66
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +94 -102
- package/src/serve/hub-app/hub.css +61 -94
- package/src/serve/hub-app/icons.tsx +16 -0
- package/src/serve/hub-app/identities-st.ts +19 -54
- package/src/serve/hub-app/identities-view.tsx +25 -24
- package/src/serve/hub-app/identity-address.ts +2 -2
- package/src/serve/hub-app/in-sight.ts +10 -0
- package/src/serve/hub-app/inbox-st.ts +20 -2
- package/src/serve/hub-app/inbox-view.tsx +16 -9
- package/src/serve/hub-app/inbox.css +1 -0
- package/src/serve/hub-app/index.html +5 -0
- package/src/serve/hub-app/insights-view.tsx +6 -5
- package/src/serve/hub-app/instructions.css +4 -1
- package/src/serve/hub-app/kept-cols.tsx +83 -20
- package/src/serve/hub-app/kept-width.tsx +76 -0
- package/src/serve/hub-app/keys.ts +116 -38
- package/src/serve/hub-app/layout-st.ts +109 -99
- package/src/serve/hub-app/lightbox-zoom.css +36 -0
- package/src/serve/hub-app/list-filter.tsx +15 -6
- package/src/serve/hub-app/list-head.tsx +29 -0
- package/src/serve/hub-app/list-row.ts +8 -0
- package/src/serve/hub-app/list-walk.ts +26 -105
- package/src/serve/hub-app/live-socket.ts +274 -0
- package/src/serve/hub-app/live-sources.ts +189 -0
- package/src/serve/hub-app/live-svc.ts +2 -2
- package/src/serve/hub-app/machine-st.ts +75 -14
- package/src/serve/hub-app/main-panel.css +211 -0
- package/src/serve/hub-app/main-panel.tsx +259 -0
- package/src/serve/hub-app/md.ts +4 -4
- package/src/serve/hub-app/media-svc.ts +5 -5
- package/src/serve/hub-app/media-view.tsx +13 -12
- package/src/serve/hub-app/messages/messages-page.tsx +8 -7
- package/src/serve/hub-app/messages/messages-st.ts +5 -2
- package/src/serve/hub-app/new-thread-st.ts +170 -0
- package/src/serve/hub-app/new-thread.tsx +133 -107
- package/src/serve/hub-app/orchestrator-line.tsx +115 -45
- package/src/serve/hub-app/orchestrator-places.tsx +86 -0
- package/src/serve/hub-app/orchestrator.css +57 -5
- package/src/serve/hub-app/page-keys.ts +107 -68
- package/src/serve/hub-app/page-reload.ts +46 -6
- package/src/serve/hub-app/pages-frames.tsx +40 -3
- package/src/serve/hub-app/pages-svc.ts +3 -1
- package/src/serve/hub-app/palette-st.ts +198 -43
- package/src/serve/hub-app/palette-view.tsx +32 -8
- package/src/serve/hub-app/panel-head-action.tsx +39 -0
- package/src/serve/hub-app/panel-head.tsx +70 -0
- package/src/serve/hub-app/panel-repo.ts +42 -0
- package/src/serve/hub-app/panel-source.ts +195 -0
- package/src/serve/hub-app/panel-tint.css +6 -0
- package/src/serve/hub-app/panel-tint.ts +23 -0
- package/src/serve/hub-app/panel-walk.ts +107 -0
- package/src/serve/hub-app/pill-row.tsx +2 -1
- package/src/serve/hub-app/place-path.ts +4 -0
- package/src/serve/hub-app/places-svc.ts +75 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/polled.ts +11 -1
- package/src/serve/hub-app/presence-st.ts +66 -32
- package/src/serve/hub-app/processes-view.tsx +2 -2
- package/src/serve/hub-app/project-bar.tsx +116 -0
- package/src/serve/hub-app/project-list.css +20 -173
- package/src/serve/hub-app/project-list.tsx +30 -298
- package/src/serve/hub-app/projects-svc.ts +59 -32
- package/src/serve/hub-app/push-sign.tsx +2 -1
- package/src/serve/hub-app/push-svc.ts +86 -69
- package/src/serve/hub-app/quiet-st.ts +5 -3
- package/src/serve/hub-app/rail-groups.ts +144 -0
- package/src/serve/hub-app/reader-chips.tsx +2 -1
- package/src/serve/hub-app/recordings-st.ts +2 -1
- package/src/serve/hub-app/recordings-view.tsx +19 -47
- package/src/serve/hub-app/recordings.css +0 -2
- package/src/serve/hub-app/reflections-page.tsx +10 -6
- package/src/serve/hub-app/releases/releases-page.tsx +6 -5
- package/src/serve/hub-app/repo-sections.ts +127 -38
- package/src/serve/hub-app/repo-st.ts +57 -36
- package/src/serve/hub-app/review/advisor-bar.tsx +3 -2
- package/src/serve/hub-app/review/ask-proof.tsx +79 -0
- package/src/serve/hub-app/review/attach-view.tsx +11 -10
- package/src/serve/hub-app/review/box-view.ts +479 -0
- package/src/serve/hub-app/review/box-zoom.tsx +70 -0
- package/src/serve/hub-app/review/diff-view.tsx +3 -2
- package/src/serve/hub-app/review/doc-body.tsx +2 -1
- package/src/serve/hub-app/review/dock.tsx +3 -2
- package/src/serve/hub-app/review/draft-body.tsx +4 -3
- package/src/serve/hub-app/review/faces.tsx +0 -8
- package/src/serve/hub-app/review/group-block.tsx +8 -7
- package/src/serve/hub-app/review/heard-line.tsx +4 -3
- package/src/serve/hub-app/review/instructions-view.tsx +3 -2
- package/src/serve/hub-app/review/item-verdict.tsx +40 -40
- package/src/serve/hub-app/review/kind-states.tsx +5 -4
- package/src/serve/hub-app/review/kit.tsx +24 -4
- package/src/serve/hub-app/review/lane-bar.tsx +30 -28
- package/src/serve/hub-app/review/lightbox.tsx +6 -4
- package/src/serve/hub-app/review/live-bar.tsx +7 -6
- package/src/serve/hub-app/review/live-view.tsx +6 -5
- package/src/serve/hub-app/review/object-card.tsx +2 -1
- package/src/serve/hub-app/review/object-panel.tsx +11 -10
- package/src/serve/hub-app/review/pano-view.tsx +3 -2
- package/src/serve/hub-app/review/question-views.tsx +6 -5
- package/src/serve/hub-app/review/review-cells.tsx +21 -20
- package/src/serve/hub-app/review/review-host.ts +3 -0
- package/src/serve/hub-app/review/review-kit.ts +7 -5
- package/src/serve/hub-app/review/review-list.tsx +98 -52
- package/src/serve/hub-app/review/review-page.tsx +3 -3
- package/src/serve/hub-app/review/review-st.ts +70 -14
- package/src/serve/hub-app/review/review-thread.tsx +234 -138
- package/src/serve/hub-app/review/review-views.tsx +166 -191
- package/src/serve/hub-app/review/space3d.tsx +17 -9
- package/src/serve/hub-app/review/thread-close.tsx +24 -32
- package/src/serve/hub-app/review/thread-st.ts +39 -25
- package/src/serve/hub-app/review/trailer-body.tsx +5 -4
- package/src/serve/hub-app/review/trailer-page.tsx +18 -16
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-timeline.tsx +10 -9
- package/src/serve/hub-app/review/trailer-voices.tsx +29 -28
- package/src/serve/hub-app/review.css +159 -42
- package/src/serve/hub-app/row-acts.tsx +126 -0
- package/src/serve/hub-app/row-face.tsx +29 -0
- package/src/serve/hub-app/running-rows.tsx +142 -0
- package/src/serve/hub-app/running-st.ts +110 -0
- package/src/serve/hub-app/search-view.tsx +3 -2
- package/src/serve/hub-app/secrets-page.tsx +290 -0
- package/src/serve/hub-app/secrets-st.ts +181 -0
- package/src/serve/hub-app/secrets.css +65 -0
- package/src/serve/hub-app/section-head.tsx +3 -2
- package/src/serve/hub-app/session-chips.tsx +55 -0
- package/src/serve/hub-app/shell.ts +56 -0
- package/src/serve/hub-app/site/site-part.tsx +6 -5
- package/src/serve/hub-app/site/site-st.ts +0 -6
- package/src/serve/hub-app/site.css +0 -1
- package/src/serve/hub-app/social/calendar.tsx +7 -6
- package/src/serve/hub-app/social/comms-page.tsx +29 -26
- package/src/serve/hub-app/social/group-editor.tsx +2 -1
- package/src/serve/hub-app/social/kit.tsx +12 -11
- package/src/serve/hub-app/social/next-release.tsx +3 -2
- package/src/serve/hub-app/social/post-card.tsx +21 -20
- package/src/serve/hub-app/social/post-page.tsx +2 -1
- package/src/serve/hub-app/social/problems.tsx +3 -2
- package/src/serve/hub-app/social/social-page.tsx +29 -27
- package/src/serve/hub-app/social/social-st.ts +4 -2
- package/src/serve/hub-app/social/stage-popup.tsx +11 -10
- package/src/serve/hub-app/social.css +7 -5
- package/src/serve/hub-app/source-acts.ts +79 -0
- package/src/serve/hub-app/source-page.tsx +17 -0
- package/src/serve/hub-app/space-view.tsx +5 -4
- package/src/serve/hub-app/stores/stores-page.tsx +21 -19
- package/src/serve/hub-app/stores/stores-st.ts +1 -1
- package/src/serve/hub-app/stores.css +1 -1
- package/src/serve/hub-app/terminal-history-st.ts +112 -0
- package/src/serve/hub-app/terminal-keys.ts +79 -0
- package/src/serve/hub-app/terminal-lib.ts +110 -0
- package/src/serve/hub-app/terminal-links.ts +55 -0
- package/src/serve/hub-app/terminal-list-st.ts +304 -0
- package/src/serve/hub-app/terminal-log-st.ts +242 -0
- package/src/serve/hub-app/terminal-out.ts +135 -0
- package/src/serve/hub-app/terminal-pages.tsx +115 -0
- package/src/serve/hub-app/terminal-panel.tsx +60 -9
- package/src/serve/hub-app/terminal-sources.tsx +335 -0
- package/src/serve/hub-app/terminal-st.ts +447 -167
- package/src/serve/hub-app/terminal-stream.ts +233 -0
- package/src/serve/hub-app/terminal-tab.tsx +64 -0
- package/src/serve/hub-app/terminal-widths.ts +30 -0
- package/src/serve/hub-app/terminal.css +50 -4
- package/src/serve/hub-app/test-view.tsx +5 -3
- package/src/serve/hub-app/tests-view.tsx +16 -15
- package/src/serve/hub-app/theme-st.ts +5 -0
- package/src/serve/hub-app/thread-row.tsx +39 -31
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-view.tsx +2 -1
- package/src/serve/hub-app/time.css +1 -1
- package/src/serve/hub-app/timeline-chart.tsx +5 -4
- package/src/serve/hub-app/timeline-view.tsx +10 -9
- package/src/serve/hub-app/tips.ts +247 -0
- package/src/serve/hub-app/tree-build.ts +40 -8
- package/src/serve/hub-app/tree-svc.ts +167 -134
- package/src/serve/hub-app/unit-icons.ts +26 -0
- package/src/serve/hub-app/url-address.ts +154 -0
- package/src/serve/hub-app/url-faces.ts +88 -0
- package/src/serve/hub-app/url-forms.tsx +183 -0
- package/src/serve/hub-app/urls-svc.ts +167 -5
- package/src/serve/hub-app/urls-view.tsx +56 -20
- package/src/serve/hub-app/urls.css +26 -0
- package/src/serve/hub-app/vault-view.tsx +5 -4
- package/src/serve/hub-app/veille/veille-page.tsx +34 -33
- package/src/serve/hub-app/veille/veille-st.ts +6 -3
- package/src/serve/hub-app/view-layout.css +3 -3
- package/src/serve/hub-app/when-view.tsx +5 -4
- package/src/serve/hub-app/wikis-view.tsx +6 -5
- package/src/serve/hub-app/words.tsx +9 -2
- package/src/serve/hub-runtime.ts +3 -2
- package/src/serve/orchestrator-host.ts +58 -0
- package/src/serve/page-live.ts +147 -0
- package/src/serve/project-gutter-route.ts +63 -2
- package/src/serve/read-worker.ts +7 -2
- package/src/serve/runs-stamp.ts +33 -0
- package/src/serve/secrets-read.ts +156 -0
- package/src/serve/serve-hub.ts +71 -22
- package/src/serve/terminal-claudes.ts +185 -0
- package/src/serve/terminal-guard.ts +10 -5
- package/src/serve/terminal-host.ts +517 -0
- package/src/serve/terminal-record.ts +104 -0
- package/src/serve/terminal-route.ts +466 -103
- package/src/serve/terminal-shells.ts +3 -0
- package/src/serve/terminal-watch.ts +102 -0
- package/src/shipkit-files.ts +9 -4
- package/src/shot/client.ts +4 -9
- package/src/shot/shooter.ts +2 -4
- package/src/shot/shot-ask.ts +2 -7
- package/src/shot/shot-theme.ts +6 -17
- package/src/social/routes.ts +2 -2
- package/src/social/writes.ts +3 -0
- package/src/suite/test-units.ts +6 -2
- package/src/trailer/sound/eleven.ts +1 -0
- package/src/urls/added.ts +111 -0
- package/src/urls/icons.ts +294 -0
- package/src/urls/places.ts +139 -0
- package/src/urls/routes.ts +17 -7
- package/src/urls/rows.ts +48 -15
- package/src/urls/unit.ts +57 -3
- package/src/urls/write-routes.ts +207 -0
- package/src/vault/vault-destroy.ts +2 -1
- package/src/vault/vault-import.ts +4 -11
- package/src/vault/vault-restore.ts +3 -2
- package/src/veille/chrome.ts +18 -3
- package/src/veille/identity.ts +6 -0
- package/src/view3d/cam.ts +30 -46
- package/src/view3d/lib.ts +20 -2
- package/src/view3d/viewer.ts +62 -88
- package/src/wiki/agent-paths.ts +2 -1
- package/src/orchestrator/deliver.ts +0 -81
- package/src/orchestrator/drill.ts +0 -129
- package/src/orchestrator/keeper.ts +0 -332
- package/src/orchestrator/pm.ts +0 -20
- package/src/orchestrator/state.ts +0 -92
- package/src/orchestrator/switch.ts +0 -86
- package/src/orchestrator/tmux.ts +0 -82
- package/src/serve/hub-app/rail-fly.tsx +0 -95
- package/src/serve/hub-app/side-lists.ts +0 -72
- package/src/serve/hub-app/sidebar.tsx +0 -62
- package/src/serve/hub-app/tree-row.tsx +0 -125
package/src/urls/unit.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
// a repo's urls on the hub (wiki tools/shipkit/urls.md): a `urls([...])` unit of any `<name>.shipkit.ts` holds the
|
|
2
2
|
// urls no global process serves (prod, a box, a console), and a login is declared by where its value lives, never by
|
|
3
|
-
// its value. Every unit file imports this module, so it stays light
|
|
3
|
+
// its value. Every unit file imports this module, and the hub's page reads its constants, so it stays light
|
|
4
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
5
|
+
|
|
6
|
+
/** the file the hub writes the urls added from it into (added.ts): a row whose `file` is this is the hub's own */
|
|
7
|
+
export const ADDED_FILE = LAYOUT.urls
|
|
8
|
+
|
|
9
|
+
/** what a plain click on a url does: a native tab of the app, a popup of the identity's Chrome, the hub's frame */
|
|
10
|
+
export type UrlOpens = 'tab' | 'chrome' | 'frame'
|
|
11
|
+
export const URL_OPENS: readonly UrlOpens[] = ['tab', 'chrome', 'frame']
|
|
4
12
|
|
|
5
13
|
/** a login of a url: a secret of the house manager (its account field when `account` is absent), or a gitignored
|
|
6
14
|
* JSON file of the repo and the two keys to read in it */
|
|
@@ -8,13 +16,59 @@ export type LoginDef =
|
|
|
8
16
|
| { label?: string; account?: string; secret: string }
|
|
9
17
|
| { label?: string; file: string; account: string; password: string }
|
|
10
18
|
|
|
19
|
+
/** where a url lives, in the order the hub lists them: a machine of his (dev), the project as deployed (prod), a third
|
|
20
|
+
* party's site or console (ext). The one list of the envs: every check, form and group reads it */
|
|
21
|
+
export const URL_ENVS = ['dev', 'prod', 'ext'] as const
|
|
22
|
+
export type UrlEnv = (typeof URL_ENVS)[number]
|
|
23
|
+
|
|
24
|
+
/** what each env means, in the hub's tips */
|
|
25
|
+
export const URL_ENV_WORDS: Record<UrlEnv, string> = {
|
|
26
|
+
dev: 'a machine of yours: this Mac, the LAN, the tailnet',
|
|
27
|
+
prod: 'the project as it is deployed',
|
|
28
|
+
ext: "a third party's site or console: a dashboard, a repo host, a cloud account",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const isUrlEnv = (v: unknown): v is UrlEnv => (URL_ENVS as readonly unknown[]).includes(v)
|
|
32
|
+
|
|
33
|
+
/** a loopback name, a LAN address (RFC 1918, link local, IPv6 unique local and link local) or a `.local` name: a
|
|
34
|
+
* machine of his */
|
|
35
|
+
export function nearHost(hostname: string): boolean {
|
|
36
|
+
const x = hostname.replace(/^\[|\]$/g, '').toLowerCase()
|
|
37
|
+
return x === 'localhost' || x.endsWith('.localhost') || x === '::1' || /^127\./.test(x) || x.endsWith('.local') || /^10\./.test(x) || /^192\.168\./.test(x)
|
|
38
|
+
|| /^172\.(1[6-9]|2\d|3[01])\./.test(x) || /^169\.254\./.test(x) || /^f[cd][0-9a-f]{2}:/.test(x) || /^fe80:/.test(x)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** a host's site, its last two labels: `app.shop.example` and `admin.shop.example` are one site */
|
|
42
|
+
const siteOf = (hostname: string): string => hostname.toLowerCase().split('.').slice(-2).join('.')
|
|
43
|
+
|
|
44
|
+
/** the env a url most likely is, `prods` the urls the repo already lists as prod: dev for a machine of his; prod for a
|
|
45
|
+
* site one of them is on, or when the repo lists no prod yet (its first public url is most often the product); ext
|
|
46
|
+
* for any other site (one beside a product the repo has is most often a third party's console). null: no url */
|
|
47
|
+
export function envOfUrl(url: string, prods: readonly string[]): UrlEnv | null {
|
|
48
|
+
let host: string
|
|
49
|
+
try {
|
|
50
|
+
host = new URL(url).hostname
|
|
51
|
+
} catch {
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
if (nearHost(host)) return 'dev'
|
|
55
|
+
const sites = prods.flatMap((p) => {
|
|
56
|
+
try {
|
|
57
|
+
return [siteOf(new URL(p).hostname)]
|
|
58
|
+
} catch {
|
|
59
|
+
return []
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
return sites.length === 0 || sites.includes(siteOf(host)) ? 'prod' : 'ext'
|
|
63
|
+
}
|
|
64
|
+
|
|
11
65
|
export interface UrlDef {
|
|
12
66
|
/** the address part, `#page:urls:<id>`: kebab-case, unique in its repo */
|
|
13
67
|
id: string
|
|
14
68
|
/** the row's words (default the url's host). A « / » makes folders on the tree: `Kovera/demo` is the leaf
|
|
15
69
|
* « demo » in the folder « Kovera », as deep as it has parts */
|
|
16
70
|
label?: string
|
|
17
|
-
env:
|
|
71
|
+
env: UrlEnv
|
|
18
72
|
url: string
|
|
19
73
|
logins?: LoginDef[]
|
|
20
74
|
}
|
|
@@ -55,7 +109,7 @@ export const labelParts = (label: string): string[] => label.split('/').map((p)
|
|
|
55
109
|
export function urlProblem(d: UrlDef): string | null {
|
|
56
110
|
const at = `url '${String(d?.id)}'`
|
|
57
111
|
if (!KEBAB.test(d?.id ?? '')) return `${at}: id must be kebab-case`
|
|
58
|
-
if (d.env
|
|
112
|
+
if (!isUrlEnv(d.env)) return `${at}: env is ${URL_ENVS.map((e) => `'${e}'`).join(', ')}`
|
|
59
113
|
if (typeof d.url !== 'string' || !/^https?:\/\//.test(d.url)) return `${at}: url must be an http url`
|
|
60
114
|
if (d.label !== undefined && !text(d.label)) return `${at}: label is a text`
|
|
61
115
|
if (d.label !== undefined && labelParts(d.label).some((p) => p === '')) return `${at}: label '${d.label}' has a « / » that makes folders: no empty part`
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// the hub's writes on a repo's urls (wiki tools/shipkit/urls.md, Add a url and its login): a url added, edited or
|
|
2
|
+
// removed, how it opens, a login typed into the vault, a url opened in the identity's Chrome. Each is a word as the
|
|
3
|
+
// owner (http/owner-word.ts, `/api/urls`), so a program's request never reaches here. The one constraint a reader
|
|
4
|
+
// breaks first: a login's password is read once from the body after the secret gate, goes to the store alone, and is
|
|
5
|
+
// in no answer, file, log or thrown line; urls.json holds its vault name, and the account rides in the vault
|
|
6
|
+
import { accountProblem, storeValue } from '../collections/actions.ts'
|
|
7
|
+
import { managerStore, secretsWhere, type SecretStore } from '../secrets/manager.ts'
|
|
8
|
+
import { secretRefusal } from '../http/secret-gate.ts'
|
|
9
|
+
import type { TailnetWho } from '../http/tailnet-caller.ts'
|
|
10
|
+
import { NO_STORE } from '../review/http.ts'
|
|
11
|
+
import { ADDED_FILE, freeId, loginNameOf, loginNameProblem, readAdded, repoPartOf, slugOf, URL_OPENS, writeAdded, type AddedUrls, type UrlOpens } from './added.ts'
|
|
12
|
+
import { loadUrls, type UrlEntry } from './rows.ts'
|
|
13
|
+
import { envOfUrl, labelParts, urlProblem, type UrlDef } from './unit.ts'
|
|
14
|
+
|
|
15
|
+
/** what the writes reach outside the repo: the vault, the identity's Chrome. A test passes fakes */
|
|
16
|
+
export type UrlWriteDeps = {
|
|
17
|
+
/** where a typed password goes; absent: the house store, as `sk secret set` makes it */
|
|
18
|
+
store?: SecretStore
|
|
19
|
+
/** a name's current vault version soft deleted (undone with undelete): 'removed', or why it was not */
|
|
20
|
+
forget?: (name: string) => Promise<'removed' | string>
|
|
21
|
+
/** why this Mac takes no write of a secret (it reads the vault of another Mac), null when it does */
|
|
22
|
+
writeRefusal?: () => Promise<string | null>
|
|
23
|
+
/** the identity this repo speaks as, with its Chrome profile's email */
|
|
24
|
+
identity?: () => Promise<{ id: string; name: string; email: string } | null>
|
|
25
|
+
/** a page opened as a popup of the profile signed in with `email` */
|
|
26
|
+
open?: (url: string, email: string) => Promise<void>
|
|
27
|
+
who?: TailnetWho
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** the longest password the form takes; a longer one, or one of several lines, goes through sk secret set */
|
|
31
|
+
const VALUE_MAX = 16_384
|
|
32
|
+
|
|
33
|
+
const ok = (b: object): Response => Response.json(b, { headers: NO_STORE })
|
|
34
|
+
/** a refusal: its one line as plain text, as the copy route answers one */
|
|
35
|
+
const bad = (why: string, status: number): Response => new Response(why, { status, headers: NO_STORE })
|
|
36
|
+
const text = (v: unknown): string => (typeof v === 'string' ? v.trim() : '')
|
|
37
|
+
|
|
38
|
+
async function body(req: Request): Promise<Record<string, unknown> | null> {
|
|
39
|
+
try {
|
|
40
|
+
const b = (await req.json()) as unknown
|
|
41
|
+
return b != null && typeof b === 'object' && !Array.isArray(b) ? (b as Record<string, unknown>) : null
|
|
42
|
+
} catch {
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const defaultIdentity = async (root: string): Promise<{ id: string; name: string; email: string } | null> => {
|
|
49
|
+
const [{ speakerOfRepo, identitiesRoot }, w] = await Promise.all([import('../veille/identity.ts'), secretsWhere(root).catch(() => null)])
|
|
50
|
+
return speakerOfRepo(w?.own?.speaksAs ?? null, identitiesRoot(root))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const defaultForget = (root: string) => async (name: string): Promise<'removed' | string> => {
|
|
54
|
+
const { removeSecretHere } = await import('../secrets/read.ts')
|
|
55
|
+
const r = await removeSecretHere({ name, cwd: root })
|
|
56
|
+
if (r == null) return 'this Mac runs no vault: its keychain copy stays (sk secret rm --keychain on his yes)'
|
|
57
|
+
return 'refused' in r ? r.refused : 'removed'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const defaultWriteRefusal = async (): Promise<string | null> => (await import('../secrets/read.ts')).masterOnly()
|
|
61
|
+
|
|
62
|
+
const defaultOpen = async (url: string, email: string): Promise<void> => (await import('../veille/chrome.ts')).openPage(url, email, 'popup')
|
|
63
|
+
|
|
64
|
+
/** a url's fields from a body, its id kept: why it cannot be listed, or the def. `prods`: the repo's prod urls, for
|
|
65
|
+
* the env of a body that names none */
|
|
66
|
+
function urlDef(b: Record<string, unknown>, id: string, prods: readonly string[], was?: UrlDef): UrlDef | string {
|
|
67
|
+
const url = text(b.url) || was?.url || ''
|
|
68
|
+
const label = b.label === undefined ? was?.label : text(b.label) || undefined
|
|
69
|
+
const env = b.env === undefined ? (was?.env ?? envOfUrl(url, prods) ?? 'prod') : b.env
|
|
70
|
+
const d = { id, url, env, ...(label != null ? { label } : {}) } as UrlDef
|
|
71
|
+
return urlProblem(d) ?? d
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** the routes, null for a path that is none of them */
|
|
75
|
+
export async function urlWriteRoutes(root: string, req: Request, path: string, deps: UrlWriteDeps = {}): Promise<Response | null> {
|
|
76
|
+
const at = /^\/api\/urls\/(add|edit|remove|opens|login|login\/remove|open)$/.exec(path)?.[1]
|
|
77
|
+
if (at == null) return null
|
|
78
|
+
if (req.method !== 'POST') return bad(`POST ${path}`, 405)
|
|
79
|
+
const b = await body(req)
|
|
80
|
+
if (b == null) return bad('the body is a json object', 400)
|
|
81
|
+
const commit = (a: AddedUrls, what: string): void => writeAdded(root, a, `urls: ${what}`)
|
|
82
|
+
let all: UrlEntry[]
|
|
83
|
+
let added: AddedUrls
|
|
84
|
+
let repo: string | null
|
|
85
|
+
try {
|
|
86
|
+
repo = repoPartOf((await secretsWhere(root)).own)
|
|
87
|
+
;[all, added] = [await loadUrls(root), readAdded(root, repo)]
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return bad(`the urls do not load: ${(e as Error).message}`, 409)
|
|
90
|
+
}
|
|
91
|
+
const id = text(b.id)
|
|
92
|
+
// a name is forgotten only when it is this url's own login name, checked again past the file's own check
|
|
93
|
+
const forgetOwn = async (name: string): Promise<{ removed: boolean; why?: string }> => {
|
|
94
|
+
const bad = loginNameProblem(name, repo, id)
|
|
95
|
+
if (bad != null) return { removed: false, why: `${bad}: left in the vault` }
|
|
96
|
+
return (deps.forget ?? defaultForget(root))(name).then((r) => (r === 'removed' ? { removed: true } : { removed: false, why: r }), (e: Error) => ({ removed: false, why: e.message }))
|
|
97
|
+
}
|
|
98
|
+
const own = (): UrlDef | null => added.urls.find((u) => u.id === id) ?? null
|
|
99
|
+
const prods = all.filter((u) => u.env === 'prod').map((u) => u.url)
|
|
100
|
+
const known = all.find((u) => u.id === id) ?? null
|
|
101
|
+
|
|
102
|
+
if (at === 'add') {
|
|
103
|
+
const url = text(b.url)
|
|
104
|
+
let host = ''
|
|
105
|
+
try { host = new URL(url).hostname } catch { /* urlProblem says it */ }
|
|
106
|
+
const base = slugOf(text(b.label) ? labelParts(text(b.label)).at(-1)! : host, 'url')
|
|
107
|
+
const d = urlDef(b, freeId(base, new Set(all.map((u) => u.id))), prods)
|
|
108
|
+
if (typeof d === 'string') return bad(d, 400)
|
|
109
|
+
commit({ ...added, urls: [...added.urls, d] }, `${d.id} added from the hub`)
|
|
110
|
+
return ok({ id: d.id })
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (known == null) return bad(`no url ${id || '(no id)'} in this repo`, 404)
|
|
114
|
+
|
|
115
|
+
if (at === 'edit' || at === 'remove') {
|
|
116
|
+
const was = own()
|
|
117
|
+
if (was == null) return bad(`${id} is declared in ${known.file}: change it there, the hub edits only the urls of ${ADDED_FILE}`, 409)
|
|
118
|
+
if (at === 'edit') {
|
|
119
|
+
const d = urlDef(b, id, prods, was)
|
|
120
|
+
if (typeof d === 'string') return bad(d, 400)
|
|
121
|
+
commit({ ...added, urls: added.urls.map((u) => (u.id === id ? d : u)) }, `${id} edited from the hub`)
|
|
122
|
+
return ok({ id })
|
|
123
|
+
}
|
|
124
|
+
const names = (added.logins[id] ?? []).flatMap((l) => ('secret' in l ? [l.secret] : []))
|
|
125
|
+
const { [id]: _l, ...logins } = added.logins
|
|
126
|
+
const { [id]: _o, ...opens } = added.opens
|
|
127
|
+
commit({ urls: added.urls.filter((u) => u.id !== id), logins, opens }, `${id} removed from the hub`)
|
|
128
|
+
const vault = await Promise.all(names.map(async (name) => ({ name, ...(await forgetOwn(name)) })))
|
|
129
|
+
return ok({ removed: id, logins: vault })
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (at === 'opens') {
|
|
133
|
+
const how = b.opens
|
|
134
|
+
if (how !== null && !URL_OPENS.includes(how as UrlOpens)) return bad('opens is tab, chrome, frame, or null for the default', 400)
|
|
135
|
+
const { [id]: _o, ...rest } = added.opens
|
|
136
|
+
commit({ ...added, opens: how === null ? rest : { ...rest, [id]: how as UrlOpens } }, `${id} opens ${how ?? 'as the page says'}`)
|
|
137
|
+
return ok({ id, opens: how })
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (at === 'login/remove') {
|
|
141
|
+
const label = text(b.label)
|
|
142
|
+
const mine = added.logins[id] ?? []
|
|
143
|
+
const gone = mine.find((l) => l.label === label)
|
|
144
|
+
if (gone == null) return bad(`${id} has no login « ${label} » added in the hub`, 404)
|
|
145
|
+
const left = mine.filter((l) => l !== gone)
|
|
146
|
+
const { [id]: _l, ...rest } = added.logins
|
|
147
|
+
commit({ ...added, logins: left.length > 0 ? { ...rest, [id]: left } : rest }, `a login of ${id} removed from the hub`)
|
|
148
|
+
return ok({ removed: label, vault: 'secret' in gone ? await forgetOwn(gone.secret) : { removed: true } })
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (at === 'login') {
|
|
152
|
+
// the gate before a value is read: the hub of this Mac or his phone over the tailnet, never another site
|
|
153
|
+
const why = await secretRefusal(req, deps.who ? { who: deps.who } : {})
|
|
154
|
+
if (why != null) return bad(why, 403)
|
|
155
|
+
const label = text(b.label) || 'login'
|
|
156
|
+
const replace = b.replace === true
|
|
157
|
+
const password = typeof b.password === 'string' ? b.password.replace(/[\r\n]+$/, '') : ''
|
|
158
|
+
const account = text(b.account)
|
|
159
|
+
const mine = added.logins[id] ?? []
|
|
160
|
+
const was = mine.find((l) => l.label === label)
|
|
161
|
+
if (replace && was == null) return bad(`${id} has no login « ${label} » added in the hub to replace`, 404)
|
|
162
|
+
if (!replace && known.logins.some((l) => l.label === label)) return bad(`${id} has a login « ${label} » already: replace its password, or name this one otherwise`, 409)
|
|
163
|
+
if (password.trim() === '') return bad('an empty password is not stored', 400)
|
|
164
|
+
if (password.length > VALUE_MAX) return bad(`a password longer than ${VALUE_MAX} characters: store it with sk secret set in a terminal`, 400)
|
|
165
|
+
if (/[\r\n]/.test(password)) return bad('a password of several lines: store it with sk secret set in a terminal', 400)
|
|
166
|
+
if (account === '') return bad('the account too (the email or user name you sign in with), nothing stored', 400)
|
|
167
|
+
const problem = accountProblem(account)
|
|
168
|
+
if (problem != null) return bad(`the account ${problem}, nothing stored`, 400)
|
|
169
|
+
const elsewhere = await (deps.writeRefusal ?? defaultWriteRefusal)()
|
|
170
|
+
if (elsewhere != null) return bad(`${elsewhere}: nothing stored`, 409)
|
|
171
|
+
if (repo == null) return bad(`repo.config.ts names no id: add id: '<the repo's kebab name>' to it, then type the login again`, 409)
|
|
172
|
+
const name = was != null && 'secret' in was ? was.secret : loginNameOf(repo, id, label)
|
|
173
|
+
// replace writes the name the file holds: never one that is not this url's own
|
|
174
|
+
const foreign = loginNameProblem(name, repo, id)
|
|
175
|
+
if (foreign != null) return bad(`${foreign}: nothing stored`, 409)
|
|
176
|
+
if (!replace && mine.some((l) => 'secret' in l && l.secret === name)) return bad(`${name} is the login of another name already: name this one otherwise`, 409)
|
|
177
|
+
try {
|
|
178
|
+
await storeValue({ root, name, value: password, account, store: deps.store ?? managerStore(root), exact: true })
|
|
179
|
+
} catch (e) {
|
|
180
|
+
// storeValue throws a fixed line that holds no value
|
|
181
|
+
return bad((e as Error).message, 502)
|
|
182
|
+
}
|
|
183
|
+
if (was == null) commit({ ...added, logins: { ...added.logins, [id]: [...mine, { label, secret: name }] } }, `a login of ${id} added from the hub`)
|
|
184
|
+
return ok({ stored: name })
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// open: the declared url's origin and the place he is on, in a popup of the identity's Chrome profile
|
|
188
|
+
const atRaw = typeof b.at === 'string' ? b.at : ''
|
|
189
|
+
let target: URL
|
|
190
|
+
try {
|
|
191
|
+
const origin = new URL(known.url).origin
|
|
192
|
+
if (atRaw !== '' && (!atRaw.startsWith('/') || atRaw.startsWith('//') || atRaw.includes('\\'))) throw new Error('at')
|
|
193
|
+
target = atRaw === '' ? new URL(known.url) : new URL(atRaw, origin)
|
|
194
|
+
if (target.origin !== origin) throw new Error('at')
|
|
195
|
+
} catch {
|
|
196
|
+
return bad(`at is a path of ${known.url} (its path, query and fragment), never another site`, 400)
|
|
197
|
+
}
|
|
198
|
+
const who = await (deps.identity ?? (() => defaultIdentity(root)))()
|
|
199
|
+
if (who == null) return bad('this repo speaks as no identity: name one with speaksAs in repo.config.ts', 409)
|
|
200
|
+
if (who.email === '') return bad(`${who.name} has no email: its Chrome profile is the one signed in with it (its identity.md, ## Profile)`, 409)
|
|
201
|
+
try {
|
|
202
|
+
await (deps.open ?? defaultOpen)(target.href, who.email)
|
|
203
|
+
} catch (e) {
|
|
204
|
+
return bad((e as Error).message, 409)
|
|
205
|
+
}
|
|
206
|
+
return ok({ opened: target.href, identity: who.name })
|
|
207
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { existsSync, readFileSync, rmSync } from 'fs'
|
|
7
7
|
import { join } from 'path'
|
|
8
8
|
import { KV_MOUNT } from './layout.ts'
|
|
9
|
+
import { lastWords } from '../problems/failure-words.ts'
|
|
9
10
|
import { markerFile, vaultUrl, type VaultPlace } from './vault-config.ts'
|
|
10
11
|
import { VaultApi, waitHealth } from './vault-http.ts'
|
|
11
12
|
import { killRecorded, notePids, recordedGone } from './vault-restore.ts'
|
|
@@ -47,7 +48,7 @@ export async function destroyInVault(d: { place: VaultPlace; path: string; sealK
|
|
|
47
48
|
const url = vaultUrl(d.place)
|
|
48
49
|
const held: { root: VaultApi | null } = { root: null }
|
|
49
50
|
const act = async (): Promise<number> => {
|
|
50
|
-
if ((await waitHealth(url, (h) => h?.code === 200, { ms: 60_000 }))?.code !== 200) return fail(`the vault did not open:
|
|
51
|
+
if ((await waitHealth(url, (h) => h?.code === 200, { ms: 60_000 }))?.code !== 200) return fail(`the vault did not open: its bao said ${lastWords(join(work, 'bao.log')) ?? 'nothing'}`)
|
|
51
52
|
notePids(work, bao)
|
|
52
53
|
const token = await new VaultApi(url).rootAfterRestore(d.recoveryKey.trim(), 30_000).catch((e: Error) => e)
|
|
53
54
|
if (token instanceof Error) return fail(`a root token from that recovery key: ${token.message}`)
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// holds differently is never overwritten, and a read back that differs stops the import and removes nothing
|
|
6
6
|
import { closeSync, openSync, readFileSync, rmSync, writeSync } from 'fs'
|
|
7
7
|
import { join } from 'path'
|
|
8
|
-
import {
|
|
8
|
+
import { scopeText, type Scope } from '../core/scope.ts'
|
|
9
|
+
import { rowOfName } from '../secrets/name-template.ts'
|
|
9
10
|
import type { Keychain } from '../secrets/keychain.ts'
|
|
10
11
|
import { KV_MOUNT, scopeRefs } from './layout.ts'
|
|
11
12
|
import { SLOTS, type VaultGrant } from './policy.ts'
|
|
@@ -18,22 +19,14 @@ export type RegistryRow = { name: string; for?: Scope; archived?: { at: string }
|
|
|
18
19
|
/** where one name of this machine's keychain goes: its path, or why it has none */
|
|
19
20
|
export type Placed = { name: string; scope: string; path?: string; why?: string }
|
|
20
21
|
|
|
21
|
-
/** a template row (`rv/realm/<word>/thing`) as the names it stands for: each `<word>` one part of a name */
|
|
22
|
-
const templateOf = (name: string): RegExp | null =>
|
|
23
|
-
name.includes('<') ? new RegExp(`^${name.split(/<[a-z-]+>/).map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join(NAME_PART.source.slice(1, -1))}$`) : null
|
|
24
|
-
|
|
25
22
|
/** each registry name this machine's keychain holds, and each `rv/` name it holds with no row, placed. A template row
|
|
26
23
|
* places every name it stands for. A row of several scopes is refused: the node template carries no exact line,
|
|
27
24
|
* and bao refuses a slot value of two parts (vault/policy.ts) */
|
|
28
25
|
export async function placeNames(o: { rows: RegistryRow[]; held: string[]; keyOf: (id: string) => Promise<string | null> }): Promise<Placed[]> {
|
|
29
26
|
const out: Placed[] = []
|
|
30
|
-
const exact = new Map(o.rows.filter((r) => templateOf(r.name) == null).map((r) => [r.name, r]))
|
|
31
|
-
const templates = o.rows.flatMap((r) => {
|
|
32
|
-
const t = templateOf(r.name)
|
|
33
|
-
return t == null ? [] : [{ t, row: r }]
|
|
34
|
-
})
|
|
35
27
|
for (const name of o.held) {
|
|
36
|
-
|
|
28
|
+
// a row with a part places every name it stands for, a template's scope bound from the name (secrets/name-template.ts)
|
|
29
|
+
const row = rowOfName(o.rows, name, { unbound: true })
|
|
37
30
|
if (row == null) {
|
|
38
31
|
out.push({ name, scope: '', why: 'no row in the registry: not imported' })
|
|
39
32
|
continue
|
|
@@ -9,6 +9,7 @@ import { basename, dirname, join } from 'path'
|
|
|
9
9
|
import { homeDir } from '../home/home-paths.ts'
|
|
10
10
|
import { auditLog, dataDir, isSealKey, markerFile, minterTokenFile, refuseRealVault, SEAL_KEY_ID, vaultHcl, vaultPlace, vaultUrl, type MarkerData, type VaultPlace } from './vault-config.ts'
|
|
11
11
|
import { KV_MOUNT } from './layout.ts'
|
|
12
|
+
import { lastWords } from '../problems/failure-words.ts'
|
|
12
13
|
import { VaultApi, vaultHealth, waitHealth } from './vault-http.ts'
|
|
13
14
|
import { setupMinter } from './vault-init.ts'
|
|
14
15
|
import { baoVersion, boundPort, portHolders, startBao, type Bao, type SealStore } from './vault-serve.ts'
|
|
@@ -232,14 +233,14 @@ export async function restoreVault(d: RestoreDeps): Promise<number> {
|
|
|
232
233
|
bao = startWork(work, d)
|
|
233
234
|
state = await awaitActive(url, work, 60_000)
|
|
234
235
|
}
|
|
235
|
-
if (!('active' in state)) return fail(`the restored vault did not turn active in 60 s:
|
|
236
|
+
if (!('active' in state)) return fail(`the restored vault did not turn active in 60 s: its bao said ${lastWords(join(work.dir, 'restore-bao.log')) ?? 'nothing'}`)
|
|
236
237
|
const got = await new VaultApi(url).rootAfterRestore(d.recoveryKey.trim()).catch((e: Error) => e)
|
|
237
238
|
if (got instanceof Error) return fail(`a root token from that recovery key: ${got.message}`)
|
|
238
239
|
const root = new VaultApi(url, got)
|
|
239
240
|
await d.step?.('root')
|
|
240
241
|
const audits = await root.auditFiles()
|
|
241
242
|
const absolute = Object.entries(audits).filter(([, f]) => f.startsWith('/'))
|
|
242
|
-
if (absolute.length > 0) return fail(`the restored vault still holds an audit device on an absolute path (${absolute.map(([k]) => k).join(', ')})
|
|
243
|
+
if (absolute.length > 0) return fail(`the restored vault still holds an audit device on an absolute path (${absolute.map(([k]) => k).join(', ')})`)
|
|
243
244
|
const minterToken = await setupMinter(root)
|
|
244
245
|
writeFileSync(join(work.dir, 'minter-token'), `${minterToken}\n`, { mode: 0o600 })
|
|
245
246
|
const names = (await new VaultApi(url, minterToken).versions(KV_MOUNT)).size
|
package/src/veille/chrome.ts
CHANGED
|
@@ -73,12 +73,27 @@ export function chromeProfile(email: string): string {
|
|
|
73
73
|
return hit[0]
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
/** how a page opens in the profile: a new tab of its window, or a popup (Chrome's app window: the page alone, no tab
|
|
77
|
+
* strip, sized like a page) */
|
|
78
|
+
export type ChromeOpen = 'tab' | 'popup'
|
|
79
|
+
|
|
80
|
+
/** a popup's size in points: a page's, never the screen's */
|
|
81
|
+
export const POPUP_SIZE = { w: 1280, h: 900 } as const
|
|
82
|
+
|
|
83
|
+
/** the one argv a page opens with: the binary itself, so a running Chrome takes it in its own process */
|
|
84
|
+
export const openArgv = (url: string, profile: string, as: ChromeOpen): string[] =>
|
|
85
|
+
[CHROME, `--profile-directory=${profile}`, ...(as === 'popup' ? [`--app=${url}`, `--window-size=${POPUP_SIZE.w},${POPUP_SIZE.h}`] : [url])]
|
|
86
|
+
|
|
87
|
+
/** one page in the Chrome profile signed in with `email`: a new tab of its window, or a popup. Nothing of the window
|
|
88
|
+
* is read back */
|
|
89
|
+
export async function openPage(url: string, email: string, as: ChromeOpen): Promise<void> {
|
|
90
|
+
const open = Bun.spawn(openArgv(url, chromeProfile(email), as), { stdout: 'ignore', stderr: 'pipe' })
|
|
79
91
|
if ((await open.exited) !== 0) throw new Error(`open Chrome: ${(await new Response(open.stderr).text()).trim()}`)
|
|
80
92
|
}
|
|
81
93
|
|
|
94
|
+
/** one page in a new tab of the Chrome profile signed in with `email`, its window left where it is */
|
|
95
|
+
export const openTab = (url: string, email: string): Promise<void> => openPage(url, email, 'tab')
|
|
96
|
+
|
|
82
97
|
/** the pages tiled in the Chrome profile signed in with `email`, then the media selected in a Finder window below them;
|
|
83
98
|
* `media` an absolute file or null */
|
|
84
99
|
export async function openAll(urls: readonly string[], media: string | null, email: string): Promise<void> {
|
package/src/veille/identity.ts
CHANGED
|
@@ -55,6 +55,12 @@ export const identities = (root = identitiesRoot()): VeilleIdentity[] => identit
|
|
|
55
55
|
|
|
56
56
|
export const identityOf = (id: string, root = identitiesRoot()): VeilleIdentity | null => identities(root).find((x) => x.id === id) ?? null
|
|
57
57
|
|
|
58
|
+
/** the identity a repo speaks as (its `speaksAs`, else the default one), Veille or none: where its pages open */
|
|
59
|
+
export function speakerOfRepo(speaksAs: string | null, root = identitiesRoot()): VeilleIdentity | null {
|
|
60
|
+
const own = speakerOf(speaksAs ?? undefined, identitiesOf(root))
|
|
61
|
+
return own == null ? null : veilleOfIdentity(own)
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
export const hasVeille = (x: VeilleIdentity): boolean => existsSync(x.watchFile)
|
|
59
65
|
|
|
60
66
|
/** the identity a Chrome profile is signed in as, by its email; null when none is */
|
package/src/view3d/cam.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
// the eye of a 3D view (view3d/viewer.ts) as numbers: where it looks, its zoom, where it stands, how
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// the eye of a 3D view (view3d/viewer.ts) as numbers: where it looks, its zoom, where it stands, and how a drag, a key
|
|
2
|
+
// and the wheel move it, and whose the wheel is. Pure: no three, no DOM, so a page, the hub and a test share the one
|
|
3
|
+
// rule, and the `cam` frame key is its text. A drag only turns the eye, ↑ ↓ carry it along the way it faces, the wheel
|
|
4
|
+
// zooms in place; a panorama only turns and zooms
|
|
5
5
|
|
|
6
|
-
/** what the eye is in: a panorama around it, a mesh
|
|
6
|
+
/** what the eye is in: a panorama around it, a mesh or a splat it moves through */
|
|
7
7
|
export type Space = 'pano' | 'mesh' | 'splat'
|
|
8
8
|
|
|
9
9
|
/** the eye: where it looks (yaw, pitch in radians, three's YXZ order), its zoom (the fov divided by it), where it stands
|
|
10
|
-
* (x, y, z)
|
|
11
|
-
export type Cam = { yaw: number; pitch: number; zoom: number; x: number; y: number; z: number
|
|
12
|
-
export const CAM0: Cam = { yaw: 0, pitch: 0, zoom: 1, x: 0, y: 0, z: 0
|
|
13
|
-
const CAM_KEYS = ['yaw', 'pitch', 'zoom', 'x', 'y', 'z'
|
|
14
|
-
|
|
15
|
-
/** a move of the drag or the wheel: `turn` looks or orbits, `pan` moves the eye and the point ahead together */
|
|
16
|
-
export type Gesture = 'turn' | 'pan'
|
|
10
|
+
* (x, y, z) */
|
|
11
|
+
export type Cam = { yaw: number; pitch: number; zoom: number; x: number; y: number; z: number }
|
|
12
|
+
export const CAM0: Cam = { yaw: 0, pitch: 0, zoom: 1, x: 0, y: 0, z: 0 }
|
|
13
|
+
const CAM_KEYS = ['yaw', 'pitch', 'zoom', 'x', 'y', 'z'] as const
|
|
17
14
|
|
|
18
15
|
/** where the view is placed, the frame keys' `mode`: a compact `thumb` in a column that scrolls, or the `lightbox`
|
|
19
16
|
* (a page that fills the window is one) */
|
|
@@ -26,7 +23,7 @@ export const wheelIsView = (mode: ViewMode, w: { ctrl: boolean; engaged: boolean
|
|
|
26
23
|
const clamp = (v: number, lo: number, hi: number): number => Math.max(lo, Math.min(hi, v))
|
|
27
24
|
const r3 = (v: number): string => String(Math.round(v * 1000) / 1000)
|
|
28
25
|
|
|
29
|
-
/** the `cam` key: `yaw,pitch,zoom,x,y,z
|
|
26
|
+
/** the `cam` key: `yaw,pitch,zoom,x,y,z`, three decimals; empty at rest (a seventh number of an older key is ignored) */
|
|
30
27
|
export const camText = (c: Cam): string => (CAM_KEYS.some((k) => c[k] !== CAM0[k]) ? CAM_KEYS.map((k) => r3(c[k])).join(',') : '')
|
|
31
28
|
|
|
32
29
|
/** a `cam` key read back: every number it holds, the rest at rest; a value that is no number stays at rest */
|
|
@@ -49,53 +46,40 @@ export function axes(c: Pick<Cam, 'yaw' | 'pitch'>): { fwd: [number, number, num
|
|
|
49
46
|
return { fwd: [-sy * cp, sp, -cy * cp], right: [cy, 0, -sy], up: [sy * sp, cp, cy * sp] }
|
|
50
47
|
}
|
|
51
48
|
|
|
49
|
+
/** a splat's scale (how far ↑ carries the eye in a second): the median distance of its splats from the eye's start,
|
|
50
|
+
* never their signed z, which a 360° splat spreads round the eye to a median near 0 */
|
|
51
|
+
export function splatDepth(centers: readonly (readonly [number, number, number])[], from: readonly [number, number, number] = [0, 0, 0]): number {
|
|
52
|
+
const ds = centers.map(([x, y, z]) => Math.hypot(x - from[0], y - from[1], z - from[2])).sort((a, b) => a - b)
|
|
53
|
+
const median = ds[ds.length >> 1] ?? 0
|
|
54
|
+
return median > 0 ? median : 6
|
|
55
|
+
}
|
|
56
|
+
|
|
52
57
|
/** the eye that stands at `at` and looks along `dir` (a unit vector), the inverse of `axes`: a glb camera as a start */
|
|
53
58
|
export function camAt(at: readonly [number, number, number], dir: readonly [number, number, number]): Cam {
|
|
54
59
|
return { ...CAM0, x: at[0], y: at[1], z: at[2], yaw: Math.atan2(-dir[0], -dir[2]), pitch: Math.asin(Math.max(-1, Math.min(1, dir[1]))) }
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
/** the space the eye is in and its scale: a splat's median depth
|
|
62
|
+
/** the space the eye is in and its scale: a splat's median depth, else a meter */
|
|
58
63
|
export interface Where {
|
|
59
64
|
space: Space
|
|
60
65
|
depth: number
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/** a drag of dx, dy pixels over a stage h pixels high, at a vertical fov of fovDeg. `turn`: the pano and the mesh look
|
|
67
|
-
* around the eye, the splat orbits around the point ahead. `pan`: the eye and that point move together */
|
|
68
|
-
export function drag(c: Cam, w: Where, g: Gesture, dx: number, dy: number, h: number, fovDeg: number): Cam {
|
|
68
|
+
/** a drag of dx, dy pixels over a stage h pixels high, at a vertical fov of fovDeg: the eye turns where it stands, in
|
|
69
|
+
* every space, and nothing else moves (the content follows the pointer) */
|
|
70
|
+
export function look(c: Cam, dx: number, dy: number, h: number, fovDeg: number): Cam {
|
|
69
71
|
const k = (fovDeg * Math.PI) / 180 / Math.max(1, h)
|
|
70
|
-
|
|
71
|
-
const d = distOf(c, w)
|
|
72
|
-
if (g === 'turn') {
|
|
73
|
-
const before = axes(c).fwd
|
|
74
|
-
const t = [c.x + before[0] * d, c.y + before[1] * d, c.z + before[2] * d] as const
|
|
75
|
-
const turned = { ...c, yaw: c.yaw - dx * k, pitch: clamp(c.pitch - dy * k, -1.5, 1.5) }
|
|
76
|
-
const f = axes(turned).fwd
|
|
77
|
-
return { ...turned, x: t[0] - f[0] * d, y: t[1] - f[1] * d, z: t[2] - f[2] * d }
|
|
78
|
-
}
|
|
79
|
-
// the point ahead follows the pointer
|
|
80
|
-
const s = (2 * d * Math.tan((fovDeg * Math.PI) / 360)) / Math.max(1, h)
|
|
81
|
-
const a = axes(c)
|
|
82
|
-
return { ...c, x: c.x + (-dx * a.right[0] + dy * a.up[0]) * s, y: c.y + (-dx * a.right[1] + dy * a.up[1]) * s, z: c.z + (-dx * a.right[2] + dy * a.up[2]) * s }
|
|
72
|
+
return { ...c, yaw: c.yaw + dx * k, pitch: clamp(c.pitch + dy * k, -1.5, 1.5) }
|
|
83
73
|
}
|
|
84
74
|
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
/** a step along the exact way the eye faces, its pitch included (back with a negative step), in the space's scale:
|
|
76
|
+
* meters in a mesh, the splat's depth in a splat; the pano never moves */
|
|
77
|
+
export function forward(c: Cam, w: Where, step: number): Cam {
|
|
78
|
+
if (w.space === 'pano') return c
|
|
88
79
|
const m = step * (w.space === 'splat' ? w.depth : 1)
|
|
89
80
|
const f = axes(c).fwd
|
|
90
|
-
|
|
91
|
-
return w.space === 'splat' ? { ...moved, dist: Math.max(0.05 * w.depth, distOf(c, w) - m) } : moved
|
|
81
|
+
return { ...c, x: c.x + f[0] * m, y: c.y + f[1] * m, z: c.z + f[2] * m }
|
|
92
82
|
}
|
|
93
83
|
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
export function move(c: Cam, w: Where, forward: number, right: number, up: number): Cam {
|
|
97
|
-
if (w.space === 'pano') return c
|
|
98
|
-
const a = axes(w.space === 'mesh' ? { yaw: c.yaw, pitch: 0 } : c)
|
|
99
|
-
const s = w.space === 'splat' ? w.depth : 1
|
|
100
|
-
return { ...c, x: c.x + (a.fwd[0] * forward + a.right[0] * right) * s, y: c.y + (a.fwd[1] * forward + up) * s, z: c.z + (a.fwd[2] * forward + a.right[2] * right) * s }
|
|
101
|
-
}
|
|
84
|
+
/** the zoom times `by`, the eye where it stands: the wheel's only move */
|
|
85
|
+
export const zoomed = (c: Cam, by: number): Cam => ({ ...c, zoom: clamp(c.zoom * by, 0.6, 4) })
|
package/src/view3d/lib.ts
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
// the 3D viewer (view3d/viewer.ts) as one browser module, three and Spark inside it: what the hub serves at
|
|
2
|
-
// /api/review-lib/view3d.mjs for the thread lightbox, built
|
|
2
|
+
// /api/review-lib/view3d.mjs for the thread lightbox, built again whenever a file of view3d/ changed (about 40 ms, 3 MB;
|
|
3
|
+
// a fix lands on the next reload, never only after a restart of the daemon that serves it), and the poster of a
|
|
3
4
|
// splat or a mesh posted with no --image: the viewer drawn alone at rest on a page of its own (`mode=thumb`), shot
|
|
4
5
|
// through the warm browser `sk shot` uses
|
|
6
|
+
import { readdirSync, statSync } from 'node:fs'
|
|
5
7
|
import { extname, join } from 'node:path'
|
|
6
8
|
import { loopbackServe } from '../http/loopback-serve.ts'
|
|
7
9
|
|
|
8
10
|
let built: Promise<{ text: string; tag: string }> | null = null
|
|
11
|
+
let builtFrom = ''
|
|
9
12
|
|
|
10
|
-
/** the
|
|
13
|
+
/** what the sources of `dir` are now: each .ts file's name, size and change time; a few stats, no read */
|
|
14
|
+
export function sourceStamp(dir: string): string {
|
|
15
|
+
return readdirSync(dir)
|
|
16
|
+
.filter((f) => f.endsWith('.ts'))
|
|
17
|
+
.sort()
|
|
18
|
+
.map((f) => {
|
|
19
|
+
const s = statSync(join(dir, f))
|
|
20
|
+
return `${f}:${s.size}:${s.mtimeMs}`
|
|
21
|
+
})
|
|
22
|
+
.join('|')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** the viewer as one ES module and its tag, built on the first ask and again once a source of view3d/ changed */
|
|
11
26
|
export function view3dLib(): Promise<{ text: string; tag: string }> {
|
|
27
|
+
const stamp = sourceStamp(import.meta.dir)
|
|
28
|
+
if (stamp !== builtFrom) built = null
|
|
29
|
+
builtFrom = stamp
|
|
12
30
|
built ??= (async () => {
|
|
13
31
|
const r = await Bun.build({ entrypoints: [join(import.meta.dir, 'viewer.ts')], target: 'browser', format: 'esm', minify: true })
|
|
14
32
|
const out = r.outputs[0]
|