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/shell/stage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/shell/stage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAO9C,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AACtC,CAAC;AAED,MAAM,U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AK,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;IACvE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9B,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Writes a control sequence to the terminal.
|
|
3
|
-
*
|
|
4
|
-
* A named seam rather than `process.stdout.write` at the call site, so tests
|
|
5
|
-
* can observe the sequence without a TTY and so the `isTTY` gate is stated
|
|
6
|
-
* once. Control sequences are not the frame: a piped or redirected run must
|
|
7
|
-
* never receive them (the frame is the product's output, and nothing that is
|
|
8
|
-
* not the frame belongs in it).
|
|
9
|
-
*/
|
|
10
|
-
export function writeToTerminal(sequence, stream) {
|
|
11
|
-
const out = stream ?? process.stdout;
|
|
12
|
-
if (!out.isTTY)
|
|
13
|
-
return;
|
|
14
|
-
out.write(sequence);
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=terminal-write.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-write.js","sourceRoot":"","sources":["../../src/shell/terminal-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,MAA2B;IAC3E,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAA;IACpC,IAAI,CAAC,GAAG,CAAC,KAAK;QAAE,OAAM;IACtB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AACrB,CAAC"}
|
package/dist/shell/theme.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/** Single source of truth for the version the shell displays. */
|
|
2
|
-
export const VERSION = '0.1.0';
|
|
3
|
-
/**
|
|
4
|
-
* Symbols are paired with words at every call site so meaning survives a
|
|
5
|
-
* monochrome terminal — colour is an accent, never the carrier.
|
|
6
|
-
*/
|
|
7
|
-
export const SYMBOLS = {
|
|
8
|
-
ok: '✓',
|
|
9
|
-
fail: '✕',
|
|
10
|
-
warn: '⚠',
|
|
11
|
-
cursor: '❯',
|
|
12
|
-
arrow: '→',
|
|
13
|
-
/**
|
|
14
|
-
* An offer the user can take or ignore — a better format, a merge worth
|
|
15
|
-
* making. Deliberately not `warn`: nothing has gone wrong when one of
|
|
16
|
-
* these appears, the file asked for is already written and correct, and
|
|
17
|
-
* `⚠` is what this shell puts in front of a skipped file, a size it could
|
|
18
|
-
* not read and a command it refused. A glyph that means two opposite
|
|
19
|
-
* things means neither.
|
|
20
|
-
*/
|
|
21
|
-
tip: '✧',
|
|
22
|
-
/**
|
|
23
|
-
* The arrow drawn between two things rather than inside a sentence — the
|
|
24
|
-
* before and after of a conversion. Long enough to read as a connector at
|
|
25
|
-
* a glance; the short one still serves inline text like "4 MB → 1 MB".
|
|
26
|
-
*/
|
|
27
|
-
longArrow: '──→',
|
|
28
|
-
longArrowDown: '│\n▼',
|
|
29
|
-
/**
|
|
30
|
-
* The target-size search's attempt row. Filled and empty differ in shape as
|
|
31
|
-
* well as intensity, so the row still reads under NO_COLOR — where the two
|
|
32
|
-
* colours it is drawn in collapse into one.
|
|
33
|
-
*/
|
|
34
|
-
dotFilled: '●',
|
|
35
|
-
dotEmpty: '○',
|
|
36
|
-
};
|
|
37
|
-
export const DARK = {
|
|
38
|
-
name: 'dark',
|
|
39
|
-
fg: '#e4e8f0',
|
|
40
|
-
// 5.4:1 on a #1e1e1e terminal. The previous #6b7385 measured 3.51:1, which
|
|
41
|
-
// is below AA for body text — and secondary text here is real content
|
|
42
|
-
// (sizes, paths), not decoration.
|
|
43
|
-
dim: '#8b93a6',
|
|
44
|
-
accent: '#e5a23c',
|
|
45
|
-
ok: '#6fcf7f',
|
|
46
|
-
warn: '#e5c07b',
|
|
47
|
-
fail: '#e8796d',
|
|
48
|
-
// 7.49:1 on #1e1e1e. A true orange (hue ~28°) rather than `warn`'s gold
|
|
49
|
-
// (~40°) — the two need to read as different colours next to each other,
|
|
50
|
-
// not just different words.
|
|
51
|
-
larger: '#f2994a',
|
|
52
|
-
tag: '#63c1d8',
|
|
53
|
-
label: '#a68ce0',
|
|
54
|
-
modeConvert: '#55c7d9',
|
|
55
|
-
modeConvertBg: '#122c33',
|
|
56
|
-
modeCompress: '#79c98b',
|
|
57
|
-
modeCompressBg: '#182c1e',
|
|
58
|
-
modePdf: '#ff6b4a',
|
|
59
|
-
modePdfBg: '#361c16',
|
|
60
|
-
// 2.97:1 — just under the 3:1 wanted for a meaningful boundary, and as far
|
|
61
|
-
// as a frame can go before it starts competing with the text inside it.
|
|
62
|
-
// The old #39404f measured 1.60:1 and was effectively invisible.
|
|
63
|
-
border: '#5f6879',
|
|
64
|
-
selectionBg: '#252c3a',
|
|
65
|
-
// Clearly distinct from selectionBg above, which is the drop area's own
|
|
66
|
-
// fill — a selection has to read against that, not blend into it.
|
|
67
|
-
textSelectionBg: '#3f5c86',
|
|
68
|
-
};
|
|
69
|
-
export const LIGHT = {
|
|
70
|
-
name: 'light',
|
|
71
|
-
fg: '#23262d',
|
|
72
|
-
// 4.77:1 on white; the previous #8b9099 was 3.21:1.
|
|
73
|
-
dim: '#6e737c',
|
|
74
|
-
// 5.19:1; #a86a06 measured 4.44:1, just under AA. The accent marks the
|
|
75
|
-
// selected row, so it has to clear the bar for text, not for decoration.
|
|
76
|
-
accent: '#9a6005',
|
|
77
|
-
ok: '#1e7a35',
|
|
78
|
-
warn: '#8a6100',
|
|
79
|
-
fail: '#b3261e',
|
|
80
|
-
// 5.56:1 on white. Same reasoning as DARK's `larger`: a burnt orange
|
|
81
|
-
// (~34°) distinct from `warn`'s brown-gold, clearing AA the way `dim` and
|
|
82
|
-
// `accent` above do.
|
|
83
|
-
larger: '#9c5700',
|
|
84
|
-
tag: '#0a6b86',
|
|
85
|
-
label: '#6141ad',
|
|
86
|
-
modeConvert: '#087f91',
|
|
87
|
-
modeConvertBg: '#e6f7fa',
|
|
88
|
-
modeCompress: '#24733a',
|
|
89
|
-
modeCompressBg: '#eaf5ec',
|
|
90
|
-
modePdf: '#c83b1d',
|
|
91
|
-
modePdfBg: '#fceee9',
|
|
92
|
-
// 3.11:1, meeting the boundary threshold. #c3bdb2 measured 1.87:1.
|
|
93
|
-
border: '#9a9184',
|
|
94
|
-
selectionBg: '#eae4d8',
|
|
95
|
-
textSelectionBg: '#b9cfe8',
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Used before the user has chosen a theme — that is, while the first-run
|
|
99
|
-
* picker is on screen and we genuinely do not know the background. It is the
|
|
100
|
-
* one palette built from ANSI names and empty strings rather than hex: it
|
|
101
|
-
* sets no background fill and no foreground at all, so it inherits the
|
|
102
|
-
* terminal's own colours and is legible on any background by construction.
|
|
103
|
-
*/
|
|
104
|
-
export const NEUTRAL = {
|
|
105
|
-
name: 'neutral',
|
|
106
|
-
fg: '',
|
|
107
|
-
dim: 'gray',
|
|
108
|
-
accent: 'yellow',
|
|
109
|
-
ok: 'green',
|
|
110
|
-
warn: 'yellow',
|
|
111
|
-
fail: 'red',
|
|
112
|
-
// No distinct "orange" in the basic 16 ANSI names this palette is built
|
|
113
|
-
// from — same collapse `accent` and `warn` already make here.
|
|
114
|
-
larger: 'yellow',
|
|
115
|
-
tag: 'cyan',
|
|
116
|
-
label: 'magenta',
|
|
117
|
-
modeConvert: 'cyan',
|
|
118
|
-
modeConvertBg: '',
|
|
119
|
-
modeCompress: 'green',
|
|
120
|
-
modeCompressBg: '',
|
|
121
|
-
modePdf: 'red',
|
|
122
|
-
modePdfBg: '',
|
|
123
|
-
border: 'gray',
|
|
124
|
-
selectionBg: '',
|
|
125
|
-
// No colour is asserted before the theme is known, so a selection in this
|
|
126
|
-
// palette is drawn with reverse video instead.
|
|
127
|
-
textSelectionBg: '',
|
|
128
|
-
};
|
|
129
|
-
export function paletteFor(theme) {
|
|
130
|
-
if (theme === 'dark')
|
|
131
|
-
return DARK;
|
|
132
|
-
if (theme === 'light')
|
|
133
|
-
return LIGHT;
|
|
134
|
-
return NEUTRAL;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Ink treats `undefined` as "do not set this attribute"; the palettes use ''
|
|
138
|
-
* for the same idea, because an interface of optional strings would make
|
|
139
|
-
* every consumer handle absence separately. This is the one adapter between
|
|
140
|
-
* the two conventions.
|
|
141
|
-
*/
|
|
142
|
-
export function colourProp(value) {
|
|
143
|
-
return value === '' ? undefined : value;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Glyphs for bar-style controls (e.g. the quality Slider). `filled` and
|
|
147
|
-
* `empty` are deliberately the same character — the design spec's mock
|
|
148
|
-
* distinguishes them by intensity (dim vs normal), not by shape, and the
|
|
149
|
-
* knob's position plus the printed numeric value carry the actual meaning.
|
|
150
|
-
*/
|
|
151
|
-
export const BAR = {
|
|
152
|
-
filled: '━',
|
|
153
|
-
empty: '━',
|
|
154
|
-
knob: '●',
|
|
155
|
-
};
|
|
156
|
-
/** Honours NO_COLOR (https://no-color.org) and non-TTY output. */
|
|
157
|
-
export function colourEnabled() {
|
|
158
|
-
if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== '')
|
|
159
|
-
return false;
|
|
160
|
-
return process.stdout.isTTY === true;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Spec §13 says `NO_COLOR` is honoured, and nothing downstream does it for
|
|
164
|
-
* us: Ink styles through chalk 5.6.2, whose vendored `supports-color` reads
|
|
165
|
-
* `FORCE_COLOR` and the `--no-color` *flag* and has no reference to the
|
|
166
|
-
* `NO_COLOR` env var at all. Measured: `NO_COLOR=1` on a colour-capable
|
|
167
|
-
* terminal still emitted `[2m`/`[31m`.
|
|
168
|
-
*
|
|
169
|
-
* `FORCE_COLOR` is the one lever chalk does read, and it reads it exactly
|
|
170
|
-
* once, when it is first imported. So this must run before anything pulls
|
|
171
|
-
* Ink in — which is why `src/index.ts` calls it immediately before its
|
|
172
|
-
* `await import('./shell/launch.js')`, and why that import is lazy.
|
|
173
|
-
*/
|
|
174
|
-
export function applyColourPreference() {
|
|
175
|
-
if (!colourEnabled())
|
|
176
|
-
process.env.FORCE_COLOR = '0';
|
|
177
|
-
}
|
|
178
|
-
//# sourceMappingURL=theme.js.map
|
package/dist/shell/theme.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/shell/theme.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;IACV;;;;;;;OAOG;IACH,GAAG,EAAE,GAAG;IACR;;;;OAIG;IACH,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,MAAM;IACrB;;;;OAIG;IACH,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;CACL,CAAA;AA+DV,MAAM,CAAC,MAAM,IAAI,GAAY;IAC3B,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,SAAS;IACb,2EAA2E;IAC3E,sEAAsE;IACtE,kCAAkC;IAClC,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,SAAS;IACjB,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,wEAAwE;IACxE,yEAAyE;IACzE,4BAA4B;IAC5B,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,SAAS;IACxB,YAAY,EAAE,SAAS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Ac,EAAE,EAAE;IAClB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,EAAE;IACb,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,EAAE;IACf,0EAA0E;IAC1E,+CAA+C;IAC/C,eAAe,EAAE,EAAE;CACpB,CAAA;AAED,MAAM,UAAU,UAAU,CAAC,KAAmC;IAC5D,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IACjC,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAA;IACnC,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;CACD,CAAA;AAEV,kEAAkE;AAClE,MAAM,UAAU,aAAa;IAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,EAAE;QAAE,OAAO,KAAK,CAAA;IACnF,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAA;AACtC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,CAAC,aAAa,EAAE;QAAE,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,CAAA;AACrD,CAAC"}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { measureElement, useStdout } from 'ink';
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { frameTopFromCursor } from './frame-geometry.js';
|
|
4
|
-
import { CURSOR_QUERY } from './mouse.js';
|
|
5
|
-
import { writeToTerminal } from './terminal-write.js';
|
|
6
|
-
import { useCursorReport } from './useMouse.js';
|
|
7
|
-
/**
|
|
8
|
-
* How many unanswered `CURSOR_QUERY` writes `pendingHeights` tolerates before
|
|
9
|
-
* this hook stops sending more. Real latency plus a burst of triggers (a fast
|
|
10
|
-
* resize followed immediately by a revision bump, say) can leave a couple of
|
|
11
|
-
* replies outstanding briefly; a terminal that never answers DSR at all —
|
|
12
|
-
* some multiplexers, CI/wrapper PTYs, minimal emulators, all real, not
|
|
13
|
-
* hypothetical — would otherwise leave this queue growing by one on every
|
|
14
|
-
* recalibration for the life of the process. Small enough to bound that
|
|
15
|
-
* leak quickly, generous enough that ordinary round-trip latency never
|
|
16
|
-
* trips it.
|
|
17
|
-
*/
|
|
18
|
-
const MAX_PENDING_QUERIES = 4;
|
|
19
|
-
/**
|
|
20
|
-
* The absolute row the frame's first line occupies, or null until the terminal
|
|
21
|
-
* has answered once.
|
|
22
|
-
*
|
|
23
|
-
* Ink hides the cursor while rendering and leaves it at column 0 one line past
|
|
24
|
-
* the frame, so asking the terminal where its cursor is (DSR) locates the frame
|
|
25
|
-
* without moving anything and without being visible. That is what makes this
|
|
26
|
-
* work inline: Ink never exposes the frame's absolute position, and in inline
|
|
27
|
-
* mode the frame moves whenever `<Static>` history scrolls the screen.
|
|
28
|
-
*
|
|
29
|
-
* The answer is cached, not re-queried per event, because hover needs a
|
|
30
|
-
* position on every cell of pointer travel and a round trip per motion event
|
|
31
|
-
* is not affordable. It is refreshed only when the frame can have moved:
|
|
32
|
-
*
|
|
33
|
-
* - mount
|
|
34
|
-
* - `revision` changed — the caller's signal that history committed
|
|
35
|
-
* - the frame's own height changed
|
|
36
|
-
* - the terminal was resized
|
|
37
|
-
*
|
|
38
|
-
* Between refreshes the cached value stands. A click landing in the window
|
|
39
|
-
* between a refresh being issued and its reply arriving is resolved against the
|
|
40
|
-
* previous origin; `<Static>` only ever pushes the frame *down*, so a stale
|
|
41
|
-
* origin fails the bounds check and the click is dropped rather than routed to
|
|
42
|
-
* the wrong target.
|
|
43
|
-
*
|
|
44
|
-
* A `heightChanged` or `resized` refresh can itself race Ink's own repaint —
|
|
45
|
-
* see the comment inside `useCursorReport` below for the mechanism and
|
|
46
|
-
* `PendingQuery` for how a reply from that race is told apart from a
|
|
47
|
-
* legitimate one.
|
|
48
|
-
*/
|
|
49
|
-
export function useFrameOrigin(rootRef, revision) {
|
|
50
|
-
const { stdout } = useStdout();
|
|
51
|
-
const [origin, setOrigin] = useState(null);
|
|
52
|
-
/**
|
|
53
|
-
* In-flight queries, oldest first. The reply carries no identity, so it
|
|
54
|
-
* must be paired with the height that was current when it was *sent* —
|
|
55
|
-
* pairing it with the height at arrival would be wrong for any render that
|
|
56
|
-
* happened in between, and a single scalar survives only one in-flight
|
|
57
|
-
* query at a time: a second recalibration before the first reply lands
|
|
58
|
-
* would overwrite it, mispairing the first reply and dropping the second
|
|
59
|
-
* (its arrival would see nothing pending).
|
|
60
|
-
*
|
|
61
|
-
* A FIFO queue instead of a scalar is correct because DSR replies are not
|
|
62
|
-
* reordered — the terminal answers requests over a single serial
|
|
63
|
-
* connection in the order they were sent — so shifting the oldest pending
|
|
64
|
-
* entry off the front always matches the oldest reply still owed, however
|
|
65
|
-
* many queries are in flight at once.
|
|
66
|
-
*/
|
|
67
|
-
const pending = useRef([]);
|
|
68
|
-
const lastHeight = useRef(null);
|
|
69
|
-
const lastRevision = useRef(null);
|
|
70
|
-
const lastColumns = useRef(stdout?.columns);
|
|
71
|
-
const lastRows = useRef(stdout?.rows);
|
|
72
|
-
/**
|
|
73
|
-
* Mirrors `origin` synchronously. `useCursorReport`'s handler fires from a
|
|
74
|
-
* raw input event, not a render, so it cannot wait for `origin` state to
|
|
75
|
-
* catch up before the next reply needs to read it — the same reason
|
|
76
|
-
* `PathInput.tsx` and `Prompt.tsx` shadow their own state with a ref.
|
|
77
|
-
*/
|
|
78
|
-
const originRef = useRef(null);
|
|
79
|
-
const query = (height, verify) => {
|
|
80
|
-
pending.current.push({ height, verify });
|
|
81
|
-
writeToTerminal(CURSOR_QUERY, stdout);
|
|
82
|
-
};
|
|
83
|
-
useCursorReport((position) => {
|
|
84
|
-
// A reply with nothing queued is a stray report the app did not ask for
|
|
85
|
-
// (or one delivered after this component already unmounted its previous
|
|
86
|
-
// instance) — ignore it rather than pairing it with an unrelated entry.
|
|
87
|
-
const entry = pending.current.shift();
|
|
88
|
-
if (!entry)
|
|
89
|
-
return;
|
|
90
|
-
/**
|
|
91
|
-
* Ink's render throttle (`node_modules/ink/build/ink.js`:
|
|
92
|
-
* `throttle(this.onRender, renderThrottleMs, {leading: true, trailing:
|
|
93
|
-
* true})`, ~33ms at the default `maxFps: 30`) can paint on a trailing
|
|
94
|
-
* timer that fires *after* the effect below has already measured the new
|
|
95
|
-
* layout and sent its query. Yoga's layout — what `measureElement` reads
|
|
96
|
-
* — updates synchronously on every commit regardless of the throttle
|
|
97
|
-
* (`resetAfterCommit` in `node_modules/ink/build/reconciler.js` calls
|
|
98
|
-
* `onComputeLayout()` unconditionally, before the possibly-throttled
|
|
99
|
-
* `onRender()`), so the effect can measure and query a height the
|
|
100
|
-
* terminal has not been told about yet. When that happens, this reply
|
|
101
|
-
* describes whatever was *last actually painted* — the old frame — but
|
|
102
|
-
* is about to be paired with the *new* height, which would misplace the
|
|
103
|
-
* origin by the difference and leave it wrong until an unrelated trigger
|
|
104
|
-
* recalibrated.
|
|
105
|
-
*
|
|
106
|
-
* `entry.verify` is false for a query that cannot have raced (see
|
|
107
|
-
* `PendingQuery`), and its reply is trusted outright. Otherwise: a reply
|
|
108
|
-
* consistent with the paint having caught up satisfies `position.row -
|
|
109
|
-
* originRef.current === entry.height` (the frame's top has not moved,
|
|
110
|
-
* only its height did — the case this hook can retry safely). A reply
|
|
111
|
-
* that fails this is not trustworthy either way — the paint may not have
|
|
112
|
-
* landed, or the frame moved for a reason this hook does not model — so
|
|
113
|
-
* it is dropped and a fresh, verified query goes out against the
|
|
114
|
-
* *current* measured height instead of risking a wrong pairing. The very
|
|
115
|
-
* first reply of all (`originRef.current === null`) has nothing to check
|
|
116
|
-
* against and is always trusted: nothing can be mid-throttle before the
|
|
117
|
-
* first paint has ever happened.
|
|
118
|
-
*/
|
|
119
|
-
if (entry.verify &&
|
|
120
|
-
originRef.current !== null &&
|
|
121
|
-
position.row - originRef.current !== entry.height) {
|
|
122
|
-
if (pending.current.length < MAX_PENDING_QUERIES) {
|
|
123
|
-
const node = rootRef.current;
|
|
124
|
-
if (node) {
|
|
125
|
-
const height = measureElement(node).height;
|
|
126
|
-
lastHeight.current = height;
|
|
127
|
-
query(height, true);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const next = frameTopFromCursor(position.row, entry.height);
|
|
133
|
-
originRef.current = next;
|
|
134
|
-
setOrigin(next);
|
|
135
|
-
});
|
|
136
|
-
// No dependency array: the frame's height is only knowable after a render,
|
|
137
|
-
// so the decision to re-query is made from measurements taken here.
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
const node = rootRef.current;
|
|
140
|
-
if (!node)
|
|
141
|
-
return;
|
|
142
|
-
const { height } = measureElement(node);
|
|
143
|
-
const heightChanged = lastHeight.current !== height;
|
|
144
|
-
const revisionChanged = lastRevision.current !== revision;
|
|
145
|
-
const resized = lastColumns.current !== stdout?.columns || lastRows.current !== stdout?.rows;
|
|
146
|
-
if (!heightChanged && !revisionChanged && !resized)
|
|
147
|
-
return;
|
|
148
|
-
// A terminal that never answers DSR is an expected case, not an anomaly
|
|
149
|
-
// (see `MAX_PENDING_QUERIES`) — nothing ever shifts `pending` in that
|
|
150
|
-
// world, so left ungated this would push one more entry per
|
|
151
|
-
// recalibration for as long as the process runs. Once that many replies
|
|
152
|
-
// are still outstanding, give up asking: `origin` stays at whatever it
|
|
153
|
-
// last resolved to (`null`, if the very first query was never answered),
|
|
154
|
-
// mouse support degrades to inert rather than guessing, and no further
|
|
155
|
-
// escape sequences are wasted on a terminal that ignores them.
|
|
156
|
-
//
|
|
157
|
-
// The trackers below are deliberately left stale while gated, so that
|
|
158
|
-
// the render right after a slot frees (a reply finally does shift one
|
|
159
|
-
// off) re-evaluates against *current* geometry rather than the
|
|
160
|
-
// possibly-long-stale geometry from when queries first stopped.
|
|
161
|
-
if (pending.current.length >= MAX_PENDING_QUERIES)
|
|
162
|
-
return;
|
|
163
|
-
lastHeight.current = height;
|
|
164
|
-
lastRevision.current = revision;
|
|
165
|
-
lastColumns.current = stdout?.columns;
|
|
166
|
-
lastRows.current = stdout?.rows;
|
|
167
|
-
// Revision-triggered queries cannot race (see `PendingQuery`) and — via
|
|
168
|
-
// `<Static>` — are the one legitimate way the origin moves, which is
|
|
169
|
-
// exactly what the verification above cannot distinguish from the race.
|
|
170
|
-
// So they skip it; height and resize queries do not.
|
|
171
|
-
query(height, !revisionChanged);
|
|
172
|
-
});
|
|
173
|
-
return origin;
|
|
174
|
-
}
|
|
175
|
-
//# sourceMappingURL=useFrameOrigin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFrameOrigin.js","sourceRoot":"","sources":["../../src/shell/useFrameOrigin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAChE,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAsB7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAqC,EACrC,QAAgB;IAEhB,MAAM,EAAE,MAAM,EA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AAC,OAAO,GAAG,MAAM,CAAA;QAC3B,YAAY,CAAC,OAAO,GAAG,QAAQ,CAAA;QAC/B,WAAW,CAAC,OAAO,GAAG,MAAM,EAAE,OAAO,CAAA;QACrC,QAAQ,CAAC,OAAO,GAAG,MAAM,EAAE,IAAI,CAAA;QAE/B,wEAAwE;QACxE,qEAAqE;QACrE,wEAAwE;QACxE,qDAAqD;QACrD,KAAK,CAAC,MAAM,EAAE,CAAC,eAAe,CAAC,CAAA;IACjC,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/shell/useKeys.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useInput } from 'ink';
|
|
2
|
-
/**
|
|
3
|
-
* `useInput`, minus key *releases*.
|
|
4
|
-
*
|
|
5
|
-
* The shell asks for the kitty keyboard protocol (see `launch.tsx`) because it
|
|
6
|
-
* is the only channel on macOS that can report Cmd — as `key.super` — and the
|
|
7
|
-
* flag that makes Cmd legible on the arrow keys, `reportEventTypes`, also
|
|
8
|
-
* makes the terminal report every key going *up* as well as down. Ink passes
|
|
9
|
-
* those through like any other event, so a handler that does not filter them
|
|
10
|
-
* runs twice per keystroke: one typed character inserted twice, one Enter
|
|
11
|
-
* submitting twice.
|
|
12
|
-
*
|
|
13
|
-
* Every `useInput` in this app therefore goes through here instead. A single
|
|
14
|
-
* choke point rather than sixteen guards, because the failure mode of missing
|
|
15
|
-
* one is silent and only appears in terminals that speak the protocol — which
|
|
16
|
-
* is not the one most of this was developed against.
|
|
17
|
-
*
|
|
18
|
-
* `repeat` is deliberately kept: it is what auto-repeat on a held key is made
|
|
19
|
-
* of, and dropping it would make held arrows move exactly one column.
|
|
20
|
-
*/
|
|
21
|
-
export function useKeys(handler, options) {
|
|
22
|
-
useInput((input, key) => {
|
|
23
|
-
if (key.eventType === 'release')
|
|
24
|
-
return;
|
|
25
|
-
handler(input, key);
|
|
26
|
-
}, options);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=useKeys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useKeys.js","sourceRoot":"","sources":["../../src/shell/useKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,KAAK,CAAA;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,OAAO,CACrB,OAA0C,EAC1C,OAAgC;IAEhC,QAAQ,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtB,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS;YAAE,OAAM;QACvC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC,EAAE,OAAO,CAAC,CAAA;AACb,CAAC"}
|
package/dist/shell/useMouse.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { writeSync } from 'node:fs';
|
|
2
|
-
import { useStdin, useStdout } from 'ink';
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
4
|
-
import { MOUSE_OFF, MOUSE_ON, MOUSE_ON_WITH_HOVER, parseCursorReport, parseMouse, } from './mouse.js';
|
|
5
|
-
/**
|
|
6
|
-
* Which reporting mode to ask the terminal for.
|
|
7
|
-
*
|
|
8
|
-
* Motion reporting costs an event per cell of pointer travel, so it is asked
|
|
9
|
-
* for only while something on screen can respond to a hover.
|
|
10
|
-
*/
|
|
11
|
-
export function reportingSequence(hover) {
|
|
12
|
-
return hover ? MOUSE_ON_WITH_HOVER : MOUSE_ON;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Turns terminal mouse reporting on for as long as the calling component is
|
|
16
|
-
* mounted, and hands decoded events to `onEvent`.
|
|
17
|
-
*
|
|
18
|
-
* Reporting is a mode set on the *terminal*, not on this process, so the one
|
|
19
|
-
* thing this must never do is exit without clearing it. A terminal left in
|
|
20
|
-
* reporting mode prints `[<35;…M` at the user's shell prompt on every mouse
|
|
21
|
-
* move, and nothing short of `reset` puts it right — that failure is behind
|
|
22
|
-
* the "stuck in mouse reporting" bug reports filed against other CLIs. Ink
|
|
23
|
-
* installs no signal handling of its own (only `beforeExit`, which a signal
|
|
24
|
-
* skips), so every path off is covered here.
|
|
25
|
-
*
|
|
26
|
-
* The cost, which is unavoidable and worth stating plainly: while reporting is
|
|
27
|
-
* on the terminal routes drags to us instead of to its own selection, so
|
|
28
|
-
* click-dragging no longer selects text to copy. Holding Option restores the
|
|
29
|
-
* native behaviour in both Terminal.app and iTerm2.
|
|
30
|
-
*/
|
|
31
|
-
export function useMouse(onEvent, options = {}) {
|
|
32
|
-
const { isActive = true, hover = false } = options;
|
|
33
|
-
const { setRawMode, internal_eventEmitter } = useStdin();
|
|
34
|
-
/**
|
|
35
|
-
* The stream Ink is rendering to, not the global `process.stdout`. They are
|
|
36
|
-
* the same object in production and deliberately are not under test — and
|
|
37
|
-
* more importantly, a run whose output is piped or redirected must not have
|
|
38
|
-
* mode-setting sequences injected into it.
|
|
39
|
-
*/
|
|
40
|
-
const { stdout } = useStdout();
|
|
41
|
-
/**
|
|
42
|
-
* Mirrored into a ref so the effect below does not re-run — and therefore
|
|
43
|
-
* does not switch reporting off and on again — every time the caller passes
|
|
44
|
-
* a fresh closure, which is every render.
|
|
45
|
-
*/
|
|
46
|
-
const handler = useRef(onEvent);
|
|
47
|
-
handler.current = onEvent;
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (!isActive)
|
|
50
|
-
return;
|
|
51
|
-
/**
|
|
52
|
-
* The stream object itself rather than `useStdout().write`: that helper is
|
|
53
|
-
* the scrollback-and-`<Static>` path for *output*, and a mode-setting
|
|
54
|
-
* sequence is not output.
|
|
55
|
-
*
|
|
56
|
-
* Gated on a real terminal. Mouse reporting is meaningless without one,
|
|
57
|
-
* and writing the sequence anyway would corrupt a piped or redirected run
|
|
58
|
-
* — the frame is the product's output, and nothing that is not the frame
|
|
59
|
-
* belongs in it.
|
|
60
|
-
*/
|
|
61
|
-
const out = stdout;
|
|
62
|
-
if (!out?.isTTY)
|
|
63
|
-
return;
|
|
64
|
-
setRawMode(true);
|
|
65
|
-
out.write(reportingSequence(hover));
|
|
66
|
-
let cleared = false;
|
|
67
|
-
const clear = () => {
|
|
68
|
-
if (cleared)
|
|
69
|
-
return;
|
|
70
|
-
cleared = true;
|
|
71
|
-
/**
|
|
72
|
-
* `writeSync` on the file descriptor rather than `out.write`: on the
|
|
73
|
-
* signal paths below the process is about to go, and a buffered async
|
|
74
|
-
* write can lose the race. This is the one sequence that must land.
|
|
75
|
-
* A stream with no fd (a test double) falls back to the ordinary write.
|
|
76
|
-
*/
|
|
77
|
-
const fd = out.fd;
|
|
78
|
-
try {
|
|
79
|
-
if (typeof fd === 'number')
|
|
80
|
-
writeSync(fd, MOUSE_OFF);
|
|
81
|
-
else
|
|
82
|
-
out.write(MOUSE_OFF);
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
out.write(MOUSE_OFF);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Ink's own input channel, which hands over sequences already reassembled
|
|
90
|
-
* by its incremental CSI parser. A bare `stdin.on('data')` listener would
|
|
91
|
-
* work too, but it sees raw chunks — a report split across two writes
|
|
92
|
-
* arrives as `"[<0;12;"` then `"34M"`, and reassembling it correctly means
|
|
93
|
-
* reimplementing the framer Ink already has.
|
|
94
|
-
*/
|
|
95
|
-
const onInput = (data) => {
|
|
96
|
-
const event = parseMouse(data);
|
|
97
|
-
if (event)
|
|
98
|
-
handler.current(event);
|
|
99
|
-
};
|
|
100
|
-
internal_eventEmitter?.on('input', onInput);
|
|
101
|
-
/**
|
|
102
|
-
* SIGINT is not "maybe" — ctrl-c is how this app is normally quit.
|
|
103
|
-
* `process.on`, not `once`, would leak across remounts, so these are
|
|
104
|
-
* removed again below.
|
|
105
|
-
*/
|
|
106
|
-
const onSignal = (signal) => {
|
|
107
|
-
clear();
|
|
108
|
-
process.removeListener(signal, onSignal);
|
|
109
|
-
process.kill(process.pid, signal);
|
|
110
|
-
};
|
|
111
|
-
process.on('SIGINT', onSignal);
|
|
112
|
-
process.on('SIGTERM', onSignal);
|
|
113
|
-
process.on('SIGHUP', onSignal);
|
|
114
|
-
process.on('exit', clear);
|
|
115
|
-
return () => {
|
|
116
|
-
clear();
|
|
117
|
-
internal_eventEmitter?.removeListener('input', onInput);
|
|
118
|
-
process.removeListener('SIGINT', onSignal);
|
|
119
|
-
process.removeListener('SIGTERM', onSignal);
|
|
120
|
-
process.removeListener('SIGHUP', onSignal);
|
|
121
|
-
process.removeListener('exit', clear);
|
|
122
|
-
};
|
|
123
|
-
}, [isActive, hover, setRawMode, internal_eventEmitter, stdout]);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Delivers the terminal's replies to `CURSOR_QUERY`.
|
|
127
|
-
*
|
|
128
|
-
* Split from `useMouse` because the two have different lifetimes: mouse
|
|
129
|
-
* reporting is a mode that must be switched on and off, while a cursor report
|
|
130
|
-
* is a one-shot answer to a question this app asked. Both read the same
|
|
131
|
-
* channel, so both go through Ink's reassembled input rather than a raw
|
|
132
|
-
* `data` listener.
|
|
133
|
-
*/
|
|
134
|
-
export function useCursorReport(onReport, isActive = true) {
|
|
135
|
-
const { internal_eventEmitter } = useStdin();
|
|
136
|
-
const handler = useRef(onReport);
|
|
137
|
-
handler.current = onReport;
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
if (!isActive)
|
|
140
|
-
return;
|
|
141
|
-
const onInput = (data) => {
|
|
142
|
-
const position = parseCursorReport(data);
|
|
143
|
-
if (position)
|
|
144
|
-
handler.current(position);
|
|
145
|
-
};
|
|
146
|
-
internal_eventEmitter?.on('input', onInput);
|
|
147
|
-
return () => internal_eventEmitter?.removeListener('input', onInput);
|
|
148
|
-
}, [isActive, internal_eventEmitter]);
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=useMouse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMouse.js","sourceRoot":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istry } from './ClickTargets.js';
|
|
3
|
-
import { useFrameOrigin } from './useFrameOrigin.js';
|
|
4
|
-
import { useMouse } from './useMouse.js';
|
|
5
|
-
/**
|
|
6
|
-
* Turns terminal mouse reports into calls on whatever is rendered under the
|
|
7
|
-
* pointer.
|
|
8
|
-
*
|
|
9
|
-
* Mounted once, at the shell root. The registry it reads is filled by
|
|
10
|
-
* `useClickTarget` from wherever the clickable things are.
|
|
11
|
-
*/
|
|
12
|
-
export function useMouseRouting(rootRef, revision) {
|
|
13
|
-
const registry = useClickTargetRegistry();
|
|
14
|
-
const origin = useFrameOrigin(rootRef, revision);
|
|
15
|
-
/** The target the pointer was over on the previous motion event. */
|
|
16
|
-
const hovered = useRef(null);
|
|
17
|
-
const hoveredLeave = useRef(null);
|
|
18
|
-
const originRef = useRef(origin);
|
|
19
|
-
originRef.current = origin;
|
|
20
|
-
const onEvent = useCallback((event) => {
|
|
21
|
-
const top = originRef.current;
|
|
22
|
-
// Uncalibrated: a coordinate cannot be placed, and guessing would route
|
|
23
|
-
// a click to whatever happens to be at that row. Drop it instead.
|
|
24
|
-
if (top === null)
|
|
25
|
-
return;
|
|
26
|
-
const point = { row: event.y - top, col: event.x };
|
|
27
|
-
const target = registry.hitTest(point);
|
|
28
|
-
if (event.action === 'move' || event.action === 'drag') {
|
|
29
|
-
const id = target?.id ?? null;
|
|
30
|
-
// Only a *change* of target redraws. Motion reporting delivers an event
|
|
31
|
-
// per cell of travel, and re-rendering on each would flicker for no
|
|
32
|
-
// visible difference.
|
|
33
|
-
if (id === hovered.current)
|
|
34
|
-
return;
|
|
35
|
-
hoveredLeave.current?.(false);
|
|
36
|
-
hovered.current = id;
|
|
37
|
-
hoveredLeave.current = target?.onHover ?? null;
|
|
38
|
-
target?.onHover?.(true);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Press only. A click delivers press *and* release at the same cell, so
|
|
43
|
-
* acting on both would fire every action twice — the same double-delivery
|
|
44
|
-
* hazard `useKeys` exists to solve for the kitty keyboard protocol.
|
|
45
|
-
* Wheel events are decoded but unbound: the inline layout has no
|
|
46
|
-
* scrollable region of its own, scrollback belongs to the terminal.
|
|
47
|
-
*/
|
|
48
|
-
if (event.action !== 'press')
|
|
49
|
-
return;
|
|
50
|
-
if (event.button !== 1)
|
|
51
|
-
return;
|
|
52
|
-
if (!target)
|
|
53
|
-
return;
|
|
54
|
-
// Target-relative, so a consumer never has to know where it was placed.
|
|
55
|
-
target.onClick({
|
|
56
|
-
row: point.row - target.rect.row,
|
|
57
|
-
col: point.col - target.rect.col,
|
|
58
|
-
});
|
|
59
|
-
}, [registry]);
|
|
60
|
-
/**
|
|
61
|
-
* Read through `useSyncExternalStore` rather than by calling `registry.size()`
|
|
62
|
-
* during render: targets register in effects, so a render-time read sees an
|
|
63
|
-
* empty registry on mount and would leave motion reporting off until
|
|
64
|
-
* something unrelated re-rendered.
|
|
65
|
-
*/
|
|
66
|
-
const targetCount = useSyncExternalStore(registry.subscribe, registry.getSnapshot, registry.getSnapshot);
|
|
67
|
-
useMouse(onEvent, { hover: targetCount > 0 });
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=useMouseRouting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMouseRouting.js","sourceRoot":"","sources":["../../src/shell/useMouseRouting.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,OAAqC,EAAE,QAAgB;IACrF,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAA;IACzC,MAAM,MAAM,GAAG,cAAc,CAA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