forge-terminal 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +305 -24
- package/dist/chunks/adm-zip-SQKLKBDP.js +3 -0
- package/dist/chunks/available-2VX7K7W6.js +3 -0
- package/dist/chunks/boot-ODZZHFUI.js +3 -0
- package/dist/chunks/cfb-V6M2PYOD.js +13 -0
- package/dist/chunks/chunk-2WYHI73Y.js +3 -0
- package/dist/chunks/chunk-4YHKTP7I.js +3 -0
- package/dist/chunks/chunk-5PYTOHLZ.js +3 -0
- package/dist/chunks/chunk-7YQR2MVH.js +3 -0
- package/dist/chunks/chunk-DRBA23IQ.js +3 -0
- package/dist/chunks/chunk-EOYBXOCV.js +4 -0
- package/dist/chunks/chunk-FQV57RMH.js +3 -0
- package/dist/chunks/chunk-IMKI5F4I.js +4 -0
- package/dist/chunks/chunk-J7FLFHQJ.js +3 -0
- package/dist/chunks/chunk-L2WK7CJG.js +3 -0
- package/dist/chunks/chunk-LFE3WRU4.js +3 -0
- package/dist/chunks/chunk-MHFY7HF6.js +10 -0
- package/dist/chunks/chunk-PBIS2ONZ.js +3 -0
- package/dist/chunks/chunk-QVACE4IE.js +3 -0
- package/dist/chunks/chunk-TMUK2DD3.js +3 -0
- package/dist/chunks/chunk-UNVHKJW4.js +41 -0
- package/dist/chunks/chunk-V4GHQGQM.js +4 -0
- package/dist/chunks/chunk-VB665HTV.js +3 -0
- package/dist/chunks/chunk-YHK5VE5R.js +3 -0
- package/dist/chunks/colour-QV2C3R7R.js +3 -0
- package/dist/chunks/config-command-UXJY623L.js +3 -0
- package/dist/chunks/dist-J2V6ITHG.js +29 -0
- package/dist/chunks/es-T2U7NBLD.js +3 -0
- package/dist/chunks/execute-4WJCUM7J.js +3 -0
- package/dist/chunks/extensions-command-6WZV2AES.js +3 -0
- package/dist/chunks/launch-2OI4ZLBQ.js +66 -0
- package/dist/chunks/lib-TPEJ5CJJ.js +46 -0
- package/dist/chunks/lock-R6GZXCCW.js +3 -0
- package/dist/chunks/manager-H52ENJOH.js +4 -0
- package/dist/chunks/paths-XY2345OS.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-N3F4EM7E.js +4 -0
- package/dist/chunks/server-5RWSVTOM.js +73 -0
- package/dist/chunks/theme-GW7CQPUO.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 +128 -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
package/dist/engines/registry.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { isForgeError } from '../core/errors.js';
|
|
2
|
-
import { imageEngine } from './image.js';
|
|
3
|
-
import { pdfEngine } from './pdf.js';
|
|
4
|
-
import { pdfiumEngine } from './pdfium.js';
|
|
5
|
-
import { wordEngine } from './word.js';
|
|
6
|
-
/**
|
|
7
|
-
* Order matters. `imageEngine` declines a PDF/docx/doc quickly, `pdfEngine`
|
|
8
|
-
* probes a real PDF successfully, `wordEngine` probes a docx/doc, and
|
|
9
|
-
* `pdfiumEngine` never probes at all — it must stay last.
|
|
10
|
-
*
|
|
11
|
-
* `pdfEngine` and `wordEngine` both declare `pdf` in `reads`/`writes` (the
|
|
12
|
-
* latter needs to, to route `docx → pdf` and `doc → pdf` — see
|
|
13
|
-
* `word.ts`), so `pdf → pdf` recompression could in principle match either.
|
|
14
|
-
* `engineForJob` takes the first match, and `pdfEngine` is listed first, so
|
|
15
|
-
* that ambiguity always resolves the same way it did before `wordEngine`
|
|
16
|
-
* existed.
|
|
17
|
-
*/
|
|
18
|
-
export const ENGINES = [imageEngine, pdfEngine, wordEngine, pdfiumEngine];
|
|
19
|
-
export function engineForSource(format) {
|
|
20
|
-
return ENGINES.find((e) => e.reads.has(format));
|
|
21
|
-
}
|
|
22
|
-
export function engineForTarget(format) {
|
|
23
|
-
return ENGINES.find((e) => e.writes.has(format));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The engine that runs a job.
|
|
27
|
-
*
|
|
28
|
-
* A conversion matches on **both ends**. Matching on the target alone was
|
|
29
|
-
* correct while exactly one engine wrote each format; the moment a second
|
|
30
|
-
* PDF-capable engine writes JPEG, `writes.has('jpeg')` stops identifying
|
|
31
|
-
* anything — the image engine would win a PDF→JPEG job and then fail on a
|
|
32
|
-
* source it cannot read. Every other operation still routes by `ops`,
|
|
33
|
-
* because a page operation has no target format.
|
|
34
|
-
*/
|
|
35
|
-
export function engineForJob(job) {
|
|
36
|
-
if (job.op === 'convert') {
|
|
37
|
-
const from = job.sources[0].format;
|
|
38
|
-
return ENGINES.find((e) => e.reads.has(from) && e.writes.has(job.target));
|
|
39
|
-
}
|
|
40
|
-
return ENGINES.find((e) => e.ops.has(job.op));
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Probing is engine-agnostic: the first engine that can read the file wins.
|
|
44
|
-
*
|
|
45
|
-
* When every engine declines, the error that surfaces is the first
|
|
46
|
-
* `ForgeError` seen rather than whichever engine happened to be last: only
|
|
47
|
-
* `imageEngine` classifies generic path failures (missing, unreadable,
|
|
48
|
-
* corrupt) into a specific, well-worded `ForgeError`, and it is tried first.
|
|
49
|
-
* A later engine's unclassified error (e.g. `pdf-lib` throwing a raw parse
|
|
50
|
-
* error on a non-PDF file) must not clobber that with something less useful.
|
|
51
|
-
*/
|
|
52
|
-
export async function probe(path) {
|
|
53
|
-
let lastError;
|
|
54
|
-
for (const engine of ENGINES) {
|
|
55
|
-
try {
|
|
56
|
-
return await engine.probe(path);
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
if (!isForgeError(lastError))
|
|
60
|
-
lastError = e;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
throw lastError;
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/engines/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,OAAO,GAAa,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,CAAA;AAEnF,MAAM,UAAU,eAAe,CAAC,MAAgB;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAgB;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AAClD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,GAAQ;IACnC,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAClC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAY;IACtC,IAAI,SAAkB,CAAA;IACtB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;gBAAE,SAAS,GAAG,CAAC,CAAA;QAC7C,CAAC;IACH,CAAC;IACD,MAAM,SAAS,CAAA;AACjB,CAAC"}
|
package/dist/engines/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/engines/types.ts"],"names":[],"mappings":""}
|
package/dist/engines/word.js
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { basename, extname, join } from 'node:path';
|
|
5
|
-
import { promisify } from 'node:util';
|
|
6
|
-
import AdmZip from 'adm-zip';
|
|
7
|
-
import { find as cfbFind, parse as cfbParse } from 'cfb';
|
|
8
|
-
import mammoth from 'mammoth';
|
|
9
|
-
import { PDFDocument as PDFLibDocument, StandardFonts } from 'pdf-lib';
|
|
10
|
-
import { PDFParse } from 'pdf-parse';
|
|
11
|
-
import WordExtractor from 'word-extractor';
|
|
12
|
-
import { writeAtomic } from '../core/atomic.js';
|
|
13
|
-
import { conversionFailed, encryptedSource } from '../core/errors.js';
|
|
14
|
-
const execFileAsync = promisify(execFile);
|
|
15
|
-
const OLE_MAGIC = Buffer.from([0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]);
|
|
16
|
-
/**
|
|
17
|
-
* A `.doc` is an OLE2 compound file — a container format also used by
|
|
18
|
-
* `.xls`, `.ppt` and `.msi`, so the magic bytes alone are not enough. The
|
|
19
|
-
* `WordDocument` stream is what only a legacy Word document has.
|
|
20
|
-
*/
|
|
21
|
-
function looksLikeDoc(bytes) {
|
|
22
|
-
if (bytes.length < OLE_MAGIC.length || !bytes.subarray(0, OLE_MAGIC.length).equals(OLE_MAGIC)) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
return cfbFind(cfbParse(bytes), 'WordDocument') !== null;
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A `.docx` is a zip — `word/document.xml` is the entry only a
|
|
34
|
-
* WordprocessingML document has (`.xlsx` has `xl/workbook.xml`, `.pptx` has
|
|
35
|
-
* `ppt/presentation.xml` — the same container, different content).
|
|
36
|
-
*
|
|
37
|
-
* `docProps/app.xml`'s cached `<Pages>` value, when present, is read with a
|
|
38
|
-
* plain regex rather than a full XML parser — the same light-touch style
|
|
39
|
-
* `heic.ts` already uses for one-off values (`pixelWidth`, `hasAlpha`).
|
|
40
|
-
*/
|
|
41
|
-
function readDocx(bytes) {
|
|
42
|
-
// One try/catch around the whole read, matching `looksLikeDoc` above:
|
|
43
|
-
// `adm-zip` only validates the fixed-size End Of Central Directory record
|
|
44
|
-
// at construction — it defers parsing the central directory itself to the
|
|
45
|
-
// first `getEntry()`/`getEntries()` call, so a zip-shaped-but-corrupted
|
|
46
|
-
// file can throw from `getEntry` or `readAsText` just as easily as from
|
|
47
|
-
// `new AdmZip()`.
|
|
48
|
-
try {
|
|
49
|
-
const zip = new AdmZip(bytes);
|
|
50
|
-
if (!zip.getEntry('word/document.xml'))
|
|
51
|
-
return undefined;
|
|
52
|
-
let pages = 0;
|
|
53
|
-
const appXml = zip.getEntry('docProps/app.xml');
|
|
54
|
-
if (appXml) {
|
|
55
|
-
const match = /<Pages>(\d+)<\/Pages>/.exec(zip.readAsText(appXml));
|
|
56
|
-
if (match?.[1])
|
|
57
|
-
pages = Number(match[1]);
|
|
58
|
-
}
|
|
59
|
-
return { pages };
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export async function probe(path) {
|
|
66
|
-
const bytes = await readFile(path);
|
|
67
|
-
const docx = readDocx(bytes);
|
|
68
|
-
if (docx) {
|
|
69
|
-
return {
|
|
70
|
-
kind: 'document',
|
|
71
|
-
path,
|
|
72
|
-
format: 'docx',
|
|
73
|
-
bytes: bytes.byteLength,
|
|
74
|
-
pages: docx.pages,
|
|
75
|
-
encrypted: false,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
if (looksLikeDoc(bytes)) {
|
|
79
|
-
return {
|
|
80
|
-
kind: 'document',
|
|
81
|
-
path,
|
|
82
|
-
format: 'doc',
|
|
83
|
-
bytes: bytes.byteLength,
|
|
84
|
-
// A legacy .doc's cached page count lives in the same OLE
|
|
85
|
-
// SummaryInformation stream `word-extractor` would need a second full
|
|
86
|
-
// parse to reach, for a number that is purely decorative in the file
|
|
87
|
-
// card (spec §5) — not attempted.
|
|
88
|
-
pages: 0,
|
|
89
|
-
encrypted: false,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
// Reached only when an earlier engine hasn't already classified this file
|
|
93
|
-
// with a real ForgeError (`registry.ts`'s `probe()` keeps the first one it
|
|
94
|
-
// sees) — the same "defensive, expected to be shadowed" throw
|
|
95
|
-
// `pdfiumEngine.probe()` uses for its own unreachable case.
|
|
96
|
-
throw new Error(`${path} is not a Word document`);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* A Homebrew cask install (`brew install --cask libreoffice`) puts
|
|
100
|
-
* `LibreOffice.app` in `/Applications` but does not add `soffice` to `PATH`
|
|
101
|
-
* — this is the fallback location when the PATH lookup below fails.
|
|
102
|
-
*/
|
|
103
|
-
const CASK_SOFFICE_PATH = '/Applications/LibreOffice.app/Contents/MacOS/soffice';
|
|
104
|
-
let resolveCallCountForTests = 0;
|
|
105
|
-
async function resolveSofficePath() {
|
|
106
|
-
resolveCallCountForTests++;
|
|
107
|
-
try {
|
|
108
|
-
await execFileAsync('soffice', ['--version'], { timeout: 5000 });
|
|
109
|
-
return 'soffice';
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
// Not on PATH — fall through to the fixed cask location.
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
await execFileAsync(CASK_SOFFICE_PATH, ['--version'], { timeout: 5000 });
|
|
116
|
-
return CASK_SOFFICE_PATH;
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
let sofficePath;
|
|
123
|
-
let forcing = false;
|
|
124
|
-
let forcedValue;
|
|
125
|
-
/**
|
|
126
|
-
* Whether LibreOffice's headless CLI is available here, and where. Cached
|
|
127
|
-
* for the process, the same way `heic.ts`'s `heicDecodable()` caches its own
|
|
128
|
-
* one-time shell probe — "install it and try again" naturally picks this up
|
|
129
|
-
* on the next run, so no invalidation logic is needed.
|
|
130
|
-
*/
|
|
131
|
-
export async function libreOfficeAvailable() {
|
|
132
|
-
if (forcing)
|
|
133
|
-
return forcedValue;
|
|
134
|
-
sofficePath ??= resolveSofficePath();
|
|
135
|
-
return sofficePath;
|
|
136
|
-
}
|
|
137
|
-
/** Only for tests, which need to exercise both the available and missing paths. */
|
|
138
|
-
export function resetLibreOfficeCache() {
|
|
139
|
-
sofficePath = undefined;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Only for tests: forces `libreOfficeAvailable()`'s answer regardless of
|
|
143
|
-
* what is actually installed. Needed because `run()`'s two dispatch
|
|
144
|
-
* branches (LibreOffice vs. the npm fallback) must both be covered
|
|
145
|
-
* deterministically — whether this machine happens to have LibreOffice
|
|
146
|
-
* installed cannot be allowed to change which branch a test exercises.
|
|
147
|
-
*/
|
|
148
|
-
export function forceLibreOfficeForTests(path) {
|
|
149
|
-
forcing = true;
|
|
150
|
-
forcedValue = path;
|
|
151
|
-
}
|
|
152
|
-
/** Only for tests: undoes `forceLibreOfficeForTests`, restoring real detection. */
|
|
153
|
-
export function stopForcingLibreOfficeForTests() {
|
|
154
|
-
forcing = false;
|
|
155
|
-
}
|
|
156
|
-
/** Only for tests: counts real (uncached, unforced) detection attempts, to prove caching actually avoids repeat work. */
|
|
157
|
-
export function getResolveCallCountForTests() {
|
|
158
|
-
return resolveCallCountForTests;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* A sentinel paragraph meaning "force a page break here" — how a PDF's own
|
|
162
|
-
* page boundaries survive into the plain-paragraph representation both
|
|
163
|
-
* `layoutAsPdf` and `buildDocx` consume. `\f` (form feed) can never appear
|
|
164
|
-
* in text `extractPlainText`'s own line-splitting produces, since that split
|
|
165
|
-
* already breaks on newlines.
|
|
166
|
-
*/
|
|
167
|
-
export const PAGE_BREAK = '\f';
|
|
168
|
-
function splitParagraphs(text) {
|
|
169
|
-
return text
|
|
170
|
-
.split(/\r?\n/)
|
|
171
|
-
.map((line) => line.trim())
|
|
172
|
-
.filter((line) => line.length > 0);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Plain paragraphs from any of the three formats this engine reads. The
|
|
176
|
-
* per-format library differs, but the output shape is one flat list of
|
|
177
|
-
* strings (with `PAGE_BREAK` sentinels for a paged source) that
|
|
178
|
-
* `layoutAsPdf`/`buildDocx` can consume without knowing where it came from.
|
|
179
|
-
*/
|
|
180
|
-
export async function extractPlainText(source) {
|
|
181
|
-
if (source.format === 'docx') {
|
|
182
|
-
const { value } = await mammoth.extractRawText({ path: source.path });
|
|
183
|
-
return splitParagraphs(value);
|
|
184
|
-
}
|
|
185
|
-
if (source.format === 'doc') {
|
|
186
|
-
const extractor = new WordExtractor();
|
|
187
|
-
const doc = await extractor.extract(source.path);
|
|
188
|
-
return splitParagraphs(doc.getBody());
|
|
189
|
-
}
|
|
190
|
-
// source.format === 'pdf'
|
|
191
|
-
const parser = new PDFParse({ data: await readFile(source.path) });
|
|
192
|
-
try {
|
|
193
|
-
const { pages } = await parser.getText();
|
|
194
|
-
return pages.flatMap((page, i) => i === 0 ? splitParagraphs(page.text) : [PAGE_BREAK, ...splitParagraphs(page.text)]);
|
|
195
|
-
}
|
|
196
|
-
finally {
|
|
197
|
-
await parser.destroy();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
const PDF_PAGE_WIDTH = 612;
|
|
201
|
-
const PDF_PAGE_HEIGHT = 792;
|
|
202
|
-
const PDF_MARGIN = 54;
|
|
203
|
-
const PDF_FONT_SIZE = 11;
|
|
204
|
-
const PDF_LINE_HEIGHT = 14;
|
|
205
|
-
/**
|
|
206
|
-
* Lays plain paragraphs out on US Letter pages with one font, one size, no
|
|
207
|
-
* headings, no lists — deliberately plain (spec §3's "genuinely plain"
|
|
208
|
-
* decision). Word-wrapping measures real glyph widths via pdf-lib's
|
|
209
|
-
* Helvetica metrics rather than guessing a character count per line.
|
|
210
|
-
*/
|
|
211
|
-
export async function layoutAsPdf(paragraphs) {
|
|
212
|
-
const doc = await PDFLibDocument.create();
|
|
213
|
-
const font = await doc.embedFont(StandardFonts.Helvetica);
|
|
214
|
-
const maxWidth = PDF_PAGE_WIDTH - PDF_MARGIN * 2;
|
|
215
|
-
let page = doc.addPage([PDF_PAGE_WIDTH, PDF_PAGE_HEIGHT]);
|
|
216
|
-
let y = PDF_PAGE_HEIGHT - PDF_MARGIN;
|
|
217
|
-
const newPage = () => {
|
|
218
|
-
page = doc.addPage([PDF_PAGE_WIDTH, PDF_PAGE_HEIGHT]);
|
|
219
|
-
y = PDF_PAGE_HEIGHT - PDF_MARGIN;
|
|
220
|
-
};
|
|
221
|
-
for (const paragraph of paragraphs) {
|
|
222
|
-
if (paragraph === PAGE_BREAK) {
|
|
223
|
-
newPage();
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
let line = '';
|
|
227
|
-
for (const word of paragraph.split(/\s+/).filter(Boolean)) {
|
|
228
|
-
const candidate = line ? `${line} ${word}` : word;
|
|
229
|
-
if (line && font.widthOfTextAtSize(candidate, PDF_FONT_SIZE) > maxWidth) {
|
|
230
|
-
if (y < PDF_MARGIN)
|
|
231
|
-
newPage();
|
|
232
|
-
page.drawText(line, { x: PDF_MARGIN, y, size: PDF_FONT_SIZE, font });
|
|
233
|
-
y -= PDF_LINE_HEIGHT;
|
|
234
|
-
line = word;
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
line = candidate;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (line) {
|
|
241
|
-
if (y < PDF_MARGIN)
|
|
242
|
-
newPage();
|
|
243
|
-
page.drawText(line, { x: PDF_MARGIN, y, size: PDF_FONT_SIZE, font });
|
|
244
|
-
y -= PDF_LINE_HEIGHT;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return doc.save();
|
|
248
|
-
}
|
|
249
|
-
let docxModule;
|
|
250
|
-
/**
|
|
251
|
-
* `docx` is loaded on first use, not at startup, and with
|
|
252
|
-
* `globalThis.localStorage` hidden while it evaluates.
|
|
253
|
-
*
|
|
254
|
-
* Its bundle inlines the browser build of `util-deprecate`, whose
|
|
255
|
-
* `deprecate()` probes `globalThis.localStorage` for `noDeprecation` — and
|
|
256
|
-
* calls it at module top level (readable-stream's `_writableState.buffer`).
|
|
257
|
-
* On Node 26 `localStorage` is a global getter that emits an
|
|
258
|
-
* ExperimentalWarning on stderr when `--localstorage-file` is absent, so a
|
|
259
|
-
* static import put that warning on every invocation, `--version` included.
|
|
260
|
-
*
|
|
261
|
-
* Loading lazily keeps it off every path that never writes a docx. Hiding
|
|
262
|
-
* the getter for the duration of the import keeps it off the path that does.
|
|
263
|
-
* Nothing is filtered: the warning is never raised, and every other Node
|
|
264
|
-
* warning still prints. Without a backing file Node's `localStorage` is
|
|
265
|
-
* unusable anyway, so `docx` sees exactly the "no localStorage" it would
|
|
266
|
-
* have concluded, and nothing in Forge reads it while it is hidden.
|
|
267
|
-
*/
|
|
268
|
-
function loadDocx() {
|
|
269
|
-
docxModule ??= importWithoutLocalStorage();
|
|
270
|
-
return docxModule;
|
|
271
|
-
}
|
|
272
|
-
async function importWithoutLocalStorage() {
|
|
273
|
-
const descriptor = Object.getOwnPropertyDescriptor(globalThis, 'localStorage');
|
|
274
|
-
if (!descriptor?.configurable)
|
|
275
|
-
return import('docx');
|
|
276
|
-
Object.defineProperty(globalThis, 'localStorage', {
|
|
277
|
-
value: undefined,
|
|
278
|
-
configurable: true,
|
|
279
|
-
enumerable: descriptor.enumerable ?? false,
|
|
280
|
-
writable: true,
|
|
281
|
-
});
|
|
282
|
-
try {
|
|
283
|
-
return await import('docx');
|
|
284
|
-
}
|
|
285
|
-
finally {
|
|
286
|
-
Object.defineProperty(globalThis, 'localStorage', descriptor);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
/** One docx paragraph per line, `PAGE_BREAK` sentinels becoming real page breaks. */
|
|
290
|
-
export async function buildDocx(paragraphs) {
|
|
291
|
-
const { Document: DocxDocument, Packer, PageBreak, Paragraph } = await loadDocx();
|
|
292
|
-
const children = paragraphs.map((p) => p === PAGE_BREAK ? new Paragraph({ children: [new PageBreak()] }) : new Paragraph(p));
|
|
293
|
-
const doc = new DocxDocument({ sections: [{ children }] });
|
|
294
|
-
return Packer.toBuffer(doc);
|
|
295
|
-
}
|
|
296
|
-
const READS = new Set(['docx', 'doc', 'pdf']);
|
|
297
|
-
const WRITES = new Set(['docx', 'pdf']);
|
|
298
|
-
const OPS = new Set(['convert']);
|
|
299
|
-
const BASIC_FIDELITY_WARNING = {
|
|
300
|
-
code: 'word-basic-fidelity',
|
|
301
|
-
message: "Converted with basic formatting only — tables, images, and complex layouts weren't preserved. " +
|
|
302
|
-
'Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice',
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Shells out to LibreOffice's headless converter. `--convert-to` takes the
|
|
306
|
-
* extension name directly — 'pdf' and 'docx' both are exactly that, so no
|
|
307
|
-
* mapping from `FormatId` is needed. LibreOffice names its own output after
|
|
308
|
-
* the input's basename, which is why the produced file has to be found
|
|
309
|
-
* rather than assumed to already be at `job.outputs[0]`.
|
|
310
|
-
*/
|
|
311
|
-
async function runSoffice(soffice, sourcePath, target) {
|
|
312
|
-
const outDir = await mkdtemp(join(tmpdir(), 'forge-word-'));
|
|
313
|
-
try {
|
|
314
|
-
await execFileAsync(soffice, [
|
|
315
|
-
// Without a per-invocation profile, two concurrent `soffice`
|
|
316
|
-
// processes (a batch run through `runJobs`' worker pool) fight over
|
|
317
|
-
// LibreOffice's shared default user profile — the second typically
|
|
318
|
-
// exits 0 having written nothing, which then surfaces as an ENOENT
|
|
319
|
-
// reading the output below rather than anything naming the real
|
|
320
|
-
// cause. `outDir` is already unique and already cleaned up per call.
|
|
321
|
-
`-env:UserInstallation=file://${outDir}/profile`,
|
|
322
|
-
'--headless',
|
|
323
|
-
'--convert-to',
|
|
324
|
-
target,
|
|
325
|
-
'--outdir',
|
|
326
|
-
outDir,
|
|
327
|
-
sourcePath,
|
|
328
|
-
], { timeout: 120_000 });
|
|
329
|
-
const stem = basename(sourcePath, extname(sourcePath));
|
|
330
|
-
return await readFile(join(outDir, `${stem}.${target}`));
|
|
331
|
-
}
|
|
332
|
-
finally {
|
|
333
|
-
await rm(outDir, { recursive: true, force: true });
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
async function run(job, onPhase) {
|
|
337
|
-
if (job.op !== 'convert')
|
|
338
|
-
throw new Error(`the word engine cannot ${job.op}`);
|
|
339
|
-
const source = job.sources[0];
|
|
340
|
-
if (source.kind !== 'document') {
|
|
341
|
-
throw new Error('the word engine can only convert a document source');
|
|
342
|
-
}
|
|
343
|
-
// `DocumentInfo.encrypted` is only ever true for a pdf source (docx/doc
|
|
344
|
-
// probing always reports false — see probe()'s comment) — a pdf -> docx
|
|
345
|
-
// job reaching this engine. Refusing with the named `encryptedSource`
|
|
346
|
-
// error here matches `pdfiumEngine`'s own refusal for the same case,
|
|
347
|
-
// rather than letting pdf-parse throw and surfacing a generic
|
|
348
|
-
// conversion-failed with no hint about --password-stdin.
|
|
349
|
-
if (source.encrypted)
|
|
350
|
-
throw encryptedSource(source.path);
|
|
351
|
-
onPhase({ phase: 'reading' });
|
|
352
|
-
const soffice = await libreOfficeAvailable();
|
|
353
|
-
onPhase({ phase: 'encoding' });
|
|
354
|
-
const warnings = [];
|
|
355
|
-
let bytes;
|
|
356
|
-
try {
|
|
357
|
-
if (soffice !== undefined) {
|
|
358
|
-
bytes = await runSoffice(soffice, source.path, job.target);
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
const paragraphs = await extractPlainText(source);
|
|
362
|
-
bytes = job.target === 'pdf' ? await layoutAsPdf(paragraphs) : await buildDocx(paragraphs);
|
|
363
|
-
warnings.push(BASIC_FIDELITY_WARNING);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
catch (e) {
|
|
367
|
-
// A failed soffice invocation and a failed npm-fallback parse are both
|
|
368
|
-
// real conversion failures, not a signal to silently retry the other
|
|
369
|
-
// path — the spec's decision (§3) is that only "not installed at all"
|
|
370
|
-
// routes to the fallback, never a per-file failure.
|
|
371
|
-
throw conversionFailed(source.path, e);
|
|
372
|
-
}
|
|
373
|
-
onPhase({ phase: 'writing' });
|
|
374
|
-
const outputBytes = await writeAtomic(job.outputs[0], bytes);
|
|
375
|
-
return { job, outputBytes, warnings };
|
|
376
|
-
}
|
|
377
|
-
export const wordEngine = {
|
|
378
|
-
id: 'word',
|
|
379
|
-
reads: READS,
|
|
380
|
-
writes: WRITES,
|
|
381
|
-
ops: OPS,
|
|
382
|
-
probe,
|
|
383
|
-
run,
|
|
384
|
-
};
|
|
385
|
-
//# sourceMappingURL=word.js.map
|
package/dist/engines/word.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"word.js","sourceRoot":"","sources":["../../src/engines/word.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,KAAK,CAAA;AACxD,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,aAAa,EAAE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