rvlib-shipkit 2.16.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 +21 -0
- package/package.json +1 -1
- package/src/assets/kit-config.ts +19 -1
- package/src/assets/run-assets.ts +18 -0
- package/src/cli/cmd_Review.ts +26 -7
- package/src/cli/cmd_Secret.ts +127 -0
- package/src/cli/cmd_Wiki.ts +4 -4
- package/src/cli/family-pages.ts +1 -0
- package/src/cli/registry.ts +4 -0
- package/src/core/discover-checks.ts +18 -5
- package/src/core/scope.ts +42 -0
- 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/repo-config.ts +3 -0
- package/src/review/auto.ts +7 -2
- package/src/review/cells.ts +1 -1
- package/src/review/format.ts +2 -2
- package/src/review/model.ts +57 -13
- package/src/review/previews.ts +1 -1
- package/src/review/routes.ts +11 -0
- package/src/review/store.ts +18 -10
- package/src/secrets/list.ts +40 -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 +12 -0
- package/src/serve/hub-app/review/review-page.tsx +1 -1
- package/src/serve/hub-app/review/review-st.ts +63 -4
- package/src/serve/hub-app/review/review-thread.tsx +1 -0
- package/src/serve/hub-app/review/review-views.tsx +215 -63
- package/src/serve/hub-app/review/thread-st.ts +82 -16
- package/src/serve/hub-app/review/trailer-page.tsx +1 -1
- package/src/serve/hub-app/review.css +41 -2
- 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/shipkit.ts +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 +22 -6
- package/src/wiki/scan-md.ts +3 -1
package/src/review/auto.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// auto rules (wiki tools/shipkit/review.md, A project's parts): a rule of the repo's review unit answers on a clock, and
|
|
2
2
|
// its answer is raised as an item to a lane, open from the start. One open item a rule and key. The hub's daemon runs
|
|
3
3
|
// them (startAuto), `sk review auto` reads their logs and runs one now
|
|
4
|
-
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
5
5
|
import { join } from 'node:path'
|
|
6
6
|
import { stateOf, type ReviewItem } from './model.ts'
|
|
7
7
|
import { raiseItem } from './store.ts'
|
|
@@ -26,6 +26,10 @@ export interface AutoLog {
|
|
|
26
26
|
/** the logs sit beside the store, out of its watch */
|
|
27
27
|
export const autoLogDir = (dir: string): string => join(dir, '..', 'review-auto')
|
|
28
28
|
|
|
29
|
+
/** the repo a store dir lives in (`<repo>/.shipkit/review`): a run never writes into a repo that moved away, so nothing
|
|
30
|
+
* recreates its old folder */
|
|
31
|
+
const repoOf = (dir: string): string => join(dir, '..', '..')
|
|
32
|
+
|
|
29
33
|
export function readAutoLog(dir: string, id: string): AutoLog | null {
|
|
30
34
|
try {
|
|
31
35
|
return JSON.parse(readFileSync(join(autoLogDir(dir), `${id}.json`), 'utf8')) as AutoLog
|
|
@@ -64,6 +68,7 @@ const answerText = (outcomes: readonly Outcome[]): string =>
|
|
|
64
68
|
/** one rule evaluated now: its raises written as items, unless an open one holds the key; `dry` writes nothing, the log
|
|
65
69
|
* included. A rule that throws is logged and rethrown */
|
|
66
70
|
export async function runRule(dir: string, rule: AutoRule, o: { items: readonly ReviewItem[]; now?: Date; dry?: boolean }): Promise<Outcome[]> {
|
|
71
|
+
if (!existsSync(repoOf(dir))) throw new Error(`${repoOf(dir)} is gone (moved or renamed): rule ${rule.id} writes nothing there`)
|
|
67
72
|
const now = o.now ?? new Date()
|
|
68
73
|
const before = readAutoLog(dir, rule.id)
|
|
69
74
|
const t0 = performance.now()
|
|
@@ -123,7 +128,7 @@ export function startAuto(dir: string, rules: readonly AutoRule[], items: () =>
|
|
|
123
128
|
for (const rule of rules) {
|
|
124
129
|
const tick = (): void =>
|
|
125
130
|
void autoTick(dir, rule, items).then(() => {
|
|
126
|
-
if (stopped) return
|
|
131
|
+
if (stopped || !existsSync(repoOf(dir))) return
|
|
127
132
|
const t = setTimeout(tick, everyMs(rule.every))
|
|
128
133
|
t.unref()
|
|
129
134
|
timers.add(t)
|
package/src/review/cells.ts
CHANGED
|
@@ -474,7 +474,7 @@ function rowOf(t: Thread, items: readonly ReviewItem[], followed: ReadonlySet<st
|
|
|
474
474
|
views: h.item.views.length,
|
|
475
475
|
thumb: first ? thumbFileOf(first) || null : null,
|
|
476
476
|
clip: h.item.views.some((v) => !isGallery(v) && v.clip !== undefined),
|
|
477
|
-
pair: first !== undefined && isPair(first.files),
|
|
477
|
+
pair: first !== undefined && !isGallery(first) && isPair(first.files),
|
|
478
478
|
choice: h.item.choice === true,
|
|
479
479
|
wip: h.item.wip !== undefined,
|
|
480
480
|
waits: waits(h),
|
package/src/review/format.ts
CHANGED
|
@@ -19,7 +19,7 @@ const atText = (t: number | undefined): string => (t === undefined ? '' : ` at $
|
|
|
19
19
|
|
|
20
20
|
/** each reaction to one view or tile: its place by label, its status, its comment */
|
|
21
21
|
const reactionTexts = (x: ReviewItem): string[] =>
|
|
22
|
-
(verdictOf(x)?.reactions ?? []).map((q) => `${placeText(q, x.item.views)}${q.status ? ` ${q.status}` : ''}${q.stars ? ` ★${q.stars}` : ''}${q.comment ? `: ${flat(q.comment)}` : ''}`)
|
|
22
|
+
(verdictOf(x)?.reactions ?? []).map((q) => `${placeText(q, x.item.views)}${q.picked ? ' picked' : ''}${q.status ? ` ${q.status}` : ''}${q.stars ? ` ★${q.stars}` : ''}${q.comment ? `: ${flat(q.comment)}` : ''}`)
|
|
23
23
|
|
|
24
24
|
/** the view he picked on a choice card, `picked [voice 1]`; null when he picked none */
|
|
25
25
|
const pickText = (x: ReviewItem): string | null => {
|
|
@@ -33,7 +33,7 @@ export function line(x: ReviewItem): string {
|
|
|
33
33
|
if (!f) return x.item.id
|
|
34
34
|
const views = x.item.views
|
|
35
35
|
const many = views.length > 1
|
|
36
|
-
const rects = f.rects.map((q, i) => `#${i + 1}${many ? ` ${placeText(q, views)}` : ''}${q.side ? ` ${q.side}` : ''}${atText(q.t)} ${flat(q.comment) || '(no comment)'}`)
|
|
36
|
+
const rects = f.rects.map((q, i) => `#${i + 1}${many || q.tile !== undefined ? ` ${placeText(q, views)}` : ''}${q.side ? ` ${q.side}` : ''}${atText(q.t)} ${flat(q.comment) || '(no comment)'}`)
|
|
37
37
|
const pick = pickText(x)
|
|
38
38
|
const parts = [...(pick ? [pick] : []), ...reactionTexts(x), ...rects]
|
|
39
39
|
return `${x.item.id} ${f.status} "${x.item.title}": ${flat(f.comment) || '(no overall comment)'}${parts.length ? ` | ${parts.join(' | ')}` : ''}`
|
package/src/review/model.ts
CHANGED
|
@@ -153,9 +153,16 @@ export interface GalleryTile {
|
|
|
153
153
|
file: string
|
|
154
154
|
label: string
|
|
155
155
|
size: { w: number; h: number }
|
|
156
|
+
/** the asset as it was, `v<n>-g<k>-before.<ext>`: the tile shows the after, the before on a peek */
|
|
157
|
+
before?: string
|
|
158
|
+
/** the row it is a variant in: one asset per row, he picks at most one tile of a row */
|
|
159
|
+
group?: string
|
|
156
160
|
}
|
|
157
161
|
|
|
158
|
-
/** a
|
|
162
|
+
/** a tile's name in the CLI's lines: `vitality/b` for a variant, else its label */
|
|
163
|
+
export const tileName = (t: GalleryTile): string => (t.group ? `${t.group}/${t.label}` : t.label)
|
|
164
|
+
|
|
165
|
+
/** a view that is a list of small images, shown as a wrapping grid, or as rows of variants when its tiles name a group */
|
|
159
166
|
export interface GalleryView {
|
|
160
167
|
label: string
|
|
161
168
|
gallery: GalleryTile[]
|
|
@@ -180,7 +187,7 @@ export interface Item {
|
|
|
180
187
|
what?: string
|
|
181
188
|
topic?: string
|
|
182
189
|
commit?: string
|
|
183
|
-
/**
|
|
190
|
+
/** a media view (an image, a clip, a sound, a pair) or a gallery of images, any of them first */
|
|
184
191
|
views: ReviewView[]
|
|
185
192
|
/** an earlier card this one is a new version of; never a raised item */
|
|
186
193
|
supersedes?: string
|
|
@@ -252,13 +259,13 @@ export const viewName = (v: ReviewView | undefined, i: number): string => v?.lab
|
|
|
252
259
|
/** every media file a card's views name: images, pairs, clips and their posters, sounds and their waveforms, tiles */
|
|
253
260
|
export function viewFilesOf(i: Item): string[] {
|
|
254
261
|
return i.views.flatMap((v) => {
|
|
255
|
-
if (isGallery(v)) return v.gallery.
|
|
262
|
+
if (isGallery(v)) return v.gallery.flatMap((g) => [g.file, ...(g.before ? [g.before] : [])])
|
|
256
263
|
return [...Object.values(v.files), ...(v.clip ? [v.clip.poster] : []), ...(v.audio ? [v.audio.wave, ...(v.audio.waveBefore ? [v.audio.waveBefore] : [])] : [])]
|
|
257
264
|
})
|
|
258
265
|
}
|
|
259
266
|
|
|
260
|
-
/** the first view
|
|
261
|
-
export const firstView = (i: Item):
|
|
267
|
+
/** the first view: media or a gallery; a note with no image has none */
|
|
268
|
+
export const firstView = (i: Item): ReviewView | undefined => i.views[0]
|
|
262
269
|
|
|
263
270
|
/** the file that stands for a view in a list: a clip's first frame, the after of a pair, the image */
|
|
264
271
|
export function thumbFileOf(v: ReviewView): string {
|
|
@@ -286,6 +293,8 @@ export interface Rect {
|
|
|
286
293
|
side?: Side
|
|
287
294
|
/** the clip time it was drawn at, in seconds */
|
|
288
295
|
t?: number
|
|
296
|
+
/** the gallery tile it is drawn on, its coordinates the tile's image */
|
|
297
|
+
tile?: number
|
|
289
298
|
world?: { x0: number; y0: number; x1: number; y1: number }
|
|
290
299
|
nodes?: string[]
|
|
291
300
|
}
|
|
@@ -305,6 +314,8 @@ export interface ReviewReaction {
|
|
|
305
314
|
comment: string
|
|
306
315
|
/** his score of the view, 1 to STARS */
|
|
307
316
|
stars?: number
|
|
317
|
+
/** a variant tile he keeps for its row: at most one a row */
|
|
318
|
+
picked?: true
|
|
308
319
|
}
|
|
309
320
|
|
|
310
321
|
/** a state change, or a read mark (`seen`, with the ids it read in `of`) */
|
|
@@ -647,6 +658,17 @@ export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
|
|
|
647
658
|
/** the live watchers that will read his answer on any of these cards */
|
|
648
659
|
export const listenersOf = (cards: readonly ReviewItem[], watchers: readonly Watcher[]): Watcher[] => watchers.filter((w) => cards.some((x) => coversCard(w, x)))
|
|
649
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
|
+
|
|
650
672
|
/** a card's own session has this long after its last message to claim it before a watch calls it untaken */
|
|
651
673
|
export const UNTAKEN_GRACE_MS = 2 * 60 * 1000
|
|
652
674
|
/** a card nobody takes is told again this often */
|
|
@@ -668,7 +690,7 @@ export function untakenOf(x: ReviewItem, superseded: boolean, watchers: readonly
|
|
|
668
690
|
}
|
|
669
691
|
|
|
670
692
|
export const ID_RE = /^\d{8}-\d{6}-[a-z0-9-]+$/
|
|
671
|
-
export const FILE_RE = /^((v\d+-)?((image|before|after|poster|wave|before-wave)\.(png|jpe?g|webp)|(video|before|after)\.(webm|mp4)|(audio|before|after)\.(wav|mp3|flac|ogg|opus|m4a))|v\d+-g\d
|
|
693
|
+
export const FILE_RE = /^((v\d+-)?((image|before|after|poster|wave|before-wave)\.(png|jpe?g|webp)|(video|before|after)\.(webm|mp4)|(audio|before|after)\.(wav|mp3|flac|ogg|opus|m4a))|v\d+-g\d+(-before)?\.(png|jpe?g|webp))$/
|
|
672
694
|
/** a message's image as an item's media names it: `thread/<file>` */
|
|
673
695
|
export const isThreadMedia = (n: string): boolean => n.startsWith('thread/') && MESSAGE_FILE_RE.test(n.slice('thread/'.length))
|
|
674
696
|
/** a name an item's media may hold: a view's file or a message's image */
|
|
@@ -678,6 +700,7 @@ export const mediaFilesOf = (x: { item: Item; thread: readonly Message[] }): str
|
|
|
678
700
|
/** the message images an item's media already holds: a rewrite of its views keeps their facts */
|
|
679
701
|
export const threadMediaOf = (i: Item): string[] => Object.keys(i.media ?? {}).filter(isThreadMedia)
|
|
680
702
|
const TILE_RE = /^v\d+-g\d+\.(png|jpe?g|webp)$/
|
|
703
|
+
const TILE_BEFORE_RE = /^v\d+-g\d+-before\.(png|jpe?g|webp)$/
|
|
681
704
|
const POSTER_RE = /^(v\d+-)?poster\.png$/
|
|
682
705
|
|
|
683
706
|
/** a clip by its extension: webm or mp4 */
|
|
@@ -769,11 +792,11 @@ export function itemProblems(v: unknown): string[] {
|
|
|
769
792
|
out.push(...subjectProblems(v.subject, NO_SPEC), ...originProblems(v.origin))
|
|
770
793
|
if (v.topic !== undefined && typeof v.topic !== 'string') out.push('topic: a text')
|
|
771
794
|
const agent = obj(v.origin) && v.origin.by === 'agent'
|
|
772
|
-
if (!Array.isArray(v.views) || (agent && v.views.length === 0)) out.push(`views: a list${agent ? '
|
|
795
|
+
if (!Array.isArray(v.views) || (agent && v.views.length === 0)) out.push(`views: a list${agent ? ' of one view or more' : ''}`)
|
|
773
796
|
else
|
|
774
797
|
v.views.forEach((w: unknown, i: number) => {
|
|
775
798
|
if (i > 0 && (!obj(w) || typeof w.label !== 'string' || w.label.trim() === '')) out.push(`views[${i}].label: a text`)
|
|
776
|
-
if (obj(w) && w.gallery !== undefined) out.push(...
|
|
799
|
+
if (obj(w) && w.gallery !== undefined) out.push(...galleryProblems(w, `views[${i}].`))
|
|
777
800
|
else out.push(...viewProblems(obj(w) ? w : {}, `views[${i}].`))
|
|
778
801
|
})
|
|
779
802
|
if (v.answers !== undefined && !(Array.isArray(v.answers) && v.answers.length > 0 && v.answers.every((a) => typeof a === 'string' && ID_RE.test(a))))
|
|
@@ -817,6 +840,8 @@ function galleryProblems(v: Record<string, unknown>, at: string): string[] {
|
|
|
817
840
|
g.forEach((t: unknown, k: number) => {
|
|
818
841
|
const ok = obj(t) && typeof t.file === 'string' && TILE_RE.test(t.file) && typeof t.label === 'string' && obj(t.size) && Number(t.size.w) > 0 && Number(t.size.h) > 0
|
|
819
842
|
if (!ok) out.push(`${at}gallery[${k}]: { file: v<n>-g<k>.<png|jpg|webp>, label, size: { w, h } }`)
|
|
843
|
+
if (obj(t) && t.before !== undefined && !(typeof t.before === 'string' && TILE_BEFORE_RE.test(t.before))) out.push(`${at}gallery[${k}].before: v<n>-g<k>-before.<png|jpg|webp>`)
|
|
844
|
+
if (obj(t) && t.group !== undefined && !(typeof t.group === 'string' && t.group.trim() !== '')) out.push(`${at}gallery[${k}].group: a text`)
|
|
820
845
|
})
|
|
821
846
|
for (const k of ['files', 'size', 'clip', 'marks']) if (v[k] !== undefined) out.push(`${at}${k}: none on a gallery view`)
|
|
822
847
|
return out
|
|
@@ -894,7 +919,13 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
|
|
|
894
919
|
continue
|
|
895
920
|
}
|
|
896
921
|
if (isGallery(on)) {
|
|
897
|
-
|
|
922
|
+
const tile = r.tile
|
|
923
|
+
if (!(typeof tile === 'number' && Number.isInteger(tile) && tile >= 0 && tile < on.gallery.length)) errors.push(`rects[${i}].tile: the index of the gallery tile it is drawn on`)
|
|
924
|
+
else out.push({ x: r.x, y: r.y, w: r.w, h: r.h, comment: typeof r.comment === 'string' ? r.comment : '', ...(view !== 0 ? { view: view as number } : {}), tile })
|
|
925
|
+
continue
|
|
926
|
+
}
|
|
927
|
+
if (r.tile !== undefined) {
|
|
928
|
+
errors.push(`rects[${i}].tile: only on a gallery view`)
|
|
898
929
|
continue
|
|
899
930
|
}
|
|
900
931
|
if (on.audio) {
|
|
@@ -945,6 +976,7 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
|
|
|
945
976
|
}
|
|
946
977
|
const out: ReviewReaction[] = []
|
|
947
978
|
const seen = new Set<string>()
|
|
979
|
+
const rowsPicked = new Set<string>()
|
|
948
980
|
for (const [i, r] of v.entries()) {
|
|
949
981
|
const on = obj(r) && typeof r.view === 'number' && Number.isInteger(r.view) ? views[r.view] : undefined
|
|
950
982
|
if (!obj(r) || !on) {
|
|
@@ -957,19 +989,30 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
|
|
|
957
989
|
if (r.status !== undefined && !STATUSES.includes(r.status as ReviewStatus)) errors.push(`reactions[${i}].status: one of ${STATUSES.join(', ')}`)
|
|
958
990
|
if (r.comment !== undefined && typeof r.comment !== 'string') errors.push(`reactions[${i}].comment: a text`)
|
|
959
991
|
const stars = r.stars
|
|
960
|
-
|
|
961
|
-
|
|
992
|
+
// a choice scores its options, a gallery each of its tiles
|
|
993
|
+
const scored = choice || (typeof tile === 'number' && tiles > 0)
|
|
994
|
+
if (stars !== undefined && !(scored && typeof stars === 'number' && Number.isInteger(stars) && stars >= 1 && stars <= STARS))
|
|
995
|
+
errors.push(scored ? `reactions[${i}].stars: 1 to ${STARS}` : `reactions[${i}].stars: only on a choice card or a gallery tile`)
|
|
962
996
|
const key = `${String(r.view)}/${String(tile ?? '')}`
|
|
963
997
|
if (seen.has(key)) errors.push(`reactions[${i}]: a second reaction on the same view or tile`)
|
|
964
998
|
seen.add(key)
|
|
999
|
+
// a variant he keeps: one tile a row
|
|
1000
|
+
const group = typeof tile === 'number' && isGallery(on) ? on.gallery[tile]?.group : undefined
|
|
1001
|
+
const picked = r.picked
|
|
1002
|
+
if (picked !== undefined) {
|
|
1003
|
+
if (picked !== true || group === undefined) errors.push(`reactions[${i}].picked: true, only on a tile of a row of variants`)
|
|
1004
|
+
else if (rowsPicked.has(`${String(r.view)}/${group}`)) errors.push(`reactions[${i}].picked: one tile a row, and ${group} has one already`)
|
|
1005
|
+
else rowsPicked.add(`${String(r.view)}/${group}`)
|
|
1006
|
+
}
|
|
965
1007
|
const comment = typeof r.comment === 'string' ? r.comment.trim() : ''
|
|
966
|
-
if (r.status === undefined && comment === '' && stars === undefined) continue
|
|
1008
|
+
if (r.status === undefined && comment === '' && stars === undefined && picked !== true) continue
|
|
967
1009
|
out.push({
|
|
968
1010
|
view: r.view as number,
|
|
969
1011
|
...(typeof tile === 'number' ? { tile } : {}),
|
|
970
1012
|
...(r.status !== undefined ? { status: r.status as ReviewStatus } : {}),
|
|
971
1013
|
comment,
|
|
972
1014
|
...(typeof stars === 'number' ? { stars } : {}),
|
|
1015
|
+
...(picked === true && group !== undefined ? { picked: true as const } : {}),
|
|
973
1016
|
})
|
|
974
1017
|
}
|
|
975
1018
|
return out
|
|
@@ -980,6 +1023,7 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
|
|
|
980
1023
|
export function placeText(r: { view?: number | undefined; tile?: number | undefined }, views: readonly ReviewView[]): string {
|
|
981
1024
|
const i = r.view ?? 0
|
|
982
1025
|
const v = views[i]
|
|
983
|
-
const
|
|
1026
|
+
const t = r.tile !== undefined && v && isGallery(v) ? v.gallery[r.tile] : undefined
|
|
1027
|
+
const tile = r.tile !== undefined && v && isGallery(v) ? ` / ${(t && tileName(t)) || `image ${r.tile + 1}`}` : ''
|
|
984
1028
|
return `[${viewLetter(i)}${v?.label ? ` ${v.label}` : ''}${tile}]`
|
|
985
1029
|
}
|
package/src/review/previews.ts
CHANGED
|
@@ -133,7 +133,7 @@ const mediaOf = (dir: string, id: string): Record<string, unknown> => {
|
|
|
133
133
|
/** every image a card draws: each view's image or pair, a clip's poster, a sound's waveforms, a gallery's tiles */
|
|
134
134
|
export function imagesOf(i: Item): string[] {
|
|
135
135
|
const names = i.views.flatMap((v) => {
|
|
136
|
-
if (isGallery(v)) return v.gallery.
|
|
136
|
+
if (isGallery(v)) return v.gallery.flatMap((g) => [g.file, ...(g.before ? [g.before] : [])])
|
|
137
137
|
const f = v.files
|
|
138
138
|
return [...('image' in f ? [f.image] : isPair(f) ? [f.before, f.after] : []), ...(v.clip ? [v.clip.poster] : []), ...(v.audio ? [v.audio.wave, ...(v.audio.waveBefore ? [v.audio.waveBefore] : [])] : [])]
|
|
139
139
|
})
|
package/src/review/routes.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { roleOf } from './role.ts'
|
|
|
16
16
|
import { addMessage, imageFile, itemOfRef, markRead, raiseItem, rateSubject, readAllCached, readItem, specOf, storeDir, storeStamp, threadImage, writeVerdict } from './store.ts'
|
|
17
17
|
import { boardOf, pageOf, queryOf, threadIndex, threadOfId, threadView, type ThreadIndex } from './cells.ts'
|
|
18
18
|
import { membersOf, threadsOf, type Thread } from './threads.ts'
|
|
19
|
+
import { putMedia } from '../media-store/put.ts'
|
|
19
20
|
import { upKeys } from '../media-store/remote.ts'
|
|
20
21
|
import { remoteUrl, reviewKey } from './media-read.ts'
|
|
21
22
|
import { trailerRoutes } from './trailer-routes.ts'
|
|
@@ -67,6 +68,8 @@ let listing: { dir: string; tag: string; body: string; zipped: Uint8Array<ArrayB
|
|
|
67
68
|
// ── the paged list and one thread: an index over the store's threads, built again when a file moved or a minute
|
|
68
69
|
// passed (a claim goes stale on the clock); its build number is every answer's ETag ──
|
|
69
70
|
|
|
71
|
+
/** the label a card's file is published under: `public/review-share/<sha>.<ext>` (the review kind's own label is the code's) */
|
|
72
|
+
const SHARE_LABEL = 'review-share'
|
|
70
73
|
const INDEX_MS = 60_000
|
|
71
74
|
const BOOT = Date.now().toString(36)
|
|
72
75
|
let builds = 0
|
|
@@ -251,6 +254,14 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
251
254
|
const r = Bun.spawnSync(['open', ...(typeof b.file === 'string' ? ['-R'] : []), target], { stdout: 'ignore', stderr: 'pipe' })
|
|
252
255
|
return r.exitCode === 0 ? Response.json({ ok: true }, { headers: NO_STORE }) : bad(`open: ${r.stderr.toString().trim() || `exit ${r.exitCode}`}`, 500)
|
|
253
256
|
}
|
|
257
|
+
// one of the card's files published in the Space: a permanent public URL through the cdn, the same key for the same content
|
|
258
|
+
if (name === 'share') {
|
|
259
|
+
const b = (await req.json().catch(() => ({}))) as { file?: unknown }
|
|
260
|
+
const target = typeof b.file === 'string' ? imageFile(dir, id, b.file) : null
|
|
261
|
+
if (!target) return bad(`no file ${id}/${String(b.file)} on this disk`, 404)
|
|
262
|
+
const p = await putMedia(target, { public: true, kind: SHARE_LABEL })
|
|
263
|
+
return Response.json({ url: p.url, key: p.key, sent: p.sent }, { headers: NO_STORE })
|
|
264
|
+
}
|
|
254
265
|
} catch (e) {
|
|
255
266
|
return bad(e)
|
|
256
267
|
}
|
package/src/review/store.ts
CHANGED
|
@@ -95,7 +95,7 @@ export interface ViewInput {
|
|
|
95
95
|
before?: string
|
|
96
96
|
after?: string
|
|
97
97
|
/** a list of small images shown as a wrapping grid, each with its label; never the first view */
|
|
98
|
-
gallery?: { file: string; label: string }[]
|
|
98
|
+
gallery?: { file: string; label: string; before?: string; group?: string }[]
|
|
99
99
|
/** a line on this view alone: an option's description on a choice card */
|
|
100
100
|
note?: string
|
|
101
101
|
}
|
|
@@ -145,7 +145,7 @@ interface Loaded {
|
|
|
145
145
|
clip?: { duration: number; fps: number; from: string }
|
|
146
146
|
/** a sound: its length, and the files its waveforms are drawn from (the after's or the one's, then the before's) */
|
|
147
147
|
audio?: { duration: number; from: string; before?: string }
|
|
148
|
-
tiles?: { path: string; label: string; size: { w: number; h: number } }[]
|
|
148
|
+
tiles?: { path: string; label: string; size: { w: number; h: number }; before?: string; group?: string }[]
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/** a view's files checked and sized, a pair of one size (and one length, two clips); throws with the reason, naming the view */
|
|
@@ -156,10 +156,15 @@ async function loadView(v: ViewInput, which: string): Promise<Loaded> {
|
|
|
156
156
|
if (v.gallery.length === 0) throw new Error(`${which}: a gallery needs at least one image`)
|
|
157
157
|
const tiles = await Promise.all(
|
|
158
158
|
v.gallery.map(async (t) => {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
const image = (f: string): string => {
|
|
160
|
+
const path = resolve(f)
|
|
161
|
+
if (!existsSync(path)) throw new Error(`${path}: no such file`)
|
|
162
|
+
if (!IMAGE_EXT.test(extname(path).toLowerCase())) throw new Error(`${which}: ${path}: a gallery holds png, jpg or webp images, never a clip`)
|
|
163
|
+
return path
|
|
164
|
+
}
|
|
165
|
+
const path = image(t.file)
|
|
166
|
+
const group = t.group?.trim()
|
|
167
|
+
return { path, label: t.label.trim(), size: await sizeOf(path), ...(t.before !== undefined ? { before: image(t.before) } : {}), ...(group ? { group } : {}) }
|
|
163
168
|
}),
|
|
164
169
|
)
|
|
165
170
|
return { label: v.label.trim(), sources: [], size: tiles[0]?.size ?? { w: 0, h: 0 }, tiles }
|
|
@@ -254,10 +259,14 @@ async function writeWaves(v: Loaded, n: number, folder: string): Promise<void> {
|
|
|
254
259
|
const prefix = (n: number): string => (n > 0 ? `v${n}-` : '')
|
|
255
260
|
|
|
256
261
|
/** the file name of tile `k` of gallery view `n` */
|
|
257
|
-
const tileName = (n: number, k: number, path: string): string => `v${n}-g${k}${extname(path).toLowerCase()}`
|
|
262
|
+
const tileName = (n: number, k: number, path: string, side = ''): string => `v${n}-g${k}${side}${extname(path).toLowerCase()}`
|
|
258
263
|
|
|
259
264
|
function viewOf(v: Loaded, n: number, marks: readonly ReviewMark[] = [], note?: string): ReviewView {
|
|
260
|
-
if (v.tiles)
|
|
265
|
+
if (v.tiles)
|
|
266
|
+
return {
|
|
267
|
+
label: v.label,
|
|
268
|
+
gallery: v.tiles.map((t, k): GalleryTile => ({ file: tileName(n, k, t.path), label: t.label, size: t.size, ...(t.before ? { before: tileName(n, k, t.before, '-before') } : {}), ...(t.group ? { group: t.group } : {}) })),
|
|
269
|
+
}
|
|
261
270
|
const audio = v.audio ? { audio: { duration: v.audio.duration, wave: `${prefix(n)}wave.png`, ...(v.audio.before ? { waveBefore: `${prefix(n)}before-wave.png` } : {}) } } : {}
|
|
262
271
|
return { label: v.label, files: filesOf(v, n), size: v.size, ...clipOf(v, n), ...audio, ...(marks.length > 0 ? { marks: [...marks] } : {}), ...(note?.trim() ? { note: note.trim() } : {}) }
|
|
263
272
|
}
|
|
@@ -305,7 +314,6 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
|
|
|
305
314
|
)
|
|
306
315
|
if (given.length === 0) throw new Error('give --image, --video or --audio, or --before and --after, or --view "<label>" <image>')
|
|
307
316
|
for (const [i, v] of given.entries()) if (i > 0 && !v.label.trim()) throw new Error('--view: every view after the first needs its label')
|
|
308
|
-
if (given[0]?.gallery) throw new Error('a gallery is never the first view: give the card an --image (or a pair, or a clip) first')
|
|
309
317
|
if (input.choice && given.length < 2) throw new Error('--choice: a choice has two options or more, one --view each')
|
|
310
318
|
for (const v of given) if (v.note !== undefined && v.gallery) throw new Error(`--view "${v.label}": a note goes on an image, a clip or a sound, never a gallery`)
|
|
311
319
|
const loaded = await Promise.all(given.map((v, i) => loadView(v, i === 0 ? 'the first view' : `--view "${v.label}"`)))
|
|
@@ -385,7 +393,7 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
|
|
|
385
393
|
/** every file of view `n` into the folder, each as `<name>.tmp` renamed, so no reader sees half of one */
|
|
386
394
|
function copyFiles(v: Loaded, n: number, into: string): void {
|
|
387
395
|
const files = filesOf(v, n) as Record<string, string>
|
|
388
|
-
const copies: [string, string][] = [...v.sources.map(([name, p]): [string, string] => [p, files[name] ?? name]), ...(v.tiles ?? []).
|
|
396
|
+
const copies: [string, string][] = [...v.sources.map(([name, p]): [string, string] => [p, files[name] ?? name]), ...(v.tiles ?? []).flatMap((t, k): [string, string][] => [[t.path, tileName(n, k, t.path)], ...(t.before ? [[t.before, tileName(n, k, t.before, '-before')] as [string, string]] : [])])]
|
|
389
397
|
for (const [from, name] of copies) {
|
|
390
398
|
const to = join(into, name)
|
|
391
399
|
copyFileSync(from, `${to}.tmp`)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// the secrets one repo is for: the house's registry rows in its scope, plus the
|
|
2
|
+
// repo's own `creds`. Presence reads each value through `credsReadCommand` and
|
|
3
|
+
// keeps only whether it answered: a value is never printed, logged or returned.
|
|
4
|
+
import { inScope, scopesAll, scopeText, type Asker } from '../core/scope.ts'
|
|
5
|
+
import type { RepoConfig } from '../repo-config.ts'
|
|
6
|
+
import { secretArgv } from '../smoke/run-smoke.ts'
|
|
7
|
+
|
|
8
|
+
export type Cred = NonNullable<RepoConfig['creds']>[number]
|
|
9
|
+
|
|
10
|
+
/** `for`: the scope as its md cell; `mine`: the scope names this repo or its identity, not every repo */
|
|
11
|
+
export type SecretRow = { name: string; service?: string; level: 'core' | 'used' | 'minor'; for: string; mine: boolean; inScope: boolean }
|
|
12
|
+
|
|
13
|
+
/** the repo's own creds win over a house row of the same name; out of scope rows only with `all` */
|
|
14
|
+
export function secretsFor(o: { asker: Asker; own: Cred[]; house: Cred[]; all?: boolean }): SecretRow[] {
|
|
15
|
+
const byName = new Map<string, Cred>()
|
|
16
|
+
for (const c of o.house) byName.set(c.name, c)
|
|
17
|
+
for (const c of o.own) byName.set(c.name, { ...c, for: c.for ?? { repos: [o.asker.repos[0]!] } })
|
|
18
|
+
const rows = [...byName.values()].map((c): SecretRow => ({
|
|
19
|
+
name: c.name,
|
|
20
|
+
...(c.service != null ? { service: c.service } : {}),
|
|
21
|
+
level: c.level ?? 'used',
|
|
22
|
+
for: scopeText(c.for),
|
|
23
|
+
mine: !scopesAll(c.for) && inScope(c.for, o.asker),
|
|
24
|
+
inScope: inScope(c.for, o.asker),
|
|
25
|
+
}))
|
|
26
|
+
return rows
|
|
27
|
+
.filter((r) => o.all === true || r.inScope)
|
|
28
|
+
.sort((a, b) => Number(b.mine) - Number(a.mine) || Number(b.inScope) - Number(a.inScope) || a.name.localeCompare(b.name))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** whether each secret answers through the read command, all at once */
|
|
32
|
+
export async function presence(reader: string, names: string[]): Promise<Map<string, boolean>> {
|
|
33
|
+
const out = new Map<string, boolean>()
|
|
34
|
+
await Promise.all(names.map(async (name) => {
|
|
35
|
+
const p = Bun.spawn(secretArgv(reader, name, 'get'), { stdout: 'pipe', stderr: 'ignore' })
|
|
36
|
+
const answered = (await new Response(p.stdout).text()).trim() !== ''
|
|
37
|
+
out.set(name, (await p.exited) === 0 && answered)
|
|
38
|
+
}))
|
|
39
|
+
return out
|
|
40
|
+
}
|
|
@@ -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)
|