rvlib-shipkit 2.17.0 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/cli/cmd_Review.ts +4 -0
- package/src/core/discover-checks.ts +18 -5
- package/src/home/beat.ts +30 -0
- package/src/home/home-paths.ts +1 -0
- package/src/home/pm.ts +3 -1
- package/src/home/run-daemon.ts +5 -2
- package/src/home/run-web.ts +4 -2
- package/src/home/supervise.ts +18 -1
- package/src/review/model.ts +11 -0
- package/src/serve/hub-app/hub-app.tsx +28 -2
- package/src/serve/hub-app/icons.tsx +1 -0
- package/src/serve/hub-app/identities-view.tsx +1 -1
- package/src/serve/hub-app/kept-cols.tsx +47 -8
- package/src/serve/hub-app/layout-st.ts +37 -3
- package/src/serve/hub-app/review/review-kit.ts +8 -0
- package/src/serve/hub-app/review/review-page.tsx +1 -1
- package/src/serve/hub-app/review/review-st.ts +26 -4
- package/src/serve/hub-app/review/review-thread.tsx +1 -0
- package/src/serve/hub-app/review/review-views.tsx +91 -20
- package/src/serve/hub-app/review/thread-st.ts +6 -0
- package/src/serve/hub-app/review/trailer-page.tsx +1 -1
- package/src/serve/hub-app/review.css +24 -0
- package/src/serve/hub-app/social/comms-page.tsx +1 -1
- package/src/serve/hub-app/social/social-page.tsx +1 -1
- package/src/serve/hub-app/stores/stores-page.tsx +1 -1
- package/src/serve/hub-app/veille/veille-page.tsx +1 -1
- package/src/shot/box.ts +9 -1
- package/src/shot/shooter.ts +24 -2
- package/src/social/load.ts +3 -1
- package/src/trailer/grammar.ts +2 -0
- package/src/trailer/sound/presets.ts +3 -3
- package/src/trailer/sound/run.ts +22 -14
- package/src/trailer/titles.ts +1 -1
- package/src/wiki/lint-md.ts +4 -2
- package/src/wiki/run-wiki.ts +11 -5
- package/src/wiki/scan-md.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 2.17.1
|
|
2
|
+
|
|
3
|
+
- **A `big` title keeps the cut's line breaks.** Each `\n` starts a line, and a line wider than the frame still wraps; the lines used to be joined and wrapped wherever the width fell.
|
|
4
|
+
- **A sound made on another machine never waits on the local load.** A `SoundRun` says `remote: true` when its work runs elsewhere; the voice, sfx and music presets set it, so an ElevenLabs line or a comfy box generation starts at once. FluidSynth and a hand written run still wait while the load is over 16.
|
|
5
|
+
- **A sign in survives the warm shooter's context swaps.** The cookies of a closed context (another viewport, a clip, the idle close) pass to the next one, in memory only.
|
|
6
|
+
- **The md scan skips a link to nothing** instead of crashing `sk wiki lint`.
|
|
7
|
+
- **`sk wiki lint` no longer calls `agent/global-contribution.md` an orphan**: the house index lists it.
|
|
8
|
+
- **A draft for an identity with no account yet loads.** `## short` and `## vertical` are always valid headings; the draft waits and posts nowhere.
|
|
9
|
+
- **`sk review add` warns when no watch hears the new card**, and names the one that would (`--mine`, `--lane <id>`). Only a watch of the card's own session or lane counts.
|
|
10
|
+
|
|
1
11
|
## 2.17.0
|
|
2
12
|
|
|
3
13
|
- **`sk secret` lists the secrets of the repo you stand in.** `sk secret list` reads the house's creds and the repo's own, keeps the ones whose new `for` scope (`{ repos, identities }`, absent for every repo) names this repo, by its config name or its folder, or the identity it speaks as, and marks each `ok` or `MISS` through `credsReadCommand`, never printing a value; `--all` keeps the rest, marked `out`. `sk secret get|account <name>` and `sk secret set <name> [account]` go through the same `credsReadCommand` and `credsCommand` templates. A list, not an access control.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rvlib-shipkit",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"funding": "https://github.com/sponsors/rvion",
|
|
5
5
|
"description": "All-in-one repo companion: ci gate (task DAG), auto-discovered health checks, release-contract fulfillness, asks queue, md-wiki tools, asset atelier, live tui",
|
|
6
6
|
"license": "MIT",
|
package/src/cli/cmd_Review.ts
CHANGED
|
@@ -252,6 +252,10 @@ export class ReviewAddCommand extends Command {
|
|
|
252
252
|
const item = await addItem(h.dir, input)
|
|
253
253
|
h.out(item.id)
|
|
254
254
|
if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the card: pass --lane <id> (or SK_AGENT), so the hub colours it')
|
|
255
|
+
const { unheardLine } = await import('../review/model.ts')
|
|
256
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
257
|
+
const unheard = unheardLine(item, liveWatchers(h.dir))
|
|
258
|
+
if (unheard) h.err(unheard)
|
|
255
259
|
return 0
|
|
256
260
|
})
|
|
257
261
|
}
|
|
@@ -25,6 +25,8 @@ import { check, type CheckDef, type CheckFrom } from '../check.ts'
|
|
|
25
25
|
import { CHECK_SUFFIX as SUFFIX, fallbackNames, isLegacyCheckSource, SKIPPED_DIRS as IGNORED_DIRS, UNIT_SUFFIX, unitBase } from './check-file-names.ts'
|
|
26
26
|
import { unitKind } from '../shipkit-files.ts'
|
|
27
27
|
import { readVendored } from './vendored-read.ts'
|
|
28
|
+
import { gitBin } from './git-bin.ts'
|
|
29
|
+
import { keptOnTree } from './tree-rev.ts'
|
|
28
30
|
|
|
29
31
|
export { fallbackNames, isLegacyCheckSource } from './check-file-names.ts'
|
|
30
32
|
|
|
@@ -101,15 +103,26 @@ function walkKept(dir: string, out: string[], suffix: string, dirs: string[] | u
|
|
|
101
103
|
dirs?.push(...seen)
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
/** the absolute
|
|
105
|
-
|
|
106
|
+
/** the absolute dirs no repo walk enters: the vendored ones, and every one git ignores. A folder of captures or a
|
|
107
|
+
* build output holds thousands of dirs, and a walk through them holds the daemon's loop for seconds */
|
|
108
|
+
const prunedDirs = (root: string): ReadonlySet<string> => new Set([...readVendored(root).map((d) => join(root, d)), ...ignoredDirs(root)])
|
|
109
|
+
|
|
110
|
+
/** the dirs git ignores under `root`, absolute, read again once the tree moved (one git spawn); none outside git */
|
|
111
|
+
function ignoredDirs(root: string): string[] {
|
|
112
|
+
return keptOnTree(ignoredLists, root, () => {
|
|
113
|
+
const p = Bun.spawnSync([gitBin(), 'ls-files', '--others', '--ignored', '--exclude-standard', '--directory', '-z'], { cwd: root, stdout: 'pipe', stderr: 'ignore' })
|
|
114
|
+
if (p.exitCode !== 0) return []
|
|
115
|
+
return p.stdout.toString().split('\0').filter((f) => f.endsWith('/')).map((f) => join(root, f.slice(0, -1)))
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
const ignoredLists = new Map<string, { rev: number; value: string[] }>()
|
|
106
119
|
|
|
107
120
|
/** every `*.shipkit.ts` file under a repo root, by the same walk. Sorted.
|
|
108
121
|
* `dirs` collects every dir the walk read: a file added to one moves its
|
|
109
122
|
* mtime, which is how a reader tells the list moved without walking again */
|
|
110
123
|
export function repoUnitFiles(root: string, dirs?: string[]): string[] {
|
|
111
124
|
const out: string[] = []
|
|
112
|
-
walkKept(root, out, UNIT_SUFFIX, dirs,
|
|
125
|
+
walkKept(root, out, UNIT_SUFFIX, dirs, prunedDirs(root))
|
|
113
126
|
return out.sort()
|
|
114
127
|
}
|
|
115
128
|
|
|
@@ -134,7 +147,7 @@ export async function importFresh(path: string): Promise<unknown> {
|
|
|
134
147
|
* Sorted. */
|
|
135
148
|
export function repoCheckFiles(root: string): string[] {
|
|
136
149
|
const out: string[] = []
|
|
137
|
-
walkKept(root, out, SUFFIX, undefined,
|
|
150
|
+
walkKept(root, out, SUFFIX, undefined, prunedDirs(root))
|
|
138
151
|
return out.sort()
|
|
139
152
|
}
|
|
140
153
|
|
|
@@ -229,7 +242,7 @@ export async function discoverChecks(root: string, o: DiscoverOpts = {}): Promis
|
|
|
229
242
|
const builtins: string[] = []
|
|
230
243
|
walk(builtinDir, builtins)
|
|
231
244
|
const found: string[] = []
|
|
232
|
-
walkKept(root, found, SUFFIX, undefined,
|
|
245
|
+
walkKept(root, found, SUFFIX, undefined, prunedDirs(root))
|
|
233
246
|
const units = repoUnitFiles(root)
|
|
234
247
|
// the repo that HOSTS the toolkit walks over `src/checks/` too, and a file
|
|
235
248
|
// discovered twice is a duplicate id rather than a second check. Real paths,
|
package/src/home/beat.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// a child's heartbeat on disk: its loop touches `<role>.beat` once a second, the file holding its pid. pm reads it
|
|
2
|
+
// before it kills a child that does not answer its probe: a beat this young says the loop still turns between long
|
|
3
|
+
// steps (a starved child on a loaded machine), where a hung one never turns again (home/supervise.ts, killIfHung)
|
|
4
|
+
import { readFileSync, statSync, utimesSync, writeFileSync } from 'fs'
|
|
5
|
+
|
|
6
|
+
export const BEAT_EVERY_MS = 1_000
|
|
7
|
+
|
|
8
|
+
/** starts the beat of this process; the function it returns stops it */
|
|
9
|
+
export function startBeat(file: string, pid = process.pid): () => void {
|
|
10
|
+
const write = (): void => {
|
|
11
|
+
try { writeFileSync(file, String(pid)) } catch { /* a read only home: pm then kills on the probe alone */ }
|
|
12
|
+
}
|
|
13
|
+
write()
|
|
14
|
+
const t = setInterval(() => {
|
|
15
|
+
const now = new Date()
|
|
16
|
+
try { utimesSync(file, now, now) } catch { write() }
|
|
17
|
+
}, BEAT_EVERY_MS)
|
|
18
|
+
t.unref?.()
|
|
19
|
+
return () => clearInterval(t)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** the last beat a file holds: its pid and when, or null when there is none */
|
|
23
|
+
export function readBeat(file: string): { pid: number; at: number } | null {
|
|
24
|
+
try {
|
|
25
|
+
const pid = Number(readFileSync(file, 'utf8').trim())
|
|
26
|
+
return Number.isInteger(pid) && pid > 0 ? { pid, at: statSync(file).mtimeMs } : null
|
|
27
|
+
} catch {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/home/home-paths.ts
CHANGED
|
@@ -67,6 +67,7 @@ export const pmLog = (dir = homeDir()): string => join(dir, 'pm.log')
|
|
|
67
67
|
* the pid record the next pm adopts (supervise.ts pidKey) */
|
|
68
68
|
export const childLog = (dir: string, role: string): string => join(dir, `${role}.log`)
|
|
69
69
|
export const childPid = (dir: string, role: string): string => join(dir, `${role}.pid`)
|
|
70
|
+
export const childBeat = (dir: string, role: string): string => join(dir, `${role}.beat`)
|
|
70
71
|
export const resourceLog = (dir: string, id: string): string => join(dir, 'resources', `${id}.log`)
|
|
71
72
|
export const resourcePid = (dir: string, id: string): string => join(dir, 'resources', `${id}.pid`)
|
|
72
73
|
export const stateFile = (dir: string): string => join(dir, 'state.json')
|
package/src/home/pm.ts
CHANGED
|
@@ -12,7 +12,8 @@ import { join } from 'path'
|
|
|
12
12
|
import { LIB_VERSION } from '../core/lib-version.ts'
|
|
13
13
|
import { iconImageType } from '../shipkit-files.ts'
|
|
14
14
|
import { sameOrigin } from '../serve/same-origin.ts'
|
|
15
|
-
import {
|
|
15
|
+
import { readBeat } from './beat.ts'
|
|
16
|
+
import { childBeat, childLog, childPid, daemonPort, homePort, pmLog, pmPort } from './home-paths.ts'
|
|
16
17
|
import type { Resources, ResourceView } from './resources.ts'
|
|
17
18
|
import { capLog, Proc, realDeps, tailLines, type ProcView, type SuperviseDeps } from './supervise.ts'
|
|
18
19
|
|
|
@@ -86,6 +87,7 @@ export class Pm {
|
|
|
86
87
|
// a crash loop while its code is being edited heals itself
|
|
87
88
|
neverGiveUp: true,
|
|
88
89
|
hangMs: CHILD_HANG_MS,
|
|
90
|
+
beat: () => readBeat(childBeat(d.dir, role)),
|
|
89
91
|
say: d.say,
|
|
90
92
|
}, d.deps ?? realDeps)]))
|
|
91
93
|
}
|
package/src/home/run-daemon.ts
CHANGED
|
@@ -19,7 +19,8 @@ import { loadRepoConfig } from '../repo-config.ts'
|
|
|
19
19
|
import { ensureIdentity } from '../core/identity.ts'
|
|
20
20
|
import { homedir } from 'os'
|
|
21
21
|
import { join } from 'path'
|
|
22
|
-
import {
|
|
22
|
+
import { startBeat } from './beat.ts'
|
|
23
|
+
import { childBeat, childLog, daemonPort, homeDir, homePort, homeUp, hubBase, publicHome, WORKER_ENV } from './home-paths.ts'
|
|
23
24
|
import { inboxAddress } from './inbox-shape.ts'
|
|
24
25
|
import { HomeState } from './home-state.ts'
|
|
25
26
|
import { Hubs } from './hubs.ts'
|
|
@@ -120,9 +121,11 @@ export async function runDaemon(root: string, io: HomeIo, o: { port?: number } =
|
|
|
120
121
|
const jobs = onlyRepos() == null ? startJobs({ cli: CLI, cwd: root, dir: join(dir, 'jobs'), log: childLog(dir, 'daemon'), printErr: io.printErr }) : null
|
|
121
122
|
// a job that holds the loop holds every page: each stall is said with the work that overlapped it
|
|
122
123
|
const stalls = loopWatch.start(io.printErr)
|
|
124
|
+
// pm tells a starved daemon from a hung one by this beat: it turns with the loop
|
|
125
|
+
const beat = startBeat(childBeat(dir, 'daemon'))
|
|
123
126
|
// its memory as a trend: a line only when it moved by a tenth, at most every 10 minutes
|
|
124
127
|
const memory = new MemoryWatch().start(io.print)
|
|
125
|
-
const code = reloadOnOwnCode({ role: 'daemon', entry: fileURLToPath(import.meta.url), busy: () => hubs.busy(), before: () => { stalls(); memory(); jobs?.stop(); home.stop() }, keep: true, io })
|
|
128
|
+
const code = reloadOnOwnCode({ role: 'daemon', entry: fileURLToPath(import.meta.url), busy: () => hubs.busy(), before: () => { stalls(); beat(); memory(); jobs?.stop(); home.stop() }, keep: true, io })
|
|
126
129
|
io.print(` ${house.repos.length} repos, state in ${dir}, reloads on ${code.files} lib files`)
|
|
127
130
|
for (const sig of ['SIGINT', 'SIGTERM'] as const)
|
|
128
131
|
process.on(sig, () => {
|
package/src/home/run-web.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// its own code, the page included, restarts it in place (lib-watch.ts).
|
|
5
5
|
import homePage from '../serve/hub-app/home.html'
|
|
6
6
|
import { fileURLToPath } from 'url'
|
|
7
|
-
import {
|
|
7
|
+
import { startBeat } from './beat.ts'
|
|
8
|
+
import { childBeat, daemonPort, daemonUrl, homeDir, homePort, homeUp, pmUrl } from './home-paths.ts'
|
|
8
9
|
import { reloadOnOwnCode } from './lib-watch.ts'
|
|
9
10
|
import { serveWeb } from './serve-web.ts'
|
|
10
11
|
import type { HomeIo } from './run-daemon.ts'
|
|
@@ -13,7 +14,8 @@ export async function runWeb(io: HomeIo, o: { port?: number } = {}): Promise<num
|
|
|
13
14
|
const port = o.port ?? homePort()
|
|
14
15
|
try {
|
|
15
16
|
const web = serveWeb({ port, daemon: daemonUrl(daemonPort()), pm: pmUrl(), page: homePage })
|
|
16
|
-
const
|
|
17
|
+
const beat = startBeat(childBeat(homeDir(), 'web'))
|
|
18
|
+
const code = reloadOnOwnCode({ role: 'web', entry: fileURLToPath(import.meta.url), bundles: true, before: () => { beat(); web.stop() }, io })
|
|
17
19
|
io.print(`home → http://localhost:${web.server.port} (the daemon: ${daemonUrl()}, pm: ${pmUrl()}), reloads on ${code.files} lib files`)
|
|
18
20
|
for (const sig of ['SIGINT', 'SIGTERM'] as const)
|
|
19
21
|
process.on(sig, () => {
|
package/src/home/supervise.ts
CHANGED
|
@@ -33,6 +33,9 @@ export type ProcSpec = {
|
|
|
33
33
|
* (a main thread stuck in one synchronous step still holds its port):
|
|
34
34
|
* killed, then started again after the crash backoff. None = never */
|
|
35
35
|
hangMs?: number
|
|
36
|
+
/** the child's last heartbeat: its loop touches a file while it turns (home/beat.ts). One of this pid newer than
|
|
37
|
+
* hangMs says the child is starved (slow steps on a loaded machine), not hung: it is kept, up to STARVED_MAX_MS */
|
|
38
|
+
beat?: () => { pid: number; at: number } | null
|
|
36
39
|
/** a line for every act the supervisor takes on its own */
|
|
37
40
|
say?: (line: string) => void
|
|
38
41
|
}
|
|
@@ -72,6 +75,9 @@ export const CRASH_LIMIT = 5
|
|
|
72
75
|
export const CRASH_WINDOW_MS = 5 * 60_000
|
|
73
76
|
/** a stop that SIGTERM did not end becomes a SIGKILL after this */
|
|
74
77
|
export const KILL_AFTER_MS = 5_000
|
|
78
|
+
/** how long a starved child is kept without an answer: past it, a loop that beats but never answers (a wedged
|
|
79
|
+
* server) is killed all the same */
|
|
80
|
+
export const STARVED_MAX_MS = 10 * 60_000
|
|
75
81
|
|
|
76
82
|
/** the process is started by a shell that exits at once: it belongs to init
|
|
77
83
|
* from its first moment, so a supervisor that restarts in place (execve)
|
|
@@ -145,6 +151,8 @@ export class Proc {
|
|
|
145
151
|
private probing = false
|
|
146
152
|
/** why the kill in flight was a hang kill, for the crash note */
|
|
147
153
|
private hung: string | null = null
|
|
154
|
+
/** the start of the probe silence already said to be starvation, so it is said once */
|
|
155
|
+
private starvedSince: number | null = null
|
|
148
156
|
/** a restart: start again once the stop landed */
|
|
149
157
|
private again = false
|
|
150
158
|
/** it answers its probe with no pid of ours behind it */
|
|
@@ -336,7 +344,16 @@ export class Proc {
|
|
|
336
344
|
private killIfHung(now: number): void {
|
|
337
345
|
const hang = this.spec.hangMs
|
|
338
346
|
if (hang == null || this.status !== 'starting' || this.pid == null || this.want !== 'up' || now - this.since < hang) return
|
|
339
|
-
|
|
347
|
+
const silent = Math.round((now - this.since) / 1000)
|
|
348
|
+
const beat = this.spec.beat?.() ?? null
|
|
349
|
+
if (beat != null && beat.pid === this.pid && now - beat.at < hang && now - this.since < STARVED_MAX_MS) {
|
|
350
|
+
if (this.starvedSince !== this.since) {
|
|
351
|
+
this.starvedSince = this.since
|
|
352
|
+
this.spec.say?.(`WARN ${this.spec.id} (pid ${this.pid}) did not answer its probe for ${silent}s, but its loop beat ${Math.round((now - beat.at) / 1000)}s ago: starved, not hung, kept (killed past ${STARVED_MAX_MS / 60_000} min)`)
|
|
353
|
+
}
|
|
354
|
+
return
|
|
355
|
+
}
|
|
356
|
+
this.hung = `did not answer its probe for ${silent}s${beat != null && beat.pid === this.pid && now - beat.at < hang ? ', though its loop beats' : ''}`
|
|
340
357
|
this.spec.say?.(`WARN ${this.spec.id} (pid ${this.pid}) ${this.hung}: killed, it starts again`)
|
|
341
358
|
this.d.kill(this.pid, 'SIGTERM')
|
|
342
359
|
this.killAt = now + KILL_AFTER_MS
|
package/src/review/model.ts
CHANGED
|
@@ -658,6 +658,17 @@ export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
|
|
|
658
658
|
/** the live watchers that will read his answer on any of these cards */
|
|
659
659
|
export const listenersOf = (cards: readonly ReviewItem[], watchers: readonly Watcher[]): Watcher[] => watchers.filter((w) => cards.some((x) => coversCard(w, x)))
|
|
660
660
|
|
|
661
|
+
/** what `review add` says when no live watch of the card's own session or lane will read his answer, else null: an
|
|
662
|
+
* unfiltered watch (a dispatcher, another session) hears it for someone else */
|
|
663
|
+
export function unheardLine(item: Item, watchers: readonly Watcher[]): string | null {
|
|
664
|
+
const o = item.origin
|
|
665
|
+
if (o.by !== 'agent') return null
|
|
666
|
+
const own = o.session || o.lane ? watchers.filter((w) => (o.session && w.session === o.session) || (o.lane && w.lane === o.lane)) : watchers
|
|
667
|
+
if (listenersOf([{ item, thread: [] }], own).length > 0) return null
|
|
668
|
+
const watch = o.session ? 'sk review watch --mine' : o.lane ? `sk review watch --lane ${o.lane}` : 'sk review watch'
|
|
669
|
+
return `no watch hears this card: run \`${watch}\` under a monitor now, so his answer reaches you as it lands`
|
|
670
|
+
}
|
|
671
|
+
|
|
661
672
|
/** a card's own session has this long after its last message to claim it before a watch calls it untaken */
|
|
662
673
|
export const UNTAKEN_GRACE_MS = 2 * 60 * 1000
|
|
663
674
|
/** a card nobody takes is told again this often */
|
|
@@ -38,7 +38,7 @@ import { CommsPage } from './social/comms-page.tsx'
|
|
|
38
38
|
import { SocialPage } from './social/social-page.tsx'
|
|
39
39
|
import { ProjectList } from './project-list.tsx'
|
|
40
40
|
import { Group, Panel, Separator, usePanelRef, type Layout } from 'react-resizable-panels'
|
|
41
|
-
import { LIST, SIDEBAR } from './layout-st.ts'
|
|
41
|
+
import { FOLD_PAGES, LIST, SIDEBAR, type LayoutSt } from './layout-st.ts'
|
|
42
42
|
import { ArchivedView, HomeStrip, NotUp, Overview } from './home-strip.tsx'
|
|
43
43
|
import { PlannedView } from './planned-view.tsx'
|
|
44
44
|
import { ActivityView } from './activity-view.tsx'
|
|
@@ -176,6 +176,16 @@ const leftPx = (el: HTMLElement | null, layout: Layout, id: string): number | nu
|
|
|
176
176
|
const Body = observer(({ app }: { app: RepoSt }) => {
|
|
177
177
|
const l = app.home.layout
|
|
178
178
|
const el = useRef<HTMLDivElement | null>(null)
|
|
179
|
+
// a page with columns folded on the left (W): no sidebar, the page's own bar stands where it was (kept-cols.tsx)
|
|
180
|
+
if (FOLD_PAGES.has(app.sel?.t ?? '') && l.foldedOn(app.sel?.t, 'left'))
|
|
181
|
+
return (
|
|
182
|
+
<div className="appbody rv-widebody">
|
|
183
|
+
<div className="pmain" style={PANEL} onPointerDownCapture={() => app.tree.leave()}>
|
|
184
|
+
<Main app={app} />
|
|
185
|
+
<PageFrames app={app} />
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
)
|
|
179
189
|
return (
|
|
180
190
|
<Group className="appbody" orientation="horizontal" elementRef={el}
|
|
181
191
|
onLayoutChanged={(layout, meta) => {
|
|
@@ -216,6 +226,17 @@ const RepoView = observer(({ app }: { app: RepoSt }) => {
|
|
|
216
226
|
})
|
|
217
227
|
|
|
218
228
|
/** the keys of the page: they act on the repo shown, and on nothing else */
|
|
229
|
+
/** W or T, plain and outside a text field: that side of the page folds, or unfolds */
|
|
230
|
+
function foldKey(e: KeyboardEvent, page: string, layout: LayoutSt): boolean {
|
|
231
|
+
const t = e.target as HTMLElement
|
|
232
|
+
if (e.metaKey || e.ctrlKey || e.altKey || t.tagName === 'TEXTAREA' || t.tagName === 'INPUT' || t.isContentEditable) return false
|
|
233
|
+
const k = e.key.toLowerCase()
|
|
234
|
+
if (k !== 'w' && k !== 't') return false
|
|
235
|
+
e.preventDefault()
|
|
236
|
+
layout.toggleFold(page, k === 'w' ? 'left' : 'right')
|
|
237
|
+
return true
|
|
238
|
+
}
|
|
239
|
+
|
|
219
240
|
function onKey(e: KeyboardEvent): void {
|
|
220
241
|
// the embed page has its page's own keys and nothing else
|
|
221
242
|
if (embed != null) {
|
|
@@ -247,7 +268,10 @@ function onKey(e: KeyboardEvent): void {
|
|
|
247
268
|
return
|
|
248
269
|
}
|
|
249
270
|
if (home.palette.open) return // the picker's input owns its keys
|
|
250
|
-
if (home.page === 'identities')
|
|
271
|
+
if (home.page === 'identities') {
|
|
272
|
+
if (foldKey(e, 'identities', home.layout)) return
|
|
273
|
+
return identityKey(e)
|
|
274
|
+
}
|
|
251
275
|
const app = home.shown
|
|
252
276
|
if (app == null) return
|
|
253
277
|
const t = e.target as HTMLElement
|
|
@@ -264,6 +288,8 @@ function onKey(e: KeyboardEvent): void {
|
|
|
264
288
|
e.preventDefault()
|
|
265
289
|
return
|
|
266
290
|
}
|
|
291
|
+
// W folds the left of a page with columns, T its right; what a page took above stays its own (T on Veille)
|
|
292
|
+
if (FOLD_PAGES.has(app.sel?.t ?? '') && foldKey(e, app.sel!.t, home.layout)) return
|
|
267
293
|
// a repo's own page, ⌥⇧ and its letter
|
|
268
294
|
const letter = pageLetterKey(e)
|
|
269
295
|
if (letter != null) {
|
|
@@ -25,6 +25,7 @@ export const ICON = {
|
|
|
25
25
|
// fold every cell: two chevrons meeting; unfold every cell: two chevrons apart
|
|
26
26
|
foldAll: 'M6 3.5l4 4 4-4M6 16.5l4-4 4 4',
|
|
27
27
|
unfoldAll: 'M6 7.5l4-4 4 4M6 12.5l4 4 4-4',
|
|
28
|
+
wide: 'M3 7V3h4M13 3h4v4M17 13v4h-4M7 17H3v-4',
|
|
28
29
|
// a repo page's sections, then its two runs and its editor
|
|
29
30
|
readme: 'M5 2.5h7l3 3v12H5zM12 2.5v3h3M7.5 9h5M7.5 12h5M7.5 15h3',
|
|
30
31
|
checks: 'M4 10.5 7.5 14 16 5.5',
|
|
@@ -70,7 +70,7 @@ export const IdentitiesView = observer(({ app }: { app: HomeSt }) => {
|
|
|
70
70
|
)
|
|
71
71
|
return (
|
|
72
72
|
<div className="so-page idview">
|
|
73
|
-
<KeptCols id="identities">
|
|
73
|
+
<KeptCols id="identities" folds={{ left: 'identity-list' }} layout={app.layout}>
|
|
74
74
|
<Panel id="identity-list" defaultSize="30%" minSize={260} className="rv-pane" style={PANEL}>
|
|
75
75
|
<IdentityList app={app} i={i} />
|
|
76
76
|
</Panel>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// a page's columns (the identities, social, comms, stores, Veille, review and trailer pages): the widths his drags
|
|
2
2
|
// leave are kept per browser and page, so a reload draws them as he left them from the first paint. One group per
|
|
3
|
-
// page id; the panel ids inside must stay the same for a kept layout to apply (useDefaultLayout's own rule)
|
|
4
|
-
|
|
3
|
+
// page id; the panel ids inside must stay the same for a kept layout to apply (useDefaultLayout's own rule), so each
|
|
4
|
+
// fold has its own kept layout. A page names the panel W folds (its list, the left) and the one T folds (the right):
|
|
5
|
+
// a folded side leaves a thin bar with a knob where it was, and a click on the bar brings it back. W also folds the
|
|
6
|
+
// repo's sidebar (hub-app.tsx, Body), so a page with no left panel still gives its main column the room.
|
|
7
|
+
import { observer } from 'mobx-react-lite'
|
|
8
|
+
import { Children, isValidElement, type ReactNode } from 'react'
|
|
5
9
|
import { Group, useDefaultLayout, type LayoutStorage } from 'react-resizable-panels'
|
|
10
|
+
import type { FoldSide, LayoutSt } from './layout-st.ts'
|
|
6
11
|
|
|
7
12
|
/** the browser's storage, or nothing: a private window or blocked site data keeps the layout for the tab only */
|
|
8
13
|
const STORE: LayoutStorage = {
|
|
@@ -20,11 +25,45 @@ const STORE: LayoutStorage = {
|
|
|
20
25
|
},
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
/** the panel each key folds, by its id */
|
|
29
|
+
export type ColFolds = { left?: string; right?: string }
|
|
30
|
+
|
|
31
|
+
/** the children left once the folded panels go, each with the separator that stood between it and the rest */
|
|
32
|
+
export function unfolded(children: ReactNode, folds: ColFolds, folded: (side: FoldSide) => boolean): ReactNode[] {
|
|
33
|
+
const all = Children.toArray(children)
|
|
34
|
+
const idOf = (c: ReactNode): string | undefined => (isValidElement<{ id?: string }>(c) ? c.props.id : undefined)
|
|
35
|
+
const drop = new Set<number>()
|
|
36
|
+
for (const side of ['left', 'right'] as const) {
|
|
37
|
+
const id = folds[side]
|
|
38
|
+
if (id == null || !folded(side)) continue
|
|
39
|
+
const at = all.findIndex((c) => idOf(c) === id)
|
|
40
|
+
if (at < 0) continue
|
|
41
|
+
drop.add(at)
|
|
42
|
+
// the separator on the side of the rest: after a left panel, before a right one
|
|
43
|
+
drop.add(side === 'left' ? at + 1 : at - 1)
|
|
44
|
+
}
|
|
45
|
+
return all.filter((_, i) => !drop.has(i))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** the bar a folded side leaves: the whole height, a knob at mid height, a click brings the side back */
|
|
49
|
+
const FoldBar = ({ side, onClick }: { side: FoldSide; onClick: () => void }) => (
|
|
50
|
+
<button className={`rv-widebar ${side}`} title={side === 'left' ? 'show the sidebar and the list again (W)' : 'show the right panel again (T)'} aria-label={side === 'left' ? 'unfold the left' : 'unfold the right'} onClick={onClick}>
|
|
51
|
+
<span className="rv-wideknob" aria-hidden="true">{side === 'left' ? '›' : '‹'}</span>
|
|
52
|
+
</button>
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
export const KeptCols = observer(({ id, children, folds, layout }: { id: string; children: ReactNode; folds?: ColFolds; layout?: LayoutSt }) => {
|
|
56
|
+
const folded = (side: FoldSide): boolean => layout?.foldedOn(id, side) === true
|
|
57
|
+
const tag = (['left', 'right'] as const).filter((s) => folds?.[s] != null && folded(s)).map((s) => `:${s}`).join('')
|
|
58
|
+
const kept = useDefaultLayout({ id: `hub:cols:${id}${tag}`, storage: STORE, onlySaveAfterUserInteractions: true })
|
|
59
|
+
const bar = (side: FoldSide): ReactNode => (layout != null && folded(side) && (side === 'left' || folds?.right != null) ? <FoldBar side={side} onClick={() => layout.toggleFold(id, side)} /> : null)
|
|
25
60
|
return (
|
|
26
|
-
<
|
|
27
|
-
{
|
|
28
|
-
|
|
61
|
+
<div className="rv-foldrow">
|
|
62
|
+
{bar('left')}
|
|
63
|
+
<Group key={tag} className="rv-cols" orientation="horizontal" defaultLayout={kept.defaultLayout} onLayoutChanged={kept.onLayoutChanged}>
|
|
64
|
+
{folds == null ? children : unfolded(children, folds, folded)}
|
|
65
|
+
</Group>
|
|
66
|
+
{bar('right')}
|
|
67
|
+
</div>
|
|
29
68
|
)
|
|
30
|
-
}
|
|
69
|
+
})
|
|
@@ -23,6 +23,21 @@ const RAIL_PAD = 6
|
|
|
23
23
|
/** the project list folded: its icons only, a row's name in its hover card */
|
|
24
24
|
export const railPx = (size: RailIcon): number => RAIL_ICONS[size] + 2 * RAIL_PAD
|
|
25
25
|
const RAIL_KEY = 'hub:list-rail'
|
|
26
|
+
/** what each page with columns has folded, by page: W the left (the repo's sidebar and the page's list), T the right
|
|
27
|
+
* panel (kept-cols.tsx) */
|
|
28
|
+
const FOLDS_KEY = 'hub:folds'
|
|
29
|
+
export type FoldSide = 'left' | 'right'
|
|
30
|
+
/** the repo pages whose columns fold (their `sel.t`): W there folds the repo's sidebar too */
|
|
31
|
+
export const FOLD_PAGES: ReadonlySet<string> = new Set(['review', 'trailer', 'stores', 'veille', 'comms', 'social'])
|
|
32
|
+
type Folds = Record<string, Partial<Record<FoldSide, true>>>
|
|
33
|
+
function loadFolds(): Folds {
|
|
34
|
+
try {
|
|
35
|
+
const v = JSON.parse(globalThis.localStorage?.getItem(FOLDS_KEY) ?? '{}') as unknown
|
|
36
|
+
return v != null && typeof v === 'object' && !Array.isArray(v) ? (v as Folds) : {}
|
|
37
|
+
} catch {
|
|
38
|
+
return {}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
26
41
|
const RAIL_ICON_KEY = 'hub:rail-icon'
|
|
27
42
|
|
|
28
43
|
function loadRailIcon(): RailIcon {
|
|
@@ -54,9 +69,9 @@ function saveWidth(b: Bounds, px: number): void {
|
|
|
54
69
|
} catch { /* private window or blocked site data: the width lasts the tab */ }
|
|
55
70
|
}
|
|
56
71
|
|
|
57
|
-
function
|
|
72
|
+
function loadFlag(key: string): boolean {
|
|
58
73
|
try {
|
|
59
|
-
return globalThis.localStorage?.getItem(
|
|
74
|
+
return globalThis.localStorage?.getItem(key) === '1'
|
|
60
75
|
} catch {
|
|
61
76
|
return false
|
|
62
77
|
}
|
|
@@ -68,12 +83,14 @@ export const NARROW_PX = 768
|
|
|
68
83
|
export class LayoutSt {
|
|
69
84
|
listWidth = loadWidth(LIST)
|
|
70
85
|
/** the owner's pick: the list shows its icons only */
|
|
71
|
-
listRail =
|
|
86
|
+
listRail = loadFlag(RAIL_KEY)
|
|
72
87
|
/** the page is narrower than NARROW_PX, read live */
|
|
73
88
|
narrow = false
|
|
74
89
|
/** the rail's icon size */
|
|
75
90
|
railIcon: RailIcon = loadRailIcon()
|
|
76
91
|
sidebarWidth = loadWidth(SIDEBAR)
|
|
92
|
+
/** each page's folded sides, kept per browser */
|
|
93
|
+
folds: Folds = loadFolds()
|
|
77
94
|
|
|
78
95
|
constructor() {
|
|
79
96
|
makeAutoObservable(this)
|
|
@@ -123,6 +140,23 @@ export class LayoutSt {
|
|
|
123
140
|
this.setRail(!this.listRail)
|
|
124
141
|
}
|
|
125
142
|
|
|
143
|
+
/** whether a page has folded that side */
|
|
144
|
+
foldedOn(page: string | undefined, side: FoldSide): boolean {
|
|
145
|
+
// a narrow page draws its own one pane layout: a fold there would hide a side with no bar to bring it back
|
|
146
|
+
return page != null && !this.narrow && this.folds[page]?.[side] === true
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** W (the left) or T (the right) on a page with columns, and the bar that stands where a folded side was */
|
|
150
|
+
toggleFold(page: string, side: FoldSide): void {
|
|
151
|
+
const cur = { ...this.folds[page] }
|
|
152
|
+
if (cur[side]) delete cur[side]
|
|
153
|
+
else cur[side] = true
|
|
154
|
+
this.folds = { ...this.folds, [page]: cur }
|
|
155
|
+
try {
|
|
156
|
+
globalThis.localStorage?.setItem(FOLDS_KEY, JSON.stringify(this.folds))
|
|
157
|
+
} catch { /* private window or blocked site data: the folds last the tab */ }
|
|
158
|
+
}
|
|
159
|
+
|
|
126
160
|
/** a drag of the sidebar's separator ended at this width */
|
|
127
161
|
setSidebarWidth(px: number): void {
|
|
128
162
|
this.sidebarWidth = clampWidth(Math.round(px), SIDEBAR)
|
|
@@ -6,6 +6,14 @@ import { reach } from '../reach.ts'
|
|
|
6
6
|
export const ZOOMS = ['fit', '1', '1.5', '2'] as const
|
|
7
7
|
export type Zoom = (typeof ZOOMS)[number]
|
|
8
8
|
|
|
9
|
+
/** how a gallery draws: a side list of its images with the picked one large, one image a row at full width, or the
|
|
10
|
+
* wrapping grid of tiles at the slider's height */
|
|
11
|
+
export const GALLERY_MODES = ['tabs', 'list', 'grid'] as const
|
|
12
|
+
export type GalleryMode = (typeof GALLERY_MODES)[number]
|
|
13
|
+
/** a large gallery image fills the column's width (it scrolls), or fits the screen whole */
|
|
14
|
+
export const GALLERY_FITS = ['width', 'screen'] as const
|
|
15
|
+
export type GalleryFit = (typeof GALLERY_FITS)[number]
|
|
16
|
+
|
|
9
17
|
/** a gallery tile's image height in px: his slider's range and its start; past THUMB a tile reads the fit preview, the
|
|
10
18
|
* list thumb is too small for it */
|
|
11
19
|
export const TILE_H = { min: 80, max: 480, start: 170, thumb: 220 } as const
|
|
@@ -33,7 +33,7 @@ export const ReviewPage = observer(({ app }: { app: RepoSt }) => {
|
|
|
33
33
|
return (
|
|
34
34
|
<>
|
|
35
35
|
<Toast rv={rv} />
|
|
36
|
-
<KeptCols id="review">
|
|
36
|
+
<KeptCols id="review" folds={{ left: 'review-list' }} layout={app.home.layout}>
|
|
37
37
|
<Panel id="review-list" defaultSize="24%" minSize={180} className="rv-pane" style={PANEL}>
|
|
38
38
|
<ReviewList rv={rv} />
|
|
39
39
|
</Panel>
|
|
@@ -8,7 +8,7 @@ import { MOVE_LABEL, pasteBlock, STATUS_LABEL, type Move, type ShownStatus, type
|
|
|
8
8
|
import type { PasteHosts } from '../../../review/paste.ts'
|
|
9
9
|
import type { Role } from '../../../review/role.ts'
|
|
10
10
|
import type { RepoSt } from '../repo-st.ts'
|
|
11
|
-
import { copyText, etagLoader, kept, postJson, TILE_H, ZOOMS, type EtagLoader, type Zoom } from './review-kit.ts'
|
|
11
|
+
import { copyText, etagLoader, GALLERY_FITS, GALLERY_MODES, kept, postJson, TILE_H, ZOOMS, type EtagLoader, type GalleryFit, type GalleryMode, type Zoom } from './review-kit.ts'
|
|
12
12
|
import { ThreadSt, type Draft } from './thread-st.ts'
|
|
13
13
|
|
|
14
14
|
/** a live `sk review watch`: its process, the session or lane it keeps, when it started */
|
|
@@ -141,6 +141,9 @@ export class ReviewSt {
|
|
|
141
141
|
tileH: number = TILE_H.start
|
|
142
142
|
/** each gallery tile also drawn at 16, 32 and 64 px, the sizes an icon lives at */
|
|
143
143
|
tileSmall = false
|
|
144
|
+
/** how a gallery draws (tabs, list, grid), and how its large image fits */
|
|
145
|
+
galleryMode: GalleryMode = 'tabs'
|
|
146
|
+
galleryFit: GalleryFit = 'width'
|
|
144
147
|
/** the contents strip beside the cells, when the column is wide enough; folded by hand */
|
|
145
148
|
railOn = true
|
|
146
149
|
/** the contents as a sheet over the cells: a narrow column or the phone */
|
|
@@ -174,7 +177,7 @@ export class ReviewSt {
|
|
|
174
177
|
this.loadBoard = etagLoader(() => st.url('/api/review/board'))
|
|
175
178
|
this.compare = new CompareSt(`${this.prefix}compare`)
|
|
176
179
|
try {
|
|
177
|
-
const p = JSON.parse(kept.get(`${this.prefix}prefs`) ?? '{}') as { hideHandled?: boolean; byLane?: boolean; zoom?: string; marks?: boolean; rail?: boolean; tileH?: number; tileSmall?: boolean }
|
|
180
|
+
const p = JSON.parse(kept.get(`${this.prefix}prefs`) ?? '{}') as { hideHandled?: boolean; byLane?: boolean; zoom?: string; marks?: boolean; rail?: boolean; tileH?: number; tileSmall?: boolean; galleryMode?: string; galleryFit?: string }
|
|
178
181
|
if (p.hideHandled === false) this.hideHandled = false
|
|
179
182
|
if (p.byLane === true) this.byLane = true
|
|
180
183
|
if (p.marks === false) this.marksOn = false
|
|
@@ -182,6 +185,8 @@ export class ReviewSt {
|
|
|
182
185
|
if ((ZOOMS as readonly string[]).includes(p.zoom ?? '')) this.zoom = p.zoom as Zoom
|
|
183
186
|
if (typeof p.tileH === 'number') this.setTileH(p.tileH)
|
|
184
187
|
if (p.tileSmall === true) this.tileSmall = true
|
|
188
|
+
if ((GALLERY_MODES as readonly string[]).includes(p.galleryMode ?? '')) this.galleryMode = p.galleryMode as GalleryMode
|
|
189
|
+
if ((GALLERY_FITS as readonly string[]).includes(p.galleryFit ?? '')) this.galleryFit = p.galleryFit as GalleryFit
|
|
185
190
|
} catch {
|
|
186
191
|
// a broken pref is the default
|
|
187
192
|
}
|
|
@@ -205,7 +210,7 @@ export class ReviewSt {
|
|
|
205
210
|
boardRows: observableRef,
|
|
206
211
|
})
|
|
207
212
|
reaction(
|
|
208
|
-
() => JSON.stringify({ hideHandled: this.hideHandled, byLane: this.byLane, zoom: this.zoom, marks: this.marksOn, rail: this.railOn, tileH: this.tileH, tileSmall: this.tileSmall }),
|
|
213
|
+
() => JSON.stringify({ hideHandled: this.hideHandled, byLane: this.byLane, zoom: this.zoom, marks: this.marksOn, rail: this.railOn, tileH: this.tileH, tileSmall: this.tileSmall, galleryMode: this.galleryMode, galleryFit: this.galleryFit }),
|
|
209
214
|
(s) => kept.put(`${this.prefix}prefs`, s),
|
|
210
215
|
)
|
|
211
216
|
// the card the address names, else the list's first: a new one is a new thread state, the old one disposed
|
|
@@ -471,6 +476,15 @@ export class ReviewSt {
|
|
|
471
476
|
return this.railOn && !this.phone.on && this.width >= RAIL_PX
|
|
472
477
|
}
|
|
473
478
|
|
|
479
|
+
/** the card drawn alone, the sidebar and the cards folded away; a phone shows one pane anyway */
|
|
480
|
+
get wide(): boolean {
|
|
481
|
+
return this.st.home.layout.foldedOn('review', 'left') && !this.phone.on
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
toggleWide(): void {
|
|
485
|
+
this.st.home.layout.toggleFold('review', 'left')
|
|
486
|
+
}
|
|
487
|
+
|
|
474
488
|
toggleRail(): void {
|
|
475
489
|
if (this.phone.on || this.width < RAIL_PX) this.sheet = !this.sheet
|
|
476
490
|
else this.railOn = !this.railOn
|
|
@@ -484,6 +498,14 @@ export class ReviewSt {
|
|
|
484
498
|
this.zoom = z
|
|
485
499
|
}
|
|
486
500
|
|
|
501
|
+
setGalleryMode(m: GalleryMode): void {
|
|
502
|
+
this.galleryMode = m
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
setGalleryFit(f: GalleryFit): void {
|
|
506
|
+
this.galleryFit = f
|
|
507
|
+
}
|
|
508
|
+
|
|
487
509
|
toggleTileSmall(): void {
|
|
488
510
|
this.tileSmall = !this.tileSmall
|
|
489
511
|
}
|
|
@@ -598,7 +620,7 @@ export class ReviewSt {
|
|
|
598
620
|
|
|
599
621
|
/** the page's keys, as the atelier takes its own: true when it used the key. V approves, F ok with a fix, R rejects,
|
|
600
622
|
* A archives, N the next waiting card, C copies the card for an agent, M the rings, T the contents, D the next
|
|
601
|
-
* compare mode of every pair (⇧D the one before), ↑ ↓ the list; the card takes
|
|
623
|
+
* compare mode of every pair (⇧D the one before), ↑ ↓ the list (W the card wide is the hub's, kept-cols.tsx); the card takes
|
|
602
624
|
* the rest (ThreadSt.key). A digit is read from its physical key (`code`), so ⇧ and an AZERTY keyboard read the same */
|
|
603
625
|
key(e: Pick<KeyboardEvent, 'key' | 'shiftKey'> & { code?: string }): boolean {
|
|
604
626
|
const card = this.card
|
|
@@ -126,6 +126,7 @@ const TopBar = observer(({ rv, card, back }: { rv: ReviewSt; card: ThreadSt; bac
|
|
|
126
126
|
<Rework r={v.rework} />
|
|
127
127
|
<span className="sp" />
|
|
128
128
|
<PostAsk rv={rv} card={card} />
|
|
129
|
+
<button className={`rv-iconbtn${rv.wide ? ' on' : ''}`} aria-pressed={rv.wide} title={rv.wide ? 'back to the sidebar and the cards (W)' : 'wide: fold the sidebar and the cards, the card takes the page (W)'} aria-label="wide" onMouseDown={keepFocus} onClick={() => rv.toggleWide()}><Icon d={ICON.wide} /></button>
|
|
129
130
|
<span className="seg">
|
|
130
131
|
<button className="rv-iconbtn" title="fold every cell" aria-label="fold every cell" onMouseDown={keepFocus} onClick={() => card.foldAll(false)}><Icon d={ICON.foldAll} /></button>
|
|
131
132
|
<button className="rv-iconbtn" title="unfold every cell (it loads every image)" aria-label="unfold every cell" onMouseDown={keepFocus} onClick={() => card.foldAll(true)}><Icon d={ICON.unfoldAll} /></button>
|
|
@@ -11,7 +11,7 @@ import { isChoice, isGallery, isPair, onFrame, STARS, STATUS_LABEL, thumbFileOf,
|
|
|
11
11
|
import { AutoText } from '../auto-text.tsx'
|
|
12
12
|
import type { ClipSt } from './clip-st.ts'
|
|
13
13
|
import { blurOnEscape, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs, SIDE_LABEL } from './kit.tsx'
|
|
14
|
-
import { TILE_H, ZOOMS, type Zoom } from './review-kit.ts'
|
|
14
|
+
import { GALLERY_FITS, GALLERY_MODES, TILE_H, ZOOMS, type GalleryFit, type GalleryMode, type Zoom } from './review-kit.ts'
|
|
15
15
|
import { COMPARE_MODES, drawnSide, type CompareMode, type CompareSt, type PairSide, type ReviewSt } from './review-st.ts'
|
|
16
16
|
import { TILE_FILTERS, viewDom, viewKind, viewKey, type ThreadSt, type TileFilter } from './thread-st.ts'
|
|
17
17
|
import { Caret } from '../icons.tsx'
|
|
@@ -358,17 +358,35 @@ const ReactionToggles = observer(({ ver, view, tile, small }: { ver: Ver; view:
|
|
|
358
358
|
)
|
|
359
359
|
})
|
|
360
360
|
|
|
361
|
-
/** a gallery view
|
|
362
|
-
*
|
|
361
|
+
/** a gallery view, drawn the way he picks (kept per repo): tabs, a side list of its images with the picked one large;
|
|
362
|
+
* list, one image a row at full width; grid, its tiles at the slider's height, one row per asset when its tiles are
|
|
363
|
+
* variants (a group each). A head picks the mode and the fit, filters the tiles, flips every tile to its before, adds
|
|
364
|
+
* the small sizes. A phone has no room for a side list, so its tabs read as the list */
|
|
363
365
|
const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: number }) => {
|
|
364
366
|
const { rv, card } = ver
|
|
365
367
|
const befores = v.gallery.some((t) => t.before)
|
|
366
368
|
const tiles = v.gallery.map((t, k) => ({ t, k }))
|
|
367
|
-
const
|
|
368
|
-
const
|
|
369
|
+
const sections = v.gallery.some((t) => t.group) ? [...new Set(v.gallery.map((t) => t.group ?? ''))].map((g) => ({ g, tiles: tiles.filter((x) => (x.t.group ?? '') === g) })) : null
|
|
370
|
+
const mode: GalleryMode = rv.galleryMode === 'tabs' && rv.phone.on ? 'list' : rv.galleryMode
|
|
371
|
+
const draw = (xs: typeof tiles): ReactNode =>
|
|
372
|
+
mode === 'list'
|
|
373
|
+
? <div className="rv-gallerylist">{xs.map(({ t, k }) => <Tile key={k} ver={ver} v={v} view={view} t={t} k={k} fill />)}</div>
|
|
374
|
+
: <div className="rv-gallery">{xs.map(({ t, k }) => <Tile key={k} ver={ver} v={v} view={view} t={t} k={k} />)}</div>
|
|
369
375
|
return (
|
|
370
376
|
<div className="rv-gallerywrap">
|
|
371
377
|
<div className="rv-galleryhead rv-small">
|
|
378
|
+
<span className="seg" role="group" aria-label="how the images show">
|
|
379
|
+
{GALLERY_MODES.map((m) => (
|
|
380
|
+
<button key={m} data-mode={m} className={rv.galleryMode === m ? 'on' : ''} title={GALLERY_MODE_TITLE[m]} onMouseDown={keepFocus} onClick={() => rv.setGalleryMode(m)}>{m}</button>
|
|
381
|
+
))}
|
|
382
|
+
</span>
|
|
383
|
+
{mode !== 'grid' ? (
|
|
384
|
+
<span className="seg" role="group" aria-label="how a large image fits">
|
|
385
|
+
{GALLERY_FITS.map((f) => (
|
|
386
|
+
<button key={f} data-fit={f} className={rv.galleryFit === f ? 'on' : ''} title={GALLERY_FIT_TITLE[f]} onMouseDown={keepFocus} onClick={() => rv.setGalleryFit(f)}>{`fit ${f}`}</button>
|
|
387
|
+
))}
|
|
388
|
+
</span>
|
|
389
|
+
) : null}
|
|
372
390
|
<span className="seg" role="group" aria-label="which tiles show">
|
|
373
391
|
{TILE_FILTERS.map((f) => (
|
|
374
392
|
<button key={f} className={card.tileFilter === f ? 'on' : ''} onMouseDown={keepFocus} onClick={() => card.setTileFilter(f)}>{TILE_FILTER_LABEL[f]}</button>
|
|
@@ -377,14 +395,63 @@ const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: nu
|
|
|
377
395
|
{befores ? <button className={`rv-chip${card.beforeAll ? ' on' : ''}`} title="every tile shows its before" onMouseDown={keepFocus} onClick={() => card.toggleBeforeAll()}>before</button> : null}
|
|
378
396
|
<button className={`rv-chip${rv.tileSmall ? ' on' : ''}`} title="each tile also at 16, 32 and 64 px" onMouseDown={keepFocus} onClick={() => rv.toggleTileSmall()}>real size</button>
|
|
379
397
|
</div>
|
|
380
|
-
{
|
|
381
|
-
?
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
398
|
+
{mode === 'tabs'
|
|
399
|
+
? <GalleryTabs ver={ver} v={v} view={view} />
|
|
400
|
+
: sections
|
|
401
|
+
? sections.map(({ g, tiles: xs }) => (
|
|
402
|
+
<div key={g} className="rv-galleryrow">
|
|
403
|
+
<div className="rv-rowlabel">{g || 'others'}</div>
|
|
404
|
+
{draw(xs)}
|
|
405
|
+
</div>
|
|
406
|
+
))
|
|
407
|
+
: draw(tiles)}
|
|
408
|
+
</div>
|
|
409
|
+
)
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
const GALLERY_MODE_TITLE: Record<GalleryMode, string> = {
|
|
413
|
+
tabs: 'a list of the images on the left, the picked one large (↑ ↓ in the list walk it)',
|
|
414
|
+
list: 'every image one under the other, at full width',
|
|
415
|
+
grid: 'the images side by side, at the tiles slider\'s height',
|
|
416
|
+
}
|
|
417
|
+
const GALLERY_FIT_TITLE: Record<GalleryFit, string> = { width: 'a large image takes the whole width, and scrolls', screen: 'a large image fits the screen whole' }
|
|
418
|
+
|
|
419
|
+
/** the tabs of a gallery: one row a shown tile (its thumbnail, its name, its stars, its mark's colour), a row per
|
|
420
|
+
* asset name over its variants, and the picked tile drawn large beside them. ↑ ↓ walk the list while it has the
|
|
421
|
+
* focus, and never reach the page, where they walk the cards */
|
|
422
|
+
const GalleryTabs = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: number }) => {
|
|
423
|
+
const { rv, card, cell } = ver
|
|
424
|
+
const id = itemOf(ver).id
|
|
425
|
+
const shown = v.gallery.map((t, k) => ({ t, k, r: card.reactionShown(cell, view, k) })).filter((x) => card.tileShown(x.r))
|
|
426
|
+
const at = shown.find((x) => x.k === card.galleryTab[view]) ?? shown[0]
|
|
427
|
+
if (at === undefined) return <div className="rv-dim rv-small">no image passes this filter</div>
|
|
428
|
+
const step = (by: number): void => {
|
|
429
|
+
const i = shown.indexOf(at)
|
|
430
|
+
card.setGalleryTab(view, shown[(i + by + shown.length) % shown.length]!.k)
|
|
431
|
+
}
|
|
432
|
+
const walk = (e: React.KeyboardEvent): void => {
|
|
433
|
+
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return
|
|
434
|
+
e.preventDefault()
|
|
435
|
+
e.stopPropagation()
|
|
436
|
+
step(e.key === 'ArrowDown' ? 1 : -1)
|
|
437
|
+
}
|
|
438
|
+
return (
|
|
439
|
+
<div className="rv-gtabs">
|
|
440
|
+
<nav className="rv-gtablist" aria-label="the images" onKeyDown={walk}>
|
|
441
|
+
{shown.map(({ t, k, r }, i) => (
|
|
442
|
+
<div key={k} className="rv-gtabslot">
|
|
443
|
+
{t.group && t.group !== shown[i - 1]?.t.group ? <div className="rv-gtabgroup">{t.group}</div> : null}
|
|
444
|
+
<button className={`rv-gtab${k === at.k ? ' on' : ''}${toneClass(r?.status)}`} aria-current={k === at.k} title={t.label} onClick={() => card.setGalleryTab(view, k)}>
|
|
445
|
+
<img src={rv.thumbUrl(id, t.file)} alt="" loading="lazy" draggable={false} />
|
|
446
|
+
<span className="rv-gtablabel">{t.label}</span>
|
|
447
|
+
<span className="rv-gtabmark">{r?.stars ? '★'.repeat(r.stars) : ''}{r?.picked ? ' ✓ kept' : ''}</span>
|
|
448
|
+
</button>
|
|
449
|
+
</div>
|
|
450
|
+
))}
|
|
451
|
+
</nav>
|
|
452
|
+
<div className="rv-gtabbody">
|
|
453
|
+
<Tile key={at.k} ver={ver} v={v} view={view} t={at.t} k={at.k} fill />
|
|
454
|
+
</div>
|
|
388
455
|
</div>
|
|
389
456
|
)
|
|
390
457
|
})
|
|
@@ -401,8 +468,9 @@ const TILE_WIDE = 1.6
|
|
|
401
468
|
const SMALL_SIZES = [16, 32, 64] as const
|
|
402
469
|
|
|
403
470
|
/** one gallery tile: its image (its before while flipped or peeked), the small sizes, its label, stars, the variant
|
|
404
|
-
* pick on a row, OK fix or no and a word; a click shows it large at the column's size
|
|
405
|
-
|
|
471
|
+
* pick on a row, OK fix or no and a word; a click shows it large at the column's size. `fill`: drawn large in the
|
|
472
|
+
* tabs or the list, at the fit he picks (the column's width, or the screen), with no click to shrink it */
|
|
473
|
+
const Tile = observer(({ ver, v, view, t, k, fill = false }: { ver: Ver; v: GalleryView; view: number; t: GalleryTile; k: number; fill?: boolean }) => {
|
|
406
474
|
const { rv, card, cell } = ver
|
|
407
475
|
const id = itemOf(ver).id
|
|
408
476
|
const big = card.bigTile === `${viewKey(id, view)}/${k}`
|
|
@@ -416,13 +484,16 @@ const Tile = observer(({ ver, v, view, t, k }: { ver: Ver; v: GalleryView; view:
|
|
|
416
484
|
const ih = Math.round(iw / ratio)
|
|
417
485
|
const file = t.before && card.showsBefore(view, k) ? t.before : t.file
|
|
418
486
|
const thumb = rv.thumbUrl(id, file)
|
|
419
|
-
const src = big || h > TILE_H.thumb ? rv.fitUrl(id, file) : thumb
|
|
420
|
-
const toggle = (): void => card.toggleTile(id, view, k)
|
|
487
|
+
const src = big || fill || h > TILE_H.thumb ? rv.fitUrl(id, file) : thumb
|
|
488
|
+
const toggle = (): void => { if (!fill) card.toggleTile(id, view, k) }
|
|
489
|
+
const aspect = `${t.size.w} / ${t.size.h}`
|
|
490
|
+
const screen = { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))`, aspectRatio: aspect }
|
|
491
|
+
const imgStyle = fill ? (rv.galleryFit === 'width' ? { width: '100%', aspectRatio: aspect } : screen) : big ? screen : { width: iw, height: ih }
|
|
492
|
+
const title = live ? (fill ? 'drag to circle a spot' : 'drag to circle a spot, click to enlarge') : fill ? undefined : big ? 'click to shrink' : 'click to enlarge'
|
|
421
493
|
return (
|
|
422
|
-
<div className={`rv-tile${big ? ' big' : ''}${r?.picked ? ' picked' : ''}${toneClass(r?.status)}`} style={big ? undefined : { width: Math.max(iw, TILE_MIN_W) + TILE_CHROME }}
|
|
494
|
+
<div className={`rv-tile${big ? ' big' : ''}${fill ? ' fill' : ''}${r?.picked ? ' picked' : ''}${toneClass(r?.status)}`} style={big || fill ? undefined : { width: Math.max(iw, TILE_MIN_W) + TILE_CHROME }}
|
|
423
495
|
onMouseEnter={live ? () => card.setHoverTile({ view, tile: k }) : undefined} onMouseLeave={live ? () => card.setHoverTile(null) : undefined}>
|
|
424
|
-
<div className="rv-tileimg" onClick={live ? undefined : toggle} title={
|
|
425
|
-
style={big ? { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))`, aspectRatio: `${t.size.w} / ${t.size.h}` } : { width: iw, height: ih }}>
|
|
496
|
+
<div className="rv-tileimg" onClick={live ? undefined : toggle} title={title} style={imgStyle}>
|
|
426
497
|
<Marks ver={ver} src={src} side={undefined} view={view} tile={k} onTap={toggle} />
|
|
427
498
|
{ver.live ? <div className="rv-over"><RectNote ver={ver} view={view} sides={[undefined]} tile={k} /></div> : null}
|
|
428
499
|
{t.before ? (
|
|
@@ -120,6 +120,8 @@ export class ThreadSt {
|
|
|
120
120
|
noteFocus: number | null = null
|
|
121
121
|
/** the gallery tile shown large, `<item>#<view>/<tile>` */
|
|
122
122
|
bigTile: string | null = null
|
|
123
|
+
/** the tile each gallery view opens in tabs mode, by view; absent = its first shown tile */
|
|
124
|
+
galleryTab: Record<number, number> = {}
|
|
123
125
|
/** the gallery tile under the pointer of the newest version: 1 to 5 score it */
|
|
124
126
|
hoverTile: { view: number; tile: number } | null = null
|
|
125
127
|
/** which gallery tiles show: all, the ones he has not scored nor marked, under 3 stars, the ones marked fix or no */
|
|
@@ -664,6 +666,10 @@ export class ThreadSt {
|
|
|
664
666
|
}
|
|
665
667
|
}
|
|
666
668
|
|
|
669
|
+
setGalleryTab(view: number, tile: number): void {
|
|
670
|
+
this.galleryTab = { ...this.galleryTab, [view]: tile }
|
|
671
|
+
}
|
|
672
|
+
|
|
667
673
|
toggleTile(id: string, view: number, tile: number): void {
|
|
668
674
|
const k = `${viewKey(id, view)}/${tile}`
|
|
669
675
|
this.bigTile = this.bigTile === k ? null : k
|
|
@@ -33,7 +33,7 @@ export const TrailerPage = observer(({ app }: { app: RepoSt }) => {
|
|
|
33
33
|
</div>
|
|
34
34
|
)
|
|
35
35
|
return (
|
|
36
|
-
<KeptCols id="trailer">
|
|
36
|
+
<KeptCols id="trailer" folds={{ left: 'trailer-cuts', right: 'trailer-notes' }} layout={app.home.layout}>
|
|
37
37
|
<Panel id="trailer-cuts" defaultSize="15%" minSize={190} className="rv-pane" style={PANEL}>
|
|
38
38
|
<div className="rv-scroll"><CutList tr={tr} /></div>
|
|
39
39
|
</Panel>
|
|
@@ -17,6 +17,17 @@
|
|
|
17
17
|
/* ── the columns ── */
|
|
18
18
|
.rv-cols{flex:1;min-height:0}
|
|
19
19
|
.rv-pane{height:100%;min-width:0;display:flex;flex-direction:column}
|
|
20
|
+
.rv-widebody{display:flex}
|
|
21
|
+
.rv-widebody > .pmain{flex:1;min-width:0}
|
|
22
|
+
.rv-foldrow{flex:1;min-height:0;min-width:0;display:flex}
|
|
23
|
+
.rv-foldrow > .rv-cols{flex:1;min-width:0}
|
|
24
|
+
.rv-widebar.right{border-right:0;border-left:1px solid var(--line)}
|
|
25
|
+
.rv-widebar{flex:none;width:16px;height:100%;padding:0;border:0;border-right:1px solid var(--line);border-radius:0;background:var(--panel);cursor:pointer;display:flex;align-items:center;justify-content:center}
|
|
26
|
+
.rv-widebar:hover{background:color-mix(in srgb,var(--accent) 12%,var(--panel))}
|
|
27
|
+
.rv-wideknob{display:flex;align-items:center;justify-content:center;width:12px;height:56px;border-radius:6px;background:color-mix(in srgb,var(--accent) 35%,var(--line));color:var(--fg);font-size:13px;font-weight:700;line-height:1}
|
|
28
|
+
.rv-widebar:hover .rv-wideknob{background:var(--accent);color:var(--bg)}
|
|
29
|
+
.rv-iconbtn.on{background:color-mix(in srgb,var(--accent) 18%,transparent);border-color:var(--accent)}
|
|
30
|
+
.rv-iconbtn.on .hico{color:var(--accent)}
|
|
20
31
|
.rv-scroll{flex:1;min-height:0;overflow-y:auto}
|
|
21
32
|
.rv-dim,.tr-dim{color:var(--dim)}
|
|
22
33
|
.rv-small,.tr-small{font-size:11px}
|
|
@@ -300,6 +311,19 @@ span.rv-react{display:inline-block;border:1px solid;border-radius:4px}
|
|
|
300
311
|
.rv-tile{display:flex;flex-direction:column;gap:var(--s1);padding:var(--s1);border-radius:6px;border:2px solid var(--line)}
|
|
301
312
|
.rv-tile[class*=' re-']{border-color:var(--tone);background:color-mix(in srgb,var(--tone) 8%,transparent)}
|
|
302
313
|
.rv-tile.big{width:100%}
|
|
314
|
+
.rv-tile.fill{width:100%}
|
|
315
|
+
.rv-tile.fill .rv-tileimg{cursor:default}
|
|
316
|
+
.rv-gallerylist{display:flex;flex-direction:column;gap:var(--s2)}
|
|
317
|
+
.rv-gtabs{display:grid;grid-template-columns:minmax(150px,220px) minmax(0,1fr);gap:var(--s2);align-items:start}
|
|
318
|
+
.rv-gtablist{position:sticky;top:0;display:flex;flex-direction:column;gap:2px;max-height:calc(100vh - 160px);overflow:auto;padding-right:2px}
|
|
319
|
+
.rv-gtab{display:grid;grid-template-columns:48px minmax(0,1fr);grid-template-rows:auto auto;column-gap:var(--s1);align-items:center;width:100%;text-align:left;padding:var(--s1);border:1px solid transparent;border-left:3px solid var(--line);border-radius:4px;background:none;cursor:pointer}
|
|
320
|
+
.rv-gtab:hover{background:color-mix(in srgb,var(--fg) 5%,transparent)}
|
|
321
|
+
.rv-gtab.on{background:color-mix(in srgb,var(--accent) 14%,transparent);border-color:var(--accent)}
|
|
322
|
+
.rv-gtab[class*=' re-']{border-left-color:var(--tone)}
|
|
323
|
+
.rv-gtab img{grid-row:span 2;width:48px;height:36px;object-fit:cover;object-position:top;border-radius:2px;background:repeating-conic-gradient(var(--chk1) 0 25%,var(--chk2) 0 50%) 0 0/8px 8px}
|
|
324
|
+
.rv-gtablabel{font-size:12px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
325
|
+
.rv-gtabmark{font-size:10px;color:var(--warn);min-height:12px}
|
|
326
|
+
.rv-gtabgroup{font-weight:600;font-size:11px;margin:var(--s1) 0 2px}
|
|
303
327
|
.rv-tileimg{border-radius:4px;cursor:zoom-in;width:100%;background:repeating-conic-gradient(var(--chk1) 0 25%,var(--chk2) 0 50%) 0 0/12px 12px}
|
|
304
328
|
.rv-tile.big .rv-tileimg{cursor:zoom-out}
|
|
305
329
|
.rv-tileimg img{display:block;width:100%;height:100%;object-fit:contain}
|
|
@@ -49,7 +49,7 @@ export const CommsPage = observer(({ app }: { app: RepoSt }) => {
|
|
|
49
49
|
return (
|
|
50
50
|
<div className="so-page">
|
|
51
51
|
<SocialCalendar so={so} />
|
|
52
|
-
<KeptCols id="comms">
|
|
52
|
+
<KeptCols id="comms" folds={{ left: 'comms-list', right: 'comms-side' }} layout={app.home.layout}>
|
|
53
53
|
<Panel id="comms-list" defaultSize="22%" minSize={240} className="rv-pane" style={PANEL}>
|
|
54
54
|
<DraftsList so={so} />
|
|
55
55
|
</Panel>
|
|
@@ -48,7 +48,7 @@ export const SocialPage = observer(({ app }: { app: RepoSt }) => {
|
|
|
48
48
|
)
|
|
49
49
|
return (
|
|
50
50
|
<div className="so-page">
|
|
51
|
-
<KeptCols id="social">
|
|
51
|
+
<KeptCols id="social" folds={{ left: 'social-list', right: 'social-right' }} layout={app.home.layout}>
|
|
52
52
|
<Panel id="social-list" defaultSize="22%" minSize={240} className="rv-pane" style={PANEL}>
|
|
53
53
|
<IdentityList so={so} />
|
|
54
54
|
</Panel>
|
|
@@ -32,7 +32,7 @@ export const StoresPage = observer(({ app }: { app: RepoSt }) => {
|
|
|
32
32
|
return (
|
|
33
33
|
<>
|
|
34
34
|
<Toast so={so} />
|
|
35
|
-
<KeptCols id="stores">
|
|
35
|
+
<KeptCols id="stores" folds={{ left: 'stores-list', right: 'stores-pictures' }} layout={app.home.layout}>
|
|
36
36
|
<Panel id="stores-list" defaultSize="20%" minSize={220} className="rv-pane" style={PANEL}>
|
|
37
37
|
<div className="rv-scroll"><StoreList so={so} /></div>
|
|
38
38
|
</Panel>
|
|
@@ -66,7 +66,7 @@ export const VeillePage = observer(({ app }: { app: RepoSt }) => {
|
|
|
66
66
|
return (
|
|
67
67
|
<>
|
|
68
68
|
<Toast v={v} />
|
|
69
|
-
<KeptCols id="veille">
|
|
69
|
+
<KeptCols id="veille" folds={{}} layout={app.home.layout}>
|
|
70
70
|
<Panel id="veille-deck" defaultSize="72%" minSize={480} className="rv-pane" style={PANEL}>
|
|
71
71
|
<Deck v={v} />
|
|
72
72
|
</Panel>
|
package/src/shot/box.ts
CHANGED
|
@@ -15,7 +15,12 @@ import { CDP_PORT } from './film-box.ts'
|
|
|
15
15
|
|
|
16
16
|
/** the slice of playwright the route drives: a browser to connect to, its default context, a page's viewport */
|
|
17
17
|
type PwPage = { setViewportSize(v: { width: number; height: number }): Promise<void>; addInitScript(s: { content: string }): Promise<void>; close(): Promise<void> }
|
|
18
|
-
type PwContext = {
|
|
18
|
+
type PwContext = {
|
|
19
|
+
newPage(): Promise<PwPage>
|
|
20
|
+
newCDPSession(p: PwPage): Promise<{ send(m: string, p?: Record<string, unknown>): Promise<unknown> }>
|
|
21
|
+
cookies(): Promise<unknown[]>
|
|
22
|
+
addCookies(c: unknown[]): Promise<void>
|
|
23
|
+
}
|
|
19
24
|
export type PwBrowser = { contexts(): PwContext[]; close(): Promise<void>; isConnected(): boolean; on(e: 'disconnected', cb: () => void): void }
|
|
20
25
|
export type Pw = { chromium: { launch(o: { headless: boolean; args: string[] }): Promise<unknown>; connectOverCDP(url: string): Promise<PwBrowser> } }
|
|
21
26
|
|
|
@@ -98,6 +103,9 @@ function asLaunched(b: PwBrowser, all: PwPage[]) {
|
|
|
98
103
|
return p
|
|
99
104
|
},
|
|
100
105
|
newCDPSession: (p: PwPage) => ctx.newCDPSession(p),
|
|
106
|
+
// the one default context holds every page's cookies already
|
|
107
|
+
cookies: () => ctx.cookies(),
|
|
108
|
+
addCookies: async () => undefined,
|
|
101
109
|
async addInitScript(s: { content: string }) {
|
|
102
110
|
scripts.push(s.content)
|
|
103
111
|
for (const p of pages) await p.addInitScript(s)
|
package/src/shot/shooter.ts
CHANGED
|
@@ -55,7 +55,16 @@ export async function consoleWords(m: { args?(): { jsonValue(): Promise<unknown>
|
|
|
55
55
|
return null
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
/** a cookie as playwright reads and writes it */
|
|
59
|
+
type Cookie = { name: string; value: string; domain: string; path: string } & Record<string, unknown>
|
|
60
|
+
type Context = {
|
|
61
|
+
newPage(): Promise<Page>
|
|
62
|
+
newCDPSession(p: Page): Promise<Cdp>
|
|
63
|
+
addInitScript(s: { content: string }): Promise<void>
|
|
64
|
+
cookies(): Promise<Cookie[]>
|
|
65
|
+
addCookies(c: Cookie[]): Promise<void>
|
|
66
|
+
close(): Promise<void>
|
|
67
|
+
}
|
|
59
68
|
export type Browser = {
|
|
60
69
|
newContext(o: { viewport: { width: number; height: number }; deviceScaleFactor: number; locale?: string }): Promise<Context>
|
|
61
70
|
close(): Promise<void>
|
|
@@ -111,6 +120,9 @@ export class Shooter {
|
|
|
111
120
|
/** before a page goes to a url: the box route forwards this machine's localhost port to the box */
|
|
112
121
|
#reach: (url: string) => Promise<void> = async () => undefined
|
|
113
122
|
#slot: Slot | null = null
|
|
123
|
+
/** the cookies a closed context held, given to the next one: a sign in survives a shot at another viewport, a
|
|
124
|
+
* clip and the idle close. Memory only, never on disk */
|
|
125
|
+
#jar: Cookie[] = []
|
|
114
126
|
#idle: ReturnType<typeof setTimeout> | null = null
|
|
115
127
|
#live: ReturnType<typeof setTimeout> | null = null
|
|
116
128
|
|
|
@@ -138,13 +150,19 @@ export class Shooter {
|
|
|
138
150
|
async close(): Promise<void> {
|
|
139
151
|
if (this.#idle) clearTimeout(this.#idle)
|
|
140
152
|
if (this.#live) clearTimeout(this.#live)
|
|
153
|
+
const s = this.#slot
|
|
141
154
|
this.#slot = null
|
|
155
|
+
if (s) await this.#keep(s.ctx)
|
|
142
156
|
const b = this.#browser
|
|
143
157
|
this.#browser = null
|
|
144
158
|
await b?.close().catch(() => undefined)
|
|
145
159
|
this.#free()
|
|
146
160
|
}
|
|
147
161
|
|
|
162
|
+
async #keep(ctx: Context): Promise<void> {
|
|
163
|
+
this.#jar = await ctx.cookies().catch(() => this.#jar)
|
|
164
|
+
}
|
|
165
|
+
|
|
148
166
|
#free(): void {
|
|
149
167
|
const held = this.#held
|
|
150
168
|
this.#held = null
|
|
@@ -198,7 +216,9 @@ export class Shooter {
|
|
|
198
216
|
|
|
199
217
|
async #context(a: ShotAsk): Promise<Context> {
|
|
200
218
|
const b = await this.#ensureBrowser()
|
|
201
|
-
|
|
219
|
+
const ctx = await b.newContext({ viewport: a.viewport, deviceScaleFactor: a.dpr, locale: 'en-US' })
|
|
220
|
+
if (this.#jar.length > 0) await ctx.addCookies(this.#jar)
|
|
221
|
+
return ctx
|
|
202
222
|
}
|
|
203
223
|
|
|
204
224
|
static #listen(page: Page, errors: string[]): void {
|
|
@@ -224,6 +244,7 @@ export class Shooter {
|
|
|
224
244
|
if (move === 'boot') {
|
|
225
245
|
const old = this.#slot
|
|
226
246
|
this.#slot = null
|
|
247
|
+
if (old) await this.#keep(old.ctx)
|
|
227
248
|
await old?.ctx.close().catch(() => undefined)
|
|
228
249
|
const t = performance.now()
|
|
229
250
|
const ctx = await this.#context(a)
|
|
@@ -330,6 +351,7 @@ export class Shooter {
|
|
|
330
351
|
const note = `${d.frames} frames ${d.width}x${d.height} at ${a.fps} fps ${how}, canvas ${d.canvasOfViewport}, ${mb} MB H.264 from the page's WebCodecs, muxed`
|
|
331
352
|
return { out: a.out, ms: ms(t0), phases, errors, note, ...stepped }
|
|
332
353
|
} finally {
|
|
354
|
+
await this.#keep(ctx)
|
|
333
355
|
await ctx.close().catch(() => undefined)
|
|
334
356
|
}
|
|
335
357
|
}
|
package/src/social/load.ts
CHANGED
|
@@ -121,6 +121,8 @@ const read = (abs: string): string => readFileSync(abs, 'utf8')
|
|
|
121
121
|
|
|
122
122
|
/** the group whose messages need a compiled 9:16 video */
|
|
123
123
|
export const VERTICAL = 'vertical'
|
|
124
|
+
/** the contract's two formats: always a heading a draft may use, even before the identity has an account in them */
|
|
125
|
+
const FORMATS = ['short', VERTICAL] as const
|
|
124
126
|
/** the name of a compiled vertical video */
|
|
125
127
|
export const VERTICAL_FILE = /-vertical\.mp4$/
|
|
126
128
|
|
|
@@ -208,7 +210,7 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
|
|
|
208
210
|
}
|
|
209
211
|
named.add(speaker.id)
|
|
210
212
|
const accounts = identities.find((i) => i.id === speaker.id)!.accounts
|
|
211
|
-
const groups = new Map([...new Set(accounts.map((a) => a.group).filter((g) => g !== ''))].map((g) => [g, accounts.filter((a) => a.group === g).map((a) => a.id)]))
|
|
213
|
+
const groups = new Map([...new Set([...FORMATS, ...accounts.map((a) => a.group).filter((g) => g !== '')])].map((g) => [g, accounts.filter((a) => a.group === g).map((a) => a.id)]))
|
|
212
214
|
const d = parseDraft(raw, file, groups)
|
|
213
215
|
errors.push(...d.errors)
|
|
214
216
|
const media = new Map<string, Media>()
|
package/src/trailer/grammar.ts
CHANGED
|
@@ -212,6 +212,8 @@ export interface SoundGen {
|
|
|
212
212
|
export interface SoundRun {
|
|
213
213
|
cmd: string
|
|
214
214
|
reads?: string[]
|
|
215
|
+
/** the work runs on another machine (ElevenLabs, the comfy box): it never waits on this machine's load */
|
|
216
|
+
remote?: true
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
export interface Sfx {
|
|
@@ -53,14 +53,14 @@ export function presetOf(a: SoundAsk, brand: TrailerSoundInput | undefined): Sou
|
|
|
53
53
|
if (a.kind === 'voice') {
|
|
54
54
|
const voice = voiceOf(brand, a.by)
|
|
55
55
|
const v = voiceFlags(voice)
|
|
56
|
-
return { cmd: ['sk sound voice', q(a.text), ...v.flags, ...('eleven' in voice ? [] : comfy), ...seed, '--out {out}'].join(' '), ...(v.reads.length ? { reads: v.reads } : {}) }
|
|
56
|
+
return { cmd: ['sk sound voice', q(a.text), ...v.flags, ...('eleven' in voice ? [] : comfy), ...seed, '--out {out}'].join(' '), ...(v.reads.length ? { reads: v.reads } : {}), remote: true }
|
|
57
57
|
}
|
|
58
|
-
if (a.kind === 'sfx') return { cmd: ['sk sound sfx', q(a.text), '--seconds', num(a.for ?? SFX_SECONDS), ...seed, ...(a.hit ? ['--hit'] : []), ...comfy, '--out {out}'].join(' ') }
|
|
58
|
+
if (a.kind === 'sfx') return { cmd: ['sk sound sfx', q(a.text), '--seconds', num(a.for ?? SFX_SECONDS), ...seed, ...(a.hit ? ['--hit'] : []), ...comfy, '--out {out}'].join(' '), remote: true }
|
|
59
59
|
// the soundfont and fluidsynth are in the words as a comment: another one renders the file again
|
|
60
60
|
if (isMidi(a.text)) return { cmd: `sk sound midi ${q(a.text)} --out {out} # fluid ${new Bun.CryptoHasher('sha1').update(fluidIdentity()).digest('hex').slice(0, 12)}`, reads: [a.text] }
|
|
61
61
|
const engine = a.by ?? 'stable-audio'
|
|
62
62
|
if (!(MUSIC_ENGINES as readonly string[]).includes(engine)) throw new Error(`music by ${engine}: the engines are ${MUSIC_ENGINES.join(', ')}`)
|
|
63
|
-
return { cmd: ['sk sound music', q(a.text), '--engine', engine, '--seconds', num(a.for ?? musicSeconds(a.seconds)), ...seed, ...comfy, '--out {out}'].join(' ') }
|
|
63
|
+
return { cmd: ['sk sound music', q(a.text), '--engine', engine, '--seconds', num(a.for ?? musicSeconds(a.seconds)), ...seed, ...comfy, '--out {out}'].join(' '), remote: true }
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/** a paid run: the characters its line costs, else null */
|
package/src/trailer/sound/run.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// THE one way a trailer makes a sound: a command that writes `{out}`, cached on its words and the content of each file
|
|
2
2
|
// it reads. A voice, an sfx, a music bed and a MIDI file are presets of it (presets.ts). The cache is
|
|
3
3
|
// `.shipkit/cache/sound/<key>.wav` with `<key>.json` (the command, its measures) and `<key>.png` (its waveform), out of
|
|
4
|
-
// the trailer's cache so a trailer prune never deletes a paid line. One sound is made at a time, under nice,
|
|
5
|
-
//
|
|
4
|
+
// the trailer's cache so a trailer prune never deletes a paid line. One sound is made at a time, under nice, and one
|
|
5
|
+
// that loads this machine (not `remote`) never starts while its load is over 16
|
|
6
6
|
import { closeSync, existsSync, mkdirSync, mkdtempSync, openSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from 'node:fs'
|
|
7
7
|
import { loadavg } from 'node:os'
|
|
8
8
|
import { join, relative, resolve } from 'node:path'
|
|
@@ -55,7 +55,7 @@ let queue: Promise<unknown> = Promise.resolve()
|
|
|
55
55
|
export function soundRun(r: SoundRun, p: RunPlace, say: (line: string) => void): Promise<{ file: string; made: boolean }> {
|
|
56
56
|
const spec = runSpec(r, p)
|
|
57
57
|
if (existsSync(spec.file)) return Promise.resolve({ file: spec.file, made: false })
|
|
58
|
-
const job = queue.then(() => make(spec, p.root, say))
|
|
58
|
+
const job = queue.then(() => make(spec, p.root, r.remote === true, say))
|
|
59
59
|
queue = job.catch(() => undefined)
|
|
60
60
|
return job
|
|
61
61
|
}
|
|
@@ -105,12 +105,12 @@ async function lockSound(spec: ReturnType<typeof runSpec>, say: (line: string) =
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
async function make(spec: ReturnType<typeof runSpec>, root: string, say: (line: string) => void): Promise<{ file: string; made: boolean }> {
|
|
108
|
+
async function make(spec: ReturnType<typeof runSpec>, root: string, remote: boolean, say: (line: string) => void): Promise<{ file: string; made: boolean }> {
|
|
109
109
|
mkdirSync(soundCache(root), { recursive: true })
|
|
110
110
|
const unlock = await lockSound(spec, say)
|
|
111
111
|
if (!unlock) return { file: spec.file, made: false }
|
|
112
112
|
try {
|
|
113
|
-
return await makeLocked(spec, root, say)
|
|
113
|
+
return await makeLocked(spec, root, remote, say)
|
|
114
114
|
} finally {
|
|
115
115
|
unlock()
|
|
116
116
|
}
|
|
@@ -134,27 +134,35 @@ export function killGroup(pid: number): void {
|
|
|
134
134
|
setTimeout(() => kill('SIGKILL'), 5000).unref()
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
const
|
|
137
|
+
const swept = new Set<string>()
|
|
138
|
+
let calm: Promise<void> | null = null
|
|
138
139
|
|
|
139
|
-
/** once per process and repo, before the first sound it makes: the folders killed makes left swept
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
/** once per process and repo, before the first sound it makes: the folders killed makes left swept */
|
|
141
|
+
function sweep(root: string): void {
|
|
142
|
+
if (swept.has(root)) return
|
|
143
|
+
swept.add(root)
|
|
142
144
|
const cache = soundCache(root)
|
|
143
145
|
for (const e of readdirSync(cache)) {
|
|
144
146
|
const f = join(cache, e)
|
|
145
147
|
if (e.startsWith('.make-') && Date.now() - statSync(f).mtimeMs > STALE_MAKE_MS) rmSync(f, { recursive: true, force: true })
|
|
146
148
|
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** once per process, before the first sound that loads this machine: a wait while its load is over 16 */
|
|
152
|
+
async function waitCalm(say: (line: string) => void): Promise<void> {
|
|
147
153
|
for (let waited = 0; loadavg()[0]! > 16; waited += 5) {
|
|
148
|
-
if (waited === 0) say(`sound: the load is ${loadavg()[0]!.toFixed(1)}, over 16: waiting before the first sound`)
|
|
154
|
+
if (waited === 0) say(`sound: the load is ${loadavg()[0]!.toFixed(1)}, over 16: waiting before the first local sound`)
|
|
149
155
|
if (waited > 600) throw new Error('sound: the load stayed over 16 for 10 minutes')
|
|
150
156
|
await Bun.sleep(5000)
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
|
|
154
|
-
async function makeLocked(spec: ReturnType<typeof runSpec>, root: string, say: (line: string) => void): Promise<{ file: string; made: boolean }> {
|
|
155
|
-
|
|
156
|
-
if (!
|
|
157
|
-
|
|
160
|
+
async function makeLocked(spec: ReturnType<typeof runSpec>, root: string, remote: boolean, say: (line: string) => void): Promise<{ file: string; made: boolean }> {
|
|
161
|
+
sweep(root)
|
|
162
|
+
if (!remote) {
|
|
163
|
+
calm ??= waitCalm(say)
|
|
164
|
+
await calm
|
|
165
|
+
}
|
|
158
166
|
const dir = mkdtempSync(join(soundCache(root), '.make-'))
|
|
159
167
|
try {
|
|
160
168
|
const out = join(dir, 'out.wav')
|
package/src/trailer/titles.ts
CHANGED
|
@@ -401,7 +401,7 @@ function drawInto(g: SKRSContext2D, d: TitleDraw, [W, H]: readonly [number, numb
|
|
|
401
401
|
// a strong display line in the upper third: light words in a thick edge outline, an accent stroke inside it
|
|
402
402
|
const p = own({ ...base((d.fx?.size ?? 112) * k, 900), outline: { w: 22 * k, color: look.edge }, inner: { w: 8 * k, color: look.accent }, shadow: { blur: 26 * k, dy: 10 * k, color: alpha(look.edge, 0.55) } })
|
|
403
403
|
setFace(g, p)
|
|
404
|
-
const lines = wrap(g,
|
|
404
|
+
const lines = wrap(g, text, W * 0.82)
|
|
405
405
|
lines.forEach((l, i) => ink(cx, g, p, l, W / 2, H * 0.26 + (i - (lines.length - 1) / 2) * p.px * 1.12))
|
|
406
406
|
} else if (style === 'line') {
|
|
407
407
|
// a tagline: light words centred low on a soft dark band, no plate, the frame stays the picture
|
package/src/wiki/lint-md.ts
CHANGED
|
@@ -12,9 +12,11 @@ export type MdLintReport = {
|
|
|
12
12
|
ok: boolean
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/** `listedElsewhere`: pages another wiki's index lists (scan-root relative), never an orphan here */
|
|
16
|
+
export function lintMd(cfg: ScanMdConfig & { listedElsewhere?: string[] }): MdLintReport {
|
|
16
17
|
const scan = scanMd(cfg)
|
|
17
|
-
const
|
|
18
|
+
const elsewhere = new Set(cfg.listedElsewhere ?? [])
|
|
19
|
+
const orphans = scan.index == null ? [] : scan.graph.nodes.filter((n) => n.depth == null && !elsewhere.has(n.id)).map((n) => n.id)
|
|
18
20
|
return {
|
|
19
21
|
index: scan.index,
|
|
20
22
|
files: scan.graph.nodes.length,
|
package/src/wiki/run-wiki.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// clipanion owns the option parsing.
|
|
4
4
|
import { existsSync } from 'fs'
|
|
5
5
|
import { basename, join, relative, resolve } from 'path'
|
|
6
|
-
import { agentDirAt } from '../core/agent-dir-at.ts'
|
|
6
|
+
import { agentDirAt, contributionFileAt } from '../core/agent-dir-at.ts'
|
|
7
7
|
import { lintMd } from './lint-md.ts'
|
|
8
8
|
import { scanMdGraph } from './scan-md.ts'
|
|
9
9
|
import { serveMdGraph } from './serve-graph.ts'
|
|
@@ -11,6 +11,8 @@ import { serveMdGraph } from './serve-graph.ts'
|
|
|
11
11
|
export type WikiScanOpts = {
|
|
12
12
|
/** default: the repo's wiki, as the hub mounts it (`wiki/`, else the agent folder, else the cwd) */
|
|
13
13
|
root?: string
|
|
14
|
+
/** the repo the command runs in, default the process's cwd */
|
|
15
|
+
cwd?: string
|
|
14
16
|
index?: string
|
|
15
17
|
skip?: string
|
|
16
18
|
/** where the verdict goes. The command passes its own stream, so the
|
|
@@ -27,7 +29,7 @@ export function defaultWikiRoot(cwd: string): string {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const scanConfig = (o: WikiScanOpts): { root: string; index?: string; skipDirs?: string[] } => ({
|
|
30
|
-
root: resolve(process.cwd(), o.root ?? defaultWikiRoot(process.cwd())),
|
|
32
|
+
root: resolve(o.cwd ?? process.cwd(), o.root ?? defaultWikiRoot(o.cwd ?? process.cwd())),
|
|
31
33
|
index: o.index,
|
|
32
34
|
skipDirs: o.skip?.split(',').filter(Boolean),
|
|
33
35
|
})
|
|
@@ -35,8 +37,9 @@ const scanConfig = (o: WikiScanOpts): { root: string; index?: string; skipDirs?:
|
|
|
35
37
|
export async function runWikiServe(o: WikiScanOpts & { port: number; title?: string }): Promise<number> {
|
|
36
38
|
const say = o.print ?? console.log
|
|
37
39
|
const cfg = scanConfig(o)
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
+
const cwd = o.cwd ?? process.cwd()
|
|
41
|
+
const rel = relative(cwd, cfg.root)
|
|
42
|
+
const title = o.title ?? (rel === '' ? basename(cfg.root) : `${basename(cwd)} ${rel}`)
|
|
40
43
|
try {
|
|
41
44
|
serveMdGraph({ port: o.port, title, root: cfg.root, load: () => scanMdGraph(cfg) })
|
|
42
45
|
say(`wiki graph → http://localhost:${o.port} (open in browser, or VSCode "Simple Browser: Show")`)
|
|
@@ -55,7 +58,10 @@ export async function runWikiServe(o: WikiScanOpts & { port: number; title?: str
|
|
|
55
58
|
export function runWikiLint(o: WikiScanOpts): number {
|
|
56
59
|
const say = o.print ?? console.log
|
|
57
60
|
const cfg = scanConfig(o)
|
|
58
|
-
|
|
61
|
+
// the global contribution is listed by the house index (SK033), never by agent/'s own
|
|
62
|
+
const cwd = o.cwd ?? process.cwd()
|
|
63
|
+
const contribution = relative(cfg.root, resolve(cwd, contributionFileAt(cwd)))
|
|
64
|
+
const r = lintMd({ ...cfg, listedElsewhere: contribution.startsWith('..') ? [] : [contribution] })
|
|
59
65
|
if (r.index == null) {
|
|
60
66
|
say(o.index != null
|
|
61
67
|
? `FAIL entrypoint '${o.index}' not found in ${cfg.root}`
|
package/src/wiki/scan-md.ts
CHANGED
|
@@ -61,7 +61,9 @@ function scanMdNow(cfg: ScanMdConfig): MdScan {
|
|
|
61
61
|
const walk = (rel: string) => {
|
|
62
62
|
for (const e of readdirSync(join(cfg.root, rel))) {
|
|
63
63
|
const r = rel === '' ? e : `${rel}/${e}`
|
|
64
|
-
|
|
64
|
+
const st = statSync(join(cfg.root, r), { throwIfNoEntry: false })
|
|
65
|
+
if (st == null) continue // a link to nothing (a deploy stage's gone target)
|
|
66
|
+
if (st.isDirectory()) {
|
|
65
67
|
if (!skip.has(e) && !e.startsWith('.') && !vendored.has(join(cfg.root, r))) walk(r)
|
|
66
68
|
} else if (e.endsWith('.md')) files.push(r)
|
|
67
69
|
}
|