rvlib-shipkit 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -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 +22 -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/scope.ts +42 -0
- 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 +46 -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/review/review-kit.ts +4 -0
- package/src/serve/hub-app/review/review-st.ts +40 -3
- package/src/serve/hub-app/review/review-views.tsx +145 -64
- package/src/serve/hub-app/review/thread-st.ts +76 -16
- package/src/serve/hub-app/review.css +17 -2
- package/src/shipkit.ts +1 -1
- package/src/wiki/run-wiki.ts +13 -3
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
|
+
}
|
|
@@ -6,6 +6,10 @@ 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
|
+
/** 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
|
+
* list thumb is too small for it */
|
|
11
|
+
export const TILE_H = { min: 80, max: 480, start: 170, thumb: 220 } as const
|
|
12
|
+
|
|
9
13
|
/** what a reload must not lose: a blocked storage only loses persistence */
|
|
10
14
|
export const kept = {
|
|
11
15
|
get(k: string): string | null {
|
|
@@ -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, ZOOMS, type EtagLoader, type Zoom } from './review-kit.ts'
|
|
11
|
+
import { copyText, etagLoader, kept, postJson, TILE_H, ZOOMS, type EtagLoader, 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 */
|
|
@@ -60,6 +60,10 @@ export class CompareSt {
|
|
|
60
60
|
if (m && (COMPARE_MODES as readonly string[]).includes(m)) this.mode = m as CompareMode
|
|
61
61
|
makeAutoObservable<this, 'key'>(this, { key: false })
|
|
62
62
|
}
|
|
63
|
+
/** the mode a pair draws in: the changes read pixels from two images, so a pair of clips shows side by side */
|
|
64
|
+
modeFor(clip: boolean): CompareMode {
|
|
65
|
+
return clip && this.mode === 'diff' ? 'side' : this.mode
|
|
66
|
+
}
|
|
63
67
|
setMode(m: CompareMode): void {
|
|
64
68
|
this.mode = m
|
|
65
69
|
kept.put(this.key, m)
|
|
@@ -133,6 +137,10 @@ export class ReviewSt {
|
|
|
133
137
|
/** the subject rings over the image (M) */
|
|
134
138
|
marksOn = true
|
|
135
139
|
zoom: Zoom = 'fit'
|
|
140
|
+
/** a gallery tile's height, his slider */
|
|
141
|
+
tileH: number = TILE_H.start
|
|
142
|
+
/** each gallery tile also drawn at 16, 32 and 64 px, the sizes an icon lives at */
|
|
143
|
+
tileSmall = false
|
|
136
144
|
/** the contents strip beside the cells, when the column is wide enough; folded by hand */
|
|
137
145
|
railOn = true
|
|
138
146
|
/** the contents as a sheet over the cells: a narrow column or the phone */
|
|
@@ -141,6 +149,8 @@ export class ReviewSt {
|
|
|
141
149
|
width = 0
|
|
142
150
|
/** what the last copy put on the clipboard, in words, shown a moment */
|
|
143
151
|
toast: string | null = null
|
|
152
|
+
/** a card file's public url once published, `sending` while it goes up; keyed `<id>/<file>` */
|
|
153
|
+
shared = new Map<string, string | 'sending'>()
|
|
144
154
|
readonly compare: CompareSt
|
|
145
155
|
readonly phone = new PhoneSt()
|
|
146
156
|
/** the view a link names before its card is made */
|
|
@@ -164,12 +174,14 @@ export class ReviewSt {
|
|
|
164
174
|
this.loadBoard = etagLoader(() => st.url('/api/review/board'))
|
|
165
175
|
this.compare = new CompareSt(`${this.prefix}compare`)
|
|
166
176
|
try {
|
|
167
|
-
const p = JSON.parse(kept.get(`${this.prefix}prefs`) ?? '{}') as { hideHandled?: boolean; byLane?: boolean; zoom?: string; marks?: boolean; rail?: boolean }
|
|
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 }
|
|
168
178
|
if (p.hideHandled === false) this.hideHandled = false
|
|
169
179
|
if (p.byLane === true) this.byLane = true
|
|
170
180
|
if (p.marks === false) this.marksOn = false
|
|
171
181
|
if (p.rail === false) this.railOn = false
|
|
172
182
|
if ((ZOOMS as readonly string[]).includes(p.zoom ?? '')) this.zoom = p.zoom as Zoom
|
|
183
|
+
if (typeof p.tileH === 'number') this.setTileH(p.tileH)
|
|
184
|
+
if (p.tileSmall === true) this.tileSmall = true
|
|
173
185
|
} catch {
|
|
174
186
|
// a broken pref is the default
|
|
175
187
|
}
|
|
@@ -193,7 +205,7 @@ export class ReviewSt {
|
|
|
193
205
|
boardRows: observableRef,
|
|
194
206
|
})
|
|
195
207
|
reaction(
|
|
196
|
-
() => JSON.stringify({ hideHandled: this.hideHandled, byLane: this.byLane, zoom: this.zoom, marks: this.marksOn, rail: this.railOn }),
|
|
208
|
+
() => JSON.stringify({ hideHandled: this.hideHandled, byLane: this.byLane, zoom: this.zoom, marks: this.marksOn, rail: this.railOn, tileH: this.tileH, tileSmall: this.tileSmall }),
|
|
197
209
|
(s) => kept.put(`${this.prefix}prefs`, s),
|
|
198
210
|
)
|
|
199
211
|
// the card the address names, else the list's first: a new one is a new thread state, the old one disposed
|
|
@@ -472,6 +484,14 @@ export class ReviewSt {
|
|
|
472
484
|
this.zoom = z
|
|
473
485
|
}
|
|
474
486
|
|
|
487
|
+
toggleTileSmall(): void {
|
|
488
|
+
this.tileSmall = !this.tileSmall
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
setTileH(h: number): void {
|
|
492
|
+
this.tileH = Math.max(TILE_H.min, Math.min(TILE_H.max, Math.round(h)))
|
|
493
|
+
}
|
|
494
|
+
|
|
475
495
|
toggleMarks(): void {
|
|
476
496
|
this.marksOn = !this.marksOn
|
|
477
497
|
}
|
|
@@ -521,6 +541,23 @@ export class ReviewSt {
|
|
|
521
541
|
}
|
|
522
542
|
}
|
|
523
543
|
|
|
544
|
+
/** one of a card's files published in the Space, its permanent cdn url to the clipboard: anyone with it downloads */
|
|
545
|
+
async share(id: string, file: string): Promise<void> {
|
|
546
|
+
const k = `${id}/${file}`
|
|
547
|
+
const known = this.shared.get(k)
|
|
548
|
+
if (known === 'sending') return
|
|
549
|
+
if (known) return this.copied(known, `link copied: ${known}`)
|
|
550
|
+
this.shared.set(k, 'sending')
|
|
551
|
+
try {
|
|
552
|
+
const r = await postJson<{ url: string }>(this.st.url(`/api/review/${id}/share`), { file })
|
|
553
|
+
runInAction(() => this.shared.set(k, r.url))
|
|
554
|
+
await this.copied(r.url, `link copied: ${r.url}`)
|
|
555
|
+
} catch (e) {
|
|
556
|
+
runInAction(() => this.shared.delete(k))
|
|
557
|
+
this.say(`not shared: ${(e as Error).message}`)
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
524
561
|
/** the open card as one paste a fresh agent session in any repo acts on: what it is, its repo, the command that shows
|
|
525
562
|
* it whole, its link here and on the phone (C) */
|
|
526
563
|
async copyCard(): Promise<void> {
|