@ponderdev/justfits 0.0.0-stage → 1.3.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/LICENSE +674 -0
- package/README.md +240 -2
- package/THIRD-PARTY-NOTICES.md +120 -0
- package/agents/skills/justfits/SKILL.md +102 -0
- package/licenses/ffmpeg-license.txt +127 -0
- package/licenses/gpl-2.0.txt +338 -0
- package/licenses/gpl-3.0.txt +674 -0
- package/package.json +51 -4
- package/scripts/link-skill.cjs +99 -0
- package/src/binaries.cjs +106 -0
- package/src/cli.cjs +603 -0
- package/src/engine.cjs +358 -0
- package/src/heif.cjs +156 -0
- package/src/kit/scan.cjs +105 -0
- package/src/kit/window.cjs +93 -0
- package/src/main.cjs +265 -0
- package/src/plan.js +257 -0
- package/src/preload.cjs +35 -0
- package/src/renderer/app.js +635 -0
- package/src/renderer/index.html +57 -0
- package/src/renderer/kit/kit.css +767 -0
- package/src/renderer/kit/kit.js +740 -0
- package/src/renderer/licenses.html +1204 -0
- package/src/renderer/styles.css +9 -0
- package/src/scan.cjs +43 -0
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
/* PonderDev kit 1.0.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
|
+
/* --- parts/start.js --- */
|
|
117
|
+
/* kit part: the start screen (option A) and the file row.
|
|
118
|
+
*
|
|
119
|
+
* const start = Kit.start(document.getElementById('start'), {
|
|
120
|
+
* name: 'Just Fits', version: '1.3.0', line: 'Makes a file small enough to send.',
|
|
121
|
+
* icon: 'video', say: 'Drop a video or a picture here', choose: 'Choose a file',
|
|
122
|
+
* takes: 'MP4, MOV, MKV, WebM and more, or a JPEG, PNG, HEIC or WebP picture',
|
|
123
|
+
* onChoose, onDrop(files),
|
|
124
|
+
* also: { label: 'Choose a folder', onClick, change: 'Change folder' }, // optional
|
|
125
|
+
* });
|
|
126
|
+
* also.change: the same second way in on the file row once something is in,
|
|
127
|
+
* beside "Change file" (decided 2026-11-21: a folder can be swapped for
|
|
128
|
+
* another folder on Windows and Linux without Start again).
|
|
129
|
+
* start.landed({ name: 'beach-day.mp4', facts: '41.3 MB · 1920x1080 · 0:12' });
|
|
130
|
+
* start.reset();
|
|
131
|
+
*/
|
|
132
|
+
(function (Kit) {
|
|
133
|
+
const el = (tag, cls, text) => { const n = document.createElement(tag); if (cls) n.className = cls; if (text !== undefined) n.textContent = text; return n; };
|
|
134
|
+
|
|
135
|
+
// also: { label, onClick } a second way to change, beside Change (a folder,
|
|
136
|
+
// on Windows and Linux where one picker cannot take both); Change then reads
|
|
137
|
+
// changeLabel ('Change file').
|
|
138
|
+
Kit.fileRow = function fileRow(root, { icon = 'file', onChange, also, changeLabel = 'Change file' } = {}) {
|
|
139
|
+
root.classList.add('k-file');
|
|
140
|
+
root.replaceChildren();
|
|
141
|
+
const text = el('div', 'k-file-text');
|
|
142
|
+
const name = el('p', 'k-file-name');
|
|
143
|
+
const facts = el('p', 'k-file-facts');
|
|
144
|
+
text.append(name, facts);
|
|
145
|
+
const change = el('button', 'btn btn-ghost btn-tight', also ? changeLabel : 'Change');
|
|
146
|
+
change.type = 'button';
|
|
147
|
+
if (onChange) change.addEventListener('click', onChange);
|
|
148
|
+
let pic = Kit.icon(icon);
|
|
149
|
+
let changeAlso = null;
|
|
150
|
+
if (also) {
|
|
151
|
+
changeAlso = el('button', 'btn btn-ghost btn-tight', also.label);
|
|
152
|
+
changeAlso.type = 'button';
|
|
153
|
+
changeAlso.addEventListener('click', () => also.onClick && also.onClick());
|
|
154
|
+
const both = el('div', 'k-file-changes');
|
|
155
|
+
both.append(change, changeAlso);
|
|
156
|
+
root.append(pic, text, both);
|
|
157
|
+
} else root.append(pic, text, change);
|
|
158
|
+
return {
|
|
159
|
+
// icon: a file's own kind when it differs from the tool's (a picture in Just Fits)
|
|
160
|
+
set({ name: n, facts: f = '', icon: i } = {}) {
|
|
161
|
+
name.textContent = n; facts.textContent = f; root.classList.add('show');
|
|
162
|
+
if (i) { const next = Kit.icon(i); pic.replaceWith(next); pic = next; }
|
|
163
|
+
},
|
|
164
|
+
change,
|
|
165
|
+
changeAlso,
|
|
166
|
+
clear() { root.classList.remove('show'); },
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// A pre-release build carries its coming version with a pre-release tag in
|
|
171
|
+
// package.json ("1.3.0-pre"), and says so in words: "1.3.0 (pre-release)",
|
|
172
|
+
// so a review picture never looks like the old build. A release build shows
|
|
173
|
+
// the plain version (decided 2026-11-20).
|
|
174
|
+
Kit.versionLabel = function versionLabel(v) {
|
|
175
|
+
const m = /^(\d+\.\d+\.\d+)-./.exec(String(v || ''));
|
|
176
|
+
return m ? `${m[1]} (pre-release)` : String(v || '');
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
Kit.start = function start(root, o) {
|
|
180
|
+
root.classList.add('k-start');
|
|
181
|
+
root.replaceChildren();
|
|
182
|
+
const head = el('header', 'k-start-head');
|
|
183
|
+
// the version sits faintly beside the name (decided 2026-11-19)
|
|
184
|
+
const title = el('h1', '', o.name);
|
|
185
|
+
if (o.version) title.append(el('span', 'k-version', Kit.versionLabel(o.version)));
|
|
186
|
+
head.append(title, el('p', 'sub', o.line));
|
|
187
|
+
const zone = el('section', 'k-zone');
|
|
188
|
+
const btn = el('button', 'btn btn-primary', o.choose || 'Choose a file');
|
|
189
|
+
btn.type = 'button';
|
|
190
|
+
const err = el('p', 'k-error');
|
|
191
|
+
// also: a second way in, as a quieter button beside the first (Zip's "Open an archive")
|
|
192
|
+
const actions = el('div', 'k-zone-actions');
|
|
193
|
+
actions.append(btn);
|
|
194
|
+
let also = null;
|
|
195
|
+
if (o.also) {
|
|
196
|
+
also = el('button', 'btn btn-ghost', o.also.label);
|
|
197
|
+
also.type = 'button';
|
|
198
|
+
also.addEventListener('click', () => o.also.onClick && o.also.onClick());
|
|
199
|
+
actions.append(also);
|
|
200
|
+
}
|
|
201
|
+
zone.append(Kit.icon(o.icon || 'file'), el('p', 'k-zone-say', o.say), actions, el('p', 'k-zone-takes', o.takes || ''), err);
|
|
202
|
+
const fileEl = el('div');
|
|
203
|
+
root.append(head, zone);
|
|
204
|
+
// skill: { copy: async () => the tool's SKILL.md text, about: () => opens its how-it-works page }
|
|
205
|
+
if (o.skill) {
|
|
206
|
+
const line = el('p', 'k-skill');
|
|
207
|
+
const copy = el('button', 'linky', 'Copy skill');
|
|
208
|
+
copy.type = 'button';
|
|
209
|
+
const about = el('button', 'linky', "What's this?");
|
|
210
|
+
about.type = 'button';
|
|
211
|
+
const note = el('p', 'k-skill-about hint');
|
|
212
|
+
note.hidden = true;
|
|
213
|
+
note.textContent = `A skill is a short file that teaches an assistant (Claude, ChatGPT, or one on your own computer) to run ${o.name} for you.`;
|
|
214
|
+
line.append('Use it with your assistant', el('span', 'k-skill-sep', '·'), copy, el('span', 'k-skill-sep', '·'), about);
|
|
215
|
+
copy.addEventListener('click', async () => {
|
|
216
|
+
try {
|
|
217
|
+
const text = await o.skill.copy();
|
|
218
|
+
await navigator.clipboard.writeText(text);
|
|
219
|
+
copy.textContent = 'Copied';
|
|
220
|
+
} catch { copy.textContent = 'Could not copy'; }
|
|
221
|
+
setTimeout(() => { copy.textContent = 'Copy skill'; }, 2200);
|
|
222
|
+
});
|
|
223
|
+
if (o.skill.about) {
|
|
224
|
+
const how = el('button', 'linky', 'How it works');
|
|
225
|
+
how.type = 'button';
|
|
226
|
+
how.addEventListener('click', () => o.skill.about());
|
|
227
|
+
note.append(' ', how);
|
|
228
|
+
}
|
|
229
|
+
about.addEventListener('click', () => { note.hidden = !note.hidden; });
|
|
230
|
+
root.append(line, note);
|
|
231
|
+
}
|
|
232
|
+
root.append(fileEl);
|
|
233
|
+
const rowAlso = o.also && o.also.change ? { label: o.also.change, onClick: o.also.onClick } : null;
|
|
234
|
+
const file = Kit.fileRow(fileEl, { icon: o.icon, onChange: o.onChoose, also: rowAlso, changeLabel: o.changeLabel });
|
|
235
|
+
|
|
236
|
+
btn.addEventListener('click', () => o.onChoose && o.onChoose());
|
|
237
|
+
for (const t of ['dragenter', 'dragover']) zone.addEventListener(t, (e) => { e.preventDefault(); zone.classList.add('over'); });
|
|
238
|
+
for (const t of ['dragleave', 'dragend']) zone.addEventListener(t, () => zone.classList.remove('over'));
|
|
239
|
+
zone.addEventListener('drop', (e) => { e.preventDefault(); zone.classList.remove('over'); if (o.onDrop) o.onDrop([...e.dataTransfer.files]); });
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
landed(f) { err.textContent = ''; file.set(f); root.classList.add('landed'); },
|
|
243
|
+
reset() { file.clear(); root.classList.remove('landed'); },
|
|
244
|
+
// a file that could not be taken: said under the zone, in the tool's words
|
|
245
|
+
error(message) { err.textContent = message || ''; },
|
|
246
|
+
// light the zone while a file is held anywhere over the window (the tool's veil decides)
|
|
247
|
+
over(on) { zone.classList.toggle('over', Boolean(on)); },
|
|
248
|
+
buttons: { choose: btn, change: file.change, changeAlso: file.changeAlso, also },
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
})(window.Kit = window.Kit || {});
|
|
252
|
+
|
|
253
|
+
/* --- parts/settings.js --- */
|
|
254
|
+
/* kit part: the fields that need behaviour. A swatch's colour is set through
|
|
255
|
+
* the style object (--swatch), never a style attribute, which the policy blocks.
|
|
256
|
+
*
|
|
257
|
+
* Kit.segmented(el, ['JPEG', 'PNG'], { value: 'JPEG', onChange })
|
|
258
|
+
* Kit.range2(el, { min: 0, max: 100, from: 20, to: 80, step: 1, onChange([from, to]) })
|
|
259
|
+
* Kit.swatches(el, ['#ffffff', '#000000', '#ffd400'], { value, custom: true, onChange })
|
|
260
|
+
*/
|
|
261
|
+
(function (Kit) {
|
|
262
|
+
Kit.segmented = function segmented(root, choices, { value, onChange } = {}) {
|
|
263
|
+
root.classList.add('k-seg');
|
|
264
|
+
root.setAttribute('role', 'group');
|
|
265
|
+
root.replaceChildren();
|
|
266
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-pressed', String(b.dataset.value === v)); };
|
|
267
|
+
for (const c of choices) {
|
|
268
|
+
const [v, label] = Array.isArray(c) ? c : [c, c];
|
|
269
|
+
const b = document.createElement('button');
|
|
270
|
+
b.type = 'button'; b.dataset.value = v; b.textContent = label;
|
|
271
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
272
|
+
root.append(b);
|
|
273
|
+
}
|
|
274
|
+
set(value === undefined ? (Array.isArray(choices[0]) ? choices[0][0] : choices[0]) : value);
|
|
275
|
+
return { set, get: () => [...root.children].find((b) => b.getAttribute('aria-pressed') === 'true')?.dataset.value };
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
Kit.range2 = function range2(root, { min = 0, max = 100, step = 1, from = min, to = max, onChange } = {}) {
|
|
279
|
+
root.classList.add('k-range2');
|
|
280
|
+
root.replaceChildren();
|
|
281
|
+
const track = document.createElement('div'); track.className = 'k-range2-track';
|
|
282
|
+
const fill = document.createElement('div'); fill.className = 'k-range2-fill';
|
|
283
|
+
track.append(fill);
|
|
284
|
+
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; };
|
|
285
|
+
const a = mk(from), b = mk(to);
|
|
286
|
+
const paint = () => {
|
|
287
|
+
let x = Number(a.value), y = Number(b.value);
|
|
288
|
+
if (x > y) [x, y] = [y, x];
|
|
289
|
+
fill.style.setProperty('--from', ((x - min) / (max - min) * 100) + '%');
|
|
290
|
+
fill.style.setProperty('--to', ((y - min) / (max - min) * 100) + '%');
|
|
291
|
+
return [x, y];
|
|
292
|
+
};
|
|
293
|
+
for (const i of [a, b]) i.addEventListener('input', () => { const v = paint(); if (onChange) onChange(v); });
|
|
294
|
+
root.append(track, a, b);
|
|
295
|
+
paint();
|
|
296
|
+
return { get: paint };
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
Kit.swatches = function swatches(root, colours, { value, custom = false, onChange } = {}) {
|
|
300
|
+
root.classList.add('k-swatches');
|
|
301
|
+
root.replaceChildren();
|
|
302
|
+
const set = (v) => { for (const s of root.children) s.setAttribute('aria-pressed', String(s.dataset.value === v)); };
|
|
303
|
+
const add = (c, isCustom) => {
|
|
304
|
+
const s = document.createElement('button');
|
|
305
|
+
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);
|
|
307
|
+
if (isCustom) {
|
|
308
|
+
const i = document.createElement('input'); i.type = 'color'; i.value = c;
|
|
309
|
+
i.addEventListener('input', () => { s.dataset.value = i.value; s.style.setProperty('--swatch', i.value); set(i.value); if (onChange) onChange(i.value); });
|
|
310
|
+
s.append(i);
|
|
311
|
+
} else {
|
|
312
|
+
s.addEventListener('click', () => { set(c); if (onChange) onChange(c); });
|
|
313
|
+
}
|
|
314
|
+
root.append(s);
|
|
315
|
+
};
|
|
316
|
+
for (const c of colours) add(c, false);
|
|
317
|
+
if (custom) add(value && !colours.includes(value) ? value : '#888888', true);
|
|
318
|
+
set(value === undefined ? colours[0] : value);
|
|
319
|
+
return { set };
|
|
320
|
+
};
|
|
321
|
+
})(window.Kit = window.Kit || {});
|
|
322
|
+
|
|
323
|
+
/* --- parts/controls.js --- */
|
|
324
|
+
/* kit part: behaviour for chips, the bipolar slider, the reveal group and the
|
|
325
|
+
* 3x3 grid.
|
|
326
|
+
*
|
|
327
|
+
* Kit.chips(el, [['soft', 'Soft'], ['bold', 'Bold']], { value, onChange })
|
|
328
|
+
* Kit.bipolar(el, { min: -100, max: 100, value: 0, onChange })
|
|
329
|
+
* Kit.reveal(checkboxEl, groupEl) shows the group while it's ticked
|
|
330
|
+
* Kit.grid9(el, { value: 8, onChange }) 1..9 in numpad order, 8 = bottom middle
|
|
331
|
+
*/
|
|
332
|
+
(function (Kit) {
|
|
333
|
+
Kit.chips = function chips(root, choices, { value, onChange } = {}) {
|
|
334
|
+
root.classList.add('k-chips');
|
|
335
|
+
root.replaceChildren();
|
|
336
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-pressed', String(b.dataset.value === v)); };
|
|
337
|
+
for (const c of choices) {
|
|
338
|
+
const [v, label] = Array.isArray(c) ? c : [c, c];
|
|
339
|
+
const b = document.createElement('button');
|
|
340
|
+
b.type = 'button'; b.dataset.value = v; b.textContent = label;
|
|
341
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
342
|
+
root.append(b);
|
|
343
|
+
}
|
|
344
|
+
if (value !== undefined) set(value);
|
|
345
|
+
return { set };
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
Kit.bipolar = function bipolar(root, { min = -100, max = 100, step = 1, value = 0, title, onChange } = {}) {
|
|
349
|
+
root.classList.add('k-bipolar');
|
|
350
|
+
root.replaceChildren();
|
|
351
|
+
const r = document.createElement('input');
|
|
352
|
+
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';
|
|
354
|
+
const pill = document.createElement('span'); pill.className = 'pill';
|
|
355
|
+
const show = () => { const v = Number(r.value); pill.textContent = v > 0 ? `+${v}` : String(v); };
|
|
356
|
+
r.addEventListener('input', () => { show(); if (onChange) onChange(Number(r.value)); });
|
|
357
|
+
r.addEventListener('dblclick', () => { r.value = 0; show(); if (onChange) onChange(0); });
|
|
358
|
+
root.append(r, pill);
|
|
359
|
+
show();
|
|
360
|
+
return { get: () => Number(r.value), set: (v) => { r.value = v; show(); } };
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
Kit.reveal = function reveal(box, group) {
|
|
364
|
+
const host = group.closest('.k-reveal') || group.parentElement;
|
|
365
|
+
host.classList.add('k-reveal');
|
|
366
|
+
group.classList.add('k-reveal-body');
|
|
367
|
+
const sync = () => host.classList.toggle('open', box.checked);
|
|
368
|
+
box.addEventListener('change', sync);
|
|
369
|
+
sync();
|
|
370
|
+
return { sync };
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const NAMES = ['', 'Bottom left', 'Bottom middle', 'Bottom right', 'Middle left', 'Centre', 'Middle right', 'Top left', 'Top middle', 'Top right'];
|
|
374
|
+
Kit.grid9 = function grid9(root, { value = 2, onChange } = {}) {
|
|
375
|
+
root.classList.add('k-grid9');
|
|
376
|
+
root.replaceChildren();
|
|
377
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-pressed', String(Number(b.dataset.value) === v)); };
|
|
378
|
+
for (const v of [7, 8, 9, 4, 5, 6, 1, 2, 3]) {
|
|
379
|
+
const b = document.createElement('button');
|
|
380
|
+
b.type = 'button'; b.dataset.value = v; b.title = NAMES[v]; b.setAttribute('aria-label', NAMES[v]);
|
|
381
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
382
|
+
root.append(b);
|
|
383
|
+
}
|
|
384
|
+
set(value);
|
|
385
|
+
return { set };
|
|
386
|
+
};
|
|
387
|
+
})(window.Kit = window.Kit || {});
|
|
388
|
+
|
|
389
|
+
/* --- parts/overlays.js --- */
|
|
390
|
+
/* kit part: tabs and the popup menu. Dialogs need no script: a <dialog
|
|
391
|
+
* class="k-dialog"> with showModal() and close().
|
|
392
|
+
*
|
|
393
|
+
* Kit.tabs(el, [['tools', 'Tools'], ['flows', 'Workflows']], { value, onChange })
|
|
394
|
+
* const m = Kit.menu([{ value: 'fade', label: 'Fade', icon: 'layers' }], { value, onPick })
|
|
395
|
+
* m.openAt(anchorEl)
|
|
396
|
+
*/
|
|
397
|
+
(function (Kit) {
|
|
398
|
+
Kit.tabs = function tabs(root, choices, { value, onChange } = {}) {
|
|
399
|
+
root.classList.add('k-tabs');
|
|
400
|
+
root.setAttribute('role', 'tablist');
|
|
401
|
+
root.replaceChildren();
|
|
402
|
+
const set = (v) => { for (const b of root.children) b.setAttribute('aria-selected', String(b.dataset.value === v)); };
|
|
403
|
+
for (const [v, label, icon] of choices) {
|
|
404
|
+
const b = document.createElement('button');
|
|
405
|
+
b.type = 'button'; b.setAttribute('role', 'tab'); b.dataset.value = v;
|
|
406
|
+
if (icon) b.append(Kit.icon(icon));
|
|
407
|
+
b.append(label);
|
|
408
|
+
b.addEventListener('click', () => { set(v); if (onChange) onChange(v); });
|
|
409
|
+
root.append(b);
|
|
410
|
+
}
|
|
411
|
+
set(value === undefined ? choices[0][0] : value);
|
|
412
|
+
return { set };
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
Kit.menu = function menu(items, { value, onPick } = {}) {
|
|
416
|
+
const root = document.createElement('div');
|
|
417
|
+
root.className = 'k-menu'; root.setAttribute('role', 'menu'); root.hidden = true;
|
|
418
|
+
for (const it of items) {
|
|
419
|
+
const b = document.createElement('button');
|
|
420
|
+
b.type = 'button'; b.setAttribute('role', 'menuitemradio'); b.dataset.value = it.value;
|
|
421
|
+
b.setAttribute('aria-checked', String(it.value === value));
|
|
422
|
+
if (it.icon) b.append(Kit.icon(it.icon));
|
|
423
|
+
b.append(it.label);
|
|
424
|
+
b.addEventListener('click', () => {
|
|
425
|
+
for (const o of root.children) o.setAttribute('aria-checked', String(o === b));
|
|
426
|
+
close(); if (onPick) onPick(it.value);
|
|
427
|
+
});
|
|
428
|
+
root.append(b);
|
|
429
|
+
}
|
|
430
|
+
document.body.append(root);
|
|
431
|
+
const close = () => { root.hidden = true; };
|
|
432
|
+
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') close(); });
|
|
433
|
+
document.addEventListener('pointerdown', (e) => { if (!root.hidden && !root.contains(e.target)) close(); });
|
|
434
|
+
return {
|
|
435
|
+
openAt(anchor) {
|
|
436
|
+
const r = anchor.getBoundingClientRect();
|
|
437
|
+
root.style.setProperty('--x', `${Math.round(Math.min(r.left, innerWidth - 200))}px`);
|
|
438
|
+
root.style.setProperty('--y', `${Math.round(r.bottom + 6)}px`);
|
|
439
|
+
root.hidden = false;
|
|
440
|
+
root.querySelector('[aria-checked="true"]')?.focus();
|
|
441
|
+
},
|
|
442
|
+
close,
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
})(window.Kit = window.Kit || {});
|
|
446
|
+
|
|
447
|
+
/* --- parts/run.js --- */
|
|
448
|
+
/*
|
|
449
|
+
* kit part: what happens under the main button in every Just tool (decided 2026-11-18):
|
|
450
|
+
* working, the queue, done and failed, the same in every tool, with the tool's
|
|
451
|
+
* own words and numbers in its slots.
|
|
452
|
+
*
|
|
453
|
+
* const run = Kit.run(document.getElementById('run'), {
|
|
454
|
+
* onCancel, onReveal, onAgain, onRetry,
|
|
455
|
+
* });
|
|
456
|
+
* run.working({ what: 'Converting to JPEG', count: '58 of 120', fraction: 0.48,
|
|
457
|
+
* file: 'IMG_4580.HEIC', left: 'About 9 seconds left' });
|
|
458
|
+
* run.working({ what: 'First pass', unknown: true }); // a step whose length can't be known:
|
|
459
|
+
* // the bar sweeps instead of sitting still
|
|
460
|
+
* run.queue([{ name: 'IMG_4403.HEIC', state: 'done' }, { name: 'IMG_4511.HEIC', state: 'failed', note: 'Not a photo' }]);
|
|
461
|
+
* run.done({ title: 'Done. 120 photos converted', detail: '21.4 MB of JPEG in 20 seconds',
|
|
462
|
+
* where: 'Saved next to the originals in Beach vacation' });
|
|
463
|
+
* run.failed('There is already a file with that name. Pick another name.');
|
|
464
|
+
* run.reset();
|
|
465
|
+
*
|
|
466
|
+
* Before a run, the estimate goes above the main button (.k-note), never
|
|
467
|
+
* in here: in here is only what happens once the button is pressed.
|
|
468
|
+
*/
|
|
469
|
+
(function (Kit) {
|
|
470
|
+
// the queue's marks are kit icons: waiting, working, check (done), close (failed)
|
|
471
|
+
const mark = (state) => Kit.icon({ waiting: 'waiting', working: 'working', done: 'check', failed: 'close' }[state] || 'waiting', { cls: 'k-q-mark' });
|
|
472
|
+
const el = (tag, cls, text) => {
|
|
473
|
+
const n = document.createElement(tag);
|
|
474
|
+
if (cls) n.className = cls;
|
|
475
|
+
if (text !== undefined) n.textContent = text;
|
|
476
|
+
return n;
|
|
477
|
+
};
|
|
478
|
+
const button = (cls, text, fn) => {
|
|
479
|
+
const b = el('button', cls, text);
|
|
480
|
+
b.type = 'button';
|
|
481
|
+
if (fn) b.addEventListener('click', fn);
|
|
482
|
+
return b;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
function mount(root, o = {}) {
|
|
486
|
+
root.classList.add('k-run');
|
|
487
|
+
root.replaceChildren();
|
|
488
|
+
// onState(state): told whenever the part changes state (idle, working, done, failed);
|
|
489
|
+
// the parent also carries it as data-run-state, so a tool's CSS can follow
|
|
490
|
+
const setState = (st) => { root.dataset.state = st; if (root.parentElement) root.parentElement.dataset.runState = st; if (o.onState) o.onState(st); };
|
|
491
|
+
root.dataset.state = 'idle';
|
|
492
|
+
|
|
493
|
+
const working = el('section', 'k-run-working');
|
|
494
|
+
const bar = el('div', 'k-run-bar');
|
|
495
|
+
const fill = el('span', 'k-run-fill');
|
|
496
|
+
bar.append(fill);
|
|
497
|
+
const line = el('p', 'k-run-line');
|
|
498
|
+
const what = el('span', 'k-run-what');
|
|
499
|
+
const count = el('span', 'k-run-count');
|
|
500
|
+
line.append(what, count);
|
|
501
|
+
const sub = el('p', 'k-run-sub');
|
|
502
|
+
const file = el('span', 'k-run-file');
|
|
503
|
+
const left = el('span', 'k-run-left');
|
|
504
|
+
sub.append(file, left);
|
|
505
|
+
const cancel = button('btn btn-ghost btn-tight k-run-cancel', 'Cancel', o.onCancel);
|
|
506
|
+
working.append(bar, line, sub, cancel);
|
|
507
|
+
|
|
508
|
+
const queueBox = el('section', 'k-run-queue');
|
|
509
|
+
const list = el('ol');
|
|
510
|
+
queueBox.append(list);
|
|
511
|
+
|
|
512
|
+
const done = el('section', 'k-run-done');
|
|
513
|
+
const title = el('p', 'k-run-done-title');
|
|
514
|
+
const detail = el('p', 'k-run-done-detail');
|
|
515
|
+
const where = el('p', 'k-run-done-where');
|
|
516
|
+
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);
|
|
519
|
+
actions.append(reveal, again);
|
|
520
|
+
done.append(title, detail, where, actions);
|
|
521
|
+
|
|
522
|
+
const failed = el('section', 'k-run-failed');
|
|
523
|
+
const err = el('p', 'k-error');
|
|
524
|
+
const retry = button('btn btn-ghost', 'Try again', o.onRetry);
|
|
525
|
+
failed.append(err, retry);
|
|
526
|
+
|
|
527
|
+
root.append(working, queueBox, done, failed);
|
|
528
|
+
|
|
529
|
+
return {
|
|
530
|
+
// unknown: true (or a fraction of null) while a step's length can't be
|
|
531
|
+
// known (Fits' first pass on a slow machine): the bar sweeps, so it is
|
|
532
|
+
// plain that something is happening, and stops sweeping as soon as a
|
|
533
|
+
// real fraction comes in (decided 2026-11-20).
|
|
534
|
+
working({ what: w = 'Working', count: c = '', fraction = 0, unknown = false, file: f = '', left: l = '' } = {}) {
|
|
535
|
+
setState('working');
|
|
536
|
+
what.textContent = w;
|
|
537
|
+
count.textContent = c;
|
|
538
|
+
file.textContent = f;
|
|
539
|
+
left.textContent = l;
|
|
540
|
+
const sweep = unknown || fraction === null;
|
|
541
|
+
bar.classList.toggle('unknown', sweep);
|
|
542
|
+
if (sweep) { bar.setAttribute('aria-busy', 'true'); fill.style.width = ''; return; }
|
|
543
|
+
bar.removeAttribute('aria-busy');
|
|
544
|
+
fill.style.width = `${Math.round(Math.max(0, Math.min(1, fraction)) * 1000) / 10}%`;
|
|
545
|
+
},
|
|
546
|
+
queue(items = []) {
|
|
547
|
+
list.replaceChildren(...items.map((it) => {
|
|
548
|
+
const li = el('li');
|
|
549
|
+
li.dataset.q = it.state || 'waiting';
|
|
550
|
+
li.append(mark(li.dataset.q), el('span', 'k-q-name', it.name));
|
|
551
|
+
if (it.note) li.append(el('span', 'k-q-note', it.note));
|
|
552
|
+
return li;
|
|
553
|
+
}));
|
|
554
|
+
queueBox.classList.toggle('has', items.length > 0);
|
|
555
|
+
// keep the row being worked on in view, so a long queue follows the run
|
|
556
|
+
const at = list.querySelector('[data-q="working"]');
|
|
557
|
+
if (at) queueBox.scrollTop = Math.max(0, at.offsetTop - queueBox.clientHeight / 2);
|
|
558
|
+
},
|
|
559
|
+
// reveal: false when there is no file to show (it already fitted, it was
|
|
560
|
+
// stopped); tone: 'over' when it did not get all the way
|
|
561
|
+
// revealLabel: 'Show me the folder' when what it shows is a results folder.
|
|
562
|
+
done({ title: t = 'Done.', detail: d = '', where: w = '', reveal: showReveal = true, revealLabel = 'Show me the file', tone = '' } = {}) {
|
|
563
|
+
setState('done');
|
|
564
|
+
reveal.hidden = !showReveal;
|
|
565
|
+
reveal.textContent = revealLabel;
|
|
566
|
+
done.classList.toggle('over', tone === 'over');
|
|
567
|
+
title.textContent = t;
|
|
568
|
+
detail.textContent = d;
|
|
569
|
+
where.textContent = w;
|
|
570
|
+
},
|
|
571
|
+
failed(message) {
|
|
572
|
+
setState('failed');
|
|
573
|
+
err.textContent = message;
|
|
574
|
+
},
|
|
575
|
+
// the parts' own buttons, for a tool that needs to label or test them
|
|
576
|
+
buttons: { cancel, reveal, again, retry },
|
|
577
|
+
reset() { setState('idle'); list.replaceChildren(); queueBox.classList.remove('has'); bar.classList.remove('unknown'); bar.removeAttribute('aria-busy'); fill.style.width = '0%'; },
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
Kit.run = mount;
|
|
582
|
+
})(window.Kit = window.Kit || {});
|
|
583
|
+
|
|
584
|
+
/* --- parts/veil.js --- */
|
|
585
|
+
/* kit part: the drag veil.
|
|
586
|
+
*
|
|
587
|
+
* const veil = Kit.veil({ say: 'Drop to add to the tray', icon: 'plus', onDrop(files) {} });
|
|
588
|
+
* veil.say('Drop to replace the video'); // when where it goes changes
|
|
589
|
+
*/
|
|
590
|
+
(function (Kit) {
|
|
591
|
+
// say: a sentence, or a function giving it when the drag starts (it can follow the screen)
|
|
592
|
+
// when: a function; while it returns false (a run is going) there is no veil and no drop
|
|
593
|
+
// 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 } = {}) {
|
|
595
|
+
const root = document.createElement('div');
|
|
596
|
+
root.className = 'k-veil'; root.hidden = true;
|
|
597
|
+
const p = document.createElement('p');
|
|
598
|
+
const text = document.createElement('span');
|
|
599
|
+
p.append(Kit.icon(icon), text);
|
|
600
|
+
root.append(p);
|
|
601
|
+
document.body.append(root);
|
|
602
|
+
let depth = 0;
|
|
603
|
+
const words = () => (typeof say === 'function' ? say() : say);
|
|
604
|
+
const hasFiles = (e) => e.dataTransfer && [...e.dataTransfer.types].includes('Files');
|
|
605
|
+
const show = (on) => { root.hidden = !on; if (onOver) onOver(on); };
|
|
606
|
+
window.addEventListener('dragenter', (e) => {
|
|
607
|
+
if (!hasFiles(e)) return;
|
|
608
|
+
depth++;
|
|
609
|
+
if (depth === 1 && when()) { text.textContent = words(); show(true); }
|
|
610
|
+
});
|
|
611
|
+
window.addEventListener('dragleave', () => { depth = Math.max(0, depth - 1); if (!depth) show(false); });
|
|
612
|
+
window.addEventListener('dragover', (e) => {
|
|
613
|
+
if (!hasFiles(e)) return;
|
|
614
|
+
e.preventDefault();
|
|
615
|
+
e.dataTransfer.dropEffect = when() ? 'copy' : 'none';
|
|
616
|
+
});
|
|
617
|
+
window.addEventListener('drop', (e) => {
|
|
618
|
+
if (!hasFiles(e)) return;
|
|
619
|
+
e.preventDefault(); depth = 0; show(false);
|
|
620
|
+
if (when() && onDrop) onDrop([...e.dataTransfer.files]);
|
|
621
|
+
});
|
|
622
|
+
return { say(s) { say = s; text.textContent = words(); } };
|
|
623
|
+
};
|
|
624
|
+
})(window.Kit = window.Kit || {});
|
|
625
|
+
|
|
626
|
+
/* --- parts/footer.js --- */
|
|
627
|
+
/* kit part: the footer. The promise is the family's, word for word; a tool does
|
|
628
|
+
* not write its own (decided 2026-11-18).
|
|
629
|
+
*
|
|
630
|
+
* Kit.footer(document.querySelector('footer'), { onSite, onLicences })
|
|
631
|
+
*
|
|
632
|
+
* Three places (decided 2026-11-20): the licences on the left, the promise in
|
|
633
|
+
* the middle, the credit on the right. The version is not here: it is beside
|
|
634
|
+
* the name on the start screen (Kit.start), which every window shows.
|
|
635
|
+
*/
|
|
636
|
+
(function (Kit) {
|
|
637
|
+
Kit.PROMISE = 'Nothing is uploaded, and your originals are never touched.';
|
|
638
|
+
// promise: only for a tool whose truth is different, one that talks to a
|
|
639
|
+
// network by design (Clipboard, the Tool Belt's updates); everyone else says
|
|
640
|
+
// the family's words, word for word.
|
|
641
|
+
Kit.footer = function footer(root, { onSite, onLicences, promise } = {}) {
|
|
642
|
+
root.classList.add('k-footer');
|
|
643
|
+
root.replaceChildren();
|
|
644
|
+
const lic = document.createElement('button');
|
|
645
|
+
lic.type = 'button'; lic.id = 'licences'; lic.className = 'k-footer-licences'; lic.textContent = 'Licences and credits';
|
|
646
|
+
const promiseEl = document.createElement('span');
|
|
647
|
+
promiseEl.className = 'k-footer-promise';
|
|
648
|
+
promiseEl.textContent = promise || Kit.PROMISE;
|
|
649
|
+
const site = document.createElement('button');
|
|
650
|
+
site.type = 'button'; site.id = 'site'; site.className = 'k-footer-credit';
|
|
651
|
+
const mark = document.createElement('span'); mark.className = 'k-mark';
|
|
652
|
+
const dev = document.createElement('b'); dev.textContent = 'Dev';
|
|
653
|
+
mark.append('Ponder', dev);
|
|
654
|
+
site.append('Powered by ', mark);
|
|
655
|
+
if (onSite) site.addEventListener('click', onSite);
|
|
656
|
+
if (onLicences) lic.addEventListener('click', onLicences);
|
|
657
|
+
root.append(lic, promiseEl, site);
|
|
658
|
+
};
|
|
659
|
+
})(window.Kit = window.Kit || {});
|
|
660
|
+
|
|
661
|
+
/* --- parts/store.js --- */
|
|
662
|
+
/* kit part: the settings store. Every setting a tool keeps between sessions
|
|
663
|
+
* goes through here, so every tool follows one rule (decided 2026-11-19):
|
|
664
|
+
*
|
|
665
|
+
* Two versions of a tool can be installed side by side, and they share one
|
|
666
|
+
* store (the same app id, the same storage). So a version keeps every key it
|
|
667
|
+
* does not know, and never drops one or fails on one. A newer version's keys
|
|
668
|
+
* ride along untouched when an older version saves, and an older version
|
|
669
|
+
* simply ignores them. A value of the wrong kind, or a store that cannot be
|
|
670
|
+
* read at all, falls back to the default; it never stops the tool.
|
|
671
|
+
*
|
|
672
|
+
* const settings = Kit.store('justcut', { removeWithoutAsking: false });
|
|
673
|
+
* settings.get('removeWithoutAsking'); // the saved value or the default
|
|
674
|
+
* settings.set('removeWithoutAsking', true); // writes this key, keeps the rest
|
|
675
|
+
* settings.clear('removeWithoutAsking'); // back to the default
|
|
676
|
+
*
|
|
677
|
+
* A key's meaning never changes: a setting that needs a new meaning takes a new
|
|
678
|
+
* name, and the old key stays for the versions that read it.
|
|
679
|
+
*
|
|
680
|
+
* A setting a tool kept under its own key before the kit (Just Cut's
|
|
681
|
+
* 'justcut.removeWithoutAsking' = '1') is carried over once:
|
|
682
|
+
*
|
|
683
|
+
* settings.adopt('justcut.removeWithoutAsking', 'removeWithoutAsking', (raw) => raw === '1');
|
|
684
|
+
*
|
|
685
|
+
* When the store has no value for the key yet and the old key is there, its
|
|
686
|
+
* value is read through the function and saved. Either way the old key is
|
|
687
|
+
* noted as adopted, so it is never read again: a person who later turns the
|
|
688
|
+
* setting back off is not overruled by the old key, which stays where it was
|
|
689
|
+
* for the older version that reads it.
|
|
690
|
+
*/
|
|
691
|
+
(function (Kit) {
|
|
692
|
+
const isPlain = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
693
|
+
const kindOf = (v) => (Array.isArray(v) ? 'array' : v === null ? 'null' : typeof v);
|
|
694
|
+
|
|
695
|
+
Kit.store = function store(name, defaults = {}, storage) {
|
|
696
|
+
const key = name + '.settings';
|
|
697
|
+
const box = () => storage || window.localStorage;
|
|
698
|
+
// Everything saved, known keys or not. Never throws.
|
|
699
|
+
function all() {
|
|
700
|
+
try {
|
|
701
|
+
const raw = box().getItem(key);
|
|
702
|
+
if (!raw) return {};
|
|
703
|
+
const saved = JSON.parse(raw);
|
|
704
|
+
return isPlain(saved) ? saved : {};
|
|
705
|
+
} catch (e) { return {}; }
|
|
706
|
+
}
|
|
707
|
+
function write(saved) {
|
|
708
|
+
try { box().setItem(key, JSON.stringify(saved)); return true; } catch (e) { return false; }
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
// A saved value of a different kind than its default is ignored: an older
|
|
712
|
+
// or newer version may have meant something else by it.
|
|
713
|
+
get(k) {
|
|
714
|
+
const saved = all();
|
|
715
|
+
if (!Object.prototype.hasOwnProperty.call(saved, k)) return defaults[k];
|
|
716
|
+
if (k in defaults && kindOf(saved[k]) !== kindOf(defaults[k])) return defaults[k];
|
|
717
|
+
return saved[k];
|
|
718
|
+
},
|
|
719
|
+
// Writes one key on top of everything saved, so keys this version does
|
|
720
|
+
// not know survive. Returns false when the store cannot be written.
|
|
721
|
+
set(k, v) { const saved = all(); saved[k] = v; return write(saved); },
|
|
722
|
+
clear(k) { const saved = all(); delete saved[k]; return write(saved); },
|
|
723
|
+
adopt(oldKey, k, read = (raw) => raw) {
|
|
724
|
+
const saved = all();
|
|
725
|
+
const done = Array.isArray(saved._adopted) ? saved._adopted : [];
|
|
726
|
+
if (done.includes(oldKey)) return false;
|
|
727
|
+
let raw = null;
|
|
728
|
+
try { raw = box().getItem(oldKey); } catch (e) { return false; }
|
|
729
|
+
let took = false;
|
|
730
|
+
if (raw !== null && !Object.prototype.hasOwnProperty.call(saved, k)) {
|
|
731
|
+
try { saved[k] = read(raw); took = true; } catch (e) { /* unreadable: the default stands */ }
|
|
732
|
+
}
|
|
733
|
+
saved._adopted = done.concat(oldKey);
|
|
734
|
+
write(saved);
|
|
735
|
+
return took;
|
|
736
|
+
},
|
|
737
|
+
};
|
|
738
|
+
};
|
|
739
|
+
})(window.Kit = window.Kit || {});
|
|
740
|
+
window.Kit.VERSION = '1.0.0';
|