rvlib-shipkit 2.19.0 → 2.20.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 +16 -0
- package/package.json +1 -1
- package/src/annex/annex.ts +227 -0
- package/src/annex/offload.ts +279 -0
- package/src/checks/SK040-release-words.check.ts +43 -0
- package/src/checks/SK041-annex-links.check.ts +28 -0
- package/src/checks/SK042-post-kinds.check.ts +73 -0
- package/src/cli/cmd_Annex.ts +179 -0
- package/src/cli/cmd_Commands.ts +4 -1
- package/src/cli/cmd_Home.ts +3 -2
- package/src/cli/cmd_Messages.ts +155 -0
- package/src/cli/cmd_Releases.ts +48 -0
- package/src/cli/cmd_Review.ts +161 -6
- package/src/cli/cmd_Shot.ts +4 -4
- package/src/cli/cmd_Social.ts +143 -6
- package/src/cli/family-pages.ts +2 -0
- package/src/cli/kit/index.ts +1 -1
- package/src/cli/kit/verb.ts +11 -3
- package/src/cli/registry.ts +6 -1
- package/src/collections/collection-types.ts +8 -1
- package/src/collections/providers.ts +4 -1
- package/src/commands/model.ts +36 -0
- package/src/commands/registry.ts +49 -0
- package/src/commands/routes.ts +59 -0
- package/src/commands/runner.ts +35 -0
- package/src/commands/runs.ts +112 -0
- package/src/core/app-icon.ts +4 -3
- package/src/core/icon-type.ts +8 -0
- package/src/core/jobs.ts +4 -3
- package/src/core/layout.ts +5 -2
- package/src/core/squircle.ts +95 -0
- package/src/home/daemon-jobs.ts +26 -2
- package/src/home/global-units.ts +3 -0
- package/src/home/gui-app/ShipkitGui.swift +302 -5
- package/src/home/gui-app.ts +63 -33
- package/src/home/hmr-keep.ts +134 -0
- package/src/home/home-start.ts +2 -2
- package/src/home/lib-watch.ts +21 -11
- package/src/home/pm.ts +1 -1
- package/src/home/process-apps.ts +181 -0
- package/src/home/resources.ts +3 -3
- package/src/home/run-web.ts +7 -4
- package/src/home/serve-web.ts +64 -14
- package/src/identities/collection.ts +49 -0
- package/src/identities/identities.ts +110 -8
- package/src/identities/machine.ts +4 -3
- package/src/identities/rating.ts +33 -0
- package/src/identities/shown.ts +170 -0
- package/src/identities/steps.ts +5 -0
- package/src/media-store/purge.ts +15 -1
- package/src/media-store/remote.ts +22 -6
- package/src/messages/brief.ts +117 -0
- package/src/messages/collection.ts +40 -0
- package/src/messages/model.ts +171 -0
- package/src/messages/routes.ts +15 -0
- package/src/messages/score.ts +180 -0
- package/src/messages/tabs.ts +13 -0
- package/src/release/notes.ts +130 -0
- package/src/release/run-bump.ts +41 -18
- package/src/release/run-release.ts +22 -4
- package/src/release/run-releases.ts +17 -15
- package/src/release/unit-resolve.ts +9 -0
- package/src/releases/add.ts +66 -0
- package/src/releases/collection.ts +36 -0
- package/src/releases/from-card.ts +66 -0
- package/src/releases/model.ts +267 -0
- package/src/releases/pictures.ts +89 -0
- package/src/releases/routes.ts +36 -0
- package/src/releases/store.ts +71 -0
- package/src/repo-config.ts +5 -0
- package/src/review/cells.ts +0 -11
- package/src/review/format.ts +10 -6
- package/src/review/model.ts +92 -3
- package/src/review/notes.ts +2 -48
- package/src/review/routes.ts +28 -10
- package/src/review/stage-card.ts +197 -0
- package/src/review/stage-routes.ts +123 -0
- package/src/review/store.ts +36 -0
- package/src/review/trailer-card.ts +99 -0
- package/src/review/trailer-desk.ts +57 -4
- package/src/review/trailer-model.ts +41 -7
- package/src/review/trailer-notes.ts +45 -0
- package/src/review/trailer-routes.ts +22 -13
- package/src/serve/hub-app/app-bridge.ts +71 -0
- package/src/serve/hub-app/commands/commands-page.tsx +122 -0
- package/src/serve/hub-app/commands/commands-st.ts +177 -0
- package/src/serve/hub-app/commands.css +24 -0
- package/src/serve/hub-app/hash-route.ts +40 -1
- package/src/serve/hub-app/home-st.ts +11 -2
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/hub-app.tsx +6 -0
- package/src/serve/hub-app/icons.tsx +5 -0
- package/src/serve/hub-app/identities-view.tsx +4 -1
- package/src/serve/hub-app/identities.css +1 -0
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +2 -2
- package/src/serve/hub-app/machine-st.ts +41 -10
- package/src/serve/hub-app/messages/messages-page.tsx +354 -0
- package/src/serve/hub-app/messages/messages-st.ts +74 -0
- package/src/serve/hub-app/messages.css +35 -0
- package/src/serve/hub-app/releases/releases-page.tsx +94 -0
- package/src/serve/hub-app/releases/releases-st.ts +69 -0
- package/src/serve/hub-app/releases.css +25 -0
- package/src/serve/hub-app/repo-sections.ts +15 -1
- package/src/serve/hub-app/repo-st.ts +56 -5
- package/src/serve/hub-app/review/clip-st.ts +31 -3
- package/src/serve/hub-app/review/note-place.ts +31 -0
- package/src/serve/hub-app/review/review-cells.tsx +27 -3
- package/src/serve/hub-app/review/review-st.ts +77 -2
- package/src/serve/hub-app/review/review-thread.tsx +9 -31
- package/src/serve/hub-app/review/review-views.tsx +164 -58
- package/src/serve/hub-app/review/thread-st.ts +108 -41
- package/src/serve/hub-app/review/trailer-card.tsx +187 -0
- package/src/serve/hub-app/review/trailer-page.tsx +62 -31
- package/src/serve/hub-app/review/trailer-st.ts +138 -26
- package/src/serve/hub-app/review/trailer-timeline.tsx +39 -26
- package/src/serve/hub-app/review.css +49 -6
- package/src/serve/hub-app/social/comms-page.tsx +55 -23
- package/src/serve/hub-app/social/identity-pictures.ts +46 -8
- package/src/serve/hub-app/social/kit.tsx +9 -6
- package/src/serve/hub-app/social/post-card.tsx +10 -2
- package/src/serve/hub-app/social/social-model.ts +37 -3
- package/src/serve/hub-app/social/social-page.tsx +179 -65
- package/src/serve/hub-app/social/social-st.ts +79 -26
- package/src/serve/hub-app/social/stage-popup.tsx +268 -0
- package/src/serve/hub-app/social/stage-st.ts +310 -0
- package/src/serve/hub-app/social/step-layout.ts +42 -0
- package/src/serve/hub-app/social.css +60 -1
- package/src/serve/hub-app/tree-build.ts +38 -1
- package/src/serve/hub-app/tree-svc.ts +10 -3
- package/src/serve/project-gutter-route.ts +4 -2
- package/src/serve/same-origin.ts +24 -1
- package/src/serve/serve-hub.ts +15 -1
- package/src/shipkit-files.ts +9 -7
- package/src/shot/shooter.ts +3 -3
- package/src/shot/shot-ask.ts +14 -3
- package/src/shot/shot.shipkit.ts +1 -1
- package/src/social/discord-layout.ts +48 -5
- package/src/social/fit.ts +84 -0
- package/src/social/identity-words.ts +74 -0
- package/src/social/kind-pages.ts +41 -0
- package/src/social/kinds.ts +92 -0
- package/src/social/load.ts +105 -9
- package/src/social/media-limit.ts +63 -2
- package/src/social/presence.ts +1 -1
- package/src/social/publish/bluesky.ts +58 -19
- package/src/social/publish/index.ts +31 -5
- package/src/social/reach.ts +49 -0
- package/src/social/release-stage.ts +173 -0
- package/src/social/routes.ts +42 -7
- package/src/social/stage.ts +227 -0
- package/src/social/strip.ts +85 -0
- package/src/social/text.ts +6 -2
- package/src/social/unit.ts +57 -1
- package/src/social/writes.ts +11 -0
- package/src/trailer/build.ts +15 -2
- package/src/trailer/grammar.ts +14 -4
- package/src/trailer/public-words.ts +41 -0
|
@@ -71,6 +71,17 @@ a.so-icon:visited{color:var(--dim)}
|
|
|
71
71
|
.so-rowname{flex:none;width:96px;align-self:center}
|
|
72
72
|
.so-rowvalue{flex:1;min-width:0;overflow-wrap:anywhere}
|
|
73
73
|
.so-uppics{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--s1)}
|
|
74
|
+
/* a picture row the account does not show as it is now */
|
|
75
|
+
.so-stale{display:flex;flex-direction:column;gap:2px;padding:var(--s1) var(--s2);border-radius:4px;border-left:4px solid var(--tone);background:color-mix(in srgb,var(--tone) 16%,var(--panel));font-size:12px;color:var(--ink)}
|
|
76
|
+
.so-stale b{font-size:12.5px;text-transform:uppercase;letter-spacing:.04em;color:var(--tone)}
|
|
77
|
+
.so-uploaded{align-self:stretch;justify-content:center;margin:0 var(--s2) var(--s2);font-weight:700}
|
|
78
|
+
.so-upband{font-weight:700;color:var(--dim);text-transform:uppercase;letter-spacing:.04em;font-size:10.5px;background:var(--panel2)}
|
|
79
|
+
.so-shownok{align-self:flex-start;margin:0 var(--s2) var(--s2)}
|
|
80
|
+
/* a text row he pastes: its state and « Done, pasted » at the row's end; a changed one marked whole */
|
|
81
|
+
.so-paste{flex:none;display:inline-flex;flex-direction:column;align-items:flex-end;gap:2px}
|
|
82
|
+
.so-chip .so-paste{flex-direction:row;align-items:center}
|
|
83
|
+
.so-pastebtn{font-size:11px;line-height:18px;padding:0 var(--s2);font-weight:700}
|
|
84
|
+
.so-rowtone{box-shadow:inset 4px 0 0 var(--tone);background:color-mix(in srgb,var(--tone) 10%,var(--panel))}
|
|
74
85
|
|
|
75
86
|
/* the list on the left */
|
|
76
87
|
.so-listcol{height:100%;display:flex;flex-direction:column;min-height:0;background:var(--panel)}
|
|
@@ -92,6 +103,10 @@ a.so-icon:visited{color:var(--dim)}
|
|
|
92
103
|
.so-draftrow.on .so-rowtitle{font-weight:800}
|
|
93
104
|
.so-rowtitle.small{font-size:12px}
|
|
94
105
|
.so-art{color:var(--review);margin-right:var(--s1)}
|
|
106
|
+
.so-kindwarn{color:var(--warn);margin-right:var(--s1);font-weight:700}
|
|
107
|
+
.so-kindproblem{font-size:12px;color:var(--warn);border-left:3px solid var(--warn);padding:2px var(--s2);background:color-mix(in srgb,var(--warn) 8%,transparent);border-radius:3px}
|
|
108
|
+
.so-kind{font-weight:700;color:var(--kt,var(--accent));border:1px solid color-mix(in srgb,var(--kt,var(--accent)) 55%,var(--line));border-radius:3px;padding:0 var(--s1);line-height:18px;text-decoration:none;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
109
|
+
a.so-kind:hover{text-decoration:underline}
|
|
95
110
|
.so-frac{flex:none;font-size:11px;font-weight:700;color:var(--dim);font-variant-numeric:tabular-nums}
|
|
96
111
|
.so-frac.t-ok{color:var(--ok)}
|
|
97
112
|
.so-who{flex:none;font-size:10px;font-weight:700;line-height:16px;padding:0 var(--s1);border-radius:3px;color:var(--k2);border:1px solid color-mix(in srgb,var(--k2) 55%,var(--line));max-width:96px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
@@ -256,7 +271,15 @@ a.so-go:visited{color:var(--accent)}
|
|
|
256
271
|
.so-steptext{flex:1;min-width:0;font-size:13.5px;line-height:1.5}
|
|
257
272
|
.so-chip{display:inline-flex;align-items:center;gap:var(--s1);vertical-align:middle;margin:var(--s0)}
|
|
258
273
|
.so-chip button,.so-chip .so-btn{font-size:11px;line-height:18px;padding:0 var(--s2)}
|
|
259
|
-
.so-chipvalue{display:inline-flex;align-items:center;gap:var(--s1);max-width:
|
|
274
|
+
.so-chipvalue{display:inline-flex;align-items:center;gap:var(--s1);max-width:100%;text-align:left}
|
|
275
|
+
.so-stepform{margin-top:var(--s2);border:1px solid var(--line);border-radius:6px;background:var(--panel);overflow:hidden;line-height:1.45}
|
|
276
|
+
.so-stepform > .so-row:first-child{border-top:0}
|
|
277
|
+
.so-stepform .so-rowfield{width:132px}
|
|
278
|
+
.so-steptext:has(> .so-stepform){container-type:inline-size}
|
|
279
|
+
@container (max-width:480px){.so-stepform .so-row{flex-wrap:wrap}.so-stepform .so-rowfield{width:100%}}
|
|
280
|
+
.so-step.done .so-stepform{opacity:.7}
|
|
281
|
+
.so-steppics{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;gap:var(--s1)}
|
|
282
|
+
.so-steptag{font-size:11px;font-weight:700;color:var(--dim);border:1px dashed var(--line);border-radius:4px;padding:0 var(--s1);white-space:nowrap}
|
|
260
283
|
.so-stepimg{height:34px;max-width:120px;object-fit:cover;border-radius:4px}
|
|
261
284
|
.so-badref{color:var(--red);font-size:11px}
|
|
262
285
|
.so-swatches{display:flex;gap:var(--s2);flex-wrap:wrap;padding:var(--s2) var(--s3)}
|
|
@@ -292,3 +315,39 @@ a.so-go:visited{color:var(--accent)}
|
|
|
292
315
|
.so-probrow{color:var(--ink);padding-left:calc(var(--s3) + var(--s4) + var(--s2))}
|
|
293
316
|
.so-probrow b{flex:none;max-width:55%;font-weight:600}
|
|
294
317
|
div.so-probrow{cursor:default}
|
|
318
|
+
|
|
319
|
+
/* a message refused by the repo's guard or a place, and a rated message's own switch */
|
|
320
|
+
.so-refused{font-size:12px;margin-top:var(--s1)}
|
|
321
|
+
|
|
322
|
+
/* the stage popup over a card: the media on the left, the words and where they go on the right */
|
|
323
|
+
.sg-veil{position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;background:var(--scrim);padding:var(--s3)}
|
|
324
|
+
.sg-pop{width:min(1180px,100%);max-height:100%;overflow:auto;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 12px 40px var(--scrim);display:flex;flex-direction:column}
|
|
325
|
+
.sg-head{display:flex;align-items:center;gap:var(--s2);padding:var(--s2) var(--s3);border-bottom:1px solid var(--line)}
|
|
326
|
+
.sg-head .sp,.sg-foot .sp{flex:1}
|
|
327
|
+
.sg-body{display:flex;gap:var(--s3);padding:var(--s3);min-height:0}
|
|
328
|
+
.sg-left{flex:1 1 52%;min-width:0;display:flex;flex-direction:column;gap:var(--s2)}
|
|
329
|
+
.sg-right{flex:1 1 48%;min-width:0;display:flex;flex-direction:column;gap:var(--s2)}
|
|
330
|
+
.sg-media{background:var(--bg);border-radius:8px;display:flex;align-items:center;justify-content:center;min-height:240px;max-height:62vh;overflow:hidden}
|
|
331
|
+
.sg-media img,.sg-media video{max-width:100%;max-height:62vh;object-fit:contain;display:block}
|
|
332
|
+
.sg-none{color:var(--dim)}
|
|
333
|
+
.sg-strip,.sg-chips{display:flex;flex-wrap:wrap;gap:var(--s1);align-items:center}
|
|
334
|
+
.sg-strip .rv-chip.on,.sg-chips .rv-chip.on{outline:2px solid var(--accent)}
|
|
335
|
+
.sg-from{font-size:11px;color:var(--dim);text-transform:uppercase;letter-spacing:.04em;margin-right:var(--s1)}
|
|
336
|
+
.sg-words{display:flex;flex-direction:column;gap:var(--s1);max-height:26vh;overflow:auto}
|
|
337
|
+
.sg-words .rv-chip{text-align:left;white-space:normal}
|
|
338
|
+
.sg-field{display:flex;align-items:center;gap:var(--s2);flex-wrap:wrap}
|
|
339
|
+
.sg-field > span:first-child{font-size:11px;color:var(--dim);text-transform:uppercase;letter-spacing:.04em;min-width:58px}
|
|
340
|
+
.sg-field input:not([type]),.sg-field select{flex:1;min-width:0}
|
|
341
|
+
.sg-text{width:100%;min-height:72px;resize:vertical;font:inherit}
|
|
342
|
+
.sg-goes{display:flex;flex-wrap:wrap;gap:var(--s1) var(--s3)}
|
|
343
|
+
.sg-acc{display:inline-flex;align-items:center;gap:var(--s1)}
|
|
344
|
+
.sg-acc.skip{opacity:.5}
|
|
345
|
+
.sg-acc.bad{color:var(--red)}
|
|
346
|
+
.sg-acc select{max-width:160px}
|
|
347
|
+
.sg-polish > span:first-child{min-width:0;text-transform:none;font-size:13px;color:var(--ink);letter-spacing:0}
|
|
348
|
+
.sg-problem{font-size:13px}
|
|
349
|
+
.sg-error{padding:var(--s1) var(--s3)}
|
|
350
|
+
.sg-foot{display:flex;align-items:center;gap:var(--s2);flex-wrap:wrap}
|
|
351
|
+
.sg-note{font-size:12px}
|
|
352
|
+
.rv-stagebtn{font-size:12px;padding:0 var(--s1)}
|
|
353
|
+
@media (max-width:767px){.sg-body{flex-direction:column}.sg-veil{padding:0}.sg-pop{border-radius:0;height:100%}}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// gets its row when a resource lands in it.
|
|
7
7
|
import { type Resource, type ResourceState, type ResourceType, type TestFacts } from '../../collections/collection-types.ts'
|
|
8
8
|
import type { ProcessRow, RowDot } from '../../home/process-rows.ts'
|
|
9
|
+
import type { CommandRow } from '../../cli/cmd_Commands.ts'
|
|
10
|
+
import type { RunView } from '../../commands/model.ts'
|
|
9
11
|
import { checkVerdictWords, plural } from '../../core/outcome-words.ts'
|
|
10
12
|
import { runsWords } from '../../core/runs-matrix.ts'
|
|
11
13
|
import { checkName } from './check-words.ts'
|
|
@@ -76,10 +78,13 @@ export const KIND_SECTION: Record<ResourceType, SectionId> = {
|
|
|
76
78
|
post: 'media',
|
|
77
79
|
wiki: 'wikis',
|
|
78
80
|
process: 'processes',
|
|
81
|
+
command: 'commands',
|
|
79
82
|
card: 'review',
|
|
80
83
|
cut: 'trailer',
|
|
81
84
|
store: 'stores',
|
|
85
|
+
release: 'releases',
|
|
82
86
|
veille: 'veille',
|
|
87
|
+
message: 'messages',
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
/** a process's colour: up reads green, crashed red, on its way orange,
|
|
@@ -101,6 +106,30 @@ export const processResources = (rows: readonly ProcessRow[]): Resource[] =>
|
|
|
101
106
|
state: PROCESS_STATE[r.dot],
|
|
102
107
|
}))
|
|
103
108
|
|
|
109
|
+
/** the project CLI's commands as tree leaves, read from the CLI itself (commands-st.ts), never from
|
|
110
|
+
* /api/resources.json. A family of more than one command is a branch named by its first word, its leaves by the
|
|
111
|
+
* rest; a command with a run going reads orange */
|
|
112
|
+
export function commandResources(rows: readonly CommandRow[], runs: readonly RunView[]): Resource[] {
|
|
113
|
+
const size = new Map<string, number>()
|
|
114
|
+
for (const r of rows) size.set(r.path.split(' ')[0]!, (size.get(r.path.split(' ')[0]!) ?? 0) + 1)
|
|
115
|
+
const going = new Set(runs.filter((r) => r.state === 'running').map((r) => r.path))
|
|
116
|
+
return rows.map((r): Resource => {
|
|
117
|
+
const family = r.path.split(' ')[0]!
|
|
118
|
+
const grouped = (size.get(family) ?? 0) > 1 && r.path !== family
|
|
119
|
+
return {
|
|
120
|
+
id: `command:${r.path}`,
|
|
121
|
+
type: 'command',
|
|
122
|
+
collection: 'commands',
|
|
123
|
+
path: `commands/${r.path.split(' ').join('/')}`,
|
|
124
|
+
virtual: true,
|
|
125
|
+
title: grouped ? r.path.slice(family.length + 1) : r.path,
|
|
126
|
+
text: r.description,
|
|
127
|
+
state: going.has(r.path) ? 'warn' : 'idle',
|
|
128
|
+
...(grouped ? { group: family } : {}),
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
104
133
|
/** a gate check lives under WHOSE it is: shipkit ships the SK checks, a
|
|
105
134
|
* repo owns what it declared. A kind the map does not know (a newer hub)
|
|
106
135
|
* still lands somewhere */
|
|
@@ -132,6 +161,10 @@ const byLabel = (a: TreeNode, b: TreeNode): number => {
|
|
|
132
161
|
const ad = a.res == null
|
|
133
162
|
const bd = b.res == null
|
|
134
163
|
if (ad !== bd) return ad ? -1 : 1 // groups first, then leaves
|
|
164
|
+
// leaves in a declared order first (a page's tabs), then by label
|
|
165
|
+
const ao = a.res?.order ?? Infinity
|
|
166
|
+
const bo = b.res?.order ?? Infinity
|
|
167
|
+
if (ao !== bo) return ao - bo
|
|
135
168
|
return a.label.localeCompare(b.label)
|
|
136
169
|
}
|
|
137
170
|
|
|
@@ -179,7 +212,8 @@ const groupOf = (r: Resource): Seg[] => {
|
|
|
179
212
|
if (r.check != null || r.type === 'contract' || r.type === 'secret') return []
|
|
180
213
|
if (r.type === 'ask') return isDone(r) ? [{ key: 'type:ask:done', label: 'done', kind: 'done', page: null }] : []
|
|
181
214
|
if (r.type === 'asset' && r.group != null) return [{ key: `cat:${r.group}`, label: r.group, kind: 'category', page: { t: 'cat', cat: r.group } }]
|
|
182
|
-
if (r.type === '
|
|
215
|
+
if (r.type === 'command' && r.group != null) return [{ key: `cmdfam:${r.group}`, label: r.group, kind: 'command', page: null }]
|
|
216
|
+
if (r.type === 'wiki' || r.type === 'asset' || r.type === 'test' || r.type === 'process' || r.type === 'command' || r.type === 'reflection' || r.type === 'message' || r.type === 'release') return []
|
|
183
217
|
return [{ key: `type:${r.type}`, label: r.type, kind: r.type, page: { t: 'col', id: r.collection } }]
|
|
184
218
|
}
|
|
185
219
|
|
|
@@ -398,10 +432,13 @@ export const TYPE_MARK: Record<string, TypeMark> = {
|
|
|
398
432
|
test: { glyph: '\u2263', hue: 'k5', word: 'a test file: the check that runs it, its last runs against its budget, the command that runs it alone' },
|
|
399
433
|
reflection: { glyph: '\u203b', hue: 'k2', word: 'a reflection: friction this repo logged against the wiki, waiting to be folded in' },
|
|
400
434
|
process: { glyph: '\u223f', hue: 'k1', word: 'a global process this repo declares: its state, its menu, its log' },
|
|
435
|
+
command: { glyph: '$', hue: 'k6', word: "a command of the repo's project CLI: its examples, its args, run from the page with its log live" },
|
|
401
436
|
card: { glyph: '\u25a3', hue: 'k2', word: 'a review card waiting for your answer: approve, fix, reject, circle a detail' },
|
|
402
437
|
cut: { glyph: '\u25b6', hue: 'k3', word: 'a trailer cut: play it with its timeline, pin a note on any frame' },
|
|
403
438
|
store: { glyph: '\u25a5', hue: 'k4', word: 'a store page (Steam, itch): every text to paste, every picture to upload, a note on each' },
|
|
439
|
+
release: { glyph: '\u2691', hue: 'k5', word: 'a version of the release notes: next.md being filled, or a released one, each change with its picture' },
|
|
404
440
|
veille: { glyph: '\u25ce', hue: 'k6', word: 'the Veille: the posts an identity scrolls past, ranked by the worth of a reply' },
|
|
441
|
+
message: { glyph: '\u275d', hue: 'k3', word: 'a tab of the messages page: the value for its cost, the personas, the page tops, the readers\u2019 notes' },
|
|
405
442
|
done: { glyph: '\u2713', hue: 'k5', word: 'a done ask: answered, filed under done, out of every count above it' },
|
|
406
443
|
}
|
|
407
444
|
|
|
@@ -9,7 +9,7 @@ import type { RepoSt } from './repo-st.ts'
|
|
|
9
9
|
import type { Resource } from './hub-types.ts'
|
|
10
10
|
import { repoSections, type RepoSection } from './repo-sections.ts'
|
|
11
11
|
import { walkKey, type WalkHost } from './list-walk.ts'
|
|
12
|
-
import { buildTree, dirKeys, flattenTree, matchesQuery, passesFilter, processResources, whenCounts, type TreeNode, type TreeRow } from './tree-build.ts'
|
|
12
|
+
import { buildTree, commandResources, dirKeys, flattenTree, matchesQuery, passesFilter, processResources, whenCounts, type TreeNode, type TreeRow } from './tree-build.ts'
|
|
13
13
|
|
|
14
14
|
const EXPANDED_KEY = 'shipkit.tree.expanded'
|
|
15
15
|
|
|
@@ -49,9 +49,10 @@ export class TreeSvc implements WalkHost<TreeRow> {
|
|
|
49
49
|
* branches that still hold something. A search names a thing to find,
|
|
50
50
|
* so it reads every row: the severity group applies only while it is empty */
|
|
51
51
|
/** every row the tree can show: the hub's resources, then the repo's
|
|
52
|
-
* global processes, which pm reports and the hub never lists
|
|
52
|
+
* global processes, which pm reports and the hub never lists, then the
|
|
53
|
+
* commands of its project CLI, which the CLI itself lists */
|
|
53
54
|
private get all(): Resource[] {
|
|
54
|
-
return [...this.st.cols.resources, ...processResources(this.st.globalProcesses)]
|
|
55
|
+
return [...this.st.cols.resources, ...processResources(this.st.globalProcesses), ...commandResources(this.st.commands.rows, this.st.commands.runs)]
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
get visible(): Resource[] {
|
|
@@ -121,6 +122,12 @@ export class TreeSvc implements WalkHost<TreeRow> {
|
|
|
121
122
|
this.expanded.has(key) ? this.expanded.delete(key) : this.expanded.add(key)
|
|
122
123
|
this.save()
|
|
123
124
|
}
|
|
125
|
+
/** unfold a branch the page shown lives in, so its rows are in sight (a page's tab rows); kept like a fold */
|
|
126
|
+
reveal(key: string): void {
|
|
127
|
+
if (this.expanded.has(key)) return
|
|
128
|
+
this.expanded.add(key)
|
|
129
|
+
this.save()
|
|
130
|
+
}
|
|
124
131
|
expandAll(): void {
|
|
125
132
|
for (const k of dirKeys(this.nodes)) this.expanded.add(k)
|
|
126
133
|
this.save()
|
|
@@ -27,7 +27,7 @@ import { appIconOf, appIconPngs, identityOfRoot } from '../core/app-icon.ts'
|
|
|
27
27
|
import { waitingCards } from '../collections/review.ts'
|
|
28
28
|
import { storeDir, warmStore } from '../review/store.ts'
|
|
29
29
|
import { writeArchived } from '../core/archived.ts'
|
|
30
|
-
import { identitiesDir } from '../identities/identities.ts'
|
|
30
|
+
import { identitiesDir, pictureVersion } from '../identities/identities.ts'
|
|
31
31
|
import { identityCache, markFile, railOf, speakerIdOf, type RailIdentity } from '../identities/machine.ts'
|
|
32
32
|
import { speaksAsOfText } from '../social/house.ts'
|
|
33
33
|
|
|
@@ -441,7 +441,9 @@ export function projectGutter(d: GutterDeps) {
|
|
|
441
441
|
const i = (await readIds()).identities.find((x) => x.id === id)
|
|
442
442
|
const file = i == null ? null : markFile(i)
|
|
443
443
|
if (file == null || !existsSync(file)) return new Response(`no mark for the identity ${JSON.stringify(id)}`, { status: 404 })
|
|
444
|
-
|
|
444
|
+
// the url names the file's version (markUrl): kept for good while it is the current one, else asked again
|
|
445
|
+
const v = new URL(req.url).searchParams.get('v')
|
|
446
|
+
return new Response(Bun.file(file), { headers: { 'cache-control': v != null && v !== '' && v === pictureVersion(file) ? 'public, max-age=31536000, immutable' : 'no-cache' } })
|
|
445
447
|
}
|
|
446
448
|
if (path.startsWith('/api/projects/app-icon/')) {
|
|
447
449
|
if (repos.length === 0) await answer()
|
package/src/serve/same-origin.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
// the one guard on a request that changes something, shared by the hub and
|
|
2
|
-
// the standalone graph server.
|
|
2
|
+
// the standalone graph server, and where a request came from.
|
|
3
|
+
|
|
4
|
+
/** a Host header's name: its port, brackets and trailing dot gone, lowercase */
|
|
5
|
+
export function hostName(host: string): string {
|
|
6
|
+
const h = host.trim().toLowerCase()
|
|
7
|
+
const name = h.startsWith('[') ? h.slice(1, h.indexOf(']') < 0 ? undefined : h.indexOf(']')) : h.replace(/:\d+$/, '')
|
|
8
|
+
return name.replace(/\.$/, '')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** a name only this machine resolves to itself */
|
|
12
|
+
export const loopbackName = (n: string): boolean => n === 'localhost' || n.endsWith('.localhost') || n === '::1' || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)
|
|
13
|
+
|
|
14
|
+
/** where a request came from: this machine, or another one over the tailnet (his phone) */
|
|
15
|
+
export type Reach = 'local' | 'tailnet'
|
|
16
|
+
/** the web's tag on what it forwards to the daemon, which never sees the browser's Host */
|
|
17
|
+
export const REACH_HEADER = 'x-shipkit-reach'
|
|
18
|
+
|
|
19
|
+
export const reachOfHost = (host: string | null): Reach => (host != null && host !== '' && loopbackName(hostName(host)) ? 'local' : 'tailnet')
|
|
20
|
+
|
|
21
|
+
/** the web's tag when it forwarded the request, else this server's own Host */
|
|
22
|
+
export function reachOf(req: Request): Reach {
|
|
23
|
+
const tag = req.headers.get(REACH_HEADER)
|
|
24
|
+
return tag === 'local' || tag === 'tailnet' ? tag : reachOfHost(req.headers.get('host') ?? new URL(req.url).host)
|
|
25
|
+
}
|
|
3
26
|
/** 127.0.0.1 keeps other machines out, not other sites: any page open in the
|
|
4
27
|
* browser can POST to localhost. A request that changes something passes
|
|
5
28
|
* only from the hub's own page, or from a client that is not a browser at
|
package/src/serve/serve-hub.ts
CHANGED
|
@@ -39,6 +39,10 @@ import { readmeRoutes } from './readme-route.ts'
|
|
|
39
39
|
import { reviewRoutes } from '../review/routes.ts'
|
|
40
40
|
import { veilleRoutes } from '../veille/routes.ts'
|
|
41
41
|
import { storesRoutes } from '../stores/routes.ts'
|
|
42
|
+
import { messagesRoutes } from '../messages/routes.ts'
|
|
43
|
+
import { releasesRoutes } from '../releases/routes.ts'
|
|
44
|
+
import { commandsRoutes } from '../commands/routes.ts'
|
|
45
|
+
import { noCli } from '../commands/registry.ts'
|
|
42
46
|
import { socialRoutes } from '../social/routes.ts'
|
|
43
47
|
import { embedRoute } from './embed.ts'
|
|
44
48
|
import { pagesRoutes } from '../pages/routes.ts'
|
|
@@ -223,7 +227,8 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
223
227
|
// editor: only the server knows where this repo sits on disk
|
|
224
228
|
// `uses` tells the home which machine resources this repo needs,
|
|
225
229
|
// `base` where this hub's page sits on the server that answers
|
|
226
|
-
|
|
230
|
+
// `cli`: the repo has a project CLI, so its commands section is no greyed row
|
|
231
|
+
if (path === '/hub.json') return Response.json({ hub: 'shipkit', name: d.name, root: d.root, base, tools, uses: d.uses ?? [], cli: noCli(d.root) == null })
|
|
227
232
|
if (path.startsWith('/api/projects')) return (await projects.handle(req, path)) ?? new Response('not found', { status: 404 })
|
|
228
233
|
// where the machine's home serves, and whether it does: a rail
|
|
229
234
|
// click opens the home on that repo, or VS Code while none runs
|
|
@@ -367,6 +372,15 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
367
372
|
// the store pages' desk (stores/routes.ts)
|
|
368
373
|
const stores = await storesRoutes(d.root, req, path)
|
|
369
374
|
if (stores != null) return stores
|
|
375
|
+
// the release files and their private pictures (releases/routes.ts)
|
|
376
|
+
const releases = await releasesRoutes(d.root, req, path)
|
|
377
|
+
if (releases != null) return releases
|
|
378
|
+
// the project CLI run from the page (commands/routes.ts)
|
|
379
|
+
const commands = await commandsRoutes(d.root, req, path)
|
|
380
|
+
if (commands != null) return commands
|
|
381
|
+
// the messages store, read whole (messages/routes.ts)
|
|
382
|
+
const messages = messagesRoutes(d.root, req, path)
|
|
383
|
+
if (messages != null) return messages
|
|
370
384
|
// the Communications and Social desks (social/routes.ts)
|
|
371
385
|
const social = await socialRoutes(d.root, req, path)
|
|
372
386
|
if (social != null) return social
|
package/src/shipkit-files.ts
CHANGED
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
import { check, type CheckDef } from './check.ts'
|
|
26
26
|
import { review, type AutoRule, type KindDef, type ReviewDef, type ReviewSource, type ReviewUnit } from './review/unit.ts'
|
|
27
27
|
import { site, type SiteDef, type SiteUnit } from './site/unit.ts'
|
|
28
|
-
import { social, type SocialDef, type SocialUnit } from './social/unit.ts'
|
|
28
|
+
import { social, type GuardInput, type ReleaseHeading, type SocialDef, type SocialUnit, type SuggestedLine } from './social/unit.ts'
|
|
29
29
|
import { stores, type StoresDef, type StoresUnit } from './stores/unit.ts'
|
|
30
30
|
import { trailer, type TrailerDef, type TrailerUnit } from './trailer/adapter.ts'
|
|
31
|
+
import { ICON_IMAGE_TYPES, iconImageType } from './core/icon-type.ts'
|
|
31
32
|
|
|
32
33
|
export { check, review, site, social, stores, trailer }
|
|
33
|
-
export type { AutoRule, KindDef, ReviewDef, ReviewSource, ReviewUnit, SiteDef, SiteUnit, SocialDef, SocialUnit, StoresDef, StoresUnit, TrailerDef, TrailerUnit }
|
|
34
|
+
export type { AutoRule, GuardInput, KindDef, ReleaseHeading, ReviewDef, ReviewSource, ReviewUnit, SiteDef, SiteUnit, SocialDef, SocialUnit, StoresDef, StoresUnit, SuggestedLine, TrailerDef, TrailerUnit }
|
|
34
35
|
|
|
35
36
|
/** one button beside a global process: a command, or a function of the file */
|
|
36
37
|
export type ProcessAction = {
|
|
@@ -48,6 +49,10 @@ export type GlobalProcessDef = {
|
|
|
48
49
|
id: string
|
|
49
50
|
/** the name on the switch (default the id) */
|
|
50
51
|
label?: string
|
|
52
|
+
/** the name of its macOS app in ~/Applications, where Spotlight and
|
|
53
|
+
* Launchpad find it (default the label). Only a process with a url has
|
|
54
|
+
* one; the daemon builds it, and removes it when the process goes */
|
|
55
|
+
app?: string
|
|
51
56
|
/** one line: what it is for */
|
|
52
57
|
description?: string
|
|
53
58
|
/** the machine it runs on, as a hint beside the switch */
|
|
@@ -93,11 +98,7 @@ const KEBAB = /^[a-z0-9][a-z0-9-]*$/
|
|
|
93
98
|
const words = (v: unknown): boolean => Array.isArray(v) && v.length > 0 && v.every((w) => typeof w === 'string')
|
|
94
99
|
const httpUrl = (v: unknown): boolean => typeof v === 'string' && /^https?:\/\//.test(v)
|
|
95
100
|
|
|
96
|
-
|
|
97
|
-
export const ICON_IMAGE_TYPES: Record<string, string> = { png: 'image/png', svg: 'image/svg+xml', ico: 'image/x-icon', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp' }
|
|
98
|
-
|
|
99
|
-
/** the image an icon names (its extension), or null when it is text */
|
|
100
|
-
export const iconImageType = (icon: string): string | null => ICON_IMAGE_TYPES[/\.([a-z]+)$/i.exec(icon)?.[1]?.toLowerCase() ?? ''] ?? null
|
|
101
|
+
export { ICON_IMAGE_TYPES, iconImageType }
|
|
101
102
|
|
|
102
103
|
function iconProblem(icon: unknown): string | null {
|
|
103
104
|
if (typeof icon !== 'string' || icon.trim() === '') return 'icon is an emoji or a repo relative image path'
|
|
@@ -113,6 +114,7 @@ export function globalProcessProblem(d: GlobalProcessDef): string | null {
|
|
|
113
114
|
if (!words(d.cmd)) return `${at}: cmd is a list of words`
|
|
114
115
|
if (d.down != null && !words(d.down)) return `${at}: down is a list of words`
|
|
115
116
|
if (d.url != null && !httpUrl(d.url)) return `${at}: url must be an http url`
|
|
117
|
+
if (d.app !== undefined && (typeof d.app !== 'string' || d.app.trim() === '' || /^\.|[/:]/.test(d.app))) return `${at}: app is a file name: not empty, no leading dot, no / or :`
|
|
116
118
|
if (d.probe != null && !httpUrl(d.probe)) return `${at}: probe must be an http url`
|
|
117
119
|
if (d.down != null && d.probe == null && d.url == null) return `${at}: a bring-up (one with down) needs probe or url, the only truth of whether it is up`
|
|
118
120
|
if (d.icon !== undefined) {
|
package/src/shot/shooter.ts
CHANGED
|
@@ -27,7 +27,7 @@ import { loadPlaywright } from '../smoke/run-smoke.ts'
|
|
|
27
27
|
import { CLIP_INIT, CLIP_QUANTIZER, clipDone, installClip, KEY_EVERY, muxArgs, type PageClipAsk, type PageClipDone, TAKE, takeClip } from './clip-encoder.ts'
|
|
28
28
|
import { type ClipPath, clipPathOf, domEncodeArgs, FrameTimeline, largestCanvas, screencastParams } from './dom-clip.ts'
|
|
29
29
|
import { openBrowser, type PwBrowser } from './box.ts'
|
|
30
|
-
import { capMsOf, type ClipAsk, pageMove, readMark, type ShotAsk, slotKey, Turns, waitReady } from './shot-ask.ts'
|
|
30
|
+
import { capMsOf, type ClipAsk, pageMove, readMark, type ShotAsk, slotKey, stillFormat, Turns, waitReady } from './shot-ask.ts'
|
|
31
31
|
|
|
32
32
|
/** the slice of playwright the shots touch, so the lib types nothing it does not ship */
|
|
33
33
|
type Cdp = {
|
|
@@ -139,7 +139,7 @@ export class Shooter {
|
|
|
139
139
|
return { browser: this.#browser?.isConnected() === true, url: this.#slot?.url ?? null, waiting: this.#turns.waiting }
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
/** a
|
|
142
|
+
/** a still of the url, written at `a.out`, encoded by its extension (stillFormat) */
|
|
143
143
|
shot(a: ShotAsk): Promise<ShotDone> {
|
|
144
144
|
return this.#turns.run(() => withCap(`the shot of ${a.url}`, capMsOf(a), this.#shot(a)).finally(() => this.#touch()))
|
|
145
145
|
}
|
|
@@ -291,7 +291,7 @@ export class Shooter {
|
|
|
291
291
|
phases['step'] = ms(t)
|
|
292
292
|
}
|
|
293
293
|
t = performance.now()
|
|
294
|
-
const r = await slot.cdp.send('Page.captureScreenshot', {
|
|
294
|
+
const r = await slot.cdp.send('Page.captureScreenshot', { ...stillFormat(a.out), optimizeForSpeed: true })
|
|
295
295
|
phases['capture'] = ms(t)
|
|
296
296
|
mkdirSync(dirname(a.out), { recursive: true })
|
|
297
297
|
await Bun.write(a.out, Buffer.from(String(r['data']), 'base64'))
|
package/src/shot/shot-ask.ts
CHANGED
|
@@ -65,8 +65,19 @@ export function normalizeUrl(s: string): string {
|
|
|
65
65
|
throw new Error(`'${s}' is not a url: give http://host:port/path, localhost:5173/path or :5173/path`)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
|
|
68
|
+
/** a still's quality as webp or jpeg: the page's text stays sharp at about an eighth of the png's bytes (a 1280x800
|
|
69
|
+
* page: png 1004 KB, webp 126 KB) */
|
|
70
|
+
export const STILL_QUALITY = 90
|
|
71
|
+
/** a still's encoding by its file's extension: webp and jpeg at STILL_QUALITY, png (lossless) for anything else */
|
|
72
|
+
export function stillFormat(out: string): { format: 'webp' | 'jpeg'; quality: number } | { format: 'png' } {
|
|
73
|
+
if (/\.webp$/i.test(out)) return { format: 'webp', quality: STILL_QUALITY }
|
|
74
|
+
if (/\.jpe?g$/i.test(out)) return { format: 'jpeg', quality: STILL_QUALITY }
|
|
75
|
+
return { format: 'png' }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** the file a shot lands in when no `--out` is given: under the repo's local scratch, named after the url; a still
|
|
79
|
+
* is a webp */
|
|
80
|
+
export function defaultOut(url: string, ext: 'webp' | 'mp4'): string {
|
|
70
81
|
const u = new URL(url)
|
|
71
82
|
const slug = `${u.hostname}-${u.port || (u.protocol === 'https:' ? '443' : '80')}${u.pathname}${u.search}${u.hash}`
|
|
72
83
|
.replace(/[^\w.-]+/g, '-')
|
|
@@ -113,7 +124,7 @@ export function askOf(f: ShotFlags, cwd: string): ShotAsk | ClipAsk {
|
|
|
113
124
|
url,
|
|
114
125
|
viewport: f.viewport == null ? DEFAULT_VIEWPORT : parseViewport(f.viewport),
|
|
115
126
|
dpr: f.dpr == null ? 1 : positive('--dpr', f.dpr, 4),
|
|
116
|
-
out: resolve(cwd, f.out ?? defaultOut(url, seconds == null ? '
|
|
127
|
+
out: resolve(cwd, f.out ?? defaultOut(url, seconds == null ? 'webp' : 'mp4')),
|
|
117
128
|
reload: f.reload === true,
|
|
118
129
|
waitMs: f.wait == null ? DEFAULT_WAIT_MS : f.wait === '0' ? 0 : positive('--wait', f.wait, 60_000),
|
|
119
130
|
}
|
package/src/shot/shot.shipkit.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { shotUrlBase } from './shot-ask.ts'
|
|
|
7
7
|
export default globalProcess({
|
|
8
8
|
id: 'shot',
|
|
9
9
|
label: 'shots',
|
|
10
|
-
description: 'warm headless browser: sk shot <url> gives a
|
|
10
|
+
description: 'warm headless browser: sk shot <url> gives a webp, --video a clip, for every repo',
|
|
11
11
|
cmd: ['bun', join(import.meta.dir, 'serve-shot.ts')],
|
|
12
12
|
probe: `${shotUrlBase()}/health`,
|
|
13
13
|
icon: '📸',
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// an identity's Discord server as data (wiki tools/shipkit/social-identities.md, The server's layout): `layout.md`
|
|
2
2
|
// beside its discord account.md, made true through the account's bot. Nothing is deleted unless asked, and never a
|
|
3
|
-
// channel that holds a message; a server that already matches gets no call but the reads
|
|
3
|
+
// channel that holds a message; a server that already matches gets no call but the reads. Its stale picture rows
|
|
4
|
+
// (icon, banner, invite splash) are set with it (What each account shows)
|
|
4
5
|
import { existsSync, readFileSync } from 'node:fs'
|
|
5
6
|
import { join } from 'node:path'
|
|
6
7
|
import type { Account } from '../identities/identities.ts'
|
|
8
|
+
import { DISCORD_ROWS, recordPushed, toPush, type PushReport } from '../identities/shown.ts'
|
|
7
9
|
import { parseFrontmatter } from './md.ts'
|
|
8
10
|
import { call, channelKey } from './publish/discord.ts'
|
|
9
11
|
|
|
@@ -123,9 +125,47 @@ export function channelChanges(ch: Channel, want: { name: string; parent_id: str
|
|
|
123
125
|
return out
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
export type ApplyReport =
|
|
128
|
+
export type ApplyReport = PushReport
|
|
127
129
|
|
|
128
|
-
/**
|
|
130
|
+
/** what the bot's calls go through: the real api, or a test's */
|
|
131
|
+
export type Send = <T>(a: Account, method: string, path: string, body?: BodyInit) => Promise<T>
|
|
132
|
+
|
|
133
|
+
/** the guild features a server needs before its banner or invite splash takes a picture */
|
|
134
|
+
const NEEDS: Readonly<Record<string, string>> = { banner: 'BANNER', splash: 'INVITE_SPLASH' }
|
|
135
|
+
|
|
136
|
+
/** a picture as a data uri, the way Discord's api takes an image */
|
|
137
|
+
const dataUri = (abs: string): string => `data:${/\.png$/i.test(abs) ? 'image/png' : /\.webp$/i.test(abs) ? 'image/webp' : /\.gif$/i.test(abs) ? 'image/gif' : 'image/jpeg'};base64,${readFileSync(abs).toString('base64')}`
|
|
138
|
+
|
|
139
|
+
/** the server's stale picture rows (icon, banner, invite splash) set through the bot in one call, each recorded in
|
|
140
|
+
* shown.md; a banner or splash its boost level does not allow is left with the reason, still stale */
|
|
141
|
+
export async function pushServerPictures(a: Account, o: { dry: boolean }, send: Send = call, guild?: { features: string[] }): Promise<PushReport> {
|
|
142
|
+
const out: PushReport = { changes: [], left: [], recorded: [] }
|
|
143
|
+
const stale = toPush(a.uploads, 'discord')
|
|
144
|
+
if (stale.length === 0 || a.guild === '') return out
|
|
145
|
+
const g = guild ?? (await send<{ features: string[] }>(a, 'GET', `/guilds/${a.guild}`))
|
|
146
|
+
const body: Record<string, string> = {}
|
|
147
|
+
const sent: typeof stale = []
|
|
148
|
+
for (const u of stale) {
|
|
149
|
+
const key = DISCORD_ROWS[u.field]!
|
|
150
|
+
const need = NEEDS[key]
|
|
151
|
+
if (need != null && !g.features.includes(need)) {
|
|
152
|
+
out.left.push(`${u.field}: the server's boost level allows none yet (no ${need}), still stale`)
|
|
153
|
+
continue
|
|
154
|
+
}
|
|
155
|
+
body[key] = dataUri(u.abs[0]!)
|
|
156
|
+
sent.push(u)
|
|
157
|
+
}
|
|
158
|
+
if (sent.length === 0) return out
|
|
159
|
+
const words = sent.map((u) => `${u.field} (${u.files[0]})`).join(', ')
|
|
160
|
+
out.changes.push(o.dry ? `would set the server's ${words}` : `set the server's ${words}`)
|
|
161
|
+
if (o.dry) return out
|
|
162
|
+
await send(a, 'PATCH', `/guilds/${a.guild}`, JSON.stringify(body))
|
|
163
|
+
for (const u of sent) out.recorded.push(recordPushed(a, u))
|
|
164
|
+
return out
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** makes the account's server match its layout and its picture rows; what it did (or would do, dry), what it left
|
|
168
|
+
* alone, the shown.md it wrote */
|
|
129
169
|
export async function applyLayout(a: Account, o: { dry: boolean; prune: boolean }): Promise<ApplyReport> {
|
|
130
170
|
const layout = layoutOf(a)
|
|
131
171
|
if (a.guild === '') {
|
|
@@ -140,8 +180,11 @@ export async function applyLayout(a: Account, o: { dry: boolean; prune: boolean
|
|
|
140
180
|
changes.push(o.dry ? `would ${what}` : what)
|
|
141
181
|
if (!o.dry) await run()
|
|
142
182
|
}
|
|
143
|
-
const guild = await call<{ name: string; owner_id: string }>(a, 'GET', `/guilds/${G}`)
|
|
183
|
+
const guild = await call<{ name: string; owner_id: string; features: string[] }>(a, 'GET', `/guilds/${G}`)
|
|
144
184
|
if (guild.name !== layout.name) await act(`rename the server « ${layout.name} »`, () => call(a, 'PATCH', `/guilds/${G}`, json({ name: layout.name })))
|
|
185
|
+
const pictures = await pushServerPictures(a, o, call, guild)
|
|
186
|
+
changes.push(...pictures.changes)
|
|
187
|
+
left.push(...pictures.left)
|
|
145
188
|
|
|
146
189
|
const roles = await call<Role[]>(a, 'GET', `/guilds/${G}/roles`)
|
|
147
190
|
const roleIds = new Map<string, string>()
|
|
@@ -235,5 +278,5 @@ export async function applyLayout(a: Account, o: { dry: boolean; prune: boolean
|
|
|
235
278
|
if (o.prune && empty && x.type === TEXT) await act(`delete #${x.name} (empty)`, () => call(a, 'DELETE', `/channels/${x.id}`))
|
|
236
279
|
else left.push(`${x.type === CATEGORY ? 'category ' : '#'}${x.name}${x.type === TEXT ? (empty ? ' (empty, --prune deletes it)' : ' (holds messages)') : ''}`)
|
|
237
280
|
}
|
|
238
|
-
return { changes, left }
|
|
281
|
+
return { changes, left, recorded: pictures.recorded }
|
|
239
282
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// a staged media cut or shrunk before it is copied into a draft (wiki tools/shipkit/social.md, A post staged): a clip's
|
|
2
|
+
// passage between his in and out, and « fit », one copy within the tightest limits of the venues it goes to (the
|
|
3
|
+
// seconds first, then the bytes: a lower bitrate, a smaller frame). Each writes a new file in a scratch folder; the
|
|
4
|
+
// stage then copies it clean like any media. ffmpeg on the CPU, never the GPU
|
|
5
|
+
import { mkdtempSync, statSync } from 'node:fs'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
7
|
+
import { extname, join } from 'node:path'
|
|
8
|
+
import sharp from 'sharp'
|
|
9
|
+
import type { MediaLimits } from '../identities/identities.ts'
|
|
10
|
+
import { mp4Seconds } from './media-limit.ts'
|
|
11
|
+
|
|
12
|
+
const VIDEO = /\.(mp4|m4v|mov|webm)$/i
|
|
13
|
+
const IMAGE = /\.(png|jpe?g|webp)$/i
|
|
14
|
+
|
|
15
|
+
const scratch = (name: string): string => join(mkdtempSync(join(tmpdir(), 'stage-fit-')), name)
|
|
16
|
+
|
|
17
|
+
function ffmpeg(args: string[]): void {
|
|
18
|
+
const r = Bun.spawnSync(['ffmpeg', '-v', 'error', '-y', ...args], { stdout: 'ignore', stderr: 'pipe' })
|
|
19
|
+
if (r.exitCode !== 0) throw new Error(`ffmpeg: ${r.stderr.toString().trim().split('\n').at(-1) ?? `exit ${r.exitCode}`}`)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** a clip's length in seconds: its mvhd box, else ffprobe */
|
|
23
|
+
export function secondsOf(file: string): number {
|
|
24
|
+
const s = /\.(mp4|m4v|mov)$/i.test(file) ? mp4Seconds(file) : null
|
|
25
|
+
if (s != null) return s
|
|
26
|
+
const r = Bun.spawnSync(['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of', 'default=nw=1:nk=1', file], { stdout: 'pipe', stderr: 'ignore' })
|
|
27
|
+
const d = Number(r.stdout.toString().trim())
|
|
28
|
+
if (!Number.isFinite(d)) throw new Error(`${file}: no length ffprobe reads`)
|
|
29
|
+
return d
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** the passage of a clip from `from` to `to` seconds, encoded again so it starts on its first frame: an mp4 */
|
|
33
|
+
export function cutPassage(file: string, from: number, to: number): string {
|
|
34
|
+
if (!VIDEO.test(file)) throw new Error(`a passage is cut from a clip, not ${extname(file)}`)
|
|
35
|
+
const len = secondsOf(file)
|
|
36
|
+
if (!(from >= 0 && to > from && from < len)) throw new Error(`passage ${from} s to ${to} s: in a clip of ${len.toFixed(2)} s, in before out`)
|
|
37
|
+
const out = scratch('passage.mp4')
|
|
38
|
+
ffmpeg(['-ss', String(from), '-to', String(Math.min(to, len)), '-i', file, '-c:v', 'libx264', '-crf', '18', '-preset', 'veryfast', '-pix_fmt', 'yuv420p', '-c:a', 'aac', '-b:a', '128k', '-movflags', '+faststart', out])
|
|
39
|
+
return out
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** the tightest of several venues' limits: each bound the smallest one any venue names */
|
|
43
|
+
export function tightest(all: readonly MediaLimits[]): MediaLimits {
|
|
44
|
+
const min = (k: keyof MediaLimits): number | undefined => {
|
|
45
|
+
const v = all.flatMap((l) => (l[k] == null ? [] : [l[k]!]))
|
|
46
|
+
return v.length ? Math.min(...v) : undefined
|
|
47
|
+
}
|
|
48
|
+
const out: MediaLimits = {}
|
|
49
|
+
for (const k of ['imageBytes', 'videoBytes', 'videoSeconds'] as const) {
|
|
50
|
+
const v = min(k)
|
|
51
|
+
if (v != null) out[k] = v
|
|
52
|
+
}
|
|
53
|
+
return out
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** one copy within the limits, or the file itself when it already fits; a clip: its first seconds up to the bound, then
|
|
57
|
+
* a bitrate that lands under the bytes with a margin; an image: a jpeg whose quality steps down until it fits */
|
|
58
|
+
export async function fitTo(file: string, l: MediaLimits): Promise<string> {
|
|
59
|
+
const size = statSync(file).size
|
|
60
|
+
if (IMAGE.test(file)) {
|
|
61
|
+
if (l.imageBytes == null || size <= l.imageBytes) return file
|
|
62
|
+
for (const [q, w] of [[90, 4096], [82, 2560], [74, 2048], [66, 1600], [58, 1280]] as const) {
|
|
63
|
+
const out = scratch(`fit-${q}.jpg`)
|
|
64
|
+
await sharp(file).rotate().resize({ width: w, height: w, fit: 'inside', withoutEnlargement: true }).jpeg({ quality: q, mozjpeg: true }).toFile(out)
|
|
65
|
+
if (statSync(out).size <= l.imageBytes) return out
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`${file}: no jpeg under ${(l.imageBytes / 1e6).toFixed(1)} MB down to 1280 px`)
|
|
68
|
+
}
|
|
69
|
+
if (!VIDEO.test(file)) return file
|
|
70
|
+
const len = secondsOf(file)
|
|
71
|
+
const secs = l.videoSeconds != null && len > l.videoSeconds ? l.videoSeconds : len
|
|
72
|
+
if (secs === len && (l.videoBytes == null || size <= l.videoBytes)) return file
|
|
73
|
+
const out = scratch('fit.mp4')
|
|
74
|
+
const kbps = l.videoBytes == null ? null : Math.floor(((l.videoBytes * 8 * 0.9) / secs - 128_000) / 1000)
|
|
75
|
+
if (kbps != null && kbps < 300) throw new Error(`${file}: ${secs.toFixed(1)} s under ${(l.videoBytes! / 1e6).toFixed(0)} MB leaves ${kbps} kb/s, too few for a clip worth posting: cut a passage`)
|
|
76
|
+
ffmpeg([
|
|
77
|
+
'-i', file, '-t', String(secs),
|
|
78
|
+
'-c:v', 'libx264', '-preset', 'veryfast', '-pix_fmt', 'yuv420p',
|
|
79
|
+
...(kbps == null ? ['-crf', '20'] : ['-b:v', `${kbps}k`, '-maxrate', `${kbps}k`, '-bufsize', `${kbps * 2}k`]),
|
|
80
|
+
'-vf', 'scale=w=min(1920\\,iw):h=-2',
|
|
81
|
+
'-c:a', 'aac', '-b:a', '128k', '-movflags', '+faststart', out,
|
|
82
|
+
])
|
|
83
|
+
return out
|
|
84
|
+
}
|