rvlib-shipkit 2.21.0 → 2.22.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/package.json +1 -1
  3. package/src/asks/asks-queue.ts +8 -7
  4. package/src/assets/kits/identity-kit.ts +158 -2
  5. package/src/cli/cmd_Bump.ts +3 -3
  6. package/src/cli/cmd_Rec.ts +349 -0
  7. package/src/cli/cmd_Releases.ts +4 -1
  8. package/src/cli/cmd_Secret.ts +10 -3
  9. package/src/cli/cmd_Sign.ts +24 -0
  10. package/src/cli/cmd_Social.ts +44 -1
  11. package/src/cli/family-pages.ts +1 -0
  12. package/src/cli/registry.ts +4 -0
  13. package/src/core/agent-spawn.ts +4 -17
  14. package/src/core/code-lines.ts +49 -0
  15. package/src/core/discover-checks.ts +27 -3
  16. package/src/core/hard-reset.ts +34 -0
  17. package/src/core/raw-access.ts +3 -13
  18. package/src/core/throwaway-worktree.ts +72 -0
  19. package/src/home/app-sign.ts +98 -0
  20. package/src/home/gui-app.ts +31 -12
  21. package/src/home/home-routes.ts +6 -0
  22. package/src/home/serve-web.ts +1 -1
  23. package/src/identities/identities.ts +6 -0
  24. package/src/media-kinds.ts +5 -3
  25. package/src/media-store/forget.ts +54 -0
  26. package/src/media-store/put.ts +4 -3
  27. package/src/media-store/space.ts +63 -24
  28. package/src/recordings/delete.ts +19 -0
  29. package/src/recordings/edit.ts +231 -0
  30. package/src/recordings/load.ts +37 -0
  31. package/src/recordings/marks-draw.ts +111 -0
  32. package/src/recordings/marks-png.ts +25 -0
  33. package/src/recordings/marks.ts +138 -0
  34. package/src/recordings/media-kind.ts +67 -0
  35. package/src/recordings/model.ts +170 -0
  36. package/src/recordings/open.ts +33 -0
  37. package/src/recordings/place.ts +89 -0
  38. package/src/recordings/presets.ts +99 -0
  39. package/src/recordings/recorder-app/Capture.swift +510 -0
  40. package/src/recordings/recorder-app/Clip.swift +107 -0
  41. package/src/recordings/recorder-app/Editor.swift +39 -0
  42. package/src/recordings/recorder-app/Tray.swift +298 -0
  43. package/src/recordings/recorder-app/main.swift +859 -0
  44. package/src/recordings/recorder-app.ts +46 -0
  45. package/src/recordings/recorder.shipkit.ts +11 -0
  46. package/src/recordings/routes.ts +140 -0
  47. package/src/recordings/run-recorder.ts +40 -0
  48. package/src/recordings/share.ts +107 -0
  49. package/src/recordings/take.ts +146 -0
  50. package/src/recordings/view.ts +40 -0
  51. package/src/release/gate-checkout.ts +74 -0
  52. package/src/release/release-scope.ts +35 -26
  53. package/src/release/run-bump.ts +79 -37
  54. package/src/release/run-release.ts +67 -53
  55. package/src/releases/add.ts +7 -2
  56. package/src/releases/from-card.ts +3 -3
  57. package/src/releases/model.ts +29 -7
  58. package/src/repo-config.ts +7 -3
  59. package/src/review/trailer-desk.ts +1 -0
  60. package/src/review/trailer-model.ts +2 -0
  61. package/src/secrets/manager.ts +18 -1
  62. package/src/serve/hub-app/home-st.ts +15 -5
  63. package/src/serve/hub-app/home.html +1 -0
  64. package/src/serve/hub-app/hub-app.tsx +6 -1
  65. package/src/serve/hub-app/icons.tsx +2 -0
  66. package/src/serve/hub-app/palette-st.ts +1 -0
  67. package/src/serve/hub-app/project-list.tsx +1 -0
  68. package/src/serve/hub-app/projects-svc.ts +1 -1
  69. package/src/serve/hub-app/recordings-st.ts +641 -0
  70. package/src/serve/hub-app/recordings-view.tsx +504 -0
  71. package/src/serve/hub-app/recordings.css +82 -0
  72. package/src/serve/hub-app/repo-st.ts +1 -1
  73. package/src/serve/hub-app/review/trailer-page.tsx +1 -0
  74. package/src/serve/hub-app/review/trailer-st.ts +16 -0
  75. package/src/serve/hub-app/review/trailer-timeline.tsx +3 -0
  76. package/src/serve/hub-app/review.css +2 -0
  77. package/src/serve/hub-app/social/post-card.tsx +31 -3
  78. package/src/serve/hub-app/social/social-model.ts +4 -0
  79. package/src/serve/hub-app/social/social-st.ts +12 -0
  80. package/src/serve/hub-app/social.css +4 -0
  81. package/src/shipkit.ts +2 -2
  82. package/src/shot/box.ts +23 -17
  83. package/src/shot/browser-slot.ts +13 -3
  84. package/src/shot/film-box.ts +193 -117
  85. package/src/shot/shooter.ts +5 -3
  86. package/src/smoke/run-smoke.ts +8 -6
  87. package/src/social/compose.ts +14 -0
  88. package/src/social/drafts.ts +1 -1
  89. package/src/social/load.ts +16 -2
  90. package/src/social/publish/index.ts +3 -1
  91. package/src/social/publish/secret.ts +12 -4
  92. package/src/social/release-card.ts +69 -0
  93. package/src/social/release-stage.ts +49 -10
  94. package/src/social/routes.ts +5 -0
  95. package/src/social/stage.ts +9 -5
  96. package/src/trailer/build.ts +24 -0
  97. package/src/trailer/ffmpeg.ts +8 -0
  98. package/src/trailer/grammar.ts +9 -2
  99. package/src/trailer/look.ts +7 -0
  100. package/src/veille/chrome.ts +6 -3
@@ -244,6 +244,9 @@ export const ShotCards = observer(({ st }: { st: TrailerSt }) => {
244
244
  <div className="tr-dim tr-small">{clock(s.start)} · {secsOf(s.length)}{s.captions.length > 0 ? ` · ${s.captions.length} title${s.captions.length > 1 ? 's' : ''}` : ''}</div>
245
245
  {status ? <div className={`tr-sstate ss-${status.state}`}><span className="tr-sdot" />{status.word}{status.state === 'waiting' && status.card ? <span className="tr-dim">{status.card}</span> : status.why && status.state !== 'ready' ? <span className="tr-dim">{status.why}</span> : null}</div> : null}
246
246
  {n > 0 ? <span className="tr-shotnotes">{n}</span> : null}
247
+ {s.recording ? (
248
+ <span role="button" tabIndex={0} className="tr-reshoot" title={`shoot ${s.recording} again with the recorder: as long as the shot, the new take keeps its name`} onClick={(e) => { e.stopPropagation(); void st.shootAgain(s) }} onKeyDown={(e) => { if (e.key === 'Enter') { e.stopPropagation(); void st.shootAgain(s) } }}>● shoot again</span>
249
+ ) : null}
247
250
  </button>
248
251
  )
249
252
  })}
@@ -624,6 +624,8 @@ button.tr-changed.on{background:var(--accent);color:var(--bg)}
624
624
  .tr-drafttag{font-size:10px;font-weight:700;text-transform:uppercase;color:var(--warn)}
625
625
  .tr-stillrect{position:absolute;border:2px solid var(--accent);pointer-events:none}
626
626
  .tr-shotnotes{position:absolute;top:var(--s2);right:var(--s2);min-width:18px;height:18px;border-radius:9px;background:var(--warn);color:var(--bg);font-size:11px;font-weight:800;text-align:center;line-height:18px;padding:0 var(--s1)}
627
+ .tr-reshoot{display:inline-block;margin-top:var(--s1);padding:0 var(--s2);border:1px solid var(--line);border-radius:999px;font-size:11px;line-height:18px;color:var(--red);cursor:pointer}
628
+ .tr-reshoot:hover{border-color:var(--red)}
627
629
  .tr-montage{display:flex;flex-direction:column;gap:var(--s1);align-items:flex-start}
628
630
  .tr-montagebody{width:100%;font-size:12.5px;padding:var(--s2) var(--s3);border:1px solid var(--line);border-radius:4px;background:var(--panel);overflow-x:auto}
629
631
  .tr-notescol{height:100%;display:flex;flex-direction:column;min-height:0}
@@ -5,7 +5,7 @@
5
5
  import { observer } from 'mobx-react-lite'
6
6
  import { Fragment, useState, type CSSProperties, type ReactNode } from 'react'
7
7
  import { CopyFrame, Count, ExpandButton, Field, Fold, FoldCard, Logo, Md, popup } from './kit.tsx'
8
- import { angleCards, isClip, isVertical, logoStacks, sharing, STATUS, TEXT_FIELD, TITLE_MAX, type DeskAccount, type Media, type Place, type SocialPost } from './social-model.ts'
8
+ import { angleCards, isClip, isVertical, logoStacks, sharing, STATUS, TAG_FIELD, TEXT_FIELD, TITLE_MAX, type DeskAccount, type Media, type Place, type SocialPost } from './social-model.ts'
9
9
  import type { SocialSt } from './social-st.ts'
10
10
  import { Caret } from '../icons.tsx'
11
11
  import { AutoText } from '../auto-text.tsx'
@@ -45,7 +45,8 @@ export function AngleCards(p: { angle: string }) {
45
45
  )
46
46
  }
47
47
 
48
- /** a still or a clip: « Copy image » for a still (the clipboard takes no clip), « ⬇ » for both, 📂 the Finder */
48
+ /** a still or a clip: « Copy image » for a still (the clipboard takes no clip), « ⬇ » for both, 📂 the Finder, « ⧉ path »
49
+ * its path on this Mac */
49
50
  export const MediaTile = observer((p: { so: SocialSt; slug: string; m: Media; size: 'large' | 'side' | 'small' }) => {
50
51
  const so = p.so
51
52
  const url = so.mediaUrl(p.slug, p.m)
@@ -72,6 +73,11 @@ export const MediaTile = observer((p: { so: SocialSt; slug: string; m: Media; si
72
73
  📂
73
74
  </button>
74
75
  ) : null}
76
+ {!so.phone ? (
77
+ <button onClick={() => void so.copyPath(p.slug, p.m, `${key}/path`)} title={`copy the path on this Mac: ${p.m.path}`}>
78
+ {so.copiedKey === `${key}/path` ? '✓ Copied' : '⧉ path'}
79
+ </button>
80
+ ) : null}
75
81
  {p.size === 'large' ? (
76
82
  <span className="rv-dim rv-small so-ellip" title={p.m.path}>
77
83
  {p.m.name}
@@ -346,9 +352,31 @@ const Fields = observer((p: { so: SocialSt; a: DeskAccount; post: SocialPost; pl
346
352
  </Field>
347
353
  {post.refused !== '' ? <div className="so-refused t-red">⛔ {post.refused}</div> : null}
348
354
  {post.rating !== 'safe' && p.a.sensitive !== '' ? <div className="so-refused t-warn">🔞 {post.rating} on {p.a.name}: {p.a.sensitive}</div> : null}
355
+ {post.tier !== '' ? (
356
+ <Field label="Tier">
357
+ <div className="so-tier">
358
+ <b>{post.tier}</b>
359
+ <span className="t-dim">{post.tierSet ? ' (its draft names it)' : ' (suggested: the open tier, no tier named)'}</span>
360
+ </div>
361
+ </Field>
362
+ ) : null}
349
363
  {post.tags.length > 0 ? (
350
364
  <Field label="Tags">
351
- <div className="so-tags">{post.tags.join(' ')}</div>
365
+ {TAG_FIELD[post.platform] === 'words' ? (
366
+ <div className="so-tagchips">
367
+ {post.tags.map((t) => {
368
+ const word = t.replace(/^#/, '')
369
+ const k = `${key}/tag/${word}`
370
+ return (
371
+ <button key={word} className="so-tagchip" title="copy this tag alone" onClick={() => void so.copy(word, k)}>
372
+ {so.copiedKey === k ? '✓ copied' : word}
373
+ </button>
374
+ )
375
+ })}
376
+ </div>
377
+ ) : (
378
+ <div className="so-tags">{post.tags.join(' ')}</div>
379
+ )}
352
380
  </Field>
353
381
  ) : null}
354
382
  {post.reply !== '' ? (
@@ -36,6 +36,10 @@ export const AUTOMATION: Readonly<Record<string, { label: string; tone: 'ok' | '
36
36
  /** the field of the platform a message's text goes in (the account's `text`) */
37
37
  export const TEXT_FIELD: Readonly<Record<string, string>> = { description: 'Description', comment: 'First comment' }
38
38
 
39
+ /** how a platform's tag field takes the tags, by platform; unnamed, they show as one line. `words`: a select that takes
40
+ * one bare word at a time, so each tag is its own chip, no `#`, copied alone */
41
+ export const TAG_FIELD: Readonly<Record<string, 'words'>> = { subscribestar: 'words' }
42
+
39
43
  /** the list's families (Fil and Vertical): the word in the address, the family of the accounts */
40
44
  export const FAMS = { feed: 'feed', vertical: 'shorts' } as const satisfies Record<string, Family>
41
45
  export type Fam = keyof typeof FAMS
@@ -999,6 +999,18 @@ export class SocialSt {
999
999
  await this.revealBody({ slug, name: m.name })
1000
1000
  }
1001
1001
 
1002
+ /** a media file's path on this Mac on the clipboard, copied on the click itself; the file is brought back from the
1003
+ * Space behind it when the disk let it go, so a paste finds it */
1004
+ async copyPath(slug: string, m: Media, key: string): Promise<void> {
1005
+ await this.copy(m.path, key)
1006
+ try {
1007
+ const r = await postJson<{ path: string }>(this.st.url('/api/social/media-back'), { slug, name: m.name })
1008
+ if (r.path !== m.path) await this.copy(r.path, key)
1009
+ } catch (e) {
1010
+ runInAction(() => (this.error = (e as Error).message))
1011
+ }
1012
+ }
1013
+
1002
1014
  /** an identity's picture shown in the Finder, its folder open and the file selected */
1003
1015
  async revealPicture(identity: string, file: string): Promise<void> {
1004
1016
  await this.revealBody({ identity, file })
@@ -156,6 +156,10 @@ a.so-kind:hover{text-decoration:underline}
156
156
  .so-corner{flex:none;display:flex;flex-direction:column;gap:var(--s1);align-items:stretch}
157
157
  .so-corner button{font-size:11px;padding:0 var(--s2);line-height:18px}
158
158
  .so-tags{border:1px solid var(--line);border-radius:6px;padding:var(--s1) var(--s3);font-size:12px;color:var(--blue)}
159
+ .so-tagchips{display:flex;flex-wrap:wrap;gap:var(--s1)}
160
+ .so-tagchip{font-size:12px;line-height:20px;padding:0 var(--s2);border:1px solid var(--line);border-radius:4px;background:var(--bg);color:var(--blue);cursor:copy}
161
+ .so-tagchip:hover{border-color:var(--accent)}
162
+ .so-tier{border:1px solid var(--line);border-radius:6px;padding:var(--s1) var(--s3);font-size:12px}
159
163
  .so-footer{border:1px dashed var(--line);border-radius:6px;padding:var(--s2) var(--s3);font-size:11px;color:var(--dim)}
160
164
  .so-flairline{display:flex;align-items:center;gap:var(--s2);padding-top:var(--s1)}
161
165
  .so-flair{font-size:13px;font-weight:700;padding:0 var(--s2);line-height:26px;border-radius:4px;background:var(--review);color:var(--bg)}
package/src/shipkit.ts CHANGED
@@ -60,8 +60,8 @@ export type { Ask, CreateOpts } from './asks/asks-queue.ts'
60
60
  // declares its kinds; `shipkit assets …` derives the rest.
61
61
  export { defineKit, defineKind, comfy, canvas, svg, manual, gemini, mediaOf, MEDIA_EXTS, geometryPanel, gridPanel, customPanel, validateKit, missingPanelScripts, loadKit, findAsset, allAssets, categoriesOf } from './assets/kit-config.ts'
62
62
  export type { KitConfig, ResolvedKit, Kind, KindMeta, Media, AssetSpec, GeneratorSpec, ComfyGen, CanvasGen, ManualGen, GeminiGen, PanelSpec, GeometryPanelSpec, GridPanelSpec, CustomPanelSpec, FoundAsset, ShipContext, ShipFn } from './assets/kit-config.ts'
63
- export { identityKinds, renderIdentity, renderIdentityFromMark, NO_PICK_FIX, FAVICON_SIZE, OG_W, OG_H, LOGO_SIZE } from './assets/kits/identity-kit.ts'
64
- export type { Brand } from './assets/kits/identity-kit.ts'
63
+ export { identityKinds, renderIdentity, renderIdentityFromMark, renderReleaseCard, NO_PICK_FIX, FAVICON_SIZE, OG_W, OG_H, LOGO_SIZE, RELEASE_W, RELEASE_H } from './assets/kits/identity-kit.ts'
64
+ export type { Brand, ReleaseCard } from './assets/kits/identity-kit.ts'
65
65
  export { studioRoutes } from './assets/server/studio-server.ts'
66
66
  export type { StudioDeps, StudioRoutes } from './assets/server/studio-server.ts'
67
67
  export { StudioQueue } from './assets/server/studio-queue.ts'
package/src/shot/box.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  // THE BOX ROUTE: a repo whose repo.config.ts `browsers.box` names an ssh host films there when it runs on a Mac. Every
2
2
  // browser start of the repo (a take, a Shooter: sk shot, look sheets, thumbs, the trailer's films) asks `openBrowser`,
3
- // which on such a Mac connects to the box's warm chromium (film-box.ts) instead of launching one: its devtools reached
4
- // through an ssh forward, each localhost page it opens reached back on this Mac through a reverse forward (the urls
5
- // unchanged), its frames drawn and encoded on the box's GPU, only the result crossing back. Anywhere else, or with
6
- // SK_FILM_HERE=1 for one run, it launches here as before, under the browser cap either way.
3
+ // which on such a Mac connects to the box's warm chromium of the slot it holds (film-box.ts: one browser per slot, so
4
+ // no film shares a GPU process with another) instead of launching one: its devtools reached through an ssh forward,
5
+ // each localhost page it opens reached back on this Mac through a reverse forward (the urls unchanged), its frames
6
+ // drawn and encoded on the box's GPU, only the result crossing back. Anywhere else, or with SK_FILM_HERE=1 for one
7
+ // run, it launches here as before, under the browser cap either way.
7
8
  //
8
9
  // The one constraint a reader breaks first: a box that does not answer is one loud line and nothing filmed, never a
9
10
  // browser launched on the Mac instead (the Mac is the machine the route protects).
10
11
  import { createHash } from 'crypto'
11
12
  import { readFileSync } from 'fs'
12
- import { browserCap, browserSlot, filmBox, HERE_ENV } from './browser-slot.ts'
13
+ import { browserCap, browserLease, type BrowserLease, filmBox, HERE_ENV } from './browser-slot.ts'
13
14
  import { CDP_PORT } from './film-box.ts'
14
15
  import { JOB_STORE_END, jobId, jobStoreScript } from './job-store.ts'
15
16
 
@@ -48,11 +49,14 @@ const closeThenFree = async (close: () => Promise<void>, free: () => void): Prom
48
49
 
49
50
  /** wait for one of the repo's browser slots where its browser would run (on its box from a Mac), and hold it until
50
51
  * the release: a caller that waits in the queue apart from its own timed work holds it first (openBrowser `held`) */
51
- export async function slotFor(o: { root?: string; who: string; say?: (l: string) => void }): Promise<() => void> {
52
+ export async function slotFor(o: { root?: string; who: string; say?: (l: string) => void }): Promise<BrowserLease> {
52
53
  const box = filmBox(await browserCap(o.root))
53
- return browserSlot(o.who, { ...(o.root ? { root: o.root } : {}), ...(o.say ? { say: o.say } : {}), onBox: box != null })
54
+ return browserLease(o.who, { ...(o.root ? { root: o.root } : {}), ...(o.say ? { say: o.say } : {}), onBox: box != null })
54
55
  }
55
56
 
57
+ /** the name the box knows a slot's browser by: the repo and the slot's index */
58
+ export const boxSlotKey = (repo: string, slot: number): string => `${repo.replace(/[^\w.-]/g, '_')}-${slot}`
59
+
56
60
  const SSH = (box: string) => ['ssh', '-o', 'ConnectTimeout=5', '-o', 'BatchMode=yes', box]
57
61
  /** where the box's devtools answer on this Mac */
58
62
  const localCdp = (box: string): number => 40000 + (parseInt(createHash('sha1').update(box).digest('hex').slice(0, 4), 16) % 9000)
@@ -71,10 +75,10 @@ async function run(cmd: string[], stdin?: Uint8Array): Promise<{ code: number; o
71
75
  return { code: await p.exited, out, err }
72
76
  }
73
77
 
74
- /** the box's warm browser answering, its script uploaded first when the box lacks this version of it */
75
- async function boxUp(box: string, version: string, say: (l: string) => void): Promise<string> {
78
+ /** the box's warm browser of a slot answering, its script uploaded first when the box lacks this version of it */
79
+ async function boxUp(box: string, version: string, key: string, say: (l: string) => void): Promise<string> {
76
80
  const script = `${FILM_DIR}/film-box-${BOX_HASH}.ts`
77
- const go = () => run([...SSH(box), `if exist ${script.replaceAll('/', '\\')} (bun ${script} up ${version}) else (exit ${MISSING})`])
81
+ const go = () => run([...SSH(box), `if exist ${script.replaceAll('/', '\\')} (bun ${script} up ${version} ${key}) else (exit ${MISSING})`])
78
82
  let r = await go()
79
83
  if (r.code === MISSING) {
80
84
  await run([...SSH(box), `mkdir ${FILM_DIR.replaceAll('/', '\\')} 2>nul`])
@@ -154,25 +158,27 @@ export function asLaunched(b: PwBrowser, all: PwPage[], store: BoxStore = 'job')
154
158
 
155
159
  /** a browser for `who` of the repo at `root`: on its box from a Mac (filmBox), else launched here; one of the repo's
156
160
  * browser slots held until close (`held`: one its caller already holds from slotFor, freed here as one taken here) */
157
- export async function openBrowser<B>(pw: Pw, o: { root?: string; who: string; args: string[]; say?: (l: string) => void; store?: BoxStore; held?: () => void }): Promise<Opened<B>> {
161
+ export async function openBrowser<B>(pw: Pw, o: { root?: string; who: string; args: string[]; say?: (l: string) => void; store?: BoxStore; held?: BrowserLease }): Promise<Opened<B>> {
158
162
  const say = o.say ?? ((l: string) => console.error(l))
159
- const box = filmBox(await browserCap(o.root))
160
- const release = o.held ?? (await slotFor({ ...(o.root ? { root: o.root } : {}), who: o.who, say }))
163
+ const cap = await browserCap(o.root)
164
+ const box = filmBox(cap)
165
+ const lease = o.held ?? (await slotFor({ ...(o.root ? { root: o.root } : {}), who: o.who, say }))
166
+ const release = lease.release
161
167
  try {
162
- if (box == null) {
168
+ if (box == null || cap == null) {
163
169
  const b = (await pw.chromium.launch({ headless: true, args: o.args })) as B & { close(): Promise<void> }
164
170
  return { browser: b, where: 'here', reach: async () => undefined, close: () => closeThenFree(() => b.close(), release) }
165
171
  }
166
172
  const t = performance.now()
167
173
  const version = (JSON.parse(readFileSync(Bun.resolveSync('playwright-core/package.json', import.meta.dir), 'utf8')) as { version: string }).version
168
- const state = await boxUp(box, version, say)
174
+ const state = await boxUp(box, version, boxSlotKey(cap.repo, lease.slot), say)
169
175
  const own: { p: ReturnType<typeof Bun.spawn> | null } = { p: null }
170
- // the box's browser answers on the port up names (a replacement runs beside a draining one on another)
176
+ // the slot's browser answers on the port up names
171
177
  const port = Number(/ port (\d+)/.exec(state)?.[1] ?? CDP_PORT)
172
178
  const cdp = localCdp(box) + (port - CDP_PORT)
173
179
  await forward(box, ['-L', `${cdp}:127.0.0.1:${port}`], own)
174
180
  const b = await pw.chromium.connectOverCDP(`http://127.0.0.1:${cdp}`)
175
- say(`${o.who}: filming on ${box} (${state.split(' ').slice(0, 2).join(' ')}, ${Math.round(performance.now() - t)} ms to its browser)`)
181
+ say(`${o.who}: filming on ${box}, browser ${boxSlotKey(cap.repo, lease.slot)} (${state.split(' ').slice(0, 2).join(' ')}, ${Math.round(performance.now() - t)} ms to it)`)
176
182
  const reached = new Set<number>()
177
183
  const pages: PwPage[] = []
178
184
  const browser = asLaunched(b, pages, o.store)
@@ -59,12 +59,22 @@ export function holderWords(h: { pid: number; check: string; since: number }, no
59
59
  return `pid ${h.pid} (${h.check}, held ${age})`
60
60
  }
61
61
 
62
+ /** a browser slot held: its index in the repo's pool (the box runs one browser per index, film-box.ts), its release */
63
+ export type BrowserLease = { slot: number; release: () => void }
64
+
65
+ type SlotOptions = { root?: string; say?: (l: string) => void; pollMs?: number; onBox?: boolean }
66
+
62
67
  /** wait for one of the repo's browser slots and hold it until the returned release (or this process ends), saying
63
68
  * once whom it waits on; outside any repo there is no cap and nothing is held. `onBox`: the browser runs on the
64
69
  * repo's box, this Mac only drives it */
65
- export async function browserSlot(who: string, o: { root?: string; say?: (l: string) => void; pollMs?: number; onBox?: boolean } = {}): Promise<() => void> {
70
+ export async function browserSlot(who: string, o: SlotOptions = {}): Promise<() => void> {
71
+ return (await browserLease(who, o)).release
72
+ }
73
+
74
+ /** browserSlot with the slot's index: on the box, the index names the browser the slot films in */
75
+ export async function browserLease(who: string, o: SlotOptions = {}): Promise<BrowserLease> {
66
76
  const c = await browserCap(o.root)
67
- if (c == null) return () => undefined
77
+ if (c == null) return { slot: 0, release: () => undefined }
68
78
  const no = browserRefusal(c, who, o.onBox === true)
69
79
  if (no != null) throw new Error(no)
70
80
  const say = o.say ?? ((l: string) => console.error(l))
@@ -77,5 +87,5 @@ export async function browserSlot(who: string, o: { root?: string; say?: (l: str
77
87
  say(`${who}: waiting for a browser of ${c.repo}${box ? ` on ${box.host}` : ''}, all ${cap} held (repo.config.ts ${key}): ${held.map((h) => holderWords(h)).join(', ') || 'a holder starting'}`),
78
88
  })
79
89
  if (got == null) throw new Error(`${who}: the browser slot wait of ${c.repo} stopped with no slot`)
80
- return got.release
90
+ return got
81
91
  }