forge-terminal 0.1.0 → 0.2.1
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 +333 -24
- package/dist/chunks/adm-zip-SQKLKBDP.js +3 -0
- package/dist/chunks/available-HEUREG6L.js +3 -0
- package/dist/chunks/boot-BUGERSEB.js +3 -0
- package/dist/chunks/catalog-NTACQH5V.js +3 -0
- package/dist/chunks/cfb-V6M2PYOD.js +13 -0
- package/dist/chunks/chunk-2WYHI73Y.js +3 -0
- package/dist/chunks/chunk-4YCO7S4K.js +3 -0
- package/dist/chunks/chunk-5B7WODWH.js +3 -0
- package/dist/chunks/chunk-C2WYXNRM.js +4 -0
- package/dist/chunks/chunk-C7OOWUMU.js +3 -0
- package/dist/chunks/chunk-EOYBXOCV.js +4 -0
- package/dist/chunks/chunk-G2D6BKOS.js +4 -0
- package/dist/chunks/chunk-HUAEVW2A.js +3 -0
- package/dist/chunks/chunk-J7FLFHQJ.js +3 -0
- package/dist/chunks/chunk-L76Q54MB.js +3 -0
- package/dist/chunks/chunk-LFE3WRU4.js +3 -0
- package/dist/chunks/chunk-PBIS2ONZ.js +3 -0
- package/dist/chunks/chunk-PD5DFBCU.js +3 -0
- package/dist/chunks/chunk-PN73WK2S.js +3 -0
- package/dist/chunks/chunk-QVACE4IE.js +3 -0
- package/dist/chunks/chunk-TEGB7JRM.js +3 -0
- package/dist/chunks/chunk-TMUK2DD3.js +3 -0
- package/dist/chunks/chunk-UNVHKJW4.js +41 -0
- package/dist/chunks/chunk-VH5RWPGZ.js +10 -0
- package/dist/chunks/chunk-XFEHJ4C7.js +3 -0
- package/dist/chunks/chunk-YXDEOLNA.js +3 -0
- package/dist/chunks/colour-DE6N6AZO.js +3 -0
- package/dist/chunks/config-command-SQXRTBRO.js +3 -0
- package/dist/chunks/dist-J2V6ITHG.js +29 -0
- package/dist/chunks/es-T2U7NBLD.js +3 -0
- package/dist/chunks/execute-M3C3TTWB.js +3 -0
- package/dist/chunks/extensions-command-HJDBUBYO.js +3 -0
- package/dist/chunks/image-GYUUMS6H.js +3 -0
- package/dist/chunks/launch-WBUFRVQ7.js +65 -0
- package/dist/chunks/lib-TPEJ5CJJ.js +46 -0
- package/dist/chunks/lock-XD4L3WFM.js +3 -0
- package/dist/chunks/manager-KBJTXZ27.js +4 -0
- package/dist/chunks/paths-JUM6GKQU.js +3 -0
- package/dist/chunks/pdf-compress-IMRFBLZF.js +3 -0
- package/dist/chunks/react-devtools-core-UM4FS6CU.js +3 -0
- package/dist/chunks/run-RXVQD4DZ.js +4 -0
- package/dist/chunks/server-DU7QWDAH.js +73 -0
- package/dist/chunks/theme-DESCJOCE.js +3 -0
- package/dist/chunks/word-OGQ2KZAJ.js +24 -0
- package/dist/index.js +67 -95
- package/dist/third-party-licenses.txt +2856 -0
- package/package.json +28 -21
- package/skills/forge/SKILL.md +149 -0
- package/dist/cli/args.js +0 -278
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/config-command.js +0 -55
- package/dist/cli/config-command.js.map +0 -1
- package/dist/cli/execute.js +0 -377
- package/dist/cli/execute.js.map +0 -1
- package/dist/cli/report.js +0 -123
- package/dist/cli/report.js.map +0 -1
- package/dist/cli/spinner.js +0 -60
- package/dist/cli/spinner.js.map +0 -1
- package/dist/cli/stdin.js +0 -47
- package/dist/cli/stdin.js.map +0 -1
- package/dist/config/preferences.js +0 -143
- package/dist/config/preferences.js.map +0 -1
- package/dist/core/actions/compress.js +0 -157
- package/dist/core/actions/compress.js.map +0 -1
- package/dist/core/actions/convert.js +0 -270
- package/dist/core/actions/convert.js.map +0 -1
- package/dist/core/actions/extract.js +0 -94
- package/dist/core/actions/extract.js.map +0 -1
- package/dist/core/actions/index.js +0 -23
- package/dist/core/actions/index.js.map +0 -1
- package/dist/core/actions/merge.js +0 -16
- package/dist/core/actions/merge.js.map +0 -1
- package/dist/core/actions/rotate.js +0 -36
- package/dist/core/actions/rotate.js.map +0 -1
- package/dist/core/actions/split.js +0 -65
- package/dist/core/actions/split.js.map +0 -1
- package/dist/core/atomic.js +0 -61
- package/dist/core/atomic.js.map +0 -1
- package/dist/core/capabilities.js +0 -59
- package/dist/core/capabilities.js.map +0 -1
- package/dist/core/compress.js +0 -76
- package/dist/core/compress.js.map +0 -1
- package/dist/core/describe.js +0 -49
- package/dist/core/describe.js.map +0 -1
- package/dist/core/errors.js +0 -469
- package/dist/core/errors.js.map +0 -1
- package/dist/core/execute-jobs.js +0 -122
- package/dist/core/execute-jobs.js.map +0 -1
- package/dist/core/formats.js +0 -108
- package/dist/core/formats.js.map +0 -1
- package/dist/core/order.js +0 -44
- package/dist/core/order.js.map +0 -1
- package/dist/core/output-path.js +0 -176
- package/dist/core/output-path.js.map +0 -1
- package/dist/core/pages.js +0 -107
- package/dist/core/pages.js.map +0 -1
- package/dist/core/pdf-compress.js +0 -206
- package/dist/core/pdf-compress.js.map +0 -1
- package/dist/core/plan.js +0 -42
- package/dist/core/plan.js.map +0 -1
- package/dist/core/resolve.js +0 -115
- package/dist/core/resolve.js.map +0 -1
- package/dist/core/run.js +0 -66
- package/dist/core/run.js.map +0 -1
- package/dist/core/suggest.js +0 -50
- package/dist/core/suggest.js.map +0 -1
- package/dist/core/types.js +0 -2
- package/dist/core/types.js.map +0 -1
- package/dist/core/units.js +0 -94
- package/dist/core/units.js.map +0 -1
- package/dist/core/write-safety.js +0 -128
- package/dist/core/write-safety.js.map +0 -1
- package/dist/engines/heic.js +0 -166
- package/dist/engines/heic.js.map +0 -1
- package/dist/engines/image.js +0 -342
- package/dist/engines/image.js.map +0 -1
- package/dist/engines/pdf.js +0 -444
- package/dist/engines/pdf.js.map +0 -1
- package/dist/engines/pdfium.js +0 -161
- package/dist/engines/pdfium.js.map +0 -1
- package/dist/engines/registry.js +0 -65
- package/dist/engines/registry.js.map +0 -1
- package/dist/engines/types.js +0 -2
- package/dist/engines/types.js.map +0 -1
- package/dist/engines/word.js +0 -385
- package/dist/engines/word.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shell/App.js +0 -1972
- package/dist/shell/App.js.map +0 -1
- package/dist/shell/ClickTargets.js +0 -183
- package/dist/shell/ClickTargets.js.map +0 -1
- package/dist/shell/ThemeContext.js +0 -21
- package/dist/shell/ThemeContext.js.map +0 -1
- package/dist/shell/blocks.js +0 -160
- package/dist/shell/blocks.js.map +0 -1
- package/dist/shell/clipboard.js +0 -64
- package/dist/shell/clipboard.js.map +0 -1
- package/dist/shell/commands.js +0 -51
- package/dist/shell/commands.js.map +0 -1
- package/dist/shell/components/Banner.js +0 -73
- package/dist/shell/components/Banner.js.map +0 -1
- package/dist/shell/components/CommandPalette.js +0 -37
- package/dist/shell/components/CommandPalette.js.map +0 -1
- package/dist/shell/components/FileCard.js +0 -59
- package/dist/shell/components/FileCard.js.map +0 -1
- package/dist/shell/components/HintBar.js +0 -18
- package/dist/shell/components/HintBar.js.map +0 -1
- package/dist/shell/components/Hints.js +0 -21
- package/dist/shell/components/Hints.js.map +0 -1
- package/dist/shell/components/MergeList.js +0 -268
- package/dist/shell/components/MergeList.js.map +0 -1
- package/dist/shell/components/ModeHeader.js +0 -21
- package/dist/shell/components/ModeHeader.js.map +0 -1
- package/dist/shell/components/PageGrid.js +0 -324
- package/dist/shell/components/PageGrid.js.map +0 -1
- package/dist/shell/components/PathInput.js +0 -147
- package/dist/shell/components/PathInput.js.map +0 -1
- package/dist/shell/components/Progress.js +0 -43
- package/dist/shell/components/Progress.js.map +0 -1
- package/dist/shell/components/Prompt.js +0 -667
- package/dist/shell/components/Prompt.js.map +0 -1
- package/dist/shell/components/ResultLinks.js +0 -26
- package/dist/shell/components/ResultLinks.js.map +0 -1
- package/dist/shell/components/Select.js +0 -152
- package/dist/shell/components/Select.js.map +0 -1
- package/dist/shell/components/Slider.js +0 -48
- package/dist/shell/components/Slider.js.map +0 -1
- package/dist/shell/components/StagedFiles.js +0 -92
- package/dist/shell/components/StagedFiles.js.map +0 -1
- package/dist/shell/components/ThemePicker.js +0 -18
- package/dist/shell/components/ThemePicker.js.map +0 -1
- package/dist/shell/components/UnitRow.js +0 -30
- package/dist/shell/components/UnitRow.js.map +0 -1
- package/dist/shell/flows/pdf.js +0 -424
- package/dist/shell/flows/pdf.js.map +0 -1
- package/dist/shell/frame-geometry.js +0 -56
- package/dist/shell/frame-geometry.js.map +0 -1
- package/dist/shell/hyperlink.js +0 -27
- package/dist/shell/hyperlink.js.map +0 -1
- package/dist/shell/intro.js +0 -101
- package/dist/shell/intro.js.map +0 -1
- package/dist/shell/launch.js +0 -75
- package/dist/shell/launch.js.map +0 -1
- package/dist/shell/mark.js +0 -134
- package/dist/shell/mark.js.map +0 -1
- package/dist/shell/mouse.js +0 -209
- package/dist/shell/mouse.js.map +0 -1
- package/dist/shell/redraw.js +0 -36
- package/dist/shell/redraw.js.map +0 -1
- package/dist/shell/reveal.js +0 -24
- package/dist/shell/reveal.js.map +0 -1
- package/dist/shell/stage.js +0 -34
- package/dist/shell/stage.js.map +0 -1
- package/dist/shell/terminal-write.js +0 -16
- package/dist/shell/terminal-write.js.map +0 -1
- package/dist/shell/theme.js +0 -178
- package/dist/shell/theme.js.map +0 -1
- package/dist/shell/useFrameOrigin.js +0 -175
- package/dist/shell/useFrameOrigin.js.map +0 -1
- package/dist/shell/useKeys.js +0 -28
- package/dist/shell/useKeys.js.map +0 -1
- package/dist/shell/useMouse.js +0 -150
- package/dist/shell/useMouse.js.map +0 -1
- package/dist/shell/useMouseRouting.js +0 -69
- package/dist/shell/useMouseRouting.js.map +0 -1
- package/dist/shell/width.js +0 -62
- package/dist/shell/width.js.map +0 -1
- package/dist/utils/display-path.js +0 -31
- package/dist/utils/display-path.js.map +0 -1
- package/dist/utils/unescape-path.js +0 -68
- package/dist/utils/unescape-path.js.map +0 -1
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile, rename, unlink, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
export const DEFAULT_PREFERENCES = {
|
|
5
|
-
defaultOutput: '~/Desktop',
|
|
6
|
-
quality: 80,
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Read at call time, not at module load: tests set XDG_CONFIG_HOME per case,
|
|
10
|
-
* and a value captured at import would pin every case to whichever ran first.
|
|
11
|
-
*/
|
|
12
|
-
export function configPath() {
|
|
13
|
-
const base = process.env.XDG_CONFIG_HOME;
|
|
14
|
-
const root = base !== undefined && base.length > 0 ? base : join(homedir(), '.config');
|
|
15
|
-
return join(root, 'forge', 'config.json');
|
|
16
|
-
}
|
|
17
|
-
export function expandTilde(path) {
|
|
18
|
-
if (path === '~')
|
|
19
|
-
return homedir();
|
|
20
|
-
if (path.startsWith('~/'))
|
|
21
|
-
return join(homedir(), path.slice(2));
|
|
22
|
-
return path;
|
|
23
|
-
}
|
|
24
|
-
function isRecord(v) {
|
|
25
|
-
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Validates field by field rather than all-or-nothing: one bad key should not
|
|
29
|
-
* cost the user the settings that are fine. Collects what it rejected so the
|
|
30
|
-
* caller can say so once, then proceeds.
|
|
31
|
-
*/
|
|
32
|
-
function validate(raw) {
|
|
33
|
-
const prefs = { ...DEFAULT_PREFERENCES };
|
|
34
|
-
const rejected = [];
|
|
35
|
-
if (raw.theme !== undefined) {
|
|
36
|
-
if (raw.theme === 'dark' || raw.theme === 'light')
|
|
37
|
-
prefs.theme = raw.theme;
|
|
38
|
-
else
|
|
39
|
-
rejected.push('theme');
|
|
40
|
-
}
|
|
41
|
-
if (raw.defaultOutput !== undefined) {
|
|
42
|
-
if (typeof raw.defaultOutput === 'string' && raw.defaultOutput.trim().length > 0) {
|
|
43
|
-
prefs.defaultOutput = raw.defaultOutput;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
rejected.push('defaultOutput');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (raw.quality !== undefined) {
|
|
50
|
-
const q = raw.quality;
|
|
51
|
-
if (typeof q === 'number' && Number.isInteger(q) && q >= 1 && q <= 100)
|
|
52
|
-
prefs.quality = q;
|
|
53
|
-
else
|
|
54
|
-
rejected.push('quality');
|
|
55
|
-
}
|
|
56
|
-
return { prefs, rejected };
|
|
57
|
-
}
|
|
58
|
-
/** The parsed file, or undefined if it is missing, unreadable, or not an object. */
|
|
59
|
-
async function readRaw() {
|
|
60
|
-
let text;
|
|
61
|
-
try {
|
|
62
|
-
text = await readFile(configPath(), 'utf8');
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
const parsed = JSON.parse(text);
|
|
69
|
-
return isRecord(parsed) ? parsed : undefined;
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Never throws, and never blocks a conversion. A missing file is the normal
|
|
77
|
-
* first-run case and is silent; anything else that goes wrong yields defaults
|
|
78
|
-
* plus one sentence the caller renders once as history.
|
|
79
|
-
*/
|
|
80
|
-
export async function loadPreferences() {
|
|
81
|
-
const path = configPath();
|
|
82
|
-
let text;
|
|
83
|
-
try {
|
|
84
|
-
text = await readFile(path, 'utf8');
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
if (e.code === 'ENOENT')
|
|
88
|
-
return { prefs: DEFAULT_PREFERENCES };
|
|
89
|
-
return {
|
|
90
|
-
prefs: DEFAULT_PREFERENCES,
|
|
91
|
-
warning: `Could not read the config at ${path} — using defaults.`,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
let parsed;
|
|
95
|
-
try {
|
|
96
|
-
parsed = JSON.parse(text);
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
return {
|
|
100
|
-
prefs: DEFAULT_PREFERENCES,
|
|
101
|
-
warning: `The config at ${path} is not valid JSON — using defaults.`,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if (!isRecord(parsed)) {
|
|
105
|
-
return {
|
|
106
|
-
prefs: DEFAULT_PREFERENCES,
|
|
107
|
-
warning: `The config at ${path} is not an object — using defaults.`,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
const { prefs, rejected } = validate(parsed);
|
|
111
|
-
if (rejected.length === 0)
|
|
112
|
-
return { prefs };
|
|
113
|
-
return {
|
|
114
|
-
prefs,
|
|
115
|
-
warning: `Ignored invalid config ${rejected.length === 1 ? 'setting' : 'settings'}: ${rejected.join(', ')}.`,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Merges `patch` over whatever is on disk and writes atomically (invariant 6).
|
|
120
|
-
* Re-reading rather than serialising a whole in-memory object is what
|
|
121
|
-
* preserves keys a later version of Forge may have written — an older binary
|
|
122
|
-
* must not silently destroy a newer one's settings.
|
|
123
|
-
*/
|
|
124
|
-
export async function savePreferences(patch) {
|
|
125
|
-
const path = configPath();
|
|
126
|
-
await mkdir(dirname(path), { recursive: true });
|
|
127
|
-
const existing = (await readRaw()) ?? {};
|
|
128
|
-
const merged = { ...existing };
|
|
129
|
-
for (const [key, value] of Object.entries(patch)) {
|
|
130
|
-
if (value !== undefined)
|
|
131
|
-
merged[key] = value;
|
|
132
|
-
}
|
|
133
|
-
const temp = `${path}.${process.pid}.tmp`;
|
|
134
|
-
try {
|
|
135
|
-
await writeFile(temp, `${JSON.stringify(merged, null, 2)}\n`, 'utf8');
|
|
136
|
-
await rename(temp, path);
|
|
137
|
-
}
|
|
138
|
-
catch (e) {
|
|
139
|
-
await unlink(temp).catch(() => { });
|
|
140
|
-
throw e;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=preferences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../src/config/preferences.ts"],"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, join } from 'node:path';
|
|
3
|
-
import { expandTilde } from '../../config/preferences.js';
|
|
4
|
-
import { invalidArguments } from '../errors.js';
|
|
5
|
-
import { FORMATS, primaryExtension } from '../formats.js';
|
|
6
|
-
const soleImage = (sources) => sources.length === 1 && sources[0]?.kind === 'image' ? sources[0] : undefined;
|
|
7
|
-
const soleDocument = (sources) => sources.length === 1 && sources[0]?.kind === 'document' ? sources[0] : undefined;
|
|
8
|
-
/**
|
|
9
|
-
* The suffix that keeps a compressed file from landing on its source.
|
|
10
|
-
*
|
|
11
|
-
* Compression keeps the extension, so without this the default output *is*
|
|
12
|
-
* the input whenever "Same folder" is chosen, and `buildPlan` would refuse
|
|
13
|
-
* every run under the never-write-over-the-input rule. The name step comes
|
|
14
|
-
* after, so this is a default the user can overwrite rather than a rule.
|
|
15
|
-
*/
|
|
16
|
-
const SUFFIX = '-small';
|
|
17
|
-
function labelFor(path, sourceDir) {
|
|
18
|
-
if (path === sourceDir)
|
|
19
|
-
return 'Same folder';
|
|
20
|
-
if (path === join(homedir(), 'Desktop'))
|
|
21
|
-
return 'Desktop';
|
|
22
|
-
if (path === join(homedir(), 'Downloads'))
|
|
23
|
-
return 'Downloads';
|
|
24
|
-
return path.split('/').pop() || path;
|
|
25
|
-
}
|
|
26
|
-
function destinationPath(source, prefs) {
|
|
27
|
-
const here = dirname(source.path);
|
|
28
|
-
const preferred = expandTilde(prefs.defaultOutput);
|
|
29
|
-
const candidates = [
|
|
30
|
-
{ label: labelFor(preferred, here), path: preferred },
|
|
31
|
-
{ label: 'Desktop', path: join(homedir(), 'Desktop') },
|
|
32
|
-
{ label: 'Same folder', path: here },
|
|
33
|
-
{ label: 'Downloads', path: join(homedir(), 'Downloads') },
|
|
34
|
-
];
|
|
35
|
-
// Two presets can resolve to one folder — the configured default is often
|
|
36
|
-
// Desktop. Select keys rows by path, so an undeduped collision is two
|
|
37
|
-
// components sharing one identity, which React refuses to render reliably.
|
|
38
|
-
const seen = new Set();
|
|
39
|
-
const presets = candidates.filter((preset) => {
|
|
40
|
-
if (seen.has(preset.path))
|
|
41
|
-
return false;
|
|
42
|
-
seen.add(preset.path);
|
|
43
|
-
return true;
|
|
44
|
-
});
|
|
45
|
-
return { kind: 'path', id: 'destination', label: 'Save to', default: preferred, presets };
|
|
46
|
-
}
|
|
47
|
-
export const compressAction = {
|
|
48
|
-
id: 'compress',
|
|
49
|
-
label: 'Compress',
|
|
50
|
-
hint: 'make it smaller',
|
|
51
|
-
/**
|
|
52
|
-
* Only formats with a quality dial.
|
|
53
|
-
*
|
|
54
|
-
* Compressing a PNG by quality is not something the encoder can do —
|
|
55
|
-
* `formats.ts` declares PNG lossless and `engines/image.ts` encodes it
|
|
56
|
-
* losslessly on purpose — so offering it here would promise something that
|
|
57
|
-
* cannot happen. Making a PNG smaller means changing its format, which is
|
|
58
|
-
* what `/convert` is for.
|
|
59
|
-
*/
|
|
60
|
-
appliesTo: (sources) => {
|
|
61
|
-
const image = soleImage(sources);
|
|
62
|
-
if (image !== undefined)
|
|
63
|
-
return FORMATS[image.format].lossy;
|
|
64
|
-
/**
|
|
65
|
-
* A PDF qualifies when it holds at least one image this can re-encode.
|
|
66
|
-
*
|
|
67
|
-
* The container itself is lossless, which is why this used to refuse
|
|
68
|
-
* every PDF — but a scan is JPEG data in a PDF wrapper, and that is the
|
|
69
|
-
* same trade compression offers anywhere else.
|
|
70
|
-
*
|
|
71
|
-
* Counted at probe time (`engines/pdf.ts`), so the flow is only offered
|
|
72
|
-
* when it can actually deliver: a text-only PDF and a PDF whose images
|
|
73
|
-
* are all Flate-encoded both have nothing to give, and opening the
|
|
74
|
-
* quality slider for either would promise a saving that cannot happen.
|
|
75
|
-
*
|
|
76
|
-
* `?? 0` matters: `images` is optional on `DocumentInfo`, and a source
|
|
77
|
-
* built without it has to read as "nothing known to compress" rather
|
|
78
|
-
* than throw.
|
|
79
|
-
*/
|
|
80
|
-
const document = soleDocument(sources);
|
|
81
|
-
return (document?.images?.compressible ?? 0) > 0;
|
|
82
|
-
},
|
|
83
|
-
options(sources, values, prefs) {
|
|
84
|
-
const source = sources[0];
|
|
85
|
-
if (!source)
|
|
86
|
-
return [];
|
|
87
|
-
const specs = [
|
|
88
|
-
{
|
|
89
|
-
kind: 'select',
|
|
90
|
-
id: 'mode',
|
|
91
|
-
label: `Compress ${source.path.split('/').pop() ?? 'this file'}`,
|
|
92
|
-
choices: [
|
|
93
|
-
{ value: 'quality', label: 'By quality', hint: 'pick a level, see the result' },
|
|
94
|
-
{ value: 'size', label: 'To a target size', hint: 'smallest quality that fits' },
|
|
95
|
-
],
|
|
96
|
-
default: 'quality',
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
if (values.mode === 'quality') {
|
|
100
|
-
specs.push({
|
|
101
|
-
kind: 'slider',
|
|
102
|
-
id: 'quality',
|
|
103
|
-
label: 'Quality',
|
|
104
|
-
min: 1,
|
|
105
|
-
max: 100,
|
|
106
|
-
step: 5,
|
|
107
|
-
default: prefs.quality,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
else if (values.mode === 'size') {
|
|
111
|
-
specs.push({
|
|
112
|
-
kind: 'text',
|
|
113
|
-
id: 'size',
|
|
114
|
-
label: 'Target size',
|
|
115
|
-
placeholder: 'e.g. 500kb or 2mb',
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
// Nothing further is knowable until the mode is answered — the steps
|
|
120
|
-
// after it differ entirely.
|
|
121
|
-
return specs;
|
|
122
|
-
}
|
|
123
|
-
specs.push(destinationPath(source, prefs));
|
|
124
|
-
return specs;
|
|
125
|
-
},
|
|
126
|
-
plan(sources, values) {
|
|
127
|
-
const mode = values.mode;
|
|
128
|
-
if (mode !== 'quality' && mode !== 'size') {
|
|
129
|
-
throw invalidArguments(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(mode)}.`, 'This is a caller bug, not a user-facing condition: walk options() before calling plan().');
|
|
130
|
-
}
|
|
131
|
-
const source = sources[0];
|
|
132
|
-
if (!source)
|
|
133
|
-
return [];
|
|
134
|
-
const stem = (source.path.split('/').pop() ?? 'file').replace(/\.[^.]+$/, '');
|
|
135
|
-
const destination = typeof values.destination === 'string' ? values.destination : dirname(source.path);
|
|
136
|
-
const output = `${destination}/${stem}${SUFFIX}${primaryExtension(source.format)}`;
|
|
137
|
-
return [
|
|
138
|
-
{
|
|
139
|
-
op: 'convert',
|
|
140
|
-
sources: [source],
|
|
141
|
-
// The whole point of the action: the format does not change.
|
|
142
|
-
target: source.format,
|
|
143
|
-
outputs: [output],
|
|
144
|
-
options: {
|
|
145
|
-
background: '#ffffff',
|
|
146
|
-
keepMetadata: false,
|
|
147
|
-
// In size mode the quality is the search's answer, not the user's,
|
|
148
|
-
// so none is carried here — the caller fills it in once found.
|
|
149
|
-
...(mode === 'quality' && typeof values.quality === 'number'
|
|
150
|
-
? { quality: values.quality }
|
|
151
|
-
: {}),
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
];
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
//# sourceMappingURL=compress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../src/core/actions/compress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,WAAW,EAAoB,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAIzD,MAAM,SAAS,GAAG,CAAC,OAAqB,EAAyB,EAAE,CACjE,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC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-
import { expandTilde } from '../../config/preferences.js';
|
|
4
|
-
import { rasterises, targetsFor } from '../capabilities.js';
|
|
5
|
-
import { invalidArguments } from '../errors.js';
|
|
6
|
-
import { FORMATS, formatById } from '../formats.js';
|
|
7
|
-
import { rasterOutputPaths, resolveOutputPath } from '../output-path.js';
|
|
8
|
-
import { normalisePages, parseRanges } from '../pages.js';
|
|
9
|
-
/**
|
|
10
|
-
* Which pages to rasterise, and the resolution to do it at. Only offered
|
|
11
|
-
* once a document source has a target that actually rasterises it — jpeg or
|
|
12
|
-
* png via pdfium, checked by the caller with `rasterises(target)`. A pdf/
|
|
13
|
-
* docx/doc target is a document-to-document conversion with no pages or
|
|
14
|
-
* dpi concept, and is never routed here.
|
|
15
|
-
*
|
|
16
|
-
* `choose` hands off to the shell's page picker (`PageGrid`, phase 3) rather
|
|
17
|
-
* than a typed field: the grid is the one existing UI for this, and building
|
|
18
|
-
* a second picker for the same job is exactly what note 4 warns against.
|
|
19
|
-
*/
|
|
20
|
-
function pagesSelect(doc) {
|
|
21
|
-
return {
|
|
22
|
-
kind: 'select',
|
|
23
|
-
id: 'pages',
|
|
24
|
-
label: 'Pages',
|
|
25
|
-
default: 'all',
|
|
26
|
-
choices: [
|
|
27
|
-
{ value: 'all', label: 'All pages', hint: `${doc.pages} pages` },
|
|
28
|
-
{ value: 'first', label: 'First page only' },
|
|
29
|
-
{ value: 'choose', label: 'Choose pages', hint: 'pick which ones' },
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The shell offers three presets because a picker needs a short list; the
|
|
35
|
-
* CLI's own `--dpi` has no such constraint and accepts any integer in
|
|
36
|
-
* `invalidDpi`'s 36-600 range (spec §10). 150 is the default either way.
|
|
37
|
-
*/
|
|
38
|
-
function dpiSelect() {
|
|
39
|
-
return {
|
|
40
|
-
kind: 'select',
|
|
41
|
-
id: 'dpi',
|
|
42
|
-
label: 'Resolution',
|
|
43
|
-
default: '150',
|
|
44
|
-
choices: [
|
|
45
|
-
{ value: '72', label: '72 dpi', hint: 'screen' },
|
|
46
|
-
{ value: '150', label: '150 dpi', hint: 'default' },
|
|
47
|
-
{ value: '300', label: '300 dpi', hint: 'print' },
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* `values.pages` arrives as one of: `'all'` (or unset), `'first'`, a typed
|
|
53
|
-
* range string (`parseRanges`'s grammar), or an explicit array — the shape
|
|
54
|
-
* `PageGrid`'s `onSubmit` hands back after "Choose pages". Every branch is
|
|
55
|
-
* normalised through the one ordering authority, `core/pages.ts`'s
|
|
56
|
-
* `normalisePages` — the same function `core/actions/extract.ts`'s
|
|
57
|
-
* `selectedPages` uses, so naming and rendering can never derive from two
|
|
58
|
-
* different orderings (phase 3's worst defect).
|
|
59
|
-
*/
|
|
60
|
-
function resolvePages(doc, raw) {
|
|
61
|
-
if (Array.isArray(raw))
|
|
62
|
-
return normalisePages(raw);
|
|
63
|
-
if (raw === 'first')
|
|
64
|
-
return [0];
|
|
65
|
-
if (typeof raw === 'string' && raw !== 'all' && raw !== '') {
|
|
66
|
-
return normalisePages(parseRanges(raw, doc.pages));
|
|
67
|
-
}
|
|
68
|
-
return Array.from({ length: doc.pages }, (_, i) => i);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Which way a target is likely to move the file's size, or undefined when
|
|
72
|
-
* there is no honest claim to make.
|
|
73
|
-
*
|
|
74
|
-
* Derived from the two formats' `lossy` flags rather than any table of
|
|
75
|
-
* pairs, so it holds for every format the engines gain later without a rule
|
|
76
|
-
* of its own: lossless keeps every pixel, which costs bytes a lossy source
|
|
77
|
-
* had already given up, and the reverse trade goes the other way. Lossy to
|
|
78
|
-
* lossy (and lossless to lossless) is left unclaimed — that comparison
|
|
79
|
-
* depends on the quality each side is encoded at, which is not known until
|
|
80
|
-
* something is actually encoded, and inventing a direction here would be
|
|
81
|
-
* exactly the kind of guess spec §12 keeps out of progress reporting.
|
|
82
|
-
*/
|
|
83
|
-
function sizeExpectation(source, target) {
|
|
84
|
-
const from = FORMATS[source.format].lossy;
|
|
85
|
-
const to = FORMATS[target].lossy;
|
|
86
|
-
if (from && !to)
|
|
87
|
-
return { hint: 'likely bigger', tone: 'warn' };
|
|
88
|
-
if (!from && to)
|
|
89
|
-
return { hint: 'likely smaller', tone: 'ok' };
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
function targetSelect(source) {
|
|
93
|
-
// Converting a file to its own format changes nothing the user can see,
|
|
94
|
-
// so it is never offered here (the CLI's separate `--to jpeg` recompress
|
|
95
|
-
// flow is unaffected — that goes through core/plan.ts, not this file).
|
|
96
|
-
const targets = targetsFor(source).filter((t) => t.id !== source.format);
|
|
97
|
-
const first = targets[0];
|
|
98
|
-
return {
|
|
99
|
-
kind: 'select',
|
|
100
|
-
id: 'target',
|
|
101
|
-
// Names the source format explicitly, so it reads as "pick something
|
|
102
|
-
// else" rather than leaving the user to wonder why their own format
|
|
103
|
-
// is missing from the list.
|
|
104
|
-
label: `Convert ${FORMATS[source.format].label} to`,
|
|
105
|
-
choices: targets.map((t) => {
|
|
106
|
-
// The size expectation replaces the format's own descriptive hint
|
|
107
|
-
// rather than joining it: one short phrase per row is what the width
|
|
108
|
-
// budget in `Select` was built around, and "smaller, modern · likely
|
|
109
|
-
// bigger" reads as a contradiction even though both halves are true.
|
|
110
|
-
const expectation = sizeExpectation(source, t.id);
|
|
111
|
-
return {
|
|
112
|
-
value: t.id,
|
|
113
|
-
label: t.label,
|
|
114
|
-
hint: expectation?.hint ?? t.hint,
|
|
115
|
-
...(expectation === undefined ? {} : { tone: expectation.tone }),
|
|
116
|
-
};
|
|
117
|
-
}),
|
|
118
|
-
default: first ? first.id : '',
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* plan() cannot trust `values.target` the way options() can afford to — a
|
|
123
|
-
* caller (in practice, the shell) is expected to reach plan() only after
|
|
124
|
-
* walking options(), but nothing enforces that. An unchecked `as FormatId`
|
|
125
|
-
* here would let a missing, empty, or bogus target slip through and crash
|
|
126
|
-
* deep inside resolveOutputPath instead of failing at the boundary with a
|
|
127
|
-
* message that says what went wrong.
|
|
128
|
-
*/
|
|
129
|
-
function requireTarget(values) {
|
|
130
|
-
const raw = values.target;
|
|
131
|
-
const spec = typeof raw === 'string' ? formatById(raw) : undefined;
|
|
132
|
-
if (!spec) {
|
|
133
|
-
throw invalidArguments(`convertAction.plan() requires a valid target format, got ${JSON.stringify(raw)}.`, 'This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().');
|
|
134
|
-
}
|
|
135
|
-
return spec;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Names a path the way the built-in presets do, so a hoisted default is not
|
|
139
|
-
* shown as a bare path when it happens to be one of them.
|
|
140
|
-
*/
|
|
141
|
-
function labelFor(path, sourceDir) {
|
|
142
|
-
if (path === sourceDir)
|
|
143
|
-
return 'Same folder';
|
|
144
|
-
if (path === join(homedir(), 'Desktop'))
|
|
145
|
-
return 'Desktop';
|
|
146
|
-
if (path === join(homedir(), 'Downloads'))
|
|
147
|
-
return 'Downloads';
|
|
148
|
-
if (path === join(sourceDir, 'converted'))
|
|
149
|
-
return 'New subfolder';
|
|
150
|
-
return path.split('/').pop() || path;
|
|
151
|
-
}
|
|
152
|
-
function destinationPath(source, prefs) {
|
|
153
|
-
const here = dirname(source.path);
|
|
154
|
-
const preferred = expandTilde(prefs.defaultOutput);
|
|
155
|
-
// The configured default leads, listed explicitly so that a default
|
|
156
|
-
// pointing somewhere none of the built-ins cover still appears at all. When
|
|
157
|
-
// it *is* one of them, the dedupe below collapses the pair and this entry
|
|
158
|
-
// wins — which is why it carries the built-in's label rather than a path.
|
|
159
|
-
const candidates = [
|
|
160
|
-
{ label: labelFor(preferred, here), path: preferred },
|
|
161
|
-
{ label: 'Desktop', path: join(homedir(), 'Desktop') },
|
|
162
|
-
{ label: 'Same folder', path: here },
|
|
163
|
-
{ label: 'Downloads', path: join(homedir(), 'Downloads') },
|
|
164
|
-
{ label: 'New subfolder', path: join(here, 'converted') },
|
|
165
|
-
];
|
|
166
|
-
// Two presets can resolve to the identical folder — e.g. "Same folder" and
|
|
167
|
-
// "Downloads" collide whenever the source file already lives in
|
|
168
|
-
// ~/Downloads. `Select` keys each row by its path, so an undeduped
|
|
169
|
-
// collision here is not cosmetic: React treats it as two components
|
|
170
|
-
// sharing one identity and refuses to render reliably. Keep the earlier
|
|
171
|
-
// (more specific) preset and drop the redundant one.
|
|
172
|
-
const seen = new Set();
|
|
173
|
-
const presets = candidates.filter((preset) => {
|
|
174
|
-
if (seen.has(preset.path))
|
|
175
|
-
return false;
|
|
176
|
-
seen.add(preset.path);
|
|
177
|
-
return true;
|
|
178
|
-
});
|
|
179
|
-
return {
|
|
180
|
-
kind: 'path',
|
|
181
|
-
id: 'destination',
|
|
182
|
-
label: 'Save to',
|
|
183
|
-
default: preferred,
|
|
184
|
-
presets,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
export const convertAction = {
|
|
188
|
-
id: 'convert',
|
|
189
|
-
label: 'Convert',
|
|
190
|
-
hint: 'to another format',
|
|
191
|
-
appliesTo: (sources) => sources.length >= 1,
|
|
192
|
-
options(sources, values, prefs) {
|
|
193
|
-
const source = sources[0];
|
|
194
|
-
if (!source)
|
|
195
|
-
return [];
|
|
196
|
-
const specs = [targetSelect(source)];
|
|
197
|
-
const target = values.target;
|
|
198
|
-
if (typeof target !== 'string')
|
|
199
|
-
return specs;
|
|
200
|
-
// A document source only needs the pages/resolution pickers when the
|
|
201
|
-
// chosen target actually rasterises it (jpeg/png, via pdfium) — a
|
|
202
|
-
// target of pdf/docx/doc is a document-to-document conversion with no
|
|
203
|
-
// pages or dpi concept at all.
|
|
204
|
-
if (source.kind === 'document' && rasterises(target)) {
|
|
205
|
-
specs.push(pagesSelect(source), dpiSelect());
|
|
206
|
-
}
|
|
207
|
-
const spec = FORMATS[target];
|
|
208
|
-
if (spec?.lossy) {
|
|
209
|
-
specs.push({
|
|
210
|
-
kind: 'slider',
|
|
211
|
-
id: 'quality',
|
|
212
|
-
label: 'Quality',
|
|
213
|
-
min: 1,
|
|
214
|
-
max: 100,
|
|
215
|
-
step: 5,
|
|
216
|
-
default: prefs.quality,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
specs.push(destinationPath(source, prefs));
|
|
220
|
-
return specs;
|
|
221
|
-
},
|
|
222
|
-
plan(sources, values) {
|
|
223
|
-
const source = sources[0];
|
|
224
|
-
if (!source)
|
|
225
|
-
return [];
|
|
226
|
-
const spec = requireTarget(values);
|
|
227
|
-
const target = spec.id;
|
|
228
|
-
const options = {
|
|
229
|
-
// The caller's fill colour when one is given. The shell has no
|
|
230
|
-
// background control and passes nothing, so it keeps the white default;
|
|
231
|
-
// the CLI's `--background` reaches here through `values`. Hardcoding
|
|
232
|
-
// white made that flag work for an image conversion and silently do
|
|
233
|
-
// nothing for a document — the same flag behaving two ways depending on
|
|
234
|
-
// what was dropped on it.
|
|
235
|
-
background: typeof values.background === 'string' ? values.background : '#ffffff',
|
|
236
|
-
// Same reasoning as `background` above: the shell has no metadata
|
|
237
|
-
// control and passes nothing, so it keeps the `false` default, while
|
|
238
|
-
// the CLI's `--keep-metadata` reaches here through `values`. Every
|
|
239
|
-
// `ConvertOptions` field a caller can set has to be readable from
|
|
240
|
-
// `values` or the flag that sets it works for one source kind and
|
|
241
|
-
// silently does nothing for the other.
|
|
242
|
-
keepMetadata: values.keepMetadata === true,
|
|
243
|
-
};
|
|
244
|
-
if (spec.lossy && typeof values.quality === 'number')
|
|
245
|
-
options.quality = values.quality;
|
|
246
|
-
const destination = typeof values.destination === 'string' ? values.destination : undefined;
|
|
247
|
-
// A document source rasterises to one image per selected page rather
|
|
248
|
-
// than one output for the whole source — `resolveOutputPath` below
|
|
249
|
-
// assumes exactly the latter, so this branches before it rather than
|
|
250
|
-
// trying to bend that function to a shape it was never built for. Only
|
|
251
|
-
// true when the target actually rasterises (jpeg/png); pdf/docx/doc
|
|
252
|
-
// fall through to the single-output path below like any other format.
|
|
253
|
-
if (source.kind === 'document' && rasterises(target)) {
|
|
254
|
-
const dpi = Number(values.dpi);
|
|
255
|
-
options.dpi = Number.isFinite(dpi) && dpi > 0 ? dpi : 150;
|
|
256
|
-
const pages = resolvePages(source, values.pages);
|
|
257
|
-
options.pages = pages;
|
|
258
|
-
const sourceRoot = typeof values.sourceRoot === 'string' ? values.sourceRoot : undefined;
|
|
259
|
-
const outputs = rasterOutputPaths(source.path, pages, target, destination, sourceRoot);
|
|
260
|
-
return [{ op: 'convert', sources: [source], outputs, target, options }];
|
|
261
|
-
}
|
|
262
|
-
const output = resolveOutputPath({
|
|
263
|
-
sourcePath: source.path,
|
|
264
|
-
target,
|
|
265
|
-
...(destination === undefined ? {} : { output: `${destination}/` }),
|
|
266
|
-
});
|
|
267
|
-
return [{ op: 'convert', sources: [source], outputs: [output], target, options }];
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/core/actions/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,WAAW,EAAoB,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa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