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.
Files changed (212) hide show
  1. package/README.md +333 -24
  2. package/dist/chunks/adm-zip-SQKLKBDP.js +3 -0
  3. package/dist/chunks/available-HEUREG6L.js +3 -0
  4. package/dist/chunks/boot-BUGERSEB.js +3 -0
  5. package/dist/chunks/catalog-NTACQH5V.js +3 -0
  6. package/dist/chunks/cfb-V6M2PYOD.js +13 -0
  7. package/dist/chunks/chunk-2WYHI73Y.js +3 -0
  8. package/dist/chunks/chunk-4YCO7S4K.js +3 -0
  9. package/dist/chunks/chunk-5B7WODWH.js +3 -0
  10. package/dist/chunks/chunk-C2WYXNRM.js +4 -0
  11. package/dist/chunks/chunk-C7OOWUMU.js +3 -0
  12. package/dist/chunks/chunk-EOYBXOCV.js +4 -0
  13. package/dist/chunks/chunk-G2D6BKOS.js +4 -0
  14. package/dist/chunks/chunk-HUAEVW2A.js +3 -0
  15. package/dist/chunks/chunk-J7FLFHQJ.js +3 -0
  16. package/dist/chunks/chunk-L76Q54MB.js +3 -0
  17. package/dist/chunks/chunk-LFE3WRU4.js +3 -0
  18. package/dist/chunks/chunk-PBIS2ONZ.js +3 -0
  19. package/dist/chunks/chunk-PD5DFBCU.js +3 -0
  20. package/dist/chunks/chunk-PN73WK2S.js +3 -0
  21. package/dist/chunks/chunk-QVACE4IE.js +3 -0
  22. package/dist/chunks/chunk-TEGB7JRM.js +3 -0
  23. package/dist/chunks/chunk-TMUK2DD3.js +3 -0
  24. package/dist/chunks/chunk-UNVHKJW4.js +41 -0
  25. package/dist/chunks/chunk-VH5RWPGZ.js +10 -0
  26. package/dist/chunks/chunk-XFEHJ4C7.js +3 -0
  27. package/dist/chunks/chunk-YXDEOLNA.js +3 -0
  28. package/dist/chunks/colour-DE6N6AZO.js +3 -0
  29. package/dist/chunks/config-command-SQXRTBRO.js +3 -0
  30. package/dist/chunks/dist-J2V6ITHG.js +29 -0
  31. package/dist/chunks/es-T2U7NBLD.js +3 -0
  32. package/dist/chunks/execute-M3C3TTWB.js +3 -0
  33. package/dist/chunks/extensions-command-HJDBUBYO.js +3 -0
  34. package/dist/chunks/image-GYUUMS6H.js +3 -0
  35. package/dist/chunks/launch-WBUFRVQ7.js +65 -0
  36. package/dist/chunks/lib-TPEJ5CJJ.js +46 -0
  37. package/dist/chunks/lock-XD4L3WFM.js +3 -0
  38. package/dist/chunks/manager-KBJTXZ27.js +4 -0
  39. package/dist/chunks/paths-JUM6GKQU.js +3 -0
  40. package/dist/chunks/pdf-compress-IMRFBLZF.js +3 -0
  41. package/dist/chunks/react-devtools-core-UM4FS6CU.js +3 -0
  42. package/dist/chunks/run-RXVQD4DZ.js +4 -0
  43. package/dist/chunks/server-DU7QWDAH.js +73 -0
  44. package/dist/chunks/theme-DESCJOCE.js +3 -0
  45. package/dist/chunks/word-OGQ2KZAJ.js +24 -0
  46. package/dist/index.js +67 -95
  47. package/dist/third-party-licenses.txt +2856 -0
  48. package/package.json +28 -21
  49. package/skills/forge/SKILL.md +149 -0
  50. package/dist/cli/args.js +0 -278
  51. package/dist/cli/args.js.map +0 -1
  52. package/dist/cli/config-command.js +0 -55
  53. package/dist/cli/config-command.js.map +0 -1
  54. package/dist/cli/execute.js +0 -377
  55. package/dist/cli/execute.js.map +0 -1
  56. package/dist/cli/report.js +0 -123
  57. package/dist/cli/report.js.map +0 -1
  58. package/dist/cli/spinner.js +0 -60
  59. package/dist/cli/spinner.js.map +0 -1
  60. package/dist/cli/stdin.js +0 -47
  61. package/dist/cli/stdin.js.map +0 -1
  62. package/dist/config/preferences.js +0 -143
  63. package/dist/config/preferences.js.map +0 -1
  64. package/dist/core/actions/compress.js +0 -157
  65. package/dist/core/actions/compress.js.map +0 -1
  66. package/dist/core/actions/convert.js +0 -270
  67. package/dist/core/actions/convert.js.map +0 -1
  68. package/dist/core/actions/extract.js +0 -94
  69. package/dist/core/actions/extract.js.map +0 -1
  70. package/dist/core/actions/index.js +0 -23
  71. package/dist/core/actions/index.js.map +0 -1
  72. package/dist/core/actions/merge.js +0 -16
  73. package/dist/core/actions/merge.js.map +0 -1
  74. package/dist/core/actions/rotate.js +0 -36
  75. package/dist/core/actions/rotate.js.map +0 -1
  76. package/dist/core/actions/split.js +0 -65
  77. package/dist/core/actions/split.js.map +0 -1
  78. package/dist/core/atomic.js +0 -61
  79. package/dist/core/atomic.js.map +0 -1
  80. package/dist/core/capabilities.js +0 -59
  81. package/dist/core/capabilities.js.map +0 -1
  82. package/dist/core/compress.js +0 -76
  83. package/dist/core/compress.js.map +0 -1
  84. package/dist/core/describe.js +0 -49
  85. package/dist/core/describe.js.map +0 -1
  86. package/dist/core/errors.js +0 -469
  87. package/dist/core/errors.js.map +0 -1
  88. package/dist/core/execute-jobs.js +0 -122
  89. package/dist/core/execute-jobs.js.map +0 -1
  90. package/dist/core/formats.js +0 -108
  91. package/dist/core/formats.js.map +0 -1
  92. package/dist/core/order.js +0 -44
  93. package/dist/core/order.js.map +0 -1
  94. package/dist/core/output-path.js +0 -176
  95. package/dist/core/output-path.js.map +0 -1
  96. package/dist/core/pages.js +0 -107
  97. package/dist/core/pages.js.map +0 -1
  98. package/dist/core/pdf-compress.js +0 -206
  99. package/dist/core/pdf-compress.js.map +0 -1
  100. package/dist/core/plan.js +0 -42
  101. package/dist/core/plan.js.map +0 -1
  102. package/dist/core/resolve.js +0 -115
  103. package/dist/core/resolve.js.map +0 -1
  104. package/dist/core/run.js +0 -66
  105. package/dist/core/run.js.map +0 -1
  106. package/dist/core/suggest.js +0 -50
  107. package/dist/core/suggest.js.map +0 -1
  108. package/dist/core/types.js +0 -2
  109. package/dist/core/types.js.map +0 -1
  110. package/dist/core/units.js +0 -94
  111. package/dist/core/units.js.map +0 -1
  112. package/dist/core/write-safety.js +0 -128
  113. package/dist/core/write-safety.js.map +0 -1
  114. package/dist/engines/heic.js +0 -166
  115. package/dist/engines/heic.js.map +0 -1
  116. package/dist/engines/image.js +0 -342
  117. package/dist/engines/image.js.map +0 -1
  118. package/dist/engines/pdf.js +0 -444
  119. package/dist/engines/pdf.js.map +0 -1
  120. package/dist/engines/pdfium.js +0 -161
  121. package/dist/engines/pdfium.js.map +0 -1
  122. package/dist/engines/registry.js +0 -65
  123. package/dist/engines/registry.js.map +0 -1
  124. package/dist/engines/types.js +0 -2
  125. package/dist/engines/types.js.map +0 -1
  126. package/dist/engines/word.js +0 -385
  127. package/dist/engines/word.js.map +0 -1
  128. package/dist/index.js.map +0 -1
  129. package/dist/shell/App.js +0 -1972
  130. package/dist/shell/App.js.map +0 -1
  131. package/dist/shell/ClickTargets.js +0 -183
  132. package/dist/shell/ClickTargets.js.map +0 -1
  133. package/dist/shell/ThemeContext.js +0 -21
  134. package/dist/shell/ThemeContext.js.map +0 -1
  135. package/dist/shell/blocks.js +0 -160
  136. package/dist/shell/blocks.js.map +0 -1
  137. package/dist/shell/clipboard.js +0 -64
  138. package/dist/shell/clipboard.js.map +0 -1
  139. package/dist/shell/commands.js +0 -51
  140. package/dist/shell/commands.js.map +0 -1
  141. package/dist/shell/components/Banner.js +0 -73
  142. package/dist/shell/components/Banner.js.map +0 -1
  143. package/dist/shell/components/CommandPalette.js +0 -37
  144. package/dist/shell/components/CommandPalette.js.map +0 -1
  145. package/dist/shell/components/FileCard.js +0 -59
  146. package/dist/shell/components/FileCard.js.map +0 -1
  147. package/dist/shell/components/HintBar.js +0 -18
  148. package/dist/shell/components/HintBar.js.map +0 -1
  149. package/dist/shell/components/Hints.js +0 -21
  150. package/dist/shell/components/Hints.js.map +0 -1
  151. package/dist/shell/components/MergeList.js +0 -268
  152. package/dist/shell/components/MergeList.js.map +0 -1
  153. package/dist/shell/components/ModeHeader.js +0 -21
  154. package/dist/shell/components/ModeHeader.js.map +0 -1
  155. package/dist/shell/components/PageGrid.js +0 -324
  156. package/dist/shell/components/PageGrid.js.map +0 -1
  157. package/dist/shell/components/PathInput.js +0 -147
  158. package/dist/shell/components/PathInput.js.map +0 -1
  159. package/dist/shell/components/Progress.js +0 -43
  160. package/dist/shell/components/Progress.js.map +0 -1
  161. package/dist/shell/components/Prompt.js +0 -667
  162. package/dist/shell/components/Prompt.js.map +0 -1
  163. package/dist/shell/components/ResultLinks.js +0 -26
  164. package/dist/shell/components/ResultLinks.js.map +0 -1
  165. package/dist/shell/components/Select.js +0 -152
  166. package/dist/shell/components/Select.js.map +0 -1
  167. package/dist/shell/components/Slider.js +0 -48
  168. package/dist/shell/components/Slider.js.map +0 -1
  169. package/dist/shell/components/StagedFiles.js +0 -92
  170. package/dist/shell/components/StagedFiles.js.map +0 -1
  171. package/dist/shell/components/ThemePicker.js +0 -18
  172. package/dist/shell/components/ThemePicker.js.map +0 -1
  173. package/dist/shell/components/UnitRow.js +0 -30
  174. package/dist/shell/components/UnitRow.js.map +0 -1
  175. package/dist/shell/flows/pdf.js +0 -424
  176. package/dist/shell/flows/pdf.js.map +0 -1
  177. package/dist/shell/frame-geometry.js +0 -56
  178. package/dist/shell/frame-geometry.js.map +0 -1
  179. package/dist/shell/hyperlink.js +0 -27
  180. package/dist/shell/hyperlink.js.map +0 -1
  181. package/dist/shell/intro.js +0 -101
  182. package/dist/shell/intro.js.map +0 -1
  183. package/dist/shell/launch.js +0 -75
  184. package/dist/shell/launch.js.map +0 -1
  185. package/dist/shell/mark.js +0 -134
  186. package/dist/shell/mark.js.map +0 -1
  187. package/dist/shell/mouse.js +0 -209
  188. package/dist/shell/mouse.js.map +0 -1
  189. package/dist/shell/redraw.js +0 -36
  190. package/dist/shell/redraw.js.map +0 -1
  191. package/dist/shell/reveal.js +0 -24
  192. package/dist/shell/reveal.js.map +0 -1
  193. package/dist/shell/stage.js +0 -34
  194. package/dist/shell/stage.js.map +0 -1
  195. package/dist/shell/terminal-write.js +0 -16
  196. package/dist/shell/terminal-write.js.map +0 -1
  197. package/dist/shell/theme.js +0 -178
  198. package/dist/shell/theme.js.map +0 -1
  199. package/dist/shell/useFrameOrigin.js +0 -175
  200. package/dist/shell/useFrameOrigin.js.map +0 -1
  201. package/dist/shell/useKeys.js +0 -28
  202. package/dist/shell/useKeys.js.map +0 -1
  203. package/dist/shell/useMouse.js +0 -150
  204. package/dist/shell/useMouse.js.map +0 -1
  205. package/dist/shell/useMouseRouting.js +0 -69
  206. package/dist/shell/useMouseRouting.js.map +0 -1
  207. package/dist/shell/width.js +0 -62
  208. package/dist/shell/width.js.map +0 -1
  209. package/dist/utils/display-path.js +0 -31
  210. package/dist/utils/display-path.js.map +0 -1
  211. package/dist/utils/unescape-path.js +0 -68
  212. package/dist/utils/unescape-path.js.map +0 -1
@@ -1,166 +0,0 @@
1
- import { execFile } from 'node:child_process';
2
- import { randomBytes } from 'node:crypto';
3
- import { open, rm } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import { promisify } from 'node:util';
7
- const run = promisify(execFile);
8
- /**
9
- * Why this file exists.
10
- *
11
- * Sharp's prebuilt binary bundles libheif *without* an HEVC decoder. That is
12
- * a licensing decision, not an oversight: HEVC sits in a patent pool, so the
13
- * upstream position is that HEIC support requires a globally installed
14
- * libvips built against libheif, libde265 and x265, and "the prebuilt
15
- * binaries will not include any support for HEIC". AVIF works in the same
16
- * container because AV1 is royalty-free.
17
- *
18
- * Measured on this machine: `sharp(heic).metadata()` succeeds and reports
19
- * `compression: 'hevc'`, so a HEIC file probes cleanly — and then decoding
20
- * fails with "Support for this compression format has not been built in".
21
- * That is the worst shape a limitation can take: the format list advertises
22
- * HEIC as readable, the picker offers targets for it, and the failure lands
23
- * at the final step with a generic message.
24
- *
25
- * Forge is a macOS tool, and macOS ships `sips`, which decodes HEIC through
26
- * Apple's own system codec. So HEIC is decoded to a temporary PNG first and
27
- * the ordinary Sharp pipeline runs on that. No new dependency, no build
28
- * step, and the fidelity comes from the same decoder Preview uses.
29
- *
30
- * If Forge ever leaves macOS, the portable substitute is `libheif-js` — a
31
- * WASM build of libheif — at the cost of an npm dependency and a slower,
32
- * in-process decode.
33
- */
34
- let cached;
35
- /**
36
- * Whether HEIC can be decoded here. Cached: this shells out, and the answer
37
- * cannot change while the process is running.
38
- */
39
- export async function heicDecodable() {
40
- if (cached !== undefined)
41
- return cached;
42
- try {
43
- await run('/usr/bin/sips', ['--help'], { timeout: 5000 });
44
- cached = true;
45
- }
46
- catch {
47
- cached = false;
48
- }
49
- return cached;
50
- }
51
- /** Only for tests, which need to exercise both the available and missing paths. */
52
- export function resetHeicSupportCache() {
53
- cached = undefined;
54
- }
55
- /**
56
- * Decodes a HEIC file to a temporary PNG.
57
- *
58
- * PNG rather than JPEG on purpose: this is an intermediate, and a lossy hop
59
- * in the middle of a conversion would throw away quality the user never
60
- * agreed to lose. `sips` applies the file's EXIF orientation as it decodes,
61
- * so the PNG is already upright — which is why the caller must not rotate it
62
- * a second time.
63
- */
64
- export async function decodeHeic(source) {
65
- const path = join(tmpdir(), `forge-heic-${randomBytes(8).toString('hex')}.png`);
66
- const cleanup = async () => {
67
- await rm(path, { force: true }).catch(() => { });
68
- };
69
- try {
70
- await run('/usr/bin/sips', ['-s', 'format', 'png', source, '--out', path], {
71
- timeout: 120_000,
72
- });
73
- return { path, cleanup };
74
- }
75
- catch (e) {
76
- await cleanup();
77
- throw e;
78
- }
79
- }
80
- /**
81
- * Whether the file is HEIC, decided by its own bytes.
82
- *
83
- * Needed because Sharp cannot be asked. A real photo is stored as a tiled
84
- * grid — a 12MP iPhone HEIC is dozens of tiles cross-referenced through the
85
- * ISO-BMFF `iref` box — and libheif refuses more than 16 references by
86
- * default:
87
- *
88
- * heif: Security limit exceeded: Number of references in iref box (48)
89
- * exceeds the security limits of 16 references
90
- *
91
- * So `sharp(photo).metadata()` throws for exactly the files people actually
92
- * have, while succeeding on the small single-tile fixtures a test suite
93
- * tends to generate. Detection therefore reads the container directly, which
94
- * is content-based and never consults the extension (invariant 3).
95
- *
96
- * Layout: a 4-byte big-endian box size, the literal 'ftyp', then a 4-byte
97
- * major brand, then optional compatible brands. Any HEIF-family brand counts;
98
- * whether it is decodable is a separate question answered by `heicDecodable`.
99
- */
100
- const HEIF_BRANDS = new Set(['heic', 'heix', 'hevc', 'hevx', 'heim', 'heis', 'mif1', 'msf1']);
101
- /**
102
- * AVIF is the same container with a different codec, and it lists `mif1`
103
- * among its compatible brands — so a check for HEIF brands alone claims
104
- * every AVIF as HEIC. An AVIF brand anywhere in the box settles it, because
105
- * sharp reads AVIF perfectly well and must keep doing so.
106
- */
107
- const AVIF_BRANDS = new Set(['avif', 'avis']);
108
- export async function looksLikeHeic(path) {
109
- let handle;
110
- try {
111
- handle = await open(path, 'r');
112
- }
113
- catch {
114
- return false;
115
- }
116
- try {
117
- const buffer = Buffer.alloc(64);
118
- const { bytesRead } = await handle.read(buffer, 0, 64, 0);
119
- if (bytesRead < 12)
120
- return false;
121
- if (buffer.toString('latin1', 4, 8) !== 'ftyp')
122
- return false;
123
- // The major brand, plus every compatible brand in the rest of the box.
124
- const size = Math.min(buffer.readUInt32BE(0), bytesRead);
125
- const brands = [];
126
- for (let at = 8; at + 4 <= size; at += 4) {
127
- brands.push(buffer.toString('latin1', at, at + 4));
128
- }
129
- if (brands.some((b) => AVIF_BRANDS.has(b)))
130
- return false;
131
- return brands.some((b) => HEIF_BRANDS.has(b));
132
- }
133
- catch {
134
- return false;
135
- }
136
- finally {
137
- await handle.close().catch(() => { });
138
- }
139
- }
140
- /**
141
- * Dimensions straight from `sips`, for the files libheif will not parse.
142
- *
143
- * Known limitation: these are the dimensions `sips` reports, which for a
144
- * HEIC carrying an EXIF rotation are the stored ones, not the displayed
145
- * ones. `sips` exposes no orientation field for HEIC (`-g orientation`
146
- * returns nil, and Spotlight has nothing either), so there is no cheap way
147
- * to correct them without decoding the file — which at probe time would cost
148
- * a second per photo for a number shown on one line.
149
- *
150
- * The conversion itself is unaffected: the decoded intermediate carries the
151
- * orientation and `.rotate()` applies it, so the written file is always the
152
- * right way up. Only the dimensions in the file card can read transposed,
153
- * and only for a rotated source.
154
- * `hasAlpha` is asked for too rather than assumed: a photo never has an alpha
155
- * channel, but a HEIC exported from a graphics tool can, and guessing would
156
- * silently skip the flatten step that keeps transparency from going black.
157
- */
158
- export async function heicInfo(path) {
159
- const { stdout } = await run('/usr/bin/sips', ['-g', 'pixelWidth', '-g', 'pixelHeight', '-g', 'hasAlpha', path], { timeout: 30_000 });
160
- return {
161
- width: Number(/pixelWidth:\s*(\d+)/.exec(stdout)?.[1] ?? 0),
162
- height: Number(/pixelHeight:\s*(\d+)/.exec(stdout)?.[1] ?? 0),
163
- hasAlpha: /hasAlpha:\s*yes/i.test(stdout),
164
- };
165
- }
166
- //# sourceMappingURL=heic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"heic.js","sourceRoot":"","sources":["../../src/engines/heic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,IAAI,MAA2B,CAAA;AAE/B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IACvC,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,MAAM,GAAG,IAAI,CAAA;IACf,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,KAAK,CAAA;IAChB,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M,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACtC,CAAC;AACH,CAAC;AAQD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAC1B,eAAe,EACf,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EACjE,EAAE,OAAO,EAAE,MAAM,EAAE,CACpB,CAAA;IACD,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3D,MAAM,EAAE,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC7D,QAAQ,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;KAC1C,CAAA;AACH,CAAC"}
@@ -1,342 +0,0 @@
1
- import { randomBytes } from 'node:crypto';
2
- import { constants } from 'node:fs';
3
- import { access, rename, rm, stat } from 'node:fs/promises';
4
- import { basename, dirname, join } from 'node:path';
5
- import sharp from 'sharp';
6
- import { prepareOutputDir } from '../core/atomic.js';
7
- import { classifyWriteError, conversionFailed, corruptFormatSource, corruptSource, fileNotFound, heicDecoderUnavailable, isForgeError, notADirectory, notAFile, pathTooLong, permissionDenied, symlinkLoop, unreadablePath, unsupportedSource, } from '../core/errors.js';
8
- import { FORMATS } from '../core/formats.js';
9
- import { decodeHeic, heicDecodable, heicInfo, looksLikeHeic } from './heic.js';
10
- const READS = new Set([
11
- 'jpeg',
12
- 'png',
13
- 'webp',
14
- 'avif',
15
- 'heic',
16
- 'gif',
17
- 'tiff',
18
- ]);
19
- /** heic is absent deliberately: sharp cannot encode HEVC. */
20
- const WRITES = new Set([
21
- 'jpeg',
22
- 'png',
23
- 'webp',
24
- 'avif',
25
- 'gif',
26
- 'tiff',
27
- ]);
28
- const DIRECT = {
29
- jpeg: 'jpeg',
30
- png: 'png',
31
- webp: 'webp',
32
- gif: 'gif',
33
- tiff: 'tiff',
34
- };
35
- /**
36
- * Sharp reports HEIC and AVIF with the same format string. The compression
37
- * field is the only thing separating them, and getting it wrong would offer
38
- * HEIC as a writable target — which fails at encode time.
39
- */
40
- function identify(path, meta) {
41
- if (meta.format === 'heif')
42
- return meta.compression === 'av1' ? 'avif' : 'heic';
43
- const id = DIRECT[meta.format ?? ''];
44
- if (!id)
45
- throw unsupportedSource(path, meta.format ?? 'an unknown format');
46
- return id;
47
- }
48
- /**
49
- * `stat`'s error taxonomy must be total, not partial: this is called
50
- * directly by the interactive shell (unlike the CLI's `resolveInputs`,
51
- * which stats every input up front and only ever forwards `probe` a path
52
- * already known to exist), so a typed or pasted path reaches this
53
- * unfiltered. Every errno not given a specific, well-worded error above
54
- * still becomes a `ForgeError` via `unreadablePath` — never a raw `Error`
55
- * left to escape as an unhandled rejection.
56
- */
57
- async function probe(path) {
58
- let stats;
59
- try {
60
- stats = await stat(path);
61
- }
62
- catch (cause) {
63
- const code = cause.code;
64
- if (code === 'ENOENT')
65
- throw fileNotFound(path);
66
- if (code === 'EACCES' || code === 'EPERM')
67
- throw permissionDenied(path);
68
- if (code === 'ENOTDIR')
69
- throw notADirectory(path);
70
- if (code === 'ELOOP')
71
- throw symlinkLoop(path);
72
- if (code === 'ENAMETOOLONG')
73
- throw pathTooLong(path);
74
- throw unreadablePath(path, cause);
75
- }
76
- if (!stats.isFile())
77
- throw notAFile(path);
78
- // Sharp gives an unreadable file the same message as a corrupt one and never
79
- // sets error.code, so readability has to be established before it is involved.
80
- try {
81
- await access(path, constants.R_OK);
82
- }
83
- catch {
84
- throw permissionDenied(path);
85
- }
86
- /**
87
- * HEIC is identified from its own container bytes and measured with `sips`,
88
- * never through Sharp.
89
- *
90
- * Sharp cannot read a real photo's metadata at all: an iPhone HEIC is a
91
- * tiled grid whose tiles are cross-referenced through the ISO-BMFF `iref`
92
- * box, and libheif rejects more than 16 references as a security limit —
93
- * a 12MP photo has 48. Routing HEIC through Sharp therefore reported
94
- * "Damaged image" for precisely the files people convert, while small
95
- * single-tile fixtures passed. See engines/heic.ts.
96
- */
97
- if (await looksLikeHeic(path)) {
98
- if (!(await heicDecodable()))
99
- throw heicDecoderUnavailable(path);
100
- let info;
101
- try {
102
- info = await heicInfo(path);
103
- }
104
- catch (cause) {
105
- // looksLikeHeic already read the ftyp box, so the format is known here
106
- // — unlike the generic sharp.metadata() failure below, this message
107
- // can and should say HEIC rather than falling back to "unrecognised".
108
- throw corruptFormatSource(path, 'heic', cause);
109
- }
110
- if (info.width === 0 || info.height === 0)
111
- throw corruptFormatSource(path, 'heic', undefined);
112
- return {
113
- kind: 'image',
114
- path,
115
- format: 'heic',
116
- width: info.width,
117
- height: info.height,
118
- bytes: stats.size,
119
- hasAlpha: info.hasAlpha,
120
- // A HEIC image sequence exists but Forge treats one photo as one frame;
121
- // the decode step hands Sharp a single still either way.
122
- frames: 1,
123
- };
124
- }
125
- let meta;
126
- try {
127
- meta = await sharp(path).metadata();
128
- }
129
- catch (cause) {
130
- throw corruptSource(path, cause);
131
- }
132
- return {
133
- kind: 'image',
134
- path,
135
- format: identify(path, meta),
136
- width: meta.width ?? 0,
137
- height: meta.height ?? 0,
138
- bytes: stats.size,
139
- hasAlpha: meta.hasAlpha ?? false,
140
- frames: meta.pages ?? 1,
141
- };
142
- }
143
- /**
144
- * The single place a target format is dispatched to a Sharp encoder call.
145
- * Exported so `engines/pdfium.ts` can reuse it for the PDF-rasterisation
146
- * path rather than keeping a second, divergent dispatch — a hand-rolled
147
- * `target === 'png' ? ... : ...` there once silently dropped PNG's
148
- * `compressionLevel: 9` and would have silently emitted JPEG bytes for any
149
- * third format `WRITES` ever gained, which is exactly the hardcoded
150
- * output-format decision invariant 2 exists to prevent.
151
- */
152
- export function encode(pipeline, target, quality) {
153
- const q = quality ?? FORMATS[target].defaultQuality;
154
- switch (target) {
155
- case 'jpeg':
156
- return pipeline.jpeg({ quality: q, mozjpeg: true });
157
- case 'webp':
158
- return pipeline.webp({ quality: q });
159
- case 'avif':
160
- return pipeline.avif({ quality: q });
161
- case 'png':
162
- // sharp's `effort` option on PNG is not a CPU dial — it turns on
163
- // `palette: true`, which quantises to <=256 colours. `formats.ts`
164
- // declares PNG lossless, so encoding must actually be lossless.
165
- return pipeline.png({ compressionLevel: 9 });
166
- case 'gif':
167
- return pipeline.gif();
168
- case 'tiff':
169
- // The default `compression` is 'jpeg', which is lossy. `formats.ts`
170
- // declares TIFF lossless (hint: 'archival'), so the encoder must match.
171
- return pipeline.tiff({ compression: 'deflate' });
172
- case 'heic':
173
- throw new Error('heic is not writable; the capability graph should have prevented this');
174
- case 'pdf':
175
- throw new Error('pdf is not an image target; the capability graph should have prevented this');
176
- case 'docx':
177
- throw new Error('docx is not an image target; the capability graph should have prevented this');
178
- case 'doc':
179
- throw new Error('doc is not an image target; the capability graph should have prevented this');
180
- }
181
- }
182
- /**
183
- * Writes via a sibling temp file and renames. A crash mid-encode can then never
184
- * leave a truncated file where a good one used to be, and overwriting in place
185
- * is safe because the original is only replaced once the new file is complete.
186
- */
187
- async function writeAtomic(pipeline, output) {
188
- const dir = dirname(output);
189
- await prepareOutputDir(output);
190
- const temp = join(dir, `.forge-tmp-${randomBytes(6).toString('hex')}-${basename(output)}`);
191
- try {
192
- const info = await pipeline.toFile(temp);
193
- await rename(temp, output);
194
- return info.size;
195
- }
196
- catch (cause) {
197
- // `force` only swallows ENOENT. A cleanup failure (EACCES, EBUSY, ...)
198
- // must never replace the real encode error that is about to be thrown.
199
- await rm(temp, { force: true }).catch(() => { });
200
- throw classifyWriteError(output, cause);
201
- }
202
- }
203
- /**
204
- * Builds the pipeline both callers encode from, up to but not including the
205
- * encode itself.
206
- *
207
- * Shared rather than duplicated so the correctness rules hold on both paths:
208
- * HEIC decoded through sips, `.rotate()` before anything else, alpha
209
- * flattened for a target that cannot carry it, EXIF stripped unless asked
210
- * for. A second copy of this would be a second place for those to drift.
211
- *
212
- * The caller owns `cleanup` and must call it on every path — the temp HEIC
213
- * decode is exactly the litter invariant 6 exists to prevent.
214
- */
215
- async function pipelineFor(source, target, options, animated) {
216
- // The image engine only ever builds a pipeline for an image — the registry
217
- // routes jobs to an engine by `reads`/`writes`, so a document source
218
- // reaching here would be a caller bug, not a condition a user can trigger.
219
- if (source.kind !== 'image') {
220
- throw new Error('pipelineFor received a non-image source');
221
- }
222
- /**
223
- * HEIC cannot be decoded by the bundled libvips (see engines/heic.ts), so
224
- * it is transcoded to a temporary PNG by `sips` first and the ordinary
225
- * pipeline runs on that. Everything downstream is unchanged; only the file
226
- * Sharp opens differs.
227
- */
228
- if (source.format === 'heic' && !(await heicDecodable())) {
229
- throw heicDecoderUnavailable(source.path);
230
- }
231
- const heic = source.format === 'heic' ? await decodeHeic(source.path) : undefined;
232
- const cleanup = async () => {
233
- await heic?.cleanup();
234
- };
235
- let pipeline = sharp(heic?.path ?? source.path, animated ? { animated: true } : {});
236
- // Rule 1: EXIF orientation, before anything else. Verified safe on
237
- // animated input — page count survives.
238
- //
239
- // Applies to a decoded HEIC too. Measured, because the opposite seemed
240
- // more likely: an oriented JPEG stored 40x80/orientation-6 becomes an
241
- // 80x40 HEIC with the rotation baked in, and `sips` then decodes that
242
- // back to a 40x80 PNG *carrying orientation 6* in an eXIf chunk. So the
243
- // intermediate needs rotating exactly like any other source, and
244
- // skipping it here shipped every HEIC photo on its side.
245
- pipeline = pipeline.rotate();
246
- // Rule 2: composite onto a background when the target has no alpha channel.
247
- if (source.hasAlpha && !FORMATS[target].hasAlpha) {
248
- pipeline = pipeline.flatten({ background: options.background });
249
- }
250
- // Rule 3: strip EXIF/GPS by default, always keep the colour profile so
251
- // colours do not shift on wide-gamut displays.
252
- pipeline = options.keepMetadata ? pipeline.keepMetadata() : pipeline.keepIccProfile();
253
- return { pipeline, cleanup };
254
- }
255
- /**
256
- * Encodes without touching the disk.
257
- *
258
- * The target-size search calls this once per attempt and only ever needs the
259
- * byte count, so writing a temp file each time would be wasted I/O — and one
260
- * left behind by a failed attempt would be litter.
261
- */
262
- export async function encodeToBuffer(source, target, options) {
263
- const { pipeline, cleanup } = await pipelineFor(source, target, options, false);
264
- try {
265
- return await encode(pipeline, target, options.quality).toBuffer();
266
- }
267
- finally {
268
- await cleanup();
269
- }
270
- }
271
- async function run(job, onPhase) {
272
- if (job.op !== 'convert') {
273
- throw new Error(`image engine cannot ${job.op}`);
274
- }
275
- const source = job.sources[0];
276
- const output = job.outputs[0];
277
- // Same reasoning as pipelineFor: the registry only ever routes an image
278
- // source to this engine.
279
- if (source.kind !== 'image') {
280
- throw new Error('the image engine cannot convert a document source');
281
- }
282
- const spec = FORMATS[job.target];
283
- const warnings = [];
284
- onPhase({ phase: 'reading' });
285
- const isAnimated = source.frames > 1;
286
- const keepFrames = isAnimated && spec.animatable;
287
- // Rule 4: never drop frames silently.
288
- if (isAnimated && !spec.animatable) {
289
- warnings.push({
290
- code: 'animation-flattened',
291
- message: `${basename(source.path)} has ${source.frames} frames, ` +
292
- `and ${spec.label} cannot animate. Only the first frame was converted.`,
293
- });
294
- }
295
- onPhase({ phase: 'decoding' });
296
- const { pipeline, cleanup } = await pipelineFor(source, job.target, job.options, keepFrames);
297
- try {
298
- onPhase({ phase: 'encoding' });
299
- const encoded = encode(pipeline, job.target, job.options.quality);
300
- onPhase({ phase: 'writing' });
301
- const outputBytes = await writeAtomic(encoded, output);
302
- return { job, outputBytes, warnings };
303
- }
304
- catch (cause) {
305
- // `writeAtomic` already names what it knows — an undirectory-able
306
- // destination becomes `outputInvalid` ("Cannot write there / Check that
307
- // the path is valid and that you have permission"). Wrapping that in the
308
- // generic `conversionFailed` threw away the better message and replaced
309
- // its hint with "run again with --debug", which the interactive shell has
310
- // no equivalent for. Only an unnamed failure gets the generic wrapper;
311
- // `run.ts` makes the same distinction the same way.
312
- throw isForgeError(cause) ? cause : conversionFailed(source.path, cause);
313
- }
314
- finally {
315
- await cleanup();
316
- }
317
- }
318
- /**
319
- * One rung: an image has a single lever, quality.
320
- *
321
- * The resolution ladder lives in the PDF engine, which is the only module that
322
- * knows why 150 → 120 → 96 → 72 and not some other sequence.
323
- */
324
- async function measurer(job) {
325
- if (job.op !== 'convert')
326
- return undefined;
327
- const source = job.sources[0];
328
- return {
329
- ladder: [{}],
330
- measure: async (options) => (await encodeToBuffer(source, job.target, options)).length,
331
- };
332
- }
333
- export const imageEngine = {
334
- id: 'image',
335
- reads: READS,
336
- writes: WRITES,
337
- ops: new Set(['convert']),
338
- probe,
339
- run,
340
- measurer,
341
- };
342
- //# sourceMappingURL=image.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/engines/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEnD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAU5C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EA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