@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/kit/kit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PonderDev kit 1.
|
|
1
|
+
/* PonderDev kit 1.1.0, built from kit/src. Do not edit: run bin/kit-sync. */
|
|
2
2
|
'use strict';
|
|
3
3
|
/* --- icons.js --- */
|
|
4
4
|
/* kit icons: one set, drawn once, used by name in every Just tool (decided
|
|
@@ -113,6 +113,209 @@
|
|
|
113
113
|
};
|
|
114
114
|
})(window.Kit = window.Kit || {});
|
|
115
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
|
+
|
|
116
319
|
/* --- parts/start.js --- */
|
|
117
320
|
/* kit part: the start screen (option A) and the file row.
|
|
118
321
|
*
|
|
@@ -130,19 +333,21 @@
|
|
|
130
333
|
* start.reset();
|
|
131
334
|
*/
|
|
132
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)));
|
|
133
338
|
const el = (tag, cls, text) => { const n = document.createElement(tag); if (cls) n.className = cls; if (text !== undefined) n.textContent = text; return n; };
|
|
134
339
|
|
|
135
340
|
// also: { label, onClick } a second way to change, beside Change (a folder,
|
|
136
341
|
// on Windows and Linux where one picker cannot take both); Change then reads
|
|
137
342
|
// changeLabel ('Change file').
|
|
138
|
-
Kit.fileRow = function fileRow(root, { icon = 'file', onChange, also, changeLabel
|
|
343
|
+
Kit.fileRow = function fileRow(root, { icon = 'file', onChange, also, changeLabel } = {}) {
|
|
139
344
|
root.classList.add('k-file');
|
|
140
345
|
root.replaceChildren();
|
|
141
346
|
const text = el('div', 'k-file-text');
|
|
142
347
|
const name = el('p', 'k-file-name');
|
|
143
348
|
const facts = el('p', 'k-file-facts');
|
|
144
349
|
text.append(name, facts);
|
|
145
|
-
const change = el('button', 'btn btn-ghost btn-tight', also ? changeLabel : 'Change');
|
|
350
|
+
const change = el('button', 'btn btn-ghost btn-tight', also ? (changeLabel || t('Change file')) : t('Change'));
|
|
146
351
|
change.type = 'button';
|
|
147
352
|
if (onChange) change.addEventListener('click', onChange);
|
|
148
353
|
let pic = Kit.icon(icon);
|
|
@@ -173,7 +378,7 @@
|
|
|
173
378
|
// the plain version (decided 2026-11-20).
|
|
174
379
|
Kit.versionLabel = function versionLabel(v) {
|
|
175
380
|
const m = /^(\d+\.\d+\.\d+)-./.exec(String(v || ''));
|
|
176
|
-
return m ?
|
|
381
|
+
return m ? t('{version} (pre-release)', { version: m[1] }) : String(v || '');
|
|
177
382
|
};
|
|
178
383
|
|
|
179
384
|
Kit.start = function start(root, o) {
|
|
@@ -185,7 +390,7 @@
|
|
|
185
390
|
if (o.version) title.append(el('span', 'k-version', Kit.versionLabel(o.version)));
|
|
186
391
|
head.append(title, el('p', 'sub', o.line));
|
|
187
392
|
const zone = el('section', 'k-zone');
|
|
188
|
-
const btn = el('button', 'btn btn-primary', o.choose || 'Choose a file');
|
|
393
|
+
const btn = el('button', 'btn btn-primary', o.choose || t('Choose a file'));
|
|
189
394
|
btn.type = 'button';
|
|
190
395
|
const err = el('p', 'k-error');
|
|
191
396
|
// also: a second way in, as a quieter button beside the first (Zip's "Open an archive")
|
|
@@ -204,24 +409,24 @@
|
|
|
204
409
|
// skill: { copy: async () => the tool's SKILL.md text, about: () => opens its how-it-works page }
|
|
205
410
|
if (o.skill) {
|
|
206
411
|
const line = el('p', 'k-skill');
|
|
207
|
-
const copy = el('button', 'linky', 'Copy skill');
|
|
412
|
+
const copy = el('button', 'linky', t('Copy skill'));
|
|
208
413
|
copy.type = 'button';
|
|
209
|
-
const about = el('button', 'linky', "What's this?");
|
|
414
|
+
const about = el('button', 'linky', t("What's this?"));
|
|
210
415
|
about.type = 'button';
|
|
211
416
|
const note = el('p', 'k-skill-about hint');
|
|
212
417
|
note.hidden = true;
|
|
213
|
-
note.textContent =
|
|
214
|
-
line.append('Use it with your assistant', el('span', 'k-skill-sep', '·'), copy, el('span', 'k-skill-sep', '·'), about);
|
|
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);
|
|
215
420
|
copy.addEventListener('click', async () => {
|
|
216
421
|
try {
|
|
217
422
|
const text = await o.skill.copy();
|
|
218
423
|
await navigator.clipboard.writeText(text);
|
|
219
|
-
copy.textContent = 'Copied';
|
|
220
|
-
} catch { copy.textContent = 'Could not copy'; }
|
|
221
|
-
setTimeout(() => { copy.textContent = 'Copy skill'; }, 2200);
|
|
424
|
+
copy.textContent = t('Copied');
|
|
425
|
+
} catch { copy.textContent = t('Could not copy'); }
|
|
426
|
+
setTimeout(() => { copy.textContent = t('Copy skill'); }, 2200);
|
|
222
427
|
});
|
|
223
428
|
if (o.skill.about) {
|
|
224
|
-
const how = el('button', 'linky', 'How it works');
|
|
429
|
+
const how = el('button', 'linky', t('How it works'));
|
|
225
430
|
how.type = 'button';
|
|
226
431
|
how.addEventListener('click', () => o.skill.about());
|
|
227
432
|
note.append(' ', how);
|
|
@@ -259,6 +464,8 @@
|
|
|
259
464
|
* Kit.swatches(el, ['#ffffff', '#000000', '#ffd400'], { value, custom: true, onChange })
|
|
260
465
|
*/
|
|
261
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)));
|
|
262
469
|
Kit.segmented = function segmented(root, choices, { value, onChange } = {}) {
|
|
263
470
|
root.classList.add('k-seg');
|
|
264
471
|
root.setAttribute('role', 'group');
|
|
@@ -303,7 +510,7 @@
|
|
|
303
510
|
const add = (c, isCustom) => {
|
|
304
511
|
const s = document.createElement('button');
|
|
305
512
|
s.type = 'button'; s.className = 'k-swatch' + (isCustom ? ' k-swatch-custom' : '');
|
|
306
|
-
s.dataset.value = c; s.style.setProperty('--swatch', c); s.setAttribute('aria-label', isCustom ? 'Another colour' : c);
|
|
513
|
+
s.dataset.value = c; s.style.setProperty('--swatch', c); s.setAttribute('aria-label', isCustom ? t('Another colour') : c);
|
|
307
514
|
if (isCustom) {
|
|
308
515
|
const i = document.createElement('input'); i.type = 'color'; i.value = c;
|
|
309
516
|
i.addEventListener('input', () => { s.dataset.value = i.value; s.style.setProperty('--swatch', i.value); set(i.value); if (onChange) onChange(i.value); });
|
|
@@ -330,6 +537,8 @@
|
|
|
330
537
|
* Kit.grid9(el, { value: 8, onChange }) 1..9 in numpad order, 8 = bottom middle
|
|
331
538
|
*/
|
|
332
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)));
|
|
333
542
|
Kit.chips = function chips(root, choices, { value, onChange } = {}) {
|
|
334
543
|
root.classList.add('k-chips');
|
|
335
544
|
root.replaceChildren();
|
|
@@ -350,7 +559,7 @@
|
|
|
350
559
|
root.replaceChildren();
|
|
351
560
|
const r = document.createElement('input');
|
|
352
561
|
r.type = 'range'; r.min = min; r.max = max; r.step = step; r.value = value;
|
|
353
|
-
r.title = title || 'Double-click to put it back to 0';
|
|
562
|
+
r.title = title || t('Double-click to put it back to 0');
|
|
354
563
|
const pill = document.createElement('span'); pill.className = 'pill';
|
|
355
564
|
const show = () => { const v = Number(r.value); pill.textContent = v > 0 ? `+${v}` : String(v); };
|
|
356
565
|
r.addEventListener('input', () => { show(); if (onChange) onChange(Number(r.value)); });
|
|
@@ -370,14 +579,14 @@
|
|
|
370
579
|
return { sync };
|
|
371
580
|
};
|
|
372
581
|
|
|
373
|
-
const NAMES = ['', 'Bottom left', 'Bottom middle', 'Bottom right', 'Middle left', 'Centre', 'Middle right', 'Top left', 'Top middle', 'Top right'];
|
|
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')];
|
|
374
583
|
Kit.grid9 = function grid9(root, { value = 2, onChange } = {}) {
|
|
375
584
|
root.classList.add('k-grid9');
|
|
376
585
|
root.replaceChildren();
|
|
377
586
|
const set = (v) => { for (const b of root.children) b.setAttribute('aria-pressed', String(Number(b.dataset.value) === v)); };
|
|
378
587
|
for (const v of [7, 8, 9, 4, 5, 6, 1, 2, 3]) {
|
|
379
588
|
const b = document.createElement('button');
|
|
380
|
-
b.type = 'button'; b.dataset.value = v;
|
|
589
|
+
b.type = 'button'; b.dataset.value = v; const said = NAMES()[v]; b.title = said; b.setAttribute('aria-label', said);
|
|
381
590
|
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
382
591
|
root.append(b);
|
|
383
592
|
}
|
|
@@ -392,7 +601,8 @@
|
|
|
392
601
|
*
|
|
393
602
|
* Kit.tabs(el, [['tools', 'Tools'], ['flows', 'Workflows']], { value, onChange })
|
|
394
603
|
* const m = Kit.menu([{ value: 'fade', label: 'Fade', icon: 'layers' }], { value, onPick })
|
|
395
|
-
* m.openAt(anchorEl)
|
|
604
|
+
* m.openAt(anchorEl) // { above: true } opens upwards
|
|
605
|
+
* items may end with { label, onClick } actions (under a line, not choices)
|
|
396
606
|
*/
|
|
397
607
|
(function (Kit) {
|
|
398
608
|
Kit.tabs = function tabs(root, choices, { value, onChange } = {}) {
|
|
@@ -416,13 +626,24 @@
|
|
|
416
626
|
const root = document.createElement('div');
|
|
417
627
|
root.className = 'k-menu'; root.setAttribute('role', 'menu'); root.hidden = true;
|
|
418
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
|
+
}
|
|
419
640
|
const b = document.createElement('button');
|
|
420
641
|
b.type = 'button'; b.setAttribute('role', 'menuitemradio'); b.dataset.value = it.value;
|
|
421
642
|
b.setAttribute('aria-checked', String(it.value === value));
|
|
422
643
|
if (it.icon) b.append(Kit.icon(it.icon));
|
|
423
644
|
b.append(it.label);
|
|
424
645
|
b.addEventListener('click', () => {
|
|
425
|
-
for (const o of root.
|
|
646
|
+
for (const o of root.querySelectorAll('[role="menuitemradio"]')) o.setAttribute('aria-checked', String(o === b));
|
|
426
647
|
close(); if (onPick) onPick(it.value);
|
|
427
648
|
});
|
|
428
649
|
root.append(b);
|
|
@@ -432,11 +653,13 @@
|
|
|
432
653
|
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') close(); });
|
|
433
654
|
document.addEventListener('pointerdown', (e) => { if (!root.hidden && !root.contains(e.target)) close(); });
|
|
434
655
|
return {
|
|
435
|
-
|
|
656
|
+
// above: open upwards, for a control at the foot of the window (the footer)
|
|
657
|
+
openAt(anchor, { above = false } = {}) {
|
|
436
658
|
const r = anchor.getBoundingClientRect();
|
|
437
659
|
root.style.setProperty('--x', `${Math.round(Math.min(r.left, innerWidth - 200))}px`);
|
|
438
660
|
root.style.setProperty('--y', `${Math.round(r.bottom + 6)}px`);
|
|
439
661
|
root.hidden = false;
|
|
662
|
+
if (above) root.style.setProperty('--y', `${Math.round(Math.max(6, r.top - root.offsetHeight - 6))}px`);
|
|
440
663
|
root.querySelector('[aria-checked="true"]')?.focus();
|
|
441
664
|
},
|
|
442
665
|
close,
|
|
@@ -456,6 +679,7 @@
|
|
|
456
679
|
* run.working({ what: 'Converting to JPEG', count: '58 of 120', fraction: 0.48,
|
|
457
680
|
* file: 'IMG_4580.HEIC', left: 'About 9 seconds left' });
|
|
458
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
|
|
459
683
|
* // the bar sweeps instead of sitting still
|
|
460
684
|
* run.queue([{ name: 'IMG_4403.HEIC', state: 'done' }, { name: 'IMG_4511.HEIC', state: 'failed', note: 'Not a photo' }]);
|
|
461
685
|
* run.done({ title: 'Done. 120 photos converted', detail: '21.4 MB of JPEG in 20 seconds',
|
|
@@ -467,6 +691,8 @@
|
|
|
467
691
|
* in here: in here is only what happens once the button is pressed.
|
|
468
692
|
*/
|
|
469
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)));
|
|
470
696
|
// the queue's marks are kit icons: waiting, working, check (done), close (failed)
|
|
471
697
|
const mark = (state) => Kit.icon({ waiting: 'waiting', working: 'working', done: 'check', failed: 'close' }[state] || 'waiting', { cls: 'k-q-mark' });
|
|
472
698
|
const el = (tag, cls, text) => {
|
|
@@ -502,8 +728,11 @@
|
|
|
502
728
|
const file = el('span', 'k-run-file');
|
|
503
729
|
const left = el('span', 'k-run-left');
|
|
504
730
|
sub.append(file, left);
|
|
505
|
-
|
|
506
|
-
|
|
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);
|
|
507
736
|
|
|
508
737
|
const queueBox = el('section', 'k-run-queue');
|
|
509
738
|
const list = el('ol');
|
|
@@ -514,14 +743,14 @@
|
|
|
514
743
|
const detail = el('p', 'k-run-done-detail');
|
|
515
744
|
const where = el('p', 'k-run-done-where');
|
|
516
745
|
const actions = el('div', 'k-run-done-actions');
|
|
517
|
-
const reveal = button('btn btn-ghost', 'Show me the file', o.onReveal);
|
|
518
|
-
const again = button('linky', 'Start again', o.onAgain);
|
|
746
|
+
const reveal = button('btn btn-ghost', t('Show me the file'), o.onReveal);
|
|
747
|
+
const again = button('linky', t('Start again'), o.onAgain);
|
|
519
748
|
actions.append(reveal, again);
|
|
520
749
|
done.append(title, detail, where, actions);
|
|
521
750
|
|
|
522
751
|
const failed = el('section', 'k-run-failed');
|
|
523
752
|
const err = el('p', 'k-error');
|
|
524
|
-
const retry = button('btn btn-ghost', 'Try again', o.onRetry);
|
|
753
|
+
const retry = button('btn btn-ghost', t('Try again'), o.onRetry);
|
|
525
754
|
failed.append(err, retry);
|
|
526
755
|
|
|
527
756
|
root.append(working, queueBox, done, failed);
|
|
@@ -531,8 +760,10 @@
|
|
|
531
760
|
// known (Fits' first pass on a slow machine): the bar sweeps, so it is
|
|
532
761
|
// plain that something is happening, and stops sweeping as soon as a
|
|
533
762
|
// real fraction comes in (decided 2026-11-20).
|
|
534
|
-
working({ what: w = 'Working', count: c = '', fraction = 0, unknown = false, file: f = '', left: l = '' } = {}) {
|
|
763
|
+
working({ what: w = t('Working'), count: c = '', fraction = 0, unknown = false, file: f = '', left: l = '', note: n = '' } = {}) {
|
|
535
764
|
setState('working');
|
|
765
|
+
note.textContent = n;
|
|
766
|
+
note.hidden = !n;
|
|
536
767
|
what.textContent = w;
|
|
537
768
|
count.textContent = c;
|
|
538
769
|
file.textContent = f;
|
|
@@ -559,12 +790,12 @@
|
|
|
559
790
|
// reveal: false when there is no file to show (it already fitted, it was
|
|
560
791
|
// stopped); tone: 'over' when it did not get all the way
|
|
561
792
|
// revealLabel: 'Show me the folder' when what it shows is a results folder.
|
|
562
|
-
done({ title:
|
|
793
|
+
done({ title: ti = t('Done.'), detail: d = '', where: w = '', reveal: showReveal = true, revealLabel = t('Show me the file'), tone = '' } = {}) {
|
|
563
794
|
setState('done');
|
|
564
795
|
reveal.hidden = !showReveal;
|
|
565
796
|
reveal.textContent = revealLabel;
|
|
566
797
|
done.classList.toggle('over', tone === 'over');
|
|
567
|
-
title.textContent =
|
|
798
|
+
title.textContent = ti;
|
|
568
799
|
detail.textContent = d;
|
|
569
800
|
where.textContent = w;
|
|
570
801
|
},
|
|
@@ -588,10 +819,12 @@
|
|
|
588
819
|
* veil.say('Drop to replace the video'); // when where it goes changes
|
|
589
820
|
*/
|
|
590
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)));
|
|
591
824
|
// say: a sentence, or a function giving it when the drag starts (it can follow the screen)
|
|
592
825
|
// when: a function; while it returns false (a run is going) there is no veil and no drop
|
|
593
826
|
// onOver(on): told when a file comes over the window and leaves it (to light a start zone)
|
|
594
|
-
Kit.veil = function veil({ say = 'Drop it here', icon = 'plus', onDrop, when = () => true, onOver } = {}) {
|
|
827
|
+
Kit.veil = function veil({ say = t('Drop it here'), icon = 'plus', onDrop, when = () => true, onOver } = {}) {
|
|
595
828
|
const root = document.createElement('div');
|
|
596
829
|
root.className = 'k-veil'; root.hidden = true;
|
|
597
830
|
const p = document.createElement('p');
|
|
@@ -632,8 +865,14 @@
|
|
|
632
865
|
* Three places (decided 2026-11-20): the licences on the left, the promise in
|
|
633
866
|
* the middle, the credit on the right. The version is not here: it is beside
|
|
634
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.
|
|
635
872
|
*/
|
|
636
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)));
|
|
637
876
|
Kit.PROMISE = 'Nothing is uploaded, and your originals are never touched.';
|
|
638
877
|
// promise: only for a tool whose truth is different, one that talks to a
|
|
639
878
|
// network by design (Clipboard, the Tool Belt's updates); everyone else says
|
|
@@ -642,19 +881,38 @@
|
|
|
642
881
|
root.classList.add('k-footer');
|
|
643
882
|
root.replaceChildren();
|
|
644
883
|
const lic = document.createElement('button');
|
|
645
|
-
lic.type = 'button'; lic.id = 'licences'; lic.className = 'k-footer-licences'; lic.textContent = 'Licences and credits';
|
|
884
|
+
lic.type = 'button'; lic.id = 'licences'; lic.className = 'k-footer-licences'; lic.textContent = t('Licences and credits');
|
|
646
885
|
const promiseEl = document.createElement('span');
|
|
647
886
|
promiseEl.className = 'k-footer-promise';
|
|
648
|
-
promiseEl.textContent = promise ||
|
|
887
|
+
promiseEl.textContent = promise || t('Nothing is uploaded, and your originals are never touched.');
|
|
649
888
|
const site = document.createElement('button');
|
|
650
889
|
site.type = 'button'; site.id = 'site'; site.className = 'k-footer-credit';
|
|
651
890
|
const mark = document.createElement('span'); mark.className = 'k-mark';
|
|
652
891
|
const dev = document.createElement('b'); dev.textContent = 'Dev';
|
|
653
892
|
mark.append('Ponder', dev);
|
|
654
|
-
site.append('Powered by ', mark);
|
|
893
|
+
site.append(t('Powered by') + ' ', mark);
|
|
655
894
|
if (onSite) site.addEventListener('click', onSite);
|
|
656
895
|
if (onLicences) lic.addEventListener('click', onLicences);
|
|
657
|
-
|
|
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);
|
|
658
916
|
};
|
|
659
917
|
})(window.Kit = window.Kit || {});
|
|
660
918
|
|
|
@@ -737,4 +995,63 @@
|
|
|
737
995
|
};
|
|
738
996
|
};
|
|
739
997
|
})(window.Kit = window.Kit || {});
|
|
740
|
-
|
|
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';
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</style></head>
|
|
27
27
|
<body>
|
|
28
28
|
<h1>Licences and credits</h1>
|
|
29
|
-
<p>Built with the PonderDev kit 1.
|
|
29
|
+
<p>Built with the PonderDev kit 1.1.0, the parts every Just tool shares.</p>
|
|
30
30
|
<div class="notices"><h2>Third party notices</h2>
|
|
31
31
|
<p>Just Fits is built on other people's work. This file records what it uses, under what terms, and where to get the original source. Full licence texts are in the <code>licenses/</code> folder and are also shown inside the app under <strong>Licences and credits</strong> in the footer.</p>
|
|
32
32
|
<p>Just Fits itself is GPL-3.0-or-later. See <code>LICENSE</code>.</p>
|