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,85 @@
|
|
|
1
|
+
// a media copied into a draft with what it says about where it was made left out (wiki tools/shipkit/social.md, A post
|
|
2
|
+
// staged): a png's text, time and exif chunks, a jpeg's exif, xmp, iptc and comments, a webp's exif and xmp, a clip's
|
|
3
|
+
// tags, chapters and encoder name. The pixels and the colour profile stay. Images are rewritten here, byte for byte
|
|
4
|
+
// the rest; a clip goes through ffmpeg, its streams copied, never encoded again
|
|
5
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
6
|
+
import { extname } from 'node:path'
|
|
7
|
+
|
|
8
|
+
const PNG_SIG = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
|
|
9
|
+
/** the png chunks that carry words, a time or exif */
|
|
10
|
+
const PNG_DROP = new Set(['tEXt', 'zTXt', 'iTXt', 'eXIf', 'tIME'])
|
|
11
|
+
|
|
12
|
+
export function stripPng(b: Buffer): Buffer {
|
|
13
|
+
if (!b.subarray(0, 8).equals(PNG_SIG)) throw new Error('not a png')
|
|
14
|
+
const keep: Buffer[] = [PNG_SIG]
|
|
15
|
+
for (let at = 8; at + 12 <= b.length; ) {
|
|
16
|
+
const len = b.readUInt32BE(at)
|
|
17
|
+
const type = b.toString('latin1', at + 4, at + 8)
|
|
18
|
+
const end = at + 12 + len
|
|
19
|
+
if (!PNG_DROP.has(type)) keep.push(b.subarray(at, end))
|
|
20
|
+
at = end
|
|
21
|
+
if (type === 'IEND') break
|
|
22
|
+
}
|
|
23
|
+
return Buffer.concat(keep)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** the jpeg segments that carry exif or xmp (APP1), iptc (APP13) and comments (COM) */
|
|
27
|
+
const JPEG_DROP = new Set([0xe1, 0xed, 0xfe])
|
|
28
|
+
|
|
29
|
+
export function stripJpeg(b: Buffer): Buffer {
|
|
30
|
+
if (b[0] !== 0xff || b[1] !== 0xd8) throw new Error('not a jpeg')
|
|
31
|
+
const keep: Buffer[] = [b.subarray(0, 2)]
|
|
32
|
+
let at = 2
|
|
33
|
+
while (at + 4 <= b.length && b[at] === 0xff) {
|
|
34
|
+
const marker = b[at + 1]!
|
|
35
|
+
// the scan: the rest is the image
|
|
36
|
+
if (marker === 0xda) break
|
|
37
|
+
const end = at + 2 + b.readUInt16BE(at + 2)
|
|
38
|
+
if (!JPEG_DROP.has(marker)) keep.push(b.subarray(at, end))
|
|
39
|
+
at = end
|
|
40
|
+
}
|
|
41
|
+
keep.push(b.subarray(at))
|
|
42
|
+
return Buffer.concat(keep)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function stripWebp(b: Buffer): Buffer {
|
|
46
|
+
if (b.toString('latin1', 0, 4) !== 'RIFF' || b.toString('latin1', 8, 12) !== 'WEBP') throw new Error('not a webp')
|
|
47
|
+
const keep: Buffer[] = []
|
|
48
|
+
for (let at = 12; at + 8 <= b.length; ) {
|
|
49
|
+
const type = b.toString('latin1', at, at + 4)
|
|
50
|
+
const len = b.readUInt32LE(at + 4)
|
|
51
|
+
const end = at + 8 + len + (len % 2)
|
|
52
|
+
if (type === 'VP8X') {
|
|
53
|
+
const c = Buffer.from(b.subarray(at, end))
|
|
54
|
+
// the flags say no exif (bit 3) and no xmp (bit 2) any more
|
|
55
|
+
c[8] = c[8]! & ~0x0c
|
|
56
|
+
keep.push(c)
|
|
57
|
+
} else if (type !== 'EXIF' && type !== 'XMP ') keep.push(b.subarray(at, end))
|
|
58
|
+
at = end
|
|
59
|
+
}
|
|
60
|
+
const body = Buffer.concat(keep)
|
|
61
|
+
const head = Buffer.alloc(12)
|
|
62
|
+
head.write('RIFF', 0, 'latin1')
|
|
63
|
+
head.writeUInt32LE(body.length + 4, 4)
|
|
64
|
+
head.write('WEBP', 8, 'latin1')
|
|
65
|
+
return Buffer.concat([head, body])
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const CLIP = new Set(['.mp4', '.m4v', '.mov', '.webm'])
|
|
69
|
+
|
|
70
|
+
/** `from` copied to `to` with its metadata left out; a kind it cannot clean is refused, never copied as it is */
|
|
71
|
+
export function stripCopy(from: string, to: string): void {
|
|
72
|
+
const ext = extname(from).toLowerCase()
|
|
73
|
+
if (ext === '.png') return writeFileSync(to, stripPng(readFileSync(from)))
|
|
74
|
+
if (ext === '.jpg' || ext === '.jpeg') return writeFileSync(to, stripJpeg(readFileSync(from)))
|
|
75
|
+
if (ext === '.webp') return writeFileSync(to, stripWebp(readFileSync(from)))
|
|
76
|
+
if (!CLIP.has(ext)) throw new Error(`${from}: a ${ext || 'file'} is no media a draft takes (png, jpg, webp, mp4, mov, webm)`)
|
|
77
|
+
const r = Bun.spawnSync(
|
|
78
|
+
['ffmpeg', '-v', 'error', '-y', '-i', from, '-map', '0', '-c', 'copy', '-map_metadata', '-1', '-map_metadata:s', '-1', '-map_chapters', '-1', '-fflags', '+bitexact', '-flags:v', '+bitexact', '-flags:a', '+bitexact', to],
|
|
79
|
+
{ stdout: 'ignore', stderr: 'pipe' },
|
|
80
|
+
)
|
|
81
|
+
if (r.exitCode !== 0) {
|
|
82
|
+
// a stream ffmpeg cannot copy into the same container: the file is refused, the reason named
|
|
83
|
+
throw new Error(`ffmpeg could not clean ${from}: ${r.stderr.toString().trim().split('\n').at(-1) ?? `exit ${r.exitCode}`}`)
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/social/text.ts
CHANGED
|
@@ -106,6 +106,7 @@ export function overviewText(m: Model, today: string, stats: Readonly<Record<str
|
|
|
106
106
|
if (waiting.length > 8) out.push(` … and ${waiting.length - 8} more: sk social plan`)
|
|
107
107
|
out.push('', sourcesLine(sent))
|
|
108
108
|
if (social.errors.length) out.push('', `${plural(social.errors.length, 'error')} in .shipkit/social/:`, ...social.errors.map((e) => ` ${e}`))
|
|
109
|
+
if (social.warnings.length) out.push('', `${plural(social.warnings.length, 'warning')}, never an error (an old kind word stays until the repo moves its drafts):`, ...social.warnings.map((e) => ` ${e}`))
|
|
109
110
|
return out
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -163,11 +164,14 @@ export function postText(m: Model, slug: string): string[] {
|
|
|
163
164
|
const w = Math.max(0, ...posts.map((p) => p.key.length))
|
|
164
165
|
for (const p of posts) {
|
|
165
166
|
const s = m.sent.find((x) => x.slug === d.slug && x.key === p.key)
|
|
166
|
-
|
|
167
|
+
const at = p.place ? ` in ${p.place}` : ''
|
|
168
|
+
out.push(`${pad(p.key, w)} ${pad(fam(p), 7)} ${s ? `posted ${when(s)} ${s.url}` : p.refused ? `refused: ${p.refused}` : `waiting${at}, ${p.length} characters${p.tags.length ? `, ${p.tags.join(' ')}` : ''}`}`)
|
|
167
169
|
}
|
|
170
|
+
for (const k of d.skipped) out.push(`${pad(k.account, w)} skipped: ${k.why}`)
|
|
171
|
+
if (d.rating !== 'safe') out.splice(2, 0, `rated ${d.rating}`)
|
|
168
172
|
const left = d.posts.filter((p) => p.posted === '').length
|
|
169
173
|
out.push('', left ? `${left} of ${d.posts.length} messages waiting` : `every message posted`)
|
|
170
|
-
const errors = m.social.errors.filter((e) => e.includes(d.slug))
|
|
174
|
+
const errors = [...m.social.errors, ...m.social.warnings].filter((e) => e.includes(d.slug))
|
|
171
175
|
if (errors.length) out.push('', ...errors)
|
|
172
176
|
return out
|
|
173
177
|
}
|
package/src/social/unit.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { existsSync } from 'node:fs'
|
|
5
5
|
import { importFresh } from '../core/discover-checks.ts'
|
|
6
6
|
import { unitFilesDeclaring } from '../core/unit-files.ts'
|
|
7
|
+
import { ownKindsProblem, type OwnKind } from './kinds.ts'
|
|
7
8
|
|
|
8
9
|
/** what the desk shows of a draft's `post.md` beyond its front matter */
|
|
9
10
|
export interface ArticleInfo {
|
|
@@ -11,9 +12,43 @@ export interface ArticleInfo {
|
|
|
11
12
|
url: string
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
/** what the repo's guard reads of a draft: every word it says in public and every media file it carries */
|
|
16
|
+
export interface GuardInput {
|
|
17
|
+
title: string
|
|
18
|
+
alt: string
|
|
19
|
+
/** each heading's text, as he writes it */
|
|
20
|
+
texts: readonly string[]
|
|
21
|
+
/** each media, absolute */
|
|
22
|
+
files: readonly string[]
|
|
23
|
+
/** what a picture shows, in words (a trailer shot a line sits over): held to what a picture may show, never to the
|
|
24
|
+
* rules of a public word */
|
|
25
|
+
shows?: readonly string[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** a line the stage popup offers, and where it comes from (`tested`, a message's id) */
|
|
29
|
+
export interface SuggestedLine {
|
|
30
|
+
text: string
|
|
31
|
+
source: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** the headings a release stages, each a group or an account of the identity with the options a draft writes */
|
|
35
|
+
export interface ReleaseHeading {
|
|
36
|
+
id: string
|
|
37
|
+
place?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
14
40
|
export interface SocialDef {
|
|
15
41
|
/** the words a draft's `topics` take; another word fails the load. Unset, any word */
|
|
16
42
|
topics?: readonly string[]
|
|
43
|
+
/** the project's own post kinds beside the shared set (kinds.ts), each with its rules page in the repo */
|
|
44
|
+
kinds?: readonly OwnKind[]
|
|
45
|
+
/** why a draft may not go out, one line a problem: run at stage and at every load, so a draft with one never
|
|
46
|
+
* publishes, opens or copies */
|
|
47
|
+
guard?(d: GuardInput): readonly string[]
|
|
48
|
+
/** the lines the stage popup offers for a card; unset, the tested phrasings of the repo's messages store */
|
|
49
|
+
lines?(card: { id: string; title: string }): readonly SuggestedLine[]
|
|
50
|
+
/** a release of the repo stages one draft with these headings; unset, a release stages nothing */
|
|
51
|
+
release?: { headings: readonly ReleaseHeading[] }
|
|
17
52
|
/** a draft folder holding a `post.md`: its address on the site */
|
|
18
53
|
article?(dir: string): ArticleInfo
|
|
19
54
|
/** the article as the site renders it, html; its media paths under `mediaBase` */
|
|
@@ -29,7 +64,14 @@ const WORD = /^[a-z][a-z0-9-]*$/
|
|
|
29
64
|
/** why a social unit cannot be read, or null */
|
|
30
65
|
export function socialProblem(d: SocialDef): string | null {
|
|
31
66
|
for (const t of d.topics ?? []) if (!WORD.test(t)) return `social: topic '${t}' is a lowercase word`
|
|
32
|
-
|
|
67
|
+
if (d.kinds !== undefined) {
|
|
68
|
+
if (!Array.isArray(d.kinds)) return 'social: kinds is a list of { id, for, page }'
|
|
69
|
+
const why = ownKindsProblem(d.kinds)
|
|
70
|
+
if (why !== null) return why
|
|
71
|
+
}
|
|
72
|
+
for (const f of ['article', 'preview', 'guard', 'lines'] as const) if (d[f] !== undefined && typeof d[f] !== 'function') return `social: ${f} is a function`
|
|
73
|
+
for (const h of d.release?.headings ?? []) if (!WORD.test(h.id)) return `social: release heading '${h.id}' is a group or an account id`
|
|
74
|
+
if (d.release !== undefined && d.release.headings.length === 0) return 'social: release names no heading'
|
|
33
75
|
if (d.notes !== undefined && !WORD.test(d.notes)) return `social: notes '${d.notes}' is a review topic, a lowercase word`
|
|
34
76
|
return null
|
|
35
77
|
}
|
|
@@ -40,6 +82,20 @@ export function social(d: SocialDef): SocialUnit {
|
|
|
40
82
|
return { ...d, kind: 'social' }
|
|
41
83
|
}
|
|
42
84
|
|
|
85
|
+
/** THE repo's public text guard on one input (wiki tools/shipkit/social.md, The guard): the unit's `guard`, one line
|
|
86
|
+
* a problem; a guard that throws is one problem naming why; no unit or no guard, none */
|
|
87
|
+
export function guardWith(unit: SocialUnit | null | undefined, input: Partial<GuardInput>): string[] {
|
|
88
|
+
if (unit?.guard == null) return []
|
|
89
|
+
try {
|
|
90
|
+
return [...unit.guard({ title: input.title ?? '', alt: input.alt ?? '', texts: input.texts ?? [], files: input.files ?? [], ...(input.shows ? { shows: input.shows } : {}) })]
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return [`the repo's guard failed: ${(e as Error).message}`]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** the guard of the repo at `root`, its unit read fresh: a release note, a phrasing of the messages store */
|
|
97
|
+
export const publicProblems = async (root: string, input: Partial<GuardInput>): Promise<string[]> => guardWith(await loadSocialUnit(root), input)
|
|
98
|
+
|
|
43
99
|
/** the repo's social unit, or null; two of them is an error naming both files */
|
|
44
100
|
export async function loadSocialUnit(root: string): Promise<SocialUnit | null> {
|
|
45
101
|
if (!existsSync(root)) return null
|
package/src/social/writes.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
|
6
6
|
import { join } from 'node:path'
|
|
7
7
|
import { gitBin } from '../core/git-bin.ts'
|
|
8
8
|
import { STEP, type Account } from '../identities/identities.ts'
|
|
9
|
+
import { recordShown, TEXT_FILE } from '../identities/shown.ts'
|
|
9
10
|
import { setHeadingText, setPostedLine } from './drafts.ts'
|
|
10
11
|
import { accountOf, draftPost, draftsDir, type Desk } from './load.ts'
|
|
11
12
|
import { setMeta } from './md.ts'
|
|
@@ -108,6 +109,16 @@ export function setLive(desk: Desk, identity: string, account: string, url: stri
|
|
|
108
109
|
return [a.file]
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
/** « Done, uploaded »: the account now shows one of a picture row's files (its first when none is named), recorded in
|
|
113
|
+
* its shown.md; a file the row does not name is refused, so the client never names a path of its own. « Done,
|
|
114
|
+
* pasted »: a text row as its value is now, refused when `sha` (what the page showed) is no longer it */
|
|
115
|
+
export function setShown(desk: Desk, identity: string, account: string, row: string, file?: string, sha?: string): string[] {
|
|
116
|
+
const a = accountOf(desk, identity, account)
|
|
117
|
+
const { abs, row: r } = recordShown(a, row, file, sha)
|
|
118
|
+
commitPaths([abs], `identities: ${identity} ${account} shows its ${row}, ${r.file === TEXT_FILE ? 'pasted' : r.file} (${r.sha})`)
|
|
119
|
+
return [abs]
|
|
120
|
+
}
|
|
121
|
+
|
|
111
122
|
/** one step of `## Setup` ticked or not, by its index among the bullets; its message and errors name it from 1, as the
|
|
112
123
|
* page numbers it */
|
|
113
124
|
export function setStep(desk: Desk, identity: string, account: string, index: number, done: boolean): string[] {
|
package/src/trailer/build.ts
CHANGED
|
@@ -124,8 +124,21 @@ export async function load(file: string, root: string, o: { text?: string; dir?:
|
|
|
124
124
|
l.score = c.score
|
|
125
125
|
l.errors.push(...c.errors)
|
|
126
126
|
}
|
|
127
|
-
if (l.errors.length === 0 &&
|
|
128
|
-
|
|
127
|
+
if (l.errors.length === 0 && o.check !== false) {
|
|
128
|
+
// the cut's public words through the repo's one guard, beside the unit's own check
|
|
129
|
+
const { cutProblems, cutWords } = await import('./public-words.ts')
|
|
130
|
+
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
131
|
+
const guarded = await loadSocialUnit(root).then(
|
|
132
|
+
(social) => {
|
|
133
|
+
const { words, unread } = cutWords(t, (p) => fileOf(p, l))
|
|
134
|
+
// with no guard there is nothing to read the voices with, and nothing to say about them
|
|
135
|
+
if (social?.guard != null) l.warnings.push(...unread.map((u) => ({ line: u.line, message: u.why })))
|
|
136
|
+
return cutProblems(social, words)
|
|
137
|
+
},
|
|
138
|
+
(e: Error) => [{ line: 1, message: `the social unit does not load, so no guard read the cut's words: ${e.message}` }],
|
|
139
|
+
)
|
|
140
|
+
if (l.unit?.check) for (const f of await l.unit.check(checkInput(l))) (f.warn ? l.warnings : l.errors).push({ line: f.line, message: f.message })
|
|
141
|
+
l.errors.push(...guarded)
|
|
129
142
|
l.warnings.sort((a, b) => a.line - b.line)
|
|
130
143
|
}
|
|
131
144
|
l.errors.sort((a, b) => a.line - b.line)
|
package/src/trailer/grammar.ts
CHANGED
|
@@ -314,6 +314,9 @@ export interface Shot {
|
|
|
314
314
|
music: Music | null
|
|
315
315
|
/** its own line failed: nothing else is checked against it */
|
|
316
316
|
broken?: true
|
|
317
|
+
/** broken by its film line alone: its length and its place on the cut still hold, so a parse that does not know a
|
|
318
|
+
* film word (the hub's, with no project CLI) times the cut as the build does */
|
|
319
|
+
filmOnly?: true
|
|
317
320
|
/** a `footage` block: filmed, never cut in */
|
|
318
321
|
offcut?: true
|
|
319
322
|
}
|
|
@@ -1106,7 +1109,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
|
|
|
1106
1109
|
if ('error' in tk) {
|
|
1107
1110
|
errors.push({ line: n, message: tk.error })
|
|
1108
1111
|
// its own line failed: the shot is not also told it films nothing
|
|
1109
|
-
if (shot && /^\s*film(\s|$)/.test(lines[n - 1]!)) shot
|
|
1112
|
+
if (shot && /^\s*film(\s|$)/.test(lines[n - 1]!)) filmFailed(shot)
|
|
1110
1113
|
continue
|
|
1111
1114
|
}
|
|
1112
1115
|
const ws = tk.words
|
|
@@ -1504,7 +1507,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
|
|
|
1504
1507
|
} catch (e) {
|
|
1505
1508
|
if (!(e instanceof LineError)) throw e
|
|
1506
1509
|
errors.push({ line: n, message: e.message })
|
|
1507
|
-
if (shot && head.text === 'film') shot
|
|
1510
|
+
if (shot && head.text === 'film') filmFailed(shot)
|
|
1508
1511
|
}
|
|
1509
1512
|
}
|
|
1510
1513
|
if (!seen.has('trailer')) errors.push({ line: 1, message: 'the file names its trailer first: trailer <name>' })
|
|
@@ -1567,6 +1570,12 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
|
|
|
1567
1570
|
/** the least a fitted shot keeps past its cut out */
|
|
1568
1571
|
const FIT_MIN_S = 0.3
|
|
1569
1572
|
|
|
1573
|
+
/** a shot's film line failed: nothing more is checked against it, and when its own line held, its timing still does */
|
|
1574
|
+
function filmFailed(s: Shot): void {
|
|
1575
|
+
if (!s.broken) s.filmOnly = true
|
|
1576
|
+
s.broken = true
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1570
1579
|
/** a section's start, or a mark's moment, in the timeline's seconds; null when no section or mark has that name */
|
|
1571
1580
|
function momentOf(t: Pick<Trailer, 'sections'>, name: string): number | null {
|
|
1572
1581
|
for (const sec of t.sections) {
|
|
@@ -1584,8 +1593,9 @@ function momentOf(t: Pick<Trailer, 'sections'>, name: string): number | null {
|
|
|
1584
1593
|
*/
|
|
1585
1594
|
function landShots(t: Trailer): TrailerError[] {
|
|
1586
1595
|
const out: TrailerError[] = []
|
|
1596
|
+
const timed = (s: Shot): boolean => !s.broken || s.filmOnly === true
|
|
1587
1597
|
t.shots.forEach((s, i) => {
|
|
1588
|
-
if (s
|
|
1598
|
+
if (!timed(s)) return
|
|
1589
1599
|
const land = s.lands ?? (s.section ? { line: s.section.line, on: s.section.name, offset: 0 } : null)
|
|
1590
1600
|
if (!land) return
|
|
1591
1601
|
const moment = momentOf(t, land.on)
|
|
@@ -1599,7 +1609,7 @@ function landShots(t: Trailer): TrailerError[] {
|
|
|
1599
1609
|
return
|
|
1600
1610
|
}
|
|
1601
1611
|
const prev = t.shots[i - 1]
|
|
1602
|
-
if (!prev || prev
|
|
1612
|
+
if (!prev || !timed(prev)) {
|
|
1603
1613
|
out.push({ line: land.line, message: `shot ${s.name}: no shot before it to fit` })
|
|
1604
1614
|
return
|
|
1605
1615
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// a cut's public words through the repo's one guard (wiki tools/trailer/index.md, Its public words): each title and each
|
|
2
|
+
// voice line of a shot that is cut in, held to the rules of a public word by the social unit's `guard` (social/unit.ts
|
|
3
|
+
// guardWith), never a word list of the trailer's own. A recorded voice is read through its transcript beside the clip
|
|
4
|
+
// (`<clip>.txt`); one with none is said, so no spoken line passes unread in silence. A film line is how a take is made,
|
|
5
|
+
// never on screen: what its words turn on is the repo's own knowledge, read by its trailer unit's `check`
|
|
6
|
+
import { readFileSync } from 'node:fs'
|
|
7
|
+
import { guardWith, type GuardInput, type SocialUnit } from '../social/unit.ts'
|
|
8
|
+
import type { Trailer, TrailerError } from './grammar.ts'
|
|
9
|
+
|
|
10
|
+
/** one word of the cut a stranger reads or hears, at its line, as the guard reads it */
|
|
11
|
+
export type CutWord = { line: number; what: 'title' | 'voice line'; input: Partial<GuardInput> }
|
|
12
|
+
|
|
13
|
+
/** a voice the guard cannot read: a clip with no transcript beside it, a line a command makes */
|
|
14
|
+
export type Unread = { line: number; why: string }
|
|
15
|
+
|
|
16
|
+
const transcriptPath = (file: string): string => file.replace(/\.[^./]+$/, '.txt')
|
|
17
|
+
|
|
18
|
+
/** every title and voice line of the shots that are cut in, in line order, and the voices it cannot read; `find` finds
|
|
19
|
+
* a file as the cut finds its clips */
|
|
20
|
+
export function cutWords(t: Pick<Trailer, 'shots'>, find: (path: string) => string | null): { words: CutWord[]; unread: Unread[] } {
|
|
21
|
+
const words: CutWord[] = []
|
|
22
|
+
const unread: Unread[] = []
|
|
23
|
+
for (const s of t.shots) {
|
|
24
|
+
for (const ti of s.titles) if (ti.text.trim() !== '') words.push({ line: ti.line, what: 'title', input: { texts: [ti.text] } })
|
|
25
|
+
for (const v of s.voices) {
|
|
26
|
+
if (v.text != null && v.text.trim() !== '') words.push({ line: v.line, what: 'voice line', input: { texts: [v.text] } })
|
|
27
|
+
else if (v.file != null) {
|
|
28
|
+
const at = find(transcriptPath(v.file))
|
|
29
|
+
const said = at == null ? '' : readFileSync(at, 'utf8').trim()
|
|
30
|
+
if (said !== '') words.push({ line: v.line, what: 'voice line', input: { texts: [said] } })
|
|
31
|
+
else unread.push({ line: v.line, why: `voice file ${v.file}: no transcript beside it (${transcriptPath(v.file)}), so no guard read what it says` })
|
|
32
|
+
} else if (v.run != null) unread.push({ line: v.line, why: 'a voice a command makes: no guard read what it says' })
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { words: words.sort((a, b) => a.line - b.line), unread }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** the guard's problems with a cut, each an error at its line; no unit or no guard, none */
|
|
39
|
+
export function cutProblems(unit: SocialUnit | null, words: readonly CutWord[]): TrailerError[] {
|
|
40
|
+
return words.flatMap((w) => guardWith(unit, w.input).map((p) => ({ line: w.line, message: `the repo's guard refuses this ${w.what}: ${p}` })))
|
|
41
|
+
}
|