rvlib-shipkit 2.28.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 +75 -1
- package/package.json +11 -2
- package/src/advisors/acts.ts +277 -0
- package/src/advisors/advice.ts +384 -0
- package/src/advisors/advisor-view.ts +417 -0
- package/src/advisors/app-graph.ts +112 -0
- package/src/advisors/app.ts +75 -0
- package/src/advisors/door.ts +59 -0
- package/src/advisors/edge/api.ts +292 -0
- package/src/advisors/edge/bucket.ts +43 -0
- package/src/advisors/edge/certs.ts +20 -0
- package/src/advisors/edge/form.ts +45 -0
- package/src/advisors/edge/handler.ts +156 -0
- package/src/advisors/edge/jwt.ts +76 -0
- package/src/advisors/edge/shell.ts +27 -0
- package/src/advisors/edge/status.ts +12 -0
- package/src/advisors/edge/types.ts +137 -0
- package/src/advisors/edge/worker.ts +52 -0
- package/src/advisors/expose.ts +154 -0
- package/src/advisors/job.ts +35 -0
- package/src/advisors/owner-store.ts +226 -0
- package/src/advisors/photos.ts +182 -0
- package/src/advisors/project.ts +311 -0
- package/src/advisors/r2.ts +46 -0
- package/src/advisors/routes.ts +496 -0
- package/src/advisors/scan.ts +205 -0
- package/src/advisors/sync.ts +363 -0
- package/src/agent-time/accounts-usage-disk.ts +29 -0
- package/src/agent-time/accounts-usage.ts +105 -0
- package/src/agent-time/claude-sessions.ts +32 -0
- package/src/agent-time/hooks.ts +64 -27
- package/src/agent-time/lane-name.ts +7 -0
- package/src/agent-time/leads.ts +95 -0
- package/src/agent-time/live.ts +5 -2
- package/src/agent-time/registry.ts +248 -86
- package/src/agent-time/render.ts +35 -4
- package/src/agent-time/report-cache.ts +4 -8
- package/src/agent-time/report.ts +19 -1
- package/src/agent-time/store.ts +16 -20
- package/src/annex/snapshots.ts +3 -3
- package/src/annex/tidy.ts +10 -23
- package/src/asks/ask-after.ts +2 -1
- package/src/asks/ask-carry.ts +190 -0
- package/src/asks/ask-close.ts +72 -0
- package/src/asks/ask-doc.ts +42 -0
- package/src/asks/ask-migrate.ts +9 -9
- package/src/asks/ask-steps-fold.ts +71 -114
- package/src/asks/ask-store.ts +190 -58
- package/src/asks/ask-words-fold.ts +208 -0
- package/src/check.ts +9 -1
- package/src/checks/SK001-package-json-shape.check.ts +6 -7
- package/src/checks/SK003-claude-md-shape.check.ts +1 -0
- package/src/checks/SK004-gitignore-policy.check.ts +25 -19
- package/src/checks/SK008-reviewer-agent.check.ts +4 -7
- package/src/checks/SK010-undeclared-unit.check.ts +77 -64
- package/src/checks/SK013-one-way-in-policy.check.ts +21 -8
- 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 +47 -6
- package/src/checks/SK033-global-contribution.check.ts +2 -1
- package/src/checks/SK034-commit-gates-armed.check.ts +1 -0
- package/src/checks/SK036-draft-media-size.check.ts +5 -4
- package/src/checks/SK039-vscode-watch-generated.check.ts +2 -1
- package/src/checks/SK040-release-words.check.ts +39 -10
- package/src/checks/SK042-post-kinds.check.ts +2 -2
- package/src/checks/SK045-slow-hooks.check.ts +5 -2
- package/src/checks/SK049-thread-answers-hook.check.ts +11 -5
- package/src/checks/SK050-retired-commands.check.ts +1 -0
- package/src/checks/SK051-no-formatter.check.ts +486 -0
- package/src/cli/channel-run.ts +17 -0
- package/src/cli/cmd_Advisors.ts +357 -0
- package/src/cli/cmd_Annex.ts +10 -10
- package/src/cli/cmd_Asks.ts +113 -12
- package/src/cli/cmd_Backup.ts +12 -8
- package/src/cli/cmd_CacheAudit.ts +2 -2
- package/src/cli/cmd_Channel.ts +43 -0
- package/src/cli/cmd_Check.ts +3 -3
- package/src/cli/cmd_Checks.ts +1 -1
- package/src/cli/cmd_Ci.ts +15 -16
- package/src/cli/cmd_Db.ts +9 -9
- package/src/cli/cmd_FleetPush.ts +1 -1
- package/src/cli/cmd_GlobalProcesses.ts +1 -0
- package/src/cli/cmd_History.ts +2 -2
- package/src/cli/cmd_Home.ts +17 -11
- package/src/cli/cmd_Hooks.ts +14 -4
- package/src/cli/cmd_Hq.ts +73 -19
- package/src/cli/cmd_Keys.ts +1 -1
- package/src/cli/cmd_Lanes.ts +22 -4
- package/src/cli/cmd_Media.ts +67 -16
- package/src/cli/cmd_Orchestrator.ts +307 -0
- package/src/cli/cmd_OrchestratorRole.ts +163 -0
- package/src/cli/cmd_Rec.ts +5 -2
- package/src/cli/cmd_Reflect.ts +17 -3
- package/src/cli/cmd_Releases.ts +38 -38
- package/src/cli/cmd_Review.ts +760 -409
- package/src/cli/cmd_Secret.ts +44 -14
- package/src/cli/cmd_Shot.ts +12 -6
- package/src/cli/cmd_Social.ts +5 -4
- package/src/cli/cmd_SocialDrafts.ts +23 -10
- package/src/cli/cmd_Sound.ts +1 -0
- package/src/cli/cmd_Space.ts +1 -1
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_ThreadKinds.ts +18 -11
- package/src/cli/cmd_ThreadReflect.ts +20 -12
- package/src/cli/cmd_ThreadSyncNeeds.ts +7 -7
- package/src/cli/cmd_Time.ts +2 -1
- package/src/cli/cmd_Tmp.ts +9 -8
- package/src/cli/cmd_TraceAudit.ts +1 -1
- package/src/cli/cmd_Trailer.ts +5 -5
- package/src/cli/cmd_Urls.ts +6 -6
- package/src/cli/cmd_Vault.ts +4 -4
- package/src/cli/cmd_When.ts +1 -1
- package/src/cli/cmd_Worktrees.ts +109 -0
- package/src/cli/inbox-hook-run.ts +109 -0
- package/src/cli/registry.ts +19 -4
- package/src/cli/review-here.ts +136 -0
- package/src/cli.ts +64 -25
- package/src/collections/actions.ts +7 -5
- package/src/collections/checks.ts +6 -1
- package/src/collections/collection-types.ts +20 -8
- package/src/collections/pings.ts +7 -1
- package/src/collections/providers.ts +21 -19
- package/src/collections/review.ts +25 -23
- package/src/collections/state-rules.ts +8 -7
- package/src/collections/tests.ts +7 -4
- package/src/comfy/comfy-panel.ts +2 -2
- package/src/commands/model.ts +1 -1
- package/src/commands/routes.ts +1 -1
- package/src/commands/runs.ts +1 -1
- package/src/core/app-icon-frame.ts +62 -0
- package/src/core/app-icon.ts +178 -22
- package/src/core/archived.ts +10 -7
- package/src/core/atomic-write.ts +36 -0
- package/src/core/budget.ts +16 -1
- package/src/core/bun-builtins.ts +7 -7
- package/src/core/canonical-scripts.ts +4 -6
- package/src/core/check-ctx.ts +54 -6
- package/src/core/check-pass.ts +7 -0
- package/src/core/day-stamp.ts +20 -0
- package/src/core/foreign.ts +87 -0
- package/src/core/git-bin.ts +10 -0
- package/src/core/git.ts +60 -16
- package/src/core/gui-color.ts +75 -0
- package/src/core/hard-reset.ts +1 -2
- package/src/core/history-files.ts +4 -8
- package/src/core/house-layout.ts +3 -0
- package/src/core/hub-theme.ts +14 -0
- package/src/core/identity.ts +1 -1
- package/src/core/in-base.ts +19 -0
- package/src/core/instance.ts +15 -5
- package/src/core/last-good.ts +42 -133
- package/src/core/layout.ts +4 -1
- package/src/core/load-probe.ts +4 -8
- package/src/core/locked-write.ts +117 -47
- package/src/core/loop-watch.ts +24 -3
- package/src/core/machine-commit.ts +9 -1
- package/src/core/machine-db.ts +54 -12
- package/src/core/machine-link.ts +1 -1
- package/src/core/memory-watch.ts +3 -2
- package/src/core/motherhome.ts +2 -1
- package/src/core/nearest.ts +23 -0
- package/src/core/on-loop.ts +57 -0
- package/src/core/one-lib.ts +2 -1
- package/src/core/one-way-in-policy.ts +43 -25
- package/src/core/owner-word-policy.ts +123 -0
- package/src/core/panel-shades.ts +140 -0
- package/src/core/raw-access.ts +9 -2
- package/src/core/reexec.ts +3 -5
- package/src/core/repo-gui-color.ts +16 -0
- package/src/core/repo-walk.ts +104 -0
- package/src/core/retention.ts +10 -12
- package/src/core/role-policy.ts +17 -0
- package/src/core/run-dirs.ts +45 -0
- package/src/core/runs-matrix.ts +1 -1
- package/src/core/scope.ts +6 -3
- package/src/core/slots.ts +2 -2
- package/src/core/slug.ts +33 -0
- package/src/core/spawn-timeout.ts +3 -1
- package/src/core/squircle.ts +0 -8
- package/src/core/throwaway-worktree.ts +21 -2
- package/src/core/tmux-policy.ts +264 -0
- package/src/core/unit-files.ts +4 -4
- package/src/core/unit-icon.ts +43 -0
- package/src/core/when-block.ts +4 -5
- package/src/core/when.ts +1 -3
- package/src/core/words.ts +33 -0
- package/src/fleet/push-fleet.ts +6 -11
- package/src/fleet/scan-fleet.ts +3 -0
- package/src/{core → gate}/cache-audit.ts +8 -2
- package/src/{core → gate}/check-runner.ts +24 -54
- package/src/{core → gate}/discover-checks.ts +5 -102
- package/src/{core → gate}/discover-legacy-checks.ts +3 -3
- package/src/{ledger → gate}/gate-checks.ts +19 -14
- package/src/gate/head-gate.ts +151 -0
- package/src/{core → gate}/job-follow.ts +1 -1
- package/src/{core → gate}/job-run.ts +3 -3
- package/src/{core → gate}/pre-commit-discovery.ts +2 -2
- package/src/{core → gate}/run-check.ts +7 -7
- package/src/{core → gate}/run-ci.ts +9 -9
- package/src/gate/run-fix.ts +198 -0
- package/src/{core → gate}/run-fixers.ts +22 -17
- package/src/{core → gate}/trace-audit.ts +8 -8
- package/src/home/activity-shape.ts +3 -1
- package/src/home/activity.ts +15 -12
- package/src/home/app-sign.ts +17 -9
- package/src/home/daemon-guard.ts +24 -0
- package/src/home/daemon-jobs.ts +66 -16
- package/src/home/database-words.ts +21 -27
- package/src/home/databases.ts +3 -3
- package/src/home/global-context.ts +2 -2
- package/src/home/global-units.ts +1 -1
- package/src/home/gui-app/ShipkitGui.swift +2129 -187
- package/src/home/gui-app/icon.svg +8 -0
- package/src/home/gui-app.ts +95 -31
- package/src/home/handover.ts +126 -0
- package/src/home/home-move.ts +29 -16
- package/src/home/home-paths.ts +30 -8
- package/src/home/home-routes.ts +120 -6
- package/src/home/home-start.ts +28 -4
- package/src/home/home-state.ts +12 -6
- package/src/home/hubs.ts +28 -5
- package/src/home/inbox-shape.ts +64 -37
- package/src/home/inbox.ts +2 -1
- package/src/home/lib-watch.ts +93 -74
- package/src/home/log-follow.ts +117 -0
- package/src/home/machine-fold.ts +47 -44
- package/src/home/machine-repair.ts +5 -6
- package/src/home/machine-stores.ts +3 -3
- package/src/home/machine-temp.ts +58 -67
- package/src/home/open-app.ts +9 -3
- package/src/home/page-build.ts +334 -0
- package/src/home/page-held.ts +338 -0
- package/src/home/pm-config.ts +2 -2
- package/src/home/pm.ts +96 -5
- package/src/home/process-apps.ts +73 -26
- package/src/home/process-rows.ts +16 -1
- package/src/home/push-sources.ts +137 -0
- package/src/home/resources.ts +16 -7
- package/src/home/run-daemon.ts +58 -5
- package/src/home/run-pm.ts +2 -1
- package/src/home/run-web.ts +11 -6
- package/src/home/search-shape.ts +54 -0
- package/src/home/search.ts +114 -0
- package/src/home/serve-daemon.ts +51 -20
- package/src/home/serve-web.ts +214 -149
- package/src/home/space-page.ts +10 -10
- package/src/home/space-route.ts +2 -2
- package/src/home/space-words.ts +11 -10
- package/src/home/supervise.ts +26 -1
- package/src/home/time-page-shape.ts +0 -13
- package/src/home/vault-page.ts +17 -16
- package/src/home/vault-reveal.ts +29 -0
- package/src/home/vault-words.ts +3 -3
- package/src/home/via-hub.ts +3 -4
- package/src/home/web-places.ts +239 -0
- package/src/home/widgets.ts +16 -2
- package/src/home/worktree-tidy.ts +236 -0
- package/src/hooks/commit-message.ts +11 -9
- package/src/hooks/edit-guard.ts +12 -0
- package/src/hooks/hook-gates.ts +2 -0
- package/src/hooks/leak-guard.ts +9 -3
- package/src/hooks/one-way-in-guard.ts +146 -61
- package/src/hooks/run-hooks.ts +70 -7
- package/src/hooks/shared-file.ts +364 -0
- package/src/hooks/shell-writes.ts +620 -0
- package/src/hooks/write-log.ts +149 -0
- package/src/{serve → house}/project-gutter.ts +5 -1
- package/src/hq/door-route.ts +64 -8
- package/src/hq/door.ts +47 -14
- package/src/hq/files-send.ts +5 -5
- package/src/hq/forgotten-log.ts +1 -1
- package/src/hq/history-check.ts +7 -6
- package/src/hq/history-send.ts +15 -15
- package/src/hq/hq-db.ts +11 -4
- package/src/hq/hq-local.ts +36 -15
- package/src/hq/hq-routes.ts +4 -2
- package/src/hq/hq-store.ts +13 -7
- package/src/hq/kinds/ask.ts +4 -3
- package/src/hq/kinds/index.ts +5 -4
- package/src/hq/kinds/{card-gone.ts → item-gone.ts} +24 -25
- package/src/hq/kinds/{card-msg.ts → item-msg.ts} +25 -27
- package/src/hq/kinds/{card.ts → item.ts} +31 -29
- package/src/hq/kinds/kind.ts +12 -4
- package/src/hq/kinds/media.ts +2 -3
- package/src/hq/kinds/presence-rule.ts +56 -0
- package/src/hq/kinds/presence.ts +210 -0
- package/src/hq/kinds/prompt.ts +2 -1
- package/src/hq/kinds/report.ts +8 -5
- package/src/hq/kinds/time-day.ts +5 -4
- package/src/hq/lead-order.ts +68 -0
- package/src/hq/ledger.ts +22 -22
- package/src/hq/machine-notes.ts +14 -15
- package/src/hq/outbox.ts +38 -22
- package/src/hq/replica.ts +5 -7
- package/src/hq/report-facts.ts +14 -7
- package/src/hq/report.ts +57 -14
- package/src/hq/switch.ts +21 -23
- package/src/hq/terminal-hop.ts +64 -0
- package/src/hq/{cards.ts → thread-sync.ts} +140 -105
- package/src/hq/vault-route.ts +1 -1
- package/src/{serve → http}/door-forward.ts +21 -16
- package/src/{serve → 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 +106 -0
- package/src/http/owner-word.ts +128 -0
- package/src/{serve → http}/same-origin.ts +15 -2
- package/src/{serve → http}/tailnet-caller.ts +5 -4
- package/src/identities/machine-route.ts +2 -2
- package/src/identities/shown.ts +2 -6
- package/src/ledger/check-table.ts +1 -1
- package/src/ledger/db.ts +1 -0
- package/src/ledger/git-key.ts +9 -3
- package/src/ledger/git-scan.ts +2 -2
- package/src/ledger/ledger.ts +6 -16
- package/src/ledger/run-log.ts +25 -1
- package/src/media-kinds.ts +4 -1
- package/src/media-store/backup/daemon.ts +3 -2
- package/src/media-store/backup/keys.ts +0 -3
- package/src/media-store/backup/manifest.ts +1 -1
- package/src/media-store/backup/prune.ts +15 -18
- package/src/media-store/backup/retention.ts +2 -2
- package/src/media-store/backup/run.ts +8 -27
- package/src/media-store/backup/sources.ts +63 -17
- package/src/media-store/backup/thread-copy.ts +16 -13
- package/src/media-store/backup/watch.ts +10 -6
- package/src/media-store/content.ts +3 -0
- package/src/media-store/copy/config.ts +10 -9
- package/src/media-store/copy/night.ts +4 -4
- package/src/media-store/daemon.ts +10 -6
- package/src/media-store/db.ts +10 -20
- package/src/media-store/forget-one.ts +247 -0
- package/src/media-store/forget.ts +23 -4
- package/src/media-store/hq-send.ts +5 -4
- package/src/media-store/purge.ts +2 -2
- package/src/media-store/put.ts +3 -0
- package/src/media-store/remote.ts +2 -2
- package/src/media-store/space-listing.ts +0 -5
- package/src/media-store/space.ts +15 -16
- package/src/media-store/tidy.ts +3 -3
- package/src/media-store/upload.ts +6 -2
- package/src/media-store/webp.ts +3 -3
- package/src/messages/collection.ts +2 -2
- package/src/messages/model.ts +6 -1
- package/src/messages/objects.ts +5 -3
- package/src/messages/routes.ts +3 -0
- package/src/messages/score.ts +1 -3
- package/src/messages/store-doc.ts +114 -0
- package/src/messages/verdicts.ts +6 -0
- package/src/messages/write.ts +3 -3
- package/src/mv/mv-md.ts +43 -12
- package/src/orchestrator/brief.md +31 -0
- package/src/orchestrator/channel-declare.ts +58 -0
- package/src/orchestrator/channel.ts +226 -0
- package/src/orchestrator/guards.ts +72 -0
- 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 +101 -0
- 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 +28 -0
- package/src/orchestrator/presence.ts +79 -0
- package/src/orchestrator/push.ts +97 -0
- package/src/orchestrator/role-shape.ts +270 -0
- package/src/orchestrator/role.ts +242 -0
- package/src/orchestrator/routes.ts +218 -0
- 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 +79 -0
- package/src/pages/frame-client.ts +44 -6
- package/src/pages/unit.ts +1 -1
- package/src/plan/repo-source.ts +1 -1
- package/src/problems/failure-words.ts +80 -0
- package/src/recordings/load.ts +1 -1
- package/src/recordings/model.ts +18 -10
- package/src/recordings/place.ts +3 -3
- package/src/recordings/recorder-app/Capture.swift +69 -21
- package/src/recordings/recorder-app/Editor.swift +214 -11
- package/src/recordings/recorder-app/main.swift +229 -47
- package/src/recordings/recorder-app.ts +1 -1
- package/src/recordings/routes.ts +11 -1
- package/src/recordings/take.ts +7 -5
- package/src/recordings/view.ts +6 -0
- package/src/reflect/prompt-corpus.ts +5 -3
- package/src/reflect/thread-words.ts +51 -0
- package/src/reflections/reflection-close.ts +123 -0
- package/src/reflections/reflection-doc.ts +59 -0
- package/src/reflections/reflection-place.ts +60 -0
- package/src/release/gate-checkout.ts +122 -20
- package/src/release/git-facts.ts +9 -8
- package/src/release/machine-words.ts +21 -3
- package/src/release/public-clean.ts +78 -19
- package/src/release/run-bump.ts +29 -10
- package/src/release/run-release.ts +76 -52
- package/src/releases/add.ts +33 -87
- package/src/releases/{from-card.ts → from-thread.ts} +47 -46
- package/src/releases/model.ts +207 -36
- package/src/releases/routes.ts +2 -2
- package/src/releases/shape.ts +184 -0
- package/src/releases/store.ts +10 -10
- package/src/repo-config.ts +46 -8
- package/src/review/anim.ts +7 -7
- package/src/review/answer-kinds.ts +39 -10
- package/src/review/aside-at.ts +19 -0
- package/src/review/auto.ts +3 -3
- package/src/review/band.ts +95 -3
- package/src/review/branch-hold.ts +12 -5
- package/src/review/cells.ts +169 -46
- package/src/review/doc-card.ts +41 -0
- package/src/review/doc-model.ts +100 -0
- package/src/review/doc-routes.ts +66 -0
- package/src/review/doc-save.ts +152 -0
- package/src/review/{draft-card.ts → draft-item.ts} +10 -7
- package/src/review/draft-model.ts +125 -17
- package/src/review/events.ts +5 -12
- package/src/review/file-tags.ts +52 -0
- package/src/review/format.ts +84 -41
- package/src/review/gone.ts +20 -20
- package/src/review/hand-over.ts +58 -0
- package/src/review/heard.ts +29 -0
- package/src/review/house-kind-defs.ts +34 -4
- package/src/review/http.ts +1 -1
- package/src/review/inbox-hook.ts +64 -10
- package/src/review/inbox-read.ts +54 -16
- package/src/review/instruction-guards.ts +137 -0
- package/src/review/instructions.ts +56 -2
- package/src/review/{card-db.ts → item-db.ts} +84 -32
- package/src/review/{card-rows.ts → item-rows.ts} +77 -50
- package/src/review/kind-still.ts +125 -0
- package/src/review/kinds.ts +46 -10
- package/src/review/lane-ask.ts +6 -2
- package/src/review/live-post.ts +107 -0
- package/src/review/live-view.ts +137 -0
- package/src/review/media-kind.ts +4 -4
- package/src/review/media-read.ts +4 -4
- package/src/review/media.ts +3 -5
- package/src/review/mentions.ts +102 -0
- package/src/review/model-moved.ts +76 -0
- package/src/review/model.ts +474 -151
- package/src/review/move.ts +59 -58
- package/src/review/need-address.ts +5 -5
- package/src/review/need-threads.ts +15 -57
- package/src/review/notes.ts +2 -1
- package/src/review/one-block.ts +64 -0
- package/src/review/owner-read.ts +41 -0
- package/src/review/owner-verdict.ts +3 -3
- package/src/review/parties.ts +172 -11
- package/src/review/paste.ts +4 -4
- package/src/review/phone-push.ts +137 -0
- package/src/review/previews.ts +16 -16
- package/src/review/project.ts +1 -1
- package/src/review/push.ts +286 -0
- package/src/review/referring.ts +26 -4
- package/src/review/reflection-object.ts +13 -18
- package/src/review/rev.ts +1 -1
- package/src/review/role.ts +3 -3
- package/src/review/routes.ts +124 -77
- package/src/review/search-index.ts +218 -0
- package/src/review/search-job.ts +40 -0
- package/src/review/search-ocr.ts +138 -0
- package/src/review/search-text.ts +129 -0
- package/src/review/secret-route.ts +45 -15
- package/src/review/settle.ts +67 -0
- package/src/review/snooze.ts +1 -16
- package/src/review/stage-routes.ts +15 -13
- package/src/review/{stage-card.ts → stage-thread.ts} +18 -17
- package/src/review/store-index.ts +49 -0
- package/src/review/store-parties.ts +22 -0
- package/src/review/store.ts +394 -214
- package/src/review/supersede.ts +23 -7
- package/src/review/take-back.ts +20 -6
- package/src/review/threads.ts +196 -64
- package/src/review/traces.ts +21 -33
- package/src/review/trailer-desk.ts +7 -7
- package/src/review/{trailer-card.ts → trailer-item.ts} +10 -10
- package/src/review/trailer-model.ts +4 -4
- package/src/review/trailer-notes.ts +2 -2
- package/src/review/trailer-routes.ts +5 -4
- package/src/review/trailer-shots.ts +3 -3
- package/src/review/unit.ts +71 -9
- package/src/review/uploads.ts +103 -0
- package/src/review/verdict-items.ts +2 -2
- package/src/review/verdict-write.ts +1 -1
- package/src/review/view-layout.ts +76 -0
- package/src/review/wait.ts +11 -5
- package/src/review/wakes.ts +115 -0
- package/src/review/watch-feed.ts +183 -0
- package/src/review/watchers.ts +48 -6
- package/src/rules/untrack-generated.ts +40 -39
- package/src/scaffold/files/bunfig.toml +1 -9
- package/src/scaffold/files/vscode-settings.json +1 -1
- package/src/scaffold/project-scaffold.ts +14 -10
- package/src/secrets/archive.ts +2 -1
- package/src/secrets/key-pair.ts +14 -0
- package/src/secrets/keychain-write.ts +11 -3
- package/src/secrets/lapse-mark.ts +8 -3
- package/src/secrets/lapse.ts +28 -17
- 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/security-line.ts +19 -0
- package/src/secrets/who-reads.ts +2 -1
- package/src/serve/embed.ts +1 -1
- package/src/serve/frame-part.ts +49 -0
- package/src/serve/house-runs.ts +1 -1
- package/src/serve/hub-app/accounts-line.tsx +55 -0
- package/src/serve/hub-app/activity-st.ts +50 -53
- package/src/serve/hub-app/activity-view.tsx +10 -9
- package/src/serve/hub-app/advice-box.tsx +67 -0
- package/src/serve/hub-app/advisor-app.tsx +48 -0
- package/src/serve/hub-app/advisor-face.tsx +30 -0
- package/src/serve/hub-app/advisor-host.ts +142 -0
- package/src/serve/hub-app/advisor.html +23 -0
- package/src/serve/hub-app/advisors-st.ts +261 -0
- package/src/serve/hub-app/advisors-view.tsx +311 -0
- package/src/serve/hub-app/advisors.css +61 -0
- package/src/serve/hub-app/app-bridge.ts +53 -24
- package/src/serve/hub-app/ask-steps-st.ts +60 -0
- package/src/serve/hub-app/ask-steps.tsx +23 -0
- package/src/serve/hub-app/asked-page.ts +24 -0
- package/src/serve/hub-app/asks-page.tsx +16 -9
- package/src/serve/hub-app/asks-st.ts +1 -4
- package/src/serve/hub-app/auto-text.tsx +110 -16
- 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 +41 -9
- package/src/serve/hub-app/code-copy.ts +173 -12
- package/src/serve/hub-app/col-card.tsx +15 -21
- package/src/serve/hub-app/col-list-page.tsx +14 -8
- package/src/serve/hub-app/col-list-st.ts +18 -3
- package/src/serve/hub-app/col-tables-view.tsx +8 -44
- package/src/serve/hub-app/col-tables.ts +14 -22
- package/src/serve/hub-app/cols-svc.ts +17 -13
- package/src/serve/hub-app/columns.ts +94 -0
- package/src/serve/hub-app/comfy-svc.ts +3 -2
- 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 +37 -27
- package/src/serve/hub-app/controls.css +80 -18
- package/src/serve/hub-app/cursor-spot.ts +81 -0
- package/src/serve/hub-app/cycle-button.tsx +2 -1
- package/src/serve/hub-app/database-st.ts +32 -27
- package/src/serve/hub-app/database-view.tsx +16 -14
- package/src/serve/hub-app/deaf.tsx +27 -0
- package/src/serve/hub-app/dock-st.ts +72 -26
- package/src/serve/hub-app/dock-view.tsx +32 -12
- package/src/serve/hub-app/editor/doc-editor-st.ts +223 -0
- package/src/serve/hub-app/editor/doc-editor.tsx +116 -0
- package/src/serve/hub-app/editor/doc-saved.tsx +26 -0
- package/src/serve/hub-app/editor/doc-slot.ts +66 -0
- package/src/serve/hub-app/editor.css +36 -0
- package/src/serve/hub-app/emoji-names.ts +1915 -0
- package/src/serve/hub-app/emoji.ts +133 -0
- 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 +217 -7
- package/src/serve/hub-app/geometry-view.tsx +3 -2
- package/src/serve/hub-app/git-st.ts +25 -19
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/hash-route.ts +15 -3
- package/src/serve/hub-app/header-bar.tsx +53 -35
- package/src/serve/hub-app/held-keys.ts +25 -0
- package/src/serve/hub-app/home-st.ts +238 -23
- package/src/serve/hub-app/home-strip.css +24 -12
- package/src/serve/hub-app/home-strip.tsx +134 -66
- package/src/serve/hub-app/home.html +12 -0
- package/src/serve/hub-app/hub-app.tsx +123 -81
- package/src/serve/hub-app/hub.css +92 -89
- package/src/serve/hub-app/icons.tsx +26 -0
- package/src/serve/hub-app/identities-st.ts +53 -78
- package/src/serve/hub-app/identities-view.tsx +34 -30
- 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 +57 -11
- package/src/serve/hub-app/inbox-view.tsx +24 -12
- package/src/serve/hub-app/inbox.css +7 -3
- package/src/serve/hub-app/index.html +12 -0
- package/src/serve/hub-app/insights-st.ts +27 -19
- package/src/serve/hub-app/insights-view.tsx +6 -5
- package/src/serve/hub-app/instructions.css +13 -7
- package/src/serve/hub-app/kept-cols.tsx +83 -20
- package/src/serve/hub-app/kept-folds.ts +43 -0
- package/src/serve/hub-app/kept-width.tsx +76 -0
- package/src/serve/hub-app/keys.ts +122 -38
- package/src/serve/hub-app/later.tsx +1 -1
- package/src/serve/hub-app/layout-st.ts +118 -77
- 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-bar.css +12 -0
- 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 +12 -2
- package/src/serve/hub-app/machine-st.ts +105 -18
- package/src/serve/hub-app/machines-st.ts +40 -34
- package/src/serve/hub-app/machines-view.tsx +5 -5
- 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/markdown.css +81 -4
- package/src/serve/hub-app/md.ts +155 -9
- package/src/serve/hub-app/media-svc.ts +49 -16
- package/src/serve/hub-app/media-view.tsx +13 -12
- package/src/serve/hub-app/messages/messages-page.tsx +63 -18
- package/src/serve/hub-app/messages/messages-st.ts +29 -22
- package/src/serve/hub-app/new-thread-st.ts +170 -0
- package/src/serve/hub-app/new-thread.tsx +147 -0
- package/src/serve/hub-app/objects.css +1 -0
- package/src/serve/hub-app/orchestrator-line.tsx +174 -0
- package/src/serve/hub-app/orchestrator-places.tsx +86 -0
- package/src/serve/hub-app/orchestrator.css +89 -0
- package/src/serve/hub-app/page-keys.ts +111 -69
- package/src/serve/hub-app/page-reload.ts +151 -0
- package/src/serve/hub-app/pages-frames.tsx +42 -4
- package/src/serve/hub-app/pages-svc.ts +11 -4
- package/src/serve/hub-app/palette-st.ts +200 -40
- package/src/serve/hub-app/palette-view.tsx +32 -8
- package/src/serve/hub-app/pane-boundary.tsx +13 -0
- package/src/serve/hub-app/pane-errors.ts +2 -1
- 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/pano.css +20 -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 +4 -3
- package/src/serve/hub-app/planned-st.ts +30 -26
- package/src/serve/hub-app/planned-view.tsx +16 -9
- package/src/serve/hub-app/polled.ts +211 -0
- package/src/serve/hub-app/presence-st.ts +144 -0
- 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 +39 -149
- package/src/serve/hub-app/project-list.tsx +63 -344
- package/src/serve/hub-app/projects-svc.ts +166 -87
- package/src/serve/hub-app/push-sign.tsx +16 -0
- package/src/serve/hub-app/push-svc.ts +290 -0
- package/src/serve/hub-app/quiet-st.ts +61 -0
- package/src/serve/hub-app/rail-groups.ts +144 -0
- package/src/serve/hub-app/reach.ts +16 -0
- package/src/serve/hub-app/reader-chips.tsx +2 -1
- package/src/serve/hub-app/recordings-st.ts +171 -10
- package/src/serve/hub-app/recordings-take.ts +58 -0
- package/src/serve/hub-app/recordings-view.tsx +51 -72
- package/src/serve/hub-app/recordings.css +0 -2
- package/src/serve/hub-app/reflections-page.tsx +24 -8
- package/src/serve/hub-app/releases/releases-page.tsx +56 -22
- package/src/serve/hub-app/releases/releases-st.ts +39 -26
- package/src/serve/hub-app/releases.css +4 -0
- package/src/serve/hub-app/repo-sections.ts +143 -43
- package/src/serve/hub-app/repo-st.ts +91 -43
- package/src/serve/hub-app/review/advisor-bar.tsx +41 -0
- package/src/serve/hub-app/review/ask-proof.tsx +79 -0
- package/src/serve/hub-app/review/attach-st.ts +195 -0
- package/src/serve/hub-app/review/attach-view.tsx +261 -0
- 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/clip-st.ts +1 -1
- package/src/serve/hub-app/review/cta.tsx +11 -0
- package/src/serve/hub-app/review/diff-view.tsx +40 -37
- package/src/serve/hub-app/review/doc-body.tsx +110 -0
- package/src/serve/hub-app/review/dock.tsx +38 -23
- package/src/serve/hub-app/review/draft-body.tsx +236 -0
- package/src/serve/hub-app/review/faces.tsx +18 -0
- package/src/serve/hub-app/review/group-block.tsx +80 -49
- package/src/serve/hub-app/review/heard-line.tsx +32 -0
- package/src/serve/hub-app/review/instructions-view.tsx +58 -32
- package/src/serve/hub-app/review/item-verdict.tsx +99 -26
- package/src/serve/hub-app/review/kind-states.tsx +149 -76
- package/src/serve/hub-app/review/kind-view.tsx +22 -7
- package/src/serve/hub-app/review/kit.tsx +27 -31
- package/src/serve/hub-app/review/lane-bar.tsx +33 -31
- package/src/serve/hub-app/review/lightbox.tsx +18 -0
- package/src/serve/hub-app/review/line-window.ts +149 -0
- package/src/serve/hub-app/review/live-bar-st.ts +145 -0
- package/src/serve/hub-app/review/live-bar.tsx +127 -0
- package/src/serve/hub-app/review/live-view.tsx +105 -0
- package/src/serve/hub-app/review/mention-st.ts +85 -0
- package/src/serve/hub-app/review/mesh-view.tsx +9 -0
- package/src/serve/hub-app/review/object-card.tsx +2 -1
- package/src/serve/hub-app/review/object-panel.tsx +41 -22
- package/src/serve/hub-app/review/pano-gl.ts +145 -0
- package/src/serve/hub-app/review/pano-view.tsx +193 -0
- package/src/serve/hub-app/review/phone-top.tsx +16 -0
- package/src/serve/hub-app/review/pictures-st.ts +38 -0
- package/src/serve/hub-app/review/question-views.tsx +111 -108
- package/src/serve/hub-app/review/review-board.tsx +1 -1
- package/src/serve/hub-app/review/review-cells.tsx +175 -116
- package/src/serve/hub-app/review/review-host.ts +72 -0
- package/src/serve/hub-app/review/review-kit.ts +41 -24
- package/src/serve/hub-app/review/review-list.tsx +210 -61
- package/src/serve/hub-app/review/review-page.tsx +10 -21
- package/src/serve/hub-app/review/review-st.ts +307 -148
- package/src/serve/hub-app/review/review-thread.tsx +633 -224
- package/src/serve/hub-app/review/review-views.tsx +636 -570
- package/src/serve/hub-app/review/scene-view.tsx +26 -0
- package/src/serve/hub-app/review/secret-facts.ts +26 -0
- package/src/serve/hub-app/review/space3d.tsx +122 -0
- package/src/serve/hub-app/review/splat-view.tsx +9 -0
- package/src/serve/hub-app/review/superseded-runs.ts +76 -0
- package/src/serve/hub-app/review/thread-close.tsx +40 -38
- package/src/serve/hub-app/review/thread-control-st.ts +2 -1
- package/src/serve/hub-app/review/thread-st.ts +542 -158
- package/src/serve/hub-app/review/thread-views.ts +71 -0
- package/src/serve/hub-app/review/{trailer-card.tsx → trailer-body.tsx} +38 -37
- package/src/serve/hub-app/review/trailer-page.tsx +41 -41
- package/src/serve/hub-app/review/trailer-st.ts +41 -40
- package/src/serve/hub-app/review/trailer-timeline.tsx +32 -27
- package/src/serve/hub-app/review/trailer-voices.tsx +32 -30
- package/src/serve/hub-app/review.css +398 -169
- 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-st.ts +138 -0
- package/src/serve/hub-app/search-view.tsx +93 -0
- 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 +6 -4
- package/src/serve/hub-app/session-chips.tsx +55 -0
- package/src/serve/hub-app/shell-rows.ts +126 -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 +18 -29
- 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 +41 -35
- package/src/serve/hub-app/social/group-editor.tsx +45 -0
- package/src/serve/hub-app/social/kit.tsx +19 -57
- package/src/serve/hub-app/social/next-release.tsx +5 -4
- package/src/serve/hub-app/social/post-card.tsx +35 -70
- package/src/serve/hub-app/social/post-page.tsx +2 -1
- package/src/serve/hub-app/social/problems.tsx +8 -6
- package/src/serve/hub-app/social/social-page.tsx +32 -30
- package/src/serve/hub-app/social/social-st.ts +35 -86
- package/src/serve/hub-app/social/stage-popup.tsx +17 -16
- package/src/serve/hub-app/social/stage-st.ts +9 -9
- package/src/serve/hub-app/social.css +7 -13
- 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-st.ts +38 -48
- package/src/serve/hub-app/space-view.tsx +10 -9
- package/src/serve/hub-app/stores/stores-page.tsx +25 -23
- package/src/serve/hub-app/stores/stores-st.ts +20 -24
- 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-input.ts +12 -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 +91 -0
- package/src/serve/hub-app/terminal-sources.tsx +335 -0
- package/src/serve/hub-app/terminal-st.ts +696 -0
- 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 +61 -0
- package/src/serve/hub-app/test-view.tsx +5 -3
- package/src/serve/hub-app/tests-svc.ts +3 -2
- package/src/serve/hub-app/tests-view.tsx +16 -15
- package/src/serve/hub-app/theme-st.ts +6 -9
- package/src/serve/hub-app/thread-row.tsx +68 -25
- package/src/serve/hub-app/time-ago.tsx +41 -17
- package/src/serve/hub-app/time-st.ts +43 -27
- package/src/serve/hub-app/time-view.tsx +4 -3
- 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 +42 -10
- package/src/serve/hub-app/tree-svc.ts +168 -135
- 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 +172 -9
- 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-st.ts +32 -27
- package/src/serve/hub-app/vault-view.tsx +56 -4
- package/src/serve/hub-app/vault.css +2 -0
- package/src/serve/hub-app/veille/veille-page.tsx +38 -37
- package/src/serve/hub-app/veille/veille-st.ts +60 -50
- package/src/serve/hub-app/view-layout.css +90 -0
- package/src/serve/hub-app/waiting-svc.ts +2 -1
- package/src/serve/hub-app/when-view.tsx +5 -4
- package/src/serve/hub-app/wiki-st.ts +3 -2
- package/src/serve/hub-app/wikis-view.tsx +24 -20
- package/src/serve/hub-app/words.tsx +22 -0
- package/src/serve/hub-collections.ts +105 -0
- package/src/serve/hub-runtime.ts +68 -89
- package/src/serve/live-hop.ts +102 -0
- package/src/serve/orchestrator-host.ts +58 -0
- package/src/serve/other-repos.ts +1 -1
- package/src/serve/page-live.ts +147 -0
- package/src/serve/project-gutter-route.ts +116 -42
- package/src/serve/read-thread.ts +76 -0
- package/src/serve/read-worker.ts +58 -0
- package/src/serve/run-serve.ts +11 -7
- package/src/serve/runs-stamp.ts +33 -0
- package/src/serve/secrets-read.ts +156 -0
- package/src/serve/serve-hub.ts +168 -50
- package/src/serve/terminal-claudes.ts +185 -0
- package/src/serve/terminal-guard.ts +55 -0
- package/src/serve/terminal-host.ts +517 -0
- package/src/serve/terminal-record.ts +104 -0
- package/src/serve/terminal-route.ts +539 -0
- 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/shipkit.ts +8 -8
- package/src/shot/client.ts +27 -16
- package/src/shot/dom-clip.ts +30 -5
- package/src/shot/film-box.ts +23 -8
- package/src/shot/serve-shot.ts +16 -5
- package/src/shot/shooter.ts +70 -24
- package/src/shot/shot-ask.ts +12 -6
- package/src/shot/shot-guard.ts +53 -0
- package/src/shot/shot-theme.ts +59 -0
- package/src/shot/still-file.ts +60 -0
- package/src/site/desk.ts +4 -3
- package/src/social/compose.ts +13 -7
- package/src/social/cover.ts +4 -3
- package/src/social/desk-index.ts +2 -2
- package/src/social/draft-doc.ts +88 -0
- package/src/social/draft-versions.ts +80 -0
- package/src/social/drafts.ts +22 -4
- package/src/social/fit.ts +4 -3
- package/src/social/house.ts +1 -1
- package/src/social/import-drafts.ts +1 -1
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +21 -13
- package/src/social/media-facts.ts +1 -19
- package/src/social/media-kind.ts +2 -2
- package/src/social/media-limit.ts +3 -18
- package/src/social/no-account.ts +38 -0
- package/src/social/post-sources.ts +4 -4
- package/src/social/post-text.ts +33 -13
- package/src/social/posts.ts +73 -18
- package/src/social/presence.ts +10 -8
- package/src/social/release-stage.ts +22 -22
- package/src/social/routes.ts +14 -32
- package/src/social/stage.ts +3 -3
- package/src/social/stats.ts +3 -4
- package/src/social/strip.ts +4 -6
- package/src/social/text.ts +2 -1
- package/src/social/{card-drafts.ts → thread-drafts.ts} +3 -3
- package/src/social/unit.ts +12 -3
- package/src/social/writes.ts +3 -6
- package/src/start-repo.ts +33 -13
- package/src/stores/desk.ts +1 -1
- package/src/suite/core-counters.ts +31 -3
- package/src/suite/judge-suites.ts +69 -47
- package/src/suite/select.ts +1 -27
- package/src/suite/suite-cli.ts +18 -8
- package/src/suite/suite-cpu-preload.ts +10 -6
- package/src/suite/test-units.ts +6 -2
- package/src/trace/tracer.ts +4 -5
- package/src/trailer/build.ts +30 -15
- package/src/trailer/ffmpeg.ts +90 -31
- package/src/trailer/fonts.ts +5 -6
- package/src/trailer/footage.ts +9 -3
- package/src/trailer/grammar.ts +2 -1
- package/src/trailer/graph.ts +12 -10
- package/src/trailer/load-unit.ts +1 -1
- package/src/trailer/passage.ts +4 -3
- package/src/trailer/prune.ts +4 -4
- package/src/trailer/score/sound.ts +3 -3
- package/src/trailer/shot-plan.ts +5 -5
- package/src/trailer/shot-state.ts +25 -31
- package/src/trailer/sound/eleven.ts +3 -1
- package/src/trailer/sound/gen.ts +3 -3
- package/src/trailer/sound/run.ts +76 -64
- package/src/trailer/sound/takes.ts +0 -3
- package/src/trailer/take-fault.ts +41 -0
- package/src/trailer/titles.ts +17 -13
- package/src/trailer/url.ts +1 -1
- package/src/trailer/vertical-draw.ts +7 -7
- package/src/trailer/vertical.ts +3 -3
- package/src/trailer/vocab.ts +3 -4
- package/src/ts/config.ts +60 -24
- package/src/ts/cycles.ts +3 -1
- package/src/ts/imports.ts +17 -3
- package/src/ts/rename.ts +6 -7
- package/src/ts/source-graph.ts +15 -9
- package/src/ts/workspaces.ts +26 -0
- package/src/tui/build-steps-panel.ts +3 -3
- package/src/tui/checks-panel.ts +2 -2
- package/src/urls/added.ts +111 -0
- package/src/urls/frame.ts +3 -3
- package/src/urls/icons.ts +294 -0
- package/src/urls/places.ts +139 -0
- package/src/urls/routes.ts +18 -8
- package/src/urls/rows.ts +49 -16
- package/src/urls/unit.ts +57 -3
- package/src/urls/write-routes.ts +207 -0
- package/src/vault/house-keys.ts +1 -1
- package/src/vault/vault-audit.ts +2 -3
- package/src/vault/vault-config.ts +6 -2
- package/src/vault/vault-destroy.ts +2 -1
- package/src/vault/vault-import.ts +4 -11
- package/src/vault/vault-restore.ts +6 -11
- package/src/vault/vault-serve.ts +47 -11
- package/src/vault/vault-snapshot.ts +5 -14
- package/src/veille/chrome.ts +18 -3
- package/src/veille/desk.ts +2 -2
- package/src/veille/identity.ts +6 -0
- package/src/veille/routes.ts +1 -1
- package/src/view3d/cam.ts +85 -0
- package/src/view3d/lib.ts +87 -0
- package/src/view3d/loop.ts +39 -0
- package/src/view3d/scene-cache.ts +62 -0
- package/src/view3d/viewer.ts +454 -0
- package/src/wiki/agent-paths.ts +56 -0
- package/src/wiki/run-wiki.ts +4 -1
- package/src/wiki/serve-graph.ts +2 -3
- package/src/core/run-fix.ts +0 -120
- package/src/home/hmr-keep.ts +0 -134
- package/src/serve/hub-app/review/draft-card.tsx +0 -163
- package/src/serve/hub-app/review/note-place.ts +0 -31
- 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 -100
- /package/src/{serve → http}/hub-port.ts +0 -0
- /package/src/{serve → http}/secret-gate.ts +0 -0
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
// one web app window on macOS: its own app, so the dock and cmd-tab show its
|
|
2
|
-
// own icon, never a second browser. The same source is the shipkit window
|
|
3
|
-
// every per-process app (home/gui-app.ts builds
|
|
4
|
-
// project): the bundle's Info.plist names the app
|
|
5
|
-
// a bare launch opens (ShipkitStartURL)
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
2
|
+
// own icon, never a second browser. The same source is the shipkit window,
|
|
3
|
+
// every per-project app and every per-process app (home/gui-app.ts builds them
|
|
4
|
+
// with swiftc, no Xcode project): the bundle's Info.plist names the app
|
|
5
|
+
// (CFBundleName), the url a bare launch opens (ShipkitStartURL), its mode
|
|
6
|
+
// (ShipkitMode: home, project, process) and a project's repo (ShipkitRepo).
|
|
7
|
+
// One WKWebView per window; every `open -a <app> <url>` opens one more window,
|
|
8
|
+
// cmd-n too in a process's app. A project app is ONE window of native tabs instead: tab 1 its hub,
|
|
9
|
+
// pinned and alone at launch, then each entry of the hub he opens beside it (cmd-t,
|
|
10
|
+
// a new window a page asks) and each url opened from the hub (`road` says where a
|
|
11
|
+
// link goes). Its tab bar shows with one tab too, so a tab pulled out into a window
|
|
12
|
+
// of its own drags back, and the Window menu merges every window into one. In the
|
|
13
|
+
// home's app and a project's, cmd-n asks the hub's page for its new thread popup.
|
|
14
|
+
// A link to another site opens in the default browser, and a
|
|
15
|
+
// download lands in ~/Downloads. The home app wears the Dock badge of the
|
|
16
|
+
// threads waiting for the owner and notifies each new one; a project app wears
|
|
17
|
+
// its repo's count alone, and stays quiet: both as their page posts them
|
|
18
|
+
// (`shipkit` message handler, serve/hub-app/app-bridge.ts).
|
|
11
19
|
import AppKit
|
|
12
20
|
import UserNotifications
|
|
13
21
|
import WebKit
|
|
@@ -15,39 +23,117 @@ import WebKit
|
|
|
15
23
|
let info = Bundle.main.infoDictionary ?? [:]
|
|
16
24
|
let appName = (info["CFBundleName"] as? String) ?? "shipkit"
|
|
17
25
|
let startURL = URL(string: (info["ShipkitStartURL"] as? String) ?? "") ?? URL(string: "http://127.0.0.1:4799/")!
|
|
18
|
-
/** the shipkit app
|
|
19
|
-
let
|
|
26
|
+
/** what this app is; a bundle built before the key: the shipkit app by its id (home/gui-app.ts BUNDLE_ID), else a process's */
|
|
27
|
+
let mode = (info["ShipkitMode"] as? String) ?? (Bundle.main.bundleIdentifier == "dev.shipkit.gui" ? "home" : "process")
|
|
28
|
+
/** the shipkit app itself: the house's badge and the notifications */
|
|
29
|
+
let isShipkit = mode == "home"
|
|
30
|
+
/** a project app's repo: its badge counts that repo's threads alone */
|
|
31
|
+
let projectRepo: String? = mode == "project" ? info["ShipkitRepo"] as? String : nil
|
|
32
|
+
/** the apps that wear a badge: the home's stays running with no window to keep it live, a project app's lives with
|
|
33
|
+
* its windows (closing the last one quits it: one hub page alive per app open, never a hidden one) */
|
|
34
|
+
let hasBadge = isShipkit || projectRepo != nil
|
|
35
|
+
/** a project app: one window, every page a native tab of it */
|
|
36
|
+
let tabbed = projectRepo != nil
|
|
37
|
+
/** a self test runs (`--self-test-…`): nothing it loads is kept on disk, and no window, sheet or alert of it ever
|
|
38
|
+
* reaches a screen. No flag brings a visible self test back: its windows are real and never ordered in */
|
|
39
|
+
let selfTesting = CommandLine.arguments.contains { $0.hasPrefix("--self-test") }
|
|
40
|
+
|
|
41
|
+
/** the windows the window server has on a screen: this process's, and every process's (the control: the menu bar and
|
|
42
|
+
* the Dock are always there, so a count of none means the server answered nothing) */
|
|
43
|
+
func windowsOnScreen() -> (own: Int, all: Int) {
|
|
44
|
+
let pid = ProcessInfo.processInfo.processIdentifier
|
|
45
|
+
let all = (CGWindowListCopyWindowInfo([.optionOnScreenOnly], kCGNullWindowID) as? [[String: Any]]) ?? []
|
|
46
|
+
return (all.filter { ($0[kCGWindowOwnerPID as String] as? Int32) == pid }.count, all.count)
|
|
47
|
+
}
|
|
48
|
+
/** the most windows a self test had on a screen at once, as the window server counted them through its run */
|
|
49
|
+
var seenOnScreen = 0
|
|
50
|
+
|
|
51
|
+
/** the end of a self test: its code, and never 0 once the window server saw one window of it on a screen, or gave
|
|
52
|
+
* no list to count in */
|
|
53
|
+
func finish(_ code: Int32) -> Never {
|
|
54
|
+
let now = windowsOnScreen()
|
|
55
|
+
seenOnScreen = max(seenOnScreen, now.own)
|
|
56
|
+
print("windows-on-screen=\(seenOnScreen) of \(now.all > 0 ? "some" : "none") the window server lists")
|
|
57
|
+
if seenOnScreen > 0 { print("refused: a self test put a window on the screen") }
|
|
58
|
+
if now.all == 0 { print("refused: the window server listed no window at all, so the count proves nothing") }
|
|
59
|
+
exit(seenOnScreen > 0 || now.all == 0 ? 1 : code)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** a self test asked for a window on the screen: said once, and nothing shows */
|
|
63
|
+
var refusedScreen = false
|
|
64
|
+
func refuseScreen() {
|
|
65
|
+
if refusedScreen { return }
|
|
66
|
+
refusedScreen = true
|
|
67
|
+
FileHandle.standardError.write("shipkit: a self test shows no window: an order to the screen was refused\n".data(using: .utf8)!)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** the repo a page of the hub belongs to (`/r/<repo>/…`), nil for any other page */
|
|
71
|
+
func repoOf(_ url: URL) -> String? {
|
|
72
|
+
let parts = url.path.split(separator: "/", omittingEmptySubsequences: true)
|
|
73
|
+
return parts.count >= 2 && parts[0] == "r" ? String(parts[1]).removingPercentEncoding : nil
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** the build a bundle carries (home/gui-app.ts writes it): the running copy compares it with its bundle's on disk */
|
|
77
|
+
func stampOnDisk() -> String? { try? String(contentsOfFile: Bundle.main.bundlePath + "/Contents/Resources/stamp", encoding: .utf8) }
|
|
78
|
+
let launchedStamp = stampOnDisk()
|
|
20
79
|
|
|
21
|
-
/** a
|
|
22
|
-
|
|
80
|
+
/** a #rrggbb as a colour, nil for anything else */
|
|
81
|
+
func colorOf(_ hex: String?) -> NSColor? {
|
|
82
|
+
guard let hex, hex.count == 7, hex.hasPrefix("#"), let n = Int(hex.dropFirst(), radix: 16) else { return nil }
|
|
83
|
+
return NSColor(srgbRed: CGFloat((n >> 16) & 255) / 255, green: CGFloat((n >> 8) & 255) / 255, blue: CGFloat(n & 255) / 255, alpha: 1)
|
|
84
|
+
}
|
|
85
|
+
/** the repo's window colour and the text that reads on it (home/gui-app.ts writes both); none: the system's chrome */
|
|
86
|
+
let tint = colorOf(info["ShipkitTint"] as? String)
|
|
87
|
+
let tintText = colorOf(info["ShipkitTintText"] as? String)
|
|
88
|
+
|
|
89
|
+
/** a window's chrome in the repo's colour, as Peacock tints a VSCode window: the title bar and the tab bar under it take
|
|
90
|
+
* the colour, and the appearance follows the text that reads on it (light text: the dark appearance) */
|
|
91
|
+
func paint(_ win: NSWindow, _ color: NSColor?, text: NSColor?) {
|
|
92
|
+
guard let color else { return }
|
|
93
|
+
win.titlebarAppearsTransparent = true
|
|
94
|
+
win.backgroundColor = color
|
|
95
|
+
let light = (text?.usingColorSpace(.sRGB)?.brightnessComponent ?? 1) > 0.5
|
|
96
|
+
win.appearance = NSAppearance(named: light ? .darkAqua : .aqua)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** the count a page's post puts on the badge: the house's, or one repo's (0 when the page names none); nil when the
|
|
100
|
+
* post carries no count */
|
|
101
|
+
func badgeCount(_ body: [String: Any], repo: String?) -> Int? {
|
|
102
|
+
guard let total = body["waiting"] as? Int else { return nil }
|
|
103
|
+
guard let repo else { return total }
|
|
104
|
+
return ((body["repos"] as? [String: Any])?[repo] as? Int) ?? 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** a thread that started waiting, as the page posts it */
|
|
108
|
+
struct WaitingThread {
|
|
23
109
|
let id: String, title: String, repo: String, url: String
|
|
24
110
|
var key: String { "\(repo)/\(id)" }
|
|
25
111
|
}
|
|
26
112
|
|
|
27
|
-
/** one notification: a
|
|
113
|
+
/** one notification: a thread, or the line for the rest of a burst, which opens the inbox of the home they came from */
|
|
28
114
|
enum Note {
|
|
29
|
-
case
|
|
30
|
-
case more([
|
|
115
|
+
case thread(WaitingThread)
|
|
116
|
+
case more([WaitingThread], inbox: URL?)
|
|
31
117
|
}
|
|
32
118
|
|
|
33
|
-
/** what a burst of new
|
|
34
|
-
func notesOf(_
|
|
35
|
-
if
|
|
36
|
-
let inbox = URL(string:
|
|
37
|
-
return
|
|
119
|
+
/** what a burst of new threads shows: each thread up to `cap`, then one line for the rest */
|
|
120
|
+
func notesOf(_ threads: [WaitingThread], cap: Int = 3) -> [Note] {
|
|
121
|
+
if threads.count <= cap { return threads.map { .thread($0) } }
|
|
122
|
+
let inbox = URL(string: threads[cap].url).flatMap { URL(string: "/inbox", relativeTo: $0)?.absoluteURL }
|
|
123
|
+
return threads.prefix(cap).map { .thread($0) } + [.more(Array(threads.dropFirst(cap)), inbox: inbox)]
|
|
38
124
|
}
|
|
39
125
|
|
|
40
|
-
/** a notification's identifier: its
|
|
126
|
+
/** a notification's identifier: its thread's key, so the banner can be taken back once the thread stops waiting */
|
|
41
127
|
func idOf(_ note: Note) -> String {
|
|
42
128
|
switch note {
|
|
43
|
-
case .
|
|
44
|
-
case .more(let
|
|
129
|
+
case .thread(let c): return c.key
|
|
130
|
+
case .more(let threads, _): return "more:" + threads.map(\.key).joined(separator: ",")
|
|
45
131
|
}
|
|
46
132
|
}
|
|
47
133
|
|
|
48
|
-
/** the banners to take back: a
|
|
49
|
-
func staleOf(_ delivered: [(id: String,
|
|
50
|
-
delivered.filter { $0.
|
|
134
|
+
/** the banners to take back: a thread's once it no longer waits, a burst line's once none of its threads does */
|
|
135
|
+
func staleOf(_ delivered: [(id: String, threads: [String])], waiting: Set<String>) -> [String] {
|
|
136
|
+
delivered.filter { $0.threads.allSatisfy { !waiting.contains($0) } }.map(\.id)
|
|
51
137
|
}
|
|
52
138
|
|
|
53
139
|
/** a url that stays in the app: the machine itself, or the host the app is for */
|
|
@@ -55,20 +141,222 @@ func stays(_ url: URL) -> Bool {
|
|
|
55
141
|
url.host == "127.0.0.1" || url.host == "localhost" || url.host == startURL.host
|
|
56
142
|
}
|
|
57
143
|
|
|
144
|
+
/** a page of the hub itself: the start url's host and port */
|
|
145
|
+
func isHub(_ url: URL) -> Bool { url.host == startURL.host && url.port == startURL.port }
|
|
146
|
+
|
|
147
|
+
/** the site a host belongs to: the machine for every loopback name, the last two labels of a dotted name
|
|
148
|
+
* (app.example.com and auth.example.com are one site, so a sign in on the second stays in the tab), else the host.
|
|
149
|
+
* No public suffix list: two sites under a two label suffix (co.uk) read as one, and such a link stays in the tab */
|
|
150
|
+
func siteOf(_ url: URL?) -> String? {
|
|
151
|
+
guard let host = url?.host?.lowercased() else { return nil }
|
|
152
|
+
if host == "127.0.0.1" || host == "localhost" || host.hasSuffix(".localhost") { return "this machine" }
|
|
153
|
+
let labels = host.split(separator: ".")
|
|
154
|
+
if labels.count < 3 || labels.allSatisfy({ Int($0) != nil }) { return host }
|
|
155
|
+
return labels.suffix(2).joined(separator: ".")
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** scheme, host and port: a url the project declares covers every page of its origin */
|
|
159
|
+
func originOf(_ url: URL) -> String { "\(url.scheme?.lowercased() ?? "")://\(url.host?.lowercased() ?? ""):\(url.port ?? (url.scheme?.lowercased() == "https" ? 443 : 80))" }
|
|
160
|
+
|
|
161
|
+
/** what a tab is found by: its address with no closing slash. A page of the hub keeps its fragment, the entry it
|
|
162
|
+
* shows (`#page:src:terminals:<id>`): two entries are two tabs. Any other page loses it */
|
|
163
|
+
func tabKey(_ url: URL) -> String {
|
|
164
|
+
var c = URLComponents(url: url, resolvingAgainstBaseURL: true)
|
|
165
|
+
if !isHub(url) || c?.fragment?.isEmpty == true { c?.fragment = nil }
|
|
166
|
+
let s = c?.string ?? url.absoluteString
|
|
167
|
+
return s.hasSuffix("/") ? String(s.dropLast()) : s
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** an app whose pages are the hub's: the home's and a project's. A process's app shows a site of its own */
|
|
171
|
+
let hubApp = isShipkit || tabbed
|
|
172
|
+
|
|
173
|
+
/** an origin as a page's script reads it (`location.origin`): no port where it is the scheme's own */
|
|
174
|
+
func pageOrigin(_ url: URL) -> String {
|
|
175
|
+
let scheme = url.scheme?.lowercased() ?? "http"
|
|
176
|
+
let port = url.port.flatMap { $0 == (scheme == "https" ? 443 : 80) ? nil : ":\($0)" } ?? ""
|
|
177
|
+
return "\(scheme)://\(url.host?.lowercased() ?? "")\(port)"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** a string as a script's literal */
|
|
181
|
+
func jsString(_ s: String) -> String {
|
|
182
|
+
guard let data = try? JSONSerialization.data(withJSONObject: [s]), let json = String(data: data, encoding: .utf8) else { return "\"\"" }
|
|
183
|
+
return String(json.dropFirst().dropLast())
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** what a framed site says of its address to the hub page that frames it (serve/hub-app/url-address.ts hears it), so
|
|
187
|
+
* a url's page comes back where he was. WebKit puts a user script in every frame of a web view, with no choice of
|
|
188
|
+
* origin, so this one does nothing by itself: one listener, in a frame right under the top page. It wakes only when
|
|
189
|
+
* the page of `hub`, its parent, asks, and the page posts its ask to the origin of the url it declared and to no
|
|
190
|
+
* other, so a frame of any other origin never hears it. Awake it reads `location.href`, nothing else of the page,
|
|
191
|
+
* and posts it to `hub` alone: at the ask, on a fragment move, a history move and a router's push */
|
|
192
|
+
func reporterScript(hub: String) -> String {
|
|
193
|
+
"""
|
|
194
|
+
(() => {
|
|
195
|
+
if (window === top || parent !== top) return
|
|
196
|
+
const HUB = \(jsString(hub))
|
|
197
|
+
let on = false
|
|
198
|
+
const say = () => { try { parent.postMessage({ skAddress: location.href }, HUB) } catch (e) {} }
|
|
199
|
+
addEventListener('message', (e) => {
|
|
200
|
+
if (e.source !== parent || e.origin !== HUB || e.data == null || e.data.skAddressAsk !== true) return
|
|
201
|
+
if (!on) {
|
|
202
|
+
on = true
|
|
203
|
+
for (const t of ['hashchange', 'popstate']) addEventListener(t, say)
|
|
204
|
+
for (const k of ['pushState', 'replaceState']) {
|
|
205
|
+
const f = history[k]
|
|
206
|
+
history[k] = function () { const r = f.apply(this, arguments); say(); return r }
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
say()
|
|
210
|
+
})
|
|
211
|
+
})()
|
|
212
|
+
"""
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** the tab command with a digit selects among `count`, as a browser: 1 to 8 that tab, 9 the last; nil: there is none */
|
|
216
|
+
func tabIndex(digit: Int, count: Int) -> Int? {
|
|
217
|
+
if count < 1 { return nil }
|
|
218
|
+
if digit == 9 { return count - 1 }
|
|
219
|
+
return digit >= 1 && digit <= count ? digit - 1 : nil
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** command with 1 to 9 as menu keys: a project app's tabs alone. The home's pages take them as repo n, and a process
|
|
223
|
+
* app's page keeps them */
|
|
224
|
+
func tabDigits(_ mode: String) -> [Int] { mode == "project" ? Array(1...9) : [] }
|
|
225
|
+
|
|
226
|
+
/** where a main frame's navigation goes in a project app */
|
|
227
|
+
enum Road: Equatable {
|
|
228
|
+
/** in the page that asked */
|
|
229
|
+
case here
|
|
230
|
+
/** a tab of this window: the one open on it, else a new one */
|
|
231
|
+
case tab
|
|
232
|
+
/** a tab when the project declares the url (its `sk urls` rows, its global processes among them), else outside */
|
|
233
|
+
case declared
|
|
234
|
+
/** the default browser, or the app of the url's scheme */
|
|
235
|
+
case outside
|
|
236
|
+
/** another repo's own app */
|
|
237
|
+
case app(String)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** `from`: the page that asks (a tab's first load asks from its own address, or from none); `home`: the address the tab was opened on; `new`: it asks
|
|
241
|
+
* a new window (target=_blank, window.open); `click`: a link clicked. The hub's pages never turn into another site:
|
|
242
|
+
* the machine's other servers and the project's urls become tabs, any other site leaves. A tab of another site keeps
|
|
243
|
+
* its site (the one it was opened on, the one it shows), and a link out of it leaves */
|
|
244
|
+
func road(to url: URL, from: URL?, home: URL?, new: Bool, click: Bool, repo: String?) -> Road {
|
|
245
|
+
switch url.scheme?.lowercased() {
|
|
246
|
+
case "http", "https": break
|
|
247
|
+
case nil, "about", "data", "blob", "javascript", "file": return .here
|
|
248
|
+
default: return click || new ? .outside : .here
|
|
249
|
+
}
|
|
250
|
+
if isHub(url) {
|
|
251
|
+
if let own = repo, let other = repoOf(url), other != own { return .app(other) }
|
|
252
|
+
return new ? .tab : .here
|
|
253
|
+
}
|
|
254
|
+
guard let from else { return .here }
|
|
255
|
+
if isHub(from) { return siteOf(url) == "this machine" ? .tab : .declared }
|
|
256
|
+
let site = siteOf(url)
|
|
257
|
+
if site == siteOf(from) || site == siteOf(home) { return new ? .tab : .here }
|
|
258
|
+
return click || new ? .outside : .here
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** a url a link or window.open leads to that leaves the app for the default browser or its own app: a web page of
|
|
262
|
+
* another host, a mail address, any other app's scheme; the page's own data, blob and about urls stay */
|
|
263
|
+
func leaves(_ url: URL) -> Bool {
|
|
264
|
+
switch url.scheme?.lowercased() {
|
|
265
|
+
case "http", "https": return !stays(url)
|
|
266
|
+
case nil, "about", "data", "blob", "javascript", "file": return false
|
|
267
|
+
default: return true
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
58
271
|
/** a window's content: the find bar above the web view when shown. WebKit's
|
|
59
272
|
* public find api searches the page: NSTextFinder never shows its bar for a
|
|
60
273
|
* WKWebView, which is no NSTextFinderClient at runtime */
|
|
61
274
|
// a window whose unhandled key makes no system beep: a key nobody took (the page, the menus) ends in the window's
|
|
62
275
|
// noResponder, which beeps; the pane marks it in a corner instead
|
|
63
276
|
final class QuietWindow: NSWindow {
|
|
277
|
+
// every window of the app is this one, so a self test's never reaches a screen: each order in is refused
|
|
278
|
+
override func order(_ place: NSWindow.OrderingMode, relativeTo other: Int) { if selfTesting && place != .out { return refuseScreen() }; super.order(place, relativeTo: other) }
|
|
279
|
+
override func makeKeyAndOrderFront(_ sender: Any?) { if selfTesting { return refuseScreen() }; super.makeKeyAndOrderFront(sender) }
|
|
280
|
+
override func orderFront(_ sender: Any?) { if selfTesting { return refuseScreen() }; super.orderFront(sender) }
|
|
281
|
+
override func orderFrontRegardless() { if selfTesting { return refuseScreen() }; super.orderFrontRegardless() }
|
|
282
|
+
|
|
283
|
+
// AppKit's performClose presses the window's red button, which closes every tab of a project app: a close asked
|
|
284
|
+
// of one tab this way (the tab bar's « close other tabs », a script) is that tab's alone
|
|
285
|
+
override func performClose(_ sender: Any?) {
|
|
286
|
+
if tabbed, let d = delegate as? Delegate { return d.closeTab(of: self) }
|
|
287
|
+
super.performClose(sender)
|
|
288
|
+
}
|
|
289
|
+
|
|
64
290
|
override func noResponder(for eventSelector: Selector) {
|
|
65
291
|
if eventSelector == #selector(NSResponder.keyDown(with:)), let pane = contentView as? Pane { return pane.blink() }
|
|
66
292
|
super.noResponder(for: eventSelector)
|
|
67
293
|
}
|
|
68
294
|
}
|
|
69
295
|
|
|
296
|
+
/** a window's web view. In a project app the context menu's « open link in new window » opens the link as a tab of
|
|
297
|
+
* this window, whatever its site: the one road by which a page of another site gets a tab here */
|
|
298
|
+
final class Web: WKWebView {
|
|
299
|
+
static let linkItem = "WKMenuItemIdentifierOpenLinkInNewWindow"
|
|
300
|
+
/** the next new window this page asks is a tab here; the menu's item sets it for its own ask alone */
|
|
301
|
+
var tabNext = false
|
|
302
|
+
private var forward: (target: AnyObject?, action: Selector?) = (nil, nil)
|
|
303
|
+
|
|
304
|
+
override func willOpenMenu(_ menu: NSMenu, with event: NSEvent) {
|
|
305
|
+
super.willOpenMenu(menu, with: event)
|
|
306
|
+
guard tabbed else { return }
|
|
307
|
+
for item in menu.items where item.identifier?.rawValue == Web.linkItem {
|
|
308
|
+
item.title = "Open in a Tab Here"
|
|
309
|
+
forward = (item.target, item.action)
|
|
310
|
+
item.target = self
|
|
311
|
+
item.action = #selector(openLinkInTab(_:))
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
@objc func openLinkInTab(_ sender: NSMenuItem) {
|
|
316
|
+
tabNext = true
|
|
317
|
+
if let action = forward.action { NSApp.sendAction(action, to: forward.target, from: sender) }
|
|
318
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { self.tabNext = false }
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** the login chips a page's tab note names (serve/hub-app/app-bridge.ts TabChips): the url's id and its logins'
|
|
323
|
+
* labels by position, at most 8; nil when it names none */
|
|
324
|
+
func chipsOf(_ body: [String: Any]) -> (urlId: String, logins: [String])? {
|
|
325
|
+
guard let id = body["urlId"] as? String, !id.isEmpty, id.count <= 120, let logins = body["logins"] as? [String], !logins.isEmpty else { return nil }
|
|
326
|
+
return (id, logins.prefix(8).map { String($0.prefix(60)) })
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** one chip of a url's tab title bar: a field of a login, by the url's id and the login's position, which the hub's
|
|
330
|
+
* copy route takes. Its title is a word, never a value */
|
|
331
|
+
final class ChipButton: NSButton {
|
|
332
|
+
var urlId = "", login = 0, label = "", field = ""
|
|
333
|
+
private var back: DispatchWorkItem?
|
|
334
|
+
|
|
335
|
+
/** `what` on the chip for `s` seconds, `why` its tip meanwhile, then its own field and tip again */
|
|
336
|
+
func say(_ what: String, why: String? = nil, for s: Double = 1.6) {
|
|
337
|
+
back?.cancel()
|
|
338
|
+
title = what
|
|
339
|
+
toolTip = why ?? "copy the \(field) of \(label)"
|
|
340
|
+
let w = DispatchWorkItem { [weak self] in
|
|
341
|
+
guard let self else { return }
|
|
342
|
+
self.title = self.field
|
|
343
|
+
self.toolTip = "copy the \(self.field) of \(self.label)"
|
|
344
|
+
}
|
|
345
|
+
back = w
|
|
346
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + s, execute: w)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
70
350
|
final class Pane: NSView, NSSearchFieldDelegate {
|
|
71
|
-
|
|
351
|
+
private(set) var web: WKWebView
|
|
352
|
+
/** the address the window was opened on: a project app finds a tab by it */
|
|
353
|
+
var opened: URL?
|
|
354
|
+
/** a project app's hub, its tab 1: its own close is refused, and it closes last */
|
|
355
|
+
var pinned = false
|
|
356
|
+
/** the name the tab was opened under, when a page of the hub gave one: a url's, where the site's own title is
|
|
357
|
+
* not the name the project gave it. It stays as he walks the site */
|
|
358
|
+
var name: String? { didSet { retitle() } }
|
|
359
|
+
private var titleWatch: NSKeyValueObservation?
|
|
72
360
|
let bar = NSStackView()
|
|
73
361
|
let field = NSSearchField()
|
|
74
362
|
let status = NSTextField(labelWithString: "")
|
|
@@ -105,6 +393,31 @@ final class Pane: NSView, NSSearchFieldDelegate {
|
|
|
105
393
|
mark.layer?.cornerRadius = 3
|
|
106
394
|
mark.alphaValue = 0
|
|
107
395
|
addSubview(mark)
|
|
396
|
+
// the page's title names the window and its tab, so cmd-tab, the window menu and the tab bar tell pages apart;
|
|
397
|
+
// a page that renames itself with no load (the hub's router) renames them too
|
|
398
|
+
watchTitle()
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private func watchTitle() {
|
|
402
|
+
titleWatch = web.observe(\.title, options: [.new]) { [weak self] _, _ in self?.retitle() }
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** the window's and the tab's title: the name it was opened under, else its page's; a page with none leaves it */
|
|
406
|
+
func retitle() {
|
|
407
|
+
if let name { window?.title = name } else if let t = web.title, !t.isEmpty { window?.title = t }
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** another web view in this one's place: the window, its tab, its pin and its find bar stay, the keys follow */
|
|
411
|
+
func swap(to new: WKWebView) {
|
|
412
|
+
let old = web
|
|
413
|
+
let keyed = (window?.firstResponder as? NSView)?.isDescendant(of: old) == true
|
|
414
|
+
addSubview(new, positioned: .below, relativeTo: bar)
|
|
415
|
+
old.removeFromSuperview()
|
|
416
|
+
web = new
|
|
417
|
+
watchTitle()
|
|
418
|
+
retitle()
|
|
419
|
+
needsLayout = true
|
|
420
|
+
if keyed { window?.makeFirstResponder(new) }
|
|
108
421
|
}
|
|
109
422
|
|
|
110
423
|
func blink() {
|
|
@@ -204,28 +517,27 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
204
517
|
if CommandLine.arguments.contains("--self-test-panels") { return selfTestPanels() }
|
|
205
518
|
if CommandLine.arguments.contains("--self-test-download") { return selfTestDownload() }
|
|
206
519
|
if CommandLine.arguments.contains("--self-test-badge") { return selfTestBadge() }
|
|
207
|
-
if CommandLine.arguments.contains("--self-test-
|
|
520
|
+
if CommandLine.arguments.contains("--self-test-reload") { return selfTestReload() }
|
|
208
521
|
if CommandLine.arguments.contains("--self-test-tabs") { return selfTestTabs() }
|
|
522
|
+
if let i = CommandLine.arguments.firstIndex(of: "--self-test-windows") { return selfTestWindows(to: i + 1 < CommandLine.arguments.count ? CommandLine.arguments[i + 1] : nil) }
|
|
523
|
+
if CommandLine.arguments.contains("--self-test-links") { return selfTestLinks() }
|
|
524
|
+
if CommandLine.arguments.contains("--self-test-address") { return selfTestAddress() }
|
|
525
|
+
if let i = CommandLine.arguments.firstIndex(of: "--self-test-chrome"), i + 1 < CommandLine.arguments.count { return selfTestChrome(to: CommandLine.arguments[i + 1], titles: Array(CommandLine.arguments.dropFirst(i + 2))) }
|
|
526
|
+
if let i = CommandLine.arguments.firstIndex(of: "--self-test-chips") { return selfTestChips(to: i + 1 < CommandLine.arguments.count ? CommandLine.arguments[i + 1] : nil) }
|
|
209
527
|
buildMenu()
|
|
528
|
+
watchBuild()
|
|
210
529
|
// the system asks the owner once; refused, the badge still counts and each notification says why it did not show
|
|
211
530
|
if isShipkit {
|
|
212
531
|
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { ok, err in
|
|
213
532
|
if !ok { NSLog("shipkit: notifications are off for this app (System Settings, Notifications, shipkit)\(err.map { ": \($0.localizedDescription)" } ?? "")") }
|
|
214
533
|
}
|
|
215
|
-
// `--background`: running with no window from the start, the badge live, as after the last window closed
|
|
216
|
-
if CommandLine.arguments.contains("--background") {
|
|
217
|
-
opened = true
|
|
218
|
-
keep(home: startURL)
|
|
219
|
-
}
|
|
220
534
|
}
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return nil
|
|
226
|
-
}
|
|
227
|
-
return e
|
|
535
|
+
// `--background`: running with no window from the start, the badge live, as after the last window closed
|
|
536
|
+
if isShipkit && CommandLine.arguments.contains("--background") {
|
|
537
|
+
opened = true
|
|
538
|
+
keep(home: startURL)
|
|
228
539
|
}
|
|
540
|
+
watchKeys()
|
|
229
541
|
// an open event may deliver the url right after launch: wait for it
|
|
230
542
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
231
543
|
if !self.opened {
|
|
@@ -239,8 +551,8 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
239
551
|
for u in urls { open(u) }
|
|
240
552
|
}
|
|
241
553
|
|
|
242
|
-
// the
|
|
243
|
-
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool { !isShipkit }
|
|
554
|
+
// the home app stays running with no window, as a mail or chat app does, so its badge stays live; Quit ends it
|
|
555
|
+
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool { !isShipkit && !selfTesting }
|
|
244
556
|
|
|
245
557
|
func applicationShouldHandleReopen(_ app: NSApplication, hasVisibleWindows: Bool) -> Bool {
|
|
246
558
|
if !hasVisibleWindows { open(startURL) }
|
|
@@ -249,8 +561,307 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
249
561
|
|
|
250
562
|
func keyPane() -> Pane? { NSApp.keyWindow?.contentView as? Pane }
|
|
251
563
|
|
|
564
|
+
/** the digit row's physical keys, 1 to 9: an AZERTY keyboard types `&` to `ç` on them, and the tab is the same */
|
|
565
|
+
static let digitKeys: [UInt16: Int] = [18: 1, 19: 2, 20: 3, 21: 4, 23: 5, 22: 6, 26: 7, 28: 8, 25: 9]
|
|
566
|
+
|
|
567
|
+
/** the keys the app takes before the page: esc closes the find bar of the key window; command and shift with the
|
|
568
|
+
* two keys right of P (their physical keys), or command with page up or page down, step the window's tabs; in a
|
|
569
|
+
* project app command with a key of the digit row (its physical key) selects that tab, command with t opens the
|
|
570
|
+
* hub's entry in a tab, command with w closes the tab, and with shift the window; in an app of the hub's pages
|
|
571
|
+
* command with n asks the new thread popup, a key no page of the hub reads. Every other key reaches the page first, a
|
|
572
|
+
* terminal's among them (control keys, option, esc, shift with return, command with c, v or k), and a menu
|
|
573
|
+
* takes one only when the page left it. True: taken */
|
|
574
|
+
func takes(_ e: NSEvent) -> Bool {
|
|
575
|
+
let mods = e.modifierFlags.intersection([.command, .shift, .option, .control])
|
|
576
|
+
if e.keyCode == 53, let pane = keyPane(), pane.isFindBarVisible {
|
|
577
|
+
pane.hideFind()
|
|
578
|
+
return true
|
|
579
|
+
}
|
|
580
|
+
let step = mods == [.command, .shift] ? (e.keyCode == 30 ? 1 : e.keyCode == 33 ? -1 : 0) : mods == [.command] ? (e.keyCode == 121 ? 1 : e.keyCode == 116 ? -1 : 0) : 0
|
|
581
|
+
if step != 0 {
|
|
582
|
+
stepTab(of: NSApp.keyWindow ?? NSApp.mainWindow ?? windows.first, by: step)
|
|
583
|
+
return true
|
|
584
|
+
}
|
|
585
|
+
if mods == [.command], let n = Delegate.digitKeys[e.keyCode], tabDigits(mode).contains(n) {
|
|
586
|
+
selectTab(digit: n)
|
|
587
|
+
return true
|
|
588
|
+
}
|
|
589
|
+
if tabbed, let c = e.charactersIgnoringModifiers?.lowercased(), mods == [.command] && (c == "t" || c == "w") || mods == [.command, .shift] && c == "w" {
|
|
590
|
+
if c == "t" { entryTab(nil) } else if mods.contains(.shift) { closeEveryTab(nil) } else { closeTab(nil) }
|
|
591
|
+
return true
|
|
592
|
+
}
|
|
593
|
+
if hubApp, mods == [.command], e.charactersIgnoringModifiers?.lowercased() == "n" {
|
|
594
|
+
newThread(nil)
|
|
595
|
+
return true
|
|
596
|
+
}
|
|
597
|
+
if hubApp, mods == [.command, .shift], e.charactersIgnoringModifiers?.lowercased() == "n" {
|
|
598
|
+
if tabbed { projectWindow(nil) } else { newWindow(nil) }
|
|
599
|
+
return true
|
|
600
|
+
}
|
|
601
|
+
return false
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
func watchKeys() {
|
|
605
|
+
NSEvent.addLocalMonitorForEvents(matching: .keyDown) { e in self.takes(e) ? nil : e }
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// one more window on the page shown; in a project app one more tab on it
|
|
252
609
|
@objc func newWindow(_ sender: Any?) {
|
|
253
|
-
open(keyPane()?.web.url ?? startURL)
|
|
610
|
+
open(keyPane()?.web.url ?? startURL, again: true)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/** shift command n, a project app's: one more window of the project, its own and never a tab of the one in front,
|
|
614
|
+
* its first tab the hub's start page, not pinned: the window that holds the pinned hub stays the project's */
|
|
615
|
+
@objc func projectWindow(_ sender: Any?) {
|
|
616
|
+
guard !windows.isEmpty else { return open(startURL) }
|
|
617
|
+
let w = makeWindow(startURL, alone: true)
|
|
618
|
+
// macOS puts a window of preferred tabbing, as it first comes on a screen, into a window of its identifier
|
|
619
|
+
w.tabbingMode = .disallowed
|
|
620
|
+
show(w)
|
|
621
|
+
w.tabbingMode = .preferred
|
|
622
|
+
settleTabs()
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** the tab beside the hub's that is open on this address. A page of the hub is found by the address it shows now,
|
|
626
|
+
* its entry included, since a hub page walks from entry to entry; the hub's own tab walks them all and is never
|
|
627
|
+
* one of them. Any other page is found by the address it was opened on, or shows */
|
|
628
|
+
func tab(on url: URL) -> NSWindow? {
|
|
629
|
+
let key = tabKey(url)
|
|
630
|
+
return windows.first { w in
|
|
631
|
+
guard let pane = w.contentView as? Pane, !pane.pinned else { return false }
|
|
632
|
+
if isHub(url) { return (pane.web.url ?? pane.opened).map(tabKey) == key }
|
|
633
|
+
return pane.opened.map(tabKey) == key || pane.web.url.map(tabKey) == key
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/** a project app's hub tab, the one pinned */
|
|
638
|
+
var hubTab: NSWindow? { windows.first(where: isPinned) }
|
|
639
|
+
|
|
640
|
+
/** the app's window in front: the key one when it is a window of pages (a panel or a sheet is none) */
|
|
641
|
+
var frontWindow: NSWindow? { NSApp.keyWindow.flatMap { k in windows.first { $0 === k } } }
|
|
642
|
+
|
|
643
|
+
/** the tabs of a window in their order: the key window's, else the project window's */
|
|
644
|
+
func tabs(of w: NSWindow?) -> [NSWindow] {
|
|
645
|
+
guard let w = w ?? windows.first else { return [] }
|
|
646
|
+
return w.tabGroup?.windows ?? [w]
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** the one place a window reaches the screen, in front. A self test never shows one */
|
|
650
|
+
func onScreen(_ w: NSWindow) {
|
|
651
|
+
if selfTesting { return }
|
|
652
|
+
if w.isMiniaturized { w.deminiaturize(nil) }
|
|
653
|
+
w.makeKeyAndOrderFront(nil)
|
|
654
|
+
NSApp.activate(ignoringOtherApps: true)
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** a window, or a project app's tab, in front */
|
|
658
|
+
func show(_ w: NSWindow) {
|
|
659
|
+
w.tabGroup?.selectedWindow = w
|
|
660
|
+
onScreen(w)
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/** the one place an alert reaches the screen: a sheet on `win`, a modal with none; `done` hears its button. A
|
|
664
|
+
* self test shows none: `onPanel` answers it, and with nobody to answer it is said on stderr and cancelled */
|
|
665
|
+
func present(_ alert: NSAlert, on win: NSWindow? = nil, done: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
|
666
|
+
if selfTesting {
|
|
667
|
+
// laid out as it would show, so its buttons and its field are the ones the owner would get
|
|
668
|
+
alert.layout()
|
|
669
|
+
if let onPanel { return onPanel(alert) { done?($0) } }
|
|
670
|
+
FileHandle.standardError.write("shipkit: an alert a self test does not show: \(alert.messageText): \(alert.informativeText)\n".data(using: .utf8)!)
|
|
671
|
+
done?(.cancel)
|
|
672
|
+
return
|
|
673
|
+
}
|
|
674
|
+
if let win { alert.beginSheetModal(for: win) { done?($0) } } else {
|
|
675
|
+
let r = alert.runModal()
|
|
676
|
+
done?(r)
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/** command with t: the entry the hub's tab shows (its address: a terminal, a Claude session, a process, a url,
|
|
681
|
+
* any page of the main panel) in a tab of its own, so the hub walks on and the entry stays; the tab already open
|
|
682
|
+
* on that entry is shown, never a second one */
|
|
683
|
+
@objc func entryTab(_ sender: Any?) {
|
|
684
|
+
guard let pane = hubTab?.contentView as? Pane else { return }
|
|
685
|
+
// an entry whose tab is no page of the hub's shell (a url's site, a terminal alone): what its page said
|
|
686
|
+
if let e = entries[ObjectIdentifier(pane.web)] {
|
|
687
|
+
if let name = e.name { tabNames[tabKey(e.url)] = name }
|
|
688
|
+
return asksWindow(e.url, from: pane.web)
|
|
689
|
+
}
|
|
690
|
+
openTab(pane.web.url ?? startURL)
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/** a page of a project app asks a new window on an address (window.open, target=_blank with no policy asked,
|
|
694
|
+
* command with t on an entry that names one): it goes down its road, a tab of the hub's own else */
|
|
695
|
+
func asksWindow(_ url: URL, from web: WKWebView) {
|
|
696
|
+
if !reroutes(url, from: web, new: true, click: false) { open(url, again: true) }
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/** the name a hub page gave the tab it asks next, by that tab's address (serve/hub-app/panel-repo.ts openTab) */
|
|
700
|
+
var tabNames: [String: String] = [:]
|
|
701
|
+
/** the login chips the same note names for that tab, a url's (wearChips) */
|
|
702
|
+
var tabChips: [String: (urlId: String, logins: [String])] = [:]
|
|
703
|
+
/** what command with t opens for the entry a hub page shows, by its web view, where that is not the page
|
|
704
|
+
* itself (serve/hub-app/panel-source.ts, tab) */
|
|
705
|
+
var entries: [ObjectIdentifier: (url: URL, name: String?)] = [:]
|
|
706
|
+
|
|
707
|
+
/** the tab a hub page named and opened before on this site: a url's row asked again shows its tab, where he
|
|
708
|
+
* left it, never a second one */
|
|
709
|
+
func tab(named url: URL) -> NSWindow? {
|
|
710
|
+
guard !isHub(url), let name = tabNames[tabKey(url)] else { return nil }
|
|
711
|
+
return windows.first { w in
|
|
712
|
+
guard let pane = w.contentView as? Pane, pane.name == name else { return false }
|
|
713
|
+
return (pane.web.url ?? pane.opened).map(originOf) == originOf(url)
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// command with a digit, as a browser: 1 to 8 that tab, 9 the last. The item is always on, so a digit with no tab
|
|
718
|
+
// is taken and nothing beeps
|
|
719
|
+
@objc func selectTab(_ sender: NSMenuItem) { selectTab(digit: sender.tag) }
|
|
720
|
+
|
|
721
|
+
func selectTab(digit: Int) {
|
|
722
|
+
let all = tabs(of: NSApp.keyWindow)
|
|
723
|
+
if let i = tabIndex(digit: digit, count: all.count) { show(all[i]) }
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
func isPinned(_ w: NSWindow?) -> Bool { (w?.contentView as? Pane)?.pinned == true }
|
|
727
|
+
|
|
728
|
+
/** the window whose red button was pressed, else the one in front, closes whole. The window that holds the hub's
|
|
729
|
+
* tab is the project's: every window of the app closes with it, the hub's tab last, and the app quits. A window
|
|
730
|
+
* of tabs pulled out of it closes alone */
|
|
731
|
+
@objc func closeEveryTab(_ sender: Any?) {
|
|
732
|
+
let from = tabs(of: (sender as? NSView)?.window ?? frontWindow)
|
|
733
|
+
let all = from.contains(where: isPinned) ? windows : from
|
|
734
|
+
for w in all.filter({ !isPinned($0) }) + all.filter(isPinned) { w.close() }
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// a project app has three closes, each on a road of its own, so none is told from another by where a click
|
|
738
|
+
// landed: the window's red button sends `closeEveryTab` (makeWindow gives it that action), command with w and
|
|
739
|
+
// `performClose` go through `closeTab`, and the tab bar's own close button is all that reaches `windowShouldClose`
|
|
740
|
+
|
|
741
|
+
// command with w closes the tab shown, and that tab alone; on the hub's tab, the one pinned, it is refused with the
|
|
742
|
+
// pane's dot: the menu's Close Window, Quit and the window's red button close the project's window, nothing else does
|
|
743
|
+
@objc func closeTab(_ sender: Any?) { closeTab(of: NSApp.keyWindow ?? windows.first?.tabGroup?.selectedWindow) }
|
|
744
|
+
|
|
745
|
+
func closeTab(of w: NSWindow?) {
|
|
746
|
+
guard let w else { return }
|
|
747
|
+
if isPinned(w) { (w.contentView as? Pane)?.blink() } else { w.close() }
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/** a tab's own close button in a project app: it closes that tab alone, whatever is left; the hub's, the one tab
|
|
751
|
+
* the badge and the project's pages live in, is refused with the pane's dot. Any other app: the window closes */
|
|
752
|
+
func windowShouldClose(_ sender: NSWindow) -> Bool {
|
|
753
|
+
guard tabbed, isPinned(sender) else { return true }
|
|
754
|
+
(sender.contentView as? Pane)?.blink()
|
|
755
|
+
return false
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** the tab bars this run asked for: a second look asks none again */
|
|
759
|
+
var barsAsked = 0
|
|
760
|
+
/** the windows whose bar stayed hidden once asked: never asked twice, so no look repeats */
|
|
761
|
+
var barRefused = Set<ObjectIdentifier>()
|
|
762
|
+
var settling = false
|
|
763
|
+
|
|
764
|
+
/** every window of a project app shows its tab bar, with one tab too. macOS hides the bar of a window whose group
|
|
765
|
+
* holds one tab, and a window with no bar has no tab to drag into another window and takes none: two windows of
|
|
766
|
+
* one tab each could never be one again. The bar is asked only where it is hidden */
|
|
767
|
+
func showTabBars() {
|
|
768
|
+
guard tabbed else { return }
|
|
769
|
+
var seen: [NSWindowTabGroup] = []
|
|
770
|
+
for w in windows {
|
|
771
|
+
guard let g = w.tabGroup, !seen.contains(where: { $0 === g }) else { continue }
|
|
772
|
+
seen.append(g)
|
|
773
|
+
let shown = g.selectedWindow ?? w
|
|
774
|
+
if g.isTabBarVisible || barRefused.contains(ObjectIdentifier(shown)) { continue }
|
|
775
|
+
shown.toggleTabBar(nil)
|
|
776
|
+
barsAsked += 1
|
|
777
|
+
if !g.isTabBarVisible { barRefused.insert(ObjectIdentifier(shown)) }
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/** the same look once the event that asked it is over (a tab dragged out or in still moves while its window
|
|
782
|
+
* becomes key): one look a turn of the run loop, however many events asked */
|
|
783
|
+
func settleTabs() {
|
|
784
|
+
guard tabbed, !settling else { return }
|
|
785
|
+
settling = true
|
|
786
|
+
DispatchQueue.main.async {
|
|
787
|
+
self.settling = false
|
|
788
|
+
self.showTabBars()
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
func windowDidBecomeKey(_ note: Notification) { settleTabs() }
|
|
793
|
+
func windowDidResignKey(_ note: Notification) { settleTabs() }
|
|
794
|
+
func windowDidBecomeMain(_ note: Notification) { settleTabs() }
|
|
795
|
+
|
|
796
|
+
/** the tab shown leaves its window for one of its own, a step down and right of it, its tab bar shown: he drags
|
|
797
|
+
* it back among the tabs, or merges */
|
|
798
|
+
@objc func tabToNewWindow(_ sender: Any?) { split(frontWindow ?? windows.first?.tabGroup?.selectedWindow) }
|
|
799
|
+
|
|
800
|
+
func split(_ w: NSWindow?) {
|
|
801
|
+
guard tabbed, let w, let g = w.tabGroup, g.windows.count > 1 else { return }
|
|
802
|
+
let from = w.frame
|
|
803
|
+
g.removeWindow(w)
|
|
804
|
+
w.setFrameTopLeftPoint(NSPoint(x: from.minX + 28, y: from.maxY - 28))
|
|
805
|
+
showTabBars()
|
|
806
|
+
show(w)
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/** every window of the project back into one */
|
|
810
|
+
@objc func mergeWindows(_ sender: Any?) { merge(shown: frontWindow) }
|
|
811
|
+
|
|
812
|
+
/** the hub's window takes the tabs of every other window after its own, each window's in their order, and the
|
|
813
|
+
* hub's tab is first whatever place a drag gave it; `shown`, the tab he was on, stays the one shown */
|
|
814
|
+
func merge(shown: NSWindow? = nil) {
|
|
815
|
+
guard tabbed, let hub = hubTab ?? windows.first else { return }
|
|
816
|
+
var kept = tabs(of: hub)
|
|
817
|
+
for w in windows where !kept.contains(where: { $0 === w }) {
|
|
818
|
+
for t in tabs(of: w) {
|
|
819
|
+
kept.last?.addTabbedWindow(t, ordered: .above)
|
|
820
|
+
kept.append(t)
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
if isPinned(hub), let g = hub.tabGroup, g.windows.count > 1, g.windows.first !== hub {
|
|
824
|
+
g.removeWindow(hub)
|
|
825
|
+
g.insertWindow(hub, at: 0)
|
|
826
|
+
}
|
|
827
|
+
showTabBars()
|
|
828
|
+
show(shown ?? hub)
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/** the windows of the app, each a group of tabs */
|
|
832
|
+
var windowCount: Int { Set(windows.map { w in ObjectIdentifier(w.tabGroup?.windows.first ?? w) }).count }
|
|
833
|
+
|
|
834
|
+
/** command with n: the hub page in front opens its new thread popup (serve/hub-app/app-bridge.ts, newThread). A
|
|
835
|
+
* tab with none to open (another site, a terminal alone) hands the ask to the hub's tab, which comes forward;
|
|
836
|
+
* with no window the home opens one first */
|
|
837
|
+
@objc func newThread(_ sender: Any?) {
|
|
838
|
+
var panes: [Pane] = []
|
|
839
|
+
for p in [keyPane(), hubTab?.contentView as? Pane, windows.first?.contentView as? Pane] {
|
|
840
|
+
if let p, !panes.contains(where: { $0 === p }) { panes.append(p) }
|
|
841
|
+
}
|
|
842
|
+
if panes.isEmpty {
|
|
843
|
+
open(startURL)
|
|
844
|
+
if let p = windows.last?.contentView as? Pane { panes = [p] }
|
|
845
|
+
}
|
|
846
|
+
askNewThread(panes, tries: 12)
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/** each pane in turn until a hub page says it opened the popup; a page still loading has no hook yet, so the
|
|
850
|
+
* round is asked again `tries` times, then the first pane marks the key as not taken */
|
|
851
|
+
func askNewThread(_ panes: [Pane], tries: Int, at i: Int = 0) {
|
|
852
|
+
guard i < panes.count else {
|
|
853
|
+
if tries > 0 { DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) { self.askNewThread(panes, tries: tries - 1) } } else { panes.first?.blink() }
|
|
854
|
+
return
|
|
855
|
+
}
|
|
856
|
+
let pane = panes[i]
|
|
857
|
+
guard pane.window != nil, pane.web.url.map(isHub) == true else { return askNewThread(panes, tries: tries, at: i + 1) }
|
|
858
|
+
pane.web.callAsyncJavaScript("return !!(window.shipkitApp && shipkitApp.newThread && shipkitApp.newThread())", arguments: [:], in: nil, in: .page) { r in
|
|
859
|
+
if case .success(let v) = r, (v as? Bool) == true {
|
|
860
|
+
if let w = pane.window { self.show(w) }
|
|
861
|
+
return
|
|
862
|
+
}
|
|
863
|
+
self.askNewThread(panes, tries: tries, at: i + 1)
|
|
864
|
+
}
|
|
254
865
|
}
|
|
255
866
|
|
|
256
867
|
/// the tab after or before the one a window shows, round to the first; one tab alone stays
|
|
@@ -258,7 +869,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
258
869
|
guard let g = w?.tabGroup, let shown = g.selectedWindow, let i = g.windows.firstIndex(of: shown), g.windows.count > 1 else { return }
|
|
259
870
|
let to = g.windows[(i + by + g.windows.count) % g.windows.count]
|
|
260
871
|
g.selectedWindow = to
|
|
261
|
-
to
|
|
872
|
+
onScreen(to)
|
|
262
873
|
}
|
|
263
874
|
|
|
264
875
|
@objc func nextTab(_ sender: Any?) { stepTab(of: NSApp.keyWindow ?? NSApp.mainWindow, by: 1) }
|
|
@@ -300,24 +911,29 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
300
911
|
let alert = NSAlert()
|
|
301
912
|
alert.messageText = "This WebKit has no way to open the inspector from a menu"
|
|
302
913
|
alert.informativeText = "Right click the page and pick Inspect Element."
|
|
303
|
-
alert
|
|
914
|
+
present(alert)
|
|
304
915
|
}
|
|
305
916
|
|
|
306
917
|
func validateMenuItem(_ item: NSMenuItem) -> Bool {
|
|
307
918
|
if item.action == #selector(hideFind(_:)) { return keyPane()?.isFindBarVisible == true }
|
|
308
919
|
if item.action == #selector(findNext(_:)) || item.action == #selector(findPrevious(_:)) { return keyPane()?.field.stringValue.isEmpty == false }
|
|
309
920
|
if item.action == #selector(showFind(_:)) { return keyPane() != nil }
|
|
921
|
+
if item.action == #selector(mergeWindows(_:)) { return windowCount > 1 }
|
|
922
|
+
if item.action == #selector(tabToNewWindow(_:)) { return tabs(of: frontWindow).count > 1 }
|
|
310
923
|
if item.action == #selector(devTools(_:)) || item.action == #selector(reload(_:)) { return keyPane() != nil }
|
|
311
924
|
return true
|
|
312
925
|
}
|
|
313
926
|
|
|
314
|
-
|
|
927
|
+
/** `bridge`: the page may post the badge; a project app gives it to its hub's pages alone, never to a tab of another site */
|
|
928
|
+
func webConfig(bridge: Bool = true) -> WKWebViewConfiguration {
|
|
315
929
|
let config = WKWebViewConfiguration()
|
|
316
930
|
config.preferences.setValue(true, forKey: "developerExtrasEnabled")
|
|
317
|
-
if
|
|
931
|
+
if selfTesting { config.websiteDataStore = .nonPersistent() }
|
|
932
|
+
if hasBadge && bridge {
|
|
318
933
|
config.userContentController.add(self, name: "shipkit")
|
|
319
|
-
// the
|
|
320
|
-
|
|
934
|
+
// the home's badge poll keeps its pace while its window is hidden or covered; a project app's page is throttled
|
|
935
|
+
// as any background page is: its badge moves at that slower pace
|
|
936
|
+
if isShipkit, #available(macOS 14.0, *) { config.preferences.inactiveSchedulingPolicy = .none }
|
|
321
937
|
}
|
|
322
938
|
return config
|
|
323
939
|
}
|
|
@@ -333,47 +949,178 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
333
949
|
keeper = web
|
|
334
950
|
}
|
|
335
951
|
|
|
336
|
-
|
|
952
|
+
/** an address asked from outside a page: the launch, the Dock, `open -a`. A project app starts with ONE tab, its
|
|
953
|
+
* hub, pinned, and its start address is that tab; any other address is a tab beside it. `again`: one more page
|
|
954
|
+
* on an address already shown */
|
|
955
|
+
func open(_ url: URL, again: Bool = false) {
|
|
337
956
|
opened = true
|
|
338
|
-
|
|
957
|
+
guard tabbed else { return show(makeWindow(url)) }
|
|
958
|
+
if windows.isEmpty { _ = makeWindow(startURL, pinned: true) }
|
|
959
|
+
if !again, tabKey(url) == tabKey(startURL), let hub = hubTab { return show(hub) }
|
|
960
|
+
openTab(url, again: again)
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/** a page as a tab beside the hub's: the tab already open on that address is shown, never loaded twice, else one
|
|
964
|
+
* more after the last */
|
|
965
|
+
func openTab(_ url: URL, again: Bool = false) {
|
|
966
|
+
if !again, let w = tab(on: url) ?? tab(named: url) { return show(w) }
|
|
967
|
+
show(makeWindow(url))
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/** a window's web view, not loaded yet. `view`: what a page kept of its scrolls before it asked for a fresh view
|
|
971
|
+
* (hub-app/page-reload.ts), put back where that page reads it, before its first script */
|
|
972
|
+
func makeWeb(_ url: URL, view: String? = nil) -> Web {
|
|
973
|
+
let config = webConfig(bridge: !tabbed || isHub(url))
|
|
974
|
+
// parsed and written again: the page's words never reach the script as they came
|
|
975
|
+
if let view, let obj = try? JSONSerialization.jsonObject(with: Data(view.utf8)), let clean = try? JSONSerialization.data(withJSONObject: obj), let json = String(data: clean, encoding: .utf8) {
|
|
976
|
+
config.userContentController.addUserScript(WKUserScript(source: "try { sessionStorage.setItem('sk-view', JSON.stringify(\(json))) } catch (e) {}", injectionTime: .atDocumentStart, forMainFrameOnly: true))
|
|
977
|
+
}
|
|
978
|
+
// a hub page's frames say their address once the page asks (reporterScript)
|
|
979
|
+
if hubApp && isHub(url) { config.userContentController.addUserScript(WKUserScript(source: reporterScript(hub: pageOrigin(startURL)), injectionTime: .atDocumentStart, forMainFrameOnly: false)) }
|
|
980
|
+
let web = Web(frame: .zero, configuration: config)
|
|
339
981
|
if #available(macOS 13.3, *) { web.isInspectable = true }
|
|
340
982
|
web.navigationDelegate = self
|
|
341
983
|
web.uiDelegate = self
|
|
342
984
|
web.allowsBackForwardNavigationGestures = true
|
|
343
985
|
web.allowsMagnification = true
|
|
344
986
|
web.pageZoom = zoom
|
|
987
|
+
return web
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/** the pages loading in a fresh web view, by that view, each with the view it replaces */
|
|
991
|
+
var arriving: [ObjectIdentifier: (new: WKWebView, old: WKWebView)] = [:]
|
|
992
|
+
/** the longest a fresh view loads before it takes its place anyway */
|
|
993
|
+
static let arriveWait = 2.5
|
|
994
|
+
/** how a fresh view loads its page: a self test hands it one with no server */
|
|
995
|
+
var loadFresh: (WKWebView, URL) -> Void = { $0.load(URLRequest(url: $1)) }
|
|
996
|
+
|
|
997
|
+
/** a hub page asks to be loaded again (a new build). WebKit keeps a page reloaded in place alive whole, one page a
|
|
998
|
+
* reload, so the page loads in a fresh web view and the old one leaves with its process. The old page stays on the
|
|
999
|
+
* screen and takes the keys until the fresh one loaded: a terminal tab loses no key */
|
|
1000
|
+
func reload(_ old: WKWebView, to url: URL, view: String?) {
|
|
1001
|
+
guard isHub(url), !arriving.values.contains(where: { $0.old === old }) else { return }
|
|
1002
|
+
// the page reloads in place by itself when nothing says this: an app built before this request
|
|
1003
|
+
old.evaluateJavaScript("window.__skAppReloads = true") { _, _ in }
|
|
1004
|
+
if old === keeper { return keep(home: url) }
|
|
1005
|
+
guard old.superview is Pane else { return }
|
|
1006
|
+
let new = makeWeb(url, view: view)
|
|
1007
|
+
new.frame = old.frame
|
|
1008
|
+
new.pageZoom = old.pageZoom
|
|
1009
|
+
new.magnification = old.magnification
|
|
1010
|
+
arriving[ObjectIdentifier(new)] = (new, old)
|
|
1011
|
+
loadFresh(new, url)
|
|
1012
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + Delegate.arriveWait) { [weak self, weak new] in if let new { self?.arrive(new) } }
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/** the fresh view takes its place: the old one is dropped, its count with it. A window closed meanwhile drops both */
|
|
1016
|
+
func arrive(_ new: WKWebView) {
|
|
1017
|
+
guard let pair = arriving.removeValue(forKey: ObjectIdentifier(new)), let pane = pair.old.superview as? Pane else { return }
|
|
1018
|
+
pane.swap(to: new)
|
|
1019
|
+
pair.old.navigationDelegate = nil
|
|
1020
|
+
pair.old.uiDelegate = nil
|
|
1021
|
+
pair.old.stopLoading()
|
|
1022
|
+
// the tab's count goes to the fresh view until its page posts its own: the badge never blinks for a build
|
|
1023
|
+
let n = counts.removeValue(forKey: ObjectIdentifier(pair.old))
|
|
1024
|
+
if let n, counts[ObjectIdentifier(new)] == nil { counts[ObjectIdentifier(new)] = n }
|
|
1025
|
+
drawBadge()
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// `--self-test-reload`, in a project app: its hub tab's page asks for a fresh web view, as hub-app/page-reload.ts
|
|
1029
|
+
// does for a new build. exit 0 only when the tab's pane holds another web view on the fresh page, that page read
|
|
1030
|
+
// the view the old one kept, the tab kept its place, its pin and its window, the count went to the fresh view, the
|
|
1031
|
+
// old view is gone from memory (its process ends with it), and an address that is no hub's was not obeyed
|
|
1032
|
+
func selfTestReload() {
|
|
1033
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 20) { print("timeout"); finish(1) }
|
|
1034
|
+
loadFresh = { web, url in web.loadHTMLString("<title>fresh</title><body><script>const v = JSON.parse(sessionStorage.getItem('sk-view') || '{}'); document.body.dataset.view = (v.scrolls ? v.scrolls[0].top : 'none') + ':' + v.at</script></body>", baseURL: url) }
|
|
1035
|
+
let hub = makeWindow(startURL, pinned: true)
|
|
1036
|
+
_ = makeWindow(startURL.appendingPathComponent("other"))
|
|
1037
|
+
guard let pane = hub.contentView as? Pane else { finish(1) }
|
|
1038
|
+
pane.web.loadHTMLString("<title>old</title><p>old</p>", baseURL: startURL)
|
|
1039
|
+
weak var old = pane.web
|
|
1040
|
+
let oldId = ObjectIdentifier(pane.web)
|
|
1041
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
|
1042
|
+
self.counts[oldId] = 2
|
|
1043
|
+
let before = self.tabs(of: nil).map { ObjectIdentifier($0) }
|
|
1044
|
+
self.reload(pane.web, to: URL(string: "https://example.com/")!, view: nil)
|
|
1045
|
+
print("foreign=\(self.arriving.isEmpty ? "refused" : "obeyed")")
|
|
1046
|
+
pane.web.evaluateJavaScript("webkit.messageHandlers.shipkit.postMessage({ reload: location.href, view: JSON.stringify({ href: location.href, at: 7, scrolls: [{ path: [0], top: 12, bottom: 0 }] }) }); 0") { _, _ in
|
|
1047
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
|
1048
|
+
pane.web.evaluateJavaScript("document.title + '|' + document.body.dataset.view") { v, _ in
|
|
1049
|
+
print("swapped=\(ObjectIdentifier(pane.web) != oldId) page=\(v ?? "nil") title=\(hub.title)")
|
|
1050
|
+
print("tab-kept=\(before == self.tabs(of: nil).map { ObjectIdentifier($0) }) pinned=\(pane.pinned) windows=\(self.windows.count)")
|
|
1051
|
+
print("count=\(self.counts[ObjectIdentifier(pane.web)] ?? -1) old-count=\(self.counts[oldId] ?? -1)")
|
|
1052
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
1053
|
+
print("old-view=\(old == nil ? "gone" : "held")")
|
|
1054
|
+
finish(0)
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/** the fresh view cannot load (the server restarts): the old page reloads in place, as it did before */
|
|
1063
|
+
func webView(_ web: WKWebView, didFailProvisionalNavigation nav: WKNavigation!, withError error: Error) {
|
|
1064
|
+
guard let pair = arriving.removeValue(forKey: ObjectIdentifier(web)) else { return }
|
|
1065
|
+
pair.old.reload()
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
/** one more window on a page, not shown yet; in a project app a tab after the last one, `alone` a window of its own
|
|
1069
|
+
* a step down and right of the one in front */
|
|
1070
|
+
func makeWindow(_ url: URL, pinned: Bool = false, alone: Bool = false) -> NSWindow {
|
|
1071
|
+
let web = makeWeb(url)
|
|
345
1072
|
let frame = NSRect(x: 0, y: 0, width: 1400, height: 900)
|
|
346
1073
|
let win = QuietWindow(contentRect: frame, styleMask: [.titled, .closable, .miniaturizable, .resizable], backing: .buffered, defer: false)
|
|
347
|
-
|
|
1074
|
+
let pane = Pane(web: web)
|
|
1075
|
+
pane.opened = url
|
|
1076
|
+
pane.pinned = pinned
|
|
1077
|
+
win.contentView = pane
|
|
348
1078
|
win.title = appName
|
|
1079
|
+
pane.name = isHub(url) ? nil : tabNames[tabKey(url)]
|
|
1080
|
+
if tabbed, !isHub(url), let chips = tabChips[tabKey(url)] { wearChips(win, chips) }
|
|
349
1081
|
win.delegate = self
|
|
350
1082
|
win.isReleasedWhenClosed = false
|
|
351
|
-
win.setFrameAutosaveName("shipkit-window")
|
|
352
|
-
|
|
1083
|
+
if !selfTesting { win.setFrameAutosaveName("shipkit-window") }
|
|
1084
|
+
paint(win, tint, text: tintText)
|
|
1085
|
+
offerRelaunch(win)
|
|
1086
|
+
if tabbed {
|
|
1087
|
+
win.tabbingMode = .preferred
|
|
1088
|
+
win.tabbingIdentifier = "project"
|
|
1089
|
+
// the red button closes the window whole through an action of its own, so it never reaches windowShouldClose
|
|
1090
|
+
if let red = win.standardWindowButton(.closeButton) {
|
|
1091
|
+
red.target = self
|
|
1092
|
+
red.action = #selector(closeEveryTab(_:))
|
|
1093
|
+
}
|
|
1094
|
+
if alone, let from = frontWindow ?? hubTab {
|
|
1095
|
+
win.setFrameTopLeftPoint(NSPoint(x: from.frame.minX + 28, y: from.frame.maxY - 28))
|
|
1096
|
+
} else if !alone, let last = tabs(of: frontWindow).last { last.addTabbedWindow(win, ordered: .above) } else { win.center() }
|
|
1097
|
+
} else if let last = windows.last { win.setFrameTopLeftPoint(NSPoint(x: last.frame.minX + 28, y: last.frame.maxY - 28)) } else { win.center() }
|
|
353
1098
|
windows.append(win)
|
|
1099
|
+
// before it is ever shown: a project's window is born with its tab bar
|
|
1100
|
+
showTabBars()
|
|
354
1101
|
web.load(URLRequest(url: url))
|
|
355
|
-
win.makeKeyAndOrderFront(nil)
|
|
356
1102
|
win.makeFirstResponder(web)
|
|
357
|
-
|
|
1103
|
+
return win
|
|
358
1104
|
}
|
|
359
1105
|
|
|
360
1106
|
var onLoad: ((WKWebView) -> Void)?
|
|
361
1107
|
|
|
362
|
-
// `--self-test-tabs`: two
|
|
1108
|
+
// `--self-test-tabs`: two windows that are never shown as two tabs of one window, the first selected; command with page down, then
|
|
363
1109
|
// with page up, as real key events. A self test is never the active app, so no window of it is key: the menu is
|
|
364
1110
|
// asked which item takes the key, and the step that item makes is run on the tab shown, as it runs on the key
|
|
365
|
-
// window. exit 0 only when each key has its item and the tab moved to the second and back
|
|
1111
|
+
// window. exit 0 only when each key has its item and the tab moved to the second and back, and, the app being no
|
|
1112
|
+
// project's, command with a digit has no item and is left to the page. A project app runs `selfTestProjectTabs`
|
|
366
1113
|
func selfTestTabs() {
|
|
1114
|
+
if tabbed { return selfTestProjectTabs() }
|
|
367
1115
|
buildMenu()
|
|
368
1116
|
let make = { () -> NSWindow in
|
|
369
|
-
let w = QuietWindow(contentRect: NSRect(x:
|
|
1117
|
+
let w = QuietWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 400), styleMask: [.titled], backing: .buffered, defer: false)
|
|
370
1118
|
w.contentView = Pane(web: WKWebView(frame: .zero, configuration: WKWebViewConfiguration()))
|
|
371
1119
|
w.tabbingMode = .preferred
|
|
372
1120
|
return w
|
|
373
1121
|
}
|
|
374
1122
|
let a = make(), b = make()
|
|
375
1123
|
windows.append(contentsOf: [a, b])
|
|
376
|
-
a.orderFrontRegardless()
|
|
377
1124
|
a.addTabbedWindow(b, ordered: .above)
|
|
378
1125
|
a.tabGroup?.selectedWindow = a
|
|
379
1126
|
let shown = { () -> Int in a.tabGroup?.selectedWindow === b ? 2 : a.tabGroup?.selectedWindow === a ? 1 : 0 }
|
|
@@ -397,52 +1144,919 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
397
1144
|
print("tabs=\(a.tabGroup?.windows.count ?? 0) start=\(start)")
|
|
398
1145
|
print("page-down=\(down) shown=\(afterDown)")
|
|
399
1146
|
print("page-up=\(up) shown=\(afterUp)")
|
|
400
|
-
|
|
1147
|
+
let digits = (NSApp.windowsMenu?.items ?? []).filter { $0.action == #selector(self.selectTab(_:)) }.map(\.keyEquivalent).joined()
|
|
1148
|
+
let taken = self.key("&", 18, [.command]).map(self.takes) ?? true
|
|
1149
|
+
print("mode=\(mode) digits=\(digits.isEmpty ? "none" : digits) digit-taken=\(taken)")
|
|
1150
|
+
finish(start == 1 && down == "Show Next Tab, menu took the key: true" && afterDown == 2 && up == "Show Previous Tab, menu took the key: true" && afterUp == 1 && digits.isEmpty && !taken ? 0 : 1)
|
|
401
1151
|
}
|
|
402
1152
|
}
|
|
403
1153
|
}
|
|
404
1154
|
}
|
|
405
1155
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
1156
|
+
/** a key down as the keyboard sends it: its characters, its physical key, its modifiers; `plain`: what the key
|
|
1157
|
+
* types with no modifier, where control or option changed it */
|
|
1158
|
+
func key(_ chars: String, _ code: UInt16, _ flags: NSEvent.ModifierFlags, plain: String? = nil) -> NSEvent? {
|
|
1159
|
+
NSEvent.keyEvent(with: .keyDown, location: .zero, modifierFlags: flags, timestamp: ProcessInfo.processInfo.systemUptime, windowNumber: windows.first?.windowNumber ?? 0, context: nil, characters: chars, charactersIgnoringModifiers: plain ?? chars, isARepeat: false, keyCode: code)
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// `--self-test-tabs` in a project app (the bundle's ShipkitMode): its real window, never shown, on the hub the
|
|
1163
|
+
// test serves at the bundle's start url (tests/gui-app-live.test.ts: the hub's page, whose address moves from
|
|
1164
|
+
// entry to entry as the main panel's does, its links, the project's url list, a terminal's page on the hub's real
|
|
1165
|
+
// terminal route, a second site of the machine under `localhost`). Each link is clicked as a real mouse event,
|
|
1166
|
+
// each key sent as its key event (the digit row as an AZERTY keyboard types it), the red button pressed as the
|
|
1167
|
+
// mouse presses it, the road out recorded instead of taken. One line a fact, ` expected …` under one that is
|
|
1168
|
+
// wrong; exit 0 only when every line is as the owner would see it
|
|
1169
|
+
func selfTestProjectTabs() {
|
|
1170
|
+
buildMenu()
|
|
1171
|
+
var out: [String] = []
|
|
1172
|
+
openOutside = { out.append($0.absoluteString) }
|
|
1173
|
+
var ok = true
|
|
1174
|
+
func say(_ name: String, _ got: String, _ want: String) {
|
|
1175
|
+
print("\(name)=\(got)")
|
|
1176
|
+
if got != want { ok = false; print(" expected \(want)") }
|
|
419
1177
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
1178
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 90) { print("timeout"); finish(1) }
|
|
1179
|
+
/** runs `then` once `cond` holds, or after 8 s: the line that follows says what did not happen */
|
|
1180
|
+
func until(_ cond: @escaping () -> Bool, _ then: @escaping () -> Void) {
|
|
1181
|
+
let start = Date()
|
|
1182
|
+
func poll() {
|
|
1183
|
+
if cond() || Date().timeIntervalSince(start) > 8 { return DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: then) }
|
|
1184
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: poll)
|
|
1185
|
+
}
|
|
1186
|
+
poll()
|
|
1187
|
+
}
|
|
1188
|
+
func all() -> [NSWindow] { tabs(of: nil) }
|
|
1189
|
+
func pane(_ i: Int) -> Pane? { i < all().count ? all()[i].contentView as? Pane : nil }
|
|
1190
|
+
func selected() -> NSWindow? { self.windows.first?.tabGroup?.selectedWindow ?? (all().count == 1 ? all().first : nil) }
|
|
1191
|
+
func shown() -> Int { all().firstIndex { $0 === selected() }.map { $0 + 1 } ?? 0 }
|
|
1192
|
+
func loaded(_ i: Int) -> Bool { pane(i).map { !$0.web.isLoading && $0.web.title?.isEmpty == false } ?? false }
|
|
1193
|
+
func titles() -> String { all().map(\.title).joined(separator: "|") }
|
|
1194
|
+
/** a press and a release of the mouse on a view of the window, which is never shown */
|
|
1195
|
+
func mouse(_ type: NSEvent.EventType, _ at: NSPoint, _ win: NSWindow) -> NSEvent? {
|
|
1196
|
+
NSEvent.mouseEvent(with: type, location: at, modifierFlags: [], timestamp: ProcessInfo.processInfo.systemUptime, windowNumber: win.windowNumber, context: nil, eventNumber: 0, clickCount: 1, pressure: type == .leftMouseDown ? 1 : 0)
|
|
1197
|
+
}
|
|
1198
|
+
func click(_ i: Int, _ id: String) {
|
|
1199
|
+
guard let web = pane(i)?.web, let win = web.window else { return }
|
|
1200
|
+
show(win)
|
|
1201
|
+
web.evaluateJavaScript("(() => { const r = document.getElementById('\(id)').getBoundingClientRect(); return [r.left + 4, r.top + r.height / 2] })()") { v, _ in
|
|
1202
|
+
guard let xy = v as? [Double], xy.count == 2 else { return print("no link \(id)") }
|
|
1203
|
+
let at = web.convert(NSPoint(x: xy[0], y: web.isFlipped ? xy[1] : web.bounds.height - xy[1]), to: nil)
|
|
1204
|
+
if let e = mouse(.leftMouseDown, at, win) { web.mouseDown(with: e) }
|
|
1205
|
+
if let e = mouse(.leftMouseUp, at, win) { web.mouseUp(with: e) }
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
/** the window's red button pressed as the mouse presses it, at its middle: a button follows the mouse in a
|
|
1209
|
+
* loop of its own from the press on, so the release waits in the queue, where that loop reads it */
|
|
1210
|
+
func pressRed(_ w: NSWindow) -> String {
|
|
1211
|
+
guard let red = w.standardWindowButton(.closeButton) else { return "no red button" }
|
|
1212
|
+
let at = red.convert(NSPoint(x: red.bounds.midX, y: red.bounds.midY), to: nil)
|
|
1213
|
+
guard let down = mouse(.leftMouseDown, at, w), let up = mouse(.leftMouseUp, at, w) else { return "no event" }
|
|
1214
|
+
NSApp.postEvent(up, atStart: false)
|
|
1215
|
+
red.mouseDown(with: down)
|
|
1216
|
+
return "pressed"
|
|
1217
|
+
}
|
|
1218
|
+
/** the close button of the nth tab, as the tab bar sends its click on: the button itself shows only under the
|
|
1219
|
+
* mouse, which a window that is never shown never has. AppKit's own names, so one that is gone is said */
|
|
1220
|
+
func tabClose(_ i: Int) -> String {
|
|
1221
|
+
guard let frame = selected()?.contentView?.superview else { return "no frame" }
|
|
1222
|
+
frame.layoutSubtreeIfNeeded()
|
|
1223
|
+
func find(_ v: NSView, _ name: String) -> [NSView] { v.className == name ? [v] : v.subviews.flatMap { find($0, name) } }
|
|
1224
|
+
guard let bar = find(frame, "NSTabBar").first else { return "no tab bar" }
|
|
1225
|
+
let buttons = find(bar, "NSTabButton").sorted { bar.convert($0.bounds, from: $0).minX < bar.convert($1.bounds, from: $1).minX }
|
|
1226
|
+
let close = NSSelectorFromString("closeTabButton:")
|
|
1227
|
+
guard i < buttons.count, bar.responds(to: close) else { return "no close of tab \(i + 1) among \(buttons.count)" }
|
|
1228
|
+
_ = bar.perform(close, with: buttons[i])
|
|
1229
|
+
return "its button"
|
|
1230
|
+
}
|
|
1231
|
+
/** command with the nth key of the digit row, as an AZERTY keyboard types it */
|
|
1232
|
+
func digit(_ n: Int) -> Bool {
|
|
1233
|
+
let azerty = ["&", "é", "\"", "'", "(", "§", "è", "!", "ç"]
|
|
1234
|
+
guard let code = Delegate.digitKeys.first(where: { $0.value == n })?.key, let e = key(azerty[n - 1], code, [.command]) else { return false }
|
|
1235
|
+
return takes(e)
|
|
1236
|
+
}
|
|
1237
|
+
func cmdT() -> Bool { self.key("t", 17, [.command]).map(self.takes) ?? false }
|
|
1238
|
+
/** one key as the app hands it on: the app's own keys first, then the window's views (the page), then the
|
|
1239
|
+
* menus, then a plain key down. Says who took it */
|
|
1240
|
+
func press(_ w: NSWindow, _ chars: String, _ code: UInt16, _ flags: NSEvent.ModifierFlags, plain: String?) -> String {
|
|
1241
|
+
guard let e = key(chars, code, flags, plain: plain) else { return "no event" }
|
|
1242
|
+
if takes(e) { return "app" }
|
|
1243
|
+
if !flags.intersection([.command, .control]).isEmpty {
|
|
1244
|
+
if w.performKeyEquivalent(with: e) { return "page" }
|
|
1245
|
+
if NSApp.mainMenu?.performKeyEquivalent(with: e) == true { return "menu" }
|
|
1246
|
+
}
|
|
1247
|
+
w.sendEvent(e)
|
|
1248
|
+
return "page"
|
|
1249
|
+
}
|
|
1250
|
+
let local = "http://localhost:\(startURL.port ?? 80)"
|
|
1251
|
+
let hubAt = startURL.absoluteString
|
|
1252
|
+
let entry = { (id: String) in URL(string: "\(hubAt)#page:src:\(id)")! }
|
|
1253
|
+
func addresses() -> String { all().map { ($0.contentView as? Pane)?.opened?.absoluteString ?? "?" }.joined(separator: " ").replacingOccurrences(of: "\(hubAt)#page:src:", with: "hub#").replacingOccurrences(of: hubAt, with: "hub") }
|
|
1254
|
+
/** the hub's tab is still a page of the hub, whatever entry it shows */
|
|
1255
|
+
func hubStays() -> Bool { pane(0)?.web.url.map { isHub($0) && $0.path == startURL.path } ?? false }
|
|
1256
|
+
/** the hub's tab goes to an entry in place, as a click on a row of its main panel does */
|
|
1257
|
+
func go(_ id: String, _ then: @escaping () -> Void) {
|
|
1258
|
+
pane(0)?.web.evaluateJavaScript("location.hash = 'page:src:\(id)'; 0") { _, _ in }
|
|
1259
|
+
until({ pane(0)?.web.url?.fragment == "page:src:\(id)" }, then)
|
|
1260
|
+
}
|
|
1261
|
+
var steps: [(@escaping () -> Void) -> Void] = []
|
|
1262
|
+
func run() {
|
|
1263
|
+
if steps.isEmpty { return }
|
|
1264
|
+
let s = steps.removeFirst()
|
|
1265
|
+
s { run() }
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// the launch: one tab, the hub, pinned and shown
|
|
1269
|
+
open(startURL)
|
|
1270
|
+
steps.append { next in
|
|
1271
|
+
until({ loaded(0) }) {
|
|
1272
|
+
say("start", "tabs=\(addresses()) windows=\(self.windows.count) pinned=\(all().map { self.isPinned($0) ? "yes" : "no" }.joined(separator: ",")) shown=\(shown()) titles=\(titles())", "tabs=hub windows=1 pinned=yes shown=1 titles=meadow hub")
|
|
1273
|
+
let items = { (m: NSMenu?, a: Selector) in (m?.items ?? []).filter { $0.action == a }.map(\.keyEquivalent).joined() }
|
|
1274
|
+
let file = NSApp.mainMenu?.items[1].submenu
|
|
1275
|
+
say("menu", "digits=\(items(NSApp.windowsMenu, #selector(self.selectTab(_:)))) entry=\(items(file, #selector(self.entryTab(_:)))) close-tab=\(items(file, #selector(self.closeTab(_:)))) close-window=\(items(file, #selector(self.closeEveryTab(_:))))", "digits=123456789 entry=t close-tab=w close-window=W")
|
|
1276
|
+
next()
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
// the hub goes to a terminal's entry in place, then command with t: that entry in a tab of its own, on its
|
|
1280
|
+
// shell already, and the hub's tab stays where it was
|
|
1281
|
+
steps.append { next in
|
|
1282
|
+
go("terminals:t1") {
|
|
1283
|
+
let at = pane(0)?.web.url?.fragment ?? "none"
|
|
1284
|
+
let took = cmdT()
|
|
1285
|
+
until({ all().count == 2 && all()[1].title == "meadow terminal" }) {
|
|
1286
|
+
say("cmd-t", "hub-at=#\(at) taken=\(took) tabs=\(addresses()) shown=\(shown()) titles=\(titles())", "hub-at=#page:src:terminals:t1 taken=true tabs=hub hub#terminals:t1 shown=2 titles=meadow t1|meadow terminal")
|
|
1287
|
+
next()
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
// the same entry again: command with t shows its tab, and so does the entry's own row asking a new window
|
|
1292
|
+
// (the main panel's ⌘ click, middle click and hover button all call window.open); never a second tab
|
|
1293
|
+
steps.append { next in
|
|
1294
|
+
let first = digit(1)
|
|
1295
|
+
let back = shown()
|
|
1296
|
+
_ = cmdT()
|
|
1297
|
+
let again = "tabs=\(all().count) shown=\(shown())"
|
|
1298
|
+
click(0, "term")
|
|
1299
|
+
until({ shown() == 2 }) {
|
|
1300
|
+
say("same-entry", "cmd-1=\(first) shown=\(back) then cmd-t \(again) then its-row tabs=\(all().count) shown=\(shown())", "cmd-1=true shown=1 then cmd-t tabs=2 shown=2 then its-row tabs=2 shown=2")
|
|
1301
|
+
next()
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
// a url the project declares, on another host: the hub is asked for the list, the link opens as tab 3
|
|
1305
|
+
steps.append { next in
|
|
1306
|
+
click(0, "prod")
|
|
1307
|
+
until({ all().count == 3 }) {
|
|
1308
|
+
say("declared-url", "tabs=\(addresses()) shown=\(shown()) out=\(out.count)", "tabs=hub hub#terminals:t1 https://app.meadow.invalid/admin shown=3 out=0")
|
|
1309
|
+
next()
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
// the same link again: its tab is selected, no second one
|
|
1313
|
+
steps.append { next in
|
|
1314
|
+
let first = digit(1)
|
|
1315
|
+
let back = shown()
|
|
1316
|
+
click(0, "prod")
|
|
1317
|
+
until({ shown() == 3 }) {
|
|
1318
|
+
say("declared-again", "cmd-1=\(first) shown=\(back) then tabs=\(all().count) shown=\(shown())", "cmd-1=true shown=1 then tabs=3 shown=3")
|
|
1319
|
+
next()
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
// any other site still leaves for the default browser
|
|
1323
|
+
steps.append { next in
|
|
1324
|
+
click(0, "other")
|
|
1325
|
+
until({ out.count == 1 }) {
|
|
1326
|
+
say("other-site", "tabs=\(all().count) out=\(out.joined(separator: ","))", "tabs=3 out=https://elsewhere.invalid/x")
|
|
1327
|
+
next()
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
// another server of this machine, a plain link: a tab, and the hub stays on itself
|
|
1331
|
+
steps.append { next in
|
|
1332
|
+
click(0, "dev")
|
|
1333
|
+
until({ all().count == 4 && loaded(3) }) {
|
|
1334
|
+
say("this-machine", "tabs=\(all().count) shown=\(shown()) tab=\(pane(3)?.web.url?.absoluteString ?? "") title=\(all().last?.title ?? "") hub-stays=\(hubStays())", "tabs=4 shown=4 tab=\(local)/app title=dev app hub-stays=true")
|
|
1335
|
+
next()
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
// in that tab a link of its own site stays, a link to another site leaves
|
|
1339
|
+
steps.append { next in
|
|
1340
|
+
click(3, "next")
|
|
1341
|
+
until({ pane(3)?.web.url?.path == "/app/next" && loaded(3) }) {
|
|
1342
|
+
click(3, "away")
|
|
1343
|
+
until({ out.count == 2 }) {
|
|
1344
|
+
say("in-a-tab", "tabs=\(all().count) tab=\(pane(3)?.web.url?.absoluteString ?? "") out=\(out.last ?? "")", "tabs=4 tab=\(local)/app/next out=https://elsewhere.invalid/y")
|
|
1345
|
+
next()
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
// the digit row: 2 that tab, 9 the last, 5 taken with no tab under it, 1 the hub; then the two keys right of P
|
|
1350
|
+
steps.append { next in
|
|
1351
|
+
var seen: [String] = []
|
|
1352
|
+
for n in [2, 9, 5, 1] { seen.append("\(digit(n) ? "" : "!")\(shown())") }
|
|
1353
|
+
for code in [UInt16(30), 30, 33] { seen.append("\(self.key(code == 30 ? "}" : "{", code, [.command, .shift]).map(self.takes) == true ? "" : "!")\(shown())") }
|
|
1354
|
+
say("tab-keys", seen.joined(separator: " "), "2 4 4 1 2 3 2")
|
|
1355
|
+
next()
|
|
1356
|
+
}
|
|
1357
|
+
// in a terminal's tab the app keeps its tab keys, and every key a terminal needs reaches the page (which
|
|
1358
|
+
// takes each key down it gets, as a terminal does, and lists them)
|
|
1359
|
+
steps.append { next in
|
|
1360
|
+
guard let w = all().count > 1 ? all()[1] : nil, let web = pane(1)?.web else { return next() }
|
|
1361
|
+
self.show(w)
|
|
1362
|
+
w.makeFirstResponder(web)
|
|
1363
|
+
let keys: [(String, String, UInt16, NSEvent.ModifierFlags, String?)] = [
|
|
1364
|
+
("ctrl+c", "\u{3}", 8, [.control], "c"), ("ctrl+l", "\u{c}", 37, [.control], "l"), ("ctrl+r", "\u{12}", 15, [.control], "r"), ("alt+b", "∫", 11, [.option], "b"), ("esc", "\u{1b}", 53, [], nil),
|
|
1365
|
+
("shift+return", "\r", 36, [.shift], nil), ("cmd+c", "c", 8, [.command], nil), ("cmd+v", "v", 9, [.command], nil), ("cmd+k", "k", 40, [.command], nil),
|
|
1366
|
+
("cmd+t", "t", 17, [.command], nil), ("cmd+3", "\"", 20, [.command], nil), ("cmd+shift+]", "}", 30, [.command, .shift], nil), ("cmd+pagedown", String(UnicodeScalar(NSPageDownFunctionKey)!), 121, [.command, .function], nil),
|
|
1367
|
+
]
|
|
1368
|
+
var who: [String] = []
|
|
1369
|
+
func send(_ i: Int) {
|
|
1370
|
+
if i == keys.count {
|
|
1371
|
+
return web.evaluateJavaScript("document.body.dataset.keys || ''") { got, _ in
|
|
1372
|
+
say("terminal-keys", who.joined(separator: " "), "ctrl+c:page ctrl+l:page ctrl+r:page alt+b:page esc:page shift+return:page cmd+c:page cmd+v:page cmd+k:page cmd+t:app cmd+3:app cmd+shift+]:app cmd+pagedown:app")
|
|
1373
|
+
say("terminal-page-got", "\((got as? String) ?? "error") tabs=\(all().count)", "ctrl+c ctrl+l ctrl+r alt+b Escape shift+Enter meta+c meta+v meta+k tabs=4")
|
|
1374
|
+
next()
|
|
1375
|
+
}
|
|
430
1376
|
}
|
|
1377
|
+
// each key goes to the terminal's tab, whatever tab the one before it showed
|
|
1378
|
+
self.show(w)
|
|
1379
|
+
who.append("\(keys[i].0):\(press(w, keys[i].1, keys[i].2, keys[i].3, plain: keys[i].4))")
|
|
1380
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { send(i + 1) }
|
|
431
1381
|
}
|
|
1382
|
+
send(0)
|
|
1383
|
+
}
|
|
1384
|
+
// an entry's tab closes as any tab does, by command with w: the window, the hub and the app stay. Command
|
|
1385
|
+
// with t opens the hub's entry again, after the last tab
|
|
1386
|
+
steps.append { next in
|
|
1387
|
+
let before = all().count
|
|
1388
|
+
self.closeTab(of: all()[1])
|
|
1389
|
+
until({ all().count == before - 1 || self.windows.isEmpty }) {
|
|
1390
|
+
let left = "tabs=\(all().count) windows=\(self.windows.count) hub=\(all().first.map { self.isPinned($0) } ?? false)"
|
|
1391
|
+
_ = cmdT()
|
|
1392
|
+
until({ all().count == before }) {
|
|
1393
|
+
let at = self.tab(on: entry("terminals:t1")).flatMap { all().firstIndex(of: $0) }.map { $0 + 1 } ?? 0
|
|
1394
|
+
say("entry-closes", "\(left) then cmd-t tabs=\(addresses()) entry-at=\(at) shown=\(shown())", "tabs=3 windows=3 hub=true then cmd-t tabs=hub https://app.meadow.invalid/admin \(local)/app hub#terminals:t1 entry-at=4 shown=4")
|
|
1395
|
+
next()
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
// the hub tab's own close button, with other tabs open: refused with the pane's dot
|
|
1400
|
+
steps.append { next in
|
|
1401
|
+
_ = digit(1)
|
|
1402
|
+
let road = tabClose(0)
|
|
1403
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
1404
|
+
say("hub-close", "by=\(road) marked=\(pane(0)?.blinks ?? 0) tabs=\(all().count) hub=\(all().first.map { self.isPinned($0) } ?? false)", "by=its button marked=1 tabs=4 hub=true")
|
|
1405
|
+
next()
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
// a tab he closes is gone with its page: the process that drew it ends (its pid read from WebKit, here alone)
|
|
1409
|
+
steps.append { next in
|
|
1410
|
+
let pid = (pane(2)?.web.value(forKey: "_webProcessIdentifier") as? Int32) ?? 0
|
|
1411
|
+
autoreleasepool { self.closeTab(of: all()[2]) }
|
|
1412
|
+
// an app in use drains its pool at each event; a self test gets none, so it sends itself one
|
|
1413
|
+
until({
|
|
1414
|
+
if let e = NSEvent.otherEvent(with: .applicationDefined, location: .zero, modifierFlags: [], timestamp: 0, windowNumber: 0, context: nil, subtype: 0, data1: 0, data2: 0) { NSApp.postEvent(e, atStart: false) }
|
|
1415
|
+
return pid > 0 && kill(pid, 0) != 0
|
|
1416
|
+
}) {
|
|
1417
|
+
say("closed-tab", "tabs=\(addresses()) its-process-ended=\(pid > 0 && kill(pid, 0) != 0)", "tabs=hub https://app.meadow.invalid/admin hub#terminals:t1 its-process-ended=true")
|
|
1418
|
+
next()
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
// the context menu's item, then what it asks: a page of any site as a tab here; without it the same ask leaves
|
|
1422
|
+
steps.append { next in
|
|
1423
|
+
guard let web = pane(0)?.web as? Web, let e = self.key("x", 7, []) else { return next() }
|
|
1424
|
+
let menu = NSMenu()
|
|
1425
|
+
let item = menu.addItem(withTitle: "Open Link in New Window", action: nil, keyEquivalent: "")
|
|
1426
|
+
item.identifier = NSUserInterfaceItemIdentifier(Web.linkItem)
|
|
1427
|
+
let other = menu.addItem(withTitle: "Copy Link", action: nil, keyEquivalent: "")
|
|
1428
|
+
web.willOpenMenu(menu, with: e)
|
|
1429
|
+
web.tabNext = true
|
|
1430
|
+
web.evaluateJavaScript("window.open('https://unrelated.invalid/z'); 0") { _, _ in }
|
|
1431
|
+
until({ all().count == 4 }) {
|
|
1432
|
+
web.evaluateJavaScript("window.open('https://unrelated.invalid/z'); 0") { _, _ in }
|
|
1433
|
+
until({ out.count == 3 }) {
|
|
1434
|
+
say("open-in-a-tab-here", "item=\(item.title) other=\(other.title) tabs=\(all().count) tab=\(pane(3)?.opened?.absoluteString ?? "") without=\(out.last ?? "")", "item=Open in a Tab Here other=Copy Link tabs=4 tab=https://unrelated.invalid/z without=https://unrelated.invalid/z")
|
|
1435
|
+
next()
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
// the badge's bridge: the hub's page has it and its count shows, a tab of another site has none
|
|
1440
|
+
steps.append { next in
|
|
1441
|
+
self.open(URL(string: "\(local)/app")!)
|
|
1442
|
+
until({ all().count == 5 && loaded(4) }) {
|
|
1443
|
+
let probe = "typeof (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.shipkit)"
|
|
1444
|
+
pane(4)?.web.evaluateJavaScript(probe) { tab, _ in
|
|
1445
|
+
pane(0)?.web.evaluateJavaScript("webkit.messageHandlers.shipkit.postMessage({waiting: 5, keys: [], repos: {meadow: 2, atelier: 3}}); \(probe)") { hub, _ in
|
|
1446
|
+
until({ NSApp.dockTile.badgeLabel != nil }) {
|
|
1447
|
+
say("bridge", "hub=\(hub as? String ?? "error") tab=\(tab as? String ?? "error") badge=\(NSApp.dockTile.badgeLabel ?? "none")", "hub=object tab=undefined badge=2")
|
|
1448
|
+
next()
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
// a page of another repo: that repo's app is asked of the hub, and this window stays as it is
|
|
1455
|
+
steps.append { next in
|
|
1456
|
+
click(0, "repo")
|
|
1457
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
1458
|
+
say("other-repo", "tabs=\(all().count) hub-stays=\(hubStays())", "tabs=5 hub-stays=true")
|
|
1459
|
+
next()
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
// the hub goes to a url's entry, then command with t: a second entry of the hub is a tab of its own, named
|
|
1463
|
+
// by its page; the start address asked from outside (the Dock, `open -a`) is the hub's tab, never one more
|
|
1464
|
+
steps.append { next in
|
|
1465
|
+
go("urls:u1") {
|
|
1466
|
+
let took = cmdT()
|
|
1467
|
+
until({ all().count == 6 && loaded(5) }) {
|
|
1468
|
+
let opened = "taken=\(took) tabs=\(all().count) shown=\(shown()) tab=\(addresses().split(separator: " ").last ?? "") title=\(all().last?.title ?? "")"
|
|
1469
|
+
self.open(startURL)
|
|
1470
|
+
say("second-entry", "\(opened) then the start address tabs=\(all().count) shown=\(shown())", "taken=true tabs=6 shown=6 tab=hub#urls:u1 title=meadow u1 then the start address tabs=6 shown=1")
|
|
1471
|
+
next()
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
// the url's entry asks its tab, as its row does, at the home's hop with its logins: the tab wears them, the hub
|
|
1476
|
+
// stays on its entry and wears none; control: the tab of this machine opened with no login wears none. Then it closes
|
|
1477
|
+
steps.append { next in
|
|
1478
|
+
let hop = "http://gate--meadow.localhost:\(startURL.port ?? 80)/"
|
|
1479
|
+
pane(0)?.web.evaluateJavaScript("webkit.messageHandlers.shipkit.postMessage({ tabName: 'gate', url: '\(hop)', urlId: 'gate', logins: ['admin'] }); window.open('\(hop)'); ''") { _, _ in }
|
|
1480
|
+
until({ all().count == 7 && loaded(6) }) {
|
|
1481
|
+
let words = { (i: Int) -> String in
|
|
1482
|
+
let b = self.chipButtons(of: i < all().count ? all()[i] : nil)
|
|
1483
|
+
return b.isEmpty ? "none" : b.map { "\($0.label):\($0.title)" }.joined(separator: ",")
|
|
1484
|
+
}
|
|
1485
|
+
say("url-chips", "tabs=\(all().count) shown=\(shown()) tab=\(pane(6)?.web.url?.host ?? "none") title=\(all().count > 6 ? all()[6].title : "none") chips=\(words(6)) hub-at=#\(pane(0)?.web.url?.fragment ?? "") hub-chips=\(words(0)) dev-chips=\(words(4))", "tabs=7 shown=7 tab=gate--meadow.localhost title=gate chips=admin:account,admin:password hub-at=#page:src:urls:u1 hub-chips=none dev-chips=none")
|
|
1486
|
+
if all().count > 6 { self.closeTab(of: all()[6]) }
|
|
1487
|
+
until({ all().count == 6 }, next)
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
steps.append { next in
|
|
1491
|
+
let u = { (s: String) in URL(string: s)! }
|
|
1492
|
+
let hubPage = u(hubAt), app = u("https://app.example.com/a")
|
|
1493
|
+
let rules: [(String, Bool)] = [
|
|
1494
|
+
("a sign in on a sibling host stays", road(to: u("https://auth.example.com/login"), from: app, home: app, new: false, click: true, repo: "meadow") == .here),
|
|
1495
|
+
("a link to another site leaves", road(to: u("https://other.org/"), from: app, home: app, new: false, click: true, repo: "meadow") == .outside),
|
|
1496
|
+
("a redirect to another site stays", road(to: u("https://other.org/"), from: app, home: app, new: false, click: false, repo: "meadow") == .here),
|
|
1497
|
+
("a new window of the tab's site is a tab", road(to: u("https://app.example.com/b"), from: app, home: app, new: true, click: true, repo: "meadow") == .tab),
|
|
1498
|
+
("a tab's first load stays", road(to: app, from: nil, home: app, new: false, click: false, repo: "meadow") == .here && road(to: app, from: app, home: app, new: false, click: false, repo: "meadow") == .here),
|
|
1499
|
+
("the hub's link to another site asks the list", road(to: app, from: hubPage, home: hubPage, new: false, click: true, repo: "meadow") == .declared),
|
|
1500
|
+
("the hub's link to a name under localhost is a tab", road(to: u("http://web--meadow.localhost:\(startURL.port ?? 80)/"), from: hubPage, home: hubPage, new: true, click: true, repo: "meadow") == .tab),
|
|
1501
|
+
("the hub's own page stays", road(to: u("\(hubAt)#page:urls"), from: hubPage, home: hubPage, new: false, click: true, repo: "meadow") == .here),
|
|
1502
|
+
("an entry of the hub asked as a new window is a tab", road(to: entry("claude:c1"), from: entry("urls:u1"), home: hubPage, new: true, click: false, repo: "meadow") == .tab),
|
|
1503
|
+
("another repo's page is its app", road(to: URL(string: "/r/atelier/", relativeTo: hubPage)!.absoluteURL, from: hubPage, home: hubPage, new: false, click: true, repo: "meadow") == .app("atelier")),
|
|
1504
|
+
("a mail address leaves", road(to: u("mailto:owner@example.com"), from: hubPage, home: hubPage, new: false, click: true, repo: "meadow") == .outside),
|
|
1505
|
+
("an address is its own site", siteOf(u("http://10.0.0.7:8080/")) == "10.0.0.7" && siteOf(u("http://127.0.0.1:1/")) == siteOf(u("http://x.localhost/"))),
|
|
1506
|
+
("two entries of the hub are two tabs", tabKey(entry("terminals:t1")) != tabKey(entry("terminals:t2")) && tabKey(entry("urls:u1")) != tabKey(hubPage)),
|
|
1507
|
+
("an empty entry is the hub's start address", tabKey(u("\(hubAt)#")) == tabKey(hubPage)),
|
|
1508
|
+
("a page of another site is one tab whatever its fragment", tabKey(u("https://app.example.com/a#one")) == tabKey(app) && tabKey(u("https://app.example.com/a/")) == tabKey(app)),
|
|
1509
|
+
("command 9 is the last tab", tabIndex(digit: 9, count: 3) == 2 && tabIndex(digit: 4, count: 3) == nil && tabIndex(digit: 1, count: 0) == nil),
|
|
1510
|
+
("the digits are a project app's alone", tabDigits("project") == Array(1...9) && tabDigits("home").isEmpty && tabDigits("process").isEmpty),
|
|
1511
|
+
]
|
|
1512
|
+
let wrong = rules.filter { !$0.1 }.map(\.0).joined(separator: "; ")
|
|
1513
|
+
say("rules", wrong.isEmpty ? "ok" : wrong, "ok")
|
|
1514
|
+
next()
|
|
1515
|
+
}
|
|
1516
|
+
// a tab's own close button closes that tab alone, and so does a close asked of it by AppKit (performClose,
|
|
1517
|
+
// which presses the red button in any other app): the window, the hub and every other tab stay
|
|
1518
|
+
steps.append { next in
|
|
1519
|
+
guard let last = all().last else { return next() }
|
|
1520
|
+
self.show(last)
|
|
1521
|
+
let road = tabClose(all().count - 1)
|
|
1522
|
+
until({ all().count == 5 }) {
|
|
1523
|
+
let button = "by=\(road) tabs=\(all().count) windows=\(self.windows.count)"
|
|
1524
|
+
all().last?.performClose(nil)
|
|
1525
|
+
until({ all().count == 4 }) {
|
|
1526
|
+
say("tab-closes", "\(button) then perform-close tabs=\(all().count) windows=\(self.windows.count) hub=\(all().first.map { self.isPinned($0) } ?? false)", "by=its button tabs=5 windows=5 then perform-close tabs=4 windows=4 hub=true")
|
|
1527
|
+
next()
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
// the hub alone, every other tab closed: the window is still there. Command with w and the hub tab's own
|
|
1532
|
+
// close close nothing. Then one tab beside the hub, shown, and the window's red button pressed as the mouse
|
|
1533
|
+
// presses it: the window closes whole, every tab, and the app quits with it
|
|
1534
|
+
steps.append { _ in
|
|
1535
|
+
for w in all().filter({ !self.isPinned($0) }) { self.closeTab(of: w) }
|
|
1536
|
+
until({ all().count == 1 || self.windows.isEmpty }) {
|
|
1537
|
+
let left = self.windows.count
|
|
1538
|
+
if let hub = all().first { self.closeTab(of: hub) }
|
|
1539
|
+
let kept = self.windows.count
|
|
1540
|
+
let closes = all().first.map { self.windowShouldClose($0) } ?? true
|
|
1541
|
+
_ = cmdT()
|
|
1542
|
+
until({ all().count == 2 && shown() == 2 }) {
|
|
1543
|
+
let open = "tabs=\(all().count) shown=\(shown())"
|
|
1544
|
+
let red = selected().map(pressRed) ?? "no tab shown"
|
|
1545
|
+
until({ self.windows.isEmpty }) {
|
|
1546
|
+
say("close-window", "hub-left=\(left) after-cmd-w=\(kept) its-button-closes=\(closes) then cmd-t \(open) then red-button \(red) tabs=\(self.windows.count)", "hub-left=1 after-cmd-w=1 its-button-closes=false then cmd-t tabs=2 shown=2 then red-button pressed tabs=0")
|
|
1547
|
+
finish(ok ? 0 : 1)
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
run()
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
// `--self-test-address`, in a project app: its real window, never shown, on a stand in for the hub's page that
|
|
1556
|
+
// the test serves at the bundle's start url (tests/gui-app-live.test.ts). That page runs the hub's own
|
|
1557
|
+
// serve/hub-app/url-address.ts on three frames of two sites of other origins, neither of which says anything of
|
|
1558
|
+
// itself: `site`, watched from its start; `stale`, watched from an address its site answers 404 for; `other`, a
|
|
1559
|
+
// frame the page never asks. It keeps what the watch tells it (`__heard`) and every address message it got
|
|
1560
|
+
// (`__said`, `__keys`). Each frame is moved as its site's own links and router would. Then the page's notes:
|
|
1561
|
+
// the name of a tab it asks, what command with t opens, a tab that asks to leave. One line a fact,
|
|
1562
|
+
// ` expected …` under one that is wrong; exit 0 only when every line is as the owner would see it
|
|
1563
|
+
func selfTestAddress() {
|
|
1564
|
+
buildMenu()
|
|
1565
|
+
var out: [String] = []
|
|
1566
|
+
openOutside = { out.append($0.absoluteString) }
|
|
1567
|
+
var ok = true
|
|
1568
|
+
func say(_ name: String, _ got: String, _ want: String) {
|
|
1569
|
+
print("\(name)=\(got)")
|
|
1570
|
+
if got != want { ok = false; print(" expected \(want)") }
|
|
1571
|
+
}
|
|
1572
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 80) { print("timeout"); finish(1) }
|
|
1573
|
+
func all() -> [NSWindow] { tabs(of: nil) }
|
|
1574
|
+
func pane(_ i: Int) -> Pane? { i < all().count ? all()[i].contentView as? Pane : nil }
|
|
1575
|
+
func shown() -> Int { all().firstIndex { $0 === (self.windows.first?.tabGroup?.selectedWindow ?? all().first) }.map { $0 + 1 } ?? 0 }
|
|
1576
|
+
func loaded(_ i: Int) -> Bool { pane(i).map { !$0.web.isLoading && $0.web.title?.isEmpty == false } ?? false }
|
|
1577
|
+
func at(_ i: Int) -> String { pane(i)?.web.url?.absoluteString ?? "none" }
|
|
1578
|
+
/** runs `then` once `cond` holds, or after 8 s: the line that follows says what did not happen */
|
|
1579
|
+
func until(_ cond: @escaping () -> Bool, _ then: @escaping () -> Void) {
|
|
1580
|
+
let start = Date()
|
|
1581
|
+
func poll() {
|
|
1582
|
+
if cond() || Date().timeIntervalSince(start) > 8 { return DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: then) }
|
|
1583
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: poll)
|
|
1584
|
+
}
|
|
1585
|
+
poll()
|
|
1586
|
+
}
|
|
1587
|
+
/** what a script says in a tab's page, as words */
|
|
1588
|
+
func js(_ i: Int, _ src: String, _ done: @escaping (String) -> Void) {
|
|
1589
|
+
guard let web = pane(i)?.web else { return done("no tab") }
|
|
1590
|
+
web.evaluateJavaScript(src) { v, err in done((v as? String) ?? err.map { "error: \($0.localizedDescription)" } ?? "") }
|
|
1591
|
+
}
|
|
1592
|
+
/** `then` with the hub page's words once `cond` holds of them, or after 8 s with what they were */
|
|
1593
|
+
func wait(_ src: String, _ cond: @escaping (String) -> Bool, _ then: @escaping (String) -> Void) {
|
|
1594
|
+
let start = Date()
|
|
1595
|
+
func poll() {
|
|
1596
|
+
js(0, src) { v in
|
|
1597
|
+
if cond(v) || Date().timeIntervalSince(start) > 8 { return then(v) }
|
|
1598
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: poll)
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
poll()
|
|
1602
|
+
}
|
|
1603
|
+
func cmdT() -> Bool { self.key("t", 17, [.command]).map(self.takes) ?? false }
|
|
1604
|
+
let heard = "(window.__heard || []).join('|')"
|
|
1605
|
+
/** what the watch of one frame told the page, in order */
|
|
1606
|
+
func of(_ h: String, _ frame: String) -> String { h.split(separator: "|").filter { $0.hasPrefix("\(frame): ") }.joined(separator: "|") }
|
|
1607
|
+
/** a frame's page moves as its site's own link or router would: the hub's page has no part in where it goes */
|
|
1608
|
+
func move(_ frame: String, _ how: String) -> String { "document.getElementById('\(frame)').contentWindow.postMessage({ go: \(how) }, '*'); ''" }
|
|
1609
|
+
func post(_ note: String) -> String { "webkit.messageHandlers.shipkit.postMessage(\(note)); ''" }
|
|
1610
|
+
var site = "", other = ""
|
|
1611
|
+
var steps: [(@escaping () -> Void) -> Void] = []
|
|
1612
|
+
func run() {
|
|
1613
|
+
if steps.isEmpty { finish(ok ? 0 : 1) }
|
|
1614
|
+
let s = steps.removeFirst()
|
|
1615
|
+
s { run() }
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
open(startURL)
|
|
1619
|
+
// each watched frame is asked at its load and answers: the one at its start keeps nothing, the one sent to
|
|
1620
|
+
// an address its site answers 404 for is sent back, on the app's word of that answer
|
|
1621
|
+
steps.append { next in
|
|
1622
|
+
wait(heard, { of($0, "site") == "site: drop" && of($0, "stale").hasSuffix("drop") }) { h in
|
|
1623
|
+
js(0, "new URL(document.getElementById('site').src).origin + ' ' + new URL(document.getElementById('other').src).origin") { o in
|
|
1624
|
+
let two = o.split(separator: " ").map(String.init)
|
|
1625
|
+
site = two.first ?? ""
|
|
1626
|
+
other = two.last ?? ""
|
|
1627
|
+
say("start", "\(of(h, "site")) \(of(h, "stale")) tabs=\(all().count)", "site: drop stale: back|stale: drop tabs=1")
|
|
1628
|
+
next()
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
// he walks inside the site: a link, the router's push, a fragment. The frame says each
|
|
1633
|
+
steps.append { next in
|
|
1634
|
+
js(0, move("site", "{ href: '/plain/games/lumen' }")) { _ in
|
|
1635
|
+
wait(heard, { of($0, "site").hasSuffix("/plain/games/lumen") }) { _ in
|
|
1636
|
+
js(0, move("site", "{ push: '/plain/games/lumen/sheet-1?zoom=2' }")) { _ in
|
|
1637
|
+
wait(heard, { of($0, "site").hasSuffix("zoom=2") }) { _ in
|
|
1638
|
+
js(0, move("site", "{ hash: 'tile-3' }")) { _ in
|
|
1639
|
+
wait(heard, { of($0, "site").hasSuffix("#tile-3") }) { h in
|
|
1640
|
+
say("walk", of(h, "site"), "site: drop|site: keep /plain/games/lumen|site: keep /plain/games/lumen/sheet-1?zoom=2|site: keep /plain/games/lumen/sheet-1?zoom=2#tile-3")
|
|
1641
|
+
next()
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
// an address the site answers an error for is dropped
|
|
1650
|
+
steps.append { next in
|
|
1651
|
+
js(0, move("site", "{ href: '/plain/gone' }")) { _ in
|
|
1652
|
+
wait(heard, { of($0, "site").hasSuffix("#tile-3|site: drop") }) { h in
|
|
1653
|
+
say("error", of(h, "site").split(separator: "|").last.map(String.init) ?? "nothing", "site: drop")
|
|
1654
|
+
next()
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
// the frame the page never asks moves too, and says nothing: every address the page got came from the
|
|
1659
|
+
// origin it asked, and held the address alone
|
|
1660
|
+
steps.append { next in
|
|
1661
|
+
js(0, move("other", "{ href: '/plain/games/lumen' }")) { _ in
|
|
1662
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
|
|
1663
|
+
js(0, move("other", "{ push: '/plain/games/lumen/sheet-1' }")) { _ in
|
|
1664
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
|
|
1665
|
+
js(0, "[...new Set(window.__said)].join(' ') + ' keys=' + [...new Set(window.__keys)].join(',')") { v in
|
|
1666
|
+
say("said", v.replacingOccurrences(of: site, with: "site").replacingOccurrences(of: other, with: "other"), "site keys=skAddress")
|
|
1667
|
+
next()
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
// a url's row in a new tab: the page says the tab's name, then asks the window. The site alone, named
|
|
1675
|
+
steps.append { next in
|
|
1676
|
+
let u = "\(site)/plain/games/lumen"
|
|
1677
|
+
js(0, post("{ tabName: 'board games', url: '\(u)' }") + "; window.open('\(u)'); ''") { _ in
|
|
1678
|
+
until({ all().count == 2 && loaded(1) }) {
|
|
1679
|
+
say("url-tab", "tabs=\(all().count) shown=\(shown()) at=\(at(1).replacingOccurrences(of: site, with: "site")) title=\(all().last?.title ?? "") out=\(out.count)", "tabs=2 shown=2 at=site/plain/games/lumen title=board games out=0")
|
|
1680
|
+
next()
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
// the same row asked again, from further inside the site: its tab is shown where he left it, no second one.
|
|
1685
|
+
// Control: a tab of the same site asked with no name is a tab of its own, named by its page
|
|
1686
|
+
steps.append { next in
|
|
1687
|
+
if let hub = all().first { self.show(hub) }
|
|
1688
|
+
let u = "\(site)/plain/games/lumen/sheet-1"
|
|
1689
|
+
js(0, post("{ tabName: 'board games', url: '\(u)' }") + "; window.open('\(u)'); ''") { _ in
|
|
1690
|
+
until({ shown() == 2 }) {
|
|
1691
|
+
let again = "tabs=\(all().count) shown=\(shown()) at=\(at(1).replacingOccurrences(of: site, with: "site"))"
|
|
1692
|
+
js(0, "window.open('\(site)/coop/'); ''") { _ in
|
|
1693
|
+
until({ all().count == 3 && loaded(2) }) {
|
|
1694
|
+
say("url-tab-again", "\(again) then no-name tabs=\(all().count) title=\(all().last?.title ?? "")", "tabs=2 shown=2 at=site/plain/games/lumen then no-name tabs=3 title=the site that says its address")
|
|
1695
|
+
next()
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
// command with t on an entry whose page named a tab: that address, down the road of a window the page
|
|
1702
|
+
// would ask, under its name; again shows that tab
|
|
1703
|
+
steps.append { next in
|
|
1704
|
+
if let hub = all().first { self.show(hub) }
|
|
1705
|
+
js(0, post("{ entryTab: { url: '\(other)/plain/', name: 'print shop' } }")) { _ in
|
|
1706
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
1707
|
+
let took = cmdT()
|
|
1708
|
+
until({ all().count == 4 && loaded(3) }) {
|
|
1709
|
+
let first = "taken=\(took) tabs=\(all().count) shown=\(shown()) at=\(at(3).replacingOccurrences(of: other, with: "other")) title=\(all().last?.title ?? "")"
|
|
1710
|
+
if let hub = all().first { self.show(hub) }
|
|
1711
|
+
_ = cmdT()
|
|
1712
|
+
until({ shown() == 4 }) {
|
|
1713
|
+
say("cmd-t-named", "\(first) then again tabs=\(all().count) shown=\(shown())", "taken=true tabs=4 shown=4 at=other/plain/ title=print shop then again tabs=4 shown=4")
|
|
1714
|
+
next()
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
// an entry whose page names none: command with t opens the hub's entry, as before. A hub page in another
|
|
1721
|
+
// tab that names one changes nothing of what command with t opens: the hub's own tab alone says it
|
|
1722
|
+
steps.append { next in
|
|
1723
|
+
if let hub = all().first { self.show(hub) }
|
|
1724
|
+
js(0, post("{ entryTab: null }") + "; location.hash = 'page:src:urls:u1'; ''") { _ in
|
|
1725
|
+
until({ pane(0)?.web.url?.fragment == "page:src:urls:u1" }) {
|
|
1726
|
+
_ = cmdT()
|
|
1727
|
+
until({ all().count == 5 && loaded(4) }) {
|
|
1728
|
+
let entry = "tabs=\(all().count) shown=\(shown()) at=\(at(4).replacingOccurrences(of: startURL.absoluteString, with: "hub"))"
|
|
1729
|
+
js(4, post("{ entryTab: { url: '\(site)/plain/elsewhere', name: 'not the hub tab' } }")) { _ in
|
|
1730
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
1731
|
+
if let hub = all().first { self.show(hub) }
|
|
1732
|
+
_ = cmdT()
|
|
1733
|
+
until({ shown() == 5 }) {
|
|
1734
|
+
say("cmd-t-entry", "\(entry) then another-tab-names-one tabs=\(all().count) shown=\(shown())", "tabs=5 shown=5 at=hub#page:src:urls:u1 then another-tab-names-one tabs=5 shown=5")
|
|
1735
|
+
next()
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
// a hub page that asks to leave closes its own tab; the hub's own tab is refused with the pane's dot
|
|
1744
|
+
steps.append { next in
|
|
1745
|
+
js(4, post("{ closeTab: true }")) { _ in
|
|
1746
|
+
until({ all().count == 4 }) {
|
|
1747
|
+
let closed = all().count
|
|
1748
|
+
js(0, post("{ closeTab: true }")) { _ in
|
|
1749
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
1750
|
+
say("close-tab", "tabs=\(closed) then the-hub tabs=\(all().count) marked=\(pane(0)?.blinks ?? 0) pinned=\(all().first.map { self.isPinned($0) } ?? false)", "tabs=4 then the-hub tabs=4 marked=1 pinned=true")
|
|
1751
|
+
next()
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
run()
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
// `--self-test-windows [png]`, in a project app: its real windows, never shown, with no server (each page a
|
|
1761
|
+
// string at the address it stands for). The hub alone shows its tab bar; a tab moved to a window of its own
|
|
1762
|
+
// leaves two windows, each with its bar, the state a drag between them needs; a second look asks no bar again;
|
|
1763
|
+
// the Window menu merges them back, the hub's tab first whatever place it had; command with n asks the hub page
|
|
1764
|
+
// for its new thread popup, and a page with none to open hands the ask to the hub's tab; the red button of a
|
|
1765
|
+
// window pulled out closes that window alone; shift command n makes a window of its own on the hub's page, apart
|
|
1766
|
+
// from the project's, and its red button closes it alone. `png`: the window pulled out and the one it left, each frame drawn
|
|
1767
|
+
// whole (`<png>` and `<png>` with `-hub` before its extension). One line a fact, ` expected …` under one that
|
|
1768
|
+
// is wrong; exit 0 only when every line is as the owner would see it. A drag of a tab is the mouse's: not here
|
|
1769
|
+
func selfTestWindows(to png: String?) {
|
|
1770
|
+
guard tabbed else { print("not a project app"); finish(1) }
|
|
1771
|
+
buildMenu()
|
|
1772
|
+
var ok = true
|
|
1773
|
+
func say(_ name: String, _ got: String, _ want: String) {
|
|
1774
|
+
print("\(name)=\(got)")
|
|
1775
|
+
if got != want { ok = false; print(" expected \(want)") }
|
|
1776
|
+
}
|
|
1777
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 40) { print("timeout"); finish(1) }
|
|
1778
|
+
var names: [ObjectIdentifier: String] = [:]
|
|
1779
|
+
/** a tab on a page that counts each ask of the new thread popup and answers `opens` */
|
|
1780
|
+
func tab(_ name: String, at url: URL, pinned: Bool = false, opens: Bool = true) -> NSWindow {
|
|
1781
|
+
let w = makeWindow(url, pinned: pinned)
|
|
1782
|
+
names[ObjectIdentifier(w)] = name
|
|
1783
|
+
(w.contentView as? Pane)?.web.loadHTMLString("<title>\(name)</title><body style='margin:0;font:15px -apple-system;background:#f6f6f6;color:#333;padding:18px'><script>window.shipkitApp = { newThread: () => { document.body.dataset.asked = String(Number(document.body.dataset.asked || 0) + 1); return \(opens) } }</script>\(appName): \(name)</body>", baseURL: url)
|
|
1784
|
+
return w
|
|
1785
|
+
}
|
|
1786
|
+
/** each window as its tabs in their order, with whether its tab bar shows */
|
|
1787
|
+
func state() -> String {
|
|
1788
|
+
var seen: [NSWindow] = []
|
|
1789
|
+
var out: [String] = []
|
|
1790
|
+
for w in windows where !seen.contains(where: { $0 === w }) {
|
|
1791
|
+
let g = tabs(of: w)
|
|
1792
|
+
seen.append(contentsOf: g)
|
|
1793
|
+
out.append(g.map { names[ObjectIdentifier($0)] ?? "?" }.joined(separator: "+") + (w.tabGroup?.isTabBarVisible == true ? " [bar]" : " [no bar]"))
|
|
1794
|
+
}
|
|
1795
|
+
return out.joined(separator: " | ")
|
|
1796
|
+
}
|
|
1797
|
+
func shown(_ w: NSWindow) -> String { (w.tabGroup?.selectedWindow ?? w).flatMap { names[ObjectIdentifier($0)] } ?? "?" }
|
|
1798
|
+
func draw(_ w: NSWindow, to out: String) -> Bool {
|
|
1799
|
+
w.setContentSize(NSSize(width: 720, height: 200))
|
|
1800
|
+
w.displayIfNeeded()
|
|
1801
|
+
guard let frame = w.contentView?.superview, let rep = frame.bitmapImageRepForCachingDisplay(in: frame.bounds) else { return false }
|
|
1802
|
+
frame.cacheDisplay(in: frame.bounds, to: rep)
|
|
1803
|
+
return (try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: out))) != nil
|
|
1804
|
+
}
|
|
1805
|
+
func asked(_ w: NSWindow, _ done: @escaping (String) -> Void) {
|
|
1806
|
+
guard let web = (w.contentView as? Pane)?.web else { return done("no page") }
|
|
1807
|
+
web.evaluateJavaScript("document.body.dataset.asked || '0'") { v, _ in done((v as? String) ?? "error") }
|
|
1808
|
+
}
|
|
1809
|
+
func later(_ s: Double, _ then: @escaping () -> Void) { DispatchQueue.main.asyncAfter(deadline: .now() + s, execute: then) }
|
|
1810
|
+
|
|
1811
|
+
let hub = tab("hub", at: startURL, pinned: true)
|
|
1812
|
+
say("one-tab", state(), "hub [bar]")
|
|
1813
|
+
let term = tab("terminal", at: URL(string: "?shell=terminal", relativeTo: startURL)!.absoluteURL, opens: false)
|
|
1814
|
+
let site = tab("site", at: URL(string: "http://site.invalid/app")!)
|
|
1815
|
+
say("three-tabs", state(), "hub+terminal+site [bar]")
|
|
1816
|
+
split(site)
|
|
1817
|
+
say("tab-moved-out", "\(state()) windows=\(windowCount)", "hub+terminal [bar] | site [bar] windows=2")
|
|
1818
|
+
split(term)
|
|
1819
|
+
say("each-alone", "\(state()) windows=\(windowCount)", "hub [bar] | terminal [bar] | site [bar] windows=3")
|
|
1820
|
+
let before = barsAsked
|
|
1821
|
+
for _ in 0..<5 {
|
|
1822
|
+
showTabBars()
|
|
1823
|
+
settleTabs()
|
|
1824
|
+
}
|
|
1825
|
+
later(1.2) {
|
|
1826
|
+
print("bars-asked=\(before)")
|
|
1827
|
+
say("second-look", "bars-asked-again=\(self.barsAsked - before) refused=\(self.barRefused.count) \(state())", "bars-asked-again=0 refused=0 hub [bar] | terminal [bar] | site [bar]")
|
|
1828
|
+
let menu = NSApp.windowsMenu?.items ?? []
|
|
1829
|
+
let count = { (t: String) in menu.filter { $0.title == t }.count }
|
|
1830
|
+
let on = { (a: Selector) -> String in menu.first { $0.action == a }.map { self.validateMenuItem($0) ? "on" : "off" } ?? "none" }
|
|
1831
|
+
say("window-menu", "move=\(count("Move Tab to New Window")) merge=\(count("Merge All Windows")) merge-now=\(on(#selector(self.mergeWindows(_:)))) move-now=\(on(#selector(self.tabToNewWindow(_:))))", "move=1 merge=1 merge-now=on move-now=off")
|
|
1832
|
+
let file = NSApp.mainMenu?.items[1].submenu?.items ?? []
|
|
1833
|
+
say("file-menu", file.filter { !$0.keyEquivalent.isEmpty }.map { "\($0.title):\($0.keyEquivalent)" }.joined(separator: " "), "New Tab:t New Thread:n New Window:N Reload:r Close Tab:w Close Window:W")
|
|
1834
|
+
if let png {
|
|
1835
|
+
let wrote = draw(term, to: png) && draw(hub, to: png.replacingOccurrences(of: ".png", with: "-hub.png"))
|
|
1836
|
+
say("drawn", "\(wrote)", "true")
|
|
1837
|
+
}
|
|
1838
|
+
// the hub's tab second in a window, as after a tab dropped before it; then every window back into one
|
|
1839
|
+
site.addTabbedWindow(hub, ordered: .above)
|
|
1840
|
+
say("hub-second", state(), "site+hub [bar] | terminal [bar]")
|
|
1841
|
+
self.merge(shown: term)
|
|
1842
|
+
say("merged", "\(state()) windows=\(self.windowCount) shown=\(shown(hub)) merge-now=\(on(#selector(self.mergeWindows(_:)))) move-now=\(on(#selector(self.tabToNewWindow(_:))))", "hub+site+terminal [bar] windows=1 shown=terminal merge-now=off move-now=on")
|
|
1843
|
+
// command with n, no window being key: the hub's tab is asked, and comes forward
|
|
1844
|
+
let took = self.key("n", 45, [.command]).map(self.takes) ?? false
|
|
1845
|
+
later(1) {
|
|
1846
|
+
let first = shown(hub)
|
|
1847
|
+
// then as from the terminal's tab in front: its page opens none, the site's is never asked, the hub's opens it
|
|
1848
|
+
term.tabGroup?.selectedWindow = term
|
|
1849
|
+
self.askNewThread([term, site, hub].compactMap { $0.contentView as? Pane }, tries: 0)
|
|
1850
|
+
later(1) {
|
|
1851
|
+
asked(hub) { h in asked(term) { t in asked(site) { s in
|
|
1852
|
+
say("new-thread", "key-taken=\(took) shown=\(first) then from-the-terminal hub=\(h) terminal=\(t) site=\(s) shown=\(shown(hub))", "key-taken=true shown=hub then from-the-terminal hub=2 terminal=1 site=0 shown=hub")
|
|
1853
|
+
// two tabs pulled out into one window, and its red button: that window alone closes
|
|
1854
|
+
self.split(term)
|
|
1855
|
+
self.split(site)
|
|
1856
|
+
term.addTabbedWindow(site, ordered: .above)
|
|
1857
|
+
let apart = state()
|
|
1858
|
+
self.closeEveryTab(term.standardWindowButton(.closeButton))
|
|
1859
|
+
later(0.6) {
|
|
1860
|
+
say("red-button-of-the-window-pulled-out", "\(apart) then \(state()) windows=\(self.windows.count)", "hub [bar] | terminal+site [bar] then hub [bar] windows=1")
|
|
1861
|
+
// shift command n, no window being key: a window of its own, apart from the project's, on the hub
|
|
1862
|
+
let tookWindow = self.key("N", 45, [.command, .shift]).map(self.takes) ?? false
|
|
1863
|
+
guard let made = self.windows.last, made !== hub, let pane = made.contentView as? Pane else {
|
|
1864
|
+
say("new-window", "none", "a window")
|
|
1865
|
+
finish(1)
|
|
1866
|
+
}
|
|
1867
|
+
names[ObjectIdentifier(made)] = "hub-page"
|
|
1868
|
+
later(0.6) {
|
|
1869
|
+
let first = self.tabs(of: made).first.flatMap { names[ObjectIdentifier($0)] } ?? "?"
|
|
1870
|
+
let onHub = pane.opened.map(tabKey) == tabKey(startURL)
|
|
1871
|
+
say("new-window", "key-taken=\(tookWindow) \(state()) windows=\(self.windowCount) apart=\(made.tabGroup !== hub.tabGroup) first=\(first) on-hub=\(onHub) pinned=\(pane.pinned) hub-tab=\(self.hubTab === hub)", "key-taken=true hub [bar] | hub-page [bar] windows=2 apart=true first=hub-page on-hub=true pinned=false hub-tab=true")
|
|
1872
|
+
self.closeEveryTab(made.standardWindowButton(.closeButton))
|
|
1873
|
+
later(0.6) {
|
|
1874
|
+
say("red-button-of-the-new-window", "\(state()) windows=\(self.windows.count)", "hub [bar] windows=1")
|
|
1875
|
+
finish(ok ? 0 : 1)
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
} } }
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// `--self-test-chrome <png> [tab title…]`: a window of tabs that is never shown (two, or one a title given) as a window of
|
|
1886
|
+
// this app opens, painted with the bundle's colour; its frame drawn whole (title bar, tab bar, page) into the png.
|
|
1887
|
+
// Prints the colour and the appearance; exit 0 only when a bundle with a colour has its window painted with it,
|
|
1888
|
+
// and one without keeps the system's
|
|
1889
|
+
func selfTestChrome(to out: String, titles: [String] = []) {
|
|
1890
|
+
let make = { (title: String) -> NSWindow in
|
|
1891
|
+
let w = QuietWindow(contentRect: NSRect(x: 0, y: 0, width: titles.count > 2 ? 980 : 720, height: 260), styleMask: [.titled, .closable, .miniaturizable, .resizable], backing: .buffered, defer: false)
|
|
1892
|
+
let web = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
|
|
1893
|
+
web.loadHTMLString("<body style='margin:0;font:15px -apple-system;background:#f6f6f6;color:#333;padding:18px'>\(appName)</body>", baseURL: nil)
|
|
1894
|
+
w.contentView = Pane(web: web)
|
|
1895
|
+
w.title = title
|
|
1896
|
+
w.tabbingMode = .preferred
|
|
1897
|
+
paint(w, tint, text: tintText)
|
|
1898
|
+
return w
|
|
1899
|
+
}
|
|
1900
|
+
let all = (titles.isEmpty ? [appName, "urls"] : titles).map(make)
|
|
1901
|
+
let a = all[0]
|
|
1902
|
+
windows.append(contentsOf: all)
|
|
1903
|
+
for (i, w) in all.enumerated().dropFirst() { all[i - 1].addTabbedWindow(w, ordered: .above) }
|
|
1904
|
+
a.tabGroup?.selectedWindow = a
|
|
1905
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
|
1906
|
+
guard let frame = a.contentView?.superview, let rep = frame.bitmapImageRepForCachingDisplay(in: frame.bounds) else { print("no frame"); finish(1) }
|
|
1907
|
+
frame.cacheDisplay(in: frame.bounds, to: rep)
|
|
1908
|
+
let wrote = (try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: out))) != nil
|
|
1909
|
+
let painted = a.backgroundColor == tint && a.titlebarAppearsTransparent
|
|
1910
|
+
print("tint=\(info["ShipkitTint"] as? String ?? "none") text=\(info["ShipkitTintText"] as? String ?? "none") appearance=\(a.appearance?.name.rawValue ?? "system") tabs=\(a.tabGroup?.windows.count ?? 0) wrote=\(wrote)")
|
|
1911
|
+
finish(wrote && (tint == nil ? !a.titlebarAppearsTransparent : painted) ? 0 : 1)
|
|
432
1912
|
}
|
|
433
|
-
web.loadHTMLString("<p>keys</p><script>addEventListener('keydown', (e) => { if (e.key === 'k') e.preventDefault() })</script>", baseURL: nil)
|
|
434
1913
|
}
|
|
435
1914
|
|
|
436
|
-
// `--self-test-
|
|
1915
|
+
// `--self-test-chips [png]`, in a project app: its real window, never shown, on a stand in for the hub that the
|
|
1916
|
+
// test serves at the bundle's start url (tests/gui-app-live.test.ts), its copy route answering made up values
|
|
1917
|
+
// (SHIPKIT_TEST_CHIPS: login 0's account and password, compared here and never printed). The hub's page names a
|
|
1918
|
+
// url's tab and asks it at a hop's address, first with no login (as a url with none), then with two. Each chip is
|
|
1919
|
+
// pressed by its own click. A copy lands on a board of the run's own, marked concealed, and leaves it at the test's
|
|
1920
|
+
// clock, unless another copy came since or the app quits first; a refusal says so on the chip and leaves the
|
|
1921
|
+
// board. `png`: that tab's frame drawn with no login (`-before` before its extension) and with its chips. One line
|
|
1922
|
+
// a fact, ` expected …` under one that is wrong; exit 0 only when every line is as the owner would see it
|
|
1923
|
+
func selfTestChips(to png: String?) {
|
|
1924
|
+
guard tabbed else { print("not a project app"); finish(1) }
|
|
1925
|
+
buildMenu()
|
|
1926
|
+
clearAfter = 0.8
|
|
1927
|
+
let want = (ProcessInfo.processInfo.environment["SHIPKIT_TEST_CHIPS"] ?? "").split(separator: "|").map(String.init)
|
|
1928
|
+
var ok = true
|
|
1929
|
+
func say(_ name: String, _ got: String, _ want: String) {
|
|
1930
|
+
print("\(name)=\(got)")
|
|
1931
|
+
if got != want { ok = false; print(" expected \(want)") }
|
|
1932
|
+
}
|
|
1933
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 45) { print("timeout"); finish(1) }
|
|
1934
|
+
func until(_ cond: @escaping () -> Bool, _ then: @escaping () -> Void) {
|
|
1935
|
+
let start = Date()
|
|
1936
|
+
func poll() {
|
|
1937
|
+
if cond() || Date().timeIntervalSince(start) > 8 { return DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: then) }
|
|
1938
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: poll)
|
|
1939
|
+
}
|
|
1940
|
+
poll()
|
|
1941
|
+
}
|
|
1942
|
+
func later(_ s: Double, _ then: @escaping () -> Void) { DispatchQueue.main.asyncAfter(deadline: .now() + s, execute: then) }
|
|
1943
|
+
func all() -> [NSWindow] { tabs(of: nil) }
|
|
1944
|
+
func pane(_ i: Int) -> Pane? { i < all().count ? all()[i].contentView as? Pane : nil }
|
|
1945
|
+
func loaded(_ i: Int) -> Bool { pane(i).map { !$0.web.isLoading && $0.web.title?.isEmpty == false } ?? false }
|
|
1946
|
+
func shown() -> Int { all().firstIndex { $0 === (self.windows.first?.tabGroup?.selectedWindow ?? all().first) }.map { $0 + 1 } ?? 0 }
|
|
1947
|
+
/** a tab's chips as words: each login's label, then its fields */
|
|
1948
|
+
func chips(_ i: Int) -> String {
|
|
1949
|
+
let b = chipButtons(of: i < all().count ? all()[i] : nil)
|
|
1950
|
+
if b.isEmpty { return "none" }
|
|
1951
|
+
var seen: [String] = []
|
|
1952
|
+
for login in Set(b.map(\.login)).sorted() { seen.append("\(b.first { $0.login == login }!.label):" + b.filter { $0.login == login }.map(\.title).joined(separator: ",")) }
|
|
1953
|
+
return seen.joined(separator: " ")
|
|
1954
|
+
}
|
|
1955
|
+
func chip(_ login: Int, _ field: String) -> ChipButton? { chipButtons(of: all().count > 1 ? all()[1] : nil).first { $0.login == login && $0.field == field } }
|
|
1956
|
+
/** what the board holds, said as how it compares: never the value */
|
|
1957
|
+
func held() -> String {
|
|
1958
|
+
guard let s = self.board.string(forType: .string) else { return "empty" }
|
|
1959
|
+
if let i = want.firstIndex(of: s) { return i == 0 ? "the account" : "the password" }
|
|
1960
|
+
return s == "his own copy" ? s : "another value"
|
|
1961
|
+
}
|
|
1962
|
+
func draw(_ w: NSWindow, to out: String) -> Bool {
|
|
1963
|
+
w.setContentSize(NSSize(width: 1100, height: 120))
|
|
1964
|
+
w.displayIfNeeded()
|
|
1965
|
+
guard let frame = w.contentView?.superview, let rep = frame.bitmapImageRepForCachingDisplay(in: frame.bounds) else { return false }
|
|
1966
|
+
frame.cacheDisplay(in: frame.bounds, to: rep)
|
|
1967
|
+
return (try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: out))) != nil
|
|
1968
|
+
}
|
|
1969
|
+
let hop = "http://admin--meadow.localhost:\(startURL.port ?? 80)/admin"
|
|
1970
|
+
func ask(_ note: String) { pane(0)?.web.evaluateJavaScript("webkit.messageHandlers.shipkit.postMessage(\(note)); window.open('\(hop)'); ''") { _, _ in } }
|
|
1971
|
+
let tab = "{ tabName: 'admin panel', url: '\(hop)'"
|
|
1972
|
+
var steps: [(@escaping () -> Void) -> Void] = []
|
|
1973
|
+
func run() {
|
|
1974
|
+
if steps.isEmpty {
|
|
1975
|
+
self.board.releaseGlobally()
|
|
1976
|
+
finish(ok ? 0 : 1)
|
|
1977
|
+
}
|
|
1978
|
+
let s = steps.removeFirst()
|
|
1979
|
+
s { run() }
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
open(startURL)
|
|
1983
|
+
// the hub's page names the tab of a url with no login: a tab named, no chip; then it leaves
|
|
1984
|
+
steps.append { next in
|
|
1985
|
+
until({ loaded(0) }) {
|
|
1986
|
+
ask(tab + " }")
|
|
1987
|
+
until({ all().count == 2 && loaded(1) }) {
|
|
1988
|
+
let drew = png.map { draw(all()[1], to: $0.replacingOccurrences(of: ".png", with: "-before.png")) } ?? true
|
|
1989
|
+
say("no-login", "tabs=\(all().count) title=\(all()[1].title) chips=\(chips(1)) drawn=\(drew)", "tabs=2 title=admin panel chips=none drawn=true")
|
|
1990
|
+
self.closeTab(of: all()[1])
|
|
1991
|
+
until({ all().count == 1 }, next)
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
// the same url with two logins: its tab, at the hop's address, wears a chip a field a login; the hub's has none
|
|
1996
|
+
steps.append { next in
|
|
1997
|
+
ask(tab + ", urlId: 'admin', logins: ['admin', 'viewer'] }")
|
|
1998
|
+
until({ all().count == 2 && loaded(1) }) {
|
|
1999
|
+
let at = pane(1)?.web.url?.absoluteString.replacingOccurrences(of: ":\(startURL.port ?? 80)", with: ":PORT") ?? "none"
|
|
2000
|
+
let drew = png.map { draw(all()[1], to: $0) } ?? true
|
|
2001
|
+
say("tab", "tabs=\(all().count) shown=\(shown()) at=\(at) title=\(all()[1].title) chips=\(chips(1)) hub-chips=\(chips(0)) drawn=\(drew)", "tabs=2 shown=2 at=http://admin--meadow.localhost:PORT/admin title=admin panel chips=admin:account,password viewer:account,password hub-chips=none drawn=true")
|
|
2002
|
+
next()
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
// a press of admin's password: on the run's own board, concealed, the chip says so; gone at the clock
|
|
2006
|
+
steps.append { next in
|
|
2007
|
+
chip(0, "password")?.performClick(nil)
|
|
2008
|
+
until({ self.board.string(forType: .string) != nil }) {
|
|
2009
|
+
let types = (self.board.types ?? []).map(\.rawValue)
|
|
2010
|
+
say("password", "board=\(self.board.name.rawValue.hasPrefix("dev.shipkit.self-test.") ? "private" : "not the run's") holds=\(held()) concealed=\(types.contains(Delegate.concealed.rawValue)) chip=\(chip(0, "password")?.title ?? "none")", "board=private holds=the password concealed=true chip=copied")
|
|
2011
|
+
later(self.clearAfter + 0.4) {
|
|
2012
|
+
say("at-the-clock", "holds=\(held())", "holds=empty")
|
|
2013
|
+
next()
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
// a press of admin's account, then his own copy before the clock: the clock leaves his copy alone
|
|
2018
|
+
steps.append { next in
|
|
2019
|
+
chip(0, "account")?.performClick(nil)
|
|
2020
|
+
until({ self.board.string(forType: .string) != nil }) {
|
|
2021
|
+
let got = held()
|
|
2022
|
+
self.board.clearContents()
|
|
2023
|
+
self.board.setString("his own copy", forType: .string)
|
|
2024
|
+
later(self.clearAfter + 0.4) {
|
|
2025
|
+
say("his-copy", "copied=\(got) then at-the-clock holds=\(held())", "copied=the account then at-the-clock holds=his own copy")
|
|
2026
|
+
next()
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
// a field the hub refuses: the chip says it and its tip the hub's words; the board is left as it was
|
|
2031
|
+
steps.append { next in
|
|
2032
|
+
chip(1, "password")?.performClick(nil)
|
|
2033
|
+
until({ chip(1, "password")?.title == "not copied" }) {
|
|
2034
|
+
say("refused", "chip=\(chip(1, "password")?.title ?? "none") tip=\(chip(1, "password")?.toolTip ?? "none") holds=\(held())", "chip=not copied tip=no password for viewer in this test hub holds=his own copy")
|
|
2035
|
+
next()
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
// a copy, then the app quits before the clock: the value leaves with it
|
|
2039
|
+
steps.append { next in
|
|
2040
|
+
chip(0, "password")?.performClick(nil)
|
|
2041
|
+
until({ held() == "the password" }) {
|
|
2042
|
+
let got = held()
|
|
2043
|
+
self.applicationWillTerminate(Notification(name: NSApplication.willTerminateNotification))
|
|
2044
|
+
say("quit", "copied=\(got) then holds=\(held())", "copied=the password then holds=empty")
|
|
2045
|
+
next()
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
run()
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
// `--self-test-find`: a window that is never shown, on a page holding a word twice,
|
|
437
2052
|
// the find bar opened, a word on the page searched, then one that is not;
|
|
438
2053
|
// what happened printed, exit 0 only when the bar shows and finds
|
|
439
2054
|
func selfTestFind() {
|
|
440
2055
|
let web = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
|
|
441
2056
|
web.navigationDelegate = self
|
|
442
2057
|
let pane = Pane(web: web)
|
|
443
|
-
let win =
|
|
2058
|
+
let win = QuietWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 400), styleMask: [.titled], backing: .buffered, defer: false)
|
|
444
2059
|
win.contentView = pane
|
|
445
|
-
win.orderFrontRegardless()
|
|
446
2060
|
windows.append(win)
|
|
447
2061
|
onLoad = { _ in
|
|
448
2062
|
pane.showFind()
|
|
@@ -454,7 +2068,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
454
2068
|
print("found=\(found)")
|
|
455
2069
|
print("absent-found=\(absent)")
|
|
456
2070
|
print("status=\(pane.status.stringValue)")
|
|
457
|
-
|
|
2071
|
+
finish(pane.isFindBarVisible && found && !absent ? 0 : 1)
|
|
458
2072
|
}
|
|
459
2073
|
}
|
|
460
2074
|
}
|
|
@@ -467,7 +2081,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
467
2081
|
let web = WKWebView(frame: NSRect(x: 0, y: 0, width: 400, height: 300), configuration: webConfig())
|
|
468
2082
|
web.navigationDelegate = self
|
|
469
2083
|
web.uiDelegate = self
|
|
470
|
-
windows.append(
|
|
2084
|
+
windows.append(QuietWindow(contentRect: NSRect(x: 0, y: 0, width: 400, height: 300), styleMask: [.titled], backing: .buffered, defer: false))
|
|
471
2085
|
windows.last?.contentView = web
|
|
472
2086
|
let probe = "typeof (navigator.mediaDevices && navigator.mediaDevices.getUserMedia)"
|
|
473
2087
|
onLoad = { _ in
|
|
@@ -476,7 +2090,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
476
2090
|
self.onLoad = { _ in
|
|
477
2091
|
web.evaluateJavaScript(probe) { other, _ in
|
|
478
2092
|
print("other=\(other as? String ?? "error")")
|
|
479
|
-
|
|
2093
|
+
finish((local as? String) == "function" ? 0 : 1)
|
|
480
2094
|
}
|
|
481
2095
|
}
|
|
482
2096
|
web.loadHTMLString("<p>other</p>", baseURL: URL(string: "http://example.invalid/"))
|
|
@@ -487,41 +2101,37 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
487
2101
|
if let url = served { web.load(URLRequest(url: url)) } else { web.loadHTMLString("<p>local</p>", baseURL: URL(string: "http://127.0.0.1:9/")) }
|
|
488
2102
|
}
|
|
489
2103
|
|
|
490
|
-
/**
|
|
491
|
-
var onPanel: ((NSAlert) -> Void)?
|
|
2104
|
+
/** a self test's answer to an alert, which it never shows: the button it gives is the one `present` reports */
|
|
2105
|
+
var onPanel: ((NSAlert, @escaping (NSApplication.ModalResponse) -> Void) -> Void)?
|
|
492
2106
|
|
|
493
|
-
// `--self-test-panels`: a page in
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
//
|
|
497
|
-
// button: a synthetic return reaches it only in a key window, and the test
|
|
498
|
-
// must not take the focus
|
|
2107
|
+
// `--self-test-panels`: a page in a window that is never shown calls prompt, confirm and alert. No panel reaches
|
|
2108
|
+
// the screen: each one is built as the owner would get it and handed to the test, which answers OK after typing
|
|
2109
|
+
// over the prompt's text, then again answers Cancel. What the page got printed, exit 0 only when every answer
|
|
2110
|
+
// reached it. Return is checked as OK being the panel's default button, esc as the key of Cancel
|
|
499
2111
|
func selfTestPanels() {
|
|
500
2112
|
let web = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
|
|
501
2113
|
web.navigationDelegate = self
|
|
502
2114
|
web.uiDelegate = self
|
|
503
|
-
let win =
|
|
2115
|
+
let win = QuietWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 400), styleMask: [.titled], backing: .buffered, defer: false)
|
|
504
2116
|
win.contentView = Pane(web: web)
|
|
505
|
-
win.orderFrontRegardless()
|
|
506
2117
|
windows.append(win)
|
|
507
2118
|
var accept = true
|
|
508
2119
|
var panels = 0
|
|
509
2120
|
var returnIsOK = true
|
|
510
2121
|
var escHeard = true
|
|
511
|
-
onPanel = { alert in
|
|
2122
|
+
onPanel = { alert, answer in
|
|
512
2123
|
panels += 1
|
|
513
2124
|
DispatchQueue.main.async {
|
|
514
2125
|
if alert.window.defaultButtonCell !== alert.buttons[0].cell { returnIsOK = false }
|
|
515
2126
|
if accept {
|
|
516
2127
|
// typing replaces the default text only when it is selected in an active editor
|
|
517
2128
|
if let field = alert.accessoryView as? NSTextField { (field.currentEditor() as? NSTextView)?.insertText("typed", replacementRange: NSRange(location: NSNotFound, length: 0)) }
|
|
518
|
-
return
|
|
2129
|
+
return answer(.alertFirstButtonReturn)
|
|
519
2130
|
}
|
|
520
|
-
if alert.buttons.count == 1 { return
|
|
521
|
-
|
|
522
|
-
if
|
|
523
|
-
|
|
524
|
-
alert.buttons[1].performClick(nil)
|
|
2131
|
+
if alert.buttons.count == 1 { return answer(.alertFirstButtonReturn) }
|
|
2132
|
+
// esc is the key of Cancel, the second button: its answer is the one given
|
|
2133
|
+
if alert.buttons[1].keyEquivalent != "\u{1b}" { escHeard = false }
|
|
2134
|
+
answer(.alertSecondButtonReturn)
|
|
525
2135
|
}
|
|
526
2136
|
}
|
|
527
2137
|
let js = "JSON.stringify([prompt('name', 'x'), confirm('ok?'), (alert('hi'), 'alerted')])"
|
|
@@ -535,7 +2145,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
535
2145
|
print("esc-heard=\(escHeard)")
|
|
536
2146
|
print("ok=\(ok)")
|
|
537
2147
|
print("cancel=\(cancel)")
|
|
538
|
-
|
|
2148
|
+
finish(panels == 6 && returnIsOK && escHeard && ok == "[\"typed\",true,\"alerted\"]" && cancel == "[null,false,\"alerted\"]" ? 0 : 1)
|
|
539
2149
|
}
|
|
540
2150
|
}
|
|
541
2151
|
}
|
|
@@ -545,6 +2155,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
545
2155
|
func windowWillClose(_ note: Notification) {
|
|
546
2156
|
let pane = (note.object as? NSWindow)?.contentView as? Pane
|
|
547
2157
|
windows.removeAll { $0 === note.object as? NSWindow }
|
|
2158
|
+
settleTabs()
|
|
548
2159
|
guard let pane else { return }
|
|
549
2160
|
// the last window leaves the home loaded with no window, on the home that window was on; its count holds
|
|
550
2161
|
// until that page posts its own
|
|
@@ -555,28 +2166,262 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
555
2166
|
dropCount(pane.web)
|
|
556
2167
|
}
|
|
557
2168
|
|
|
558
|
-
//
|
|
2169
|
+
// a page with no title leaves the app's name on its window (Pane watches the title of one that has)
|
|
559
2170
|
func webView(_ web: WKWebView, didFinish nav: WKNavigation!) {
|
|
2171
|
+
arrive(web)
|
|
560
2172
|
onLoad?(web)
|
|
561
|
-
web.window?.title = (web.
|
|
2173
|
+
if web.title?.isEmpty != false { web.window?.title = (web.superview as? Pane)?.name ?? appName }
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
/** the project's own urls as its hub lists them (`sk urls`: its declared urls, its global processes among them),
|
|
2177
|
+
* any host: a link of the hub to one opens as a tab, where any other site leaves for the default browser */
|
|
2178
|
+
var declared: [URL] = []
|
|
2179
|
+
/** asks the hub for the list; the self test answers in its place */
|
|
2180
|
+
lazy var fetchDeclared: (@escaping ([URL]?) -> Void) -> Void = { done in
|
|
2181
|
+
guard let repo = projectRepo?.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed), let api = URL(string: "/r/\(repo)/api/urls.json", relativeTo: startURL) else { return done(nil) }
|
|
2182
|
+
var req = URLRequest(url: api)
|
|
2183
|
+
req.timeoutInterval = 3
|
|
2184
|
+
URLSession.shared.dataTask(with: req) { data, _, err in
|
|
2185
|
+
let rows = data.flatMap { try? JSONSerialization.jsonObject(with: $0) as? [String: Any] }?["urls"] as? [[String: Any]]
|
|
2186
|
+
if rows == nil { NSLog("shipkit: the project's urls did not load, so a link to one leaves for the browser: \(err?.localizedDescription ?? "not the list") (\(api.absoluteString))") }
|
|
2187
|
+
DispatchQueue.main.async { done(rows?.compactMap { ($0["url"] as? String).flatMap { URL(string: $0) } }) }
|
|
2188
|
+
}.resume()
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
func isDeclared(_ url: URL) -> Bool { declared.contains { originOf($0) == originOf(url) } }
|
|
2192
|
+
|
|
2193
|
+
/** a url of another site asked from the hub: a tab when the project declares it, read again from the hub when
|
|
2194
|
+
* the list kept does not hold it (a url declared since), else the road out */
|
|
2195
|
+
func openDeclared(_ url: URL) {
|
|
2196
|
+
if isDeclared(url) { return open(url) }
|
|
2197
|
+
fetchDeclared { list in
|
|
2198
|
+
if let list { self.declared = list }
|
|
2199
|
+
if self.isDeclared(url) { self.open(url) } else { self.openOutside(url) }
|
|
2200
|
+
}
|
|
562
2201
|
}
|
|
563
2202
|
|
|
564
|
-
|
|
2203
|
+
/** another repo's own app, through the home (`/api/projects/open-app`): built when missing, a running one brought
|
|
2204
|
+
* forward; a refusal says so in a panel */
|
|
2205
|
+
func openProjectApp(_ repo: String) {
|
|
2206
|
+
guard let api = URL(string: "/api/projects/open-app", relativeTo: startURL) else { return }
|
|
2207
|
+
var req = URLRequest(url: api)
|
|
2208
|
+
req.httpMethod = "POST"
|
|
2209
|
+
req.setValue("application/json", forHTTPHeaderField: "content-type")
|
|
2210
|
+
req.httpBody = try? JSONSerialization.data(withJSONObject: ["name": repo])
|
|
2211
|
+
URLSession.shared.dataTask(with: req) { data, res, err in
|
|
2212
|
+
let code = (res as? HTTPURLResponse)?.statusCode ?? 0
|
|
2213
|
+
if code == 200 { return }
|
|
2214
|
+
let why = err?.localizedDescription ?? data.flatMap { String(data: $0, encoding: .utf8) } ?? "status \(code)"
|
|
2215
|
+
DispatchQueue.main.async {
|
|
2216
|
+
let alert = NSAlert()
|
|
2217
|
+
alert.messageText = "The app of \(repo) did not open"
|
|
2218
|
+
alert.informativeText = why
|
|
2219
|
+
self.present(alert)
|
|
2220
|
+
}
|
|
2221
|
+
}.resume()
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
// a rebuilt bundle reaches a running copy: with no window it relaunches by itself; with windows, each one shows a
|
|
2225
|
+
// « new version: relaunch » button in its title bar, and only his click quits it
|
|
2226
|
+
var stale = false
|
|
2227
|
+
func watchBuild() {
|
|
2228
|
+
Timer.scheduledTimer(withTimeInterval: 20, repeats: true) { _ in
|
|
2229
|
+
guard !self.stale, let now = stampOnDisk(), let was = launchedStamp, now != was else { return }
|
|
2230
|
+
self.stale = true
|
|
2231
|
+
if self.windows.isEmpty { return self.relaunch(nil) }
|
|
2232
|
+
for w in self.windows { self.offerRelaunch(w) }
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
func offerRelaunch(_ w: NSWindow) {
|
|
2237
|
+
guard stale, !w.titlebarAccessoryViewControllers.contains(where: { $0.identifier?.rawValue == "relaunch" }) else { return }
|
|
2238
|
+
let button = NSButton(title: "new version: relaunch", target: self, action: #selector(relaunch(_:)))
|
|
2239
|
+
button.bezelStyle = .recessed
|
|
2240
|
+
button.controlSize = .small
|
|
2241
|
+
button.sizeToFit()
|
|
2242
|
+
let holder = NSView(frame: NSRect(x: 0, y: 0, width: button.frame.width + 12, height: 28))
|
|
2243
|
+
button.frame.origin = NSPoint(x: 6, y: (28 - button.frame.height) / 2)
|
|
2244
|
+
holder.addSubview(button)
|
|
2245
|
+
let c = NSTitlebarAccessoryViewController()
|
|
2246
|
+
c.identifier = NSUserInterfaceItemIdentifier("relaunch")
|
|
2247
|
+
c.view = holder
|
|
2248
|
+
c.layoutAttribute = .trailing
|
|
2249
|
+
w.addTitlebarAccessoryViewController(c)
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
/** a url's tab wears its logins in its title bar, as the hub's page does above a frame: each login's label, then
|
|
2253
|
+
* one chip a field. A press copies that field (copyChip). Words only: no value is drawn or kept */
|
|
2254
|
+
func wearChips(_ w: NSWindow, _ chips: (urlId: String, logins: [String])) {
|
|
2255
|
+
let row = NSStackView()
|
|
2256
|
+
row.orientation = .horizontal
|
|
2257
|
+
row.spacing = 4
|
|
2258
|
+
row.edgeInsets = NSEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
|
|
2259
|
+
for (i, label) in chips.logins.enumerated() {
|
|
2260
|
+
let name = NSTextField(labelWithString: label)
|
|
2261
|
+
name.font = .systemFont(ofSize: NSFont.smallSystemFontSize)
|
|
2262
|
+
name.textColor = .secondaryLabelColor
|
|
2263
|
+
if let last = row.arrangedSubviews.last { row.setCustomSpacing(12, after: last) }
|
|
2264
|
+
row.addArrangedSubview(name)
|
|
2265
|
+
for field in ["account", "password"] {
|
|
2266
|
+
let b = ChipButton(title: field, target: self, action: #selector(copyChip(_:)))
|
|
2267
|
+
b.urlId = chips.urlId
|
|
2268
|
+
b.login = i
|
|
2269
|
+
b.label = label
|
|
2270
|
+
b.field = field
|
|
2271
|
+
b.toolTip = "copy the \(field) of \(label)"
|
|
2272
|
+
b.bezelStyle = .recessed
|
|
2273
|
+
b.controlSize = .small
|
|
2274
|
+
b.image = NSImage(systemSymbolName: "doc.on.doc", accessibilityDescription: "copy")
|
|
2275
|
+
b.imagePosition = .imageLeading
|
|
2276
|
+
row.addArrangedSubview(b)
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
row.frame = NSRect(x: 0, y: 0, width: row.fittingSize.width, height: 28)
|
|
2280
|
+
let c = NSTitlebarAccessoryViewController()
|
|
2281
|
+
c.identifier = NSUserInterfaceItemIdentifier("logins")
|
|
2282
|
+
c.view = row
|
|
2283
|
+
c.layoutAttribute = .trailing
|
|
2284
|
+
w.addTitlebarAccessoryViewController(c)
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
/** the chips a tab wears, in their order */
|
|
2288
|
+
func chipButtons(of w: NSWindow?) -> [ChipButton] {
|
|
2289
|
+
guard let c = w?.titlebarAccessoryViewControllers.first(where: { $0.identifier?.rawValue == "logins" }) else { return [] }
|
|
2290
|
+
return (c.view as? NSStackView)?.arrangedSubviews.compactMap { $0 as? ChipButton } ?? []
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
/** the hub's answers to a chip: nothing of them is kept on disk */
|
|
2294
|
+
lazy var quiet = URLSession(configuration: .ephemeral)
|
|
2295
|
+
|
|
2296
|
+
/** a chip's press: the hub's copy route answers the field (any program of this Mac reaches it, the hub guards it),
|
|
2297
|
+
* and the value goes from the answer to the board, nowhere else. A refusal says the hub's words on the chip */
|
|
2298
|
+
@objc func copyChip(_ b: ChipButton) {
|
|
2299
|
+
guard let repo = projectRepo?.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed), let api = URL(string: "/r/\(repo)/api/urls/copy", relativeTo: startURL) else { return }
|
|
2300
|
+
var req = URLRequest(url: api)
|
|
2301
|
+
req.httpMethod = "POST"
|
|
2302
|
+
req.timeoutInterval = 5
|
|
2303
|
+
req.setValue("application/json", forHTTPHeaderField: "content-type")
|
|
2304
|
+
req.httpBody = try? JSONSerialization.data(withJSONObject: ["id": b.urlId, "login": b.login, "field": b.field])
|
|
2305
|
+
b.say("copying…", for: 6)
|
|
2306
|
+
quiet.dataTask(with: req) { data, res, err in
|
|
2307
|
+
let code = (res as? HTTPURLResponse)?.statusCode ?? 0
|
|
2308
|
+
let value = code == 200 ? (data.flatMap { try? JSONSerialization.jsonObject(with: $0) } as? [String: Any])?["value"] as? String : nil
|
|
2309
|
+
// a refusal's words are the hub's, which never hold a value; the answer of a copy is never read as words
|
|
2310
|
+
let why = value != nil ? "" : code == 200 ? "the hub's answer held no value" : err?.localizedDescription ?? data.flatMap { String(data: $0, encoding: .utf8) }.map { String($0.prefix(200)) } ?? "the hub answered \(code)"
|
|
2311
|
+
DispatchQueue.main.async {
|
|
2312
|
+
if let value {
|
|
2313
|
+
self.conceal(value)
|
|
2314
|
+
return b.say("copied")
|
|
2315
|
+
}
|
|
2316
|
+
NSLog("shipkit: the \(b.field) of \(b.label) (\(b.urlId)) was not copied: \(why)")
|
|
2317
|
+
b.say("not copied", why: why, for: 5)
|
|
2318
|
+
}
|
|
2319
|
+
}.resume()
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
/** the board a chip copies into: the owner's, and one of the run's own in a self test, which never reaches his */
|
|
2323
|
+
lazy var board: NSPasteboard = selfTesting ? NSPasteboard(name: NSPasteboard.Name("dev.shipkit.self-test.\(ProcessInfo.processInfo.processIdentifier)")) : .general
|
|
2324
|
+
/** how long a copied value stays on the board */
|
|
2325
|
+
var clearAfter: TimeInterval = 90
|
|
2326
|
+
/** the board's count right after the last copy: while it matches, the board holds that value */
|
|
2327
|
+
var copiedAt: Int?
|
|
2328
|
+
/** the mark a clipboard manager skips (nspasteboard.org): a password never lands in its history */
|
|
2329
|
+
static let concealed = NSPasteboard.PasteboardType("org.nspasteboard.ConcealedType")
|
|
2330
|
+
|
|
2331
|
+
func conceal(_ value: String) {
|
|
2332
|
+
board.clearContents()
|
|
2333
|
+
board.declareTypes([.string, Delegate.concealed], owner: nil)
|
|
2334
|
+
board.setString(value, forType: .string)
|
|
2335
|
+
board.setString("", forType: Delegate.concealed)
|
|
2336
|
+
let mark = board.changeCount
|
|
2337
|
+
copiedAt = mark
|
|
2338
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + clearAfter) { [weak self] in self?.clearCopy(mark) }
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
/** the value copied at `mark` (none: the last one) leaves the board, unless anything was copied since */
|
|
2342
|
+
func clearCopy(_ mark: Int? = nil) {
|
|
2343
|
+
guard let at = copiedAt, mark == nil || mark == at else { return }
|
|
2344
|
+
copiedAt = nil
|
|
2345
|
+
if board.changeCount == at { board.clearContents() }
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
// a quit before the clock: the value leaves with the app
|
|
2349
|
+
func applicationWillTerminate(_ note: Notification) { clearCopy() }
|
|
2350
|
+
|
|
2351
|
+
/** a fresh copy of this bundle once this one has quit: the home app with no window comes back with none */
|
|
2352
|
+
@objc func relaunch(_ sender: Any?) {
|
|
2353
|
+
let back = isShipkit && windows.isEmpty ? " --args --background" : ""
|
|
2354
|
+
let path = Bundle.main.bundlePath.replacingOccurrences(of: "'", with: "'\\''")
|
|
2355
|
+
let p = Process()
|
|
2356
|
+
p.executableURL = URL(fileURLWithPath: "/bin/sh")
|
|
2357
|
+
p.arguments = ["-c", "while kill -0 \(ProcessInfo.processInfo.processIdentifier) 2>/dev/null; do sleep 0.2; done; open '\(path)'\(back)"]
|
|
2358
|
+
try? p.run()
|
|
2359
|
+
NSApp.terminate(nil)
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
/** the one road out of the app: the default browser, or the app of the url's scheme; a refusal says so */
|
|
2363
|
+
lazy var openOutside: (URL) -> Void = { url in
|
|
2364
|
+
NSWorkspace.shared.open(url, configuration: NSWorkspace.OpenConfiguration()) { _, err in
|
|
2365
|
+
guard let err else { return }
|
|
2366
|
+
DispatchQueue.main.async {
|
|
2367
|
+
let alert = NSAlert()
|
|
2368
|
+
alert.messageText = "This link could not open outside the app"
|
|
2369
|
+
alert.informativeText = "\(url.absoluteString)\n\n\(err.localizedDescription)"
|
|
2370
|
+
self.present(alert)
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
/** a project app sends a main frame's move down its road: a tab, the default browser, another repo's app. False:
|
|
2376
|
+
* it stays in the page that asked. The context menu's « open in a tab here » makes its own ask a tab, whatever
|
|
2377
|
+
* the site */
|
|
2378
|
+
func reroutes(_ url: URL, from web: WKWebView, new: Bool, click: Bool) -> Bool {
|
|
2379
|
+
let menu = new && (web as? Web)?.tabNext == true
|
|
2380
|
+
if menu { (web as? Web)?.tabNext = false }
|
|
2381
|
+
switch menu ? Road.tab : road(to: url, from: web.url, home: (web.superview as? Pane)?.opened, new: new, click: click, repo: projectRepo) {
|
|
2382
|
+
case .here: return false
|
|
2383
|
+
case .tab: openTab(url, again: menu)
|
|
2384
|
+
case .declared: openDeclared(url)
|
|
2385
|
+
case .outside: openOutside(url)
|
|
2386
|
+
case .app(let other): openProjectApp(other)
|
|
2387
|
+
}
|
|
2388
|
+
return true
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
// a link clicked, or a new window asked (target=_blank, window.open): the app's own host stays in the app, any
|
|
2392
|
+
// other site or app leaves for the default browser (`leaves`)
|
|
565
2393
|
func webView(_ web: WKWebView, decidePolicyFor action: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
|
566
2394
|
// a link marked download saves the file, as a browser does, instead of showing it in the window
|
|
567
2395
|
if action.shouldPerformDownload { return decisionHandler(.download) }
|
|
568
|
-
|
|
569
|
-
if
|
|
570
|
-
|
|
2396
|
+
// a project app: each main frame's move takes its road
|
|
2397
|
+
if tabbed, let url = action.request.url, action.targetFrame?.isMainFrame ?? true {
|
|
2398
|
+
return decisionHandler(reroutes(url, from: web, new: action.targetFrame == nil, click: action.navigationType == .linkActivated) ? .cancel : .allow)
|
|
2399
|
+
}
|
|
2400
|
+
// a frame of a project app's page moves inside its own site; a link clicked in it to another site leaves
|
|
2401
|
+
if tabbed, let url = action.request.url, action.targetFrame != nil {
|
|
2402
|
+
let out = action.navigationType == .linkActivated && road(to: url, from: action.sourceFrame.request.url, home: nil, new: false, click: true, repo: nil) == .outside
|
|
2403
|
+
if out { openOutside(url) }
|
|
2404
|
+
return decisionHandler(out ? .cancel : .allow)
|
|
2405
|
+
}
|
|
2406
|
+
guard let url = action.request.url, action.navigationType == .linkActivated || action.targetFrame == nil, leaves(url) else { return decisionHandler(.allow) }
|
|
2407
|
+
openOutside(url)
|
|
571
2408
|
decisionHandler(.cancel)
|
|
572
2409
|
}
|
|
573
2410
|
|
|
574
2411
|
// a response the window cannot show (an archive, an attachment) is saved too
|
|
575
2412
|
func webView(_ web: WKWebView, decidePolicyFor response: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
|
2413
|
+
if !response.isForMainFrame, hubApp, web.url.map(isHub) == true, let http = response.response as? HTTPURLResponse, http.statusCode >= 400, let url = http.url { frameAnswered(web, url, http.statusCode) }
|
|
576
2414
|
let attachment = ((response.response as? HTTPURLResponse)?.value(forHTTPHeaderField: "Content-Disposition") ?? "").lowercased().hasPrefix("attachment")
|
|
577
2415
|
decisionHandler(attachment || !response.canShowMIMEType ? .download : .allow)
|
|
578
2416
|
}
|
|
579
2417
|
|
|
2418
|
+
/** a frame of a hub page got an error for an address: the page hears that address and its status, nothing else,
|
|
2419
|
+
* so a url's page drops an address its site no longer answers (serve/hub-app/url-address.ts, FRAME_ANSWER) */
|
|
2420
|
+
func frameAnswered(_ web: WKWebView, _ url: URL, _ status: Int) {
|
|
2421
|
+
guard let data = try? JSONSerialization.data(withJSONObject: ["url": url.absoluteString, "status": status]), let json = String(data: data, encoding: .utf8) else { return }
|
|
2422
|
+
web.evaluateJavaScript("dispatchEvent(new CustomEvent('sk-frame-answer', { detail: \(json) })); 0") { _, _ in }
|
|
2423
|
+
}
|
|
2424
|
+
|
|
580
2425
|
func webView(_ web: WKWebView, navigationAction: WKNavigationAction, didBecome download: WKDownload) { download.delegate = self }
|
|
581
2426
|
func webView(_ web: WKWebView, navigationResponse: WKNavigationResponse, didBecome download: WKDownload) { download.delegate = self }
|
|
582
2427
|
|
|
@@ -623,20 +2468,19 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
623
2468
|
let alert = NSAlert()
|
|
624
2469
|
alert.messageText = "Download failed"
|
|
625
2470
|
alert.informativeText = "\(dest?.lastPathComponent ?? "the file"): \(error.localizedDescription)"
|
|
626
|
-
alert
|
|
2471
|
+
present(alert)
|
|
627
2472
|
}
|
|
628
2473
|
|
|
629
|
-
// `--self-test-download`:
|
|
2474
|
+
// `--self-test-download`: a page in a window that is never shown clicks a link marked download, twice, into SHIPKIT_GUI_DOWNLOADS; what
|
|
630
2475
|
// landed printed, exit 0 only when both files hold the bytes under a free name and the page stayed on itself
|
|
631
2476
|
func selfTestDownload() {
|
|
632
2477
|
let web = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
|
|
633
2478
|
web.navigationDelegate = self
|
|
634
|
-
let win =
|
|
2479
|
+
let win = QuietWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 400), styleMask: [.titled], backing: .buffered, defer: false)
|
|
635
2480
|
win.contentView = Pane(web: web)
|
|
636
|
-
win.orderFrontRegardless()
|
|
637
2481
|
windows.append(win)
|
|
638
2482
|
var saved: [String] = []
|
|
639
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + 15) { print("timeout");
|
|
2483
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 15) { print("timeout"); finish(1) }
|
|
640
2484
|
let click = "document.getElementById('a').click(); 'clicked'"
|
|
641
2485
|
onDownloaded = { url in
|
|
642
2486
|
let text = url.flatMap { try? String(contentsOf: $0, encoding: .utf8) } ?? "none"
|
|
@@ -645,7 +2489,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
645
2489
|
web.evaluateJavaScript("document.body.dataset.page") { page, _ in
|
|
646
2490
|
print("saved=\(saved.joined(separator: ","))")
|
|
647
2491
|
print("page=\((page as? String) ?? "gone")")
|
|
648
|
-
|
|
2492
|
+
finish(saved == ["hello.txt:hello", "hello (2).txt:hello"] && (page as? String) == "here" ? 0 : 1)
|
|
649
2493
|
}
|
|
650
2494
|
}
|
|
651
2495
|
var started = false
|
|
@@ -657,23 +2501,93 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
657
2501
|
web.loadHTMLString("<body data-page=here><a id=a href='data:text/plain,hello' download='hello.txt'>save</a></body>", baseURL: nil)
|
|
658
2502
|
}
|
|
659
2503
|
|
|
660
|
-
//
|
|
661
|
-
//
|
|
662
|
-
//
|
|
2504
|
+
// `--self-test-links`: a page of the machine, in a window that is never shown, with a link of each kind, each clicked as a real mouse
|
|
2505
|
+
// event, then a window.open with no click under it; the road out recorded instead of taken. What left and where
|
|
2506
|
+
// the page is printed, exit 0 only when every link to another site or app left, the machine's own link stayed in
|
|
2507
|
+
// the page and no window opened
|
|
2508
|
+
func selfTestLinks() {
|
|
2509
|
+
var out: [String] = []
|
|
2510
|
+
openOutside = { out.append($0.absoluteString) }
|
|
2511
|
+
let web = WKWebView(frame: NSRect(x: 0, y: 0, width: 600, height: 400), configuration: webConfig())
|
|
2512
|
+
web.navigationDelegate = self
|
|
2513
|
+
web.uiDelegate = self
|
|
2514
|
+
let win = QuietWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 400), styleMask: [.titled], backing: .buffered, defer: false)
|
|
2515
|
+
win.contentView = web
|
|
2516
|
+
windows.append(win)
|
|
2517
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 15) { print("timeout"); finish(1) }
|
|
2518
|
+
let ids = ["blank", "plain", "mail", "home"]
|
|
2519
|
+
let expected = ["https://dash.cloudflare.com/?to=/:account/r2/api-tokens", "https://example.com/plain", "mailto:owner@example.com", "https://example.com/later"]
|
|
2520
|
+
func click(_ k: Int) {
|
|
2521
|
+
if k == ids.count {
|
|
2522
|
+
// the page's own window.open, from its load timer: no click and no script of the app under it
|
|
2523
|
+
return DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
|
2524
|
+
web.evaluateJavaScript("location.href + ' clicked=' + document.body.dataset.clicked") { page, _ in
|
|
2525
|
+
print("out=\(out.joined(separator: ","))")
|
|
2526
|
+
print("page=\((page as? String) ?? "gone")")
|
|
2527
|
+
print("windows=\(self.windows.count)")
|
|
2528
|
+
let p = (page as? String) ?? ""
|
|
2529
|
+
finish(out == expected && p.hasPrefix("http://127.0.0.1:9/") && p.hasSuffix(" clicked=,blank,plain,mail,home") && self.windows.count == 1 ? 0 : 1)
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
web.evaluateJavaScript("(() => { const r = document.getElementById('\(ids[k])').getBoundingClientRect(); return [r.left + 4, r.top + r.height / 2] })()") { v, _ in
|
|
2534
|
+
guard let xy = v as? [Double], xy.count == 2 else { print("no link \(ids[k])"); finish(1) }
|
|
2535
|
+
let at = web.convert(NSPoint(x: xy[0], y: web.isFlipped ? xy[1] : web.bounds.height - xy[1]), to: nil)
|
|
2536
|
+
for type in [NSEvent.EventType.leftMouseDown, .leftMouseUp] {
|
|
2537
|
+
guard let e = NSEvent.mouseEvent(with: type, location: at, modifierFlags: [], timestamp: ProcessInfo.processInfo.systemUptime, windowNumber: win.windowNumber, context: nil, eventNumber: 0, clickCount: 1, pressure: 1) else { continue }
|
|
2538
|
+
if type == .leftMouseDown { web.mouseDown(with: e) } else { web.mouseUp(with: e) }
|
|
2539
|
+
}
|
|
2540
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { click(k + 1) }
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
var started = false
|
|
2544
|
+
onLoad = { _ in
|
|
2545
|
+
if started { return }
|
|
2546
|
+
started = true
|
|
2547
|
+
click(0)
|
|
2548
|
+
}
|
|
2549
|
+
let links = "<a id=blank href='https://dash.cloudflare.com/?to=/:account/r2/api-tokens' target=_blank rel='noopener noreferrer'>bucket key</a><br><a id=plain href='https://example.com/plain'>plain</a><br><a id=mail href='mailto:owner@example.com'>mail</a><br><a id=home href='http://127.0.0.1:9/#here'>home</a>"
|
|
2550
|
+
web.loadHTMLString("<body style='font:20px sans-serif' data-clicked=''>\(links)<script>addEventListener('click', (e) => { document.body.dataset.clicked += ',' + e.target.id }); setTimeout(() => window.open('https://example.com/later'), 3000)</script></body>", baseURL: URL(string: "http://127.0.0.1:9/"))
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
// the Dock badge and the notifications: every window's page posts the same house count, the threads waiting at its
|
|
2554
|
+
// first answer (the seed) and those it saw start waiting after; the app owns the one set of threads notified, so a
|
|
2555
|
+
// thread notifies once whatever the number of windows or reloads, a burst gathered for half a second
|
|
663
2556
|
|
|
664
|
-
/** the
|
|
2557
|
+
/** the threads already notified or already waiting at start, for the life of the app */
|
|
665
2558
|
var notified = Set<String>()
|
|
666
2559
|
/** the first seed of the app's life is the backlog: it never notifies */
|
|
667
2560
|
var seeded = false
|
|
668
|
-
var burst: [
|
|
2561
|
+
var burst: [WaitingThread] = []
|
|
669
2562
|
/** each web view's last count: a page that leaves the home, or a closed window, drops out of the badge */
|
|
670
2563
|
var counts: [ObjectIdentifier: Int] = [:]
|
|
2564
|
+
/** the repo the badge counts, the bundle's (the self test sets one) */
|
|
2565
|
+
var badgeRepo = projectRepo
|
|
671
2566
|
/** hears every notification instead of the system: the self test reads it */
|
|
672
2567
|
var deliver: ((Note) -> Void)?
|
|
673
2568
|
|
|
674
2569
|
func userContentController(_ controller: WKUserContentController, didReceive message: WKScriptMessage) {
|
|
675
2570
|
guard message.frameInfo.isMainFrame, let body = message.body as? [String: Any] else { return }
|
|
676
|
-
|
|
2571
|
+
// a project app hears its hub alone: a page of another site that reached a hub tab posts nothing
|
|
2572
|
+
let from = message.frameInfo.securityOrigin
|
|
2573
|
+
if tabbed && !(from.host == startURL.host && from.port == (startURL.port ?? 0)) { return }
|
|
2574
|
+
if let href = body["reload"] as? String, let url = URL(string: href), let web = message.webView { return reload(web, to: url, view: body["view"] as? String) }
|
|
2575
|
+
// the name of the tab the page asks next, and what command with t opens for the entry it shows
|
|
2576
|
+
if let name = body["tabName"] as? String, let url = (body["url"] as? String).flatMap({ URL(string: $0) }) {
|
|
2577
|
+
tabNames[tabKey(url)] = String(name.prefix(120))
|
|
2578
|
+
tabChips[tabKey(url)] = chipsOf(body)
|
|
2579
|
+
return
|
|
2580
|
+
}
|
|
2581
|
+
if let e = body["entryTab"], let web = message.webView {
|
|
2582
|
+
let d = e as? [String: Any]
|
|
2583
|
+
let live = Set(windows.compactMap { ($0.contentView as? Pane)?.web }.map(ObjectIdentifier.init) + arriving.keys)
|
|
2584
|
+
entries = entries.filter { live.contains($0.key) }
|
|
2585
|
+
entries[ObjectIdentifier(web)] = (d?["url"] as? String).flatMap { URL(string: $0) }.map { (url: $0, name: d?["name"] as? String) }
|
|
2586
|
+
return
|
|
2587
|
+
}
|
|
2588
|
+
// a page that has nothing left to show asks to leave (a terminal alone whose terminal ended): its tab, never the hub's
|
|
2589
|
+
if body["closeTab"] as? Bool == true { return closeTab(of: message.webView?.window) }
|
|
2590
|
+
if let n = badgeCount(body, repo: badgeRepo), let web = message.webView {
|
|
677
2591
|
// a window's page posts again: the page kept with no window leaves
|
|
678
2592
|
if let k = keeper, k !== web {
|
|
679
2593
|
keeper = nil
|
|
@@ -685,25 +2599,27 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
685
2599
|
drawBadge()
|
|
686
2600
|
if let keys = body["keys"] as? [String] { takeBack(waiting: Set(keys)) }
|
|
687
2601
|
}
|
|
2602
|
+
// a project app notifies nothing: the home app's banners already name every thread
|
|
2603
|
+
guard badgeRepo == nil else { return }
|
|
688
2604
|
if let seed = body["seed"] as? [[String: Any]] {
|
|
689
|
-
let
|
|
2605
|
+
let threads = seed.compactMap(threadOf)
|
|
690
2606
|
if !seeded {
|
|
691
2607
|
seeded = true
|
|
692
|
-
for c in
|
|
2608
|
+
for c in threads { notified.insert("\(c.repo)/\(c.id)") }
|
|
693
2609
|
} else {
|
|
694
2610
|
// a reloaded page or a later window: what waits that the app never saw arrived in between
|
|
695
|
-
|
|
2611
|
+
threads.forEach(arrived)
|
|
696
2612
|
}
|
|
697
2613
|
}
|
|
698
|
-
if let c = (body["card"] as? [String: Any]).flatMap(
|
|
2614
|
+
if let c = (body["card"] as? [String: Any]).flatMap(threadOf) { arrived(c) }
|
|
699
2615
|
}
|
|
700
2616
|
|
|
701
|
-
func
|
|
2617
|
+
func threadOf(_ c: [String: Any]) -> WaitingThread? {
|
|
702
2618
|
guard let id = c["id"] as? String, let repo = c["repo"] as? String else { return nil }
|
|
703
|
-
return
|
|
2619
|
+
return WaitingThread(id: id, title: (c["title"] as? String) ?? id, repo: repo, url: (c["url"] as? String) ?? "")
|
|
704
2620
|
}
|
|
705
2621
|
|
|
706
|
-
func arrived(_ c:
|
|
2622
|
+
func arrived(_ c: WaitingThread) {
|
|
707
2623
|
if !notified.insert("\(c.repo)/\(c.id)").inserted { return }
|
|
708
2624
|
burst.append(c)
|
|
709
2625
|
if burst.count == 1 { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { self.flush() } }
|
|
@@ -721,7 +2637,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
721
2637
|
// a new page in a window: its count is gone until the page posts one
|
|
722
2638
|
func webView(_ web: WKWebView, didCommit nav: WKNavigation!) { dropCount(web) }
|
|
723
2639
|
|
|
724
|
-
/** the banners of the
|
|
2640
|
+
/** the banners of the threads that no longer wait leave Notification Center */
|
|
725
2641
|
func takeBack(waiting: Set<String>) {
|
|
726
2642
|
guard isShipkit, deliver == nil else { return }
|
|
727
2643
|
let center = UNUserNotificationCenter.current()
|
|
@@ -740,15 +2656,15 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
740
2656
|
func notify(_ note: Note) {
|
|
741
2657
|
let content = UNMutableNotificationContent()
|
|
742
2658
|
switch note {
|
|
743
|
-
case .
|
|
2659
|
+
case .thread(let c):
|
|
744
2660
|
content.title = c.title
|
|
745
2661
|
content.body = c.repo
|
|
746
2662
|
content.threadIdentifier = c.repo
|
|
747
2663
|
content.userInfo = ["repo": c.repo, "id": c.id, "url": c.url, "cards": [c.key]]
|
|
748
|
-
case .more(let
|
|
749
|
-
content.title = "\(
|
|
2664
|
+
case .more(let threads, let inbox):
|
|
2665
|
+
content.title = "\(threads.count) more thread\(threads.count == 1 ? "" : "s") wait for you"
|
|
750
2666
|
content.body = "open the inbox"
|
|
751
|
-
content.userInfo = ["inbox": true, "url": inbox?.absoluteString ?? "", "cards":
|
|
2667
|
+
content.userInfo = ["inbox": true, "url": inbox?.absoluteString ?? "", "cards": threads.map(\.key)]
|
|
752
2668
|
}
|
|
753
2669
|
content.sound = .default
|
|
754
2670
|
UNUserNotificationCenter.current().add(UNNotificationRequest(identifier: idOf(note), content: content, trigger: nil)) { err in
|
|
@@ -766,7 +2682,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
766
2682
|
done()
|
|
767
2683
|
}
|
|
768
2684
|
|
|
769
|
-
/** a click: a window forward on the
|
|
2685
|
+
/** a click: a window forward on the thread (or the inbox), in place through the page's hooks; a page without them,
|
|
770
2686
|
* or no window at all, loads the address */
|
|
771
2687
|
func route(_ info: [AnyHashable: Any]) {
|
|
772
2688
|
let win = (NSApp.keyWindow?.contentView is Pane ? NSApp.keyWindow : nil) ?? windows.first
|
|
@@ -774,23 +2690,21 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
774
2690
|
if let url = fallbackOf(info) { open(url) }
|
|
775
2691
|
return
|
|
776
2692
|
}
|
|
777
|
-
|
|
778
|
-
win.makeKeyAndOrderFront(nil)
|
|
779
|
-
NSApp.activate(ignoringOtherApps: true)
|
|
2693
|
+
onScreen(win)
|
|
780
2694
|
openIn(pane.web, info)
|
|
781
2695
|
}
|
|
782
2696
|
|
|
783
|
-
/** the address a click loads where the page has no hooks: the
|
|
784
|
-
*
|
|
2697
|
+
/** the address a click loads where the page has no hooks: the thread's review page, or the inbox of the home the
|
|
2698
|
+
* threads came from */
|
|
785
2699
|
func fallbackOf(_ info: [AnyHashable: Any]) -> URL? {
|
|
786
2700
|
let url = URL(string: (info["url"] as? String) ?? "")
|
|
787
2701
|
return (info["inbox"] as? Bool) == true && url == nil ? URL(string: "/inbox", relativeTo: startURL)?.absoluteURL : url
|
|
788
2702
|
}
|
|
789
2703
|
|
|
790
|
-
/** the page's own hooks open the
|
|
2704
|
+
/** the page's own hooks open the thread in place; `done` hears whether they did */
|
|
791
2705
|
func openIn(_ web: WKWebView, _ info: [AnyHashable: Any], done: ((Bool) -> Void)? = nil) {
|
|
792
2706
|
let inbox = (info["inbox"] as? Bool) == true
|
|
793
|
-
let js = inbox ? "if (!window.shipkitApp) return false; shipkitApp.openInbox(); return true" : "if (!window.shipkitApp) return false; shipkitApp.
|
|
2707
|
+
let js = inbox ? "if (!window.shipkitApp) return false; shipkitApp.openInbox(); return true" : "if (!window.shipkitApp) return false; shipkitApp.openThread(repo, id); return true"
|
|
794
2708
|
web.callAsyncJavaScript(js, arguments: ["repo": (info["repo"] as? String) ?? "", "id": (info["id"] as? String) ?? ""], in: nil, in: .page) { r in
|
|
795
2709
|
if case .success(let v) = r, (v as? Bool) == true {
|
|
796
2710
|
done?(true)
|
|
@@ -801,26 +2715,25 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
801
2715
|
}
|
|
802
2716
|
}
|
|
803
2717
|
|
|
804
|
-
// `--self-test-badge`:
|
|
805
|
-
// of a reload, a burst of five, the count back to zero, then a notification's click opens a
|
|
2718
|
+
// `--self-test-badge`: a page in a window that is never shown posts as the hub does: the seed and a count, threads (one twice), the seed
|
|
2719
|
+
// of a reload, a burst of five, the count back to zero, then a notification's click opens a thread through the
|
|
806
2720
|
// page's hook; the badge, the planned
|
|
807
|
-
// notifications and the
|
|
808
|
-
// reaches the system's notification center
|
|
2721
|
+
// notifications and the thread opened printed, exit 0 only when each one is as the owner would see it. Nothing
|
|
2722
|
+
// reaches the system's notification center
|
|
809
2723
|
func selfTestBadge() {
|
|
810
2724
|
let config = WKWebViewConfiguration()
|
|
811
2725
|
config.userContentController.add(self, name: "shipkit")
|
|
812
2726
|
let web = WKWebView(frame: .zero, configuration: config)
|
|
813
2727
|
web.navigationDelegate = self
|
|
814
|
-
let win =
|
|
2728
|
+
let win = QuietWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 400), styleMask: [.titled], backing: .buffered, defer: false)
|
|
815
2729
|
win.contentView = Pane(web: web)
|
|
816
|
-
win.orderFrontRegardless()
|
|
817
2730
|
windows.append(win)
|
|
818
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + 15) { print("timeout");
|
|
2731
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 15) { print("timeout"); finish(1) }
|
|
819
2732
|
var notes: [String] = []
|
|
820
2733
|
deliver = { n in
|
|
821
2734
|
switch n {
|
|
822
|
-
case .
|
|
823
|
-
case .more(let
|
|
2735
|
+
case .thread(let c): notes.append("\(c.repo)/\(c.id):\(c.title)")
|
|
2736
|
+
case .more(let threads, let inbox): notes.append("more:\(threads.count):\(inbox?.absoluteString ?? "none")")
|
|
824
2737
|
}
|
|
825
2738
|
notes[notes.count - 1] += "@" + idOf(n)
|
|
826
2739
|
}
|
|
@@ -830,7 +2743,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
830
2743
|
}
|
|
831
2744
|
}
|
|
832
2745
|
let row = { (repo: String, id: String) in "{id: '\(id)', title: 't\(id)', repo: '\(repo)', url: 'http://127.0.0.1:9/r/\(repo)/'}" }
|
|
833
|
-
let
|
|
2746
|
+
let thread = { (repo: String, id: String) in "p({card: \(row(repo, id))})" }
|
|
834
2747
|
// the second seed is a reloaded page: a/0 waited at start, a/1 was notified, d/1 arrived during the reload
|
|
835
2748
|
let reload = "p({seed: [\(row("a", "0")), \(row("a", "1")), \(row("d", "1"))]})"
|
|
836
2749
|
var started = false
|
|
@@ -839,26 +2752,35 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
839
2752
|
started = true
|
|
840
2753
|
post("p({seed: [\(row("a", "0"))]}); p({waiting: 2})") {
|
|
841
2754
|
let two = NSApp.dockTile.badgeLabel ?? "none"
|
|
842
|
-
post([
|
|
2755
|
+
post([thread("a", "1"), thread("a", "1"), thread("b", "1"), reload].joined(separator: "; ")) {
|
|
843
2756
|
let few = notes
|
|
844
2757
|
notes = []
|
|
845
|
-
post((1...5).map {
|
|
2758
|
+
post((1...5).map { thread("c", "\($0)") }.joined(separator: "; ") + "; " + thread("a", "1")) {
|
|
846
2759
|
let many = notes
|
|
847
2760
|
post("p({waiting: 0})") {
|
|
848
2761
|
let zero = NSApp.dockTile.badgeLabel ?? "none"
|
|
849
|
-
// a
|
|
850
|
-
self.
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
2762
|
+
// a project app of repo b: the same post shows b's count, and a thread arriving notifies nothing
|
|
2763
|
+
self.badgeRepo = "b"
|
|
2764
|
+
let heard = notes.count
|
|
2765
|
+
post("p({waiting: 3, keys: [], repos: {a: 2, b: 1}}); " + thread("e", "1")) {
|
|
2766
|
+
let project = NSApp.dockTile.badgeLabel ?? "none"
|
|
2767
|
+
let quiet = notes.count == heard
|
|
2768
|
+
self.badgeRepo = nil
|
|
2769
|
+
// a click on the notification of thread b/1: the page's hook opens it in place
|
|
2770
|
+
self.openIn(web, ["repo": "b", "id": "1", "url": "http://127.0.0.1:9/"]) { ok in
|
|
2771
|
+
web.evaluateJavaScript("document.body.dataset.opened") { opened, _ in
|
|
2772
|
+
let o = (opened as? String) ?? "none"
|
|
2773
|
+
// the banners taken back once a/1 and c/5 alone still wait: b/1's, and one left by an older build
|
|
2774
|
+
let stale = staleOf([("a/1", ["a/1"]), ("b/1", ["b/1"]), ("more:c/4,c/5", ["c/4", "c/5"]), ("F09E-0F96", ["F09E-0F96"])], waiting: ["a/1", "c/5"])
|
|
2775
|
+
print("badge-two=\(two)")
|
|
2776
|
+
print("few=\(few.joined(separator: ","))")
|
|
2777
|
+
print("burst=\(many.joined(separator: ","))")
|
|
2778
|
+
print("badge-zero=\(zero)")
|
|
2779
|
+
print("badge-project=\(project) quiet=\(quiet)")
|
|
2780
|
+
print("click-opened=\(ok ? o : "fallback")")
|
|
2781
|
+
print("stale=\(stale.joined(separator: ","))")
|
|
2782
|
+
finish(two == "2" && few == ["a/1:t1@a/1", "b/1:t1@b/1", "d/1:t1@d/1"] && many == ["c/1:t1@c/1", "c/2:t2@c/2", "c/3:t3@c/3", "more:2:http://127.0.0.1:9/inbox@more:c/4,c/5"] && zero == "none" && project == "1" && quiet && ok && o == "b/1" && stale == ["b/1", "F09E-0F96"] ? 0 : 1)
|
|
2783
|
+
}
|
|
862
2784
|
}
|
|
863
2785
|
}
|
|
864
2786
|
}
|
|
@@ -866,13 +2788,14 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
866
2788
|
}
|
|
867
2789
|
}
|
|
868
2790
|
}
|
|
869
|
-
web.loadHTMLString("<body><script>window.shipkitApp = {
|
|
2791
|
+
web.loadHTMLString("<body><script>window.shipkitApp = { openThread: (r, i) => { document.body.dataset.opened = r + '/' + i }, openInbox: () => { document.body.dataset.opened = 'inbox' } }</script><p>badge</p></body>", baseURL: nil)
|
|
870
2792
|
}
|
|
871
2793
|
|
|
872
|
-
// window.open and target=_blank: one more window of this app for its own pages
|
|
2794
|
+
// window.open and target=_blank: one more window of this app for its own pages, the default browser for the rest
|
|
873
2795
|
func webView(_ web: WKWebView, createWebViewWith config: WKWebViewConfiguration, for action: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
|
|
874
2796
|
if let url = action.request.url {
|
|
875
|
-
|
|
2797
|
+
// a script's window.open comes here with no policy asked first: a project app sends it down its road too
|
|
2798
|
+
if tabbed { asksWindow(url, from: web) } else if leaves(url) { openOutside(url) } else { open(url) }
|
|
876
2799
|
}
|
|
877
2800
|
return nil
|
|
878
2801
|
}
|
|
@@ -901,14 +2824,9 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
901
2824
|
alert.accessoryView = field
|
|
902
2825
|
alert.window.initialFirstResponder = field
|
|
903
2826
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
alert.beginSheetModal(for: win) { r in done(r == .alertFirstButtonReturn) }
|
|
909
|
-
// first responder selects the whole default text, so typing replaces it
|
|
910
|
-
if let field { alert.window.makeFirstResponder(field) }
|
|
911
|
-
onPanel?(alert)
|
|
2827
|
+
present(alert, on: web.window) { done($0 == .alertFirstButtonReturn) }
|
|
2828
|
+
// on a sheet, first responder selects the whole default text, so typing replaces it
|
|
2829
|
+
if let field, web.window != nil { alert.window.makeFirstResponder(field) }
|
|
912
2830
|
}
|
|
913
2831
|
|
|
914
2832
|
func webView(_ web: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
|
|
@@ -942,9 +2860,19 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
942
2860
|
let fileItem = NSMenuItem()
|
|
943
2861
|
main.addItem(fileItem)
|
|
944
2862
|
let file = NSMenu(title: "File")
|
|
945
|
-
|
|
2863
|
+
// command with t, a project app's: the entry the hub shows in a tab of its own. Command with n: the new thread
|
|
2864
|
+
// popup in an app of the hub's pages, one more window in a process's; an app of the hub's pages has its new window
|
|
2865
|
+
// on shift, a project's a window of its own on the hub
|
|
2866
|
+
if tabbed { file.addItem(withTitle: "New Tab", action: #selector(entryTab(_:)), keyEquivalent: "t") }
|
|
2867
|
+
if hubApp { file.addItem(withTitle: "New Thread", action: #selector(newThread(_:)), keyEquivalent: "n") }
|
|
2868
|
+
if tabbed {
|
|
2869
|
+
file.addItem(withTitle: "New Window", action: #selector(projectWindow(_:)), keyEquivalent: "N")
|
|
2870
|
+
item(file, "Duplicate Tab", #selector(newWindow(_:)), "", [])
|
|
2871
|
+
} else if hubApp { file.addItem(withTitle: "New Window", action: #selector(newWindow(_:)), keyEquivalent: "N") }
|
|
2872
|
+
else { file.addItem(withTitle: "New Window", action: #selector(newWindow(_:)), keyEquivalent: "n") }
|
|
946
2873
|
file.addItem(withTitle: "Reload", action: #selector(reload(_:)), keyEquivalent: "r")
|
|
947
|
-
file.addItem(withTitle: "Close Window", action: #selector(NSWindow.performClose(_:)), keyEquivalent: "w")
|
|
2874
|
+
file.addItem(withTitle: tabbed ? "Close Tab" : "Close Window", action: tabbed ? #selector(closeTab(_:)) : #selector(NSWindow.performClose(_:)), keyEquivalent: "w")
|
|
2875
|
+
if tabbed { file.addItem(withTitle: "Close Window", action: #selector(closeEveryTab(_:)), keyEquivalent: "W") }
|
|
948
2876
|
fileItem.submenu = file
|
|
949
2877
|
let editItem = NSMenuItem()
|
|
950
2878
|
main.addItem(editItem)
|
|
@@ -988,6 +2916,18 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
988
2916
|
previous.keyEquivalentModifierMask = [.command]
|
|
989
2917
|
let next = win.addItem(withTitle: "Show Next Tab", action: #selector(nextTab(_:)), keyEquivalent: String(UnicodeScalar(NSPageDownFunctionKey)!))
|
|
990
2918
|
next.keyEquivalentModifierMask = [.command]
|
|
2919
|
+
// a project app's windows by their standard words: the tab shown into a window of its own, every window back
|
|
2920
|
+
// into one. Their actions are the app's own, so the hub's tab ends first
|
|
2921
|
+
if tabbed {
|
|
2922
|
+
item(win, "Move Tab to New Window", #selector(tabToNewWindow(_:)), "", [])
|
|
2923
|
+
item(win, "Merge All Windows", #selector(mergeWindows(_:)), "", [])
|
|
2924
|
+
}
|
|
2925
|
+
// a project app's tabs by number: the items show the keys, `takes` reads them from the physical digit row
|
|
2926
|
+
let digits = tabDigits(mode)
|
|
2927
|
+
if !digits.isEmpty { win.addItem(.separator()) }
|
|
2928
|
+
for n in digits {
|
|
2929
|
+
item(win, n == 1 ? "Show the Hub" : n == 9 ? "Show the Last Tab" : "Show Tab \(n)", #selector(selectTab(_:)), String(n), tag: n)
|
|
2930
|
+
}
|
|
991
2931
|
winItem.submenu = win
|
|
992
2932
|
NSApp.windowsMenu = win
|
|
993
2933
|
NSApp.mainMenu = main
|
|
@@ -997,5 +2937,7 @@ final class Delegate: NSObject, NSApplicationDelegate, WKNavigationDelegate, WKU
|
|
|
997
2937
|
let app = NSApplication.shared
|
|
998
2938
|
let delegate = Delegate()
|
|
999
2939
|
app.delegate = delegate
|
|
1000
|
-
app
|
|
2940
|
+
// a self test is no app of the Dock and takes no focus; the window server is asked through its whole run
|
|
2941
|
+
app.setActivationPolicy(selfTesting ? .prohibited : .regular)
|
|
2942
|
+
if selfTesting { Timer.scheduledTimer(withTimeInterval: 0.05, repeats: true) { _ in seenOnScreen = max(seenOnScreen, windowsOnScreen().own) } }
|
|
1001
2943
|
app.run()
|