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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// the stage popup over a card (wiki tools/shipkit/review-raised-items.md, A post staged from a card): the media large,
|
|
2
|
+
// the card's media strip, the alt, the rating, the kind and its rules page, the card's words as chips, his text, the tags, where it goes with each
|
|
3
|
+
// count and skip, the slot, « ✍️ polish », the problems; Enter stages, Escape closes
|
|
4
|
+
import { observer } from 'mobx-react-lite'
|
|
5
|
+
import { useEffect, useRef, type CSSProperties } from 'react'
|
|
6
|
+
import { takes, type PostRating } from '../../../identities/rating.ts'
|
|
7
|
+
import type { Chip } from '../../../review/stage-card.ts'
|
|
8
|
+
import { editorLink, kindTone } from './social-model.ts'
|
|
9
|
+
import type { StageSt } from './stage-st.ts'
|
|
10
|
+
|
|
11
|
+
const FROM: Record<Chip['from'] | 'tested', string> = { tested: 'tested', post: 'its post line', card: 'the card', view: 'its views', his: 'your words', agent: 'the lane' }
|
|
12
|
+
const RATING_TIP: Record<PostRating, string> = { safe: 'no nudity', mild: 'nudity, never explicit', explicit: 'the rest: adult venues only' }
|
|
13
|
+
|
|
14
|
+
/** what the post is for: each kind the repo takes with its line, its rules page beside it, and a custom kind's reason */
|
|
15
|
+
const Kind = observer(({ st }: { st: StageSt }) => {
|
|
16
|
+
if (!st.picksKind) return null
|
|
17
|
+
const k = st.kindInfo
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<div className="sg-field">
|
|
21
|
+
<span>kind</span>
|
|
22
|
+
<select value={st.kind} onChange={(e) => st.setKind(e.target.value)} title="what the post is for: read its rules page before the first word">
|
|
23
|
+
{(st.data?.kinds ?? []).map((x) => (
|
|
24
|
+
<option key={x.id} value={x.id}>
|
|
25
|
+
{x.id}: {x.for}
|
|
26
|
+
</option>
|
|
27
|
+
))}
|
|
28
|
+
</select>
|
|
29
|
+
{k?.page ? (
|
|
30
|
+
<a className="so-kind" style={{ '--kt': kindTone(k.id) } as CSSProperties} href={editorLink(k.page)} title={`the rules of a ${k.id} post: ${k.page}`}>
|
|
31
|
+
{k.title ?? k.id} ↗
|
|
32
|
+
</a>
|
|
33
|
+
) : null}
|
|
34
|
+
</div>
|
|
35
|
+
{st.kind === 'custom' ? (
|
|
36
|
+
<label className="sg-field">
|
|
37
|
+
<span>why</span>
|
|
38
|
+
<input value={st.kindWhy} onChange={(e) => st.setKindWhy(e.target.value)} placeholder="why no kind fits, one line: it goes in the draft as kindWhy" />
|
|
39
|
+
</label>
|
|
40
|
+
) : null}
|
|
41
|
+
</>
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
/** the media as it will go out: the image, the clip, or the pair's wipe drawn from its two images */
|
|
46
|
+
const Media = observer(({ st, url }: { st: StageSt; url: (p: string) => string }) => {
|
|
47
|
+
const clip = useRef<HTMLVideoElement | null>(null)
|
|
48
|
+
const m = st.media
|
|
49
|
+
if (m == null) return <div className="sg-media sg-none">no media: a text post</div>
|
|
50
|
+
const src = m.side === 'wipe' ? url(`/api/review/${m.item}/anim?view=${m.view}&mode=wipe&format=mp4&labels=none`) : url(`/api/review/${m.item}/${m.file}`)
|
|
51
|
+
const p = st.passage
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<div className="sg-media">
|
|
55
|
+
{m.kind === 'clip' ? <video ref={clip} key={src} src={src} controls loop autoPlay muted playsInline /> : <img src={url(`/api/review/${m.item}/preview/fit/${m.file}`)} alt={st.alt} />}
|
|
56
|
+
</div>
|
|
57
|
+
{m.kind === 'clip' ? (
|
|
58
|
+
<div className="sg-strip">
|
|
59
|
+
<span className="sg-from">passage</span>
|
|
60
|
+
<button className="rv-chip" title="the passage starts at the player's time" onClick={() => st.setIn(clip.current?.currentTime ?? 0)}>
|
|
61
|
+
⇤ in here
|
|
62
|
+
</button>
|
|
63
|
+
<button className="rv-chip" title="the passage ends at the player's time" onClick={() => st.setOut(clip.current?.currentTime ?? 0)}>
|
|
64
|
+
out here ⇥
|
|
65
|
+
</button>
|
|
66
|
+
<span className="rv-dim">{p.from !== null && p.to !== null ? `${p.from} s → ${p.to} s` : p.from !== null ? `from ${p.from} s, set the out` : 'the whole clip'}</span>
|
|
67
|
+
{p.from !== null || p.to !== null ? (
|
|
68
|
+
<button className="ghost" onClick={() => st.clearPassage()}>
|
|
69
|
+
✕
|
|
70
|
+
</button>
|
|
71
|
+
) : null}
|
|
72
|
+
</div>
|
|
73
|
+
) : null}
|
|
74
|
+
</>
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
/** each account of the voice: where the post lands, its count against its max, or why it skips */
|
|
79
|
+
const GoesTo = observer(({ st }: { st: StageSt }) => {
|
|
80
|
+
const d = st.data
|
|
81
|
+
if (d == null || st.rating === null) return null
|
|
82
|
+
const rating = st.rating
|
|
83
|
+
return (
|
|
84
|
+
<div className="sg-goes">
|
|
85
|
+
{d.accounts.map((a) => {
|
|
86
|
+
const post = st.dry?.posts.find((p) => p.platform === a.id)
|
|
87
|
+
const skip = st.dry?.skipped.find((k) => k.account === a.id)
|
|
88
|
+
const over = post && a.max !== null && post.length > a.max
|
|
89
|
+
const channels = a.places.filter((p) => takes(p.ceiling as PostRating, rating))
|
|
90
|
+
return (
|
|
91
|
+
<span key={a.id} className={`sg-acc${skip || (st.dry && !post) ? ' skip' : ''}${over || post?.refused ? ' bad' : ''}`} title={skip?.why ?? post?.refused ?? ''}>
|
|
92
|
+
<b>{a.name}</b>
|
|
93
|
+
{post ? (
|
|
94
|
+
<>
|
|
95
|
+
{' '}
|
|
96
|
+
{a.max !== null ? `${post.length}/${a.max}` : post.length} {over || post.refused ? '✗' : '✓'}
|
|
97
|
+
{a.places.length > 0 ? (
|
|
98
|
+
<select value={st.place?.account === a.id ? st.place.place : post.place} onChange={(e) => st.setPlace(a.id, e.target.value, post.place)}>
|
|
99
|
+
{channels.map((c) => (
|
|
100
|
+
<option key={c.id} value={c.id}>
|
|
101
|
+
#{c.id}
|
|
102
|
+
</option>
|
|
103
|
+
))}
|
|
104
|
+
</select>
|
|
105
|
+
) : post.place ? (
|
|
106
|
+
<span className="rv-dim"> {post.place}</span>
|
|
107
|
+
) : null}
|
|
108
|
+
</>
|
|
109
|
+
) : skip ? (
|
|
110
|
+
<span className="rv-dim"> ✗ {skip.why.split(':')[0]}</span>
|
|
111
|
+
) : st.dry ? (
|
|
112
|
+
<span className="rv-dim"> not in this post</span>
|
|
113
|
+
) : (
|
|
114
|
+
<span className="rv-dim"> …</span>
|
|
115
|
+
)}
|
|
116
|
+
</span>
|
|
117
|
+
)
|
|
118
|
+
})}
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
export const StagePopup = observer(({ st, url, close }: { st: StageSt; url: (p: string) => string; close: () => void }) => {
|
|
124
|
+
const box = useRef<HTMLTextAreaElement | null>(null)
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
const t = setTimeout(() => box.current?.focus(), 0)
|
|
127
|
+
return () => clearTimeout(t)
|
|
128
|
+
}, [st])
|
|
129
|
+
const d = st.data
|
|
130
|
+
const chips: { from: Chip['from'] | 'tested'; text: string }[] = [...(d?.lines ?? []).map((l) => ({ from: 'tested' as const, text: l.text })), ...(d?.words ?? [])]
|
|
131
|
+
const groups = [...new Set(chips.map((c) => c.from))]
|
|
132
|
+
return (
|
|
133
|
+
<div
|
|
134
|
+
className="sg-veil"
|
|
135
|
+
onClick={close}
|
|
136
|
+
onKeyDown={(e) => {
|
|
137
|
+
if (e.key === 'Escape') {
|
|
138
|
+
e.stopPropagation()
|
|
139
|
+
close()
|
|
140
|
+
}
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
<div className="sg-pop" role="dialog" aria-label="stage a post" onClick={(e) => e.stopPropagation()}>
|
|
144
|
+
<div className="sg-head">
|
|
145
|
+
<b>Stage a post</b>
|
|
146
|
+
<span className="rv-dim">{d?.identity ? `speaks as ${d.identity.name}${d.identity.adult ? ' (18+)' : ''}` : 'reading the card…'}</span>
|
|
147
|
+
<span className="sp" />
|
|
148
|
+
<button className="ghost" onClick={close} title="close (Escape)">
|
|
149
|
+
esc
|
|
150
|
+
</button>
|
|
151
|
+
</div>
|
|
152
|
+
{st.error ? <div className="sg-error t-red">{st.error}</div> : null}
|
|
153
|
+
<div className="sg-body">
|
|
154
|
+
<div className="sg-left">
|
|
155
|
+
<Media st={st} url={url} />
|
|
156
|
+
<div className="sg-strip">
|
|
157
|
+
{d?.media.map((m) => (
|
|
158
|
+
<button key={m.key} className={`rv-chip${m.key === st.pick ? ' on' : ''}`} onClick={() => st.setPick(m.key)} title={m.key}>
|
|
159
|
+
{m.kind === 'clip' ? '▶ ' : ''}
|
|
160
|
+
{m.label}
|
|
161
|
+
</button>
|
|
162
|
+
))}
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
<div className="sg-right">
|
|
166
|
+
<label className="sg-field">
|
|
167
|
+
<span>alt</span>
|
|
168
|
+
<input value={st.alt} onChange={(e) => st.setAlt(e.target.value)} placeholder="what the media shows" />
|
|
169
|
+
</label>
|
|
170
|
+
<div className="sg-field">
|
|
171
|
+
<span>rating</span>
|
|
172
|
+
<span className="seg">
|
|
173
|
+
{(d?.ratings ?? []).map((r) => (
|
|
174
|
+
<button key={r} className={st.rating === r ? 'on' : ''} title={RATING_TIP[r]} onClick={() => st.setRating(r)}>
|
|
175
|
+
{r}
|
|
176
|
+
</button>
|
|
177
|
+
))}
|
|
178
|
+
</span>
|
|
179
|
+
{st.rating === null && d ? <span className="t-warn"> pick one</span> : null}
|
|
180
|
+
</div>
|
|
181
|
+
<Kind st={st} />
|
|
182
|
+
<div className="sg-words">
|
|
183
|
+
{groups.map((g) => (
|
|
184
|
+
<div key={g} className="sg-chips">
|
|
185
|
+
<span className="sg-from">{FROM[g]}</span>
|
|
186
|
+
{chips
|
|
187
|
+
.filter((c) => c.from === g)
|
|
188
|
+
.map((c, k) => (
|
|
189
|
+
<button key={k} className="rv-chip" title="insert at the cursor" onMouseDown={(e) => e.preventDefault()} onClick={() => st.insert(c.text)}>
|
|
190
|
+
{c.text.length > 90 ? `${c.text.slice(0, 88)}…` : c.text}
|
|
191
|
+
</button>
|
|
192
|
+
))}
|
|
193
|
+
</div>
|
|
194
|
+
))}
|
|
195
|
+
</div>
|
|
196
|
+
<textarea
|
|
197
|
+
ref={box}
|
|
198
|
+
className="sg-text"
|
|
199
|
+
rows={3}
|
|
200
|
+
value={st.text}
|
|
201
|
+
placeholder="the post: click a chip, or write it. Enter stages, ⇧Enter a new line"
|
|
202
|
+
onChange={(e) => st.setText(e.target.value, e.target.selectionStart)}
|
|
203
|
+
onSelect={(e) => st.setCaret(e.currentTarget.selectionStart)}
|
|
204
|
+
onKeyDown={(e) => {
|
|
205
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
206
|
+
e.preventDefault()
|
|
207
|
+
void st.stage()
|
|
208
|
+
}
|
|
209
|
+
}}
|
|
210
|
+
/>
|
|
211
|
+
{d && d.tags.length > 0 ? (
|
|
212
|
+
<div className="sg-chips">
|
|
213
|
+
<span className="sg-from">tags</span>
|
|
214
|
+
{d.tags.map((t) => (
|
|
215
|
+
<button key={t} className={`rv-chip${st.tags.includes(t) ? ' on' : ''}`} onClick={() => st.toggleTag(t)}>
|
|
216
|
+
{t}
|
|
217
|
+
</button>
|
|
218
|
+
))}
|
|
219
|
+
</div>
|
|
220
|
+
) : null}
|
|
221
|
+
<div className="sg-field">
|
|
222
|
+
<span>goes to</span>
|
|
223
|
+
<GoesTo st={st} />
|
|
224
|
+
</div>
|
|
225
|
+
{d && d.slots.length > 0 ? (
|
|
226
|
+
<label className="sg-field">
|
|
227
|
+
<span>when</span>
|
|
228
|
+
<select value={st.slot} onChange={(e) => st.setSlot(e.target.value)}>
|
|
229
|
+
<option value="">the queue, no slot</option>
|
|
230
|
+
{d.slots.map((s) => (
|
|
231
|
+
<option key={s.value} value={s.value}>
|
|
232
|
+
{s.value} {s.what}
|
|
233
|
+
{s.taken ? ' (taken)' : ''}
|
|
234
|
+
</option>
|
|
235
|
+
))}
|
|
236
|
+
</select>
|
|
237
|
+
</label>
|
|
238
|
+
) : null}
|
|
239
|
+
<label className="sg-field sg-polish">
|
|
240
|
+
<input type="checkbox" checked={st.polish} onChange={(e) => st.setPolish(e.target.checked)} />
|
|
241
|
+
<span>✍️ polish: an agent rewrites it in the voice, each venue its own words</span>
|
|
242
|
+
</label>
|
|
243
|
+
{st.anyOverLimit || st.fit ? (
|
|
244
|
+
<label className="sg-field sg-polish">
|
|
245
|
+
<input type="checkbox" checked={st.fit} onChange={(e) => st.setFit(e.target.checked)} />
|
|
246
|
+
<span>fit: one copy within the tightest limits of the venues it goes to</span>
|
|
247
|
+
</label>
|
|
248
|
+
) : null}
|
|
249
|
+
{st.problems.map((p, k) => (
|
|
250
|
+
<div key={k} className="sg-problem t-red">
|
|
251
|
+
⚠ {p}
|
|
252
|
+
</div>
|
|
253
|
+
))}
|
|
254
|
+
<div className="sg-foot">
|
|
255
|
+
{d && d.drafts.length > 0 ? <span className="rv-dim">already staged from this card: {d.drafts.map((x) => `📝 ${x.title}`).join(' · ')}</span> : null}
|
|
256
|
+
<span className="sp" />
|
|
257
|
+
<span className="rv-dim">{st.waits}</span>
|
|
258
|
+
<button className="primary" disabled={!st.ready} onClick={() => void st.stage()}>
|
|
259
|
+
{st.busy ? 'Staging…' : 'Stage ⏎'}
|
|
260
|
+
</button>
|
|
261
|
+
</div>
|
|
262
|
+
<div className="rv-dim sg-note">Staging writes a draft in Communications. Nothing is posted: Publish stays yours.</div>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
)
|
|
268
|
+
})
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// the stage popup's state (wiki tools/shipkit/review-raised-items.md, A post staged from a card): what the card offers
|
|
2
|
+
// (its media, its words, the repo's lines), his text, the rating, where it goes; each change runs a dry stage on the
|
|
3
|
+
// server, so every count, place and problem shown is the desk's own load, never a guess of the page. Enter stages
|
|
4
|
+
import { makeAutoObservable, runInAction } from 'mobx'
|
|
5
|
+
import type { PostRating } from '../../../identities/rating.ts'
|
|
6
|
+
import type { Chip, Stageable } from '../../../review/stage-card.ts'
|
|
7
|
+
import type { StageAccount } from '../../../review/stage-routes.ts'
|
|
8
|
+
import type { DeskKind } from '../../../social/kind-pages.ts'
|
|
9
|
+
import { sourceKind } from '../../../social/kinds.ts'
|
|
10
|
+
import { postJson } from '../review/review-kit.ts'
|
|
11
|
+
import { reach } from '../reach.ts'
|
|
12
|
+
|
|
13
|
+
export type StageData = {
|
|
14
|
+
head: string
|
|
15
|
+
first: string
|
|
16
|
+
title: string
|
|
17
|
+
media: Stageable[]
|
|
18
|
+
words: Chip[]
|
|
19
|
+
identity: { id: string; name: string; adult: boolean } | null
|
|
20
|
+
ratings: PostRating[]
|
|
21
|
+
rating: PostRating | null
|
|
22
|
+
accounts: StageAccount[]
|
|
23
|
+
lines: { text: string; source: string }[]
|
|
24
|
+
slots: { value: string; what: string; taken: boolean }[]
|
|
25
|
+
tags: string[]
|
|
26
|
+
drafts: { slug: string; title: string }[]
|
|
27
|
+
/** the kinds the repo takes, each with what it is for and its rules page */
|
|
28
|
+
kinds?: DeskKind[]
|
|
29
|
+
errors: string[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type DryAnswer = {
|
|
33
|
+
slug: string
|
|
34
|
+
posts: { key: string; platform: string; place: string; length: number; refused: string }[]
|
|
35
|
+
skipped: { account: string; why: string }[]
|
|
36
|
+
errors: string[]
|
|
37
|
+
polish?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const DRY_MS = 180
|
|
41
|
+
|
|
42
|
+
/** what a link to the popup prefills: his text, the rating, the kind and a custom kind's reason */
|
|
43
|
+
export type StageFill = { text: string; rating: PostRating | null; kind?: string; kindWhy?: string }
|
|
44
|
+
|
|
45
|
+
/** the two urls a popup talks to, what each of its bodies carries besides his draft (a release draft's slug), and the
|
|
46
|
+
* kind a new draft takes unless he picks another; no kind, the popup writes no draft of its own and picks none */
|
|
47
|
+
export type StageSource = { get: string; post: string; extra?: Record<string, unknown>; kind?: string }
|
|
48
|
+
|
|
49
|
+
/** a card's stage popup */
|
|
50
|
+
export const cardSource = (url: (p: string) => string, card: string): StageSource => ({
|
|
51
|
+
get: url(`/api/review/${encodeURIComponent(card)}/stage`),
|
|
52
|
+
post: url(`/api/review/${encodeURIComponent(card)}/stage`),
|
|
53
|
+
kind: sourceKind({ review: card }),
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
/** a release draft's: the approved cards it ships as its media */
|
|
57
|
+
export const releaseSource = (url: (p: string) => string, slug: string): StageSource => ({ get: url(`/api/social/release-media?slug=${encodeURIComponent(slug)}`), post: url('/api/social/release-media'), extra: { slug } })
|
|
58
|
+
|
|
59
|
+
export class StageSt {
|
|
60
|
+
data: StageData | null = null
|
|
61
|
+
error: string | null = null
|
|
62
|
+
busy = false
|
|
63
|
+
pick = ''
|
|
64
|
+
text = ''
|
|
65
|
+
alt = ''
|
|
66
|
+
rating: PostRating | null = null
|
|
67
|
+
/** what the post is for, its source's kind until he picks another */
|
|
68
|
+
kind = ''
|
|
69
|
+
/** a `custom` kind's line on why no kind fits */
|
|
70
|
+
kindWhy = ''
|
|
71
|
+
tags: string[] = []
|
|
72
|
+
slot = ''
|
|
73
|
+
/** a channel he picked on an account, over its default */
|
|
74
|
+
place: { account: string; place: string } | null = null
|
|
75
|
+
polish = false
|
|
76
|
+
/** a clip's passage, his in and out on its player */
|
|
77
|
+
passage: { from: number | null; to: number | null } = { from: null, to: null }
|
|
78
|
+
/** one copy within the tightest limits of the venues it reaches */
|
|
79
|
+
fit = false
|
|
80
|
+
dry: DryAnswer | null = null
|
|
81
|
+
/** where the text box's cursor stands: a chip goes in there */
|
|
82
|
+
caret = 0
|
|
83
|
+
private timer: ReturnType<typeof setTimeout> | null = null
|
|
84
|
+
private asked = 0
|
|
85
|
+
|
|
86
|
+
constructor(
|
|
87
|
+
/** where the popup reads its data and sends his draft: a card's stage route, or a release draft's media route */
|
|
88
|
+
private readonly source: StageSource,
|
|
89
|
+
/** a pick, or the start of one (`<item>#<view>`): the first media it names */
|
|
90
|
+
want: string,
|
|
91
|
+
private readonly done: (slug: string) => void,
|
|
92
|
+
/** what a link prefills: his text, the rating, the kind */
|
|
93
|
+
private readonly fill?: StageFill,
|
|
94
|
+
) {
|
|
95
|
+
this.pick = want
|
|
96
|
+
this.kind = source.kind ?? ''
|
|
97
|
+
makeAutoObservable<this, 'source' | 'done' | 'fill' | 'timer' | 'asked'>(this, { source: false, done: false, fill: false, timer: false, asked: false })
|
|
98
|
+
void this.load()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async load(): Promise<void> {
|
|
102
|
+
try {
|
|
103
|
+
const r = await reach(this.source.get)
|
|
104
|
+
const d = (await r.json()) as StageData & { error?: string }
|
|
105
|
+
if (!r.ok) throw new Error(d.error ?? `HTTP ${r.status}`)
|
|
106
|
+
runInAction(() => {
|
|
107
|
+
this.data = d
|
|
108
|
+
this.rating = this.fill?.rating ?? d.rating
|
|
109
|
+
const w = this.pick
|
|
110
|
+
const m = d.media.find((x) => x.key === w) ?? d.media.find((x) => w !== '' && (x.key.startsWith(`${w}.`) || x.key.startsWith(`${w}/`))) ?? d.media[0]
|
|
111
|
+
this.pick = m?.key ?? ''
|
|
112
|
+
this.alt = m?.note ?? ''
|
|
113
|
+
this.text = this.fill?.text || (d.words.find((w) => w.from === 'post')?.text ?? '')
|
|
114
|
+
this.caret = this.text.length
|
|
115
|
+
// a kind the link names that the repo takes; any other word keeps the source's
|
|
116
|
+
const k = this.fill?.kind
|
|
117
|
+
if (k && d.kinds?.some((x) => x.id === k)) this.kind = k
|
|
118
|
+
this.kindWhy = this.fill?.kindWhy ?? ''
|
|
119
|
+
})
|
|
120
|
+
this.again()
|
|
121
|
+
} catch (e) {
|
|
122
|
+
runInAction(() => (this.error = (e as Error).message))
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get media(): Stageable | null {
|
|
127
|
+
return this.data?.media.find((m) => m.key === this.pick) ?? null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** the guard's lines and the load's: Stage waits while one stands; a venue's limit stands no more once « fit » is on */
|
|
131
|
+
get problems(): string[] {
|
|
132
|
+
return (this.dry?.errors ?? []).filter((e) => !(this.fit && this.overLimit(e)))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** a line of a venue's media limit, which « fit » answers */
|
|
136
|
+
overLimit(e: string): boolean {
|
|
137
|
+
return e.includes('« fit » makes it a copy that fits')
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get anyOverLimit(): boolean {
|
|
141
|
+
return (this.dry?.errors ?? []).some((e) => this.overLimit(e))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
setIn(t: number): void {
|
|
145
|
+
this.passage = { from: Math.round(t * 100) / 100, to: this.passage.to !== null && this.passage.to > t ? this.passage.to : null }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setOut(t: number): void {
|
|
149
|
+
this.passage = { from: this.passage.from !== null && this.passage.from < t ? this.passage.from : 0, to: Math.round(t * 100) / 100 }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
clearPassage(): void {
|
|
153
|
+
this.passage = { from: null, to: null }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setFit(on: boolean): void {
|
|
157
|
+
this.fit = on
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** the popup offers a kind: it writes a draft of its own, and the repo lists its kinds */
|
|
161
|
+
get picksKind(): boolean {
|
|
162
|
+
return this.source.kind != null && (this.data?.kinds?.length ?? 0) > 0
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** the kind picked, with what it is for and its rules page */
|
|
166
|
+
get kindInfo(): DeskKind | null {
|
|
167
|
+
return this.data?.kinds?.find((k) => k.id === this.kind) ?? null
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** a custom kind still waiting for its line on why no kind fits */
|
|
171
|
+
get needsWhy(): boolean {
|
|
172
|
+
return this.picksKind && this.kind === 'custom' && this.kindWhy.trim() === ''
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
get ready(): boolean {
|
|
176
|
+
return this.data !== null && this.rating !== null && this.text.trim() !== '' && !this.needsWhy && this.dry !== null && this.problems.length === 0 && !this.busy
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** why Stage waits, in plain words */
|
|
180
|
+
get waits(): string {
|
|
181
|
+
if (this.rating === null) return 'pick a rating: this voice is adult, so no rating is chosen for you'
|
|
182
|
+
if (this.needsWhy) return 'say why no kind fits: a custom post carries its reason'
|
|
183
|
+
if (this.text.trim() === '') return 'write the post'
|
|
184
|
+
if (this.problems.length > 0) return 'fix the line above first'
|
|
185
|
+
return ''
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
setPick(key: string): void {
|
|
189
|
+
this.pick = key
|
|
190
|
+
this.passage = { from: null, to: null }
|
|
191
|
+
const m = this.media
|
|
192
|
+
if (m && (this.alt === '' || this.data?.media.some((x) => x.note === this.alt))) this.alt = m.note
|
|
193
|
+
this.again()
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
setText(t: string, caret?: number): void {
|
|
197
|
+
this.text = t
|
|
198
|
+
if (caret !== undefined) this.caret = caret
|
|
199
|
+
this.again()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
setCaret(n: number): void {
|
|
203
|
+
this.caret = n
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** a chip goes in at the cursor, a space on each side where words would touch */
|
|
207
|
+
insert(words: string): void {
|
|
208
|
+
const at = Math.min(this.caret, this.text.length)
|
|
209
|
+
const before = this.text.slice(0, at)
|
|
210
|
+
const after = this.text.slice(at)
|
|
211
|
+
const lead = before === '' || /\s$/.test(before) ? '' : ' '
|
|
212
|
+
const tail = after === '' || /^\s/.test(after) ? '' : ' '
|
|
213
|
+
this.text = `${before}${lead}${words}${tail}${after}`
|
|
214
|
+
this.caret = before.length + lead.length + words.length
|
|
215
|
+
this.again()
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
setAlt(t: string): void {
|
|
219
|
+
this.alt = t
|
|
220
|
+
this.again()
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
setRating(r: PostRating): void {
|
|
224
|
+
this.rating = r
|
|
225
|
+
this.place = null
|
|
226
|
+
this.again()
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
setKind(k: string): void {
|
|
230
|
+
this.kind = k
|
|
231
|
+
this.again()
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
setKindWhy(t: string): void {
|
|
235
|
+
this.kindWhy = t
|
|
236
|
+
this.again()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
toggleTag(t: string): void {
|
|
240
|
+
this.tags = this.tags.includes(t) ? this.tags.filter((x) => x !== t) : [...this.tags, t]
|
|
241
|
+
this.again()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
setSlot(v: string): void {
|
|
245
|
+
this.slot = v
|
|
246
|
+
this.again()
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
setPlace(account: string, place: string, fallback: string): void {
|
|
250
|
+
this.place = place === fallback ? null : { account, place }
|
|
251
|
+
this.again()
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
setPolish(on: boolean): void {
|
|
255
|
+
this.polish = on
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private body(dry: boolean): Record<string, unknown> {
|
|
259
|
+
return {
|
|
260
|
+
...this.source.extra,
|
|
261
|
+
pick: this.pick,
|
|
262
|
+
text: this.text,
|
|
263
|
+
rating: this.rating,
|
|
264
|
+
...(this.picksKind ? { kind: this.kind, ...(this.kind === 'custom' && this.kindWhy.trim() ? { kindWhy: this.kindWhy.trim() } : {}) } : {}),
|
|
265
|
+
alt: this.alt,
|
|
266
|
+
...(this.slot ? { slot: this.slot } : {}),
|
|
267
|
+
...(this.tags.length ? { tags: this.tags.join(' ') } : {}),
|
|
268
|
+
...(this.place ? { place: this.place } : {}),
|
|
269
|
+
...(this.polish ? { polish: true } : {}),
|
|
270
|
+
...(this.fit ? { fit: true } : {}),
|
|
271
|
+
...(this.passage.from !== null && this.passage.to !== null && this.media?.kind === 'clip' ? { passage: this.passage } : {}),
|
|
272
|
+
dry,
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** a dry stage soon after his last change; an older answer that lands late is dropped */
|
|
277
|
+
private again(): void {
|
|
278
|
+
if (this.timer !== null) clearTimeout(this.timer)
|
|
279
|
+
if (this.rating === null || this.data === null) return
|
|
280
|
+
this.timer = setTimeout(() => void this.runDry(), DRY_MS)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private async runDry(): Promise<void> {
|
|
284
|
+
const n = ++this.asked
|
|
285
|
+
try {
|
|
286
|
+
const r = await postJson<DryAnswer>(this.source.post, this.body(true))
|
|
287
|
+
if (n === this.asked) runInAction(() => ((this.dry = r), (this.error = null)))
|
|
288
|
+
} catch (e) {
|
|
289
|
+
if (n === this.asked) runInAction(() => (this.error = (e as Error).message))
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Enter: the draft written; the popup closes on its slug */
|
|
294
|
+
async stage(): Promise<void> {
|
|
295
|
+
if (!this.ready) return
|
|
296
|
+
this.busy = true
|
|
297
|
+
try {
|
|
298
|
+
const r = await postJson<DryAnswer>(this.source.post, this.body(false))
|
|
299
|
+
this.done(r.slug)
|
|
300
|
+
} catch (e) {
|
|
301
|
+
runInAction(() => (this.error = (e as Error).message))
|
|
302
|
+
} finally {
|
|
303
|
+
runInAction(() => (this.busy = false))
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
dispose(): void {
|
|
308
|
+
if (this.timer !== null) clearTimeout(this.timer)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// how a setup step reads (wiki tools/shipkit/social-identities.md, The accounts, `## Setup`): never a cut value. A
|
|
2
|
+
// step whose rows are all short keeps them as chips in its sentence; a step with a long row or a picture is its
|
|
3
|
+
// sentence, then a form of its rows in the order it names them
|
|
4
|
+
|
|
5
|
+
/** what a `[[ref]]` names: a draft, a picture row, a text row by its length, or nothing */
|
|
6
|
+
export type RefKind = 'draft' | 'picture' | 'long' | 'short' | 'bad'
|
|
7
|
+
|
|
8
|
+
/** a piece of the sentence: words, a ref drawn whole (`chip`), or a form row named by its field (`tag`) */
|
|
9
|
+
export type StepPiece = { text: string } | { ref: string; as: 'chip' | 'tag' }
|
|
10
|
+
|
|
11
|
+
export type StepLayout = { sentence: StepPiece[]; fields: string[] }
|
|
12
|
+
|
|
13
|
+
/** a text value that fits a chip: one line, 40 characters at most */
|
|
14
|
+
export const SHORT = 40
|
|
15
|
+
|
|
16
|
+
export const textKind = (value: string): 'long' | 'short' => (value.length > SHORT || value.includes('\n') ? 'long' : 'short')
|
|
17
|
+
|
|
18
|
+
const REF = /\[\[([^\]]+)\]\]/g
|
|
19
|
+
// what may sit between the rows that end a step: spaces, commas, semicolons, a colon, a period, « and »
|
|
20
|
+
const BETWEEN = /^(?:[\s,;:.]|\band\b)*$/
|
|
21
|
+
|
|
22
|
+
export function stepLayout(text: string, kindOf: (ref: string) => RefKind): StepLayout {
|
|
23
|
+
const parts = text.split(REF)
|
|
24
|
+
const pieces: StepPiece[] = parts.map((p, j) => (j % 2 === 0 ? { text: p } : { ref: p, as: 'chip' }))
|
|
25
|
+
const rowRef = (p: StepPiece): p is { ref: string; as: 'chip' | 'tag' } => 'ref' in p && ['picture', 'long', 'short'].includes(kindOf(p.ref))
|
|
26
|
+
const form = pieces.some((p) => 'ref' in p && (kindOf(p.ref) === 'picture' || kindOf(p.ref) === 'long'))
|
|
27
|
+
if (!form) return { sentence: pieces.filter((p) => !('text' in p) || p.text !== ''), fields: [] }
|
|
28
|
+
const fields = [...new Set(pieces.filter(rowRef).map((p) => p.ref))]
|
|
29
|
+
// the rows that end the step live in the form only; its last words before them stay
|
|
30
|
+
let end = pieces.length
|
|
31
|
+
for (let j = pieces.length - 1; j >= 0; j--) {
|
|
32
|
+
const p = pieces[j]!
|
|
33
|
+
if ('text' in p && BETWEEN.test(p.text)) continue
|
|
34
|
+
if (rowRef(p)) end = j
|
|
35
|
+
else break
|
|
36
|
+
}
|
|
37
|
+
const sentence = pieces
|
|
38
|
+
.slice(0, end)
|
|
39
|
+
.map((p): StepPiece => (rowRef(p) ? { ref: p.ref, as: 'tag' } : p))
|
|
40
|
+
.filter((p) => !('text' in p) || p.text !== '')
|
|
41
|
+
return { sentence, fields }
|
|
42
|
+
}
|