@ponderdev/justfits 1.2.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 +133 -15
- package/THIRD-PARTY-NOTICES.md +21 -10
- package/agents/skills/justfits/SKILL.md +104 -0
- package/package.json +19 -10
- package/scripts/link-skill.cjs +99 -0
- package/src/binaries.cjs +26 -10
- package/src/cli.cjs +245 -19
- package/src/engine.cjs +181 -26
- package/src/heif.cjs +156 -0
- 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 +105 -0
- package/src/kit/window.cjs +113 -0
- package/src/main.cjs +131 -20
- package/src/plan.js +136 -26
- package/src/preload.cjs +25 -1
- package/src/renderer/app.js +728 -104
- package/src/renderer/index.html +39 -56
- package/src/renderer/kit/kit.css +780 -0
- package/src/renderer/kit/kit.js +1057 -0
- package/src/renderer/licenses.html +44 -111
- package/src/renderer/strings.js +1562 -0
- package/src/renderer/styles.css +6 -256
- package/src/scan.cjs +80 -0
|
@@ -0,0 +1,1057 @@
|
|
|
1
|
+
/* PonderDev kit 1.1.0, built from kit/src. Do not edit: run bin/kit-sync. */
|
|
2
|
+
'use strict';
|
|
3
|
+
/* --- icons.js --- */
|
|
4
|
+
/* kit icons: one set, drawn once, used by name in every Just tool (decided
|
|
5
|
+
* 2026-11-18). 24px grid, outline, stroke var(--icon-stroke), round caps and
|
|
6
|
+
* joins, currentColor, so an icon takes the colour of the text around it.
|
|
7
|
+
*
|
|
8
|
+
* <i data-icon="play"></i> filled in by Kit.icons() on load
|
|
9
|
+
* Kit.icon('folder', { size: 32 }) an <svg> element, for script
|
|
10
|
+
*
|
|
11
|
+
* A tool never draws its own copy of one of these; the kit check refuses an
|
|
12
|
+
* inline <svg> in a tool's renderer. A tool's app icon (build/icon.svg) is its
|
|
13
|
+
* own and is not here. To add an icon, add it here, in this style, and run
|
|
14
|
+
* bin/kit-sync on the tools that use it. */
|
|
15
|
+
(function (Kit) {
|
|
16
|
+
const P = {
|
|
17
|
+
// things
|
|
18
|
+
file: '<path d="M7 3h7l5 5v13H7z"/><path d="M14 3v5h5"/>',
|
|
19
|
+
folder: '<path d="M3 7.5V18a1.5 1.5 0 0 0 1.5 1.5h15A1.5 1.5 0 0 0 21 18V9a1.5 1.5 0 0 0-1.5-1.5H12L10 5H4.5A1.5 1.5 0 0 0 3 6.5z"/>',
|
|
20
|
+
'folder-open': '<path d="M3 18V6.5A1.5 1.5 0 0 1 4.5 5H10l2 2.5h6.5A1.5 1.5 0 0 1 20 9v1.5"/><path d="M3 18l2.6-6.4A1.5 1.5 0 0 1 7 10.5h13.2a1 1 0 0 1 .9 1.4L18.5 18.6a1.5 1.5 0 0 1-1.4.9H4.5A1.5 1.5 0 0 1 3 18z"/>',
|
|
21
|
+
video: '<rect x="3" y="5.5" width="18" height="13" rx="2"/><path d="M10 9.5l5 2.5-5 2.5z"/>',
|
|
22
|
+
clapper: '<rect x="3" y="7" width="18" height="12.5" rx="2"/><path d="M3 10.5h18"/><path d="M8 7l-2 3.5M13 7l-2 3.5M18 7l-2 3.5"/>',
|
|
23
|
+
film: '<rect x="3" y="4.5" width="18" height="15" rx="2"/><path d="M3 9h18M3 15h18M7.5 4.5V9M12 4.5V9M16.5 4.5V9M7.5 15v4.5M12 15v4.5M16.5 15v4.5"/>',
|
|
24
|
+
photo: '<rect x="3" y="4.5" width="18" height="15" rx="2"/><circle cx="8.5" cy="9.5" r="1.8"/><path d="M3 17l5-5 4 4 3-3 6 6"/>',
|
|
25
|
+
photos: '<rect x="6" y="3" width="15" height="13" rx="2"/><path d="M3 7v11a2 2 0 0 0 2 2h12"/><circle cx="10.5" cy="7.5" r="1.5"/><path d="M6 13.5l4-3.5 3 2.5 2.5-2 5.5 4.5"/>',
|
|
26
|
+
audio: '<path d="M4 10v4M8 7v10M12 4v16M16 8v8M20 10.5v3"/>',
|
|
27
|
+
captions: '<rect x="3" y="5.5" width="18" height="13" rx="2"/><path d="M10.5 10.3a2.2 2.2 0 1 0 0 3.4M17 10.3a2.2 2.2 0 1 0 0 3.4"/>',
|
|
28
|
+
colour: '<path d="M12 3.5s6 6.4 6 10.5a6 6 0 0 1-12 0c0-4.1 6-10.5 6-10.5z"/><path d="M9 14.5a3 3 0 0 0 3 3"/>',
|
|
29
|
+
layers: '<path d="M12 4l9 4.5-9 4.5-9-4.5z"/><path d="M3 13l9 4.5 9-4.5"/>',
|
|
30
|
+
archive: '<rect x="3" y="4" width="18" height="5" rx="1.5"/><path d="M5 9v9.5A1.5 1.5 0 0 0 6.5 20h11a1.5 1.5 0 0 0 1.5-1.5V9"/><path d="M10 13h4"/>',
|
|
31
|
+
// playing and editing
|
|
32
|
+
play: '<path d="M8 5.5v13l10-6.5z"/>',
|
|
33
|
+
pause: '<path d="M8.5 5.5v13M15.5 5.5v13"/>',
|
|
34
|
+
undo: '<path d="M9 13.5L4.5 9 9 4.5"/><path d="M4.5 9h10a5 5 0 0 1 0 10H11"/>',
|
|
35
|
+
redo: '<path d="M15 13.5L19.5 9 15 4.5"/><path d="M19.5 9h-10a5 5 0 0 0 0 10H13"/>',
|
|
36
|
+
split: '<path d="M12 3v18"/><path d="M8 7.5L4.5 12 8 16.5M16 7.5l3.5 4.5-3.5 4.5"/>',
|
|
37
|
+
trash: '<path d="M4 7h16M10 3.5h4M6 7l1 13h10l1-13"/><path d="M10 11v5.5M14 11v5.5"/>',
|
|
38
|
+
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
39
|
+
close: '<path d="M6 6l12 12M18 6L6 18"/>',
|
|
40
|
+
change: '<path d="M4 9h13l-3.5-3.5"/><path d="M20 15H7l3.5 3.5"/>',
|
|
41
|
+
drag: '<circle cx="9" cy="6" r=".9"/><circle cx="15" cy="6" r=".9"/><circle cx="9" cy="12" r=".9"/><circle cx="15" cy="12" r=".9"/><circle cx="9" cy="18" r=".9"/><circle cx="15" cy="18" r=".9"/>',
|
|
42
|
+
// results
|
|
43
|
+
export: '<path d="M12 15V3.5M7.5 8L12 3.5 16.5 8"/><path d="M5 12v7.5A1.5 1.5 0 0 0 6.5 21h11a1.5 1.5 0 0 0 1.5-1.5V12"/>',
|
|
44
|
+
reveal: '<path d="M3 18V6.5A1.5 1.5 0 0 1 4.5 5H10l2 2.5h7.5A1.5 1.5 0 0 1 21 9v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18z"/><path d="M10 13.5h6M13.5 11l2.5 2.5-2.5 2.5"/>',
|
|
45
|
+
check: '<path d="M5 12.5l4.5 4.5L19 7.5"/>',
|
|
46
|
+
warning: '<path d="M12 4l9 15.5H3z"/><path d="M12 10v4.5M12 17.2v.1"/>',
|
|
47
|
+
info: '<circle cx="12" cy="12" r="8.5"/><path d="M12 11v5.5M12 7.8v.1"/>',
|
|
48
|
+
help: '<circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.5a2.5 2.5 0 1 1 3.4 2.3c-.7.3-1 .8-1 1.5v.4M12 16.8v.1"/>',
|
|
49
|
+
// more, from the inventory (kit/INVENTORY.md)
|
|
50
|
+
stop: '<rect x="6.5" y="6.5" width="11" height="11" rx="1.5"/>',
|
|
51
|
+
compare: '<rect x="3.5" y="5" width="17" height="14" rx="2"/><path d="M12 3v18"/><path d="M7 10l-1.5 2L7 14M17 10l1.5 2-1.5 2"/>',
|
|
52
|
+
reset: '<path d="M4.5 12a7.5 7.5 0 1 0 2.2-5.3"/><path d="M4.5 4.5v4h4"/>',
|
|
53
|
+
auto: '<path d="M5 19L15 9"/><path d="M14 4.5l.8 1.7 1.7.8-1.7.8-.8 1.7-.8-1.7-1.7-.8 1.7-.8z"/><path d="M19 10l.5 1 1 .5-1 .5-.5 1-.5-1-1-.5 1-.5z"/>',
|
|
54
|
+
forward: '<rect x="8" y="3.5" width="12.5" height="12.5" rx="2"/><path d="M5.5 8v10A2.5 2.5 0 0 0 8 20.5h10"/>',
|
|
55
|
+
back: '<rect x="3.5" y="8" width="12.5" height="12.5" rx="2"/><path d="M8 5.5V5A1.5 1.5 0 0 1 9.5 3.5h9.5A1.5 1.5 0 0 1 20.5 5v9.5a1.5 1.5 0 0 1-1.5 1.5h-.5"/>',
|
|
56
|
+
shape: '<circle cx="8.5" cy="8.5" r="4.5"/><rect x="11" y="11" width="9.5" height="9.5" rx="1.5"/>',
|
|
57
|
+
text: '<path d="M5 6.5V5h14v1.5M12 5v14M9 19h6"/>',
|
|
58
|
+
eye: '<path d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z"/><circle cx="12" cy="12" r="3"/>',
|
|
59
|
+
music: '<path d="M9 18V5.5l11-2V16"/><circle cx="6.5" cy="18" r="2.5"/><circle cx="17.5" cy="16" r="2.5"/>',
|
|
60
|
+
mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7"/>',
|
|
61
|
+
speaker: '<path d="M4 9.5h3.5L12 5.5v13l-4.5-4H4z"/><path d="M15.5 9a4 4 0 0 1 0 6M18 6.5a7.5 7.5 0 0 1 0 11"/>',
|
|
62
|
+
position: '<rect x="3.5" y="3.5" width="17" height="17" rx="2"/><path d="M9.2 3.5v17M14.8 3.5v17M3.5 9.2h17M3.5 14.8h17"/>',
|
|
63
|
+
clock: '<circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/>',
|
|
64
|
+
language: '<circle cx="12" cy="12" r="8.5"/><path d="M3.5 12h17M12 3.5c2.5 2.6 3.6 5.4 3.6 8.5s-1.1 5.9-3.6 8.5c-2.5-2.6-3.6-5.4-3.6-8.5S9.5 6.1 12 3.5z"/>',
|
|
65
|
+
download: '<path d="M12 3.5V15M7.5 10.5L12 15l4.5-4.5"/><path d="M5 18.5h14"/>',
|
|
66
|
+
update: '<path d="M19.5 12a7.5 7.5 0 0 1-13.4 4.6M4.5 12a7.5 7.5 0 0 1 13.4-4.6"/><path d="M18 3.5v4h-4M6 20.5v-4h4"/>',
|
|
67
|
+
rollback: '<path d="M9 7.5L4.5 12 9 16.5"/><path d="M4.5 12H15a4.5 4.5 0 0 0 0-9h-1"/>',
|
|
68
|
+
run: '<circle cx="12" cy="12" r="8.5"/><path d="M10 8.5v7l5.5-3.5z"/>',
|
|
69
|
+
chain: '<rect x="3" y="9" width="6" height="6" rx="1.5"/><rect x="15" y="9" width="6" height="6" rx="1.5"/><path d="M9 12h6M13 10l2 2-2 2"/>',
|
|
70
|
+
link: '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>',
|
|
71
|
+
connected: '<path d="M4.5 9.5a11 11 0 0 1 15 0M7.5 12.8a6.5 6.5 0 0 1 9 0"/><circle cx="12" cy="16.5" r="1.2"/>',
|
|
72
|
+
disconnected: '<path d="M4.5 9.5a11 11 0 0 1 4-2.3M14.5 7a11 11 0 0 1 5 2.5M7.5 12.8a6.5 6.5 0 0 1 2.2-1.3"/><circle cx="12" cy="16.5" r="1.2"/><path d="M4 4l16 16"/>',
|
|
73
|
+
server: '<rect x="4" y="4" width="16" height="7" rx="1.5"/><rect x="4" y="13" width="16" height="7" rx="1.5"/><path d="M7.5 7.5h.1M7.5 16.5h.1"/>',
|
|
74
|
+
search: '<circle cx="10.5" cy="10.5" r="6"/><path d="M15 15l5 5"/>',
|
|
75
|
+
tree: '<path d="M5 4v14.5A1.5 1.5 0 0 0 6.5 20H9M5 9.5h4"/><rect x="9" y="6.5" width="11" height="6" rx="1.5"/><rect x="9" y="16.5" width="11" height="6" rx="1.5"/>',
|
|
76
|
+
pen: '<path d="M4 20l1-4.5L15.5 5a2.1 2.1 0 0 1 3 3L8 18.5z"/><path d="M13.5 7l3 3"/>',
|
|
77
|
+
note: '<path d="M5 4.5h14v10l-5 5H5z"/><path d="M14 19.5v-5h5M8.5 9h7M8.5 12.5h4"/>',
|
|
78
|
+
bolt: '<path d="M13 3L5.5 13.5H12L11 21l7.5-10.5H12z"/>',
|
|
79
|
+
belt: '<rect x="4" y="14" width="16" height="5" rx="1.5"/><rect x="5.5" y="9.5" width="13" height="4.5" rx="1.5"/><rect x="7" y="5" width="10" height="4.5" rx="1.5"/>',
|
|
80
|
+
tabs: '<path d="M3.5 19.5V7A1.5 1.5 0 0 1 5 5.5h4.5L11 8h8a1.5 1.5 0 0 1 1.5 1.5v10z"/><path d="M11 8h9.5"/>',
|
|
81
|
+
minus: '<path d="M5 12h14"/>',
|
|
82
|
+
// the window
|
|
83
|
+
'chevron-down': '<path d="M6 9.5l6 6 6-6"/>',
|
|
84
|
+
'chevron-right': '<path d="M9.5 6l6 6-6 6"/>',
|
|
85
|
+
settings: '<circle cx="12" cy="12" r="3"/><path d="M12 3v2.5M12 18.5V21M3 12h2.5M18.5 12H21M5.6 5.6l1.8 1.8M16.6 16.6l1.8 1.8M5.6 18.4l1.8-1.8M16.6 7.4l1.8-1.8"/>',
|
|
86
|
+
zoom: '<circle cx="10.5" cy="10.5" r="6"/><path d="M15 15l5 5"/>',
|
|
87
|
+
waiting: '<circle cx="12" cy="12" r="7"/>',
|
|
88
|
+
working: '<path d="M12 5a7 7 0 1 1-7 7"/>',
|
|
89
|
+
};
|
|
90
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
91
|
+
|
|
92
|
+
Kit.ICONS = Object.keys(P);
|
|
93
|
+
|
|
94
|
+
Kit.icon = function icon(name, { size, cls } = {}) {
|
|
95
|
+
if (!P[name]) throw new Error(`kit: no icon "${name}"`);
|
|
96
|
+
const s = document.createElementNS(NS, 'svg');
|
|
97
|
+
s.setAttribute('viewBox', '0 0 24 24');
|
|
98
|
+
s.setAttribute('aria-hidden', 'true');
|
|
99
|
+
s.setAttribute('class', 'k-icon' + (cls ? ' ' + cls : ''));
|
|
100
|
+
s.dataset.icon = name;
|
|
101
|
+
if (size) { s.setAttribute('width', size); s.setAttribute('height', size); }
|
|
102
|
+
s.innerHTML = P[name]; // this file's own constants, never outside text
|
|
103
|
+
return s;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// <i data-icon="name"></i> becomes the icon, keeping any classes on the <i>
|
|
107
|
+
Kit.icons = function icons(root = document) {
|
|
108
|
+
for (const i of root.querySelectorAll('i[data-icon]')) {
|
|
109
|
+
const s = Kit.icon(i.dataset.icon, { cls: i.className });
|
|
110
|
+
if (i.getAttribute('aria-label')) { s.setAttribute('aria-hidden', 'false'); s.setAttribute('role', 'img'); s.setAttribute('aria-label', i.getAttribute('aria-label')); }
|
|
111
|
+
i.replaceWith(s);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
})(window.Kit = window.Kit || {});
|
|
115
|
+
|
|
116
|
+
/* --- words.js --- */
|
|
117
|
+
/* kit: words, the one way a Just tool says anything in the window
|
|
118
|
+
* (languages in the kit).
|
|
119
|
+
*
|
|
120
|
+
* The English sentence is its own key: the code reads as it always did, and a
|
|
121
|
+
* sentence nobody has translated yet simply shows in English.
|
|
122
|
+
*
|
|
123
|
+
* const w = KitWords.words(strings, 'de');
|
|
124
|
+
* w.t('Choose a file') // "Datei auswählen"
|
|
125
|
+
* w.t('Unpacked into {folder}', { folder }) // {name} slots are filled in
|
|
126
|
+
* w.tn(count, '{n} file', '{n} files') // the right plural for the language
|
|
127
|
+
* w.num(59400) // "59.400"
|
|
128
|
+
*
|
|
129
|
+
* strings is { de: { 'Choose a file': 'Datei auswählen', '{n} file|{n} files':
|
|
130
|
+
* { one: '{n} Datei', other: '{n} Dateien' }, ... }, ... }, built from each
|
|
131
|
+
* tool's strings/<code>.json and the kit's own by bin/strings.
|
|
132
|
+
*
|
|
133
|
+
* This file runs in the window (inside kit.js) and on the main side (inside
|
|
134
|
+
* src/kit/lang.cjs), so a dialog's title and a button say the same thing.
|
|
135
|
+
*/
|
|
136
|
+
(function (root) {
|
|
137
|
+
// The languages a tool can be in, each named in its own language, in the
|
|
138
|
+
// order the menu lists them (decided 2026-11-24: English plus the five
|
|
139
|
+
// named on 11-21). Portuguese is Brazil's, the larger audience.
|
|
140
|
+
const LANGUAGES = [
|
|
141
|
+
['en', 'English'],
|
|
142
|
+
['es', 'Español'],
|
|
143
|
+
['pt', 'Português'],
|
|
144
|
+
['fr', 'Français'],
|
|
145
|
+
['de', 'Deutsch'],
|
|
146
|
+
['ja', '日本語'],
|
|
147
|
+
];
|
|
148
|
+
const CODES = LANGUAGES.map(([code]) => code);
|
|
149
|
+
|
|
150
|
+
// The first language the system asks for that we have, else English.
|
|
151
|
+
// 'pt-BR' and 'pt-PT' both take 'pt'; 'en-GB' takes 'en'.
|
|
152
|
+
function pick(wanted) {
|
|
153
|
+
const list = Array.isArray(wanted) ? wanted : [wanted];
|
|
154
|
+
for (const w of list) {
|
|
155
|
+
const code = String(w || '').toLowerCase().split(/[-_]/)[0];
|
|
156
|
+
if (CODES.includes(code)) return code;
|
|
157
|
+
}
|
|
158
|
+
return 'en';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const fill = (text, vars) => String(text).replace(/\{(\w+)\}/g, (m, k) => (vars && Object.prototype.hasOwnProperty.call(vars, k) ? String(vars[k]) : m));
|
|
162
|
+
|
|
163
|
+
function words(strings, lang) {
|
|
164
|
+
const code = CODES.includes(lang) ? lang : 'en';
|
|
165
|
+
const table = (strings && strings[code]) || {};
|
|
166
|
+
let rules = null;
|
|
167
|
+
try { rules = new Intl.PluralRules(code); } catch (e) { rules = null; }
|
|
168
|
+
const num = (n, opts) => {
|
|
169
|
+
try { return new Intl.NumberFormat(code, opts).format(n); } catch (e) { return String(n); }
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
lang: code,
|
|
173
|
+
t(source, vars) { // strings: passes on
|
|
174
|
+
const said = table[source];
|
|
175
|
+
return fill(typeof said === 'string' && said ? said : source, vars);
|
|
176
|
+
},
|
|
177
|
+
// one and other are the English forms; the key is both, joined by '|'
|
|
178
|
+
tn(n, one, other, vars = {}) {
|
|
179
|
+
const v = Object.assign({ n: num(n) }, vars);
|
|
180
|
+
const said = table[`${one}|${other}`];
|
|
181
|
+
if (said && typeof said === 'object') {
|
|
182
|
+
const form = said[rules ? rules.select(n) : 'other'] || said.other;
|
|
183
|
+
if (form) return fill(form, v);
|
|
184
|
+
}
|
|
185
|
+
return fill(n === 1 ? one : other, v);
|
|
186
|
+
},
|
|
187
|
+
num,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const api = { LANGUAGES, CODES, pick, words, fill };
|
|
192
|
+
if (typeof module !== 'undefined' && module.exports) module.exports = api;
|
|
193
|
+
else root.KitWords = api;
|
|
194
|
+
})(typeof window !== 'undefined' ? window : globalThis);
|
|
195
|
+
|
|
196
|
+
/* --- parts/lang.js --- */
|
|
197
|
+
/* kit part: the window's language.
|
|
198
|
+
*
|
|
199
|
+
* Every word the window shows goes through Kit.t, so it can be in the
|
|
200
|
+
* person's language:
|
|
201
|
+
*
|
|
202
|
+
* const { t, tn } = Kit;
|
|
203
|
+
* button.textContent = t('Choose files');
|
|
204
|
+
* note.textContent = tn(count, '{n} file left out', '{n} files left out');
|
|
205
|
+
* <h2 data-t>Make an archive</h2> static words in the page: data-t
|
|
206
|
+
* <button data-t-title="Start again"> an attribute: data-t-title,
|
|
207
|
+
* data-t-aria-label, data-t-placeholder
|
|
208
|
+
*
|
|
209
|
+
* The strings come from src/renderer/strings.js (window.KitStrings), which
|
|
210
|
+
* bin/strings writes from the tool's strings/<code>.json and the kit's own;
|
|
211
|
+
* the page loads it before kit.js.
|
|
212
|
+
*
|
|
213
|
+
* The language is the system's when we have it, else English, until the
|
|
214
|
+
* person picks another from the footer (Kit.footer draws the button). The
|
|
215
|
+
* choice is kept in the kit's own store, so it holds across versions.
|
|
216
|
+
* Picking one reloads the window in it, so nothing is left half translated;
|
|
217
|
+
* it is not offered while a run is going. A tool that refuses navigation
|
|
218
|
+
* hands over reload (the bridge's reloadWindow: main reloads the window, which
|
|
219
|
+
* a page cannot do for itself), and keep, which is told just before the
|
|
220
|
+
* reload so the tool can put back what was on screen, a finished result
|
|
221
|
+
* above all.
|
|
222
|
+
*
|
|
223
|
+
* The tool hands over what only it knows, once, before anything else:
|
|
224
|
+
*
|
|
225
|
+
* Kit.languages({
|
|
226
|
+
* tell: api.language, // main side: its dialogs follow (kit/lang.cjs)
|
|
227
|
+
* mistake: api.translationMistake, // opens the tool's issue page for a wrong translation
|
|
228
|
+
* busy: () => busy, // no switching mid-run
|
|
229
|
+
* reload: api.reloadWindow, // main reloads the window (a page cannot, where navigation is refused)
|
|
230
|
+
* keep: () => saveWhatIsShown(), // told just before the reload
|
|
231
|
+
* });
|
|
232
|
+
*/
|
|
233
|
+
(function (Kit) {
|
|
234
|
+
const W = window.KitWords;
|
|
235
|
+
const strings = window.KitStrings || {};
|
|
236
|
+
const KEY = 'kit.settings';
|
|
237
|
+
const readChoice = () => {
|
|
238
|
+
try { const saved = JSON.parse(window.localStorage.getItem(KEY) || '{}'); return typeof saved.language === 'string' ? saved.language : 'auto'; } catch (e) { return 'auto'; }
|
|
239
|
+
};
|
|
240
|
+
const writeChoice = (code) => {
|
|
241
|
+
try {
|
|
242
|
+
let saved = {};
|
|
243
|
+
try { saved = JSON.parse(window.localStorage.getItem(KEY) || '{}') || {}; } catch (e) { saved = {}; }
|
|
244
|
+
if (typeof saved !== 'object' || Array.isArray(saved)) saved = {};
|
|
245
|
+
saved.language = code;
|
|
246
|
+
window.localStorage.setItem(KEY, JSON.stringify(saved));
|
|
247
|
+
return true;
|
|
248
|
+
} catch (e) { return false; }
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const chosen = readChoice();
|
|
252
|
+
const lang = chosen !== 'auto' && W.CODES.includes(chosen) ? chosen : W.pick(navigator.languages || [navigator.language]);
|
|
253
|
+
const w = W.words(strings, lang);
|
|
254
|
+
|
|
255
|
+
Kit.LANGUAGES = W.LANGUAGES;
|
|
256
|
+
Kit.lang = w.lang;
|
|
257
|
+
Kit.t = w.t;
|
|
258
|
+
Kit.tn = w.tn;
|
|
259
|
+
Kit.num = w.num;
|
|
260
|
+
// A language is offered only when its strings are there (English always is).
|
|
261
|
+
Kit.offered = () => W.LANGUAGES.filter(([code]) => code === 'en' || (strings[code] && Object.keys(strings[code]).length));
|
|
262
|
+
// True when the window is in a language a machine translated (every one but English for now).
|
|
263
|
+
Kit.machine = () => w.lang !== 'en';
|
|
264
|
+
document.documentElement.lang = w.lang;
|
|
265
|
+
|
|
266
|
+
// Static words in the page: an element with data-t has its own text as the
|
|
267
|
+
// key; data-t-<attribute> holds the key for that attribute. Safe to run again
|
|
268
|
+
// on what a tool adds later (the English is kept in data-t-source).
|
|
269
|
+
Kit.translate = function translate(root = document) {
|
|
270
|
+
for (const node of root.querySelectorAll('[data-t]')) {
|
|
271
|
+
if (!node.dataset.tSource) node.dataset.tSource = node.textContent.replace(/\s+/g, ' ').trim();
|
|
272
|
+
node.textContent = w.t(node.dataset.tSource); // strings: passes on
|
|
273
|
+
}
|
|
274
|
+
for (const attr of ['title', 'aria-label', 'placeholder', 'alt']) {
|
|
275
|
+
for (const node of root.querySelectorAll(`[data-t-${attr}]`)) node.setAttribute(attr, w.t(node.getAttribute(`data-t-${attr}`))); // strings: passes on
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const hooks = { tell: null, mistake: null, busy: () => false, reload: null, keep: null };
|
|
280
|
+
Kit.languages = function languages({ tell, mistake, busy, reload, keep } = {}) {
|
|
281
|
+
if (tell) hooks.tell = tell;
|
|
282
|
+
if (mistake) hooks.mistake = mistake;
|
|
283
|
+
if (busy) hooks.busy = busy;
|
|
284
|
+
if (reload) hooks.reload = reload;
|
|
285
|
+
if (keep) hooks.keep = keep;
|
|
286
|
+
if (hooks.tell) { try { Promise.resolve(hooks.tell(w.lang)).catch(() => {}); } catch (e) { /* the main side keeps English */ } }
|
|
287
|
+
return { lang: w.lang };
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// Used by the footer: switch, or report a wrong translation.
|
|
291
|
+
Kit.chooseLanguage = function chooseLanguage(code) {
|
|
292
|
+
if (hooks.busy()) return false;
|
|
293
|
+
if (!W.CODES.includes(code)) return false;
|
|
294
|
+
writeChoice(code);
|
|
295
|
+
if (code === w.lang) return true;
|
|
296
|
+
if (hooks.keep) { try { hooks.keep(); } catch (e) { /* the switch still goes ahead */ } }
|
|
297
|
+
// Main reloads the window when the tool gives the bridge's call: a page's
|
|
298
|
+
// own reload is a navigation, which a tool that refuses navigation cancels.
|
|
299
|
+
if (hooks.reload) {
|
|
300
|
+
let asked = null;
|
|
301
|
+
try { asked = hooks.reload(); } catch (e) { asked = false; } // the call never reached main: the page reloads itself
|
|
302
|
+
// Only main's plain "no" means the page reloads itself. A rejected call is
|
|
303
|
+
// what this page sees when main has reloaded it already and the page is
|
|
304
|
+
// going away; reloading again then would load the window twice, and the
|
|
305
|
+
// first load would already have used up what keep saved.
|
|
306
|
+
Promise.resolve(asked).then((ok) => { if (ok === false) window.location.reload(); }, () => {});
|
|
307
|
+
} else window.location.reload();
|
|
308
|
+
return true;
|
|
309
|
+
};
|
|
310
|
+
Kit.reportMistake = function reportMistake() {
|
|
311
|
+
if (hooks.mistake) { try { Promise.resolve(hooks.mistake(w.lang)).catch(() => {}); } catch (e) { /* nothing to open */ } }
|
|
312
|
+
};
|
|
313
|
+
Kit.languageBusy = () => hooks.busy();
|
|
314
|
+
|
|
315
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => Kit.translate());
|
|
316
|
+
else Kit.translate();
|
|
317
|
+
})(window.Kit = window.Kit || {});
|
|
318
|
+
|
|
319
|
+
/* --- parts/start.js --- */
|
|
320
|
+
/* kit part: the start screen (option A) and the file row.
|
|
321
|
+
*
|
|
322
|
+
* const start = Kit.start(document.getElementById('start'), {
|
|
323
|
+
* name: 'Just Fits', version: '1.3.0', line: 'Makes a file small enough to send.',
|
|
324
|
+
* icon: 'video', say: 'Drop a video or a picture here', choose: 'Choose a file',
|
|
325
|
+
* takes: 'MP4, MOV, MKV, WebM and more, or a JPEG, PNG, HEIC or WebP picture',
|
|
326
|
+
* onChoose, onDrop(files),
|
|
327
|
+
* also: { label: 'Choose a folder', onClick, change: 'Change folder' }, // optional
|
|
328
|
+
* });
|
|
329
|
+
* also.change: the same second way in on the file row once something is in,
|
|
330
|
+
* beside "Change file" (decided 2026-11-21: a folder can be swapped for
|
|
331
|
+
* another folder on Windows and Linux without Start again).
|
|
332
|
+
* start.landed({ name: 'beach-day.mp4', facts: '41.3 MB · 1920x1080 · 0:12' });
|
|
333
|
+
* start.reset();
|
|
334
|
+
*/
|
|
335
|
+
(function (Kit) {
|
|
336
|
+
// Kit.t (parts/lang.js) when it is loaded; the English, with its {slots} filled, when not
|
|
337
|
+
const t = (s, v) => (Kit.t ? Kit.t(s, v) : String(s).replace(/\{(\w+)\}/g, (m, k) => (v && k in v ? String(v[k]) : m)));
|
|
338
|
+
const el = (tag, cls, text) => { const n = document.createElement(tag); if (cls) n.className = cls; if (text !== undefined) n.textContent = text; return n; };
|
|
339
|
+
|
|
340
|
+
// also: { label, onClick } a second way to change, beside Change (a folder,
|
|
341
|
+
// on Windows and Linux where one picker cannot take both); Change then reads
|
|
342
|
+
// changeLabel ('Change file').
|
|
343
|
+
Kit.fileRow = function fileRow(root, { icon = 'file', onChange, also, changeLabel } = {}) {
|
|
344
|
+
root.classList.add('k-file');
|
|
345
|
+
root.replaceChildren();
|
|
346
|
+
const text = el('div', 'k-file-text');
|
|
347
|
+
const name = el('p', 'k-file-name');
|
|
348
|
+
const facts = el('p', 'k-file-facts');
|
|
349
|
+
text.append(name, facts);
|
|
350
|
+
const change = el('button', 'btn btn-ghost btn-tight', also ? (changeLabel || t('Change file')) : t('Change'));
|
|
351
|
+
change.type = 'button';
|
|
352
|
+
if (onChange) change.addEventListener('click', onChange);
|
|
353
|
+
let pic = Kit.icon(icon);
|
|
354
|
+
let changeAlso = null;
|
|
355
|
+
if (also) {
|
|
356
|
+
changeAlso = el('button', 'btn btn-ghost btn-tight', also.label);
|
|
357
|
+
changeAlso.type = 'button';
|
|
358
|
+
changeAlso.addEventListener('click', () => also.onClick && also.onClick());
|
|
359
|
+
const both = el('div', 'k-file-changes');
|
|
360
|
+
both.append(change, changeAlso);
|
|
361
|
+
root.append(pic, text, both);
|
|
362
|
+
} else root.append(pic, text, change);
|
|
363
|
+
return {
|
|
364
|
+
// icon: a file's own kind when it differs from the tool's (a picture in Just Fits)
|
|
365
|
+
set({ name: n, facts: f = '', icon: i } = {}) {
|
|
366
|
+
name.textContent = n; facts.textContent = f; root.classList.add('show');
|
|
367
|
+
if (i) { const next = Kit.icon(i); pic.replaceWith(next); pic = next; }
|
|
368
|
+
},
|
|
369
|
+
change,
|
|
370
|
+
changeAlso,
|
|
371
|
+
clear() { root.classList.remove('show'); },
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// A pre-release build carries its coming version with a pre-release tag in
|
|
376
|
+
// package.json ("1.3.0-pre"), and says so in words: "1.3.0 (pre-release)",
|
|
377
|
+
// so a review picture never looks like the old build. A release build shows
|
|
378
|
+
// the plain version (decided 2026-11-20).
|
|
379
|
+
Kit.versionLabel = function versionLabel(v) {
|
|
380
|
+
const m = /^(\d+\.\d+\.\d+)-./.exec(String(v || ''));
|
|
381
|
+
return m ? t('{version} (pre-release)', { version: m[1] }) : String(v || '');
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
Kit.start = function start(root, o) {
|
|
385
|
+
root.classList.add('k-start');
|
|
386
|
+
root.replaceChildren();
|
|
387
|
+
const head = el('header', 'k-start-head');
|
|
388
|
+
// the version sits faintly beside the name (decided 2026-11-19)
|
|
389
|
+
const title = el('h1', '', o.name);
|
|
390
|
+
if (o.version) title.append(el('span', 'k-version', Kit.versionLabel(o.version)));
|
|
391
|
+
head.append(title, el('p', 'sub', o.line));
|
|
392
|
+
const zone = el('section', 'k-zone');
|
|
393
|
+
const btn = el('button', 'btn btn-primary', o.choose || t('Choose a file'));
|
|
394
|
+
btn.type = 'button';
|
|
395
|
+
const err = el('p', 'k-error');
|
|
396
|
+
// also: a second way in, as a quieter button beside the first (Zip's "Open an archive")
|
|
397
|
+
const actions = el('div', 'k-zone-actions');
|
|
398
|
+
actions.append(btn);
|
|
399
|
+
let also = null;
|
|
400
|
+
if (o.also) {
|
|
401
|
+
also = el('button', 'btn btn-ghost', o.also.label);
|
|
402
|
+
also.type = 'button';
|
|
403
|
+
also.addEventListener('click', () => o.also.onClick && o.also.onClick());
|
|
404
|
+
actions.append(also);
|
|
405
|
+
}
|
|
406
|
+
zone.append(Kit.icon(o.icon || 'file'), el('p', 'k-zone-say', o.say), actions, el('p', 'k-zone-takes', o.takes || ''), err);
|
|
407
|
+
const fileEl = el('div');
|
|
408
|
+
root.append(head, zone);
|
|
409
|
+
// skill: { copy: async () => the tool's SKILL.md text, about: () => opens its how-it-works page }
|
|
410
|
+
if (o.skill) {
|
|
411
|
+
const line = el('p', 'k-skill');
|
|
412
|
+
const copy = el('button', 'linky', t('Copy skill'));
|
|
413
|
+
copy.type = 'button';
|
|
414
|
+
const about = el('button', 'linky', t("What's this?"));
|
|
415
|
+
about.type = 'button';
|
|
416
|
+
const note = el('p', 'k-skill-about hint');
|
|
417
|
+
note.hidden = true;
|
|
418
|
+
note.textContent = t('A skill is a short file that teaches an assistant (Claude, ChatGPT, or one on your own computer) to run {name} for you.', { name: o.name });
|
|
419
|
+
line.append(t('Use it with your assistant'), el('span', 'k-skill-sep', '·'), copy, el('span', 'k-skill-sep', '·'), about);
|
|
420
|
+
copy.addEventListener('click', async () => {
|
|
421
|
+
try {
|
|
422
|
+
const text = await o.skill.copy();
|
|
423
|
+
await navigator.clipboard.writeText(text);
|
|
424
|
+
copy.textContent = t('Copied');
|
|
425
|
+
} catch { copy.textContent = t('Could not copy'); }
|
|
426
|
+
setTimeout(() => { copy.textContent = t('Copy skill'); }, 2200);
|
|
427
|
+
});
|
|
428
|
+
if (o.skill.about) {
|
|
429
|
+
const how = el('button', 'linky', t('How it works'));
|
|
430
|
+
how.type = 'button';
|
|
431
|
+
how.addEventListener('click', () => o.skill.about());
|
|
432
|
+
note.append(' ', how);
|
|
433
|
+
}
|
|
434
|
+
about.addEventListener('click', () => { note.hidden = !note.hidden; });
|
|
435
|
+
root.append(line, note);
|
|
436
|
+
}
|
|
437
|
+
root.append(fileEl);
|
|
438
|
+
const rowAlso = o.also && o.also.change ? { label: o.also.change, onClick: o.also.onClick } : null;
|
|
439
|
+
const file = Kit.fileRow(fileEl, { icon: o.icon, onChange: o.onChoose, also: rowAlso, changeLabel: o.changeLabel });
|
|
440
|
+
|
|
441
|
+
btn.addEventListener('click', () => o.onChoose && o.onChoose());
|
|
442
|
+
for (const t of ['dragenter', 'dragover']) zone.addEventListener(t, (e) => { e.preventDefault(); zone.classList.add('over'); });
|
|
443
|
+
for (const t of ['dragleave', 'dragend']) zone.addEventListener(t, () => zone.classList.remove('over'));
|
|
444
|
+
zone.addEventListener('drop', (e) => { e.preventDefault(); zone.classList.remove('over'); if (o.onDrop) o.onDrop([...e.dataTransfer.files]); });
|
|
445
|
+
|
|
446
|
+
return {
|
|
447
|
+
landed(f) { err.textContent = ''; file.set(f); root.classList.add('landed'); },
|
|
448
|
+
reset() { file.clear(); root.classList.remove('landed'); },
|
|
449
|
+
// a file that could not be taken: said under the zone, in the tool's words
|
|
450
|
+
error(message) { err.textContent = message || ''; },
|
|
451
|
+
// light the zone while a file is held anywhere over the window (the tool's veil decides)
|
|
452
|
+
over(on) { zone.classList.toggle('over', Boolean(on)); },
|
|
453
|
+
buttons: { choose: btn, change: file.change, changeAlso: file.changeAlso, also },
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
})(window.Kit = window.Kit || {});
|
|
457
|
+
|
|
458
|
+
/* --- parts/settings.js --- */
|
|
459
|
+
/* kit part: the fields that need behaviour. A swatch's colour is set through
|
|
460
|
+
* the style object (--swatch), never a style attribute, which the policy blocks.
|
|
461
|
+
*
|
|
462
|
+
* Kit.segmented(el, ['JPEG', 'PNG'], { value: 'JPEG', onChange })
|
|
463
|
+
* Kit.range2(el, { min: 0, max: 100, from: 20, to: 80, step: 1, onChange([from, to]) })
|
|
464
|
+
* Kit.swatches(el, ['#ffffff', '#000000', '#ffd400'], { value, custom: true, onChange })
|
|
465
|
+
*/
|
|
466
|
+
(function (Kit) {
|
|
467
|
+
// Kit.t (parts/lang.js) when it is loaded; the English, with its {slots} filled, when not
|
|
468
|
+
const t = (s, v) => (Kit.t ? Kit.t(s, v) : String(s).replace(/\{(\w+)\}/g, (m, k) => (v && k in v ? String(v[k]) : m)));
|
|
469
|
+
Kit.segmented = function segmented(root, choices, { value, onChange } = {}) {
|
|
470
|
+
root.classList.add('k-seg');
|
|
471
|
+
root.setAttribute('role', 'group');
|
|
472
|
+
root.replaceChildren();
|
|
473
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-pressed', String(b.dataset.value === v)); };
|
|
474
|
+
for (const c of choices) {
|
|
475
|
+
const [v, label] = Array.isArray(c) ? c : [c, c];
|
|
476
|
+
const b = document.createElement('button');
|
|
477
|
+
b.type = 'button'; b.dataset.value = v; b.textContent = label;
|
|
478
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
479
|
+
root.append(b);
|
|
480
|
+
}
|
|
481
|
+
set(value === undefined ? (Array.isArray(choices[0]) ? choices[0][0] : choices[0]) : value);
|
|
482
|
+
return { set, get: () => [...root.children].find((b) => b.getAttribute('aria-pressed') === 'true')?.dataset.value };
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
Kit.range2 = function range2(root, { min = 0, max = 100, step = 1, from = min, to = max, onChange } = {}) {
|
|
486
|
+
root.classList.add('k-range2');
|
|
487
|
+
root.replaceChildren();
|
|
488
|
+
const track = document.createElement('div'); track.className = 'k-range2-track';
|
|
489
|
+
const fill = document.createElement('div'); fill.className = 'k-range2-fill';
|
|
490
|
+
track.append(fill);
|
|
491
|
+
const mk = (v) => { const i = document.createElement('input'); i.type = 'range'; i.min = min; i.max = max; i.step = step; i.value = v; return i; };
|
|
492
|
+
const a = mk(from), b = mk(to);
|
|
493
|
+
const paint = () => {
|
|
494
|
+
let x = Number(a.value), y = Number(b.value);
|
|
495
|
+
if (x > y) [x, y] = [y, x];
|
|
496
|
+
fill.style.setProperty('--from', ((x - min) / (max - min) * 100) + '%');
|
|
497
|
+
fill.style.setProperty('--to', ((y - min) / (max - min) * 100) + '%');
|
|
498
|
+
return [x, y];
|
|
499
|
+
};
|
|
500
|
+
for (const i of [a, b]) i.addEventListener('input', () => { const v = paint(); if (onChange) onChange(v); });
|
|
501
|
+
root.append(track, a, b);
|
|
502
|
+
paint();
|
|
503
|
+
return { get: paint };
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
Kit.swatches = function swatches(root, colours, { value, custom = false, onChange } = {}) {
|
|
507
|
+
root.classList.add('k-swatches');
|
|
508
|
+
root.replaceChildren();
|
|
509
|
+
const set = (v) => { for (const s of root.children) s.setAttribute('aria-pressed', String(s.dataset.value === v)); };
|
|
510
|
+
const add = (c, isCustom) => {
|
|
511
|
+
const s = document.createElement('button');
|
|
512
|
+
s.type = 'button'; s.className = 'k-swatch' + (isCustom ? ' k-swatch-custom' : '');
|
|
513
|
+
s.dataset.value = c; s.style.setProperty('--swatch', c); s.setAttribute('aria-label', isCustom ? t('Another colour') : c);
|
|
514
|
+
if (isCustom) {
|
|
515
|
+
const i = document.createElement('input'); i.type = 'color'; i.value = c;
|
|
516
|
+
i.addEventListener('input', () => { s.dataset.value = i.value; s.style.setProperty('--swatch', i.value); set(i.value); if (onChange) onChange(i.value); });
|
|
517
|
+
s.append(i);
|
|
518
|
+
} else {
|
|
519
|
+
s.addEventListener('click', () => { set(c); if (onChange) onChange(c); });
|
|
520
|
+
}
|
|
521
|
+
root.append(s);
|
|
522
|
+
};
|
|
523
|
+
for (const c of colours) add(c, false);
|
|
524
|
+
if (custom) add(value && !colours.includes(value) ? value : '#888888', true);
|
|
525
|
+
set(value === undefined ? colours[0] : value);
|
|
526
|
+
return { set };
|
|
527
|
+
};
|
|
528
|
+
})(window.Kit = window.Kit || {});
|
|
529
|
+
|
|
530
|
+
/* --- parts/controls.js --- */
|
|
531
|
+
/* kit part: behaviour for chips, the bipolar slider, the reveal group and the
|
|
532
|
+
* 3x3 grid.
|
|
533
|
+
*
|
|
534
|
+
* Kit.chips(el, [['soft', 'Soft'], ['bold', 'Bold']], { value, onChange })
|
|
535
|
+
* Kit.bipolar(el, { min: -100, max: 100, value: 0, onChange })
|
|
536
|
+
* Kit.reveal(checkboxEl, groupEl) shows the group while it's ticked
|
|
537
|
+
* Kit.grid9(el, { value: 8, onChange }) 1..9 in numpad order, 8 = bottom middle
|
|
538
|
+
*/
|
|
539
|
+
(function (Kit) {
|
|
540
|
+
// Kit.t (parts/lang.js) when it is loaded; the English, with its {slots} filled, when not
|
|
541
|
+
const t = (s, v) => (Kit.t ? Kit.t(s, v) : String(s).replace(/\{(\w+)\}/g, (m, k) => (v && k in v ? String(v[k]) : m)));
|
|
542
|
+
Kit.chips = function chips(root, choices, { value, onChange } = {}) {
|
|
543
|
+
root.classList.add('k-chips');
|
|
544
|
+
root.replaceChildren();
|
|
545
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-pressed', String(b.dataset.value === v)); };
|
|
546
|
+
for (const c of choices) {
|
|
547
|
+
const [v, label] = Array.isArray(c) ? c : [c, c];
|
|
548
|
+
const b = document.createElement('button');
|
|
549
|
+
b.type = 'button'; b.dataset.value = v; b.textContent = label;
|
|
550
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
551
|
+
root.append(b);
|
|
552
|
+
}
|
|
553
|
+
if (value !== undefined) set(value);
|
|
554
|
+
return { set };
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
Kit.bipolar = function bipolar(root, { min = -100, max = 100, step = 1, value = 0, title, onChange } = {}) {
|
|
558
|
+
root.classList.add('k-bipolar');
|
|
559
|
+
root.replaceChildren();
|
|
560
|
+
const r = document.createElement('input');
|
|
561
|
+
r.type = 'range'; r.min = min; r.max = max; r.step = step; r.value = value;
|
|
562
|
+
r.title = title || t('Double-click to put it back to 0');
|
|
563
|
+
const pill = document.createElement('span'); pill.className = 'pill';
|
|
564
|
+
const show = () => { const v = Number(r.value); pill.textContent = v > 0 ? `+${v}` : String(v); };
|
|
565
|
+
r.addEventListener('input', () => { show(); if (onChange) onChange(Number(r.value)); });
|
|
566
|
+
r.addEventListener('dblclick', () => { r.value = 0; show(); if (onChange) onChange(0); });
|
|
567
|
+
root.append(r, pill);
|
|
568
|
+
show();
|
|
569
|
+
return { get: () => Number(r.value), set: (v) => { r.value = v; show(); } };
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
Kit.reveal = function reveal(box, group) {
|
|
573
|
+
const host = group.closest('.k-reveal') || group.parentElement;
|
|
574
|
+
host.classList.add('k-reveal');
|
|
575
|
+
group.classList.add('k-reveal-body');
|
|
576
|
+
const sync = () => host.classList.toggle('open', box.checked);
|
|
577
|
+
box.addEventListener('change', sync);
|
|
578
|
+
sync();
|
|
579
|
+
return { sync };
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const NAMES = () => ['', t('Bottom left'), t('Bottom middle'), t('Bottom right'), t('Middle left'), t('Centre'), t('Middle right'), t('Top left'), t('Top middle'), t('Top right')];
|
|
583
|
+
Kit.grid9 = function grid9(root, { value = 2, onChange } = {}) {
|
|
584
|
+
root.classList.add('k-grid9');
|
|
585
|
+
root.replaceChildren();
|
|
586
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-pressed', String(Number(b.dataset.value) === v)); };
|
|
587
|
+
for (const v of [7, 8, 9, 4, 5, 6, 1, 2, 3]) {
|
|
588
|
+
const b = document.createElement('button');
|
|
589
|
+
b.type = 'button'; b.dataset.value = v; const said = NAMES()[v]; b.title = said; b.setAttribute('aria-label', said);
|
|
590
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
591
|
+
root.append(b);
|
|
592
|
+
}
|
|
593
|
+
set(value);
|
|
594
|
+
return { set };
|
|
595
|
+
};
|
|
596
|
+
})(window.Kit = window.Kit || {});
|
|
597
|
+
|
|
598
|
+
/* --- parts/overlays.js --- */
|
|
599
|
+
/* kit part: tabs and the popup menu. Dialogs need no script: a <dialog
|
|
600
|
+
* class="k-dialog"> with showModal() and close().
|
|
601
|
+
*
|
|
602
|
+
* Kit.tabs(el, [['tools', 'Tools'], ['flows', 'Workflows']], { value, onChange })
|
|
603
|
+
* const m = Kit.menu([{ value: 'fade', label: 'Fade', icon: 'layers' }], { value, onPick })
|
|
604
|
+
* m.openAt(anchorEl) // { above: true } opens upwards
|
|
605
|
+
* items may end with { label, onClick } actions (under a line, not choices)
|
|
606
|
+
*/
|
|
607
|
+
(function (Kit) {
|
|
608
|
+
Kit.tabs = function tabs(root, choices, { value, onChange } = {}) {
|
|
609
|
+
root.classList.add('k-tabs');
|
|
610
|
+
root.setAttribute('role', 'tablist');
|
|
611
|
+
root.replaceChildren();
|
|
612
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-selected', String(b.dataset.value === v)); };
|
|
613
|
+
for (const [v, label, icon] of choices) {
|
|
614
|
+
const b = document.createElement('button');
|
|
615
|
+
b.type = 'button'; b.setAttribute('role', 'tab'); b.dataset.value = v;
|
|
616
|
+
if (icon) b.append(Kit.icon(icon));
|
|
617
|
+
b.append(label);
|
|
618
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
619
|
+
root.append(b);
|
|
620
|
+
}
|
|
621
|
+
set(value === undefined ? choices[0][0] : value);
|
|
622
|
+
return { set };
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
Kit.menu = function menu(items, { value, onPick } = {}) {
|
|
626
|
+
const root = document.createElement('div');
|
|
627
|
+
root.className = 'k-menu'; root.setAttribute('role', 'menu'); root.hidden = true;
|
|
628
|
+
for (const it of items) {
|
|
629
|
+
// an item with onClick is an action under a line, not a choice (the
|
|
630
|
+
// language menu's "Spot a mistake?")
|
|
631
|
+
if (it.onClick) {
|
|
632
|
+
const a = document.createElement('button');
|
|
633
|
+
a.type = 'button'; a.setAttribute('role', 'menuitem'); a.className = 'k-menu-action';
|
|
634
|
+
if (it.icon) a.append(Kit.icon(it.icon));
|
|
635
|
+
a.append(it.label);
|
|
636
|
+
a.addEventListener('click', () => { close(); it.onClick(); });
|
|
637
|
+
root.append(a);
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
const b = document.createElement('button');
|
|
641
|
+
b.type = 'button'; b.setAttribute('role', 'menuitemradio'); b.dataset.value = it.value;
|
|
642
|
+
b.setAttribute('aria-checked', String(it.value === value));
|
|
643
|
+
if (it.icon) b.append(Kit.icon(it.icon));
|
|
644
|
+
b.append(it.label);
|
|
645
|
+
b.addEventListener('click', () => {
|
|
646
|
+
for (const o of root.querySelectorAll('[role="menuitemradio"]')) o.setAttribute('aria-checked', String(o === b));
|
|
647
|
+
close(); if (onPick) onPick(it.value);
|
|
648
|
+
});
|
|
649
|
+
root.append(b);
|
|
650
|
+
}
|
|
651
|
+
document.body.append(root);
|
|
652
|
+
const close = () => { root.hidden = true; };
|
|
653
|
+
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') close(); });
|
|
654
|
+
document.addEventListener('pointerdown', (e) => { if (!root.hidden && !root.contains(e.target)) close(); });
|
|
655
|
+
return {
|
|
656
|
+
// above: open upwards, for a control at the foot of the window (the footer)
|
|
657
|
+
openAt(anchor, { above = false } = {}) {
|
|
658
|
+
const r = anchor.getBoundingClientRect();
|
|
659
|
+
root.style.setProperty('--x', `${Math.round(Math.min(r.left, innerWidth - 200))}px`);
|
|
660
|
+
root.style.setProperty('--y', `${Math.round(r.bottom + 6)}px`);
|
|
661
|
+
root.hidden = false;
|
|
662
|
+
if (above) root.style.setProperty('--y', `${Math.round(Math.max(6, r.top - root.offsetHeight - 6))}px`);
|
|
663
|
+
root.querySelector('[aria-checked="true"]')?.focus();
|
|
664
|
+
},
|
|
665
|
+
close,
|
|
666
|
+
};
|
|
667
|
+
};
|
|
668
|
+
})(window.Kit = window.Kit || {});
|
|
669
|
+
|
|
670
|
+
/* --- parts/run.js --- */
|
|
671
|
+
/*
|
|
672
|
+
* kit part: what happens under the main button in every Just tool (decided 2026-11-18):
|
|
673
|
+
* working, the queue, done and failed, the same in every tool, with the tool's
|
|
674
|
+
* own words and numbers in its slots.
|
|
675
|
+
*
|
|
676
|
+
* const run = Kit.run(document.getElementById('run'), {
|
|
677
|
+
* onCancel, onReveal, onAgain, onRetry,
|
|
678
|
+
* });
|
|
679
|
+
* run.working({ what: 'Converting to JPEG', count: '58 of 120', fraction: 0.48,
|
|
680
|
+
* file: 'IMG_4580.HEIC', left: 'About 9 seconds left' });
|
|
681
|
+
* run.working({ what: 'First pass', unknown: true }); // a step whose length can't be known:
|
|
682
|
+
* run.working({ what, unknown: true, note: 'A tar is read through once first.' }); // a sentence that wraps
|
|
683
|
+
* // the bar sweeps instead of sitting still
|
|
684
|
+
* run.queue([{ name: 'IMG_4403.HEIC', state: 'done' }, { name: 'IMG_4511.HEIC', state: 'failed', note: 'Not a photo' }]);
|
|
685
|
+
* run.done({ title: 'Done. 120 photos converted', detail: '21.4 MB of JPEG in 20 seconds',
|
|
686
|
+
* where: 'Saved next to the originals in Beach vacation' });
|
|
687
|
+
* run.failed('There is already a file with that name. Pick another name.');
|
|
688
|
+
* run.reset();
|
|
689
|
+
*
|
|
690
|
+
* Before a run, the estimate goes above the main button (.k-note), never
|
|
691
|
+
* in here: in here is only what happens once the button is pressed.
|
|
692
|
+
*/
|
|
693
|
+
(function (Kit) {
|
|
694
|
+
// Kit.t (parts/lang.js) when it is loaded; the English, with its {slots} filled, when not
|
|
695
|
+
const t = (s, v) => (Kit.t ? Kit.t(s, v) : String(s).replace(/\{(\w+)\}/g, (m, k) => (v && k in v ? String(v[k]) : m)));
|
|
696
|
+
// the queue's marks are kit icons: waiting, working, check (done), close (failed)
|
|
697
|
+
const mark = (state) => Kit.icon({ waiting: 'waiting', working: 'working', done: 'check', failed: 'close' }[state] || 'waiting', { cls: 'k-q-mark' });
|
|
698
|
+
const el = (tag, cls, text) => {
|
|
699
|
+
const n = document.createElement(tag);
|
|
700
|
+
if (cls) n.className = cls;
|
|
701
|
+
if (text !== undefined) n.textContent = text;
|
|
702
|
+
return n;
|
|
703
|
+
};
|
|
704
|
+
const button = (cls, text, fn) => {
|
|
705
|
+
const b = el('button', cls, text);
|
|
706
|
+
b.type = 'button';
|
|
707
|
+
if (fn) b.addEventListener('click', fn);
|
|
708
|
+
return b;
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
function mount(root, o = {}) {
|
|
712
|
+
root.classList.add('k-run');
|
|
713
|
+
root.replaceChildren();
|
|
714
|
+
// onState(state): told whenever the part changes state (idle, working, done, failed);
|
|
715
|
+
// the parent also carries it as data-run-state, so a tool's CSS can follow
|
|
716
|
+
const setState = (st) => { root.dataset.state = st; if (root.parentElement) root.parentElement.dataset.runState = st; if (o.onState) o.onState(st); };
|
|
717
|
+
root.dataset.state = 'idle';
|
|
718
|
+
|
|
719
|
+
const working = el('section', 'k-run-working');
|
|
720
|
+
const bar = el('div', 'k-run-bar');
|
|
721
|
+
const fill = el('span', 'k-run-fill');
|
|
722
|
+
bar.append(fill);
|
|
723
|
+
const line = el('p', 'k-run-line');
|
|
724
|
+
const what = el('span', 'k-run-what');
|
|
725
|
+
const count = el('span', 'k-run-count');
|
|
726
|
+
line.append(what, count);
|
|
727
|
+
const sub = el('p', 'k-run-sub');
|
|
728
|
+
const file = el('span', 'k-run-file');
|
|
729
|
+
const left = el('span', 'k-run-left');
|
|
730
|
+
sub.append(file, left);
|
|
731
|
+
// a sentence about the step (why it can't be measured yet): wraps, in the
|
|
732
|
+
// page's font, so a longer language is never cut off
|
|
733
|
+
const note = el('p', 'k-run-note');
|
|
734
|
+
const cancel = button('btn btn-ghost btn-tight k-run-cancel', t('Cancel'), o.onCancel);
|
|
735
|
+
working.append(bar, line, sub, note, cancel);
|
|
736
|
+
|
|
737
|
+
const queueBox = el('section', 'k-run-queue');
|
|
738
|
+
const list = el('ol');
|
|
739
|
+
queueBox.append(list);
|
|
740
|
+
|
|
741
|
+
const done = el('section', 'k-run-done');
|
|
742
|
+
const title = el('p', 'k-run-done-title');
|
|
743
|
+
const detail = el('p', 'k-run-done-detail');
|
|
744
|
+
const where = el('p', 'k-run-done-where');
|
|
745
|
+
const actions = el('div', 'k-run-done-actions');
|
|
746
|
+
const reveal = button('btn btn-ghost', t('Show me the file'), o.onReveal);
|
|
747
|
+
const again = button('linky', t('Start again'), o.onAgain);
|
|
748
|
+
actions.append(reveal, again);
|
|
749
|
+
done.append(title, detail, where, actions);
|
|
750
|
+
|
|
751
|
+
const failed = el('section', 'k-run-failed');
|
|
752
|
+
const err = el('p', 'k-error');
|
|
753
|
+
const retry = button('btn btn-ghost', t('Try again'), o.onRetry);
|
|
754
|
+
failed.append(err, retry);
|
|
755
|
+
|
|
756
|
+
root.append(working, queueBox, done, failed);
|
|
757
|
+
|
|
758
|
+
return {
|
|
759
|
+
// unknown: true (or a fraction of null) while a step's length can't be
|
|
760
|
+
// known (Fits' first pass on a slow machine): the bar sweeps, so it is
|
|
761
|
+
// plain that something is happening, and stops sweeping as soon as a
|
|
762
|
+
// real fraction comes in (decided 2026-11-20).
|
|
763
|
+
working({ what: w = t('Working'), count: c = '', fraction = 0, unknown = false, file: f = '', left: l = '', note: n = '' } = {}) {
|
|
764
|
+
setState('working');
|
|
765
|
+
note.textContent = n;
|
|
766
|
+
note.hidden = !n;
|
|
767
|
+
what.textContent = w;
|
|
768
|
+
count.textContent = c;
|
|
769
|
+
file.textContent = f;
|
|
770
|
+
left.textContent = l;
|
|
771
|
+
const sweep = unknown || fraction === null;
|
|
772
|
+
bar.classList.toggle('unknown', sweep);
|
|
773
|
+
if (sweep) { bar.setAttribute('aria-busy', 'true'); fill.style.width = ''; return; }
|
|
774
|
+
bar.removeAttribute('aria-busy');
|
|
775
|
+
fill.style.width = `${Math.round(Math.max(0, Math.min(1, fraction)) * 1000) / 10}%`;
|
|
776
|
+
},
|
|
777
|
+
queue(items = []) {
|
|
778
|
+
list.replaceChildren(...items.map((it) => {
|
|
779
|
+
const li = el('li');
|
|
780
|
+
li.dataset.q = it.state || 'waiting';
|
|
781
|
+
li.append(mark(li.dataset.q), el('span', 'k-q-name', it.name));
|
|
782
|
+
if (it.note) li.append(el('span', 'k-q-note', it.note));
|
|
783
|
+
return li;
|
|
784
|
+
}));
|
|
785
|
+
queueBox.classList.toggle('has', items.length > 0);
|
|
786
|
+
// keep the row being worked on in view, so a long queue follows the run
|
|
787
|
+
const at = list.querySelector('[data-q="working"]');
|
|
788
|
+
if (at) queueBox.scrollTop = Math.max(0, at.offsetTop - queueBox.clientHeight / 2);
|
|
789
|
+
},
|
|
790
|
+
// reveal: false when there is no file to show (it already fitted, it was
|
|
791
|
+
// stopped); tone: 'over' when it did not get all the way
|
|
792
|
+
// revealLabel: 'Show me the folder' when what it shows is a results folder.
|
|
793
|
+
done({ title: ti = t('Done.'), detail: d = '', where: w = '', reveal: showReveal = true, revealLabel = t('Show me the file'), tone = '' } = {}) {
|
|
794
|
+
setState('done');
|
|
795
|
+
reveal.hidden = !showReveal;
|
|
796
|
+
reveal.textContent = revealLabel;
|
|
797
|
+
done.classList.toggle('over', tone === 'over');
|
|
798
|
+
title.textContent = ti;
|
|
799
|
+
detail.textContent = d;
|
|
800
|
+
where.textContent = w;
|
|
801
|
+
},
|
|
802
|
+
failed(message) {
|
|
803
|
+
setState('failed');
|
|
804
|
+
err.textContent = message;
|
|
805
|
+
},
|
|
806
|
+
// the parts' own buttons, for a tool that needs to label or test them
|
|
807
|
+
buttons: { cancel, reveal, again, retry },
|
|
808
|
+
reset() { setState('idle'); list.replaceChildren(); queueBox.classList.remove('has'); bar.classList.remove('unknown'); bar.removeAttribute('aria-busy'); fill.style.width = '0%'; },
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
Kit.run = mount;
|
|
813
|
+
})(window.Kit = window.Kit || {});
|
|
814
|
+
|
|
815
|
+
/* --- parts/veil.js --- */
|
|
816
|
+
/* kit part: the drag veil.
|
|
817
|
+
*
|
|
818
|
+
* const veil = Kit.veil({ say: 'Drop to add to the tray', icon: 'plus', onDrop(files) {} });
|
|
819
|
+
* veil.say('Drop to replace the video'); // when where it goes changes
|
|
820
|
+
*/
|
|
821
|
+
(function (Kit) {
|
|
822
|
+
// Kit.t (parts/lang.js) when it is loaded; the English, with its {slots} filled, when not
|
|
823
|
+
const t = (s, v) => (Kit.t ? Kit.t(s, v) : String(s).replace(/\{(\w+)\}/g, (m, k) => (v && k in v ? String(v[k]) : m)));
|
|
824
|
+
// say: a sentence, or a function giving it when the drag starts (it can follow the screen)
|
|
825
|
+
// when: a function; while it returns false (a run is going) there is no veil and no drop
|
|
826
|
+
// onOver(on): told when a file comes over the window and leaves it (to light a start zone)
|
|
827
|
+
Kit.veil = function veil({ say = t('Drop it here'), icon = 'plus', onDrop, when = () => true, onOver } = {}) {
|
|
828
|
+
const root = document.createElement('div');
|
|
829
|
+
root.className = 'k-veil'; root.hidden = true;
|
|
830
|
+
const p = document.createElement('p');
|
|
831
|
+
const text = document.createElement('span');
|
|
832
|
+
p.append(Kit.icon(icon), text);
|
|
833
|
+
root.append(p);
|
|
834
|
+
document.body.append(root);
|
|
835
|
+
let depth = 0;
|
|
836
|
+
const words = () => (typeof say === 'function' ? say() : say);
|
|
837
|
+
const hasFiles = (e) => e.dataTransfer && [...e.dataTransfer.types].includes('Files');
|
|
838
|
+
const show = (on) => { root.hidden = !on; if (onOver) onOver(on); };
|
|
839
|
+
window.addEventListener('dragenter', (e) => {
|
|
840
|
+
if (!hasFiles(e)) return;
|
|
841
|
+
depth++;
|
|
842
|
+
if (depth === 1 && when()) { text.textContent = words(); show(true); }
|
|
843
|
+
});
|
|
844
|
+
window.addEventListener('dragleave', () => { depth = Math.max(0, depth - 1); if (!depth) show(false); });
|
|
845
|
+
window.addEventListener('dragover', (e) => {
|
|
846
|
+
if (!hasFiles(e)) return;
|
|
847
|
+
e.preventDefault();
|
|
848
|
+
e.dataTransfer.dropEffect = when() ? 'copy' : 'none';
|
|
849
|
+
});
|
|
850
|
+
window.addEventListener('drop', (e) => {
|
|
851
|
+
if (!hasFiles(e)) return;
|
|
852
|
+
e.preventDefault(); depth = 0; show(false);
|
|
853
|
+
if (when() && onDrop) onDrop([...e.dataTransfer.files]);
|
|
854
|
+
});
|
|
855
|
+
return { say(s) { say = s; text.textContent = words(); } };
|
|
856
|
+
};
|
|
857
|
+
})(window.Kit = window.Kit || {});
|
|
858
|
+
|
|
859
|
+
/* --- parts/footer.js --- */
|
|
860
|
+
/* kit part: the footer. The promise is the family's, word for word; a tool does
|
|
861
|
+
* not write its own (decided 2026-11-18).
|
|
862
|
+
*
|
|
863
|
+
* Kit.footer(document.querySelector('footer'), { onSite, onLicences })
|
|
864
|
+
*
|
|
865
|
+
* Three places (decided 2026-11-20): the licences on the left, the promise in
|
|
866
|
+
* the middle, the credit on the right. The version is not here: it is beside
|
|
867
|
+
* the name on the start screen (Kit.start), which every window shows.
|
|
868
|
+
*
|
|
869
|
+
* Beside the licences sits the language: the current one's name and
|
|
870
|
+
* a menu of the others, with "Machine translated. Spot a mistake?" under them
|
|
871
|
+
* when the window is in a machine-translated language.
|
|
872
|
+
*/
|
|
873
|
+
(function (Kit) {
|
|
874
|
+
// Kit.t (parts/lang.js) when it is loaded; the English, with its {slots} filled, when not
|
|
875
|
+
const t = (s, v) => (Kit.t ? Kit.t(s, v) : String(s).replace(/\{(\w+)\}/g, (m, k) => (v && k in v ? String(v[k]) : m)));
|
|
876
|
+
Kit.PROMISE = 'Nothing is uploaded, and your originals are never touched.';
|
|
877
|
+
// promise: only for a tool whose truth is different, one that talks to a
|
|
878
|
+
// network by design (Clipboard, the Tool Belt's updates); everyone else says
|
|
879
|
+
// the family's words, word for word.
|
|
880
|
+
Kit.footer = function footer(root, { onSite, onLicences, promise } = {}) {
|
|
881
|
+
root.classList.add('k-footer');
|
|
882
|
+
root.replaceChildren();
|
|
883
|
+
const lic = document.createElement('button');
|
|
884
|
+
lic.type = 'button'; lic.id = 'licences'; lic.className = 'k-footer-licences'; lic.textContent = t('Licences and credits');
|
|
885
|
+
const promiseEl = document.createElement('span');
|
|
886
|
+
promiseEl.className = 'k-footer-promise';
|
|
887
|
+
promiseEl.textContent = promise || t('Nothing is uploaded, and your originals are never touched.');
|
|
888
|
+
const site = document.createElement('button');
|
|
889
|
+
site.type = 'button'; site.id = 'site'; site.className = 'k-footer-credit';
|
|
890
|
+
const mark = document.createElement('span'); mark.className = 'k-mark';
|
|
891
|
+
const dev = document.createElement('b'); dev.textContent = 'Dev';
|
|
892
|
+
mark.append('Ponder', dev);
|
|
893
|
+
site.append(t('Powered by') + ' ', mark);
|
|
894
|
+
if (onSite) site.addEventListener('click', onSite);
|
|
895
|
+
if (onLicences) lic.addEventListener('click', onLicences);
|
|
896
|
+
// The language, beside the licences: its own name, in its own
|
|
897
|
+
// language, so a person who cannot read the current one still finds theirs.
|
|
898
|
+
const left = document.createElement('span');
|
|
899
|
+
left.className = 'k-footer-start';
|
|
900
|
+
left.append(lic);
|
|
901
|
+
const offered = Kit.offered ? Kit.offered() : [];
|
|
902
|
+
if (offered.length > 1) {
|
|
903
|
+
const lang = document.createElement('button');
|
|
904
|
+
lang.type = 'button'; lang.id = 'language'; lang.className = 'k-footer-lang';
|
|
905
|
+
lang.setAttribute('aria-haspopup', 'menu');
|
|
906
|
+
lang.title = t('Language');
|
|
907
|
+
const name = (offered.find(([c]) => c === Kit.lang) || offered[0])[1];
|
|
908
|
+
lang.append(Kit.icon('language'), name);
|
|
909
|
+
const items = offered.map(([value, label]) => ({ value, label }));
|
|
910
|
+
if (Kit.machine && Kit.machine()) items.push({ label: t('Machine translated. Spot a mistake?'), onClick: () => Kit.reportMistake() });
|
|
911
|
+
const menu = Kit.menu(items, { value: Kit.lang, onPick: (code) => Kit.chooseLanguage(code) });
|
|
912
|
+
lang.addEventListener('click', () => { if (!Kit.languageBusy()) menu.openAt(lang, { above: true }); });
|
|
913
|
+
left.append(lang);
|
|
914
|
+
}
|
|
915
|
+
root.append(left, promiseEl, site);
|
|
916
|
+
};
|
|
917
|
+
})(window.Kit = window.Kit || {});
|
|
918
|
+
|
|
919
|
+
/* --- parts/store.js --- */
|
|
920
|
+
/* kit part: the settings store. Every setting a tool keeps between sessions
|
|
921
|
+
* goes through here, so every tool follows one rule (decided 2026-11-19):
|
|
922
|
+
*
|
|
923
|
+
* Two versions of a tool can be installed side by side, and they share one
|
|
924
|
+
* store (the same app id, the same storage). So a version keeps every key it
|
|
925
|
+
* does not know, and never drops one or fails on one. A newer version's keys
|
|
926
|
+
* ride along untouched when an older version saves, and an older version
|
|
927
|
+
* simply ignores them. A value of the wrong kind, or a store that cannot be
|
|
928
|
+
* read at all, falls back to the default; it never stops the tool.
|
|
929
|
+
*
|
|
930
|
+
* const settings = Kit.store('justcut', { removeWithoutAsking: false });
|
|
931
|
+
* settings.get('removeWithoutAsking'); // the saved value or the default
|
|
932
|
+
* settings.set('removeWithoutAsking', true); // writes this key, keeps the rest
|
|
933
|
+
* settings.clear('removeWithoutAsking'); // back to the default
|
|
934
|
+
*
|
|
935
|
+
* A key's meaning never changes: a setting that needs a new meaning takes a new
|
|
936
|
+
* name, and the old key stays for the versions that read it.
|
|
937
|
+
*
|
|
938
|
+
* A setting a tool kept under its own key before the kit (Just Cut's
|
|
939
|
+
* 'justcut.removeWithoutAsking' = '1') is carried over once:
|
|
940
|
+
*
|
|
941
|
+
* settings.adopt('justcut.removeWithoutAsking', 'removeWithoutAsking', (raw) => raw === '1');
|
|
942
|
+
*
|
|
943
|
+
* When the store has no value for the key yet and the old key is there, its
|
|
944
|
+
* value is read through the function and saved. Either way the old key is
|
|
945
|
+
* noted as adopted, so it is never read again: a person who later turns the
|
|
946
|
+
* setting back off is not overruled by the old key, which stays where it was
|
|
947
|
+
* for the older version that reads it.
|
|
948
|
+
*/
|
|
949
|
+
(function (Kit) {
|
|
950
|
+
const isPlain = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
951
|
+
const kindOf = (v) => (Array.isArray(v) ? 'array' : v === null ? 'null' : typeof v);
|
|
952
|
+
|
|
953
|
+
Kit.store = function store(name, defaults = {}, storage) {
|
|
954
|
+
const key = name + '.settings';
|
|
955
|
+
const box = () => storage || window.localStorage;
|
|
956
|
+
// Everything saved, known keys or not. Never throws.
|
|
957
|
+
function all() {
|
|
958
|
+
try {
|
|
959
|
+
const raw = box().getItem(key);
|
|
960
|
+
if (!raw) return {};
|
|
961
|
+
const saved = JSON.parse(raw);
|
|
962
|
+
return isPlain(saved) ? saved : {};
|
|
963
|
+
} catch (e) { return {}; }
|
|
964
|
+
}
|
|
965
|
+
function write(saved) {
|
|
966
|
+
try { box().setItem(key, JSON.stringify(saved)); return true; } catch (e) { return false; }
|
|
967
|
+
}
|
|
968
|
+
return {
|
|
969
|
+
// A saved value of a different kind than its default is ignored: an older
|
|
970
|
+
// or newer version may have meant something else by it.
|
|
971
|
+
get(k) {
|
|
972
|
+
const saved = all();
|
|
973
|
+
if (!Object.prototype.hasOwnProperty.call(saved, k)) return defaults[k];
|
|
974
|
+
if (k in defaults && kindOf(saved[k]) !== kindOf(defaults[k])) return defaults[k];
|
|
975
|
+
return saved[k];
|
|
976
|
+
},
|
|
977
|
+
// Writes one key on top of everything saved, so keys this version does
|
|
978
|
+
// not know survive. Returns false when the store cannot be written.
|
|
979
|
+
set(k, v) { const saved = all(); saved[k] = v; return write(saved); },
|
|
980
|
+
clear(k) { const saved = all(); delete saved[k]; return write(saved); },
|
|
981
|
+
adopt(oldKey, k, read = (raw) => raw) {
|
|
982
|
+
const saved = all();
|
|
983
|
+
const done = Array.isArray(saved._adopted) ? saved._adopted : [];
|
|
984
|
+
if (done.includes(oldKey)) return false;
|
|
985
|
+
let raw = null;
|
|
986
|
+
try { raw = box().getItem(oldKey); } catch (e) { return false; }
|
|
987
|
+
let took = false;
|
|
988
|
+
if (raw !== null && !Object.prototype.hasOwnProperty.call(saved, k)) {
|
|
989
|
+
try { saved[k] = read(raw); took = true; } catch (e) { /* unreadable: the default stands */ }
|
|
990
|
+
}
|
|
991
|
+
saved._adopted = done.concat(oldKey);
|
|
992
|
+
write(saved);
|
|
993
|
+
return took;
|
|
994
|
+
},
|
|
995
|
+
};
|
|
996
|
+
};
|
|
997
|
+
})(window.Kit = window.Kit || {});
|
|
998
|
+
|
|
999
|
+
/* --- parts/family.js --- */
|
|
1000
|
+
/* kit part: family hints. The tools are separate, and they complete
|
|
1001
|
+
* each other: when a tool is handed something a sibling does, it says so in
|
|
1002
|
+
* one line and offers that sibling's page (decided 2026-11-24).
|
|
1003
|
+
*
|
|
1004
|
+
* const hint = Kit.hint(document.getElementById('hint'), { open: api.openSibling });
|
|
1005
|
+
* hint.show('justzip', t('Just Fits shrinks videos and pictures. To send this as it is, Just Zip packs it into one file.'));
|
|
1006
|
+
* hint.clear();
|
|
1007
|
+
* Kit.kindOf('report.pdf') // 'document'
|
|
1008
|
+
*
|
|
1009
|
+
* The button says "Try Just Zip" and asks the main side to open that tool's
|
|
1010
|
+
* page on ponderdev.com (src/kit/family.cjs): the page never hands over an
|
|
1011
|
+
* address, only a tool's id from the family list, so nothing else can open.
|
|
1012
|
+
*/
|
|
1013
|
+
(function (Kit) {
|
|
1014
|
+
// Kit.t (parts/lang.js) when it is loaded; the English, with its {slots} filled, when not
|
|
1015
|
+
const t = (s, v) => (Kit.t ? Kit.t(s, v) : String(s).replace(/\{(\w+)\}/g, (m, k) => (v && k in v ? String(v[k]) : m)));
|
|
1016
|
+
|
|
1017
|
+
// The released tools a hint may point to, by id. A tool joins when it ships.
|
|
1018
|
+
Kit.FAMILY = { justzip: 'Just Zip', justfits: 'Just Fits', justjpeg: 'Just JPEG', justcut: 'Just Cut' };
|
|
1019
|
+
|
|
1020
|
+
// What kind of thing a file is, from its name alone, the same in every tool.
|
|
1021
|
+
const KINDS = {
|
|
1022
|
+
video: ['mp4', 'mov', 'm4v', 'mkv', 'webm', 'avi', 'wmv', 'flv', 'mpg', 'mpeg', '3gp', 'mts', 'm2ts'],
|
|
1023
|
+
heic: ['heic', 'heif', 'hif'],
|
|
1024
|
+
picture: ['jpg', 'jpeg', 'png', 'webp', 'gif', 'tif', 'tiff', 'bmp', 'avif'],
|
|
1025
|
+
raw: ['dng', 'cr2', 'cr3', 'nef', 'arw', 'orf', 'rw2', 'raf', 'srw', 'pef'],
|
|
1026
|
+
audio: ['mp3', 'm4a', 'wav', 'aac', 'flac', 'ogg', 'opus', 'aiff', 'aif'],
|
|
1027
|
+
archive: ['zip', 'tar', 'gz', 'tgz', '7z', 'rar', 'xz', 'bz2'],
|
|
1028
|
+
document: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp', 'rtf', 'txt', 'csv', 'pages', 'numbers', 'key', 'epub'],
|
|
1029
|
+
};
|
|
1030
|
+
Kit.kindOf = function kindOf(name) {
|
|
1031
|
+
const ext = String(name || '').toLowerCase().split(/[\\/]/).pop().split('.').slice(1).pop() || '';
|
|
1032
|
+
for (const [kind, list] of Object.entries(KINDS)) if (list.includes(ext)) return kind;
|
|
1033
|
+
return 'other';
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
Kit.hint = function hint(root, { open } = {}) {
|
|
1037
|
+
root.classList.add('k-hint');
|
|
1038
|
+
root.hidden = true;
|
|
1039
|
+
return {
|
|
1040
|
+
show(id, say) {
|
|
1041
|
+
const name = Kit.FAMILY[id];
|
|
1042
|
+
if (!name || !say) { root.hidden = true; return; }
|
|
1043
|
+
root.replaceChildren();
|
|
1044
|
+
const text = document.createElement('span');
|
|
1045
|
+
text.textContent = say;
|
|
1046
|
+
const go = document.createElement('button');
|
|
1047
|
+
go.type = 'button'; go.className = 'linky k-hint-go'; go.dataset.sibling = id;
|
|
1048
|
+
go.textContent = t('Try {name}', { name });
|
|
1049
|
+
go.addEventListener('click', () => { if (open) open(id); });
|
|
1050
|
+
root.append(Kit.icon('info'), text, go);
|
|
1051
|
+
root.hidden = false;
|
|
1052
|
+
},
|
|
1053
|
+
clear() { root.hidden = true; root.replaceChildren(); },
|
|
1054
|
+
};
|
|
1055
|
+
};
|
|
1056
|
+
})(window.Kit = window.Kit || {});
|
|
1057
|
+
window.Kit.VERSION = '1.1.0';
|