@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.
@@ -1,259 +1,9 @@
1
- /* Same palette and idiom as Just JPEG, so the two apps read as one family
2
- sitting side by side in the Dock. Cool near-black, blue accent, 12px radius,
3
- px type sizes throughout. */
4
- :root {
5
- --bg: #12131a;
6
- --panel: #191b24;
7
- --panel-2: #21232f;
8
- --line: #2c2f3d;
9
- --text: #eceef5;
10
- --muted: #9aa0b4;
11
- --accent: #6c8cff;
12
- --accent-hot: #8aa2ff;
13
- --good: #52d1a4;
14
- --bad: #ff7a7a;
15
- --radius: 12px;
16
- }
1
+ /* Just Fits' own styles. Everything else, from the page to the run part, is
2
+ the kit's (kit/kit.css); what is here is only what Just Fits alone has, and
3
+ uses the kit's tokens. */
17
4
 
18
- * { box-sizing: border-box; }
19
-
20
- html, body {
21
- margin: 0;
22
- height: 100%;
23
- background: var(--bg);
24
- color: var(--text);
25
- font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
26
- -webkit-font-smoothing: antialiased;
27
- user-select: none;
28
- cursor: default;
29
- }
30
-
31
- body { display: flex; flex-direction: column; }
32
-
33
- /* Space for the macOS traffic lights, which sit over the content. */
34
- .titlebar {
35
- height: 28px;
36
- -webkit-app-region: drag;
37
- flex: none;
38
- }
39
-
40
- #app {
41
- flex: 1;
42
- min-height: 0; /* let the scroll happen here, not on the body */
43
- padding: 0 32px 20px;
44
- overflow: auto;
45
- }
46
-
47
- .view { max-width: 620px; margin: 0 auto; }
48
-
49
- h1 { font-size: 24px; margin: 4px 0; font-weight: 650; }
50
- h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
51
-
52
- .muted { color: var(--muted); }
53
- .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
54
- .sub { color: var(--muted); margin: 0 0 4px; }
55
-
56
- /* ------------------------------------------------------------- dropzone --- */
57
-
58
- .dropzone {
59
- margin-top: 28px;
60
- padding: 44px 28px;
61
- text-align: center;
62
- border: 2px dashed var(--line);
63
- border-radius: 18px;
64
- background: var(--panel);
65
- transition: border-color .15s, background .15s, transform .15s;
66
- }
67
- .dropzone.over {
68
- border-color: var(--accent);
69
- background: #1b1f33;
70
- transform: scale(1.01);
71
- }
72
-
73
- .dz-icon {
74
- width: 56px; height: 56px;
75
- fill: none;
76
- stroke: var(--muted);
77
- stroke-width: 2.2;
78
- stroke-linejoin: round;
79
- stroke-linecap: round;
80
- margin-bottom: 10px;
81
- }
82
- .dropzone.over .dz-icon { stroke: var(--accent); }
83
-
84
- .dz-title { margin: 0; font-size: 17px; font-weight: 600; }
85
- .dz-sub { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
86
-
87
- /* Classes rather than style attributes, because the Content Security Policy
88
- blocks inline styles and is worth keeping that way. */
89
- .spaced { margin-top: 12px; }
90
-
91
- /* --------------------------------------------------------------- panels --- */
92
-
93
- .settings {
94
- background: var(--panel);
95
- border: 1px solid var(--line);
96
- border-radius: var(--radius);
97
- padding: 6px 20px;
98
- margin-top: 20px;
99
- }
100
-
101
- .field { padding: 16px 0; border-bottom: 1px solid var(--line); }
102
- .field:last-child { border-bottom: none; }
103
- .field > label { display: block; font-weight: 560; margin-bottom: 9px; }
104
-
105
- .hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
106
- .hint:empty { display: none; }
107
-
108
- .row { display: flex; align-items: center; gap: 12px; }
109
-
110
- .pill {
111
- background: var(--panel-2);
112
- border-radius: 20px;
113
- padding: 1px 9px;
114
- font-size: 12px;
115
- color: var(--muted);
116
- margin-left: 6px;
117
- }
118
-
119
- .name { margin: 0; font-weight: 560; word-break: break-all; }
120
-
121
- /* -------------------------------------------------------------- controls --- */
122
-
123
- .btn {
124
- font: inherit;
125
- font-weight: 560;
126
- padding: 9px 18px;
127
- border-radius: 9px;
128
- border: 1px solid transparent;
129
- cursor: pointer;
130
- transition: background .12s, border-color .12s, opacity .12s;
131
- }
132
- .btn-primary { background: var(--accent); color: #fff; }
133
- .btn-primary:hover:not(:disabled) { background: var(--accent-hot); }
134
- .btn-primary:disabled { opacity: .45; cursor: default; background: var(--accent); }
135
- .btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
136
- .btn-ghost:hover { background: var(--panel-2); }
137
-
138
- .btn-wide { display: block; width: 100%; margin-top: 20px; padding: 11px; }
139
-
140
- .linky {
141
- font: inherit;
142
- color: var(--accent);
143
- background: none;
144
- border: 0;
145
- padding: 0;
146
- cursor: pointer;
147
- text-decoration: underline;
148
- text-underline-offset: 3px;
149
- }
150
- .linky:hover { color: var(--accent-hot); }
151
-
152
- select {
153
- font: inherit;
154
- color: var(--text);
155
- background: var(--panel-2);
156
- border: 1px solid var(--line);
157
- border-radius: 9px;
158
- padding: 8px 12px;
159
- width: 100%;
160
- }
161
- select:focus { outline: none; border-color: var(--accent); }
5
+ /* The targets are grouped (Discord, email and messaging), and only
6
+ Just Fits has a grouped list: the group names read as headings, not as
7
+ choices. */
162
8
  select optgroup { color: var(--muted); font-style: normal; }
163
9
  select option { color: var(--text); }
164
-
165
- input[type=number] {
166
- font: inherit;
167
- width: 84px;
168
- color: var(--text);
169
- background: var(--panel-2);
170
- border: 1px solid var(--line);
171
- border-radius: 9px;
172
- padding: 6px 10px;
173
- user-select: text;
174
- }
175
- input[type=number]:focus { outline: none; border-color: var(--accent); }
176
-
177
- /* --------------------------------------------------------------- working --- */
178
-
179
- .working { margin-top: 22px; }
180
-
181
- .bar-track {
182
- height: 6px;
183
- background: var(--panel-2);
184
- border-radius: 999px;
185
- overflow: hidden;
186
- }
187
- .bar-track span {
188
- display: block;
189
- height: 100%;
190
- width: 0;
191
- background: var(--accent);
192
- transition: width .25s ease;
193
- }
194
-
195
- .stage {
196
- display: flex;
197
- justify-content: space-between;
198
- margin: 10px 0 0;
199
- font-size: 13px;
200
- color: var(--muted);
201
- }
202
-
203
- /* ---------------------------------------------------------------- result --- */
204
-
205
- .result-card {
206
- margin-top: 22px;
207
- background: var(--panel);
208
- border: 1px solid var(--line);
209
- border-left: 3px solid var(--good);
210
- border-radius: var(--radius);
211
- padding: 16px 20px;
212
- }
213
- .result-card.over { border-left-color: var(--bad); }
214
- .result { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
215
- /* A Windows folder path has no spaces to break at, and is worth copying. */
216
- .where { word-break: break-all; user-select: text; }
217
-
218
- .error {
219
- margin-top: 20px;
220
- padding: 14px 18px;
221
- border-radius: var(--radius);
222
- background: rgba(255, 122, 122, .1);
223
- border: 1px solid rgba(255, 122, 122, .3);
224
- color: var(--bad);
225
- white-space: pre-wrap;
226
- user-select: text;
227
- }
228
-
229
- /* ---------------------------------------------------------------- footer --- */
230
-
231
- .app-footer {
232
- flex: none;
233
- display: flex;
234
- align-items: center;
235
- justify-content: space-between;
236
- gap: 16px;
237
- padding: 10px 24px;
238
- border-top: 1px solid var(--line);
239
- background: var(--panel);
240
- font-size: 11.5px;
241
- color: var(--muted);
242
- }
243
- .foot-links { display: flex; align-items: center; gap: 18px; }
244
-
245
- .mark-link {
246
- font: inherit;
247
- color: var(--muted);
248
- background: none;
249
- border: 0;
250
- padding: 0;
251
- cursor: pointer;
252
- }
253
- .mark-link:hover { color: var(--accent); }
254
- .mark-link:hover .mark b { color: var(--accent); }
255
-
256
- .app-footer a { color: var(--muted); text-decoration: none; }
257
- .app-footer a:hover { color: var(--accent); }
258
- .app-footer .mark b { font-weight: 700; color: var(--text); }
259
- .app-footer a:hover .mark b { color: var(--accent); }
package/src/scan.cjs ADDED
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ /*
4
+ * What a set of paths holds, for the window and the command line alike, so a
5
+ * folder means the same thing in both. The walk is the kit's folder intake
6
+ * (kit/scan.cjs, the same in every tool); what is Just Fits' own is here: the
7
+ * names it takes from inside a folder, and its own results (name-fits.mp4,
8
+ * name-fits 2.jpg), which are passed over so a folder fitted once and then
9
+ * again is not fitted on top of itself, and its results folders ("Holiday
10
+ * (fitted)"), for the same reason. A file named on its own is always taken,
11
+ * and the probe says whether it can be read.
12
+ */
13
+
14
+ const fs = require('node:fs');
15
+ const path = require('node:path');
16
+ const kit = require('./kit/scan.cjs');
17
+
18
+ const EXTENSIONS = new Set(['.mp4', '.mov', '.m4v', '.mkv', '.webm', '.avi', '.jpg', '.jpeg', '.png', '.heic', '.webp', '.gif',
19
+ '.mp3', '.m4a', '.aac', '.wav', '.flac', '.ogg', '.opus', '.aif', '.aiff']);
20
+ const OURS = /-fits( \d+)?$/i;
21
+
22
+ // What it did, for a folder's results folder: "Holiday (fitted)".
23
+ const WORD = 'fitted';
24
+
25
+ const scan = (paths) => kit.scan(paths, { extensions: [...EXTENSIONS], ours: OURS, word: WORD });
26
+
27
+ /*
28
+ * Where each file's result goes, for one run: a folder's results go into a
29
+ * new "Holiday (fitted)" beside it, chosen once per folder per run; a file on
30
+ * its own, or every file when beside is set (Save next to the originals
31
+ * instead), gets its result beside it. Either way a result is named
32
+ * name-fits.mp4 (decided 2026-11-20), so it reads as a result wherever it goes. Returns
33
+ * { outDir, suffix, folder } for the engine; folder is the results folder, or
34
+ * null beside the original.
35
+ */
36
+ function places({ beside = false } = {}) {
37
+ const chosen = new Map();
38
+ return (file) => {
39
+ if (beside || !file.from) return { outDir: undefined, suffix: undefined, folder: null };
40
+ if (!chosen.has(file.from)) chosen.set(file.from, kit.resultsFolder(file.from, WORD));
41
+ const folder = chosen.get(file.from);
42
+ return { outDir: kit.resultDir(file, folder), suffix: undefined, folder };
43
+ };
44
+ }
45
+
46
+ /*
47
+ * Whether a folder named holds anything Just Fits passes over for not being a
48
+ * video or picture (a PDF, a document, an archive), so the window can point
49
+ * to Just Zip for sending them as one file. Hidden files, a Mac's
50
+ * "._name" files, Just Fits' own results and results folders are not counted,
51
+ * as the walk does not take them either. It stops at the first one, looks at
52
+ * no more than a few thousand entries, and never throws.
53
+ */
54
+ async function others(paths) {
55
+ const results = new RegExp(` \\(${WORD}\\)( \\d+)?$`, 'i');
56
+ let looked = 0;
57
+ async function walk(dir) {
58
+ let entries;
59
+ try { entries = await fs.promises.readdir(dir, { withFileTypes: true }); } catch { return false; }
60
+ for (const entry of entries) {
61
+ if (++looked > 5000) return false;
62
+ if (entry.name.startsWith('.')) continue;
63
+ const full = path.join(dir, entry.name);
64
+ if (entry.isDirectory()) {
65
+ if (!results.test(entry.name) && await walk(full)) return true;
66
+ } else if (entry.isFile() && !EXTENSIONS.has(path.extname(entry.name).toLowerCase()) && !OURS.test(path.parse(entry.name).name)) {
67
+ return true;
68
+ }
69
+ }
70
+ return false;
71
+ }
72
+ for (const p of paths) {
73
+ let stat;
74
+ try { stat = await fs.promises.stat(p); } catch { continue; }
75
+ if (stat.isDirectory() && await walk(p)) return true;
76
+ }
77
+ return false;
78
+ }
79
+
80
+ module.exports = { scan, places, others, EXTENSIONS, WORD };