@ponderdev/justfits 0.0.0-stage → 1.2.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/src/plan.js ADDED
@@ -0,0 +1,246 @@
1
+ 'use strict';
2
+
3
+ /*
4
+ * The arithmetic that decides how to make a file fit.
5
+ *
6
+ * Pure functions. No ffmpeg, no filesystem, no Electron. Whether your video
7
+ * comes in under the line is the one thing this app has to get right, so the
8
+ * maths behind it is testable directly rather than trusted by eye.
9
+ *
10
+ * Everything here works in kbps and bytes. The caller turns the result into
11
+ * ffmpeg arguments.
12
+ */
13
+
14
+ // Decimal megabytes, not mebibytes. Services are vague about which they mean,
15
+ // and being wrong in this direction leaves us slightly under the limit rather
16
+ // than slightly over it, which is the only direction that matters.
17
+ const MB = 1000 * 1000;
18
+
19
+ /*
20
+ * Where people actually get stuck, with the real numbers.
21
+ *
22
+ * Checked August 2026. They move, so they live in one list rather than
23
+ * scattered through the app, and the custom box is always there for when a
24
+ * platform changes its mind.
25
+ */
26
+
27
+ // Email attachments are base64 encoded in transit, which inflates them by
28
+ // about 37 percent. A provider advertising 25MB will bounce a 25MB file, so
29
+ // the ones marked `encoded` aim at the size the file has to be before that
30
+ // happens rather than the number on the tin.
31
+ const BASE64 = 1.37;
32
+
33
+ const TARGETS = [
34
+ { id: 'discord', group: 'Discord', label: 'Discord, free account', mb: 10,
35
+ note: 'The usual one. A boosted server raises it for everyone in that server.' },
36
+ { id: 'discord-basic', group: 'Discord', label: 'Discord Nitro Basic', mb: 50 },
37
+ { id: 'discord-boost3', group: 'Discord', label: 'Discord, level 3 boosted server', mb: 100,
38
+ note: 'Server boosts count even if you have no Nitro yourself.' },
39
+ { id: 'discord-nitro', group: 'Discord', label: 'Discord Nitro', mb: 500 },
40
+
41
+ { id: 'gmail', group: 'Email', label: 'Gmail', limitMb: 25, encoded: true },
42
+ { id: 'outlook', group: 'Email', label: 'Outlook and Microsoft 365', limitMb: 20, encoded: true },
43
+
44
+ { id: 'whatsapp', group: 'Messaging', label: 'WhatsApp video', mb: 16,
45
+ note: 'Sending it as a document instead allows up to 2GB.' },
46
+ { id: 'signal', group: 'Messaging', label: 'Signal', mb: 100 },
47
+ { id: 'imessage', group: 'Messaging', label: 'iMessage', mb: 100 },
48
+ { id: 'slack', group: 'Messaging', label: 'Slack', mb: 1000 },
49
+ { id: 'telegram', group: 'Messaging', label: 'Telegram', mb: 2000 },
50
+ ].map((t) => ({
51
+ ...t,
52
+ bytes: t.encoded ? Math.floor((t.limitMb * MB) / BASE64) : t.mb * MB,
53
+ note: t.note || (t.encoded
54
+ ? `${t.limitMb}MB limit, but base64 encoding adds about 37% in transit, so the file has to be smaller than that.`
55
+ : ''),
56
+ }));
57
+
58
+ // mp4 spends a couple of percent on headers, indexes and muxing that the
59
+ // bitrate maths cannot see, and x264 does not hit a requested bitrate exactly.
60
+ // Aim under the line rather than at it.
61
+ const HEADROOM = 0.95;
62
+
63
+ /*
64
+ * How much of the budget goes to sound.
65
+ *
66
+ * Speech stays intelligible far below the point where video falls apart, so
67
+ * audio gives way first. The last two rungs are mono, because at that budget
68
+ * one clean channel beats two muddy ones.
69
+ */
70
+ const AUDIO_LADDER = [
71
+ { from: 700, kbps: 128, channels: 2 },
72
+ { from: 400, kbps: 96, channels: 2 },
73
+ { from: 200, kbps: 64, channels: 2 },
74
+ { from: 110, kbps: 48, channels: 1 },
75
+ { from: 0, kbps: 32, channels: 1 },
76
+ ];
77
+
78
+ // Ladder rungs are the short edge, so a portrait clip steps down the same way
79
+ // a landscape one does.
80
+ const SHORT_EDGES = [2160, 1440, 1080, 720, 540, 432, 360, 270];
81
+
82
+ // Bits per pixel per frame.
83
+ //
84
+ // 0.08 is the low end of what YouTube recommends for an upload at a given
85
+ // resolution, and it is the bar a rung has to clear to be chosen. It was 0.09
86
+ // at first, which pushed a 30 second 1080p clip into a 10MB target down to
87
+ // 540p when 720p had 2400kbps available: comfortably inside YouTube's own
88
+ // 2500-4000 range for 720p30. Below 0.05 h264 smears on anything that moves,
89
+ // so that is the point where a smaller frame genuinely does look better.
90
+ const GOOD_BPP = 0.08;
91
+ const MIN_BPP = 0.05;
92
+
93
+ // Under this there is no point pretending. The caller warns the user.
94
+ const FLOOR_KBPS = 60;
95
+
96
+ function even(n) {
97
+ return Math.max(2, Math.round(n / 2) * 2);
98
+ }
99
+
100
+ /** Scale to a short edge, never upwards, always to even dimensions. */
101
+ function scaleToShortEdge(srcW, srcH, edge) {
102
+ const src = Math.min(srcW, srcH);
103
+ if (!src || edge >= src) return { width: even(srcW), height: even(srcH) };
104
+ const k = edge / src;
105
+ return { width: even(srcW * k), height: even(srcH * k) };
106
+ }
107
+
108
+ function audioFor(totalKbps, hasAudio) {
109
+ if (!hasAudio) return { kbps: 0, channels: 0 };
110
+ const rung = AUDIO_LADDER.find((r) => totalKbps >= r.from) || AUDIO_LADDER[AUDIO_LADDER.length - 1];
111
+ // Never let sound eat more than a quarter of the budget. Below 16kbps AAC
112
+ // is not worth encoding, so a budget that tight is hopeless anyway and
113
+ // planVideo flags it as such rather than this quietly papering over it.
114
+ const cap = Math.floor(totalKbps * 0.25);
115
+ return { kbps: Math.max(16, Math.min(rung.kbps, cap)), channels: rung.channels };
116
+ }
117
+
118
+ function bppFor(videoKbps, width, height, fps) {
119
+ return (videoKbps * 1000) / (width * height * fps);
120
+ }
121
+
122
+ /**
123
+ * Pick the largest frame that still gets enough bits, dropping frame rate
124
+ * before resolution gets silly.
125
+ */
126
+ function pickFrame(videoKbps, srcW, srcH, srcFps) {
127
+ const rates = srcFps > 32 ? [srcFps, 30] : [srcFps];
128
+ const shortEdge = Math.min(srcW, srcH);
129
+ // Leaving the source alone is always the first option. Without this a clip
130
+ // whose height falls between two rungs gets shrunk for no reason at all.
131
+ const rungs = [shortEdge, ...SHORT_EDGES.filter((e) => e < shortEdge)];
132
+
133
+ for (const bar of [GOOD_BPP, MIN_BPP]) {
134
+ for (const fps of rates) {
135
+ for (const edge of rungs) {
136
+ const { width, height } = scaleToShortEdge(srcW, srcH, edge);
137
+ if (bppFor(videoKbps, width, height, fps) >= bar) {
138
+ return { width, height, fps, rough: bar === MIN_BPP };
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+ // Nothing clears even the low bar. Take the smallest rung and be honest
145
+ // about it rather than shipping a plan that pretends otherwise.
146
+ const edge = rungs[rungs.length - 1];
147
+ const { width, height } = scaleToShortEdge(srcW, srcH, edge);
148
+ return { width, height, fps: Math.min(srcFps, 30), rough: true };
149
+ }
150
+
151
+ /**
152
+ * Work out one encode.
153
+ *
154
+ * `correction` carries what the previous attempt actually produced, so a
155
+ * second pass can aim lower without starting the reasoning again.
156
+ */
157
+ function planVideo({ durationSec, targetBytes, hasAudio = true, width, height, fps = 30, correction = 1 }) {
158
+ if (!(durationSec > 0)) throw new Error('Cannot plan an encode without a duration');
159
+ if (!(targetBytes > 0)) throw new Error('Cannot plan an encode without a target size');
160
+
161
+ const budgetBytes = targetBytes * HEADROOM * correction;
162
+ const totalKbps = (budgetBytes * 8) / durationSec / 1000;
163
+
164
+ const audio = audioFor(totalKbps, hasAudio);
165
+ const videoKbps = Math.floor(totalKbps - audio.kbps);
166
+
167
+ // Too long for the target at any quality worth producing.
168
+ if (videoKbps < FLOOR_KBPS) {
169
+ const frame = pickFrame(Math.max(videoKbps, 1), width, height, fps);
170
+ return {
171
+ videoKbps: Math.max(videoKbps, 20),
172
+ audioKbps: audio.kbps,
173
+ audioChannels: audio.channels,
174
+ ...frame,
175
+ rough: true,
176
+ hopeless: true,
177
+ };
178
+ }
179
+
180
+ const frame = pickFrame(videoKbps, width, height, fps);
181
+ return {
182
+ videoKbps,
183
+ audioKbps: audio.kbps,
184
+ audioChannels: audio.channels,
185
+ ...frame,
186
+ hopeless: false,
187
+ };
188
+ }
189
+
190
+ /**
191
+ * After an encode lands, how much to scale the next attempt by.
192
+ *
193
+ * x264 overshoots on hard content and undershoots on easy content, so rather
194
+ * than guessing better we measure and correct. The extra 2 percent stops a
195
+ * near miss from needing a third go.
196
+ */
197
+ function correctionFor(actualBytes, targetBytes, previous = 1) {
198
+ if (!(actualBytes > 0)) return previous;
199
+ const next = previous * (targetBytes / actualBytes) * 0.98;
200
+ // Never chase below a tenth of the original guess: something else is wrong.
201
+ return Math.max(0.1, Math.min(next, previous));
202
+ }
203
+
204
+ /** A still image, where quality is a dial rather than a bitrate. */
205
+ function planImage({ targetBytes, width, height, attempt = 0 }) {
206
+ // JPEG quality in ffmpeg's -q:v scale, where 2 is best and 31 is worst.
207
+ const quality = [3, 6, 10, 16, 24][Math.min(attempt, 4)];
208
+ const shrink = [1, 1, 0.8, 0.6, 0.45][Math.min(attempt, 4)];
209
+ return {
210
+ quality,
211
+ width: even(width * shrink),
212
+ height: even(height * shrink),
213
+ lastResort: attempt >= 4,
214
+ targetBytes,
215
+ };
216
+ }
217
+
218
+ /*
219
+ * Windows opens a device, not a file, for these names with any extension and
220
+ * in any case (con.mp4, NUL, lpt1.txt), so the result would vanish while the
221
+ * command reported success. Refused on every platform, since a script written
222
+ * on a Mac may well be run on Windows. Windows also ignores trailing dots and
223
+ * spaces, so "nul. " is NUL too.
224
+ */
225
+ function isDeviceName(outPath) {
226
+ if (typeof outPath !== 'string') return false;
227
+ // Windows reads a name only up to its first dot and ignores spaces before
228
+ // it, so "CON .mp4" and "con.take2.mp4" open the device as surely as "CON".
229
+ // The same rule in every tool, so a name refused by one is refused by all.
230
+ const head = outPath.split(/[\\/]/).pop().split('.')[0].replace(/ +$/, '');
231
+ return /^(con|prn|aux|nul|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])$/i.test(head);
232
+ }
233
+
234
+ module.exports = {
235
+ MB,
236
+ BASE64,
237
+ TARGETS,
238
+ HEADROOM,
239
+ planVideo,
240
+ planImage,
241
+ correctionFor,
242
+ scaleToShortEdge,
243
+ audioFor,
244
+ bppFor,
245
+ isDeviceName,
246
+ };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ // The only surface the page gets. No node, no filesystem, no network.
4
+ const { contextBridge, ipcRenderer, webUtils } = require('electron');
5
+
6
+ contextBridge.exposeInMainWorld('fits', {
7
+ // Fetched from main rather than required in here: preloads are sandboxed
8
+ // and can only require Electron's own modules. Keeping the sandbox is worth
9
+ // more than the convenience, and it means one copy of the list either way.
10
+ targets: () => ipcRenderer.invoke('targets'),
11
+ probe: (file) => ipcRenderer.invoke('probe', file),
12
+ fit: (file, targetBytes) => ipcRenderer.invoke('fit', { file, targetBytes }),
13
+ cancel: () => ipcRenderer.invoke('cancel'),
14
+ reveal: (file) => ipcRenderer.invoke('reveal', file),
15
+ openSite: () => ipcRenderer.invoke('open-site'),
16
+ openLicences: () => ipcRenderer.invoke('open-licences'),
17
+ pickFile: () => ipcRenderer.invoke('pick-file'),
18
+ // File.path was removed in Electron 32. Dropped files have to be resolved
19
+ // through webUtils now, which only exists on this side of the bridge.
20
+ pathFor: (file) => webUtils.getPathForFile(file),
21
+ onProgress: (fn) => ipcRenderer.on('progress', (_e, p) => fn(p)),
22
+ });
@@ -0,0 +1,226 @@
1
+ 'use strict';
2
+
3
+ /* The window. Holds no logic worth testing: the decisions live in plan.js. */
4
+
5
+ const MB = 1000 * 1000;
6
+
7
+ const el = (id) => document.getElementById(id);
8
+ let chosen = null; // the file being worked on
9
+ let targetBytes = 10 * MB;
10
+ let busy = false;
11
+
12
+ function human(bytes) {
13
+ if (bytes >= 1000 * MB) return trim(bytes / 1000 / MB) + ' GB';
14
+ if (bytes >= MB) return trim(bytes / MB) + ' MB';
15
+ return Math.max(1, Math.round(bytes / 1000)) + ' KB';
16
+ }
17
+
18
+ // 10 rather than 10.0, but 9.5 rather than 10.
19
+ function trim(n) {
20
+ return n.toFixed(n >= 100 ? 0 : 1).replace(/\.0$/, '');
21
+ }
22
+
23
+ function clock(seconds) {
24
+ const s = Math.round(seconds);
25
+ return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
26
+ }
27
+
28
+ /* --- target picking ----------------------------------------------------- */
29
+
30
+ let TARGETS = [];
31
+
32
+ async function drawTargets() {
33
+ TARGETS = await window.fits.targets();
34
+ const select = el('target');
35
+ let html = '';
36
+ let group = null;
37
+ for (const t of TARGETS) {
38
+ if (t.group !== group) {
39
+ if (group !== null) html += '</optgroup>';
40
+ group = t.group;
41
+ html += `<optgroup label="${group}">`;
42
+ }
43
+ const size = t.bytes >= 1000 * MB ? `${t.bytes / 1000 / MB}GB` : `${Math.round(t.bytes / MB)}MB`;
44
+ html += `<option value="${t.id}">${t.label} &middot; ${size}</option>`;
45
+ }
46
+ select.innerHTML = html + '</optgroup>';
47
+ select.value = TARGETS[0].id;
48
+ useTarget(TARGETS[0]);
49
+ }
50
+
51
+ function useTarget(t) {
52
+ targetBytes = t.bytes;
53
+ el('aim').textContent = `aiming for ${human(t.bytes)}`;
54
+ el('why').textContent = t.note || '';
55
+ }
56
+
57
+ el('target').addEventListener('change', (e) => {
58
+ const t = TARGETS.find((x) => x.id === e.target.value);
59
+ if (!t || busy) return;
60
+ el('custom').value = '';
61
+ useTarget(t);
62
+ });
63
+
64
+ el('custom').addEventListener('input', (e) => {
65
+ const mb = Number(e.target.value);
66
+ if (!(mb > 0)) {
67
+ // Cleared or nonsense: fall back to what the dropdown shows, rather than
68
+ // quietly keeping the last custom size while the dropdown says otherwise.
69
+ const t = TARGETS.find((x) => x.id === el('target').value);
70
+ if (t) useTarget(t);
71
+ return;
72
+ }
73
+ targetBytes = mb * MB;
74
+ el('aim').textContent = `aiming for ${human(targetBytes)}`;
75
+ el('why').textContent = '';
76
+ });
77
+
78
+ /* --- picking a file ----------------------------------------------------- */
79
+
80
+ async function take(filePath) {
81
+ if (busy) return;
82
+ hide('error');
83
+ hide('done');
84
+
85
+ // A drop that carries no path (dragged from somewhere that is not a real
86
+ // file on disk) would otherwise surface ffprobe's ": No such file" with no name.
87
+ const r = filePath
88
+ ? await window.fits.probe(filePath)
89
+ : { ok: false, message: 'Could not tell where that file is. Try "choose a file" instead.' };
90
+ if (!r.ok) {
91
+ chosen = null;
92
+ el('go').disabled = true;
93
+ // Hide the previous file, so its name is not left beside an error about another.
94
+ el('file').hidden = true;
95
+ showInView('error', r.message);
96
+ return;
97
+ }
98
+
99
+ chosen = { path: filePath, info: r.info };
100
+ el('name').textContent = filePath.split(/[\\/]/).pop();
101
+ el('facts').textContent = [
102
+ human(r.info.bytes),
103
+ r.info.width && `${r.info.width}x${r.info.height}`,
104
+ r.info.kind === 'video' && r.info.durationSec && clock(r.info.durationSec),
105
+ r.info.kind === 'video' && `${Math.round(r.info.fps)}fps`,
106
+ r.info.kind === 'video' && (r.info.hasAudio ? 'with sound' : 'silent'),
107
+ ].filter(Boolean).join(' · ');
108
+
109
+ el('file').hidden = false;
110
+ el('go').disabled = false;
111
+ }
112
+
113
+ const drop = el('drop');
114
+ for (const type of ['dragenter', 'dragover']) {
115
+ drop.addEventListener(type, (e) => { e.preventDefault(); drop.classList.add('over'); });
116
+ }
117
+ for (const type of ['dragleave', 'drop']) {
118
+ drop.addEventListener(type, () => drop.classList.remove('over'));
119
+ }
120
+ drop.addEventListener('drop', (e) => {
121
+ e.preventDefault();
122
+ const f = e.dataTransfer.files[0];
123
+ if (f) take(window.fits.pathFor ? window.fits.pathFor(f) : f.path);
124
+ });
125
+ document.addEventListener('dragover', (e) => e.preventDefault());
126
+ document.addEventListener('drop', (e) => e.preventDefault());
127
+
128
+ el('browse').addEventListener('click', async () => {
129
+ const f = await window.fits.pickFile();
130
+ if (f) take(f);
131
+ });
132
+
133
+ /* --- the work ----------------------------------------------------------- */
134
+
135
+ function show(id, text) {
136
+ const node = el(id);
137
+ if (text !== undefined) node.textContent = text;
138
+ node.hidden = false;
139
+ }
140
+ function hide(id) { el(id).hidden = true; }
141
+
142
+ // At 800x600 the window is short enough that progress, the result and errors
143
+ // all land below the fold, and a greyed button alone looks the same as nothing
144
+ // happening. So whatever the user is now waiting on, or has just got, scrolls
145
+ // into view.
146
+ function showInView(id, text) {
147
+ show(id, text);
148
+ el(id).scrollIntoView({ block: 'nearest', behavior: 'smooth' });
149
+ }
150
+
151
+ // The output goes beside the original with no Save window, so the Done card
152
+ // says what it is called and where it is, rather than leaving the user to find
153
+ // out through "Show me the file". Split by hand: the page has no path module.
154
+ function whereText(file) {
155
+ const cut = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
156
+ const name = file.slice(cut + 1);
157
+ // A file at the top of a drive or the root keeps its separator: C:\ and /.
158
+ const folder = cut > 0 && !/:$/.test(file.slice(0, cut)) ? file.slice(0, cut) : file.slice(0, cut + 1);
159
+ return folder ? `Saved as ${name}, next to the original in ${folder}` : `Saved as ${name}`;
160
+ }
161
+
162
+ window.fits.onProgress((p) => {
163
+ el('fill').style.width = Math.round(p.progress * 100) + '%';
164
+ el('stage').textContent = p.stage;
165
+ el('pct').textContent = Math.round(p.progress * 100) + '%';
166
+ el('attempt').textContent = p.attempt > 0 ? `attempt ${p.attempt + 1}, aiming lower` : '';
167
+ });
168
+
169
+ el('go').addEventListener('click', async () => {
170
+ if (!chosen || busy) return;
171
+
172
+ if (chosen.info.bytes <= targetBytes) {
173
+ el('result').textContent = 'That already fits.';
174
+ el('result').classList.remove('over');
175
+ el('detail').textContent = `${human(chosen.info.bytes)}, under the ${human(targetBytes)} limit. Nothing to do.`;
176
+ el('reveal').hidden = true;
177
+ el('where').textContent = '';
178
+ showInView('done');
179
+ return;
180
+ }
181
+
182
+ busy = true;
183
+ el('go').disabled = true;
184
+ hide('error');
185
+ hide('done');
186
+ el('fill').style.width = '0%';
187
+ showInView('working');
188
+
189
+ const r = await window.fits.fit(chosen.path, targetBytes);
190
+
191
+ busy = false;
192
+ el('go').disabled = false;
193
+ hide('working');
194
+
195
+ if (!r.ok) {
196
+ if (!r.cancelled) showInView('error', r.message);
197
+ return;
198
+ }
199
+
200
+ const saved = Math.round((1 - r.bytes / r.before) * 100);
201
+ el('done').classList.toggle('over', Boolean(r.over));
202
+ el('result').textContent = r.over
203
+ ? `Got it to ${human(r.bytes)}, still over the line.`
204
+ : `Done. ${human(r.before)} to ${human(r.bytes)}, ${saved}% smaller.`;
205
+
206
+ const bits = [];
207
+ if (r.plan && r.kind === 'video') {
208
+ bits.push(`${r.plan.width}x${r.plan.height}`);
209
+ bits.push(`${Math.round(r.plan.fps)}fps`);
210
+ bits.push(`${r.plan.videoKbps}k video`);
211
+ if (r.plan.audioKbps) bits.push(`${r.plan.audioKbps}k audio`);
212
+ }
213
+ if (r.attempts > 1) bits.push(`${r.attempts} attempts`);
214
+ el('detail').textContent = bits.join(' · ');
215
+
216
+ el('where').textContent = whereText(r.path);
217
+ el('reveal').hidden = false;
218
+ el('reveal').onclick = () => window.fits.reveal(r.path);
219
+ showInView('done');
220
+ });
221
+
222
+ el('cancel').addEventListener('click', () => window.fits.cancel());
223
+ el('site').addEventListener('click', () => window.fits.openSite());
224
+ el('licences').addEventListener('click', () => window.fits.openLicences());
225
+
226
+ drawTargets();
@@ -0,0 +1,81 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:;">
6
+ <title>Just Fits</title>
7
+ <link rel="stylesheet" href="styles.css">
8
+ </head>
9
+ <body>
10
+ <div class="titlebar"></div>
11
+
12
+ <div id="app">
13
+ <div class="view">
14
+
15
+ <h1>Just Fits</h1>
16
+ <p class="sub">Makes a file small enough to send. Nothing leaves this machine.</p>
17
+
18
+ <section id="drop" class="dropzone">
19
+ <svg class="dz-icon" viewBox="0 0 48 48" aria-hidden="true">
20
+ <rect x="6" y="11" width="36" height="26" rx="4"/>
21
+ <path d="M20 20l9 4-9 4z"/>
22
+ </svg>
23
+ <p class="dz-title">Drop a file in</p>
24
+ <p class="dz-sub">or <button type="button" id="browse" class="linky">choose a file</button></p>
25
+ </section>
26
+
27
+ <section id="file" class="settings" hidden>
28
+ <div class="field">
29
+ <p class="name" id="name"></p>
30
+ <p class="hint mono" id="facts"></p>
31
+ </div>
32
+ </section>
33
+
34
+ <section class="settings">
35
+ <div class="field">
36
+ <label for="target">Where is it going</label>
37
+ <select id="target"></select>
38
+ <p class="hint" id="why"></p>
39
+ </div>
40
+ <div class="field">
41
+ <label for="custom">Or aim for a size yourself</label>
42
+ <div class="row">
43
+ <input type="number" id="custom" min="1" max="20000" step="1" placeholder="25">
44
+ <span class="muted">MB</span>
45
+ <span class="pill" id="aim"></span>
46
+ </div>
47
+ </div>
48
+ </section>
49
+
50
+ <button type="button" id="go" class="btn btn-primary btn-wide" disabled>Compress</button>
51
+
52
+ <section id="working" class="working" hidden>
53
+ <div class="bar-track"><span id="fill"></span></div>
54
+ <p class="stage"><span id="stage">Working</span><span id="pct"></span></p>
55
+ <p class="hint" id="attempt"></p>
56
+ <button type="button" id="cancel" class="btn btn-ghost spaced">Cancel</button>
57
+ </section>
58
+
59
+ <section id="done" class="result-card" hidden>
60
+ <p class="result" id="result"></p>
61
+ <p class="hint mono" id="detail"></p>
62
+ <p class="hint where" id="where"></p>
63
+ <button type="button" id="reveal" class="linky spaced">Show me the file</button>
64
+ </section>
65
+
66
+ <p class="error" id="error" hidden></p>
67
+
68
+ </div>
69
+ </div>
70
+
71
+ <footer class="app-footer">
72
+ <span>Nothing is uploaded. It all happens here.</span>
73
+ <span class="foot-links">
74
+ <button type="button" id="site" class="mark-link">Powered by <span class="mark">Ponder<b>Dev</b></span></button>
75
+ <button type="button" id="licences" class="mark-link">Licences and credits</button>
76
+ </span>
77
+ </footer>
78
+
79
+ <script src="app.js"></script>
80
+ </body>
81
+ </html>