uniweb 1.34.7 → 1.34.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniweb",
3
- "version": "1.34.7",
3
+ "version": "1.34.9",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,15 +41,15 @@
41
41
  "js-yaml": "^4.3.2",
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.5.21",
44
+ "@uniweb/schemas": "~1.7.4",
44
45
  "@uniweb/content-writer": "~1.3.2",
45
46
  "@uniweb/core": "~1.6.13",
46
- "@uniweb/schemas": "~1.7.4",
47
47
  "@uniweb/semantic-parser": "~1.13.5"
48
48
  },
49
49
  "peerDependencies": {
50
+ "@uniweb/build": "~1.23.8",
50
51
  "@uniweb/content-reader": "~1.5.10",
51
- "@uniweb/semantic-parser": "~1.13.5",
52
- "@uniweb/build": "~1.23.6"
52
+ "@uniweb/semantic-parser": "~1.13.5"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@uniweb/build": {
@@ -131,7 +131,7 @@ Image attributes: `{width=800 height=600 loading=lazy fit=cover position=center
131
131
 
132
132
  **Section links:** `page:about#team` → `/about#section-team`; `page:/#features` → a homepage section. The id is the file name without its number (`2-features.md` → `features`) or `id:` in frontmatter.
133
133
 
134
- **Where media lives.** `./x` is beside the page, `/x` is in `public/`; both reach a static build and a published site. Keep a page's media beside it, and in `public/` what belongs to the whole site: the favicon, fonts. **Only a static host gives a file a fixed address** at the site root. A site published with Uniweb serves a file that something names from an address the upload gives it, and nothing at `/x` — so for a file other sites or scripts fetch by URL, keep it somewhere with its own address and add a page whose `redirect:` goes there. A static build copies `public/` whole, a photo's location included, and adds its own copy of each file a page names there: keep a phone's photos beside their page. **A picture is made ready before it is stored or shipped:** `uniweb push` and `uniweb publish` upload, and a static build copies, a PNG, JPEG or GIF as a WebP when that is at least 10% smaller (a TIFF or HEIC always), turned upright and without its location and camera data; a WebP stays one, without that data. The favicon, the touch icon, the site's card and its social images go up in their own format, without their location and camera data; a static build serves them from `public/` as they are. A picture keeps its pixels, so add one no wider than a page shows it; a HEIC from a phone that can't be converted here goes up as it is, with a note: export it as JPEG. `uniweb push` uploads a file beside a page wherever the page is (mounted directories included); a file outside the site and its mounts is not uploaded — put that in `public/`. There is no `assets/` directory for media; a build stops on a `/x` only `assets/` holds.
134
+ **Where media lives.** `./x` is beside the page, `/x` is in `public/`; both reach a static build and a published site. Keep a page's media beside it, and in `public/` what belongs to the whole site: the favicon, fonts. **Only a static host gives a file a fixed address** at the site root. A site published with Uniweb serves a file that something names from an address the upload gives it, and nothing at `/x` — so for a file other sites or scripts fetch by URL, keep it somewhere with its own address and add a page whose `redirect:` goes there. A static build copies `public/` whole, a photo's location included, and adds its own copy of each file a page names there: keep a phone's photos beside their page. **A picture is made ready before it is stored or shipped:** `uniweb push` and `uniweb publish` upload, and a static build copies, a PNG, JPEG or GIF as a WebP when that is at least 10% smaller (a TIFF or HEIC always), turned upright and without its location and camera data; a WebP stays one, without that data. The favicon, the touch icon, the site's card and its social images go up in their own format, without their location and camera data; a static build serves them from `public/` as they are. **A video** goes up as H.264 and AAC in an MP4, at most 1920 on its long edge and about 5 Mbps at 1080p, when ffmpeg with libx264 is installed (one already within that is only repackaged). It loses its location and camera data either way, an HDR video goes up as it is with a note, and a static build copies videos as they are. A picture keeps its pixels, so add one no wider than a page shows it; a HEIC from a phone that can't be converted here goes up without its location, with a note: export it as JPEG. An AVIF stays one, without that data. `uniweb push` uploads a file beside a page wherever the page is (mounted directories included); a file outside the site and its mounts is not uploaded — put that in `public/`. There is no `assets/` directory for media; a build stops on a `/x` only `assets/` holds.
135
135
 
136
136
  **Placement** (`{placement=left|right|wide|full}`) on an image or video, or on a table's caption line, which follows the table after a blank line (`: Plans and prices {placement=wide #tbl-plans}`, which also sets caption and id; with no blank line it becomes a row). It's the author's intent, honoured by kit's `<Render>`, `<Prose>` and `<Article>` and ignored by other components; a section type declares which it honours in `meta.js` (`sequence: { placement: true }`) and the build warns on a mismatch.
137
137
 
@@ -68,7 +68,7 @@ A site can be in more than one place. `publish` makes a change live on Cloud, `g
68
68
 
69
69
  **Sync is developer-only and one-sided.** The app is the live source of truth for content; git is the reviewed, durable record. Authors never push or pull.
70
70
 
71
- **Nobody's work is overwritten without asking.** `push` is refused if the site changed on the backend since your last pull, and reports what changed. In a git repository `pull` merges like `git pull`: it commits the backend's content (*"The site's content on …"*) and merges into your branch against the last shared state. Your work and a teammate's are kept; a file the backend never had is never deleted; only a genuine overlap leaves conflict markers and a non-zero exit — settle it as in any merge, then `git commit` (where your uncommitted changes overlap, settle, `git add`, then `git stash drop`). A push or publish is refused while a file is in conflict. **In a repository a push sends what you have committed**: uncommitted site content is refused before anything is sent — commit, or `uniweb push --commit -m "…"` (commits the site's content only; `publish` and `sync` take `--commit` too). The ids the backend assigns are committed by the push itself, as `uniweb`. A push is also refused when your branch doesn't hold what this copy last took from the backend (after `git merge --abort`, or a fresh clone) — pull, then push. Outside git (including a directory the surrounding repo ignores), `pull` takes the backend's version over your files, asking first. `--force` is the deliberate overwrite in either direction. `sync` is `refresh` then `push`; neither publishes.
71
+ **Nobody's work is overwritten without asking.** `push` is refused if the site changed on the backend since your last pull, and reports what changed. In a git repository `pull` merges like `git pull`: it commits the backend's content (*"The site's content on …"*) and merges into your branch against the last shared state. Your work and a teammate's are kept; a file the backend never had is never deleted; what the app removed — a page, a section, a record — is removed here too unless you changed it, and the pull names each record it removes (restored from history and pushed, one goes up as a new record); only a genuine overlap leaves conflict markers and a non-zero exit — settle it as in any merge, then `git commit` (where your uncommitted changes overlap, settle, `git add`, then `git stash drop`). A push or publish is refused while a file is in conflict. **In a repository a push sends what you have committed**: uncommitted site content is refused before anything is sent — commit, or `uniweb push --commit -m "…"` (commits the site's content only; `publish` and `sync` take `--commit` too). The ids the backend assigns are committed by the push itself, as `uniweb`. A push is also refused when your branch doesn't hold what this copy last took from the backend (after `git merge --abort`, or a fresh clone) — pull, then push. Outside git (including a directory the surrounding repo ignores), `pull` takes the backend's version over your files, asking first. `--force` is the deliberate overwrite in either direction. `sync` is `refresh` then `push`; neither publishes.
72
72
 
73
73
  **Working on a site others edit:** `status` when you begin, when you come back, before push/publish/deploy, after any refusal. It reads the backend without taking anything: what changed file by file, what you hold that it lacks, who has a page open in the app right now, what in the project is uncommitted (an update, foundation source — a push neither sends nor waits for that, but a push or publish releases a changed foundation from the files). Take what changed (`pull` or `refresh`) before you edit; when someone has a page open in the app, tell the person before changing that page.
74
74
 
@@ -0,0 +1,280 @@
1
+ /**
2
+ * A VIDEO MADE READY BEFORE IT IS UPLOADED — the video half of the rule a push applies to what it
3
+ * uploads, which only a client applies, since a host converts no video:
4
+ *
5
+ * 1. **H.264 at CRF 23**, 8-bit 4:2:0, with AAC-LC at 128 kbps in stereo, in an MP4 whose index comes
6
+ * first, so a page can start playing it before it has all of it.
7
+ * 2. **A long edge of at most 1920**, never enlarged, with a phone's rotation applied to the pixels.
8
+ * 3. **A bitrate ceiling** of 5 Mbps at 1080p, scaled by the frame's size (about 2.2 Mbps at 720p). An
9
+ * encode that comes out over it is made again at the ceiling.
10
+ * 4. **Location and camera data are dropped**, as from a picture.
11
+ * 5. **A video already within the rule** (H.264 with AAC or no sound, at most 1920 on its long edge, at
12
+ * or under the ceiling) is remuxed only: into an MP4, without its private data, its index first.
13
+ * 6. **An HDR video** (HLG, PQ or Dolby Vision) is remuxed in its own container and kept as it is,
14
+ * with a note. Making one SDR needs tone mapping, and no chain for it is measured here yet.
15
+ * 7. **With no `ffmpeg` that has `libx264`**, an MP4 or QuickTime file still loses its location and
16
+ * camera data: its metadata boxes are blanked in place, so nothing else in it moves
17
+ * (`blankVideoMetadata`). It goes up otherwise as it is, with a note when it is heavy.
18
+ *
19
+ * The quality target repeats byte for byte, and so does an encode at the ceiling, so a prepared video
20
+ * has one identity wherever the same `ffmpeg` makes it. A cap during the encode (`-maxrate`) did not
21
+ * repeat with more than one thread (measured with Homebrew's ffmpeg 8.1, 2026-11-12).
22
+ *
23
+ * `ffmpeg` and `ffprobe` run with their output captured, never handed ours, so a reader that leaves
24
+ * can't stop them (`utils/closed-reader.js`).
25
+ */
26
+ import { execFile } from 'node:child_process'
27
+ import { mkdtemp, readFile, rm } from 'node:fs/promises'
28
+ import { tmpdir } from 'node:os'
29
+ import { join } from 'node:path'
30
+ import { promisify } from 'node:util'
31
+
32
+ const run = promisify(execFile)
33
+
34
+ /** The rule's numbers. */
35
+ export const VIDEO_RULE = Object.freeze({
36
+ crf: 23,
37
+ longEdge: 1920,
38
+ /** Bits a second at 1920×1080; the ceiling scales with the frame's area. */
39
+ ceilingAt1080p: 5_000_000,
40
+ audioBitrate: '128k',
41
+ })
42
+
43
+ /** Containers the rule prepares, by extension. */
44
+ const PREPARED = new Set(['mp4', 'm4v', 'mov', 'webm'])
45
+
46
+ /** Containers whose metadata boxes can be blanked in place. */
47
+ const BOXED = new Set(['mp4', 'm4v', 'mov'])
48
+
49
+ const extOf = (ext) => String(ext || '').toLowerCase().replace(/^\./, '')
50
+
51
+ /**
52
+ * Whether the rule prepares a video with this extension.
53
+ *
54
+ * @param {string} ext - `mp4`, `.mov` or `MP4`
55
+ * @returns {boolean}
56
+ */
57
+ export function isPreparableVideo(ext) {
58
+ return PREPARED.has(extOf(ext))
59
+ }
60
+
61
+ /** The ceiling for a frame of this size, in bits a second. */
62
+ export function ceilingFor(width, height) {
63
+ return Math.round((VIDEO_RULE.ceilingAt1080p * width * height) / (1920 * 1080))
64
+ }
65
+
66
+ /** The frame a video is encoded to: at most `longEdge` on its long edge, its sides even. */
67
+ function encodedSize(width, height) {
68
+ const scale = Math.min(1, VIDEO_RULE.longEdge / Math.max(width, height))
69
+ if (scale === 1) return [width, height]
70
+ const even = (n) => Math.max(2, Math.round((n * scale) / 2) * 2)
71
+ return [even(width), even(height)]
72
+ }
73
+
74
+ let tools // undefined: not looked for yet; null: none here
75
+
76
+ /**
77
+ * The `ffmpeg` and `ffprobe` this machine has, when its `ffmpeg` has `libx264` and `aac`. Some Linux
78
+ * packages leave `libx264` out, and such a build counts as none. Looked for once.
79
+ *
80
+ * @returns {Promise<{ ffmpeg: string, ffprobe: string } | null>}
81
+ */
82
+ export async function findVideoTools() {
83
+ if (tools !== undefined) return tools
84
+ try {
85
+ const { stdout } = await run('ffmpeg', ['-hide_banner', '-encoders'], { maxBuffer: 4 << 20 })
86
+ await run('ffprobe', ['-version'])
87
+ tools = / libx264 /.test(stdout) && / aac /.test(stdout) ? { ffmpeg: 'ffmpeg', ffprobe: 'ffprobe' } : null
88
+ } catch {
89
+ tools = null
90
+ }
91
+ return tools
92
+ }
93
+
94
+ /** What `ffprobe` says of a file: its first video stream, its first audio stream and its format. */
95
+ async function probe(ffprobe, path) {
96
+ const { stdout } = await run(
97
+ ffprobe,
98
+ ['-v', 'error', '-print_format', 'json', '-show_format', '-show_streams', path],
99
+ { maxBuffer: 16 << 20 }
100
+ )
101
+ const info = JSON.parse(stdout)
102
+ const streams = info.streams || []
103
+ return {
104
+ video: streams.find((s) => s.codec_type === 'video' && !s.disposition?.attached_pic),
105
+ audio: streams.find((s) => s.codec_type === 'audio'),
106
+ format: info.format || {},
107
+ }
108
+ }
109
+
110
+ const HDR_TRANSFERS = new Set(['arib-std-b67', 'smpte2084'])
111
+
112
+ function isHdr(video) {
113
+ if (HDR_TRANSFERS.has(video.color_transfer)) return true
114
+ return (video.side_data_list || []).some((d) => /DOVI/i.test(d.side_data_type || ''))
115
+ }
116
+
117
+ /** A stream's bitrate, or the format's less the sound's when the stream states none. */
118
+ function videoBitrate({ video, audio, format }) {
119
+ const own = Number(video.bit_rate)
120
+ if (own > 0) return own
121
+ return Math.max(0, (Number(format.bit_rate) || 0) - (Number(audio?.bit_rate) || 0))
122
+ }
123
+
124
+ /** Whether a probed video is within the rule, its container apart. */
125
+ function withinRule(probed) {
126
+ const { video, audio } = probed
127
+ const width = Number(video.width)
128
+ const height = Number(video.height)
129
+ return (
130
+ video.codec_name === 'h264' &&
131
+ (video.pix_fmt === 'yuv420p' || video.pix_fmt === 'yuvj420p') &&
132
+ (!audio || audio.codec_name === 'aac') &&
133
+ Math.max(width, height) <= VIDEO_RULE.longEdge &&
134
+ videoBitrate(probed) <= ceilingFor(width, height)
135
+ )
136
+ }
137
+
138
+ const QUIET = ['-hide_banner', '-loglevel', 'error', '-nostdin', '-y']
139
+ // Only the picture and the sound go, without the file's metadata, chapters or other tracks, and with
140
+ // no encoder version written, so the same input gives the same bytes.
141
+ const KEEP = ['-map', '0:v:0', '-map', '0:a:0?', '-map_metadata', '-1', '-map_chapters', '-1']
142
+ const FINISH = ['-movflags', '+faststart', '-fflags', '+bitexact']
143
+
144
+ // WebM has no index to move first.
145
+ const remux = (input, output, { webm = false } = {}) => [
146
+ ...QUIET, '-i', input, ...KEEP, '-c', 'copy', ...(webm ? ['-fflags', '+bitexact'] : FINISH), output,
147
+ ]
148
+
149
+ function encode(input, output, rate) {
150
+ const edge = VIDEO_RULE.longEdge
151
+ const fit = `scale=w=if(gte(iw\\,ih)\\,min(${edge}\\,iw)\\,-2):h=if(gte(iw\\,ih)\\,-2\\,min(${edge}\\,ih)),format=yuv420p`
152
+ return [
153
+ ...QUIET, '-i', input, ...KEEP,
154
+ '-vf', fit,
155
+ '-c:v', 'libx264', '-preset', 'medium', '-profile:v', 'high', ...rate,
156
+ '-c:a', 'aac', '-b:a', VIDEO_RULE.audioBitrate, '-ac', '2',
157
+ ...FINISH, output,
158
+ ]
159
+ }
160
+
161
+ /**
162
+ * Prepare a video under the rule.
163
+ *
164
+ * @param {string} path - the file on disk, which `ffmpeg` reads
165
+ * @param {Buffer} bytes - the same file, for when there is no `ffmpeg`
166
+ * @param {string} ext - its extension
167
+ * @param {{ tools?: { ffmpeg: string, ffprobe: string } | null, onProgress?: (m: string) => void }} [options]
168
+ * `tools`: what `findVideoTools` found, or `null` to prepare without them
169
+ * @returns {Promise<{ bytes: Buffer, ext: string, converted: boolean, note?: string }>} `converted`:
170
+ * encoded again. `note`: what to tell the author.
171
+ */
172
+ export async function prepareVideo(path, bytes, ext, { tools: found, onProgress } = {}) {
173
+ const kind = extOf(ext)
174
+ const available = found === undefined ? await findVideoTools() : found
175
+ if (!available) return withoutTools(bytes, kind)
176
+
177
+ let probed
178
+ try {
179
+ probed = await probe(available.ffprobe, path)
180
+ } catch {
181
+ return { ...withoutTools(bytes, kind), note: "is uploaded as it is: ffmpeg couldn't read it, so check that it plays." }
182
+ }
183
+ // Sound alone: nothing to encode, and its metadata blanked where its container allows.
184
+ if (!probed.video) return { bytes: (BOXED.has(kind) && blankVideoMetadata(bytes)?.bytes) || bytes, ext: kind, converted: false }
185
+
186
+ const dir = await mkdtemp(join(tmpdir(), 'uniweb-video-'))
187
+ try {
188
+ if (isHdr(probed.video)) {
189
+ const out = join(dir, `remuxed.${kind}`)
190
+ await run(available.ffmpeg, remux(path, out, { webm: kind === 'webm' }))
191
+ return {
192
+ bytes: await readFile(out),
193
+ ext: kind,
194
+ converted: false,
195
+ note: "is HDR, so it goes up as it is: it can't be made SDR here. Export it as SDR (HD or 1080p) for a smaller file most browsers play.",
196
+ }
197
+ }
198
+ const out = join(dir, 'prepared.mp4')
199
+ if (withinRule(probed)) {
200
+ await run(available.ffmpeg, remux(path, out))
201
+ return { bytes: await readFile(out), ext: 'mp4', converted: false }
202
+ }
203
+ onProgress?.('making a video smaller…')
204
+ await run(available.ffmpeg, encode(path, out, ['-crf', String(VIDEO_RULE.crf)]), { maxBuffer: 4 << 20 })
205
+ const [width, height] = encodedSize(Number(probed.video.width), Number(probed.video.height))
206
+ const ceiling = ceilingFor(width, height)
207
+ const made = await probe(available.ffprobe, out)
208
+ if (videoBitrate(made) > ceiling) {
209
+ await run(available.ffmpeg, encode(path, out, ['-b:v', String(ceiling)]), { maxBuffer: 4 << 20 })
210
+ }
211
+ return { bytes: await readFile(out), ext: 'mp4', converted: true }
212
+ } catch {
213
+ return { ...withoutTools(bytes, kind), note: "is uploaded as it is: ffmpeg couldn't convert it, so check that it plays." }
214
+ } finally {
215
+ await rm(dir, { recursive: true, force: true })
216
+ }
217
+ }
218
+
219
+ /** Without `ffmpeg`: blanked in place where its container allows, and a note when it is heavy. */
220
+ function withoutTools(bytes, kind) {
221
+ const blanked = BOXED.has(kind) ? blankVideoMetadata(bytes) : null
222
+ const seconds = blanked?.seconds
223
+ const heavy = seconds > 0 ? (bytes.length * 8) / seconds > VIDEO_RULE.ceilingAt1080p : !blanked
224
+ return {
225
+ bytes: blanked?.bytes ?? bytes,
226
+ ext: kind,
227
+ converted: false,
228
+ ...(heavy
229
+ ? { note: "is uploaded as it is: a push makes a video smaller only with ffmpeg installed, with libx264 (on a Mac: brew install ffmpeg)." }
230
+ : {}),
231
+ }
232
+ }
233
+
234
+ /**
235
+ * An MP4 or QuickTime file without its location and camera data, nothing else in it moved. The
236
+ * metadata boxes in `moov` and in each `trak` (`udta`, `meta`) become `free` boxes with their bytes
237
+ * zeroed, so no size or offset changes and every player skips them. A timed metadata track's samples
238
+ * are not reached, which a remux with `ffmpeg` drops.
239
+ *
240
+ * @param {Buffer} bytes
241
+ * @returns {{ bytes: Buffer, seconds?: number } | null} null when the file doesn't parse as boxes.
242
+ * `seconds`: its duration, from `mvhd`.
243
+ */
244
+ export function blankVideoMetadata(bytes) {
245
+ const out = Buffer.from(bytes)
246
+ let seconds
247
+ const box = (at, end) => {
248
+ if (at + 8 > end) return null
249
+ let size = out.readUInt32BE(at)
250
+ let head = 8
251
+ if (size === 1) {
252
+ if (at + 16 > end) return null
253
+ size = Number(out.readBigUInt64BE(at + 8))
254
+ head = 16
255
+ } else if (size === 0) size = end - at
256
+ if (size < head || at + size > end) return null
257
+ return { type: out.toString('latin1', at + 4, at + 8), start: at + head, end: at + size }
258
+ }
259
+ const walk = (from, end, parent) => {
260
+ for (let at = from; at < end; ) {
261
+ const b = box(at, end)
262
+ if (!b) return false
263
+ if ((parent === 'moov' || parent === 'trak') && (b.type === 'udta' || b.type === 'meta')) {
264
+ out.write('free', at + 4, 'latin1')
265
+ out.fill(0, b.start, b.end)
266
+ } else if (b.type === 'moov' || b.type === 'trak') {
267
+ if (!walk(b.start, b.end, b.type)) return false
268
+ } else if (b.type === 'mvhd' && parent === 'moov') {
269
+ const v1 = out[b.start] === 1
270
+ const scale = out.readUInt32BE(b.start + (v1 ? 20 : 12))
271
+ const length = v1 ? Number(out.readBigUInt64BE(b.start + 24)) : out.readUInt32BE(b.start + 16)
272
+ if (scale > 0) seconds = length / scale
273
+ }
274
+ at = b.end
275
+ }
276
+ return true
277
+ }
278
+ if (out.length < 8 || !walk(0, out.length, null)) return null
279
+ return { bytes: out, ...(seconds ? { seconds } : {}) }
280
+ }
@@ -19,6 +19,7 @@ import { basename } from 'node:path'
19
19
  import { resolveAssetPath } from '@uniweb/build/site'
20
20
  import { servedFingerprint } from '@uniweb/build/uwx'
21
21
  import { prepareImage, isPreparableImage } from '@uniweb/build/images'
22
+ import { prepareVideo, isPreparableVideo } from './prepare-video.js'
22
23
  import { contentTypeFor } from '../utils/code-upload.js'
23
24
  import { humanBytes } from '../utils/bytes.js'
24
25
 
@@ -93,10 +94,10 @@ export async function uploadSiteMedia(
93
94
  // images) keeps its format, since a home screen takes a PNG and a link preview a JPEG or PNG, and
94
95
  // loses only its location and camera data. ⛔ Until 2026-11-12 those went up as they were, so a
95
96
  // phone's photo made a social image kept where it was taken, on its page too.
97
+ // A video a page plays is prepared too (`prepareVideo`), under the video half of the rule.
96
98
  const ext = extOf(resolved)
97
- const prepare = !declared && isPreparableImage(ext)
98
- const options = { keepFormat: keepFormat.has(ref) }
99
- files.push(prepare ? await preparedFile(file, bytes, ext, recorded?.[ref], warn, options) : file)
99
+ const make = declared ? null : makerFor(ref, resolved, bytes, ext, { keepFormat: keepFormat.has(ref), onProgress })
100
+ files.push(make ? await preparedFile(file, ext, recorded?.[ref], warn, make) : file)
100
101
  }
101
102
  if (!files.length) return { map: {}, ids: {}, missing, served, failed: [] }
102
103
 
@@ -118,7 +119,7 @@ export async function uploadSiteMedia(
118
119
  localUrl: was.localUrl,
119
120
  diskPath: was.diskPath
120
121
  }
121
- again.push(await preparedFile(file, bytes, extOf(was.diskPath), null, warn, { keepFormat: was.keepFormat }))
122
+ again.push(await preparedFile(file, extOf(was.diskPath), null, warn, was.make))
122
123
  }
123
124
  const retry = await client.uploadSiteAssets({ files: again, siteUuid, onProgress })
124
125
  result = {
@@ -185,8 +186,21 @@ const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex')
185
186
  const extOf = (path) => (basename(path).match(/\.([^.]+)$/)?.[1] || '').toLowerCase()
186
187
 
187
188
  /**
188
- * The plan entry for a picture a page shows, stored as `prepareImage` makes it. Three cases, by what
189
- * this backend's asset map records for the ref:
189
+ * How a file is prepared before it is uploaded, or null when it goes up as it is.
190
+ *
191
+ * @returns {null | (() => Promise<{ bytes: Buffer, ext: string, unreadable?: boolean, note?: string }>)}
192
+ */
193
+ function makerFor(ref, path, bytes, ext, { keepFormat, onProgress }) {
194
+ if (isPreparableImage(ext)) return () => prepareImage(bytes, ext, { keepFormat })
195
+ if (isPreparableVideo(ext)) {
196
+ return () => prepareVideo(path, bytes, ext, { onProgress: (m) => onProgress?.(`${ref}: ${m}`) })
197
+ }
198
+ return null
199
+ }
200
+
201
+ /**
202
+ * The plan entry for a picture or a video a page shows, stored as `make` prepares it. Three cases, by
203
+ * what this backend's asset map records for the ref:
190
204
  *
191
205
  * - **Prepared before, from these same bytes** (`source` is their hash): planned by the identity it
192
206
  * recorded, with no bytes, so nothing is prepared again. The backend still holding it, the plan
@@ -197,13 +211,12 @@ const extOf = (path) => (basename(path).match(/\.([^.]+)$/)?.[1] || '').toLowerC
197
211
  * - **New or changed:** prepared now.
198
212
  *
199
213
  * @param {object} file - the plan entry for the file as it is
200
- * @param {Buffer} bytes - the file
201
214
  * @param {string} ext - its extension
202
215
  * @param {object|undefined|null} prior - its entry in the asset map
203
216
  * @param {(m: string) => void} [warn]
204
- * @param {{ keepFormat?: boolean }} [options] - a picture other software fetches by its address
217
+ * @param {() => Promise<{ bytes: Buffer, ext: string, unreadable?: boolean, note?: string }>} make
205
218
  */
206
- async function preparedFile(file, bytes, ext, prior, warn, { keepFormat = false } = {}) {
219
+ async function preparedFile(file, ext, prior, warn, make) {
207
220
  const source = file.sha256
208
221
  const key = file.path
209
222
  if (prior?.source === source && prior.id && prior.ext && Number.isInteger(prior.size)) {
@@ -215,16 +228,15 @@ async function preparedFile(file, bytes, ext, prior, warn, { keepFormat = false
215
228
  size: prior.size,
216
229
  sha256: prior.id,
217
230
  source,
218
- keepFormat,
219
- load: async () => (await prepareImage(bytes, ext, { keepFormat })).bytes
231
+ make,
232
+ load: async () => (await make()).bytes
220
233
  }
221
234
  }
222
235
  if (prior && !prior.source && prior.id === source) return { ...file, key, source }
223
236
 
224
- const prepared = await prepareImage(bytes, ext, { keepFormat })
225
- if (prepared.unreadable) {
226
- warn?.(`local-media: ${file.localUrl} is uploaded as it is: it can't be converted here, and some browsers can't show it`)
227
- }
237
+ const prepared = await make()
238
+ const note = prepared.note ?? (prepared.unreadable ? `is uploaded as it is: ${unreadable(ext)}` : null)
239
+ if (note) warn?.(`local-media: ${file.localUrl} ${note}`)
228
240
  return {
229
241
  ...file,
230
242
  key,
@@ -234,10 +246,20 @@ async function preparedFile(file, bytes, ext, prior, warn, { keepFormat = false
234
246
  sha256: sha256(prepared.bytes),
235
247
  bytes: prepared.bytes,
236
248
  source,
237
- keepFormat
249
+ make
238
250
  }
239
251
  }
240
252
 
253
+ /**
254
+ * What to tell an author whose picture couldn't be read here, by its format. A BMP is drawn by every
255
+ * browser, so it only stays as large as it is; a HEIC is drawn by few.
256
+ */
257
+ function unreadable(ext) {
258
+ if (ext === 'heic' || ext === 'heif') return "it can't be converted here, and most browsers won't show it. Export it as JPEG."
259
+ if (ext === 'bmp') return "it can't be made smaller here. Export it as PNG or JPEG for a smaller file."
260
+ return "it can't be read here, so check that it opens."
261
+ }
262
+
241
263
  /**
242
264
  * The plan's key for a prepared file. The backend types an upload by its extension, so a picture
243
265
  * stored as a WebP goes by one ending in `.webp`: its own key with the extension added, which keeps
@@ -1422,10 +1422,24 @@ export function writeQueryUuids(siteDir, backend, map) {
1422
1422
  if (!map || !Object.keys(map).length) return
1423
1423
  updateBackendMap(siteDir, backend, 'queries', map)
1424
1424
  }
1425
+ // Placements a recovery found missing, beside the ones this copy holds (`recoverRecordsIdentity`).
1425
1426
  export function writeFolderItemUuids(siteDir, backend, map) {
1426
1427
  if (!map || !Object.keys(map).length) return
1427
1428
  updateBackendMap(siteDir, backend, 'folders', map)
1428
1429
  }
1430
+ /**
1431
+ * The placements of a folder the backend handed back — a pull's, or the one a push stored — written
1432
+ * WHOLE, as its record types are (`writeHeldTypes`), so they name exactly the entries it holds.
1433
+ *
1434
+ * ⛔ Until 2026-11-13 each answer was merged into the ones before, so an entry the app removed kept its
1435
+ * `$uuid` here, and the next push stamped it on the record's entry again, which the backend re-created:
1436
+ * a record an author had removed from the site in the app came back with a teammate's push from a copy
1437
+ * that still held its file (measured on a site, 2026-11-10). A removed entry's `$uuid` leaves with it
1438
+ * now, so a record whose file is brought back goes up in an entry of its own.
1439
+ */
1440
+ export function writeFolderPlacements(siteDir, backend, folderDoc) {
1441
+ setBackendMap(siteDir, backend, 'folders', collectFolderItemUuids(folderDoc))
1442
+ }
1429
1443
  /**
1430
1444
  * What the backend holds each record as — its uuid → the data schema its folder entry names —
1431
1445
  * banked wherever placements are, from the same folder document. A push reads it to tell a record
@@ -3092,9 +3106,7 @@ export async function pushSyncPackages({
3092
3106
  // live manor 2026-08-27; the identities were on the wire all along.
3093
3107
  const folderDoc = finalized.find((f) => f?.document?.contents)?.document
3094
3108
  if (folderDoc) {
3095
- const placements = collectFolderItemUuids(folderDoc)
3096
- if (Object.keys(placements).length)
3097
- writeFolderItemUuids(siteDir, client.origin, placements)
3109
+ writeFolderPlacements(siteDir, client.origin, folderDoc)
3098
3110
  // What the folder places now, and so which records this push took out of it.
3099
3111
  retireUnplaced(siteDir, client.origin, writeHeldTypes(siteDir, client.origin, folderDoc), { ownedBefore })
3100
3112
  // ⭐ A LINK RECORD'S IDENTITY is its folder entry's `$uuid`, banked as a record's is: into
@@ -41,6 +41,7 @@ import { discoverFoundations, discoverSites } from '../utils/discover.js'
41
41
  import { siteAround } from '../utils/pick-site.js'
42
42
  import { workspaceTypesDefinedTwice } from '../utils/workspace-types.js'
43
43
  import { checkSiteInstall } from '../utils/install-integrity.js'
44
+ import { findVideoTools } from '../backend/prepare-video.js'
44
45
  import { editWorkspaceFilePackages } from '../utils/workspace-packages.js'
45
46
  import { findWorkspaceRoot } from '../utils/workspace.js'
46
47
  import { ignoredByRepo } from '../utils/git.js'
@@ -1364,6 +1365,54 @@ function listSome(items, n = 5) {
1364
1365
  if (items.length > n) log(` ${colors.dim}…and ${items.length - n} more${colors.reset}`)
1365
1366
  }
1366
1367
 
1368
+ /** A site's local video references: `/x.mp4`, `./x.mov` and the like, in its pages, layout and records. */
1369
+ function localVideoRefs(sitePath) {
1370
+ const refs = new Set()
1371
+ const ref = /(?:\]\(|:\s*['"]?|\s)(\.{0,2}\/(?!\/)[^\s)'"\]]+\.(?:mp4|m4v|mov|webm))\b/gi
1372
+ const walk = (dir) => {
1373
+ let entries
1374
+ try {
1375
+ entries = readdirSync(dir, { withFileTypes: true })
1376
+ } catch {
1377
+ return
1378
+ }
1379
+ for (const entry of entries) {
1380
+ if (entry.name.startsWith('.') || entry.name === 'node_modules') continue
1381
+ const path = join(dir, entry.name)
1382
+ if (entry.isDirectory()) walk(path)
1383
+ else if (/\.(md|ya?ml|json)$/.test(entry.name)) {
1384
+ for (const match of readFileSync(path, 'utf8').matchAll(ref)) refs.add(match[1])
1385
+ }
1386
+ }
1387
+ }
1388
+ for (const dir of ['pages', 'layout', 'records']) walk(join(sitePath, dir))
1389
+ return [...refs]
1390
+ }
1391
+
1392
+ /**
1393
+ * Whether a push can make the site's videos smaller. `uniweb push` and `uniweb publish` prepare a
1394
+ * video a page plays with this machine's `ffmpeg`, when it has `libx264`; with none, a video goes up
1395
+ * as it is, without its location. Said only where the site has videos, and only when there is no
1396
+ * such `ffmpeg`: the CLI ships no encoder [Diego, 2026-11-12: "Clearly we are not going to ship
1397
+ * ffmpeg inside the CLI. That's out of the question. The cli help or `doctor` command can suggest
1398
+ * installing it, and it can check if it's already available and use it."].
1399
+ *
1400
+ * @param {{ sitePath: string, siteName: string, issues: object[], tools?: object|null }} options
1401
+ * `tools`: what `findVideoTools` found, for a test to say
1402
+ */
1403
+ export async function checkVideoTools({ sitePath, siteName, issues, tools }) {
1404
+ const videos = localVideoRefs(sitePath)
1405
+ if (videos.length === 0) return
1406
+ const found = tools === undefined ? await findVideoTools() : tools
1407
+ if (found) return
1408
+ const id = 'video-encoder-none'
1409
+ const n = videos.length
1410
+ const message = `A push uploads this site's ${n === 1 ? 'video' : `${n} videos`} as ${n === 1 ? 'it is' : 'they are'}: this machine has no ffmpeg with libx264`
1411
+ issues.push({ id, type: 'info', site: siteName, message })
1412
+ info(`[${id}] ${message}`)
1413
+ log(` Install ffmpeg (on a Mac: ${colors.green}brew install ffmpeg${colors.reset}), and a push makes a new or changed video smaller before it goes up: H.264 at most 1920 on its long edge, about 5 Mbps at 1080p. A video already stored stays as it is.`)
1414
+ }
1415
+
1367
1416
  /**
1368
1417
  * What a link to the site shows. A chat, a feed or a search result draws a card from a page's head
1369
1418
  * tags (`Page#getHeadMeta`): its image — the page's `seo.image`, else the site's — its title and its
@@ -2336,6 +2385,8 @@ async function runDoctor(args = []) {
2336
2385
  await checkLinkPreviews({ sitePath, siteName, issues })
2337
2386
  await checkFavicon({ sitePath, siteName, siteYml, issues, shouldFix, fixed })
2338
2387
  await checkTouchIcon({ sitePath, siteName, siteYml, issues, shouldFix, fixed })
2388
+ // Whether a push can make its videos smaller.
2389
+ await checkVideoTools({ sitePath, siteName, issues })
2339
2390
 
2340
2391
  // Forms need a destination, and having none is only visible on the page.
2341
2392
  await checkFormSubmitTarget({ sitePath, siteName, siteYml, issues })
@@ -36,8 +36,8 @@
36
36
  * the backend's version whole, and leaves a sync point.
37
37
  *
38
38
  * Outside a repository there is nothing to merge against: a pull reconciles the files to
39
- * the backend — section bodies rewritten, pages and sections the backend no longer has
40
- * DELETED (`--no-delete` keeps them; an empty or partial payload never wipes the tree) —
39
+ * the backend — section bodies rewritten, pages, sections and records the backend no longer
40
+ * has DELETED (`--no-delete` keeps them; an empty or partial payload never wipes the tree) —
41
41
  * and asks first, unless nothing there is the author's (`pull-written.js`).
42
42
  *
43
43
  * `uniweb login && uniweb pull`. Run from a site, or a workspace with one site.
@@ -71,7 +71,7 @@ import {
71
71
  statSync
72
72
  } from 'node:fs'
73
73
  import { createInterface } from 'node:readline/promises'
74
- import { join, dirname, relative, resolve, posix } from 'node:path'
74
+ import { join, dirname, relative, resolve, posix, sep } from 'node:path'
75
75
  import { execFileSync } from 'node:child_process'
76
76
  import yaml from 'js-yaml'
77
77
  import { downloadMissingAssets, downloadFileRecords } from '../backend/asset-download.js'
@@ -87,7 +87,6 @@ import {
87
87
  computeUnitHashes,
88
88
  collectUnitUuids,
89
89
  collectQueryUuids,
90
- collectFolderItemUuids,
91
90
  documentSchema
92
91
  } from '@uniweb/build/uwx'
93
92
  import {
@@ -112,12 +111,13 @@ import {
112
111
  commitWriteBacks,
113
112
  reportWriteBacks,
114
113
  writeItemUuids,
115
- writeFolderItemUuids,
114
+ writeFolderPlacements,
116
115
  writeHeldTypes,
117
116
  readItemBaseVersions
118
117
  } from '../backend/site-sync.js'
119
118
  import { resolveWorkspace } from '../backend/workspace.js'
120
- import { siteRoots, sentRoots, laneRoots, writableMounts, refusedMountLines, heldMountLines, levelsAboveRepository } from '../utils/site-roots.js'
119
+ import { siteRoots, sentRoots, laneRoots, unsentPaths, pageRoots, writableMounts, refusedMountLines, heldMountLines, levelsAboveRepository } from '../utils/site-roots.js'
120
+ import { sectionFilesNamedTwice, describeSectionsNamedTwice } from '@uniweb/build/site'
121
121
  import {
122
122
  repoOf,
123
123
  mergeInProgress,
@@ -259,7 +259,12 @@ function pullCachePath(siteDir) {
259
259
  // ⛔ VERSION 3 DISOWNS THOSE OF A PULL THAT READ NOTHING OF `@`. Before 2026-10-31 a pull took a
260
260
  // translation the app had flagged for current, and kept nothing of `@`. A site that has not moved
261
261
  // since would answer 304, and its next push would remove what the app keeps there.
262
- const PULL_CACHE_VERSION = 3
262
+ // ⛔ VERSION 4 DISOWNS THOSE OF A PULL THAT KEPT A REMOVED RECORD'S FILE. Before 2026-11-13 a pull took
263
+ // a folder without a record this copy had pushed, and left the record's file and its mapping, and the
264
+ // `$uuid` of the entry the app removed, which the next push stamped back on. A folder that has not
265
+ // moved since would answer 304, and neither would ever go (`recordsToProject`'s `prune`,
266
+ // `writeFolderPlacements`).
267
+ const PULL_CACHE_VERSION = 4
263
268
  export function readPullCache(siteDir) {
264
269
  try {
265
270
  const obj = JSON.parse(readFileSync(pullCachePath(siteDir), 'utf8'))
@@ -381,6 +386,30 @@ export function describeUnplacedRecords({ docs, taken, skipped }) {
381
386
  // `readZip` reads both); the entity files ARE the documents. Falls back to a JSON body (a raw doc, a `{document}`/`{entity}` envelope,
382
387
  // or a list) so the lane survives a future envelope change. Returns an array (possibly
383
388
  // empty).
389
+ /**
390
+ * Each page directory of the site that holds a section in more than one file, said as the build says
391
+ * it (`sectionFilesNamedTwice`, `@uniweb/build/site`).
392
+ *
393
+ * @param {string} siteDir
394
+ * @returns {string[]}
395
+ */
396
+ function sectionsNamedTwiceIn(siteDir) {
397
+ const found = []
398
+ const walk = (dir) => {
399
+ let entries
400
+ try {
401
+ entries = readdirSync(dir, { withFileTypes: true })
402
+ } catch {
403
+ return
404
+ }
405
+ const twice = sectionFilesNamedTwice(entries.filter((e) => e.isFile()).map((e) => e.name))
406
+ if (twice.length) found.push(describeSectionsNamedTwice(relative(siteDir, dir).split(sep).join('/') || '.', twice))
407
+ for (const e of entries) if (e.isDirectory() && !e.name.startsWith('.') && e.name !== 'node_modules') walk(join(dir, e.name))
408
+ }
409
+ for (const root of pageRoots(siteDir)) walk(join(siteDir, root))
410
+ return found
411
+ }
412
+
384
413
  export function readPullDocuments(buf) {
385
414
  // `.uwx` ZIP — the local-file signature is "PK\x03\x04".
386
415
  if (buf.length >= 2 && buf[0] === 0x50 && buf[1] === 0x4b) {
@@ -983,6 +1012,8 @@ export async function pull(args = [], deps = {}) {
983
1012
  let sections = 0
984
1013
  let records = 0
985
1014
  let deleted = 0
1015
+ // The records the app removed, which this pull removes from the files (`recordsToProject`'s `prune`).
1016
+ let recordsRemoved = []
986
1017
  // The pages a pull does not write — a mount's, a folder-mode `.md` page given what its file cannot
987
1018
  // hold, a route the files give two pages for (`@uniweb/build`'s `page-files.js`). Said, since an app
988
1019
  // edit to one does not come back; each `.md` page with what it could not hold.
@@ -1189,7 +1220,9 @@ export async function pull(args = [], deps = {}) {
1189
1220
  ...(taken(folderLane) ? [{ source: folderLane.source, roots: rootsOfLanes.records }] : [])
1190
1221
  ],
1191
1222
  origin: client.origin,
1192
- siteUuid: siteContentUuid
1223
+ siteUuid: siteContentUuid,
1224
+ // Files a push never sends: a commit that changed only those holds what the backend does.
1225
+ unsent: unsentPaths(siteDir)
1193
1226
  })
1194
1227
  // A probe with no base cannot tell the backend's changes from this copy's: onto HEAD, it says
1195
1228
  // what differs, and which way is the person's to read (`noBase`, below). ⛔ Until 2026-10-26
@@ -1341,15 +1374,22 @@ export async function pull(args = [], deps = {}) {
1341
1374
  // back in `records/article/` — see `pullScope`.
1342
1375
  scope: pullScope,
1343
1376
  // What the foundation declares, read again now the site's content (its `site.yml`) is in.
1344
- foundation: await readSiteFoundationDeclarations(projDir)
1377
+ foundation: await readSiteFoundationDeclarations(projDir),
1378
+ // ⭐ A record the app removed is removed here, as a page is: onto the stand-in in a
1379
+ // repository, where git merges it, and where this pull's outside-git consent says so.
1380
+ // `--no-delete` keeps its file, as it keeps a page's.
1381
+ prune
1345
1382
  }
1346
1383
  })
1384
+ recordsRemoved = (report.removed || []).map((p) => relative(projDir, p).split(sep).join('/'))
1385
+ removed.push(...(report.removed || []))
1347
1386
  // ⭐ THE FOLDER'S PLACEMENT IDENTITY, from the folder this pull took — as a push banks
1348
1387
  // it from the folder it sent. ⛔ Only a push banked it until 2026-09-25, so a copy that
1349
1388
  // had never pushed (every clone) sent its first folder with its placements uuid-less,
1350
1389
  // and the backend refused that push (`identity_required`, section `contents`) —
1351
1390
  // measured on a template clone's first edit.
1352
- if (folderDoc) writeFolderItemUuids(projDir, client.origin, collectFolderItemUuids(folderDoc))
1391
+ // Whole, so an entry the app removed leaves with it (`writeFolderPlacements`).
1392
+ if (folderDoc) writeFolderPlacements(projDir, client.origin, folderDoc)
1353
1393
  // …and what each record is held as, so a push can tell a record whose file moved schema.
1354
1394
  if (folderDoc) writeHeldTypes(projDir, client.origin, folderDoc)
1355
1395
  // The folder's organization, `folder.yml` in the records directory — named as
@@ -1683,9 +1723,14 @@ export async function pull(args = [], deps = {}) {
1683
1723
 
1684
1724
  const summary =
1685
1725
  `Pulled — ${pages} page(s), ${sections} section(s), ${records} record(s)` +
1686
- (deleted ? `, ${deleted} deleted` : '')
1726
+ (deleted ? `, ${deleted} deleted` : '') +
1727
+ (recordsRemoved.length ? `, ${recordsRemoved.length} record(s) removed in the app` : '')
1687
1728
  if (notTaken || recordsNotPlaced) info(summary)
1688
1729
  else success(summary)
1730
+ // ⭐ Each record the app removed, by its file: one a person meant to keep is brought back by restoring
1731
+ // the file and pushing it, when it goes up as a new record.
1732
+ for (const p of recordsRemoved.slice(0, 12)) note(` removed in the app: ${p}`)
1733
+ if (recordsRemoved.length > 12) note(` … and ${recordsRemoved.length - 12} more`)
1689
1734
  // ⭐ Said, since it edits `site.yml`: the route is the mount's key there, and its local folder.
1690
1735
  if (!notTaken) {
1691
1736
  for (const { from, to } of mountRoutes) {
@@ -1746,7 +1791,7 @@ export async function pull(args = [], deps = {}) {
1746
1791
  // ⛔ Nothing changed in the files is not the files holding what the backend has: what
1747
1792
  // this copy changed since the base, the backend lacks. Until 2026-10-18 it said they
1748
1793
  // held it either way — measured over a revert the backend did not have yet.
1749
- const ahead = merge.theirs ? filesDifferFrom(repo, merge.theirs, roots) : []
1794
+ const ahead = merge.theirs ? filesDifferFrom(repo, merge.theirs, roots, unsentPaths(siteDir)) : []
1750
1795
  if (!ahead.length) note(`Your files already hold what ${client.origin} has.`)
1751
1796
  else {
1752
1797
  note(`Nothing new from ${client.origin}. ${ahead.length} file(s) here hold changes it does not have yet — \`uniweb push\` sends them:`)
@@ -1759,6 +1804,14 @@ export async function pull(args = [], deps = {}) {
1759
1804
  for (const p of merge.keptAsWritten.slice(0, 12)) note(` ${repo.prefix}${p}`)
1760
1805
  if (merge.keptAsWritten.length > 12) note(` … and ${merge.keptAsWritten.length - 12} more`)
1761
1806
  }
1807
+ // ⛔ ONE SECTION, ONE FILE. Each side adding a section under its own name — `1-lost.md` here, the
1808
+ // backend's `lost.md` — merges without a conflict, and the page would show it twice (2026-11-12).
1809
+ merge.namedTwice = sectionsNamedTwiceIn(siteDir)
1810
+ if (merge.namedTwice.length) {
1811
+ error(`${merge.namedTwice.length} page(s) hold a section in two files, which the merge left side by side:`)
1812
+ for (const line of merge.namedTwice) note(` ${line}`)
1813
+ note('A number orders a section and never names it, so each pair is one section. Keep one file of each, then `git commit`.')
1814
+ }
1762
1815
  if (merge.conflicted.length) {
1763
1816
  error(`${merge.conflicted.length} file(s) have conflicts to resolve:`)
1764
1817
  for (const f of merge.conflicted) note(` ${f}`)
@@ -1827,7 +1880,7 @@ export async function pull(args = [], deps = {}) {
1827
1880
  // all in the files — a chained push must not go on as if it were. And a merge that
1828
1881
  // could not be made took nothing.
1829
1882
  return {
1830
- exitCode: merge.conflicted.length || recordsNotPlaced || notTaken ? 1 : 0,
1883
+ exitCode: merge.conflicted.length || merge.namedTwice?.length || recordsNotPlaced || notTaken ? 1 : 0,
1831
1884
  merge
1832
1885
  }
1833
1886
  }
@@ -81,7 +81,7 @@ import {
81
81
  siteTreeIn,
82
82
  unmergedPaths
83
83
  } from '../utils/sync-point.js'
84
- import { submoduleMountRoots, writableMounts, refusedMountLines, heldMountLines } from '../utils/site-roots.js'
84
+ import { submoduleMountRoots, writableMounts, refusedMountLines, heldMountLines, unsentPaths } from '../utils/site-roots.js'
85
85
  import { aheadBehind, remoteMoved, upstreamOf } from '../utils/git.js'
86
86
  import { mountedRepositories, askRemote, standing, mountName, short } from '../utils/mounted-repositories.js'
87
87
  import { getLatestVersion, isBehind } from '../utils/update-check.js'
@@ -401,7 +401,9 @@ async function gitChecks(siteDir, { offline, origin, mounts = [] }) {
401
401
  let localFiles = null
402
402
  const point = readSyncPoint(siteDir, origin)
403
403
  if (repo.head && point && isAncestor(repo, point) && siteTreeIn(repo, point)) {
404
- localFiles = filesDifferFrom(repo, point, [...sentRoots(siteDir), ...submoduleMountRoots(siteDir)])
404
+ // ⛔ Not the files a push never sends, which no backend can lack: a refreshed translation list was
405
+ // counted among "changes the backend does not have yet" until 2026-11-13.
406
+ localFiles = filesDifferFrom(repo, point, [...sentRoots(siteDir), ...submoduleMountRoots(siteDir)], unsentPaths(siteDir))
405
407
  }
406
408
 
407
409
  const upstream = upstreamOf(siteDir)
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-12T22:48:58.824Z",
3
+ "generatedAt": "2026-11-13T06:00:46.139Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
6
  "version": "1.7.0"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.23.6"
9
+ "version": "1.23.8"
10
10
  },
11
11
  "@uniweb/content-reader": {
12
12
  "version": "1.5.10"
package/src/index.js CHANGED
@@ -1568,6 +1568,9 @@ package.json it writes), syncs content, settles payment when go-live needs it
1568
1568
  (a browser handoff), and goes live. A published-registry foundation needs no
1569
1569
  release; an already-paid site opens no browser.
1570
1570
 
1571
+ Its pictures and videos are made ready as \`uniweb push\` makes them: a video is
1572
+ made smaller only with ffmpeg installed, with libx264 (\`uniweb doctor\` says).
1573
+
1571
1574
  For a third-party host use \`uniweb deploy --host=<name>\`; to register a
1572
1575
  FOUNDATION on its own use \`uniweb register\` (alias \`uniweb release\`).
1573
1576
 
@@ -2093,6 +2096,10 @@ In a git repository a push sends what is committed. It is refused, with nothing
2093
2096
  written, if the site changed in the app since your last pull: run \`uniweb pull\` to
2094
2097
  merge those changes with yours, then push again.
2095
2098
 
2099
+ Pictures and videos are made ready before they go up, without their location. A
2100
+ video is made smaller only with ffmpeg installed, with libx264: \`uniweb doctor\`
2101
+ says whether this machine has it.
2102
+
2096
2103
  ${colors.bright}Options:${colors.reset}
2097
2104
  --commit In a git repository, commit the site's content first (-m <message>)
2098
2105
  --mounts-as-is Send page folders mounted from other repositories as they are,
@@ -66,6 +66,10 @@ const CONTENT_TYPES = {
66
66
  webp: 'image/webp',
67
67
  avif: 'image/avif',
68
68
  ico: 'image/x-icon',
69
+ mp4: 'video/mp4',
70
+ m4v: 'video/mp4',
71
+ mov: 'video/quicktime',
72
+ webm: 'video/webm',
69
73
  txt: 'text/plain',
70
74
  html: 'text/html'
71
75
  }
@@ -50,20 +50,50 @@ export function siteRoots(siteDir, { media = true } = {}) {
50
50
  /** What a push sends from the files: the site's roots, its media among them. */
51
51
  export const sentRoots = (siteDir) => siteRoots(siteDir)
52
52
 
53
+ /** The directories a site's pages are read from: its pages root, and each mount its repository holds. */
54
+ export function pageRoots(siteDir) {
55
+ return rootsOf(siteDir)
56
+ .filter((r) => r.kind === 'pages' || (r.kind === 'mount' && mountHolding(siteDir, r.abs).kind === 'site'))
57
+ .map((r) => r.path)
58
+ }
59
+
53
60
  /**
54
61
  * What each lane of a push carries, as roots: the folder lane the records — their files, and their
55
62
  * translations — and the content lane everything else a pull writes, media (`public/`) and the
56
- * mounts the site's repository holds included. ⚠️ `locales` stays whole on the content side, record
57
- * translations with it: a root too many there costs a less precise base, never a wrong one.
63
+ * mounts the site's repository holds included. `locales` stays whole on the content side, record
64
+ * translations with it. ⛔ A root too many there is NOT harmless: a pull's base is a lane's commit only
65
+ * where every lane's roots hold the same in both, so a root too many takes an older base, and an older
66
+ * base can merge a person's own pushed work back as the app's, or drop a change they took back
67
+ * (`utils/sync-point.js`). So compare these with `unsentPaths` left out.
58
68
  */
59
69
  export function laneRoots(siteDir) {
60
- const records = rootsOf(siteDir).find((r) => r.kind === 'records').path
70
+ const roots = rootsOf(siteDir)
71
+ const records = roots.find((r) => r.kind === 'records').path
72
+ const translations = roots.find((r) => r.kind === 'translations').path
61
73
  return {
62
74
  content: siteRoots(siteDir).filter((r) => r !== records),
63
- records: [records, 'locales/records'],
75
+ records: [records, `${translations}/records`],
64
76
  }
65
77
  }
66
78
 
79
+ /**
80
+ * The files under the site's roots that a push never sends — its translation tools' own, such as the
81
+ * list `i18n extract` refreshes (`unsentTranslationFiles`, `@uniweb/build`) — as paths from the site,
82
+ * `*` for one directory. Left out wherever a copy is compared with what the backend holds: the base a
83
+ * pull merges from, what `uniweb status` says waits to be pushed, and what a pull says it kept.
84
+ *
85
+ * ⛔ Until 2026-11-13 they counted. A teammate's commit that only refreshed
86
+ * `locales/records/manifest.json` read as a records change, so the next pull merged from an older sync
87
+ * point than the one the backend named, and their own published work came back as the app's: three
88
+ * conflicts and a section twice (measured on a site's pull, 2026-11-12).
89
+ *
90
+ * @param {string} siteDir
91
+ * @returns {string[]}
92
+ */
93
+ export function unsentPaths(siteDir) {
94
+ return rootsOf(siteDir).flatMap((r) => r.unsent || [])
95
+ }
96
+
67
97
  /**
68
98
  * ⭐ HOW FAR ABOVE ITS REPOSITORY THE SITE REACHES: the most directories above the repository's top
69
99
  * that one of the site's relative paths climbs, `site.yml`'s `paths:` and its `file:` and `link:`
@@ -365,7 +365,8 @@ export function newestBase(repo, candidates) {
365
365
  * second-guessed here.
366
366
  *
367
367
  * ⛔ ONE MERGE TAKES ONE BASE FOR EVERY LANE, and what the backend names is exact for its own
368
- * lane only. A commit one lane names that is newer than another lane's, with that lane's files
368
+ * lane only. Lanes are compared by what a push sends: `unsent` (`utils/site-roots.js::unsentPaths`)
369
+ * names the files it never does, a translation tool's list among them. A commit one lane names that is newer than another lane's, with that lane's files
369
370
  * different, would read what that lane lacks — a push of it the backend refused while it took the
370
371
  * other — as the backend's removal, and the merge would drop it. So it is not a base. A lane is
371
372
  * held to the commit it names, read through the commit its push made of what it wrote back
@@ -377,7 +378,7 @@ export function newestBase(repo, candidates) {
377
378
  * it, and each was dropped: a pull merged from the site's first push, measured by flows against a
378
379
  * real backend — a reverted change came back (A18), a re-wrap and six pushed edits conflicted.
379
380
  */
380
- export function baseFor(repo, { known = [], lanes = [], origin, siteUuid }) {
381
+ export function baseFor(repo, { known = [], lanes = [], origin, siteUuid, unsent = [] }) {
381
382
  const held = (s) => Boolean(s) && canBeBase(repo, s)
382
383
  const fallback = newestBase(repo, known)
383
384
  const refs = lanes.map(({ source, roots }) => ({
@@ -386,7 +387,7 @@ export function baseFor(repo, { known = [], lanes = [], origin, siteUuid }) {
386
387
  }))
387
388
  const named = lanes.flatMap(({ source }) => (held(source) ? [source, recordedAfter(repo, source, { origin, siteUuid })] : []))
388
389
  const taken = named.filter(Boolean).filter((s) =>
389
- refs.every(({ ref, roots }) => Boolean(ref) && (s === ref || isAncestor(repo, s, ref) || !differsIn(repo, ref, s, roots)))
390
+ refs.every(({ ref, roots }) => Boolean(ref) && (s === ref || isAncestor(repo, s, ref) || !differsIn(repo, ref, s, roots, unsent)))
390
391
  )
391
392
  return newestBase(repo, [...known, ...taken])
392
393
  }
@@ -410,10 +411,18 @@ export function recordedAfter(repo, sha, { origin, siteUuid }) {
410
411
  return null
411
412
  }
412
413
 
414
+ /**
415
+ * The pathspecs for the roots, from the repository's top, with the files a push never sends left out
416
+ * (`unsent`, paths from the site, `*` for one directory).
417
+ */
418
+ function pathspecs(repo, roots, unsent = []) {
419
+ return [...roots.map((r) => underTop(repo, r)), ...unsent.map((u) => `:(exclude,glob)${underTop(repo, u)}`)]
420
+ }
421
+
413
422
  /** Does the content under `roots` differ between two commits? Anything but "no" counts as yes. */
414
- function differsIn(repo, a, b, roots) {
423
+ function differsIn(repo, a, b, roots, unsent = []) {
415
424
  try {
416
- git(repo.top, ['diff', '--quiet', a, b, '--', ...roots.map((r) => underTop(repo, r))])
425
+ git(repo.top, ['diff', '--quiet', a, b, '--', ...pathspecs(repo, roots, unsent)])
417
426
  return false
418
427
  } catch {
419
428
  return true
@@ -1063,10 +1072,11 @@ export function fileAt(repo, rev, path) {
1063
1072
 
1064
1073
  /**
1065
1074
  * The files under the roots that differ from what `rev` holds there — changed, deleted, or
1066
- * new and not ignored — relative to the site, one outside it (a mounted folder's) included.
1075
+ * new and not ignored — relative to the site, one outside it (a mounted folder's) included. `unsent`:
1076
+ * files a push never sends (`unsentPaths`), which no backend can lack.
1067
1077
  */
1068
- export function filesDifferFrom(repo, rev, roots) {
1069
- const full = roots.map((r) => underTop(repo, r))
1078
+ export function filesDifferFrom(repo, rev, roots, unsent = []) {
1079
+ const full = pathspecs(repo, roots, unsent)
1070
1080
  try {
1071
1081
  const changed = zlist(git(repo.top, ['diff', '--name-only', '-z', '--no-renames', rev, '--', ...full]))
1072
1082
  const added = zlist(git(repo.top, ['ls-files', '--others', '--exclude-standard', '-z', '--', ...full]))