rvlib-shipkit 2.12.0 → 2.13.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 +48 -13
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/agent-time/store.ts +2 -2
- package/src/check.ts +1 -1
- package/src/checks/SK001-package-json-shape.check.ts +4 -0
- package/src/checks/SK003-claude-md-shape.check.ts +1 -1
- package/src/checks/SK004-gitignore-policy.check.ts +27 -2
- package/src/checks/SK005-rvlib-versions.check.ts +1 -1
- package/src/checks/SK008-reviewer-agent.check.ts +2 -2
- package/src/checks/SK012-config-barrel-import.check.ts +1 -1
- package/src/checks/SK015-nested-repo.check.ts +1 -1
- package/src/checks/SK035-public-clean.check.ts +46 -0
- package/src/checks/SK036-draft-media-size.check.ts +28 -0
- package/src/cli/cmd_Backup.ts +152 -0
- package/src/cli/cmd_Ci.ts +8 -11
- package/src/cli/cmd_Drill.ts +145 -0
- package/src/cli/cmd_Home.ts +50 -3
- package/src/cli/cmd_Media.ts +7 -5
- package/src/cli/cmd_Review.ts +4 -2
- package/src/cli/cmd_Shot.ts +5 -2
- package/src/cli/cmd_Smoke.ts +4 -1
- package/src/cli/cmd_Social.ts +226 -0
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +5 -2
- package/src/cli/cmd_Veille.ts +173 -0
- package/src/cli/family-pages.ts +3 -0
- package/src/cli/registry.ts +13 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +1 -49
- package/src/collections/checks.ts +2 -1
- package/src/collections/collection-types.ts +11 -2
- package/src/collections/providers.ts +4 -4
- package/src/collections/review.ts +2 -1
- package/src/collections/tests.ts +19 -8
- package/src/contracts/apply-contracts.ts +1 -3
- package/src/contracts/contract-manifests.ts +2 -3
- package/src/contracts/contract-types.ts +0 -1
- package/src/contracts/contracts-engine.ts +0 -3
- package/src/core/app-icon.ts +9 -3
- package/src/core/bun-builtins.ts +2 -2
- package/src/core/discover-checks.ts +37 -5
- package/src/core/fix-scope.ts +4 -2
- package/src/core/floor-resolve.ts +68 -48
- package/src/core/floor.ts +9 -0
- package/src/core/git-root.ts +24 -0
- package/src/core/last-good.ts +3 -1
- package/src/core/layout.ts +8 -0
- package/src/core/log-stamp.ts +36 -0
- package/src/core/loop-watch.ts +93 -0
- package/src/core/machine-link.ts +134 -0
- package/src/core/memory-watch.ts +41 -0
- package/src/core/one-way-in-policy.ts +27 -19
- package/src/core/run-ci.ts +6 -8
- package/src/core/run-fixers.ts +9 -9
- package/src/core/slots.ts +21 -0
- package/src/core/tree-rev.ts +60 -0
- package/src/core/unit-files.ts +42 -0
- package/src/drill/render.ts +140 -0
- package/src/drill/run.ts +269 -0
- package/src/fleet/scan-fleet.ts +6 -5
- package/src/home/daemon-jobs.ts +201 -0
- package/src/home/global-context.ts +34 -1
- package/src/home/home-routes.ts +22 -15
- package/src/home/hubs.ts +10 -3
- package/src/home/inbox-shape.ts +53 -4
- package/src/home/inbox.ts +16 -1
- package/src/home/lib-watch.ts +10 -3
- package/src/home/machine-stores.ts +15 -29
- package/src/home/run-daemon.ts +15 -18
- package/src/home/run-pm.ts +2 -0
- package/src/home/serve-daemon.ts +4 -3
- package/src/home/serve-web.ts +104 -1
- package/src/hooks/commit-message.ts +28 -19
- package/src/hooks/leak-guard.ts +10 -3
- package/src/hooks/run-hooks.ts +2 -6
- package/src/identities/identities.ts +334 -0
- package/src/identities/machine-route.ts +126 -0
- package/src/identities/machine.ts +62 -0
- package/src/init-repo.ts +1 -1
- package/src/ledger/check-stats.ts +10 -9
- package/src/ledger/gate-checks.ts +32 -1
- package/src/ledger/record-kept.ts +112 -0
- package/src/ledger/repo-view.ts +10 -0
- package/src/ledger/run-log.ts +17 -12
- package/src/ledger/run-timeline.ts +8 -4
- package/src/ledger/store.ts +7 -0
- package/src/ledger/suite-log.ts +17 -13
- package/src/media-kinds.ts +2 -1
- package/src/media-store/backup/daemon.ts +73 -0
- package/src/media-store/backup/keys.ts +25 -0
- package/src/media-store/backup/manifest.ts +193 -0
- package/src/media-store/backup/restore.ts +192 -0
- package/src/media-store/backup/run.ts +278 -0
- package/src/media-store/backup/secret.ts +86 -0
- package/src/media-store/backup/snapshot.ts +64 -0
- package/src/media-store/backup/sources.ts +199 -0
- package/src/media-store/daemon.ts +56 -70
- package/src/media-store/put.ts +4 -2
- package/src/media-store/space.ts +23 -4
- package/src/pages/forward.ts +35 -0
- package/src/pages/frame-client.ts +118 -0
- package/src/pages/routes.ts +29 -0
- package/src/pages/unit.ts +92 -0
- package/src/plan/planner.ts +12 -0
- package/src/plan/repo-source.ts +19 -5
- package/src/reflect/transcript.ts +35 -10
- package/src/release/public-clean.ts +301 -0
- package/src/release/published-here.ts +22 -0
- package/src/release/run-bump.ts +2 -1
- package/src/release/run-release.ts +4 -1
- package/src/repo-config.ts +53 -2
- package/src/review/http.ts +16 -2
- package/src/review/model.ts +15 -4
- package/src/review/notes.ts +77 -0
- package/src/review/project.ts +6 -38
- package/src/review/routes.ts +4 -12
- package/src/review/store.ts +41 -1
- package/src/review/trailer-media.ts +7 -4
- package/src/review/trailer-shots.ts +21 -4
- package/src/review/unit.ts +1 -1
- package/src/scaffold/files/agent-handoff.md +3 -0
- package/src/scaffold/files/agent-index.md +4 -12
- package/src/scaffold/project-scaffold.ts +5 -4
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +3 -17
- package/src/serve/hub-app/col-tables-view.tsx +2 -1
- package/src/serve/hub-app/cols-svc.ts +0 -13
- package/src/serve/hub-app/dock-st.ts +4 -2
- package/src/serve/hub-app/dock-view.tsx +2 -0
- package/src/serve/hub-app/frames-st.ts +35 -0
- package/src/serve/hub-app/hash-route.ts +64 -1
- package/src/serve/hub-app/home-st.ts +31 -7
- package/src/serve/hub-app/home-strip.css +9 -1
- package/src/serve/hub-app/home-strip.tsx +7 -6
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +49 -5
- package/src/serve/hub-app/hub.css +29 -11
- package/src/serve/hub-app/icons.tsx +16 -1
- package/src/serve/hub-app/identities-st.ts +210 -0
- package/src/serve/hub-app/identities-view.tsx +352 -0
- package/src/serve/hub-app/identities.css +48 -0
- package/src/serve/hub-app/identity-address.ts +52 -0
- package/src/serve/hub-app/inbox-st.ts +59 -6
- package/src/serve/hub-app/inbox-view.tsx +48 -6
- package/src/serve/hub-app/inbox.css +12 -1
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +10 -2
- package/src/serve/hub-app/list-walk.ts +89 -0
- package/src/serve/hub-app/machine-st.ts +12 -0
- package/src/serve/hub-app/media-view.tsx +2 -1
- package/src/serve/hub-app/pages-frames.tsx +134 -0
- package/src/serve/hub-app/pages-svc.ts +111 -0
- package/src/serve/hub-app/palette-st.ts +18 -3
- package/src/serve/hub-app/palette-view.tsx +9 -2
- package/src/serve/hub-app/planned-view.tsx +2 -1
- package/src/serve/hub-app/project-list.css +18 -14
- package/src/serve/hub-app/project-list.tsx +88 -49
- package/src/serve/hub-app/projects-svc.ts +33 -3
- package/src/serve/hub-app/repo-sections.ts +19 -2
- package/src/serve/hub-app/repo-st.ts +75 -19
- package/src/serve/hub-app/review/review-cells.tsx +3 -3
- package/src/serve/hub-app/review/review-kit.ts +30 -7
- package/src/serve/hub-app/review/review-page.tsx +1 -1
- package/src/serve/hub-app/review/review-st.ts +19 -8
- package/src/serve/hub-app/review/review-thread.tsx +11 -9
- package/src/serve/hub-app/review/review-views.tsx +84 -19
- package/src/serve/hub-app/review/thread-st.ts +1 -10
- package/src/serve/hub-app/review/trailer-page.tsx +2 -1
- package/src/serve/hub-app/review.css +17 -8
- package/src/serve/hub-app/site/site-part.tsx +173 -0
- package/src/serve/hub-app/site/site-st.ts +157 -0
- package/src/serve/hub-app/site.css +35 -0
- package/src/serve/hub-app/social/calendar.tsx +182 -0
- package/src/serve/hub-app/social/comms-page.tsx +306 -0
- package/src/serve/hub-app/social/kit.tsx +244 -0
- package/src/serve/hub-app/social/post-card.tsx +456 -0
- package/src/serve/hub-app/social/problems.tsx +60 -0
- package/src/serve/hub-app/social/social-model.ts +154 -0
- package/src/serve/hub-app/social/social-page.tsx +674 -0
- package/src/serve/hub-app/social/social-st.ts +986 -0
- package/src/serve/hub-app/social.css +289 -0
- package/src/serve/hub-app/stores/stores-page.tsx +311 -0
- package/src/serve/hub-app/stores/stores-st.ts +286 -0
- package/src/serve/hub-app/stores.css +54 -0
- package/src/serve/hub-app/timeline-geometry.ts +1 -1
- package/src/serve/hub-app/timeline-view.tsx +3 -2
- package/src/serve/hub-app/tree-build.ts +6 -0
- package/src/serve/hub-app/tree-row.tsx +27 -4
- package/src/serve/hub-app/tree-svc.ts +18 -49
- package/src/serve/hub-app/veille/veille-page.tsx +514 -0
- package/src/serve/hub-app/veille/veille-st.ts +443 -0
- package/src/serve/hub-app/veille.css +84 -0
- package/src/serve/hub-runtime.ts +14 -9
- package/src/serve/project-gutter-route.ts +44 -12
- package/src/serve/run-lanes.ts +7 -4
- package/src/serve/same-origin.ts +1 -1
- package/src/serve/serve-hub.ts +20 -12
- package/src/serve/tracked-watch.ts +24 -3
- package/src/serve/warm-cell.ts +5 -1
- package/src/shipkit-files.ts +15 -4
- package/src/shipkit.ts +0 -1
- package/src/shot/box.ts +162 -0
- package/src/shot/browser-slot.ts +62 -0
- package/src/shot/client.ts +43 -7
- package/src/shot/clip-encoder.ts +93 -12
- package/src/shot/film-box.ts +188 -0
- package/src/shot/shooter.ts +50 -15
- package/src/shot/shot-ask.ts +10 -2
- package/src/shot/stepped-clip.ts +5 -4
- package/src/site/desk.ts +242 -0
- package/src/site/routes.ts +66 -0
- package/src/site/unit.ts +62 -0
- package/src/social/brands.ts +22 -0
- package/src/social/compose.ts +97 -0
- package/src/social/desk-index.ts +123 -0
- package/src/social/desk-wire.ts +64 -0
- package/src/social/drafts.ts +183 -0
- package/src/social/house.ts +24 -0
- package/src/social/load.ts +319 -0
- package/src/social/md.ts +70 -0
- package/src/social/media-facts.ts +53 -0
- package/src/social/media-kind.ts +189 -0
- package/src/social/media-limit.ts +42 -0
- package/src/social/media-of.ts +30 -0
- package/src/social/migrate.ts +123 -0
- package/src/social/open.ts +17 -0
- package/src/social/post-url.ts +158 -0
- package/src/social/presence.ts +332 -0
- package/src/social/public-read.ts +53 -0
- package/src/social/publish/bluesky.ts +168 -0
- package/src/social/publish/discord.ts +76 -0
- package/src/social/publish/index.ts +24 -0
- package/src/social/publish/secret.ts +13 -0
- package/src/social/push.ts +31 -0
- package/src/social/richtext.ts +37 -0
- package/src/social/routes.ts +180 -0
- package/src/social/stats.ts +134 -0
- package/src/social/text.ts +267 -0
- package/src/social/tracker-route.ts +39 -0
- package/src/social/tracker.ts +255 -0
- package/src/social/unit.ts +53 -0
- package/src/social/writes.ts +130 -0
- package/src/start-repo.ts +14 -9
- package/src/stores/collection.ts +27 -0
- package/src/stores/desk.ts +336 -0
- package/src/stores/model.ts +187 -0
- package/src/stores/routes.ts +126 -0
- package/src/stores/unit.ts +57 -0
- package/src/suite/calibrate.ts +127 -0
- package/src/suite/core-counters.ts +91 -0
- package/src/suite/judge-suites.ts +94 -34
- package/src/suite/suite-cli.ts +44 -10
- package/src/suite/suite-cpu-preload.ts +34 -9
- package/src/trailer/adapter.ts +4 -0
- package/src/trailer/build.ts +42 -11
- package/src/trailer/ffmpeg.ts +11 -0
- package/src/trailer/footage.ts +30 -13
- package/src/trailer/grammar.ts +18 -2
- package/src/trailer/graph.ts +28 -6
- package/src/trailer/passage.ts +17 -5
- package/src/trailer/plan.ts +74 -3
- package/src/trailer/stitch.ts +67 -26
- package/src/trailer/url.ts +1 -1
- package/src/trailer/versions.ts +24 -0
- package/src/ts/gate-typecheck.ts +32 -0
- package/src/ts/typecheck-cli.ts +9 -11
- package/src/tui/tui-app.tsx +0 -1
- package/src/veille/asks.ts +155 -0
- package/src/veille/auto.ts +31 -0
- package/src/veille/batch.ts +27 -0
- package/src/veille/chrome.ts +127 -0
- package/src/veille/collection.ts +28 -0
- package/src/veille/desk.ts +242 -0
- package/src/veille/identity.ts +80 -0
- package/src/veille/import.ts +68 -0
- package/src/veille/log.ts +183 -0
- package/src/veille/platforms.ts +118 -0
- package/src/veille/reads.ts +66 -0
- package/src/veille/replied.ts +110 -0
- package/src/veille/routes.ts +185 -0
- package/src/veille/service.ts +81 -0
- package/src/veille/watch.ts +116 -0
- package/src/veille/worth.ts +46 -0
- package/src/wiki/scan-md.ts +18 -0
- package/src/collections/posts.ts +0 -142
- package/src/contracts/manifests/social.contract.ts +0 -20
- package/src/scaffold/files/agent-coding.md +0 -35
- package/src/ts/typecheck-cache.ts +0 -11
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// the address of the home's identity view (wiki build/shipkit/social.md, Identities): `/identities#<id>[/<part>[/<place>]]`,
|
|
2
|
+
// the part a section (`@legal`, `@veille`, `@site`) or an account, the place one of that account's; no part, the profile.
|
|
3
|
+
// And the rows of its list, in the order the arrows walk them
|
|
4
|
+
import type { MachineIdentity } from '../../identities/machine-route.ts'
|
|
5
|
+
|
|
6
|
+
const IDENTITIES_PATH = '/identities'
|
|
7
|
+
|
|
8
|
+
/** the sections of an identity beside its accounts; the profile is the identity alone */
|
|
9
|
+
const SECTIONS = ['@legal', '@veille', '@site'] as const
|
|
10
|
+
type Section = (typeof SECTIONS)[number]
|
|
11
|
+
const LEGAL_PART: Section = '@legal'
|
|
12
|
+
|
|
13
|
+
export type IdentitySel = { id: string | null; part: string | null; place: string | null }
|
|
14
|
+
|
|
15
|
+
export const isSection = (part: string | null): part is Section => SECTIONS.includes(part as Section)
|
|
16
|
+
|
|
17
|
+
/** the hash of a pick, empty for the view with nothing picked */
|
|
18
|
+
export function identityHash(s: IdentitySel): string {
|
|
19
|
+
if (s.id == null) return ''
|
|
20
|
+
const parts = [s.id, ...(s.part == null ? [] : [s.part]), ...(s.part != null && !isSection(s.part) && s.place != null ? [s.place] : [])]
|
|
21
|
+
return `#${parts.join('/')}`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** a hash read back; a word the view does not know is left to the view, which shows it is gone */
|
|
25
|
+
export function parseIdentityHash(hash: string): IdentitySel {
|
|
26
|
+
const [id = '', part = '', place = ''] = hash.replace(/^#/, '').split('/').map((x) => decodeURIComponent(x))
|
|
27
|
+
return { id: id === '' ? null : id, part: id === '' || part === '' ? null : part, place: part === '' || place === '' || isSection(part) ? null : place }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const identityAddress = (s: IdentitySel): string => `${IDENTITIES_PATH}${identityHash(s)}`
|
|
31
|
+
|
|
32
|
+
/** a row of the view's list, in the order the arrows walk it (list-walk.ts): the sections, each account, each repo.
|
|
33
|
+
* A row opens its part in place, a repo row leaves for that repo's Social page */
|
|
34
|
+
export type IdentityRow = { key: string; depth: 0; dir: false; block: 'sections' | 'accounts' | 'repos'; part: string | null; repo: string | null; words: string }
|
|
35
|
+
|
|
36
|
+
type Listed = Pick<MachineIdentity, 'site' | 'repos'> & { accounts: readonly Pick<MachineIdentity['accounts'][number], 'id' | 'name' | 'handle'>[] }
|
|
37
|
+
|
|
38
|
+
/** every row of an identity, the company only when it has one; `q` keeps the rows whose words hold it, as the repo
|
|
39
|
+
* tree's filter does */
|
|
40
|
+
export function identityRows(i: Listed, company: boolean, q = ''): IdentityRow[] {
|
|
41
|
+
const row = (block: IdentityRow['block'], key: string, part: string | null, repo: string | null, words: string): IdentityRow => ({ key, depth: 0, dir: false, block, part, repo, words: words.toLowerCase() })
|
|
42
|
+
const all = [
|
|
43
|
+
row('sections', 's:profile', null, null, 'profile'),
|
|
44
|
+
...(company ? [row('sections', `s:${LEGAL_PART}`, LEGAL_PART, null, 'company legal')] : []),
|
|
45
|
+
row('sections', 's:@veille', '@veille', null, 'veille'),
|
|
46
|
+
row('sections', 's:@site', '@site', null, `site ${i.site}`),
|
|
47
|
+
...i.accounts.map((a) => row('accounts', `a:${a.id}`, a.id, null, `${a.id} ${a.name} ${a.handle}`)),
|
|
48
|
+
...i.repos.map((r) => row('repos', `r:${r}`, null, r, r)),
|
|
49
|
+
]
|
|
50
|
+
const k = q.trim().toLowerCase()
|
|
51
|
+
return k === '' ? all : all.filter((r) => r.words.includes(k))
|
|
52
|
+
}
|
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
// the one constraint a reader breaks first: the address and the open item move together, through HomeSt.show; `open`
|
|
7
7
|
// only says which item the address names
|
|
8
8
|
import { makeAutoObservable, observableRef, runInAction } from 'mobx'
|
|
9
|
-
import { INBOX_PAGE, openOf, type InboxAnswer, type InboxRow } from '../../home/inbox-shape.ts'
|
|
10
|
-
import { etagLoader } from './review/review-kit.ts'
|
|
9
|
+
import { groupRows, INBOX_GROUPS, INBOX_PAGE, openOf, type InboxAnswer, type InboxGroup, type InboxGroupNode, type InboxRow, type InboxShow } from '../../home/inbox-shape.ts'
|
|
10
|
+
import { etagLoader, kept, type EtagLoader } from './review/review-kit.ts'
|
|
11
11
|
import { ownTrouble } from './reach.ts'
|
|
12
12
|
import { ClockSvc } from './clock-svc.ts'
|
|
13
13
|
import type { HomeSt } from './home-st.ts'
|
|
14
14
|
|
|
15
15
|
const POLL_MS = 4000
|
|
16
|
+
const PREFS = 'shipkit.inbox.prefs'
|
|
16
17
|
|
|
17
18
|
/** below this width the inbox is the phone's: one pane at a time, the list or the item */
|
|
18
19
|
export const INBOX_PHONE_PX = 768
|
|
@@ -23,6 +24,10 @@ export class InboxSt {
|
|
|
23
24
|
error = ''
|
|
24
25
|
/** the rows asked of the main list: a page more on « more » */
|
|
25
26
|
shown = INBOX_PAGE
|
|
27
|
+
/** the review cards only, or every kind */
|
|
28
|
+
show: InboxShow = 'cards'
|
|
29
|
+
/** what the rows group by, each on its own */
|
|
30
|
+
groupBy: InboxGroup[] = []
|
|
26
31
|
/** the folded list unfolded: read while it is */
|
|
27
32
|
yellowOpen = false
|
|
28
33
|
/** the item the address names */
|
|
@@ -32,15 +37,25 @@ export class InboxSt {
|
|
|
32
37
|
/** every row's age reads it, ticking while the page shows */
|
|
33
38
|
readonly clock = new ClockSvc()
|
|
34
39
|
private timer: ReturnType<typeof setInterval> | null = null
|
|
35
|
-
private readonly loadMain:
|
|
36
|
-
private readonly loadYellow:
|
|
40
|
+
private readonly loadMain: EtagLoader<InboxAnswer>
|
|
41
|
+
private readonly loadYellow: EtagLoader<InboxAnswer>
|
|
37
42
|
private readonly onVisible = (): void => {
|
|
38
43
|
if (document.visibilityState === 'visible' && this.timer != null) void this.poll()
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
constructor(private readonly home: HomeSt) {
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
try {
|
|
48
|
+
const p = JSON.parse(kept.get(PREFS) ?? '{}') as { show?: string; groupBy?: string[] }
|
|
49
|
+
if (p.show === 'all') this.show = 'all'
|
|
50
|
+
this.groupBy = INBOX_GROUPS.filter((g) => p.groupBy?.includes(g))
|
|
51
|
+
} catch {
|
|
52
|
+
// a broken pref is the default
|
|
53
|
+
}
|
|
54
|
+
// the last lists drawn in the first frame: the daemon answers after, and only what moved draws again
|
|
55
|
+
this.loadMain = etagLoader(() => `/api/inbox?show=${this.show}&limit=${this.shown}`, { keep: 'inbox.main' })
|
|
56
|
+
this.loadYellow = etagLoader(() => `/api/inbox?show=${this.show}&list=yellow&limit=500`, { keep: 'inbox.yellow' })
|
|
57
|
+
this.page = this.loadMain.held()
|
|
58
|
+
this.yellowPage = this.loadYellow.held()
|
|
44
59
|
makeAutoObservable<this, 'home' | 'timer' | 'loadMain' | 'loadYellow' | 'onVisible'>(this, { home: false, timer: false, loadMain: false, loadYellow: false, onVisible: false, clock: false, page: observableRef, yellowPage: observableRef })
|
|
45
60
|
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
|
|
46
61
|
const mq = window.matchMedia(`(max-width: ${INBOX_PHONE_PX - 1}px)`)
|
|
@@ -57,6 +72,24 @@ export class InboxSt {
|
|
|
57
72
|
return this.yellowPage?.rows ?? []
|
|
58
73
|
}
|
|
59
74
|
|
|
75
|
+
/** the main list as it draws: one group of every row, or nested by what is on */
|
|
76
|
+
get groups(): InboxGroupNode[] {
|
|
77
|
+
return groupRows(this.rows, this.groupBy)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get yellowGroups(): InboxGroupNode[] {
|
|
81
|
+
return groupRows(this.yellowRows, this.groupBy)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** what « all » would show beside the cards, both lists */
|
|
85
|
+
get allCount(): number {
|
|
86
|
+
return (this.page?.all?.main ?? 0) + (this.page?.all?.yellow ?? 0)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get cardCount(): number {
|
|
90
|
+
return this.show === 'cards' ? this.count + this.yellowCount : 0
|
|
91
|
+
}
|
|
92
|
+
|
|
60
93
|
get count(): number {
|
|
61
94
|
return this.page?.counts.main ?? 0
|
|
62
95
|
}
|
|
@@ -120,6 +153,26 @@ export class InboxSt {
|
|
|
120
153
|
])
|
|
121
154
|
}
|
|
122
155
|
|
|
156
|
+
setShow(s: InboxShow): void {
|
|
157
|
+
if (this.show === s) return
|
|
158
|
+
this.show = s
|
|
159
|
+
this.shown = INBOX_PAGE
|
|
160
|
+
// the kept answer of the other mode, if any, draws at once
|
|
161
|
+
this.page = this.loadMain.held()
|
|
162
|
+
this.yellowPage = this.loadYellow.held()
|
|
163
|
+
this.save()
|
|
164
|
+
void this.poll()
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
toggleGroup(g: InboxGroup): void {
|
|
168
|
+
this.groupBy = this.groupBy.includes(g) ? this.groupBy.filter((x) => x !== g) : INBOX_GROUPS.filter((x) => x === g || this.groupBy.includes(x))
|
|
169
|
+
this.save()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private save(): void {
|
|
173
|
+
kept.put(PREFS, JSON.stringify({ show: this.show, groupBy: this.groupBy }))
|
|
174
|
+
}
|
|
175
|
+
|
|
123
176
|
showMore(): void {
|
|
124
177
|
if (this.more === 0) return
|
|
125
178
|
this.shown += INBOX_PAGE
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
// the list kept under the item so back finds it where it was
|
|
6
6
|
import { observer } from 'mobx-react-lite'
|
|
7
7
|
import { useLayoutEffect } from 'react'
|
|
8
|
-
import { isReviewId, type InboxRow } from '../../home/inbox-shape.ts'
|
|
8
|
+
import { INBOX_GROUPS, isReviewId, type InboxGroup, type InboxGroupNode, type InboxRow } from '../../home/inbox-shape.ts'
|
|
9
9
|
import { hashFor } from './hash-route.ts'
|
|
10
10
|
import { plainClick, repoPage, type HomeSt } from './home-st.ts'
|
|
11
|
-
import { Icon, ICON } from './icons.tsx'
|
|
11
|
+
import { Caret, Icon, ICON } from './icons.tsx'
|
|
12
12
|
import type { InboxSt } from './inbox-st.ts'
|
|
13
13
|
import { ItemView } from './item-view.tsx'
|
|
14
14
|
import { Face } from './project-list.tsx'
|
|
@@ -36,6 +36,7 @@ export const InboxView = observer(({ app }: { app: HomeSt }) => {
|
|
|
36
36
|
<h1>inbox</h1>
|
|
37
37
|
<Counts ib={ib} />
|
|
38
38
|
</div>
|
|
39
|
+
<Bar ib={ib} />
|
|
39
40
|
<InboxList app={app} />
|
|
40
41
|
</div>
|
|
41
42
|
{open != null ? <OpenItem app={app} item={open} /> : null}
|
|
@@ -48,6 +49,7 @@ export const InboxView = observer(({ app }: { app: HomeSt }) => {
|
|
|
48
49
|
<h1>inbox</h1>
|
|
49
50
|
<Counts ib={ib} />
|
|
50
51
|
</div>
|
|
52
|
+
<Bar ib={ib} />
|
|
51
53
|
<InboxList app={app} />
|
|
52
54
|
</div>
|
|
53
55
|
<div className="ib-itemcol">{open != null ? <OpenItem app={app} item={open} /> : <div className="ph">{ib.count > 0 ? 'pick a row: it opens here' : ''}</div>}</div>
|
|
@@ -64,6 +66,46 @@ const Counts = observer(({ ib }: { ib: InboxSt }) =>
|
|
|
64
66
|
),
|
|
65
67
|
)
|
|
66
68
|
|
|
69
|
+
const GROUP_WORDS: Record<InboxGroup, string> = { repo: 'project', kind: 'type', lane: 'lane' }
|
|
70
|
+
|
|
71
|
+
/** what the list shows (the review cards, or every kind) and what it groups by, each axis on its own */
|
|
72
|
+
const Bar = observer(({ ib }: { ib: InboxSt }) => (
|
|
73
|
+
<div className="ib-bar">
|
|
74
|
+
<span className="seg" title="the review cards only, or every kind: checks, asks and needs too">
|
|
75
|
+
<button className={ib.show === 'cards' ? 'on' : ''} onClick={() => ib.setShow('cards')}>cards</button>
|
|
76
|
+
<button className={ib.show === 'all' ? 'on' : ''} onClick={() => ib.setShow('all')}>all{ib.show === 'cards' && ib.allCount > ib.cardCount ? <span className="ib-dim"> · {ib.allCount}</span> : null}</button>
|
|
77
|
+
</span>
|
|
78
|
+
<span className="sp" />
|
|
79
|
+
<span className="ib-groupby">
|
|
80
|
+
<span className="ib-dim">group by</span>
|
|
81
|
+
<span className="seg">
|
|
82
|
+
{INBOX_GROUPS.map((g) => (
|
|
83
|
+
<button key={g} className={ib.groupBy.includes(g) ? 'on' : ''} aria-pressed={ib.groupBy.includes(g)} onClick={() => ib.toggleGroup(g)}>{GROUP_WORDS[g]}</button>
|
|
84
|
+
))}
|
|
85
|
+
</span>
|
|
86
|
+
</span>
|
|
87
|
+
</div>
|
|
88
|
+
))
|
|
89
|
+
|
|
90
|
+
/** the rows as their groups nest: a group's head says what it is and how many, then its rows or its inner groups */
|
|
91
|
+
const Groups = observer(({ app, gs, depth = 0 }: { app: HomeSt; gs: InboxGroupNode[]; depth?: number }) => (
|
|
92
|
+
<>
|
|
93
|
+
{gs.map((g) =>
|
|
94
|
+
g.label === '' ? (
|
|
95
|
+
g.rows.map((r) => <Row key={r.key} app={app} r={r} />)
|
|
96
|
+
) : (
|
|
97
|
+
<section key={g.key} className={`ib-group d${depth}`}>
|
|
98
|
+
<div className="ib-grouphead">
|
|
99
|
+
<span className="ib-glabel">{g.label}</span>
|
|
100
|
+
<span className="ib-gn">{g.n}</span>
|
|
101
|
+
</div>
|
|
102
|
+
{g.groups != null ? <Groups app={app} gs={g.groups} depth={depth + 1} /> : g.rows.map((r) => <Row key={r.key} app={app} r={r} />)}
|
|
103
|
+
</section>
|
|
104
|
+
),
|
|
105
|
+
)}
|
|
106
|
+
</>
|
|
107
|
+
))
|
|
108
|
+
|
|
67
109
|
const InboxList = observer(({ app }: { app: HomeSt }) => {
|
|
68
110
|
const ib = app.inbox
|
|
69
111
|
const p = ib.page
|
|
@@ -73,19 +115,19 @@ const InboxList = observer(({ app }: { app: HomeSt }) => {
|
|
|
73
115
|
{p == null ? (
|
|
74
116
|
ib.error === '' ? <div className="ib-wait"><span className="spin" />reading every repo…</div> : null
|
|
75
117
|
) : ib.rows.length === 0 ? (
|
|
76
|
-
<div className="ib-clear">nothing waits on you
|
|
118
|
+
<div className="ib-clear">{ib.show === 'cards' ? 'no card waits on you ✨' : 'nothing waits on you ✨'}</div>
|
|
77
119
|
) : (
|
|
78
|
-
|
|
120
|
+
<Groups app={app} gs={ib.groups} />
|
|
79
121
|
)}
|
|
80
122
|
{ib.more > 0 ? <button className="ib-more" onClick={() => ib.showMore()}>{ib.more} more</button> : null}
|
|
81
123
|
{ib.yellowCount > 0 ? (
|
|
82
124
|
<div className={`ib-fold${ib.yellowOpen ? ' on' : ''}`}>
|
|
83
125
|
<button className="ib-foldhead" aria-expanded={ib.yellowOpen} onClick={() => ib.toggleYellow()}>
|
|
84
|
-
<span className="ib-caret"
|
|
126
|
+
<span className="ib-caret"><Caret open={ib.yellowOpen} /></span>
|
|
85
127
|
<span>can wait</span>
|
|
86
128
|
<span className="ib-n">{ib.yellowCount}</span>
|
|
87
129
|
</button>
|
|
88
|
-
{ib.yellowOpen ?
|
|
130
|
+
{ib.yellowOpen ? <Groups app={app} gs={ib.yellowGroups} /> : null}
|
|
89
131
|
</div>
|
|
90
132
|
) : null}
|
|
91
133
|
{p != null && p.missing.length > 0 ? (
|
|
@@ -39,13 +39,24 @@ a.ib-row.t-yellow{border-left-color:var(--warn)}
|
|
|
39
39
|
.ib-l2 .ago{flex:none;margin-left:auto}
|
|
40
40
|
.ib-thumb{flex:none;width:64px;height:48px;object-fit:cover;border-radius:4px;border:1px solid var(--line);background:var(--panel2)}
|
|
41
41
|
|
|
42
|
+
/* what the list shows and groups by, under the title */
|
|
43
|
+
.ib-bar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--s2);padding:0 var(--s4) var(--s2)}
|
|
44
|
+
.ib-bar .sp{flex:1}
|
|
45
|
+
.ib-bar .seg button{font-size:12px;padding:0 var(--s2);line-height:22px}
|
|
46
|
+
.ib-groupby{display:flex;align-items:center;gap:var(--s2);font-size:12px}
|
|
47
|
+
/* a group: its head, then its rows; an inner group steps in */
|
|
48
|
+
.ib-grouphead{display:flex;align-items:baseline;gap:var(--s2);padding:var(--s3) var(--s4) var(--s1);font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--dim);border-top:1px solid var(--line)}
|
|
49
|
+
.ib-group .ib-group > .ib-grouphead{margin-left:var(--s4);padding-top:var(--s2);border-top:0;font-size:10.5px}
|
|
50
|
+
.ib-glabel{text-transform:none;letter-spacing:0;font-size:12.5px;color:var(--ink)}
|
|
51
|
+
.ib-gn{font-variant-numeric:tabular-nums}
|
|
52
|
+
|
|
42
53
|
/* the folded list and the repos it could not read */
|
|
43
54
|
button.ib-more{margin:var(--s3) var(--s4) 0;min-height:44px;font-size:14px}
|
|
44
55
|
.ib-fold{margin-top:var(--s4);border-top:1px solid var(--line)}
|
|
45
56
|
button.ib-foldhead{display:flex;align-items:center;gap:var(--s2);width:100%;min-height:48px;padding:0 var(--s4);border:0;border-radius:0;
|
|
46
57
|
background:transparent;color:var(--dim);font-size:14px;text-align:left}
|
|
47
58
|
button.ib-foldhead:hover{color:var(--ink)}
|
|
48
|
-
.ib-caret{width:
|
|
59
|
+
.ib-caret{display:inline-flex;width:14px}
|
|
49
60
|
.ib-n{color:var(--warn);font-weight:700}
|
|
50
61
|
.ib-fold.on a.ib-row{opacity:.85}
|
|
51
62
|
.ib-missing{padding:var(--s3) var(--s4);color:var(--dim);font-size:12.5px;display:flex;flex-direction:column;gap:var(--s1)}
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
<link rel="stylesheet" href="./dock.css" />
|
|
16
16
|
<link rel="stylesheet" href="./controls.css" />
|
|
17
17
|
<link rel="stylesheet" href="./review.css" />
|
|
18
|
+
<link rel="stylesheet" href="./stores.css" />
|
|
19
|
+
<link rel="stylesheet" href="./veille.css" />
|
|
20
|
+
<link rel="stylesheet" href="./social.css" />
|
|
18
21
|
</head>
|
|
19
22
|
<body>
|
|
20
23
|
<div id="root"></div>
|
|
@@ -59,8 +59,8 @@ export function isSearchKey(e: Pick<KeyLike, 'key' | 'metaKey' | 'ctrlKey' | 'al
|
|
|
59
59
|
* plus a letter only types a character inside a text field, where the page
|
|
60
60
|
* leaves the key alone. Read from the physical key (`code`): on a Mac ⌥C
|
|
61
61
|
* types ç, and AZERTY moves the letters */
|
|
62
|
-
export type SectionId = 'readme' | 'contracts' | 'shipkit' | 'repo' | 'secrets' | 'when' | 'runs' | 'plan' | 'processes' | 'git' | 'asks' | 'review' | 'reflections' | 'tests' | 'media' | 'trailer' | 'wikis' | 'admin'
|
|
63
|
-
export const SECTION_LETTER: Record<SectionId, string> = { readme: 'E', review: 'V', trailer: 'L', contracts: 'K', shipkit: 'S', repo: 'C', secrets: 'X', when: 'O', runs: 'R', plan: 'N', processes: 'P', git: 'G', asks: 'A', reflections: 'F', tests: 'T', media: 'M', wikis: 'W', admin: 'D' }
|
|
62
|
+
export type SectionId = 'readme' | 'contracts' | 'shipkit' | 'repo' | 'secrets' | 'when' | 'runs' | 'plan' | 'processes' | 'git' | 'asks' | 'review' | 'reflections' | 'tests' | 'media' | 'trailer' | 'stores' | 'veille' | 'comms' | 'social' | 'wikis' | 'admin'
|
|
63
|
+
export const SECTION_LETTER: Record<SectionId, string> = { readme: 'E', review: 'V', trailer: 'L', stores: 'B', veille: 'Y', comms: 'U', social: 'I', contracts: 'K', shipkit: 'S', repo: 'C', secrets: 'X', when: 'O', runs: 'R', plan: 'N', processes: 'P', git: 'G', asks: 'A', reflections: 'F', tests: 'T', media: 'M', wikis: 'W', admin: 'D' }
|
|
64
64
|
/** a section's words on its row, where the id alone would not say it */
|
|
65
65
|
export const SECTION_LABEL: Partial<Record<SectionId, string>> = { shipkit: 'shipkit checks', repo: 'repo checks' }
|
|
66
66
|
export const sectionLabel = (id: SectionId): string => SECTION_LABEL[id] ?? id
|
|
@@ -74,3 +74,11 @@ export function sectionKey(e: KeyLike): SectionId | null {
|
|
|
74
74
|
const hit = Object.entries(SECTION_LETTER).find(([, l]) => l === m[1])
|
|
75
75
|
return hit == null ? null : (hit[0] as SectionId)
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
/** a repo's own page on ⌥⇧ and its letter (wiki build/shipkit/project-pages.md, Keys): shipkit's ⌥ letters stay its
|
|
79
|
+
* own. The letter, read from the physical key, or null */
|
|
80
|
+
export function pageLetterKey(e: KeyLike): string | null {
|
|
81
|
+
if (!e.altKey || !e.shiftKey || e.metaKey || e.ctrlKey) return null
|
|
82
|
+
return /^Key([A-Z])$/.exec(e.code)?.[1] ?? null
|
|
83
|
+
}
|
|
84
|
+
export const pageKeyLabel = (letter: string): string => `⌥⇧${letter}`
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// the arrows over a list of rows: the one keyboard model of the hub's lists, the repo tree (tree-svc.ts) and the
|
|
2
|
+
// identity view (identities-st.ts). ↑ ↓ land on the row above or below, stepping over inert ones; → unfolds a folded
|
|
3
|
+
// row, else steps down; ← folds an unfolded row, else climbs to its parent; Enter and space open the row. What landing
|
|
4
|
+
// and opening do is the host's
|
|
5
|
+
export type WalkRow = { key: string; depth: number; dir: boolean }
|
|
6
|
+
|
|
7
|
+
export type WalkHost<R extends WalkRow> = {
|
|
8
|
+
readonly rows: readonly R[]
|
|
9
|
+
/** the row under the keyboard cursor */
|
|
10
|
+
cursor: string | null
|
|
11
|
+
/** where the arrows start with no cursor: the row of the page shown, -1 for none */
|
|
12
|
+
home(rows: readonly R[]): number
|
|
13
|
+
/** a row the arrows step over */
|
|
14
|
+
inert(row: R): boolean
|
|
15
|
+
/** an arrow landed on it */
|
|
16
|
+
land(row: R): void
|
|
17
|
+
/** Enter or space on it */
|
|
18
|
+
activate(row: R): void
|
|
19
|
+
isOpen(key: string): boolean
|
|
20
|
+
toggle(key: string): void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function from<R extends WalkRow>(h: WalkHost<R>): number {
|
|
24
|
+
const rows = h.rows
|
|
25
|
+
const i = rows.findIndex((r) => r.key === h.cursor)
|
|
26
|
+
return i !== -1 ? i : h.home(rows)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function move<R extends WalkRow>(h: WalkHost<R>, d: number): void {
|
|
30
|
+
const rows = h.rows
|
|
31
|
+
if (rows.length === 0) return
|
|
32
|
+
const i = from(h)
|
|
33
|
+
let next = i === -1 ? (d > 0 ? 0 : rows.length - 1) : i + d
|
|
34
|
+
while (next >= 0 && next < rows.length && h.inert(rows[next]!)) next += d
|
|
35
|
+
if (next < 0 || next >= rows.length || next === i) return
|
|
36
|
+
h.land(rows[next]!)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cur = <R extends WalkRow>(h: WalkHost<R>): R | null => h.rows.find((r) => r.key === h.cursor) ?? null
|
|
40
|
+
|
|
41
|
+
function right<R extends WalkRow>(h: WalkHost<R>): void {
|
|
42
|
+
const r = cur(h)
|
|
43
|
+
if (r != null && r.dir && !h.isOpen(r.key)) h.toggle(r.key)
|
|
44
|
+
else move(h, 1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function left<R extends WalkRow>(h: WalkHost<R>): void {
|
|
48
|
+
const r = cur(h)
|
|
49
|
+
if (r == null) return move(h, -1)
|
|
50
|
+
if (r.dir && h.isOpen(r.key)) return h.toggle(r.key)
|
|
51
|
+
const rows = h.rows
|
|
52
|
+
const i = rows.findIndex((x) => x.key === r.key)
|
|
53
|
+
for (let n = i - 1; n >= 0; n--) if (rows[n]!.depth < r.depth) return h.land(rows[n]!)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** one key on the list; true = it was the list's, so the page must not also scroll */
|
|
57
|
+
export function walkKey<R extends WalkRow>(h: WalkHost<R>, k: string): boolean {
|
|
58
|
+
if (k === 'ArrowDown') move(h, 1)
|
|
59
|
+
else if (k === 'ArrowUp') move(h, -1)
|
|
60
|
+
else if (k === 'ArrowRight') right(h)
|
|
61
|
+
else if (k === 'ArrowLeft') left(h)
|
|
62
|
+
else if (k === 'Enter' || k === ' ') {
|
|
63
|
+
const r = cur(h)
|
|
64
|
+
if (r != null) h.activate(r)
|
|
65
|
+
} else return false
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** a walk with the arrows is one history entry: its first step pushes, every next one rewrites it, so back returns to
|
|
70
|
+
* where the walk started. A held arrow opens ~30 pages a second, and the browser throws past 100 pushState calls per
|
|
71
|
+
* 10 seconds */
|
|
72
|
+
export class WalkEntry {
|
|
73
|
+
private walking = false
|
|
74
|
+
private walked = false
|
|
75
|
+
run(open: () => void): void {
|
|
76
|
+
this.walking = true
|
|
77
|
+
try {
|
|
78
|
+
open()
|
|
79
|
+
} finally {
|
|
80
|
+
this.walking = false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** the history verb of a new address, asked once per address written */
|
|
84
|
+
how(): 'push' | 'replace' {
|
|
85
|
+
const h = this.walking && this.walked ? 'replace' : 'push'
|
|
86
|
+
this.walked = this.walking
|
|
87
|
+
return h
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -44,6 +44,10 @@ function loadKept(): Kept | null {
|
|
|
44
44
|
export const webDownText = (why: string): string =>
|
|
45
45
|
`the shipkit web does not answer on ${globalThis.location?.origin ?? 'this page\'s origin'} (${why}). \`shipkit pm\` runs it; this page comes back by itself once it answers`
|
|
46
46
|
|
|
47
|
+
/** the daemon restarting, as the machine card says it: the page keeps working on the web's copies */
|
|
48
|
+
export const restartingText = (at: number): string =>
|
|
49
|
+
`the daemon restarts: the page shows the last answers it gave${Number.isFinite(at) && at > 0 ? `, from ${new Date(at).toLocaleTimeString()}` : ''}, and comes back by itself`
|
|
50
|
+
|
|
47
51
|
export type MachineOpts = { reload?: () => void; timeoutMs?: number }
|
|
48
52
|
|
|
49
53
|
export class MachineSt {
|
|
@@ -62,6 +66,8 @@ export class MachineSt {
|
|
|
62
66
|
* shipkit app window */
|
|
63
67
|
/** why the daemon did not answer the last poll, or '' while it does */
|
|
64
68
|
down = ''
|
|
69
|
+
/** the daemon restarts: the web answered the last answers it kept (serve-web.ts LastGood), '' while it answers */
|
|
70
|
+
restarting = ''
|
|
65
71
|
/** which one did not answer: the web itself, or the daemon behind it */
|
|
66
72
|
downWho: 'web' | 'daemon' = 'daemon'
|
|
67
73
|
/** the daemon answered once since the load: until then data, pm and
|
|
@@ -191,6 +197,12 @@ export class MachineSt {
|
|
|
191
197
|
const r = await reach('/api/home.json', { signal: AbortSignal.timeout(this.o.timeoutMs ?? MACHINE_TIMEOUT_MS) })
|
|
192
198
|
if (!r.ok) throw new Error(`/api/home.json answered ${r.status}: ${await r.text()}`)
|
|
193
199
|
const j = (await r.json()) as HomeAnswer
|
|
200
|
+
const stale = r.headers.get('x-shipkit-daemon') === 'restarting'
|
|
201
|
+
runInAction(() => {
|
|
202
|
+
this.restarting = stale ? restartingText(Number(r.headers.get('x-shipkit-daemon-at'))) : ''
|
|
203
|
+
if (stale) this.down = ''
|
|
204
|
+
})
|
|
205
|
+
if (stale) return
|
|
194
206
|
const back = this.wasDown
|
|
195
207
|
const cleared = this.pollError
|
|
196
208
|
this.wasDown = false
|
|
@@ -10,6 +10,7 @@ import { AutoText } from './auto-text.tsx'
|
|
|
10
10
|
import { isAud, type MediaSvc } from './media-svc.ts'
|
|
11
11
|
import { GeometryLayer, Rectbar, measureBox, type Box } from './geometry-view.tsx'
|
|
12
12
|
import type { CatRow, CustomPanelRef } from './hub-types.ts'
|
|
13
|
+
import { Caret } from './icons.tsx'
|
|
13
14
|
|
|
14
15
|
const TEX = 1024
|
|
15
16
|
const MIX_UNIT = 24
|
|
@@ -26,7 +27,7 @@ export const MediaTopbar = observer(({ app }: { app: RepoSt }) => {
|
|
|
26
27
|
folded (default) = one ellipsized line, click to expand */}
|
|
27
28
|
<div className="promptrow">
|
|
28
29
|
<button className="fold" title={m.promptOpen ? 'fold the prompt' : 'expand the prompt'}
|
|
29
|
-
onClick={() => m.togglePrompt()}
|
|
30
|
+
onClick={() => m.togglePrompt()}><Caret open={m.promptOpen} /></button>
|
|
30
31
|
{m.promptOpen
|
|
31
32
|
// it grows on every prompt change, a selection's included; the css max-height caps it near 14 lines
|
|
32
33
|
? <AutoText className="prompt" value={m.prompt} placeholder="select an asset ←" onText={(t) => m.setPrompt(t)} />
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// the hub side of a repo page's frame (wiki build/shipkit/project-pages.md, The frame contract): every kept frame of
|
|
2
|
+
// this repo, the shown one displayed, the others hidden but alive (frames-st.ts). A frame loads through the hub's
|
|
3
|
+
// proxy, on this origin, and speaks `{ shipkit: <verb> }` messages, checked by source and origin. Its process down,
|
|
4
|
+
// the pane shows the start button, never a blank frame
|
|
5
|
+
import { reaction } from 'mobx'
|
|
6
|
+
import { observer } from 'mobx-react-lite'
|
|
7
|
+
import { useEffect, useRef, useState } from 'react'
|
|
8
|
+
import type { RepoSt } from './repo-st.ts'
|
|
9
|
+
|
|
10
|
+
type Msg = { shipkit?: unknown; keys?: unknown; title?: unknown; badge?: unknown; hash?: unknown; key?: unknown; code?: unknown; altKey?: unknown; shiftKey?: unknown; metaKey?: unknown; ctrlKey?: unknown }
|
|
11
|
+
|
|
12
|
+
/** the keys a frame passes up as typed on the hub: ⌥ letters, ⌥⇧ letters, the home's ⌘ keys */
|
|
13
|
+
function replayKey(m: Msg): void {
|
|
14
|
+
if (typeof m.key !== 'string' || typeof m.code !== 'string') return
|
|
15
|
+
document.body.dispatchEvent(new KeyboardEvent('keydown', { key: m.key, code: m.code, altKey: m.altKey === true, shiftKey: m.shiftKey === true, metaKey: m.metaKey === true, ctrlKey: m.ctrlKey === true, bubbles: true, cancelable: true }))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** the page's process, as pm reports it: null when none is declared or pm does not say */
|
|
19
|
+
const processOf = (app: RepoSt, id: string) => {
|
|
20
|
+
const p = app.pages.find(id)
|
|
21
|
+
return p?.process == null ? null : (app.globalProcesses.find((r) => r.id === p.process) ?? null)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const DownCard = observer(({ app, id, text }: { app: RepoSt; id: string; text: string | null }) => {
|
|
25
|
+
const p = app.pages.find(id)
|
|
26
|
+
const proc = processOf(app, id)
|
|
27
|
+
const m = app.home.machine
|
|
28
|
+
const starting = proc?.dot === 'starting'
|
|
29
|
+
return (
|
|
30
|
+
<div className="stagewrap">
|
|
31
|
+
<div className="colcard checkcard">
|
|
32
|
+
<div className="chead"><span className="tid">page</span><h3 className="ctitle">{app.pages.title(id)}</h3></div>
|
|
33
|
+
<div className="usays">{text ?? (proc == null ? `the page does not answer on ${p?.url ?? id}` : `${proc.label} is ${proc.dot}: it serves this page`)}</div>
|
|
34
|
+
{proc != null && m != null ? (
|
|
35
|
+
<button disabled={starting} onClick={() => void m.processAct(proc.id, 'start')}>{starting ? `starting ${proc.label}…` : `start ${proc.label}`}</button>
|
|
36
|
+
) : null}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const PageFrame = observer(({ app, id, on }: { app: RepoSt; id: string; on: boolean }) => {
|
|
43
|
+
const ref = useRef<HTMLIFrameElement>(null)
|
|
44
|
+
/** the keys the frame holds now: what it posted, or what the hub last sent it */
|
|
45
|
+
const held = useRef<string>(app.sel?.t === 'page' && app.sel.id === id ? (app.sel.q ?? '') : (app.pages.keys.get(id) ?? ''))
|
|
46
|
+
const onNow = useRef(on)
|
|
47
|
+
onNow.current = on
|
|
48
|
+
const [downText, setDownText] = useState<string | null>(null)
|
|
49
|
+
const [epoch, setEpoch] = useState(0)
|
|
50
|
+
const proc = processOf(app, id)
|
|
51
|
+
const down = proc != null && proc.dot !== 'up' && proc.dot !== 'unknown'
|
|
52
|
+
const missing = app.pages.loaded && app.pages.find(id) == null
|
|
53
|
+
const mounted = !down && !missing && downText == null
|
|
54
|
+
// the process came back: a frame that showed the down text loads again
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!down && downText != null && proc?.dot === 'up') {
|
|
57
|
+
setDownText(null)
|
|
58
|
+
setEpoch((n) => n + 1)
|
|
59
|
+
}
|
|
60
|
+
}, [down, downText, proc?.dot])
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!mounted) return
|
|
63
|
+
const post = (m: Record<string, unknown>): void => ref.current?.contentWindow?.postMessage({ ...m }, location.origin)
|
|
64
|
+
/** the identity the repo speaks as (its row's `speaksAs`, the default already folded in), null with none */
|
|
65
|
+
const identity = (): string | null => app.home.projects.list.find((p) => p.name === app.key)?.speaksAs ?? null
|
|
66
|
+
const hello = (): void => post({ shipkit: 'hello', keys: held.current, theme: app.home.theme.resolved, identity: identity(), on: onNow.current })
|
|
67
|
+
const onMessage = (e: MessageEvent): void => {
|
|
68
|
+
if (e.source !== ref.current?.contentWindow || e.origin !== location.origin) return
|
|
69
|
+
const m = (e.data ?? {}) as Msg
|
|
70
|
+
switch (m.shipkit) {
|
|
71
|
+
case 'ready': return hello()
|
|
72
|
+
case 'keys':
|
|
73
|
+
if (typeof m.keys !== 'string') return
|
|
74
|
+
held.current = m.keys
|
|
75
|
+
return app.pageMoved(id, m.keys)
|
|
76
|
+
case 'title': return app.pages.post(id, m)
|
|
77
|
+
case 'open':
|
|
78
|
+
if (typeof m.hash === 'string' && m.hash.startsWith('#')) location.hash = m.hash
|
|
79
|
+
return
|
|
80
|
+
case 'key': return replayKey(m)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
window.addEventListener('message', onMessage)
|
|
84
|
+
const theme = reaction(() => app.home.theme.resolved, (t) => post({ shipkit: 'theme', theme: t }))
|
|
85
|
+
const speaker = reaction(identity, (i) => post({ shipkit: 'identity', identity: i }))
|
|
86
|
+
// the address moved from outside (back, a pasted link): the frame takes it
|
|
87
|
+
const keys = reaction(
|
|
88
|
+
() => (app.sel?.t === 'page' && app.sel.id === id ? (app.sel.q ?? '') : null),
|
|
89
|
+
(q) => {
|
|
90
|
+
if (q == null || q === held.current) return
|
|
91
|
+
held.current = q
|
|
92
|
+
post({ shipkit: 'keys', keys: q })
|
|
93
|
+
},
|
|
94
|
+
)
|
|
95
|
+
return () => {
|
|
96
|
+
window.removeEventListener('message', onMessage)
|
|
97
|
+
theme()
|
|
98
|
+
speaker()
|
|
99
|
+
keys()
|
|
100
|
+
}
|
|
101
|
+
}, [app, id, mounted, epoch])
|
|
102
|
+
// shown or hidden: the page decides what stops; shown, it takes the keyboard
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
ref.current?.contentWindow?.postMessage({ shipkit: 'focus', on }, location.origin)
|
|
105
|
+
if (on) ref.current?.contentWindow?.focus()
|
|
106
|
+
}, [on])
|
|
107
|
+
/** the proxy's answer when the process does not: its text, in the down card */
|
|
108
|
+
const onLoad = (): void => {
|
|
109
|
+
try {
|
|
110
|
+
const d = ref.current?.contentDocument
|
|
111
|
+
if (d?.contentType === 'text/plain') setDownText(d.body.innerText.trim())
|
|
112
|
+
else if (on) ref.current?.contentWindow?.focus()
|
|
113
|
+
} catch {
|
|
114
|
+
// another origin cannot be read: never the case behind the proxy
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return (
|
|
118
|
+
<div className="pframe" hidden={!on}>
|
|
119
|
+
{mounted ? <iframe key={epoch} ref={ref} src={app.pages.src(id)} title={app.pages.title(id)} onLoad={onLoad} /> : <DownCard app={app} id={id} text={missing ? (app.pages.problem ?? `this repo declares no page ${id}: a page({...}) unit adds one`) : downText} />}
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
/** every kept frame of this repo: under the main pane, shown when the page is */
|
|
125
|
+
export const PageFrames = observer(({ app }: { app: RepoSt }) => {
|
|
126
|
+
const ids = app.home.frames.of(app.key)
|
|
127
|
+
const shown = app.sel?.t === 'page' ? app.sel.id : null
|
|
128
|
+
if (ids.length === 0) return null
|
|
129
|
+
return (
|
|
130
|
+
<div className="pframes" hidden={shown == null}>
|
|
131
|
+
{ids.map((id) => <PageFrame key={id} app={app} id={id} on={id === shown && app.isShown} />)}
|
|
132
|
+
</div>
|
|
133
|
+
)
|
|
134
|
+
})
|