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.
Files changed (208) hide show
  1. package/README.md +305 -24
  2. package/dist/chunks/adm-zip-SQKLKBDP.js +3 -0
  3. package/dist/chunks/available-2VX7K7W6.js +3 -0
  4. package/dist/chunks/boot-ODZZHFUI.js +3 -0
  5. package/dist/chunks/cfb-V6M2PYOD.js +13 -0
  6. package/dist/chunks/chunk-2WYHI73Y.js +3 -0
  7. package/dist/chunks/chunk-4YHKTP7I.js +3 -0
  8. package/dist/chunks/chunk-5PYTOHLZ.js +3 -0
  9. package/dist/chunks/chunk-7YQR2MVH.js +3 -0
  10. package/dist/chunks/chunk-DRBA23IQ.js +3 -0
  11. package/dist/chunks/chunk-EOYBXOCV.js +4 -0
  12. package/dist/chunks/chunk-FQV57RMH.js +3 -0
  13. package/dist/chunks/chunk-IMKI5F4I.js +4 -0
  14. package/dist/chunks/chunk-J7FLFHQJ.js +3 -0
  15. package/dist/chunks/chunk-L2WK7CJG.js +3 -0
  16. package/dist/chunks/chunk-LFE3WRU4.js +3 -0
  17. package/dist/chunks/chunk-MHFY7HF6.js +10 -0
  18. package/dist/chunks/chunk-PBIS2ONZ.js +3 -0
  19. package/dist/chunks/chunk-QVACE4IE.js +3 -0
  20. package/dist/chunks/chunk-TMUK2DD3.js +3 -0
  21. package/dist/chunks/chunk-UNVHKJW4.js +41 -0
  22. package/dist/chunks/chunk-V4GHQGQM.js +4 -0
  23. package/dist/chunks/chunk-VB665HTV.js +3 -0
  24. package/dist/chunks/chunk-YHK5VE5R.js +3 -0
  25. package/dist/chunks/colour-QV2C3R7R.js +3 -0
  26. package/dist/chunks/config-command-UXJY623L.js +3 -0
  27. package/dist/chunks/dist-J2V6ITHG.js +29 -0
  28. package/dist/chunks/es-T2U7NBLD.js +3 -0
  29. package/dist/chunks/execute-4WJCUM7J.js +3 -0
  30. package/dist/chunks/extensions-command-6WZV2AES.js +3 -0
  31. package/dist/chunks/launch-2OI4ZLBQ.js +66 -0
  32. package/dist/chunks/lib-TPEJ5CJJ.js +46 -0
  33. package/dist/chunks/lock-R6GZXCCW.js +3 -0
  34. package/dist/chunks/manager-H52ENJOH.js +4 -0
  35. package/dist/chunks/paths-XY2345OS.js +3 -0
  36. package/dist/chunks/pdf-compress-IMRFBLZF.js +3 -0
  37. package/dist/chunks/react-devtools-core-UM4FS6CU.js +3 -0
  38. package/dist/chunks/run-N3F4EM7E.js +4 -0
  39. package/dist/chunks/server-5RWSVTOM.js +73 -0
  40. package/dist/chunks/theme-GW7CQPUO.js +3 -0
  41. package/dist/chunks/word-OGQ2KZAJ.js +24 -0
  42. package/dist/index.js +67 -95
  43. package/dist/third-party-licenses.txt +2856 -0
  44. package/package.json +28 -21
  45. package/skills/forge/SKILL.md +128 -0
  46. package/dist/cli/args.js +0 -278
  47. package/dist/cli/args.js.map +0 -1
  48. package/dist/cli/config-command.js +0 -55
  49. package/dist/cli/config-command.js.map +0 -1
  50. package/dist/cli/execute.js +0 -377
  51. package/dist/cli/execute.js.map +0 -1
  52. package/dist/cli/report.js +0 -123
  53. package/dist/cli/report.js.map +0 -1
  54. package/dist/cli/spinner.js +0 -60
  55. package/dist/cli/spinner.js.map +0 -1
  56. package/dist/cli/stdin.js +0 -47
  57. package/dist/cli/stdin.js.map +0 -1
  58. package/dist/config/preferences.js +0 -143
  59. package/dist/config/preferences.js.map +0 -1
  60. package/dist/core/actions/compress.js +0 -157
  61. package/dist/core/actions/compress.js.map +0 -1
  62. package/dist/core/actions/convert.js +0 -270
  63. package/dist/core/actions/convert.js.map +0 -1
  64. package/dist/core/actions/extract.js +0 -94
  65. package/dist/core/actions/extract.js.map +0 -1
  66. package/dist/core/actions/index.js +0 -23
  67. package/dist/core/actions/index.js.map +0 -1
  68. package/dist/core/actions/merge.js +0 -16
  69. package/dist/core/actions/merge.js.map +0 -1
  70. package/dist/core/actions/rotate.js +0 -36
  71. package/dist/core/actions/rotate.js.map +0 -1
  72. package/dist/core/actions/split.js +0 -65
  73. package/dist/core/actions/split.js.map +0 -1
  74. package/dist/core/atomic.js +0 -61
  75. package/dist/core/atomic.js.map +0 -1
  76. package/dist/core/capabilities.js +0 -59
  77. package/dist/core/capabilities.js.map +0 -1
  78. package/dist/core/compress.js +0 -76
  79. package/dist/core/compress.js.map +0 -1
  80. package/dist/core/describe.js +0 -49
  81. package/dist/core/describe.js.map +0 -1
  82. package/dist/core/errors.js +0 -469
  83. package/dist/core/errors.js.map +0 -1
  84. package/dist/core/execute-jobs.js +0 -122
  85. package/dist/core/execute-jobs.js.map +0 -1
  86. package/dist/core/formats.js +0 -108
  87. package/dist/core/formats.js.map +0 -1
  88. package/dist/core/order.js +0 -44
  89. package/dist/core/order.js.map +0 -1
  90. package/dist/core/output-path.js +0 -176
  91. package/dist/core/output-path.js.map +0 -1
  92. package/dist/core/pages.js +0 -107
  93. package/dist/core/pages.js.map +0 -1
  94. package/dist/core/pdf-compress.js +0 -206
  95. package/dist/core/pdf-compress.js.map +0 -1
  96. package/dist/core/plan.js +0 -42
  97. package/dist/core/plan.js.map +0 -1
  98. package/dist/core/resolve.js +0 -115
  99. package/dist/core/resolve.js.map +0 -1
  100. package/dist/core/run.js +0 -66
  101. package/dist/core/run.js.map +0 -1
  102. package/dist/core/suggest.js +0 -50
  103. package/dist/core/suggest.js.map +0 -1
  104. package/dist/core/types.js +0 -2
  105. package/dist/core/types.js.map +0 -1
  106. package/dist/core/units.js +0 -94
  107. package/dist/core/units.js.map +0 -1
  108. package/dist/core/write-safety.js +0 -128
  109. package/dist/core/write-safety.js.map +0 -1
  110. package/dist/engines/heic.js +0 -166
  111. package/dist/engines/heic.js.map +0 -1
  112. package/dist/engines/image.js +0 -342
  113. package/dist/engines/image.js.map +0 -1
  114. package/dist/engines/pdf.js +0 -444
  115. package/dist/engines/pdf.js.map +0 -1
  116. package/dist/engines/pdfium.js +0 -161
  117. package/dist/engines/pdfium.js.map +0 -1
  118. package/dist/engines/registry.js +0 -65
  119. package/dist/engines/registry.js.map +0 -1
  120. package/dist/engines/types.js +0 -2
  121. package/dist/engines/types.js.map +0 -1
  122. package/dist/engines/word.js +0 -385
  123. package/dist/engines/word.js.map +0 -1
  124. package/dist/index.js.map +0 -1
  125. package/dist/shell/App.js +0 -1972
  126. package/dist/shell/App.js.map +0 -1
  127. package/dist/shell/ClickTargets.js +0 -183
  128. package/dist/shell/ClickTargets.js.map +0 -1
  129. package/dist/shell/ThemeContext.js +0 -21
  130. package/dist/shell/ThemeContext.js.map +0 -1
  131. package/dist/shell/blocks.js +0 -160
  132. package/dist/shell/blocks.js.map +0 -1
  133. package/dist/shell/clipboard.js +0 -64
  134. package/dist/shell/clipboard.js.map +0 -1
  135. package/dist/shell/commands.js +0 -51
  136. package/dist/shell/commands.js.map +0 -1
  137. package/dist/shell/components/Banner.js +0 -73
  138. package/dist/shell/components/Banner.js.map +0 -1
  139. package/dist/shell/components/CommandPalette.js +0 -37
  140. package/dist/shell/components/CommandPalette.js.map +0 -1
  141. package/dist/shell/components/FileCard.js +0 -59
  142. package/dist/shell/components/FileCard.js.map +0 -1
  143. package/dist/shell/components/HintBar.js +0 -18
  144. package/dist/shell/components/HintBar.js.map +0 -1
  145. package/dist/shell/components/Hints.js +0 -21
  146. package/dist/shell/components/Hints.js.map +0 -1
  147. package/dist/shell/components/MergeList.js +0 -268
  148. package/dist/shell/components/MergeList.js.map +0 -1
  149. package/dist/shell/components/ModeHeader.js +0 -21
  150. package/dist/shell/components/ModeHeader.js.map +0 -1
  151. package/dist/shell/components/PageGrid.js +0 -324
  152. package/dist/shell/components/PageGrid.js.map +0 -1
  153. package/dist/shell/components/PathInput.js +0 -147
  154. package/dist/shell/components/PathInput.js.map +0 -1
  155. package/dist/shell/components/Progress.js +0 -43
  156. package/dist/shell/components/Progress.js.map +0 -1
  157. package/dist/shell/components/Prompt.js +0 -667
  158. package/dist/shell/components/Prompt.js.map +0 -1
  159. package/dist/shell/components/ResultLinks.js +0 -26
  160. package/dist/shell/components/ResultLinks.js.map +0 -1
  161. package/dist/shell/components/Select.js +0 -152
  162. package/dist/shell/components/Select.js.map +0 -1
  163. package/dist/shell/components/Slider.js +0 -48
  164. package/dist/shell/components/Slider.js.map +0 -1
  165. package/dist/shell/components/StagedFiles.js +0 -92
  166. package/dist/shell/components/StagedFiles.js.map +0 -1
  167. package/dist/shell/components/ThemePicker.js +0 -18
  168. package/dist/shell/components/ThemePicker.js.map +0 -1
  169. package/dist/shell/components/UnitRow.js +0 -30
  170. package/dist/shell/components/UnitRow.js.map +0 -1
  171. package/dist/shell/flows/pdf.js +0 -424
  172. package/dist/shell/flows/pdf.js.map +0 -1
  173. package/dist/shell/frame-geometry.js +0 -56
  174. package/dist/shell/frame-geometry.js.map +0 -1
  175. package/dist/shell/hyperlink.js +0 -27
  176. package/dist/shell/hyperlink.js.map +0 -1
  177. package/dist/shell/intro.js +0 -101
  178. package/dist/shell/intro.js.map +0 -1
  179. package/dist/shell/launch.js +0 -75
  180. package/dist/shell/launch.js.map +0 -1
  181. package/dist/shell/mark.js +0 -134
  182. package/dist/shell/mark.js.map +0 -1
  183. package/dist/shell/mouse.js +0 -209
  184. package/dist/shell/mouse.js.map +0 -1
  185. package/dist/shell/redraw.js +0 -36
  186. package/dist/shell/redraw.js.map +0 -1
  187. package/dist/shell/reveal.js +0 -24
  188. package/dist/shell/reveal.js.map +0 -1
  189. package/dist/shell/stage.js +0 -34
  190. package/dist/shell/stage.js.map +0 -1
  191. package/dist/shell/terminal-write.js +0 -16
  192. package/dist/shell/terminal-write.js.map +0 -1
  193. package/dist/shell/theme.js +0 -178
  194. package/dist/shell/theme.js.map +0 -1
  195. package/dist/shell/useFrameOrigin.js +0 -175
  196. package/dist/shell/useFrameOrigin.js.map +0 -1
  197. package/dist/shell/useKeys.js +0 -28
  198. package/dist/shell/useKeys.js.map +0 -1
  199. package/dist/shell/useMouse.js +0 -150
  200. package/dist/shell/useMouse.js.map +0 -1
  201. package/dist/shell/useMouseRouting.js +0 -69
  202. package/dist/shell/useMouseRouting.js.map +0 -1
  203. package/dist/shell/width.js +0 -62
  204. package/dist/shell/width.js.map +0 -1
  205. package/dist/utils/display-path.js +0 -31
  206. package/dist/utils/display-path.js.map +0 -1
  207. package/dist/utils/unescape-path.js +0 -68
  208. package/dist/utils/unescape-path.js.map +0 -1
@@ -1,101 +0,0 @@
1
- import { WORDMARK } from './components/Banner.js';
2
- import { composeMark, glyphColour, HEAT, MARK_AT_REST, MARK_HEIGHT, MARK_WIDTH, REST_STEP, SWING, } from './mark.js';
3
- import { bandFor } from './width.js';
4
- /**
5
- * The banner, played once, *before* Ink starts.
6
- *
7
- * This is the only way to have both a moving mark and a mark that stays at the
8
- * top of the session. Ink's `<Static>` is written once and never redrawn,
9
- * which is what pins content above the live region — so an animation cannot
10
- * live there. Running it in the live region instead and then committing to
11
- * `<Static>` was tried: the live region shrinks on that transition and the
12
- * terminal is left holding lines Ink can no longer erase.
13
- *
14
- * So the loop is drawn here, by hand, with a cursor-up between frames to
15
- * redraw in place. When it finishes, the last frame is simply left where it
16
- * is. It becomes ordinary scrollback — exactly like the output of any other
17
- * command — and Ink then mounts underneath it, never knowing it happened.
18
- */
19
- const ESC = String.fromCharCode(27);
20
- const FRAME_MS = 130;
21
- const GAP = ' ';
22
- function sgr(colour) {
23
- if (colour === undefined)
24
- return '';
25
- const n = Number.parseInt(colour.slice(1), 16);
26
- return `${ESC}[38;2;${(n >> 16) & 255};${(n >> 8) & 255};${n & 255}m`;
27
- }
28
- const RESET = `${ESC}[39m`;
29
- /**
30
- * One rendered line of the banner: the mark's row, a gap, then the wordmark's.
31
- * The wordmark is shorter than the mark, so it is bottom-aligned against it —
32
- * the letters sit level with the anvil rather than floating above it.
33
- */
34
- function bannerLines(mark, step, heat, palette, colour) {
35
- const lead = MARK_HEIGHT - WORDMARK.length;
36
- return mark.map((row, y) => {
37
- const word = y >= lead ? (WORDMARK[y - lead] ?? '') : ' '.repeat(WORDMARK[0]?.length ?? 0);
38
- if (!colour)
39
- return `${row}${GAP}${word}`;
40
- const drawnMark = Array.from(row)
41
- .map((ch) => {
42
- const c = glyphColour(ch, y, step, heat, palette.dim);
43
- return c === undefined ? ch : `${sgr(c)}${ch}${RESET}`;
44
- })
45
- .join('');
46
- const drawnWord = Array.from(word)
47
- .map((ch) => {
48
- if (ch === ' ')
49
- return ch;
50
- // Face in the theme's foreground, edge in the accent — the outline is
51
- // what makes the letters legible, so it carries the colour.
52
- return `${sgr(ch === '█' ? palette.fg : palette.accent)}${ch}${RESET}`;
53
- })
54
- .join('');
55
- return `${drawnMark}${GAP}${drawnWord}`;
56
- });
57
- }
58
- /**
59
- * Plays the loop and leaves the final frame on screen. Resolves once it has.
60
- *
61
- * Skipped entirely when the terminal is too narrow for the art, and reduced to
62
- * a single still frame when colour is off — an animation whose whole subject
63
- * is metal changing temperature has nothing to say in monochrome, and would
64
- * only cost the user a second.
65
- */
66
- export async function playIntro(opts) {
67
- const write = opts.write ?? ((t) => process.stdout.write(t));
68
- const full = MARK_WIDTH + GAP.length + (WORDMARK[0]?.length ?? 0);
69
- if (bandFor(opts.width) === 'compact' || opts.width < full) {
70
- write(`\n ⚒ Forge ${opts.version}\n\n`);
71
- return;
72
- }
73
- const status = ` Convert ${opts.version} · image`;
74
- const pad = ' '.repeat(Math.max(2, Math.min(opts.width, 100) - status.length - opts.defaultOutput.length - 1));
75
- const statusLine = opts.colour
76
- ? `${sgr(opts.palette.dim)}${status}${pad}${opts.defaultOutput}${RESET}`
77
- : `${status}${pad}${opts.defaultOutput}`;
78
- const finish = (mark, step, heat) => {
79
- write(`${bannerLines(mark, step, heat, opts.palette, opts.colour).join('\n')}\n\n${statusLine}\n\n`);
80
- };
81
- if (!opts.colour) {
82
- finish(MARK_AT_REST, REST_STEP, '');
83
- return;
84
- }
85
- const frameMs = opts.frameMs ?? FRAME_MS;
86
- write('\n');
87
- for (let i = 0; i < SWING.length; i++) {
88
- const step = SWING[i];
89
- const heat = HEAT[i % HEAT.length] ?? HEAT[0];
90
- const lines = bannerLines(composeMark(step), step, heat, opts.palette, true);
91
- write(`${lines.join('\n')}\n`);
92
- if (i === SWING.length - 1)
93
- break;
94
- await new Promise((r) => setTimeout(r, frameMs));
95
- // Back up over the block just written, so the next frame lands on top of
96
- // it rather than below it.
97
- write(`${ESC}[${MARK_HEIGHT}A`);
98
- }
99
- write(`\n${statusLine}\n\n`);
100
- }
101
- //# sourceMappingURL=intro.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intro.js","sourceRoot":"","sources":["../../src/shell/intro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EACL,WAAW,EACX,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,KAAK,GAEN,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC;;;;;;;;;;;;;;GAcG;AAEH,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;AACnC,MAAM,QAAQ,GAAG,GAAG,CAAA;AACpB,MAAM,GAAG,GAAG,IAAI,CAAA;AAEhB,SAAS,GAAG,CAAC,MAA0B;IACrC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IACnC,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,OAAO,GAAG,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;AACvE,CAAC;AAED,MAAM,KAAK,GAAG,GAAG,GAAG,MAAM,CAAA;AAE1B;;;;GAIG;AACH,SAAS,WAAW,CAClB,IAAuB,EACvB,IAA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AAW,GAAG,CAAC,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,KAAK,UAAU,MAAM,CAAC,CAAA;AAC9B,CAAC"}
@@ -1,75 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from 'ink';
3
- import { loadPreferences } from '../config/preferences.js';
4
- import { App } from './App.js';
5
- import { playIntro } from './intro.js';
6
- import { ThemeProvider } from './ThemeContext.js';
7
- import { colourEnabled, paletteFor, VERSION } from './theme.js';
8
- /**
9
- * Renders the shell and resolves when the user exits it.
10
- *
11
- * Preferences are read exactly once, here, at the edge — `core/` never
12
- * touches the config file, and the shell threads what it needs downward.
13
- * A config that could not be read is not fatal: `loadPreferences` hands back
14
- * defaults plus a sentence, and the shell shows that as history.
15
- */
16
- export async function launchShell() {
17
- const { prefs, warning } = await loadPreferences();
18
- const palette = paletteFor(prefs.theme);
19
- /**
20
- * The banner is drawn here, before Ink exists, so its loop can play and then
21
- * simply stop — the last frame becomes scrollback and Ink mounts underneath
22
- * it. See intro.ts for why it cannot be done inside Ink.
23
- *
24
- * Skipped on first run: the theme picker owns the screen until a theme is
25
- * chosen, and until then there is no palette to draw it in. App pushes a
26
- * still banner once the answer is in.
27
- */
28
- if (prefs.theme !== undefined) {
29
- await playIntro({
30
- width: process.stdout.columns ?? 80,
31
- palette,
32
- version: VERSION,
33
- defaultOutput: prefs.defaultOutput,
34
- colour: colourEnabled(),
35
- });
36
- }
37
- const instance = render(_jsx(ThemeProvider, { palette: palette, children: _jsx(App, { prefs: prefs, introShown: prefs.theme !== undefined, ...(warning === undefined ? {} : { configWarning: warning }) }) }), {
38
- /**
39
- * The kitty keyboard protocol, which is the only way Cmd ever reaches a
40
- * terminal app on macOS.
41
- *
42
- * Without it a terminal reports modifiers by prefixing ESC, which cannot
43
- * express Command at all — Terminal.app's key-mapping UI does not even
44
- * offer it as a modifier. With it, the terminal reports each key as a
45
- * structured event carrying a modifier bitmask, and Cmd arrives as
46
- * `key.super`. That is what makes Cmd+Left and Cmd+Backspace possible in
47
- * iTerm2, Ghostty, WezTerm, kitty and VS Code's terminal.
48
- *
49
- * `auto` rather than `enabled`: Ink probes with `CSI ? u` and waits
50
- * 200ms for a reply, so a terminal that does not implement the protocol
51
- * — Terminal.app among them — is left exactly as it was rather than
52
- * being sent sequences it would print as text. The shell keeps working
53
- * there; it simply falls back to Option and the Ctrl bindings.
54
- *
55
- * `reportEventTypes` is what makes Cmd legible on the *arrow* keys, and
56
- * it is not optional for that. Measured against Ink 7.1.1: with only
57
- * `disambiguateEscapeCodes`, Cmd+Left arrives as the legacy `CSI 1;9D`,
58
- * which Ink's pre-kitty parser folds into `key.meta` — indistinguishable
59
- * from Option, so Cmd+Left would move by word instead of to the line
60
- * start. With event types on it arrives as `CSI 1;9:1D` and reports
61
- * `key.super` correctly.
62
- *
63
- * The cost is that the terminal then reports every key going up as well
64
- * as down. `useKeys` drops those releases in one place; nothing in this
65
- * app may call Ink's `useInput` directly, or it will fire twice per
66
- * keystroke.
67
- */
68
- kittyKeyboard: {
69
- mode: 'auto',
70
- flags: ['disambiguateEscapeCodes', 'reportEventTypes'],
71
- },
72
- });
73
- await instance.waitUntilExit();
74
- }
75
- //# sourceMappingURL=launch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"launch.js","sourceRoot":"","sources":["../../src/shell/launch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE/D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,eAAe,EAAE,CAAA;IAClD,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAEvC;;;;;;;;OAQG;IACH,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,SAAS,CAAC;YACd,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE;YACnC,OAAO;YACP,OAAO,EAAE,OAAO;YAChB,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,MAAM,EAAE,aAAa,EAAE;SACxB,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CACrB,KAAC,aAAa,IAAC,OAAO,EAAE,OAAO,YAC7B,KAAC,GAAG,IACF,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,KAAK,CAAC,KAAK,KAAK,SAAS,KACjC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,GAC7D,GACY,EAChB;QACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6BG;QACH,aAAa,EAAE;YACb,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,CAAC,yBAAyB,EAAE,kBAAkB,CAAC;SACvD;KACF,CACF,CAAA;IACD,MAAM,QAAQ,CAAC,aAAa,EAAE,CAAA;AAChC,CAAC"}
@@ -1,134 +0,0 @@
1
- /**
2
- * The anvil mark, as data.
3
- *
4
- * Deliberately React-free: this is drawn twice, once by the intro that runs
5
- * before Ink exists (`intro.ts`) and once by the `Banner` component for the
6
- * cases the intro skips. Keeping the geometry in one module is what stops the
7
- * two drifting apart.
8
- */
9
- /**
10
- * The hammer, defined once as a sprite and animated by moving it down a row.
11
- * Handle rows first, head last, and adjacent by construction — an earlier
12
- * version transcribed every frame by hand and let the handle come away from
13
- * the head.
14
- *
15
- * The head spans columns 3-7, whose centre is column 5, so the handle is one
16
- * column wide and sits at 5. A two-column handle straddles 4.5 and reads as
17
- * offset, which is exactly what it did.
18
- */
19
- export const HAMMER = [' ║ ', ' ║ ', ' ║ ', ' █████ '];
20
- /** The anvil never moves. Row 0 is its face — the row drawn at temperature. */
21
- export const ANVIL = [' ▄▄▄▄▄▄▄▄▄ ', '▐█████████▌', ' ▀▀▀▐█▌▀▀▀ ', ' ▄▄██████▄ '];
22
- /**
23
- * Rows of clear space above the anvil that the hammer swings through.
24
- *
25
- * The hammer sprite is four rows and its head is the last of them, so an
26
- * offset of 0 puts the head on the bottom row of the sky — resting directly
27
- * on the anvil's face. Offsets above that raise it, clipping the top of the
28
- * handle off the frame, which is what a hammer lifted out of shot looks like.
29
- * A positive offset would push the head onto the anvil's own row, where the
30
- * anvil overwrites it and the hammer loses its head entirely.
31
- */
32
- export const AIR = 4;
33
- export const MARK_WIDTH = ANVIL[0].length;
34
- export const MARK_HEIGHT = AIR + ANVIL.length;
35
- /**
36
- * Sparks, keyed by how long ago the strike was. Each spark keeps its column
37
- * and only climbs a row — that difference is the whole reason these read as
38
- * radiating rather than sliding sideways, which is what an earlier version
39
- * did by moving them along a row instead.
40
- *
41
- * `row` counts upward from the anvil face.
42
- */
43
- const SPARKS = [
44
- [{ row: 0, cells: [[2, '\\'], [5, '|'], [8, '/']] }],
45
- [
46
- { row: 0, cells: [[1, '\\'], [9, '/']] },
47
- { row: 1, cells: [[3, '.'], [7, '.']] },
48
- ],
49
- [
50
- { row: 1, cells: [[1, '*'], [9, '*']] },
51
- { row: 2, cells: [[3, "'"], [7, "'"]] },
52
- ],
53
- [{ row: 2, cells: [[1, '.'], [9, '.']] }],
54
- [],
55
- ];
56
- /**
57
- * Raised, falling, strike, then held while the sparks climb.
58
- *
59
- * It ends on the strike rather than on the lift, because the loop plays once
60
- * and stops — whatever the last frame is becomes the mark that sits in the
61
- * scrollback for the rest of the session. A hammer caught mid-lift is a
62
- * strange thing to leave there; a hammer on the metal with sparks in the air
63
- * is the moment worth holding.
64
- */
65
- export const SWING = [
66
- { offset: -2, spark: -1, hot: false },
67
- { offset: -1, spark: -1, hot: false },
68
- { offset: 0, spark: 0, hot: true },
69
- { offset: 0, spark: 1, hot: true },
70
- // The head cools on the frame the loop stops on. Only the work is hot —
71
- // a hammer that stays glowing in the scrollback reads as the thing being
72
- // forged rather than the thing doing the forging.
73
- { offset: 0, spark: 2, hot: false },
74
- ];
75
- /**
76
- * Composes one frame: empty sky, the hammer dropped in at its offset, sparks
77
- * laid over the top. Composition rather than transcription, so a frame cannot
78
- * be drawn with the pieces in the wrong places.
79
- */
80
- export function composeMark(step) {
81
- const sky = Array.from({ length: AIR }, () => Array(MARK_WIDTH).fill(' '));
82
- HAMMER.forEach((row, i) => {
83
- const y = step.offset + i;
84
- if (y < 0 || y >= AIR)
85
- return;
86
- Array.from(row).forEach((ch, x) => {
87
- if (ch !== ' ') {
88
- const line = sky[y];
89
- if (line)
90
- line[x] = ch;
91
- }
92
- });
93
- });
94
- for (const band of SPARKS[step.spark] ?? []) {
95
- const y = AIR - 1 - band.row;
96
- if (y < 0 || y >= AIR)
97
- continue;
98
- for (const [x, ch] of band.cells) {
99
- const line = sky[y];
100
- if (line && line[x] === ' ')
101
- line[x] = ch;
102
- }
103
- }
104
- return [...sky.map((r) => r.join('')), ...ANVIL];
105
- }
106
- /** The row of a composed frame that is the anvil's face. */
107
- export const FACE_ROW = AIR;
108
- /** The frame the loop stops on, and the still mark everywhere else. */
109
- export const REST_STEP = SWING[SWING.length - 1];
110
- export const MARK_AT_REST = composeMark(REST_STEP);
111
- /**
112
- * Heat colours are fixed rather than taken from the palette: metal at forging
113
- * temperature is orange whatever theme the terminal is set to, and a face that
114
- * turned grey in light mode would stop being hot metal and become a line.
115
- */
116
- export const HEAT = ['#a34a17', '#b4531a', '#c9631d', '#e0701c', '#ff8c1a', '#e0701c'];
117
- export const SPARK_COLOUR = '#ffc247';
118
- export const HANDLE_COLOUR = '#8a5a2b';
119
- /** Which colour a glyph takes, given how far down the frame it sits. */
120
- export function glyphColour(ch, row, step, heat, steel) {
121
- if (ch === ' ')
122
- return undefined;
123
- if (row === FACE_ROW)
124
- return heat;
125
- if (ch === '║')
126
- return HANDLE_COLOUR;
127
- if ("\\|/*.'".includes(ch))
128
- return SPARK_COLOUR;
129
- // The head is the only block glyph above the anvil, and it glows on impact.
130
- if (ch === '█' && row < FACE_ROW)
131
- return step.hot ? heat : steel;
132
- return steel;
133
- }
134
- //# sourceMappingURL=mark.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mark.js","sourceRoot":"","sources":["../../src/shell/mark.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,CAAU,CAAA;AAE3F,+EAA+E;AAC/E,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,CAAU,CAAA;AAE1F;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA;AACpB,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AACzC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC,MAAM,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,MAAM,GAAgF;IAC1F,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAU,EAAE,CAAC,CAAC,EAAE,GAAG,CAAU,EAAE,CAAC,CAAC,EAAE,GAAG,CAAU,CAAC,EAAE,CAAC;IAC/E;QACE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAU,EAAE,CAAC,CAAC,EAAE,GAAG,CAAU,CAAC,E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C,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAA;AAClD,CAAC;AAED,4DAA4D;AAC5D,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAA;AAE3B,uEAAuE;AACvE,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAc,CAAA;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC,SAAS,CAAC,CAAA;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAU,CAAA;AAC/F,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAA;AACrC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,wEAAwE;AACxE,MAAM,UAAU,WAAW,CACzB,EAAU,EACV,GAAW,EACX,IAAe,EACf,IAAY,EACZ,KAAa;IAEb,IAAI,EAAE,KAAK,GAAG;QAAE,OAAO,SAAS,CAAA;IAChC,IAAI,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IACjC,IAAI,EAAE,KAAK,GAAG;QAAE,OAAO,aAAa,CAAA;IACpC,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QAAE,OAAO,YAAY,CAAA;IAC/C,4EAA4E;IAC5E,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,GAAG,QAAQ;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;IAChE,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,209 +0,0 @@
1
- import stringWidth from 'string-width';
2
- import supportsHyperlinks from 'supports-hyperlinks';
3
- /**
4
- * Terminal mouse reporting: the escape sequences that switch it on, and the
5
- * decoder for the reports that come back.
6
- *
7
- * Pure data in, pure data out — nothing here touches React or stdout, for the
8
- * same reason `core/` does not (invariant 1). The hook that owns the terminal
9
- * side lives in `useMouse.ts`.
10
- *
11
- * Protocol reference: xterm ctlseqs, "Mouse Tracking".
12
- */
13
- /**
14
- * Whether this terminal is worth drawing a clickable affordance in at all.
15
- *
16
- * Enabling reporting (below) and registering click targets costs nothing on
17
- * a terminal that ignores both — a stray `?1000h` prints as garbage only if
18
- * the terminal cannot parse CSI at all, which none in real use fail at. The
19
- * actual failure mode, confirmed against real Terminal.app: reporting turns
20
- * on and the app calibrates its frame origin without error (Terminal.app
21
- * answers the plain `CURSOR_QUERY` DSR this app relies on — see
22
- * `useFrameOrigin.ts` — DSR/CPR is old, universal VT100, unlike the mouse
23
- * protocol layered on top of it), so nothing here can tell a click was ever
24
- * dropped. The result is a coloured label that looks exactly like a button
25
- * and never responds — worse than not drawing it, because a keyboard
26
- * shortcut for the same action is already shown right below it.
27
- *
28
- * Reuses `hyperlinksSupported`'s terminal allowlist rather than keeping a
29
- * second one: every terminal named there for OSC 8 (iTerm2, WezTerm, VS
30
- * Code, Ghostty, kitty, …) is also one with real SGR mouse support in
31
- * practice, and Apple's Terminal.app — the one terminal excluded from both
32
- * — is the actual, reported failure this exists to route around. Not a
33
- * logical guarantee (the two protocols are unrelated), but the same
34
- * pragmatic bet this codebase already made once.
35
- */
36
- export function mouseSupported() {
37
- return supportsHyperlinks.stdout;
38
- }
39
- /**
40
- * SGR encoding (`?1006`) rather than the original X10 scheme, which packs
41
- * each coordinate into a single byte at `value + 32` and therefore cannot
42
- * express a column past 223. A wide terminal is not an edge case, and the
43
- * failure is silent — the coordinate simply wraps.
44
- *
45
- * `?1002` (report motion only while a button is held) rather than `?1003`
46
- * (report every motion): a text field has nothing to do with a bare hover,
47
- * and `?1003` wakes the process on every pixel of pointer travel.
48
- */
49
- export const MOUSE_ON = '\x1b[?1000h\x1b[?1002h\x1b[?1006h';
50
- /**
51
- * `MOUSE_ON`, but with `?1003` (report *every* motion) in place of `?1002`
52
- * (report motion only while a button is held).
53
- *
54
- * Used only while something hoverable is on screen. `?1003` wakes the process
55
- * on every cell of pointer travel, which is why it is not the default: with an
56
- * empty target registry `useMouse` asks for `MOUSE_ON` instead and the terminal
57
- * stays quiet. Cleared by the same `MOUSE_OFF`, which clears `?1003`
58
- * explicitly rather than counting on the terminal to alias it to `?1002`'s
59
- * tracking slot — see the comment on `MOUSE_OFF` for why.
60
- */
61
- export const MOUSE_ON_WITH_HOVER = '\x1b[?1000h\x1b[?1003h\x1b[?1006h';
62
- /**
63
- * Disabled in the reverse order, and — critically — this must run on every
64
- * exit path. Ink installs no SIGINT/SIGTSTP handling of its own, so a process
65
- * killed while reporting is on leaves the *terminal* in that state: the shell
66
- * the user returns to spews `[<35;…M` on every mouse move. That is the bug
67
- * behind the "stuck in mouse reporting" reports filed against other CLIs.
68
- *
69
- * Clears `?1002` and `?1003` both, even though only one of them was ever
70
- * turned on (`MOUSE_ON` sets the former, `MOUSE_ON_WITH_HOVER` the latter).
71
- * On a terminal with a single button-motion tracking slot, clearing either
72
- * one releases it regardless of which set it — but that is an aliasing
73
- * behaviour specific implementations happen to have (xterm, iTerm2), not
74
- * something the mouse-tracking protocol promises, and at least one real class
75
- * of emulator tracks `any_event` (`?1003`) as a flag of its own rather than
76
- * aliasing it to `?1002`. Relying on that aliasing is not worth the failure
77
- * mode above, so every mode this file can turn on is explicitly turned back
78
- * off, whether or not the terminal would have released it anyway.
79
- */
80
- export const MOUSE_OFF = '\x1b[?1006l\x1b[?1002l\x1b[?1003l\x1b[?1000l';
81
- /**
82
- * Recognises a control sequence Ink handed to a text consumer as if it were
83
- * typed input, rather than something the app should insert into a text
84
- * buffer.
85
- *
86
- * This shell now receives two kinds of sequence on stdin that never existed
87
- * before mouse support: `CURSOR_QUERY` replies (see `parseCursorReport`
88
- * above) and SGR mouse reports (see `parseMouse` below). Ink strips the
89
- * leading ESC from any sequence its own keypress parser could not resolve,
90
- * and both of those are exactly that — so they arrive at a plain text field
91
- * looking like ordinary characters starting with `[`, e.g. `"[<0;12;34M"` or
92
- * `"[24;1R"`. A field with no guard against this appends them to whatever
93
- * the user was typing.
94
- *
95
- * Matched narrowly on purpose: a lone `[`, and `[` followed by anything that
96
- * is not a CSI parameter run, must stay typeable, because brackets are legal
97
- * in filenames — `shot[1].png` must still work. A bare NUL (`\x00`), which
98
- * some terminals send as filler, is filtered for the same reason: it is
99
- * wire noise, not something anyone typed.
100
- */
101
- export function isStrayEscapeSequence(input) {
102
- return /^\[(?:[<>?][\d;]*|[\d;]+)[A-Za-z~]$/.test(input) || input === '\x00';
103
- }
104
- /**
105
- * Device Status Report — asks the terminal where the cursor currently is.
106
- * The reply comes back on the *input* stream as `ESC [ row ; col R`.
107
- *
108
- * This is what makes a click mappable at all. Ink never exposes the absolute
109
- * terminal position of its frame (the reason its maintainers rejected built-in
110
- * mouse support), and in inline mode the frame moves every time `<Static>`
111
- * history scrolls the screen. But `useCursor` parks the *real* terminal cursor
112
- * on the caret, so asking the terminal where the cursor is answers where the
113
- * caret is, in absolute coordinates, no matter what has scrolled.
114
- */
115
- export const CURSOR_QUERY = '\x1b[6n';
116
- /**
117
- * Decodes a DSR reply. Like a mouse report, this arrives with its leading ESC
118
- * already stripped by Ink, so the ESC is optional.
119
- */
120
- export function parseCursorReport(input) {
121
- // biome-ignore lint/suspicious/noControlCharactersInRegex: ESC is the sequence's own first byte
122
- const m = /^(?:\x1b)?\[(\d+);(\d+)R$/.exec(input);
123
- if (!m)
124
- return null;
125
- // One-based on the wire, zero-based everywhere downstream — the same
126
- // convention the mouse decoder above applies.
127
- return { row: Number(m[1]) - 1, col: Number(m[2]) - 1 };
128
- }
129
- /**
130
- * `ESC [ < Pb ; Px ; Py (M|m)` — but Ink strips the leading ESC from any
131
- * sequence its keypress parser could not resolve, and a mouse report is
132
- * exactly that. So the ESC is optional here: this accepts both the raw
133
- * sequence and the stripped form Ink actually delivers.
134
- */
135
- // biome-ignore lint/suspicious/noControlCharactersInRegex: ESC is the sequence's own first byte
136
- const SGR = /^(?:\x1b)?\[<(\d+);(\d+);(\d+)([Mm])$/;
137
- /**
138
- * Maps a click's column to an index into `text`, by walking display widths
139
- * rather than code points — `日本語` is three characters and six columns, and
140
- * a caret placed by column arithmetic alone lands in the wrong place the
141
- * moment a path contains one wide glyph or an emoji.
142
- *
143
- * A click past the midpoint of a wide glyph lands after it, which is what
144
- * every graphical text field does.
145
- */
146
- export function offsetForColumn(text, column) {
147
- const chars = Array.from(text);
148
- let col = 0;
149
- for (let i = 0; i < chars.length; i++) {
150
- const w = stringWidth(chars[i] ?? '');
151
- if (column < col + w / 2)
152
- return i;
153
- col += w;
154
- }
155
- return chars.length;
156
- }
157
- /**
158
- * Decodes one SGR mouse report, or returns null for anything else — including
159
- * ordinary typed text, which is the common case and must stay cheap.
160
- */
161
- export function parseMouse(input) {
162
- const m = SGR.exec(input);
163
- if (!m)
164
- return null;
165
- const code = Number(m[1]);
166
- const col = Number(m[2]);
167
- const row = Number(m[3]);
168
- const released = m[4] === 'm';
169
- /**
170
- * Bit 32 marks motion, bit 64 the wheel, bit 128 the extra buttons; the low
171
- * two bits carry which button, except that `3` means "none" (a release in
172
- * the days before the `m` terminator disambiguated it).
173
- */
174
- const low = code & 3;
175
- const motion = (code & 32) !== 0;
176
- let button;
177
- if (code & 64)
178
- button = 4 + low;
179
- else if (code & 128)
180
- button = 8 + low;
181
- else
182
- button = low === 3 ? null : low + 1;
183
- /**
184
- * The wheel reports no release — a scroll is a single event terminated by
185
- * `M` — so it is checked before the release flag, which would otherwise
186
- * never be reached for it anyway but reads as an accident.
187
- */
188
- const action = code & 64
189
- ? 'wheel'
190
- : released
191
- ? 'release'
192
- : motion
193
- ? button === null
194
- ? 'move'
195
- : 'drag'
196
- : 'press';
197
- return {
198
- // The protocol numbers the top-left cell 1,1; every layout calculation
199
- // downstream is zero-based, so the conversion happens once, here.
200
- x: col - 1,
201
- y: row - 1,
202
- button,
203
- action,
204
- shift: (code & 4) !== 0,
205
- meta: (code & 8) !== 0,
206
- ctrl: (code & 16) !== 0,
207
- };
208
- }
209
- //# sourceMappingURL=mouse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mouse.js","sourceRoot":"","sources":["../../src/shell/mouse.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,kBAAkB,MAAM,qBAAqB,CAAA;AAEpD;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,kBAAkB,CAAC,MAAM,CAAA;AAClC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,mCAAmC,CAAA;AAE3D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mCAAmC,CAAA;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,8CAA8C,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,qCAAqC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,MAAM,CAAA;AAC9E,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAA;AAErC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,gGAAgG;IAChG,MAAM,CAAC,GAAG,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACjD,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAA;IACnB,qEAAqE;IACrE,8CAA8C;IAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA;AACzD,CAAC;AAe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AE,MAAM,GAAG,CAAC,GAAG,GAAG,CAAA;SAC1B,IAAI,IAAI,GAAG,GAAG;QAAE,MAAM,GAAG,CAAC,GAAG,GAAG,CAAA;;QAChC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IAExC;;;;OAIG;IACH,MAAM,MAAM,GACV,IAAI,GAAG,EAAE;QACP,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,QAAQ;YACR,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,MAAM;gBACN,CAAC,CAAC,MAAM,KAAK,IAAI;oBACf,CAAC,CAAC,MAAM;oBACR,CAAC,CAAC,MAAM;gBACV,CAAC,CAAC,OAAO,CAAA;IAEjB,OAAO;QACL,uEAAuE;QACvE,kEAAkE;QAClE,CAAC,EAAE,GAAG,GAAG,CAAC;QACV,CAAC,EAAE,GAAG,GAAG,CAAC;QACV,MAAM;QACN,MAAM;QACN,KAAK,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC;QACvB,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC;QACtB,IAAI,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC;KACxB,CAAA;AACH,CAAC"}
@@ -1,36 +0,0 @@
1
- /**
2
- * Erase the visible screen *and* the scrollback, then home the cursor.
3
- *
4
- * Why the shell needs this on a width change at all: a terminal reflows the
5
- * lines already on screen when it is resized — one 100-column line becomes two
6
- * rows at 50 — but Ink erases its previous frame by counting the lines it
7
- * wrote, not the rows they now occupy. Every resize therefore left a partial
8
- * copy of the old frame above the new one, and the copies accumulated (UX
9
- * audit #5). Ink's own narrowing clear has the same blind spot.
10
- *
11
- * There is no erase that can be aimed at "the rows the old frame reflowed
12
- * into", so the shell clears everything and redraws: history is replayed
13
- * through a fresh `<Static>` and the live frame is drawn under it, both at the
14
- * new width. The scrollback has to go too — the reflowed copies live there
15
- * once they scroll off, and replaying history above them would duplicate
16
- * every block. This is the same sequence Ink itself writes when a frame
17
- * overflows the viewport.
18
- */
19
- export const CLEAR_SCREEN = '\u001b[2J\u001b[3J\u001b[H';
20
- /**
21
- * History as it is replayed after `CLEAR_SCREEN`.
22
- *
23
- * Banners and separator rules carry the width they were drawn at; everything
24
- * else is laid out from the live width already. Redrawing a rule at its old
25
- * width would wrap it — the very artefact the redraw exists to remove.
26
- *
27
- * `intro` is the banner `playIntro` printed before Ink mounted. It was never
28
- * part of history, so the clear erases it with nothing to put it back; the
29
- * caller passes it on the first redraw only, after which it is history like
30
- * any other block.
31
- */
32
- export function historyForRedraw(history, width, intro) {
33
- const blocks = intro ? [intro, ...history] : history;
34
- return blocks.map((block) => block.kind === 'banner' || block.kind === 'separator' ? { ...block, width } : block);
35
- }
36
- //# sourceMappingURL=redraw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redraw.js","sourceRoot":"","sources":["../../src/shell/redraw.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,4BAA4B,CAAA;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAuB,EACvB,KAAa,EACb,KAAoB;IAEpB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IACpD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1B,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CACpF,CAAA;AACH,CAAC"}
@@ -1,24 +0,0 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
- const run = promisify(execFile);
4
- /** Opens a file with its default application. */
5
- export async function openPath(path) {
6
- await run('open', [path]);
7
- }
8
- /** Reveals a file in Finder with it selected. */
9
- export async function revealPath(path) {
10
- await run('open', ['-R', path]);
11
- }
12
- /**
13
- * What the reveal action is called here. Finder is a macOS name, and Forge is
14
- * a macOS tool — but the wording should not be a lie anywhere it happens to
15
- * run, so the label follows the platform rather than being hardcoded.
16
- */
17
- export function revealLabel(platform = process.platform) {
18
- if (platform === 'darwin')
19
- return 'Show in Finder';
20
- if (platform === 'win32')
21
- return 'Show location';
22
- return 'Show in file manager';
23
- }
24
- //# sourceMappingURL=reveal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reveal.js","sourceRoot":"","sources":["../../src/shell/reveal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAE/B,iDAAiD;AACjD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;AAC3B,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,QAAQ,GAAW,OAAO,CAAC,QAAQ;IAC7D,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,gBAAgB,CAAA;IAClD,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,eAAe,CAAA;IAChD,OAAO,sBAAsB,CAAA;AAC/B,CAAC"}
@@ -1,34 +0,0 @@
1
- import { formatBytes } from '../core/units.js';
2
- export function emptyStage() {
3
- return { sources: [], failures: [] };
4
- }
5
- export function clearStage() {
6
- return emptyStage();
7
- }
8
- /**
9
- * Drops accumulate.
10
- *
11
- * Building a merge list means adding files one at a time, so a second drop
12
- * has to append rather than replace. Converting `a.jpg` and then dropping
13
- * `b.jpg` still starts fresh, because completing an action clears the stage —
14
- * that is where the replace behaviour lives, not here.
15
- */
16
- export function addToStage(stage, sources, failures) {
17
- const seen = new Set(stage.sources.map((s) => s.path));
18
- const added = sources.filter((s) => !seen.has(s.path));
19
- return {
20
- sources: [...stage.sources, ...added],
21
- failures: [...stage.failures, ...failures],
22
- };
23
- }
24
- export function stageSummary(stage) {
25
- const { sources } = stage;
26
- const bytes = sources.reduce((n, s) => n + s.bytes, 0);
27
- const pages = sources.reduce((n, s) => n + (s.kind === 'document' ? s.pages : 0), 0);
28
- const parts = [`${sources.length} ${sources.length === 1 ? 'file' : 'files'}`];
29
- if (pages > 0)
30
- parts.push(`${pages} ${pages === 1 ? 'page' : 'pages'}`);
31
- parts.push(formatBytes(bytes));
32
- return parts.join(' · ');
33
- }
34
- //# sourceMappingURL=stage.js.map