@ponderdev/justfits 1.3.0 → 1.4.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/README.md +46 -10
- package/agents/skills/justfits/SKILL.md +12 -10
- package/package.json +2 -2
- package/src/cli.cjs +42 -20
- package/src/engine.cjs +79 -12
- package/src/kit/desktop.cjs +136 -0
- package/src/kit/family.cjs +29 -0
- package/src/kit/lang.cjs +166 -0
- package/src/kit/scan.cjs +2 -2
- package/src/kit/window.cjs +22 -2
- package/src/main.cjs +49 -14
- package/src/plan.js +128 -29
- package/src/preload.cjs +11 -0
- package/src/renderer/app.js +332 -117
- package/src/renderer/index.html +11 -4
- package/src/renderer/kit/kit.css +16 -3
- package/src/renderer/kit/kit.js +351 -34
- package/src/renderer/licenses.html +1 -1
- package/src/renderer/strings.js +1562 -0
- package/src/scan.cjs +39 -2
package/src/renderer/app.js
CHANGED
|
@@ -2,12 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
/* The window. Holds no logic worth testing: the decisions live in plan.js.
|
|
4
4
|
The start screen, the file row, the run part and the footer come from the
|
|
5
|
-
kit (kit/kit.js); this file fills them with Just Fits' own words.
|
|
5
|
+
kit (kit/kit.js); this file fills them with Just Fits' own words.
|
|
6
|
+
|
|
7
|
+
Every word it shows goes through the kit's language (Kit.t and Kit.tn, the
|
|
8
|
+
English sentence as the key), and what it hands the kit's parts is already
|
|
9
|
+
translated: the kit does not translate what it is given. What main sends
|
|
10
|
+
(the targets, a probe's reason, the progress stage, a length note) comes
|
|
11
|
+
translated from main, which has the same language. ffmpeg's own lines are
|
|
12
|
+
shown as ffmpeg wrote them. Sizes (10 MB, 1.5 GB), a frame size (1280x720)
|
|
13
|
+
and a frame rate (30fps) are left as they are. */
|
|
6
14
|
|
|
7
15
|
const MB = 1000 * 1000;
|
|
8
16
|
|
|
9
17
|
const el = (id) => document.getElementById(id);
|
|
10
18
|
|
|
19
|
+
// The language first, before anything shows a word: main is told it, so what
|
|
20
|
+
// it sends the window is in it too.
|
|
21
|
+
Kit.languages({ tell: window.fits.language, mistake: window.fits.translationMistake, busy: () => busy, reload: window.fits.reloadWindow, keep: () => keepForSwitch() });
|
|
22
|
+
const { t, tn } = Kit;
|
|
23
|
+
|
|
24
|
+
// A whole percent, written the way the window's language writes one ("50 %"
|
|
25
|
+
// in French, "50%" in English).
|
|
26
|
+
const percent = (fraction) => Kit.num(Math.round(fraction * 100) / 100, { style: 'percent' });
|
|
27
|
+
|
|
11
28
|
// The strip at the top is room for the Mac's traffic lights, which sit over the
|
|
12
29
|
// page. Windows and Linux have a native title bar of their own, so there it
|
|
13
30
|
// would only be an empty band under it.
|
|
@@ -20,7 +37,13 @@ let runNo = 0; // each press of Compress on a batch, so main picks a fo
|
|
|
20
37
|
|
|
21
38
|
// A folder's results go into a new folder beside it ("Holiday (fitted)")
|
|
22
39
|
// unless Save next to the originals instead is ticked (decided 2026-11-20).
|
|
23
|
-
const settings = Kit.store('justfits', { beside: false });
|
|
40
|
+
const settings = Kit.store('justfits', { beside: false, carry: {} });
|
|
41
|
+
|
|
42
|
+
// What is on screen, as plain data: the paths that came in, the last result
|
|
43
|
+
// card drawn (shown), and the paths as they were taken (taken). Kept across a
|
|
44
|
+
// language switch (see the end of this file), where the page is rebuilt.
|
|
45
|
+
let taken = null;
|
|
46
|
+
let shown = null;
|
|
24
47
|
|
|
25
48
|
function human(bytes) {
|
|
26
49
|
if (bytes >= 1000 * MB) return trim(bytes / 1000 / MB) + ' GB';
|
|
@@ -56,13 +79,13 @@ async function chooseFolder() {
|
|
|
56
79
|
const start = Kit.start(el('start'), {
|
|
57
80
|
name: 'Just Fits',
|
|
58
81
|
version: window.fits.version,
|
|
59
|
-
line: 'Makes a file small enough to send.',
|
|
82
|
+
line: t('Makes a file small enough to send.'),
|
|
60
83
|
icon: 'video',
|
|
61
|
-
say: 'Drop videos, pictures or a folder here',
|
|
62
|
-
choose: 'Choose a file',
|
|
63
|
-
takes: 'A video or
|
|
84
|
+
say: t('Drop videos, pictures, sound or a folder here'),
|
|
85
|
+
choose: t('Choose a file'),
|
|
86
|
+
takes: t('A video, picture or sound file, or several, or a folder of them'),
|
|
64
87
|
onChoose: choose,
|
|
65
|
-
also: window.fits.folderButton ? { label: 'Choose a folder', onClick: chooseFolder, change: 'Change folder' } : null,
|
|
88
|
+
also: window.fits.folderButton ? { label: t('Choose a folder'), onClick: chooseFolder, change: t('Change folder') } : null,
|
|
66
89
|
// Copy skill puts the app's own SKILL.md on the clipboard; What's this?
|
|
67
90
|
// says what a skill is, with How it works opening the page through main.
|
|
68
91
|
skill: {
|
|
@@ -89,7 +112,7 @@ run.buttons.again.id = 'again';
|
|
|
89
112
|
run.buttons.retry.id = 'retry';
|
|
90
113
|
|
|
91
114
|
const veil = Kit.veil({
|
|
92
|
-
say: 'Drop videos, pictures or a folder',
|
|
115
|
+
say: t('Drop videos, pictures, sound or a folder'),
|
|
93
116
|
icon: 'video',
|
|
94
117
|
// While a file is being fitted a drop is refused: no veil, and the pointer
|
|
95
118
|
// shows it will not be taken, rather than a drop that does nothing.
|
|
@@ -108,16 +131,22 @@ Kit.footer(el('footer'), {
|
|
|
108
131
|
onLicences: () => window.fits.openLicences(),
|
|
109
132
|
});
|
|
110
133
|
|
|
134
|
+
// A sibling tool for what Just Fits does not do: Just Zip for files
|
|
135
|
+
// it cannot shrink, Just JPEG for a HEIC picture. One line, never in the way.
|
|
136
|
+
const familyHint = Kit.hint(el('family-hint'), { open: (id) => window.fits.openSibling(id) });
|
|
137
|
+
const MEDIA = ['video', 'picture', 'heic', 'audio'];
|
|
138
|
+
const notMedia = (name) => !MEDIA.includes(Kit.kindOf(name));
|
|
139
|
+
|
|
111
140
|
const runState = () => el('run').dataset.state;
|
|
112
141
|
|
|
113
142
|
// The estimate above the main button is for before a run; once the button is
|
|
114
143
|
// pressed the run part says what is happening instead.
|
|
115
144
|
function note() {
|
|
116
|
-
el('aim').textContent = runState() === 'idle' ?
|
|
145
|
+
el('aim').textContent = runState() === 'idle' ? t('Aiming for {size}', { size: human(targetBytes) }) : '';
|
|
117
146
|
}
|
|
118
147
|
|
|
119
148
|
function veilSay() {
|
|
120
|
-
veil.say(batch ? 'Drop to use these instead' : chosen ? 'Drop to use this file instead' : 'Drop videos, pictures or a folder');
|
|
149
|
+
veil.say(batch ? t('Drop to use these instead') : chosen ? t('Drop to use this file instead') : t('Drop videos, pictures, sound or a folder'));
|
|
121
150
|
}
|
|
122
151
|
|
|
123
152
|
/* --- target picking ----------------------------------------------------- */
|
|
@@ -127,18 +156,22 @@ let TARGETS = [];
|
|
|
127
156
|
async function drawTargets() {
|
|
128
157
|
TARGETS = await window.fits.targets();
|
|
129
158
|
const select = el('target');
|
|
130
|
-
|
|
159
|
+
// Built as elements rather than HTML: the labels come in the window's
|
|
160
|
+
// language, and a translation may hold a character HTML would read.
|
|
161
|
+
select.replaceChildren();
|
|
131
162
|
let group = null;
|
|
132
|
-
for (const
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
group =
|
|
136
|
-
|
|
163
|
+
for (const target of TARGETS) {
|
|
164
|
+
if (!group || group.label !== target.group) {
|
|
165
|
+
group = document.createElement('optgroup');
|
|
166
|
+
group.label = target.group;
|
|
167
|
+
select.append(group);
|
|
137
168
|
}
|
|
138
|
-
const size =
|
|
139
|
-
|
|
169
|
+
const size = target.bytes >= 1000 * MB ? `${target.bytes / 1000 / MB}GB` : `${Math.round(target.bytes / MB)}MB`;
|
|
170
|
+
const option = document.createElement('option');
|
|
171
|
+
option.value = target.id;
|
|
172
|
+
option.textContent = `${target.label} \u00b7 ${size}`;
|
|
173
|
+
group.append(option);
|
|
140
174
|
}
|
|
141
|
-
select.innerHTML = html + '</optgroup>';
|
|
142
175
|
select.value = TARGETS[0].id;
|
|
143
176
|
useTarget(TARGETS[0]);
|
|
144
177
|
}
|
|
@@ -149,18 +182,18 @@ function dropDone() {
|
|
|
149
182
|
if (!busy && (runState() === 'done' || runState() === 'failed')) run.reset();
|
|
150
183
|
}
|
|
151
184
|
|
|
152
|
-
function useTarget(
|
|
185
|
+
function useTarget(target) {
|
|
153
186
|
dropDone();
|
|
154
|
-
targetBytes =
|
|
155
|
-
el('why').textContent =
|
|
187
|
+
targetBytes = target.bytes;
|
|
188
|
+
el('why').textContent = target.note || '';
|
|
156
189
|
note();
|
|
157
190
|
}
|
|
158
191
|
|
|
159
192
|
el('target').addEventListener('change', (e) => {
|
|
160
|
-
const
|
|
161
|
-
if (!
|
|
193
|
+
const target = TARGETS.find((x) => x.id === e.target.value);
|
|
194
|
+
if (!target || busy) return;
|
|
162
195
|
el('custom').value = '';
|
|
163
|
-
useTarget(
|
|
196
|
+
useTarget(target);
|
|
164
197
|
});
|
|
165
198
|
|
|
166
199
|
el('custom').addEventListener('input', (e) => {
|
|
@@ -168,8 +201,8 @@ el('custom').addEventListener('input', (e) => {
|
|
|
168
201
|
if (!(mb > 0)) {
|
|
169
202
|
// Cleared or nonsense: fall back to what the dropdown shows, rather than
|
|
170
203
|
// quietly keeping the last custom size while the dropdown says otherwise.
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
204
|
+
const target = TARGETS.find((x) => x.id === el('target').value);
|
|
205
|
+
if (target) useTarget(target);
|
|
173
206
|
return;
|
|
174
207
|
}
|
|
175
208
|
dropDone();
|
|
@@ -189,6 +222,7 @@ async function intake(paths) {
|
|
|
189
222
|
// says so in its own words.
|
|
190
223
|
if (!paths.length) return take('');
|
|
191
224
|
const g = await window.fits.gather(paths);
|
|
225
|
+
taken = paths;
|
|
192
226
|
if (g.single) return take(paths[0]);
|
|
193
227
|
return takeMany(paths, g);
|
|
194
228
|
}
|
|
@@ -196,6 +230,7 @@ async function intake(paths) {
|
|
|
196
230
|
async function take(filePath) {
|
|
197
231
|
if (busy) return;
|
|
198
232
|
start.error('');
|
|
233
|
+
familyHint.clear();
|
|
199
234
|
run.reset();
|
|
200
235
|
made = null;
|
|
201
236
|
batch = null;
|
|
@@ -205,29 +240,37 @@ async function take(filePath) {
|
|
|
205
240
|
// file on disk) would otherwise surface ffprobe's ": No such file" with no name.
|
|
206
241
|
const r = filePath
|
|
207
242
|
? await window.fits.probe(filePath)
|
|
208
|
-
: { ok: false, message: 'Could not tell where that file is. Try "Choose a file" instead.' };
|
|
243
|
+
: { ok: false, message: t('Could not tell where that file is. Try "Choose a file" instead.') };
|
|
209
244
|
if (!r.ok) {
|
|
210
245
|
chosen = null;
|
|
246
|
+
taken = null;
|
|
211
247
|
// Back to the start, so the previous file's name is not left beside an
|
|
212
248
|
// error about another; the reason goes under the drop zone.
|
|
213
249
|
start.reset();
|
|
214
250
|
note();
|
|
215
251
|
veilSay();
|
|
216
252
|
start.error(r.message);
|
|
253
|
+
// Read but not a video or picture (a PDF, a document, anything else): Just
|
|
254
|
+
// Zip sends it as it is. Not for a file that is gone or cannot be opened.
|
|
255
|
+
if (r.code === 'unreadable' && notMedia(filePath)) {
|
|
256
|
+
familyHint.show('justzip', t('Just Fits shrinks videos, pictures and sound. To send this as it is, Just Zip packs it into one file.'));
|
|
257
|
+
}
|
|
217
258
|
el('start').scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
218
259
|
return;
|
|
219
260
|
}
|
|
220
261
|
|
|
221
262
|
chosen = { path: filePath, info: r.info };
|
|
263
|
+
// A HEIC fits like any picture; this only says Just JPEG is there for one.
|
|
264
|
+
if (Kit.kindOf(filePath) === 'heic') familyHint.show('justjpeg', t('Need it as a JPEG instead?'));
|
|
222
265
|
start.landed({
|
|
223
266
|
name: filePath.split(/[\\/]/).pop(),
|
|
224
|
-
icon: r.info.kind === 'image' ? 'photo' : 'video',
|
|
267
|
+
icon: r.info.kind === 'image' ? 'photo' : r.info.kind === 'audio' ? 'audio' : 'video',
|
|
225
268
|
facts: [
|
|
226
269
|
human(r.info.bytes),
|
|
227
270
|
r.info.width && `${r.info.width}x${r.info.height}`,
|
|
228
|
-
r.info.kind === 'video' && r.info.durationSec && clock(r.info.durationSec),
|
|
271
|
+
(r.info.kind === 'video' || r.info.kind === 'audio') && r.info.durationSec && clock(r.info.durationSec),
|
|
229
272
|
r.info.kind === 'video' && `${Math.round(r.info.fps)}fps`,
|
|
230
|
-
r.info.kind === 'video' && (r.info.hasAudio ? 'with sound' : 'silent'),
|
|
273
|
+
r.info.kind === 'video' && (r.info.hasAudio ? t('with sound') : t('silent')),
|
|
231
274
|
].filter(Boolean).join(' · '),
|
|
232
275
|
});
|
|
233
276
|
el('go').disabled = false;
|
|
@@ -240,40 +283,54 @@ async function take(filePath) {
|
|
|
240
283
|
async function takeMany(paths, g) {
|
|
241
284
|
if (busy) return;
|
|
242
285
|
start.error('');
|
|
286
|
+
familyHint.clear();
|
|
243
287
|
run.reset();
|
|
244
288
|
made = null;
|
|
245
289
|
chosen = null;
|
|
246
290
|
batch = null;
|
|
247
291
|
whereField(null);
|
|
248
|
-
const label = paths.length === 1 && g.folders === 1 ? paths[0].replace(/[\\/]+$/, '').split(/[\\/]/).pop() :
|
|
292
|
+
const label = paths.length === 1 && g.folders === 1 ? paths[0].replace(/[\\/]+$/, '').split(/[\\/]/).pop() : tn(g.files.length, '{n} file', '{n} files');
|
|
293
|
+
// Some of them are not videos or pictures (in a folder, or named): the media
|
|
294
|
+
// ones are fitted as ever, and Just Zip sends the lot as one file.
|
|
295
|
+
const zipHint = () => familyHint.show('justzip', t('To send them as one file, try Just Zip.'));
|
|
249
296
|
if (!g.files.length) {
|
|
297
|
+
taken = null;
|
|
250
298
|
start.reset();
|
|
251
299
|
note();
|
|
252
300
|
veilSay();
|
|
253
|
-
start.error(g.missing.length
|
|
301
|
+
start.error(g.missing.length
|
|
302
|
+
? t('Could not find {name}. It may have been moved or deleted.', { name: g.missing[0].split(/[\\/]/).pop() })
|
|
303
|
+
: t('There are no videos or pictures in {name}.', { name: label }));
|
|
304
|
+
if (g.others) zipHint();
|
|
254
305
|
return;
|
|
255
306
|
}
|
|
256
307
|
|
|
257
308
|
// A few at a time: a folder of hundreds should not wait on each in turn.
|
|
258
|
-
const items = g.files.map((f) => ({ path: f.path, name: f.name, bytes: f.bytes, from: f.from, info: null, message: '' }));
|
|
309
|
+
const items = g.files.map((f) => ({ path: f.path, name: f.name, bytes: f.bytes, from: f.from, info: null, message: '', code: '' }));
|
|
259
310
|
for (let i = 0; i < items.length; i += 4) {
|
|
260
311
|
await Promise.all(items.slice(i, i + 4).map(async (it) => {
|
|
261
312
|
const r = await window.fits.probe(it.path);
|
|
262
|
-
if (r.ok) it.info = r.info; else it.message = r.message;
|
|
313
|
+
if (r.ok) it.info = r.info; else { it.message = r.message; it.code = r.code || ''; }
|
|
263
314
|
}));
|
|
264
315
|
}
|
|
265
316
|
if (busy) return;
|
|
266
317
|
|
|
267
318
|
const videos = items.filter((it) => it.info && it.info.kind === 'video').length;
|
|
268
319
|
const pictures = items.filter((it) => it.info && it.info.kind === 'image').length;
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const kinds = [
|
|
320
|
+
const sounds = items.filter((it) => it.info && it.info.kind === 'audio').length;
|
|
321
|
+
const unreadable = items.length - videos - pictures - sounds;
|
|
322
|
+
const kinds = [
|
|
323
|
+
videos && tn(videos, '{n} video', '{n} videos'),
|
|
324
|
+
pictures && tn(pictures, '{n} picture', '{n} pictures'),
|
|
325
|
+
sounds && tn(sounds, '{n} sound file', '{n} sound files'),
|
|
326
|
+
unreadable && tn(unreadable, '{n} it cannot read', '{n} it cannot read'),
|
|
327
|
+
].filter(Boolean);
|
|
272
328
|
batch = { label, items };
|
|
329
|
+
if (g.others || items.some((it) => notMedia(it.name))) zipHint();
|
|
273
330
|
whereField(items.find((it) => it.from));
|
|
274
331
|
start.landed({
|
|
275
332
|
name: label,
|
|
276
|
-
icon: g.folders ? 'folder' : videos ? 'video' : 'photos',
|
|
333
|
+
icon: g.folders ? 'folder' : videos ? 'video' : sounds && !pictures ? 'audio' : 'photos',
|
|
277
334
|
facts: `${kinds.join(', ')} · ${human(items.reduce((n, it) => n + it.bytes, 0))}`,
|
|
278
335
|
});
|
|
279
336
|
el('go').disabled = false;
|
|
@@ -289,8 +346,9 @@ function whereField(fromFolder) {
|
|
|
289
346
|
const name = fromFolder.from.replace(/[\\/]+$/, '').split(/[\\/]/).pop();
|
|
290
347
|
el('beside').checked = settings.get('beside');
|
|
291
348
|
el('where-hint').textContent = el('beside').checked
|
|
292
|
-
? 'Each one is saved beside its original, as name-fits.'
|
|
293
|
-
|
|
349
|
+
? t('Each one is saved beside its original, as name-fits.')
|
|
350
|
+
// The results folder's real name on disk, which is always "(fitted)".
|
|
351
|
+
: t('Otherwise they go in a new folder beside it, {folder}, and the folder itself is left as it is.', { folder: `${name} (fitted)` });
|
|
294
352
|
}
|
|
295
353
|
el('beside').addEventListener('change', () => {
|
|
296
354
|
settings.set('beside', el('beside').checked);
|
|
@@ -300,8 +358,10 @@ el('beside').addEventListener('change', () => {
|
|
|
300
358
|
// Start again: back to the drop zone, with the target left as it was.
|
|
301
359
|
function again() {
|
|
302
360
|
if (busy) return;
|
|
361
|
+
familyHint.clear();
|
|
303
362
|
chosen = null;
|
|
304
363
|
batch = null;
|
|
364
|
+
taken = null;
|
|
305
365
|
whereField(null);
|
|
306
366
|
made = null;
|
|
307
367
|
start.error('');
|
|
@@ -329,7 +389,7 @@ function whereText(file) {
|
|
|
329
389
|
const name = file.slice(cut + 1);
|
|
330
390
|
// A file at the top of a drive or the root keeps its separator: C:\ and /.
|
|
331
391
|
const folder = cut > 0 && !/:$/.test(file.slice(0, cut)) ? file.slice(0, cut) : file.slice(0, cut + 1);
|
|
332
|
-
return folder ?
|
|
392
|
+
return folder ? t('Saved as {name}, next to the original in {folder}', { name, folder }) : t('Saved as {name}', { name });
|
|
333
393
|
}
|
|
334
394
|
|
|
335
395
|
// The time left, from how fast this attempt has gone so far. Each attempt
|
|
@@ -341,21 +401,25 @@ function timeLeft(p) {
|
|
|
341
401
|
const done = p.progress - pace.from;
|
|
342
402
|
const spent = (now - pace.at) / 1000;
|
|
343
403
|
if (spent < 2 || done < 0.02) return '';
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
404
|
+
return aboutLeft(spent / done * (1 - p.progress));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// "About 9 seconds left", whole, in the window's language.
|
|
408
|
+
function aboutLeft(seconds) {
|
|
409
|
+
const s = Math.max(1, Math.round(seconds));
|
|
410
|
+
if (s < 60) return tn(s, 'About {n} second left', 'About {n} seconds left');
|
|
411
|
+
return tn(Math.round(s / 60), 'About {n} minute left', 'About {n} minutes left');
|
|
348
412
|
}
|
|
349
413
|
|
|
350
414
|
window.fits.onProgress((p) => {
|
|
351
415
|
if (!busy) return;
|
|
352
416
|
if (batch) return manyProgress(p);
|
|
353
|
-
const pct = Math.round(p.progress * 100);
|
|
354
417
|
run.working({
|
|
355
|
-
|
|
418
|
+
// The stage comes from main in the window's language.
|
|
419
|
+
what: p.attempt > 0 ? t('{stage}, attempt {n}, aiming lower', { stage: p.stage, n: p.attempt + 1 }) : p.stage,
|
|
356
420
|
// Until ffmpeg says how far it is (a slow machine's first pass can take
|
|
357
421
|
// a while to say anything, and a picture says nothing), the bar sweeps.
|
|
358
|
-
count: p.progress > 0 ?
|
|
422
|
+
count: p.progress > 0 ? percent(p.progress) : '',
|
|
359
423
|
fraction: p.progress,
|
|
360
424
|
unknown: !(p.progress > 0),
|
|
361
425
|
file: chosen ? chosen.path.split(/[\\/]/).pop() : '',
|
|
@@ -365,7 +429,7 @@ window.fits.onProgress((p) => {
|
|
|
365
429
|
|
|
366
430
|
function finished({ title, detail = '', where = '', file = null, folder = false, over = false }) {
|
|
367
431
|
made = file;
|
|
368
|
-
run.done({ title, detail, where, reveal: Boolean(file), revealLabel: folder ? 'Show me the folder' : 'Show me the file', tone: over ? 'over' : '' });
|
|
432
|
+
run.done({ title, detail, where, reveal: Boolean(file), revealLabel: folder ? t('Show me the folder') : t('Show me the file'), tone: over ? 'over' : '' });
|
|
369
433
|
note();
|
|
370
434
|
inView();
|
|
371
435
|
}
|
|
@@ -374,10 +438,7 @@ async function compress() {
|
|
|
374
438
|
if (!chosen || busy) return;
|
|
375
439
|
|
|
376
440
|
if (chosen.info.bytes <= targetBytes) {
|
|
377
|
-
|
|
378
|
-
title: 'That already fits.',
|
|
379
|
-
detail: `${human(chosen.info.bytes)}, under the ${human(targetBytes)} limit. Nothing to do.`,
|
|
380
|
-
});
|
|
441
|
+
showSingle({ k: 'fits', size: chosen.info.bytes, limit: targetBytes });
|
|
381
442
|
return;
|
|
382
443
|
}
|
|
383
444
|
|
|
@@ -385,7 +446,7 @@ async function compress() {
|
|
|
385
446
|
pace = null;
|
|
386
447
|
el('go').disabled = true;
|
|
387
448
|
veilSay();
|
|
388
|
-
run.working({ what: 'Working', unknown: true, file: chosen.path.split(/[\\/]/).pop() });
|
|
449
|
+
run.working({ what: t('Working'), unknown: true, file: chosen.path.split(/[\\/]/).pop() });
|
|
389
450
|
note();
|
|
390
451
|
inView();
|
|
391
452
|
|
|
@@ -396,37 +457,66 @@ async function compress() {
|
|
|
396
457
|
veilSay();
|
|
397
458
|
|
|
398
459
|
if (!r.ok) {
|
|
399
|
-
if (!r.cancelled) {
|
|
400
|
-
run.failed(r.message);
|
|
401
|
-
note();
|
|
402
|
-
inView();
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
460
|
// Cancelled: say so, or the window just goes back to how it was.
|
|
406
|
-
|
|
461
|
+
showSingle(r.cancelled ? { k: 'stopped' } : { k: 'failed', message: r.message });
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
showSingle({
|
|
466
|
+
k: 'done',
|
|
467
|
+
before: r.before, bytes: r.bytes, over: Boolean(r.over), kind: r.kind, path: r.path, attempts: r.attempts, note: r.note || '', duration: r.durationSec || 0,
|
|
468
|
+
plan: r.plan ? { width: r.plan.width, height: r.plan.height, fps: r.plan.fps, videoKbps: r.plan.videoKbps, audioKbps: r.plan.audioKbps } : null,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// A single file's result card, drawn from plain data so it can be drawn again
|
|
473
|
+
// in another language after a switch (what main said in its own words, the
|
|
474
|
+
// length note and a failure's message, stays as it was).
|
|
475
|
+
function showSingle(res) {
|
|
476
|
+
shown = { single: res };
|
|
477
|
+
if (res.k === 'fits') {
|
|
478
|
+
finished({
|
|
479
|
+
title: t('That already fits.'),
|
|
480
|
+
detail: t('{size}, under the {limit} limit. Nothing to do.', { size: human(res.size), limit: human(res.limit) }),
|
|
481
|
+
});
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (res.k === 'failed') {
|
|
485
|
+
run.failed(res.message);
|
|
486
|
+
note();
|
|
487
|
+
inView();
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (res.k === 'stopped') {
|
|
491
|
+
finished({ title: t('Stopped.'), detail: t('Nothing was saved, and the original is untouched.') });
|
|
407
492
|
return;
|
|
408
493
|
}
|
|
409
494
|
|
|
410
|
-
const saved = Math.round((1 -
|
|
411
|
-
const title =
|
|
412
|
-
?
|
|
413
|
-
:
|
|
495
|
+
const saved = Math.round((1 - res.bytes / res.before) * 100);
|
|
496
|
+
const title = res.over
|
|
497
|
+
? t('Got it to {size}, still over the line.', { size: human(res.bytes) })
|
|
498
|
+
: t('Done. {before} to {after}, {percent}% smaller.', { before: human(res.before), after: human(res.bytes), percent: saved });
|
|
414
499
|
|
|
415
500
|
const bits = [];
|
|
416
|
-
if (
|
|
417
|
-
bits.push(`${
|
|
418
|
-
bits.push(`${Math.round(
|
|
419
|
-
bits.push(
|
|
420
|
-
if (
|
|
501
|
+
if (res.plan && res.kind === 'video') {
|
|
502
|
+
bits.push(`${res.plan.width}x${res.plan.height}`);
|
|
503
|
+
bits.push(`${Math.round(res.plan.fps)}fps`);
|
|
504
|
+
bits.push(t('{kbps}k video', { kbps: res.plan.videoKbps }));
|
|
505
|
+
if (res.plan.audioKbps) bits.push(t('{kbps}k audio', { kbps: res.plan.audioKbps }));
|
|
421
506
|
}
|
|
422
|
-
|
|
507
|
+
// Sound has no frame to describe: how long it is and what it was made at.
|
|
508
|
+
if (res.plan && res.kind === 'audio') {
|
|
509
|
+
if (res.duration) bits.push(clock(res.duration));
|
|
510
|
+
if (res.plan.audioKbps) bits.push(t('{kbps}k audio', { kbps: res.plan.audioKbps }));
|
|
511
|
+
}
|
|
512
|
+
if (res.attempts > 1) bits.push(tn(res.attempts, '{n} attempt', '{n} attempts'));
|
|
423
513
|
// The plan knew when the target was too small for the length; say it here
|
|
424
514
|
// too, so a soft picture is explained rather than a surprise. The sentence
|
|
425
515
|
// is the command line's, from plan.lengthNote through main.
|
|
426
|
-
const rough =
|
|
516
|
+
const rough = res.note || '';
|
|
427
517
|
|
|
428
518
|
// the facts stay a facts line; the plain-words warning leads the line under it
|
|
429
|
-
finished({ title, detail: bits.join(' · '), where: (rough ? rough + ' ' : '') + whereText(
|
|
519
|
+
finished({ title, detail: bits.join(' · '), where: (rough ? rough + ' ' : '') + whereText(res.path), file: res.path, over: res.over });
|
|
430
520
|
}
|
|
431
521
|
|
|
432
522
|
/* --- several files ------------------------------------------------------ */
|
|
@@ -445,8 +535,20 @@ function cancel() {
|
|
|
445
535
|
|
|
446
536
|
let manyAt = null; // where a batch run is: which file, since when
|
|
447
537
|
|
|
538
|
+
// What the queue says beside a file, from what happened to it, so it can be
|
|
539
|
+
// said again in another language after a switch.
|
|
540
|
+
function noteOf(it) {
|
|
541
|
+
if (it.mark === 'part') return t('Stopped part way, nothing kept');
|
|
542
|
+
if (it.mark === 'unstarted') return t('Not started');
|
|
543
|
+
if (it.result === 'failed') return shortReason(it.message, it.code);
|
|
544
|
+
if (it.result === 'skipped') return it.copied ? t('Already small enough, copied in') : t('Already small enough');
|
|
545
|
+
if (it.result === 'over') return t('Could not get under {limit}, got to {size}', { limit: human(it.limit), size: human(it.after) });
|
|
546
|
+
if (it.result === 'fitted') return t('{before} to {after}', { before: human(it.before), after: human(it.after) });
|
|
547
|
+
return '';
|
|
548
|
+
}
|
|
549
|
+
|
|
448
550
|
function rows() {
|
|
449
|
-
return batch.items.map((it) => ({ name: it.name, state: it.state || 'waiting', note: it
|
|
551
|
+
return batch.items.map((it) => ({ name: it.name, state: it.state || 'waiting', note: noteOf(it) }));
|
|
450
552
|
}
|
|
451
553
|
|
|
452
554
|
// The queue shows every file, so the one being fitted is kept in sight in it.
|
|
@@ -457,13 +559,6 @@ function showQueue() {
|
|
|
457
559
|
if (now) box.scrollTop = Math.max(0, now.offsetTop - box.clientHeight / 2);
|
|
458
560
|
}
|
|
459
561
|
|
|
460
|
-
function inWords(seconds) {
|
|
461
|
-
const s = Math.max(1, Math.round(seconds));
|
|
462
|
-
if (s < 60) return `${s} second${s === 1 ? '' : 's'}`;
|
|
463
|
-
const m = Math.round(s / 60);
|
|
464
|
-
return `${m} minute${m === 1 ? '' : 's'}`;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
562
|
function manyProgress(p) {
|
|
468
563
|
if (!manyAt) return;
|
|
469
564
|
manyAt.last = p;
|
|
@@ -475,11 +570,13 @@ function manyProgress(p) {
|
|
|
475
570
|
const before = items.slice(0, manyAt.index).reduce((t, it) => t + it.bytes, 0);
|
|
476
571
|
const overall = Math.min(1, (before + items[manyAt.index].bytes * (p ? p.progress : 0)) / total);
|
|
477
572
|
const spent = (Date.now() - manyAt.started) / 1000;
|
|
478
|
-
const left = spent > 3 && overall > 0.02 ?
|
|
479
|
-
const
|
|
573
|
+
const left = spent > 3 && overall > 0.02 ? aboutLeft(spent / overall * (1 - overall)) : '';
|
|
574
|
+
const at = { at: manyAt.index + 1, total: n };
|
|
480
575
|
run.working({
|
|
481
|
-
what: stopping ? 'Stopping'
|
|
482
|
-
|
|
576
|
+
what: stopping ? t('Stopping')
|
|
577
|
+
: p && p.attempt > 0 ? t('Fitting {at} of {total}, attempt {n}', { ...at, n: p.attempt + 1 })
|
|
578
|
+
: t('Fitting {at} of {total}', at),
|
|
579
|
+
count: overall > 0 ? percent(overall) : '',
|
|
483
580
|
fraction: overall,
|
|
484
581
|
unknown: !(overall > 0),
|
|
485
582
|
file: batch.items[manyAt.index].name,
|
|
@@ -488,17 +585,18 @@ function manyProgress(p) {
|
|
|
488
585
|
}
|
|
489
586
|
|
|
490
587
|
// A short reason for the queue; the whole sentence is in the probe's message.
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
if (
|
|
494
|
-
if (
|
|
495
|
-
|
|
588
|
+
// Told by the probe's code, not its words, which are in the window's language.
|
|
589
|
+
function shortReason(message, code) {
|
|
590
|
+
if (code === 'unreadable') return t('Not a video, picture or sound file Just Fits can read');
|
|
591
|
+
if (code === 'animated-webp') return t('An animated WebP, which it cannot shrink');
|
|
592
|
+
if (code === 'missing') return t('It was moved or deleted');
|
|
593
|
+
return String(message || t('Failed')).split('\n')[0];
|
|
496
594
|
}
|
|
497
595
|
|
|
498
596
|
async function compressMany() {
|
|
499
597
|
if (!batch || busy) return;
|
|
500
598
|
const items = batch.items;
|
|
501
|
-
for (const it of items) { it.state = 'waiting'; it.
|
|
599
|
+
for (const it of items) { it.state = 'waiting'; it.mark = ''; it.out = null; it.folder = null; it.copied = false; it.result = null; }
|
|
502
600
|
const run1 = ++runNo;
|
|
503
601
|
const beside = settings.get('beside');
|
|
504
602
|
|
|
@@ -527,28 +625,26 @@ async function compressMany() {
|
|
|
527
625
|
if (!it.info) {
|
|
528
626
|
it.result = 'failed';
|
|
529
627
|
it.state = 'failed';
|
|
530
|
-
it.note = shortReason(it.message);
|
|
531
628
|
} else if (it.info.bytes <= target && (beside || !it.from)) {
|
|
532
629
|
it.result = 'skipped';
|
|
533
630
|
it.state = 'done';
|
|
534
|
-
it.note = 'Already small enough';
|
|
535
631
|
} else {
|
|
536
632
|
const r = await window.fits.fit(it.path, target, { beside, run: run1 });
|
|
537
633
|
if (r.cancelled) {
|
|
538
634
|
// stopped part way: nothing of it was kept, and the queue says so
|
|
539
635
|
it.state = 'waiting';
|
|
540
|
-
it.
|
|
636
|
+
it.mark = 'part';
|
|
541
637
|
stoppedAt = i;
|
|
542
638
|
break;
|
|
543
639
|
} else if (!r.ok) {
|
|
544
640
|
it.result = 'failed';
|
|
545
641
|
it.state = 'failed';
|
|
546
|
-
it.
|
|
642
|
+
it.message = r.message || '';
|
|
643
|
+
it.code = r.code || '';
|
|
547
644
|
} else if (r.copied) {
|
|
548
645
|
// already small enough, copied into the results folder as it is
|
|
549
646
|
it.result = 'skipped';
|
|
550
647
|
it.state = 'done';
|
|
551
|
-
it.note = 'Already small enough, copied in';
|
|
552
648
|
it.out = r.path;
|
|
553
649
|
it.folder = r.folder;
|
|
554
650
|
it.copied = true;
|
|
@@ -561,11 +657,10 @@ async function compressMany() {
|
|
|
561
657
|
if (r.over) {
|
|
562
658
|
it.result = 'over';
|
|
563
659
|
it.state = 'failed';
|
|
564
|
-
it.
|
|
660
|
+
it.limit = target;
|
|
565
661
|
} else {
|
|
566
662
|
it.result = 'fitted';
|
|
567
663
|
it.state = 'done';
|
|
568
|
-
it.note = `${human(r.before)} to ${human(r.bytes)}`;
|
|
569
664
|
}
|
|
570
665
|
}
|
|
571
666
|
}
|
|
@@ -575,7 +670,15 @@ async function compressMany() {
|
|
|
575
670
|
busy = false;
|
|
576
671
|
el('go').disabled = false;
|
|
577
672
|
veilSay();
|
|
578
|
-
for (const it of items) if (it.state === 'waiting' && stoppedAt !== null && !it.
|
|
673
|
+
for (const it of items) if (it.state === 'waiting' && stoppedAt !== null && !it.mark) it.mark = 'unstarted';
|
|
674
|
+
showMany({ seconds, stoppedAt, target });
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// A batch's result card and queue, from what happened to each file, so they
|
|
678
|
+
// can be drawn again in another language after a switch.
|
|
679
|
+
function showMany({ seconds, stoppedAt, target }) {
|
|
680
|
+
const items = batch.items;
|
|
681
|
+
shown = { many: { seconds, stoppedAt, target } };
|
|
579
682
|
showQueue();
|
|
580
683
|
|
|
581
684
|
const tally = (k) => items.filter((it) => it.result === k).length;
|
|
@@ -586,39 +689,51 @@ async function compressMany() {
|
|
|
586
689
|
const tried = fitted + skipped + over + failed;
|
|
587
690
|
|
|
588
691
|
if (stoppedAt === null && failed === items.length) {
|
|
589
|
-
run.failed(
|
|
692
|
+
run.failed(tn(items.length, 'The file could not be fitted. The list says why.', 'None of the {n} files could be fitted. The list says why for each.'));
|
|
590
693
|
note();
|
|
591
694
|
inView();
|
|
592
695
|
return;
|
|
593
696
|
}
|
|
594
697
|
|
|
698
|
+
// Each count is a whole phrase of its own; the list of them goes into the
|
|
699
|
+
// title as one slot.
|
|
595
700
|
const parts = [];
|
|
596
|
-
if (fitted || (!skipped && !over && !failed)) parts.push(
|
|
597
|
-
if (skipped) parts.push(
|
|
598
|
-
if (over) parts.push(
|
|
599
|
-
if (failed) parts.push(
|
|
701
|
+
if (fitted || (!skipped && !over && !failed)) parts.push(tn(fitted, '{n} fitted', '{n} fitted'));
|
|
702
|
+
if (skipped) parts.push(tn(skipped, '{n} already small enough', '{n} already small enough'));
|
|
703
|
+
if (over) parts.push(tn(over, '{n} could not get under {limit}', '{n} could not get under {limit}', { limit: human(target) }));
|
|
704
|
+
if (failed) parts.push(tn(failed, '{n} could not be read or fitted', '{n} could not be read or fitted'));
|
|
705
|
+
const results = parts.join(', ');
|
|
600
706
|
let title;
|
|
601
|
-
if (stoppedAt !== null && !tried) title =
|
|
602
|
-
else if (stoppedAt !== null) title =
|
|
603
|
-
else if (skipped === items.length) title =
|
|
604
|
-
else title =
|
|
707
|
+
if (stoppedAt !== null && !tried) title = tn(items.length, 'Stopped. The file was not changed.', 'Stopped. None of the {n} files were changed.');
|
|
708
|
+
else if (stoppedAt !== null) title = t('Stopped after {done} of {total}. {results}.', { done: tried, total: items.length, results });
|
|
709
|
+
else if (skipped === items.length) title = tn(items.length, 'It already fits under {limit}.', 'All {n} already fit under {limit}.', { limit: human(target) });
|
|
710
|
+
else title = t('Done. {results}.', { results });
|
|
605
711
|
title = title.charAt(0).toUpperCase() + title.slice(1);
|
|
606
712
|
|
|
607
713
|
const changed = items.filter((it) => it.out && !it.copied);
|
|
608
714
|
const written = items.filter((it) => it.out);
|
|
609
715
|
const before = changed.reduce((n, it) => n + it.before, 0);
|
|
610
716
|
const after = changed.reduce((n, it) => n + it.after, 0);
|
|
611
|
-
const
|
|
717
|
+
const took = Math.max(1, Math.round(seconds));
|
|
718
|
+
const sizes = { before: human(before), after: human(after) };
|
|
719
|
+
const detail = !changed.length ? ''
|
|
720
|
+
: took < 60 ? tn(took, '{before} to {after} in {n} second', '{before} to {after} in {n} seconds', sizes)
|
|
721
|
+
: tn(Math.round(took / 60), '{before} to {after} in {n} minute', '{before} to {after} in {n} minutes', sizes);
|
|
612
722
|
const folders = [...new Set(written.map((it) => it.folder).filter(Boolean))];
|
|
613
723
|
const besideCount = written.filter((it) => !it.folder).length;
|
|
614
724
|
const nameOf = (p) => p.split(/[\\/]/).pop();
|
|
615
|
-
const files = (n) => `${n} ${n === 1 ? 'file' : 'files'}`;
|
|
616
725
|
let where = '';
|
|
617
|
-
if (folders.length === 1 && !besideCount) where =
|
|
618
|
-
else if (folders.length > 1 && !besideCount) where =
|
|
619
|
-
else if (folders.length)
|
|
620
|
-
|
|
621
|
-
|
|
726
|
+
if (folders.length === 1 && !besideCount) where = tn(written.length, 'Saved {n} file in {folder}', 'Saved {n} files in {folder}', { folder: nameOf(folders[0]) });
|
|
727
|
+
else if (folders.length > 1 && !besideCount) where = tn(written.length, 'Saved {n} file in {count} new folders beside the originals', 'Saved {n} files in {count} new folders beside the originals', { count: folders.length });
|
|
728
|
+
else if (folders.length) {
|
|
729
|
+
// Two counts in one sentence: the folders and the files beside their
|
|
730
|
+
// originals are each said whole and go into the files' sentence as slots.
|
|
731
|
+
where = tn(written.length - besideCount, 'Saved {n} file in {folder}, {beside}', 'Saved {n} files in {folder}, {beside}', {
|
|
732
|
+
folder: folders.length === 1 ? nameOf(folders[0]) : tn(folders.length, '{n} new folder', '{n} new folders'),
|
|
733
|
+
beside: tn(besideCount, '{n} next to its original', '{n} next to their originals'),
|
|
734
|
+
});
|
|
735
|
+
} else if (written.length) where = t('Saved next to each original');
|
|
736
|
+
if (where && stoppedAt !== null) where = t('{saved}. The rest were left as they were.', { saved: where });
|
|
622
737
|
finished({
|
|
623
738
|
title,
|
|
624
739
|
detail,
|
|
@@ -632,4 +747,104 @@ async function compressMany() {
|
|
|
632
747
|
|
|
633
748
|
el('go').addEventListener('click', () => (batch ? compressMany() : compress()));
|
|
634
749
|
|
|
635
|
-
|
|
750
|
+
/* --- across a language switch -------------------------------------------- */
|
|
751
|
+
|
|
752
|
+
/*
|
|
753
|
+
* Picking another language reloads the window, which would drop what is on
|
|
754
|
+
* screen. Told just before, this keeps a plain description of it (the paths
|
|
755
|
+
* that came in, the target and custom size, and a finished, stopped or failed
|
|
756
|
+
* result) once, for the page that loads next to put back in the new language.
|
|
757
|
+
* The files come back through intake, the way a drop does, so main's checks
|
|
758
|
+
* all apply; a file that has gone is left out. Save next to the originals is
|
|
759
|
+
* already kept by its own setting.
|
|
760
|
+
*/
|
|
761
|
+
const KEPT_FOR = 60 * 1000;
|
|
762
|
+
const PICK = ['fitted', 'skipped', 'over', 'failed'];
|
|
763
|
+
|
|
764
|
+
function keepForSwitch() {
|
|
765
|
+
const carry = { at: Date.now(), runNo };
|
|
766
|
+
const state = runState();
|
|
767
|
+
if (taken && (chosen || batch)) {
|
|
768
|
+
carry.paths = taken;
|
|
769
|
+
carry.target = el('target').value;
|
|
770
|
+
carry.custom = el('custom').value;
|
|
771
|
+
if (!busy && (state === 'done' || state === 'failed') && shown) {
|
|
772
|
+
if (shown.single) carry.single = shown.single;
|
|
773
|
+
else if (shown.many && batch) {
|
|
774
|
+
carry.many = {
|
|
775
|
+
...shown.many,
|
|
776
|
+
made,
|
|
777
|
+
items: batch.items.map((it) => ({
|
|
778
|
+
path: it.path, state: it.state, result: it.result, mark: it.mark, message: it.message, code: it.code, limit: it.limit,
|
|
779
|
+
before: it.before, after: it.after, out: it.out, folder: it.folder, copied: it.copied,
|
|
780
|
+
})),
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
settings.set('carry', carry);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Only what is the right shape goes back, and nothing here throws: on any
|
|
789
|
+
// doubt the start screen is what the person sees.
|
|
790
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
791
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
|
|
792
|
+
|
|
793
|
+
async function restore() {
|
|
794
|
+
const carry = settings.get('carry');
|
|
795
|
+
settings.set('carry', {});
|
|
796
|
+
await drawTargets();
|
|
797
|
+
try {
|
|
798
|
+
if (carry && Number.isInteger(carry.runNo) && carry.runNo > runNo) runNo = carry.runNo;
|
|
799
|
+
if (!carry || !Array.isArray(carry.paths) || !carry.paths.length || !(Date.now() - carry.at < KEPT_FOR)) return;
|
|
800
|
+
const target = TARGETS.find((x) => x.id === carry.target);
|
|
801
|
+
if (target) {
|
|
802
|
+
el('target').value = target.id;
|
|
803
|
+
useTarget(target);
|
|
804
|
+
}
|
|
805
|
+
const mb = Number(carry.custom);
|
|
806
|
+
if (carry.custom && mb > 0) {
|
|
807
|
+
el('custom').value = String(carry.custom);
|
|
808
|
+
el('custom').dispatchEvent(new Event('input', { bubbles: true }));
|
|
809
|
+
}
|
|
810
|
+
await intake(carry.paths.map(String));
|
|
811
|
+
if (!chosen && !batch) {
|
|
812
|
+
// Nothing came back (the file has gone): no error from a file the
|
|
813
|
+
// person did not just pick.
|
|
814
|
+
start.error('');
|
|
815
|
+
familyHint.clear();
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if (busy) return;
|
|
819
|
+
if (carry.single && chosen) {
|
|
820
|
+
const s = carry.single;
|
|
821
|
+
if (s.k === 'fits') showSingle({ k: 'fits', size: num(s.size), limit: num(s.limit) });
|
|
822
|
+
else if (s.k === 'stopped') showSingle({ k: 'stopped' });
|
|
823
|
+
else if (s.k === 'failed') showSingle({ k: 'failed', message: text(s.message) });
|
|
824
|
+
else if (s.k === 'done') {
|
|
825
|
+
showSingle({
|
|
826
|
+
k: 'done', before: num(s.before), bytes: num(s.bytes), over: Boolean(s.over), kind: text(s.kind), path: text(s.path),
|
|
827
|
+
attempts: num(s.attempts), note: text(s.note), duration: num(s.duration),
|
|
828
|
+
plan: s.plan ? { width: num(s.plan.width), height: num(s.plan.height), fps: num(s.plan.fps), videoKbps: num(s.plan.videoKbps), audioKbps: num(s.plan.audioKbps) } : null,
|
|
829
|
+
});
|
|
830
|
+
made = text(s.path) || null;
|
|
831
|
+
}
|
|
832
|
+
} else if (carry.many && batch) {
|
|
833
|
+
const m = carry.many;
|
|
834
|
+
const saved = Array.isArray(m.items) ? m.items : [];
|
|
835
|
+
// The same files, in the same order, or the result is not put back: it
|
|
836
|
+
// would describe a different set.
|
|
837
|
+
if (saved.length !== batch.items.length || !saved.every((x, i) => x && x.path === batch.items[i].path)) return;
|
|
838
|
+
saved.forEach((x, i) => {
|
|
839
|
+
const it = batch.items[i];
|
|
840
|
+
it.state = text(x.state); it.result = PICK.includes(x.result) ? x.result : null; it.mark = text(x.mark);
|
|
841
|
+
it.message = text(x.message); it.code = text(x.code); it.limit = num(x.limit);
|
|
842
|
+
it.before = num(x.before); it.after = num(x.after); it.out = text(x.out) || null; it.folder = text(x.folder) || null; it.copied = Boolean(x.copied);
|
|
843
|
+
});
|
|
844
|
+
made = text(m.made) || null;
|
|
845
|
+
showMany({ seconds: num(m.seconds), stoppedAt: Number.isInteger(m.stoppedAt) ? m.stoppedAt : null, target: num(m.target) });
|
|
846
|
+
}
|
|
847
|
+
} catch (err) { /* nothing to put back; the start screen is there */ }
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
restore();
|