@earendil-works/pi-tui 0.83.0 → 0.84.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 (90) hide show
  1. package/README.md +77 -14
  2. package/dist/components/alt-screen-flash.d.ts +13 -0
  3. package/dist/components/alt-screen-flash.d.ts.map +1 -0
  4. package/dist/components/alt-screen-flash.js +37 -0
  5. package/dist/components/alt-screen-flash.js.map +1 -0
  6. package/dist/components/editor.d.ts.map +1 -1
  7. package/dist/components/editor.js +11 -0
  8. package/dist/components/editor.js.map +1 -1
  9. package/dist/components/h-stack.d.ts +7 -0
  10. package/dist/components/h-stack.d.ts.map +1 -0
  11. package/dist/components/h-stack.js +43 -0
  12. package/dist/components/h-stack.js.map +1 -0
  13. package/dist/components/markdown.d.ts +4 -0
  14. package/dist/components/markdown.d.ts.map +1 -1
  15. package/dist/components/markdown.js +128 -2
  16. package/dist/components/markdown.js.map +1 -1
  17. package/dist/components/scroll-view.d.ts +51 -0
  18. package/dist/components/scroll-view.d.ts.map +1 -0
  19. package/dist/components/scroll-view.js +173 -0
  20. package/dist/components/scroll-view.js.map +1 -0
  21. package/dist/components/settings-list.d.ts.map +1 -1
  22. package/dist/components/settings-list.js +3 -6
  23. package/dist/components/settings-list.js.map +1 -1
  24. package/dist/components/stack.d.ts +32 -0
  25. package/dist/components/stack.d.ts.map +1 -0
  26. package/dist/components/stack.js +111 -0
  27. package/dist/components/stack.js.map +1 -0
  28. package/dist/components/v-stack.d.ts +8 -0
  29. package/dist/components/v-stack.d.ts.map +1 -0
  30. package/dist/components/v-stack.js +26 -0
  31. package/dist/components/v-stack.js.map +1 -0
  32. package/dist/index.d.ts +9 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +10 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/keybindings.d.ts +54 -4
  37. package/dist/keybindings.d.ts.map +1 -1
  38. package/dist/keybindings.js +39 -4
  39. package/dist/keybindings.js.map +1 -1
  40. package/dist/latex.d.ts +10 -0
  41. package/dist/latex.d.ts.map +1 -0
  42. package/dist/latex.js +1264 -0
  43. package/dist/latex.js.map +1 -0
  44. package/dist/layout-node.d.ts +40 -0
  45. package/dist/layout-node.d.ts.map +1 -0
  46. package/dist/layout-node.js +6 -0
  47. package/dist/layout-node.js.map +1 -0
  48. package/dist/layout.d.ts +40 -0
  49. package/dist/layout.d.ts.map +1 -0
  50. package/dist/layout.js +314 -0
  51. package/dist/layout.js.map +1 -0
  52. package/dist/native-modifiers.d.ts.map +1 -1
  53. package/dist/native-modifiers.js +10 -3
  54. package/dist/native-modifiers.js.map +1 -1
  55. package/dist/terminal-colors.d.ts.map +1 -1
  56. package/dist/terminal-colors.js +1 -1
  57. package/dist/terminal-colors.js.map +1 -1
  58. package/dist/terminal-image.d.ts +21 -0
  59. package/dist/terminal-image.d.ts.map +1 -1
  60. package/dist/terminal-image.js +128 -3
  61. package/dist/terminal-image.js.map +1 -1
  62. package/dist/terminal.d.ts +1 -0
  63. package/dist/terminal.d.ts.map +1 -1
  64. package/dist/terminal.js +10 -7
  65. package/dist/terminal.js.map +1 -1
  66. package/dist/tui-alt-screen.d.ts +97 -0
  67. package/dist/tui-alt-screen.d.ts.map +1 -0
  68. package/dist/tui-alt-screen.js +902 -0
  69. package/dist/tui-alt-screen.js.map +1 -0
  70. package/dist/tui-main-screen.d.ts +39 -0
  71. package/dist/tui-main-screen.d.ts.map +1 -0
  72. package/dist/tui-main-screen.js +533 -0
  73. package/dist/tui-main-screen.js.map +1 -0
  74. package/dist/tui.d.ts +75 -38
  75. package/dist/tui.d.ts.map +1 -1
  76. package/dist/tui.js +98 -573
  77. package/dist/tui.js.map +1 -1
  78. package/dist/utils.d.ts +11 -0
  79. package/dist/utils.d.ts.map +1 -1
  80. package/dist/utils.js +119 -6
  81. package/dist/utils.js.map +1 -1
  82. package/native/darwin/README.md +20 -0
  83. package/native/darwin/build.sh +62 -0
  84. package/native/darwin/src/darwin-modifiers.c +70 -0
  85. package/native/win32/README.md +22 -0
  86. package/native/win32/build.mjs +229 -0
  87. package/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  88. package/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  89. package/native/win32/src/win32-console-mode.c +119 -0
  90. package/package.json +9 -1
package/dist/layout.js ADDED
@@ -0,0 +1,314 @@
1
+ import { allocateStackSizes, visibleStackEntries } from "./components/stack.js";
2
+ import { getLayoutNode } from "./layout-node.js";
3
+ import { cropKittyImageLine, getKittyImageMetadata, isImageLine } from "./terminal-image.js";
4
+ import { CURSOR_MARKER, compositeTuiLine } from "./tui.js";
5
+ import { extractAnsiCode, getGraphemeCellRange, sliceByColumn, visibleWidth } from "./utils.js";
6
+ const OSC133_ZONE_PREFIX = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
7
+ function intersect(a, b) {
8
+ const x = Math.max(a.x, b.x);
9
+ const y = Math.max(a.y, b.y);
10
+ const right = Math.min(a.x + a.width, b.x + b.width);
11
+ const bottom = Math.min(a.y + a.height, b.y + b.height);
12
+ return { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };
13
+ }
14
+ function renderCached(context, component, width) {
15
+ const safeWidth = Math.max(1, Math.floor(width));
16
+ let widths = context.renderCache.get(component);
17
+ if (!widths) {
18
+ widths = new Map();
19
+ context.renderCache.set(component, widths);
20
+ }
21
+ let lines = widths.get(safeWidth);
22
+ if (!lines) {
23
+ lines = component.render(safeWidth);
24
+ widths.set(safeWidth, lines);
25
+ }
26
+ return lines;
27
+ }
28
+ function measureHeight(context, component, width) {
29
+ return renderCached(context, component, width).length;
30
+ }
31
+ function measureWidth(context, component, width) {
32
+ return renderCached(context, component, width).reduce((max, line) => Math.max(max, visibleWidth(line)), 0);
33
+ }
34
+ function withParent(box, parent) {
35
+ box.parent = parent;
36
+ return box;
37
+ }
38
+ function translateBox(box, deltaY) {
39
+ box.rect.y += deltaY;
40
+ for (const child of box.children)
41
+ translateBox(child, deltaY);
42
+ }
43
+ function updateClips(box, parentClip) {
44
+ box.clip = intersect(parentClip, box.rect);
45
+ for (const child of box.children)
46
+ updateClips(child, box.clip);
47
+ }
48
+ function layoutComponent(context, component, x, y, width, height, clip) {
49
+ const safeWidth = Math.max(1, Math.floor(width));
50
+ const node = getLayoutNode(component);
51
+ if (!node) {
52
+ const lines = renderCached(context, component, safeWidth);
53
+ const allocatedHeight = height === undefined ? lines.length : Math.max(0, Math.floor(height));
54
+ let lineOffset = 0;
55
+ if (lines.length > allocatedHeight && allocatedHeight > 0) {
56
+ const cursorLine = lines.findIndex((line) => line.includes(CURSOR_MARKER));
57
+ if (cursorLine >= allocatedHeight)
58
+ lineOffset = cursorLine - allocatedHeight + 1;
59
+ }
60
+ return {
61
+ component,
62
+ rect: { x, y, width: safeWidth, height: allocatedHeight },
63
+ clip: intersect(clip, { x, y, width: safeWidth, height: allocatedHeight }),
64
+ children: [],
65
+ lines,
66
+ lineOffset,
67
+ layer: 0,
68
+ };
69
+ }
70
+ if (node.type === "scroll") {
71
+ const previousScrollTop = node.state.scrollTop;
72
+ const contentWidth = node.state.getContentWidth(safeWidth);
73
+ const childBox = layoutComponent(context, node.component, x, y - previousScrollTop, contentWidth, undefined, clip);
74
+ const contentHeight = childBox.rect.height;
75
+ const viewportHeight = height === undefined ? contentHeight : Math.max(0, Math.floor(height));
76
+ node.state.updateLayout(contentHeight, viewportHeight, context.requestRender);
77
+ translateBox(childBox, previousScrollTop - node.state.scrollTop);
78
+ const scrollView = node.state;
79
+ if (node.state.primary || !context.primaryScrollView)
80
+ context.primaryScrollView = scrollView;
81
+ const rect = { x, y, width: safeWidth, height: viewportHeight };
82
+ const childClip = intersect(clip, rect);
83
+ const box = {
84
+ component,
85
+ rect,
86
+ clip: childClip,
87
+ children: [childBox],
88
+ scrollView,
89
+ scrollContentLines: renderCached(context, node.component, contentWidth),
90
+ layer: 0,
91
+ };
92
+ childBox.parent = box;
93
+ updateClips(childBox, childClip);
94
+ return box;
95
+ }
96
+ const entries = visibleStackEntries(node.entries, context.viewport);
97
+ const gapTotal = Math.max(0, entries.length - 1) * node.gap;
98
+ if (node.type === "vstack") {
99
+ const intrinsicHeights = entries.map((entry) => typeof entry.basis === "number" ? entry.basis : measureHeight(context, entry.component, safeWidth));
100
+ const sizes = allocateStackSizes(entries, intrinsicHeights, height, node.gap);
101
+ const naturalHeight = sizes.reduce((sum, size) => sum + size, 0) + gapTotal;
102
+ const allocatedHeight = height === undefined ? naturalHeight : Math.max(0, Math.floor(height));
103
+ const rect = { x, y, width: safeWidth, height: allocatedHeight };
104
+ const box = {
105
+ component,
106
+ rect,
107
+ clip: intersect(clip, rect),
108
+ children: [],
109
+ layer: 0,
110
+ };
111
+ let childY = y;
112
+ for (let index = 0; index < entries.length; index++) {
113
+ box.children.push(withParent(layoutComponent(context, entries[index].component, x, childY, safeWidth, sizes[index], box.clip), box));
114
+ childY += sizes[index] + node.gap;
115
+ }
116
+ return box;
117
+ }
118
+ const intrinsicWidths = entries.map((entry) => typeof entry.basis === "number" ? entry.basis : measureWidth(context, entry.component, safeWidth));
119
+ const widths = allocateStackSizes(entries, intrinsicWidths, safeWidth, node.gap);
120
+ const intrinsicHeights = entries.map((entry, index) => measureHeight(context, entry.component, Math.max(1, widths[index])));
121
+ const allocatedHeight = height === undefined
122
+ ? intrinsicHeights.reduce((max, childHeight) => Math.max(max, childHeight), 0)
123
+ : Math.max(0, height);
124
+ const rect = { x, y, width: safeWidth, height: allocatedHeight };
125
+ const box = {
126
+ component,
127
+ rect,
128
+ clip: intersect(clip, rect),
129
+ children: [],
130
+ layer: 0,
131
+ };
132
+ let childX = x;
133
+ for (let index = 0; index < entries.length; index++) {
134
+ const naturalChildHeight = intrinsicHeights[index];
135
+ const childHeight = node.align === "stretch" ? allocatedHeight : Math.min(allocatedHeight, naturalChildHeight);
136
+ let childY = y;
137
+ if (node.align === "center")
138
+ childY += Math.floor((allocatedHeight - childHeight) / 2);
139
+ else if (node.align === "end")
140
+ childY += allocatedHeight - childHeight;
141
+ const childWidth = widths[index];
142
+ if (childWidth === 0) {
143
+ box.children.push({
144
+ component: entries[index].component,
145
+ rect: { x: childX, y: childY, width: 0, height: childHeight },
146
+ clip: { x: childX, y: childY, width: 0, height: 0 },
147
+ children: [],
148
+ parent: box,
149
+ layer: 0,
150
+ });
151
+ }
152
+ else {
153
+ box.children.push(withParent(layoutComponent(context, entries[index].component, childX, childY, childWidth, childHeight, box.clip), box));
154
+ }
155
+ childX += childWidth + node.gap;
156
+ }
157
+ return box;
158
+ }
159
+ function styleScrollbarCell(line, column, totalWidth, style) {
160
+ if (isImageLine(line))
161
+ return line;
162
+ const graphemeRange = getGraphemeCellRange(line, column);
163
+ const start = graphemeRange?.start ?? column;
164
+ const end = graphemeRange?.end ?? column + 1;
165
+ const before = sliceByColumn(line, 0, start, true);
166
+ const target = sliceByColumn(line, start, end - start, true);
167
+ const after = sliceByColumn(line, end, Math.max(0, totalWidth - end), true);
168
+ let targetPrefix = "";
169
+ let targetIndex = 0;
170
+ while (targetIndex < target.length) {
171
+ const ansi = extractAnsiCode(target, targetIndex);
172
+ if (!ansi)
173
+ break;
174
+ targetPrefix += ansi.code;
175
+ targetIndex += ansi.length;
176
+ }
177
+ const targetText = target.slice(targetIndex) || " ".repeat(end - start);
178
+ const beforePadding = " ".repeat(Math.max(0, start - visibleWidth(before)));
179
+ return `${before}${beforePadding}${targetPrefix}${style(targetText)}${after}`;
180
+ }
181
+ export function getScrollbarGeometry(box) {
182
+ if (!box.scrollView?.isScrollbarVisible || box.rect.width <= 0 || box.rect.height <= 0)
183
+ return undefined;
184
+ const contentHeight = box.children[0]?.rect.height ?? box.scrollContentLines?.length ?? 0;
185
+ const trackHeight = box.rect.height;
186
+ const minThumbHeight = Math.min(2, trackHeight);
187
+ const thumbHeight = Math.max(minThumbHeight, Math.min(trackHeight, Math.round((trackHeight * trackHeight) / contentHeight)));
188
+ const maxScrollTop = Math.max(0, contentHeight - trackHeight);
189
+ const maxThumbTop = trackHeight - thumbHeight;
190
+ const thumbOffset = maxScrollTop === 0 ? 0 : Math.round((box.scrollView.scrollTop / maxScrollTop) * maxThumbTop);
191
+ const column = box.rect.x + box.rect.width - 1;
192
+ if (column < box.clip.x || column >= box.clip.x + box.clip.width)
193
+ return undefined;
194
+ return {
195
+ column,
196
+ trackTop: box.rect.y,
197
+ trackHeight,
198
+ thumbTop: box.rect.y + thumbOffset,
199
+ thumbHeight,
200
+ maxScrollTop,
201
+ };
202
+ }
203
+ function paintScrollbar(box, screen, totalWidth) {
204
+ const geometry = getScrollbarGeometry(box);
205
+ if (!geometry || !box.scrollView)
206
+ return;
207
+ for (let offset = 0; offset < geometry.thumbHeight; offset++) {
208
+ const row = geometry.thumbTop + offset;
209
+ if (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length)
210
+ continue;
211
+ screen[row] = styleScrollbarCell(screen[row] ?? "", geometry.column, totalWidth, box.scrollView.scrollbarStyle);
212
+ }
213
+ }
214
+ function paintBox(box, screen, totalWidth) {
215
+ if (box.lines) {
216
+ const offset = box.lineOffset ?? 0;
217
+ const firstRow = Math.max(box.rect.y, box.clip.y, 0);
218
+ const lastRow = Math.min(box.rect.y + box.rect.height, box.clip.y + box.clip.height, screen.length);
219
+ for (let row = firstRow; row < lastRow; row++) {
220
+ const sourceLine = box.lines[offset + row - box.rect.y];
221
+ if (sourceLine === undefined)
222
+ continue;
223
+ let line = sourceLine.replace(OSC133_ZONE_PREFIX, "");
224
+ const imageMetadata = getKittyImageMetadata(line);
225
+ if (imageMetadata) {
226
+ const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
227
+ const visibleRows = Math.min(imageMetadata.rows, clipBottom - row);
228
+ if (visibleRows < imageMetadata.rows)
229
+ line = cropKittyImageLine(line, 0, visibleRows);
230
+ }
231
+ if (isImageLine(line) && box.rect.x === 0 && box.rect.width >= totalWidth)
232
+ screen[row] = line;
233
+ else
234
+ screen[row] = compositeTuiLine(screen[row] ?? "", line, box.rect.x, box.rect.width, totalWidth);
235
+ }
236
+ }
237
+ for (const child of box.children)
238
+ paintBox(child, screen, totalWidth);
239
+ if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
240
+ for (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {
241
+ const imageLine = box.scrollContentLines[imageRow] ?? "";
242
+ const metadata = getKittyImageMetadata(imageLine);
243
+ if (metadata) {
244
+ const hiddenRows = box.scrollView.scrollTop - imageRow;
245
+ if (hiddenRows < metadata.rows) {
246
+ const visibleRows = Math.min(box.rect.height, metadata.rows - hiddenRows);
247
+ const cropped = cropKittyImageLine(imageLine, hiddenRows, visibleRows);
248
+ if (box.rect.x === 0 && box.rect.width >= totalWidth)
249
+ screen[box.rect.y] = cropped;
250
+ }
251
+ break;
252
+ }
253
+ if (imageLine !== "")
254
+ break;
255
+ }
256
+ }
257
+ paintScrollbar(box, screen, totalWidth);
258
+ }
259
+ export function renderLayoutFrame(root, width, height, requestRender) {
260
+ const safeWidth = Math.max(1, Math.floor(width));
261
+ const safeHeight = Math.max(1, Math.floor(height));
262
+ const context = {
263
+ viewport: { width: safeWidth, height: safeHeight },
264
+ renderCache: new Map(),
265
+ requestRender,
266
+ primaryScrollView: undefined,
267
+ };
268
+ const rootBox = layoutComponent(context, root, 0, 0, safeWidth, safeHeight, {
269
+ x: 0,
270
+ y: 0,
271
+ width: safeWidth,
272
+ height: safeHeight,
273
+ });
274
+ const lines = Array.from({ length: safeHeight }, () => "");
275
+ paintBox(rootBox, lines, safeWidth);
276
+ return {
277
+ root: rootBox,
278
+ width: safeWidth,
279
+ height: safeHeight,
280
+ lines,
281
+ ...(context.primaryScrollView === undefined ? {} : { primaryScrollView: context.primaryScrollView }),
282
+ };
283
+ }
284
+ function containsPoint(rect, x, y) {
285
+ return x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height;
286
+ }
287
+ export function getScrollViewBox(frame, scrollView) {
288
+ const visit = (box) => {
289
+ if (box.scrollView === scrollView)
290
+ return box;
291
+ for (const child of box.children) {
292
+ const match = visit(child);
293
+ if (match)
294
+ return match;
295
+ }
296
+ return undefined;
297
+ };
298
+ return visit(frame.root);
299
+ }
300
+ export function getScrollViewsAt(frame, x, y) {
301
+ const result = [];
302
+ const visit = (box, depth) => {
303
+ if (!containsPoint(box.clip, x, y))
304
+ return;
305
+ if (box.scrollView && containsPoint(box.rect, x, y))
306
+ result.push({ scrollView: box.scrollView, depth });
307
+ for (const child of box.children)
308
+ visit(child, depth + 1);
309
+ };
310
+ visit(frame.root, 0);
311
+ result.sort((a, b) => b.depth - a.depth);
312
+ return result.map((entry) => entry.scrollView);
313
+ }
314
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAkB,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEhG,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AA8ClE,SAAS,SAAS,CAAC,CAAa,EAAE,CAAa,EAAc;IAC5D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAA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AC;IACzC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAAA,CAC/C","sourcesContent":["import type { ScrollView } from \"./components/scroll-view.ts\";\nimport { allocateStackSizes, visibleStackEntries } from \"./components/stack.ts\";\nimport { getLayoutNode } from \"./layout-node.ts\";\nimport { cropKittyImageLine, getKittyImageMetadata, isImageLine } from \"./terminal-image.ts\";\nimport { type Component, CURSOR_MARKER, compositeTuiLine } from \"./tui.ts\";\nimport { extractAnsiCode, getGraphemeCellRange, sliceByColumn, visibleWidth } from \"./utils.ts\";\n\nconst OSC133_ZONE_PREFIX = /^(?:\\x1b\\]133;[ABC](?:\\x07|\\x1b\\\\))+/;\n\nexport interface LayoutRect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\nexport interface LayoutBox {\n\tcomponent: Component;\n\trect: LayoutRect;\n\tclip: LayoutRect;\n\tchildren: LayoutBox[];\n\tparent?: LayoutBox;\n\tlines?: readonly string[];\n\tlineOffset?: number;\n\tscrollView?: ScrollView;\n\tscrollContentLines?: readonly string[];\n\tlayer: number;\n}\n\nexport interface LayoutFrame {\n\troot: LayoutBox;\n\twidth: number;\n\theight: number;\n\tlines: string[];\n\tprimaryScrollView?: ScrollView;\n}\n\nexport interface ScrollbarGeometry {\n\tcolumn: number;\n\ttrackTop: number;\n\ttrackHeight: number;\n\tthumbTop: number;\n\tthumbHeight: number;\n\tmaxScrollTop: number;\n}\n\ninterface LayoutContext {\n\tviewport: { width: number; height: number };\n\trenderCache: Map<Component, Map<number, string[]>>;\n\trequestRender: () => void;\n\tprimaryScrollView: ScrollView | undefined;\n}\n\nfunction intersect(a: LayoutRect, b: LayoutRect): LayoutRect {\n\tconst x = Math.max(a.x, b.x);\n\tconst y = Math.max(a.y, b.y);\n\tconst right = Math.min(a.x + a.width, b.x + b.width);\n\tconst bottom = Math.min(a.y + a.height, b.y + b.height);\n\treturn { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };\n}\n\nfunction renderCached(context: LayoutContext, component: Component, width: number): string[] {\n\tconst safeWidth = Math.max(1, Math.floor(width));\n\tlet widths = context.renderCache.get(component);\n\tif (!widths) {\n\t\twidths = new Map<number, string[]>();\n\t\tcontext.renderCache.set(component, widths);\n\t}\n\tlet lines = widths.get(safeWidth);\n\tif (!lines) {\n\t\tlines = component.render(safeWidth);\n\t\twidths.set(safeWidth, lines);\n\t}\n\treturn lines;\n}\n\nfunction measureHeight(context: LayoutContext, component: Component, width: number): number {\n\treturn renderCached(context, component, width).length;\n}\n\nfunction measureWidth(context: LayoutContext, component: Component, width: number): number {\n\treturn renderCached(context, component, width).reduce((max, line) => Math.max(max, visibleWidth(line)), 0);\n}\n\nfunction withParent(box: LayoutBox, parent: LayoutBox): LayoutBox {\n\tbox.parent = parent;\n\treturn box;\n}\n\nfunction translateBox(box: LayoutBox, deltaY: number): void {\n\tbox.rect.y += deltaY;\n\tfor (const child of box.children) translateBox(child, deltaY);\n}\n\nfunction updateClips(box: LayoutBox, parentClip: LayoutRect): void {\n\tbox.clip = intersect(parentClip, box.rect);\n\tfor (const child of box.children) updateClips(child, box.clip);\n}\n\nfunction layoutComponent(\n\tcontext: LayoutContext,\n\tcomponent: Component,\n\tx: number,\n\ty: number,\n\twidth: number,\n\theight: number | undefined,\n\tclip: LayoutRect,\n): LayoutBox {\n\tconst safeWidth = Math.max(1, Math.floor(width));\n\tconst node = getLayoutNode(component);\n\tif (!node) {\n\t\tconst lines = renderCached(context, component, safeWidth);\n\t\tconst allocatedHeight = height === undefined ? lines.length : Math.max(0, Math.floor(height));\n\t\tlet lineOffset = 0;\n\t\tif (lines.length > allocatedHeight && allocatedHeight > 0) {\n\t\t\tconst cursorLine = lines.findIndex((line) => line.includes(CURSOR_MARKER));\n\t\t\tif (cursorLine >= allocatedHeight) lineOffset = cursorLine - allocatedHeight + 1;\n\t\t}\n\t\treturn {\n\t\t\tcomponent,\n\t\t\trect: { x, y, width: safeWidth, height: allocatedHeight },\n\t\t\tclip: intersect(clip, { x, y, width: safeWidth, height: allocatedHeight }),\n\t\t\tchildren: [],\n\t\t\tlines,\n\t\t\tlineOffset,\n\t\t\tlayer: 0,\n\t\t};\n\t}\n\n\tif (node.type === \"scroll\") {\n\t\tconst previousScrollTop = node.state.scrollTop;\n\t\tconst contentWidth = node.state.getContentWidth(safeWidth);\n\t\tconst childBox = layoutComponent(\n\t\t\tcontext,\n\t\t\tnode.component,\n\t\t\tx,\n\t\t\ty - previousScrollTop,\n\t\t\tcontentWidth,\n\t\t\tundefined,\n\t\t\tclip,\n\t\t);\n\t\tconst contentHeight = childBox.rect.height;\n\t\tconst viewportHeight = height === undefined ? contentHeight : Math.max(0, Math.floor(height));\n\t\tnode.state.updateLayout(contentHeight, viewportHeight, context.requestRender);\n\t\ttranslateBox(childBox, previousScrollTop - node.state.scrollTop);\n\t\tconst scrollView = node.state as ScrollView;\n\t\tif (node.state.primary || !context.primaryScrollView) context.primaryScrollView = scrollView;\n\t\tconst rect = { x, y, width: safeWidth, height: viewportHeight };\n\t\tconst childClip = intersect(clip, rect);\n\t\tconst box: LayoutBox = {\n\t\t\tcomponent,\n\t\t\trect,\n\t\t\tclip: childClip,\n\t\t\tchildren: [childBox],\n\t\t\tscrollView,\n\t\t\tscrollContentLines: renderCached(context, node.component, contentWidth),\n\t\t\tlayer: 0,\n\t\t};\n\t\tchildBox.parent = box;\n\t\tupdateClips(childBox, childClip);\n\t\treturn box;\n\t}\n\n\tconst entries = visibleStackEntries(node.entries, context.viewport);\n\tconst gapTotal = Math.max(0, entries.length - 1) * node.gap;\n\tif (node.type === \"vstack\") {\n\t\tconst intrinsicHeights = entries.map((entry) =>\n\t\t\ttypeof entry.basis === \"number\" ? entry.basis : measureHeight(context, entry.component, safeWidth),\n\t\t);\n\t\tconst sizes = allocateStackSizes(entries, intrinsicHeights, height, node.gap);\n\t\tconst naturalHeight = sizes.reduce((sum, size) => sum + size, 0) + gapTotal;\n\t\tconst allocatedHeight = height === undefined ? naturalHeight : Math.max(0, Math.floor(height));\n\t\tconst rect = { x, y, width: safeWidth, height: allocatedHeight };\n\t\tconst box: LayoutBox = {\n\t\t\tcomponent,\n\t\t\trect,\n\t\t\tclip: intersect(clip, rect),\n\t\t\tchildren: [],\n\t\t\tlayer: 0,\n\t\t};\n\t\tlet childY = y;\n\t\tfor (let index = 0; index < entries.length; index++) {\n\t\t\tbox.children.push(\n\t\t\t\twithParent(\n\t\t\t\t\tlayoutComponent(context, entries[index]!.component, x, childY, safeWidth, sizes[index]!, box.clip),\n\t\t\t\t\tbox,\n\t\t\t\t),\n\t\t\t);\n\t\t\tchildY += sizes[index]! + node.gap;\n\t\t}\n\t\treturn box;\n\t}\n\n\tconst intrinsicWidths = entries.map((entry) =>\n\t\ttypeof entry.basis === \"number\" ? entry.basis : measureWidth(context, entry.component, safeWidth),\n\t);\n\tconst widths = allocateStackSizes(entries, intrinsicWidths, safeWidth, node.gap);\n\tconst intrinsicHeights = entries.map((entry, index) =>\n\t\tmeasureHeight(context, entry.component, Math.max(1, widths[index]!)),\n\t);\n\tconst allocatedHeight =\n\t\theight === undefined\n\t\t\t? intrinsicHeights.reduce((max, childHeight) => Math.max(max, childHeight), 0)\n\t\t\t: Math.max(0, height);\n\tconst rect = { x, y, width: safeWidth, height: allocatedHeight };\n\tconst box: LayoutBox = {\n\t\tcomponent,\n\t\trect,\n\t\tclip: intersect(clip, rect),\n\t\tchildren: [],\n\t\tlayer: 0,\n\t};\n\tlet childX = x;\n\tfor (let index = 0; index < entries.length; index++) {\n\t\tconst naturalChildHeight = intrinsicHeights[index]!;\n\t\tconst childHeight = node.align === \"stretch\" ? allocatedHeight : Math.min(allocatedHeight, naturalChildHeight);\n\t\tlet childY = y;\n\t\tif (node.align === \"center\") childY += Math.floor((allocatedHeight - childHeight) / 2);\n\t\telse if (node.align === \"end\") childY += allocatedHeight - childHeight;\n\t\tconst childWidth = widths[index]!;\n\t\tif (childWidth === 0) {\n\t\t\tbox.children.push({\n\t\t\t\tcomponent: entries[index]!.component,\n\t\t\t\trect: { x: childX, y: childY, width: 0, height: childHeight },\n\t\t\t\tclip: { x: childX, y: childY, width: 0, height: 0 },\n\t\t\t\tchildren: [],\n\t\t\t\tparent: box,\n\t\t\t\tlayer: 0,\n\t\t\t});\n\t\t} else {\n\t\t\tbox.children.push(\n\t\t\t\twithParent(\n\t\t\t\t\tlayoutComponent(context, entries[index]!.component, childX, childY, childWidth, childHeight, box.clip),\n\t\t\t\t\tbox,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tchildX += childWidth + node.gap;\n\t}\n\treturn box;\n}\n\nfunction styleScrollbarCell(line: string, column: number, totalWidth: number, style: (text: string) => string): string {\n\tif (isImageLine(line)) return line;\n\n\tconst graphemeRange = getGraphemeCellRange(line, column);\n\tconst start = graphemeRange?.start ?? column;\n\tconst end = graphemeRange?.end ?? column + 1;\n\tconst before = sliceByColumn(line, 0, start, true);\n\tconst target = sliceByColumn(line, start, end - start, true);\n\tconst after = sliceByColumn(line, end, Math.max(0, totalWidth - end), true);\n\n\tlet targetPrefix = \"\";\n\tlet targetIndex = 0;\n\twhile (targetIndex < target.length) {\n\t\tconst ansi = extractAnsiCode(target, targetIndex);\n\t\tif (!ansi) break;\n\t\ttargetPrefix += ansi.code;\n\t\ttargetIndex += ansi.length;\n\t}\n\tconst targetText = target.slice(targetIndex) || \" \".repeat(end - start);\n\tconst beforePadding = \" \".repeat(Math.max(0, start - visibleWidth(before)));\n\treturn `${before}${beforePadding}${targetPrefix}${style(targetText)}${after}`;\n}\n\nexport function getScrollbarGeometry(box: LayoutBox): ScrollbarGeometry | undefined {\n\tif (!box.scrollView?.isScrollbarVisible || box.rect.width <= 0 || box.rect.height <= 0) return undefined;\n\n\tconst contentHeight = box.children[0]?.rect.height ?? box.scrollContentLines?.length ?? 0;\n\tconst trackHeight = box.rect.height;\n\n\tconst minThumbHeight = Math.min(2, trackHeight);\n\tconst thumbHeight = Math.max(\n\t\tminThumbHeight,\n\t\tMath.min(trackHeight, Math.round((trackHeight * trackHeight) / contentHeight)),\n\t);\n\tconst maxScrollTop = Math.max(0, contentHeight - trackHeight);\n\tconst maxThumbTop = trackHeight - thumbHeight;\n\tconst thumbOffset = maxScrollTop === 0 ? 0 : Math.round((box.scrollView.scrollTop / maxScrollTop) * maxThumbTop);\n\tconst column = box.rect.x + box.rect.width - 1;\n\tif (column < box.clip.x || column >= box.clip.x + box.clip.width) return undefined;\n\n\treturn {\n\t\tcolumn,\n\t\ttrackTop: box.rect.y,\n\t\ttrackHeight,\n\t\tthumbTop: box.rect.y + thumbOffset,\n\t\tthumbHeight,\n\t\tmaxScrollTop,\n\t};\n}\n\nfunction paintScrollbar(box: LayoutBox, screen: string[], totalWidth: number): void {\n\tconst geometry = getScrollbarGeometry(box);\n\tif (!geometry || !box.scrollView) return;\n\n\tfor (let offset = 0; offset < geometry.thumbHeight; offset++) {\n\t\tconst row = geometry.thumbTop + offset;\n\t\tif (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length) continue;\n\t\tscreen[row] = styleScrollbarCell(screen[row] ?? \"\", geometry.column, totalWidth, box.scrollView.scrollbarStyle);\n\t}\n}\n\nfunction paintBox(box: LayoutBox, screen: string[], totalWidth: number): void {\n\tif (box.lines) {\n\t\tconst offset = box.lineOffset ?? 0;\n\t\tconst firstRow = Math.max(box.rect.y, box.clip.y, 0);\n\t\tconst lastRow = Math.min(box.rect.y + box.rect.height, box.clip.y + box.clip.height, screen.length);\n\t\tfor (let row = firstRow; row < lastRow; row++) {\n\t\t\tconst sourceLine = box.lines[offset + row - box.rect.y];\n\t\t\tif (sourceLine === undefined) continue;\n\t\t\tlet line = sourceLine.replace(OSC133_ZONE_PREFIX, \"\");\n\t\t\tconst imageMetadata = getKittyImageMetadata(line);\n\t\t\tif (imageMetadata) {\n\t\t\t\tconst clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);\n\t\t\t\tconst visibleRows = Math.min(imageMetadata.rows, clipBottom - row);\n\t\t\t\tif (visibleRows < imageMetadata.rows) line = cropKittyImageLine(line, 0, visibleRows);\n\t\t\t}\n\t\t\tif (isImageLine(line) && box.rect.x === 0 && box.rect.width >= totalWidth) screen[row] = line;\n\t\t\telse screen[row] = compositeTuiLine(screen[row] ?? \"\", line, box.rect.x, box.rect.width, totalWidth);\n\t\t}\n\t}\n\tfor (const child of box.children) paintBox(child, screen, totalWidth);\n\n\tif (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {\n\t\tfor (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {\n\t\t\tconst imageLine = box.scrollContentLines[imageRow] ?? \"\";\n\t\t\tconst metadata = getKittyImageMetadata(imageLine);\n\t\t\tif (metadata) {\n\t\t\t\tconst hiddenRows = box.scrollView.scrollTop - imageRow;\n\t\t\t\tif (hiddenRows < metadata.rows) {\n\t\t\t\t\tconst visibleRows = Math.min(box.rect.height, metadata.rows - hiddenRows);\n\t\t\t\t\tconst cropped = cropKittyImageLine(imageLine, hiddenRows, visibleRows);\n\t\t\t\t\tif (box.rect.x === 0 && box.rect.width >= totalWidth) screen[box.rect.y] = cropped;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (imageLine !== \"\") break;\n\t\t}\n\t}\n\n\tpaintScrollbar(box, screen, totalWidth);\n}\n\nexport function renderLayoutFrame(\n\troot: Component,\n\twidth: number,\n\theight: number,\n\trequestRender: () => void,\n): LayoutFrame {\n\tconst safeWidth = Math.max(1, Math.floor(width));\n\tconst safeHeight = Math.max(1, Math.floor(height));\n\tconst context: LayoutContext = {\n\t\tviewport: { width: safeWidth, height: safeHeight },\n\t\trenderCache: new Map(),\n\t\trequestRender,\n\t\tprimaryScrollView: undefined,\n\t};\n\tconst rootBox = layoutComponent(context, root, 0, 0, safeWidth, safeHeight, {\n\t\tx: 0,\n\t\ty: 0,\n\t\twidth: safeWidth,\n\t\theight: safeHeight,\n\t});\n\tconst lines = Array.from({ length: safeHeight }, () => \"\");\n\tpaintBox(rootBox, lines, safeWidth);\n\treturn {\n\t\troot: rootBox,\n\t\twidth: safeWidth,\n\t\theight: safeHeight,\n\t\tlines,\n\t\t...(context.primaryScrollView === undefined ? {} : { primaryScrollView: context.primaryScrollView }),\n\t};\n}\n\nfunction containsPoint(rect: LayoutRect, x: number, y: number): boolean {\n\treturn x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height;\n}\n\nexport function getScrollViewBox(frame: LayoutFrame, scrollView: ScrollView): LayoutBox | undefined {\n\tconst visit = (box: LayoutBox): LayoutBox | undefined => {\n\t\tif (box.scrollView === scrollView) return box;\n\t\tfor (const child of box.children) {\n\t\t\tconst match = visit(child);\n\t\t\tif (match) return match;\n\t\t}\n\t\treturn undefined;\n\t};\n\treturn visit(frame.root);\n}\n\nexport function getScrollViewsAt(frame: LayoutFrame, x: number, y: number): ScrollView[] {\n\tconst result: Array<{ scrollView: ScrollView; depth: number }> = [];\n\tconst visit = (box: LayoutBox, depth: number): void => {\n\t\tif (!containsPoint(box.clip, x, y)) return;\n\t\tif (box.scrollView && containsPoint(box.rect, x, y)) result.push({ scrollView: box.scrollView, depth });\n\t\tfor (const child of box.children) visit(child, depth + 1);\n\t};\n\tvisit(frame.root, 0);\n\tresult.sort((a, b) => b.depth - a.depth);\n\treturn result.map((entry) => entry.scrollView);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"native-modifiers.d.ts","sourceRoot":"","sources":["../src/native-modifiers.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AA4CrE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAQjE","sourcesContent":["import { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nexport type ModifierKey = \"shift\" | \"command\" | \"control\" | \"option\";\n\ntype NativeModifiersHelper = {\n\tisModifierPressed: (name: ModifierKey) => boolean;\n};\n\nlet nativeModifiersHelper: NativeModifiersHelper | null | undefined;\n\nfunction isNativeModifiersHelper(value: unknown): value is NativeModifiersHelper {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = (value as { isModifierPressed?: unknown }).isModifierPressed;\n\treturn typeof candidate === \"function\";\n}\n\nfunction loadNativeModifiersHelper(): NativeModifiersHelper | undefined {\n\tif (nativeModifiersHelper !== undefined) return nativeModifiersHelper ?? undefined;\n\tnativeModifiersHelper = null;\n\tif (process.platform !== \"darwin\") return undefined;\n\tconst arch = process.arch;\n\tif (arch !== \"x64\" && arch !== \"arm64\") return undefined;\n\n\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\tconst nativePath = path.join(\"native\", \"darwin\", \"prebuilds\", `darwin-${arch}`, \"darwin-modifiers.node\");\n\tconst candidates = [\n\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\tpath.join(moduleDir, nativePath),\n\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t];\n\n\tfor (const modulePath of candidates) {\n\t\ttry {\n\t\t\tconst helper = cjsRequire(modulePath) as unknown;\n\t\t\tif (isNativeModifiersHelper(helper)) {\n\t\t\t\tnativeModifiersHelper = helper;\n\t\t\t\treturn helper;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Try the next possible packaging location.\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nexport function isNativeModifierPressed(key: ModifierKey): boolean {\n\tconst helper = loadNativeModifiersHelper();\n\tif (!helper) return false;\n\ttry {\n\t\treturn helper.isModifierPressed(key) === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"file":"native-modifiers.d.ts","sourceRoot":"","sources":["../src/native-modifiers.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAmDrE,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAQjE","sourcesContent":["import { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nexport type ModifierKey = \"shift\" | \"command\" | \"control\" | \"option\";\n\ntype NativeModifiersHelper = {\n\tisModifierPressed: (name: ModifierKey) => boolean;\n};\n\nlet nativeModifiersHelper: NativeModifiersHelper | null | undefined;\n\nfunction isNativeModifiersHelper(value: unknown): value is NativeModifiersHelper {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = (value as { isModifierPressed?: unknown }).isModifierPressed;\n\treturn typeof candidate === \"function\";\n}\n\nfunction loadNativeModifiersHelper(): NativeModifiersHelper | undefined {\n\tif (nativeModifiersHelper !== undefined) return nativeModifiersHelper ?? undefined;\n\tnativeModifiersHelper = null;\n\tconst arch = process.arch;\n\tif (arch !== \"x64\" && arch !== \"arm64\") return undefined;\n\n\tlet nativePath: string;\n\tif (process.platform === \"darwin\") {\n\t\tnativePath = path.join(\"native\", \"darwin\", \"prebuilds\", `darwin-${arch}`, \"darwin-modifiers.node\");\n\t} else if (process.platform === \"win32\") {\n\t\tnativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t} else {\n\t\treturn undefined;\n\t}\n\n\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\tconst candidates = [\n\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\tpath.join(moduleDir, nativePath),\n\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t];\n\n\tfor (const modulePath of candidates) {\n\t\ttry {\n\t\t\tconst helper = cjsRequire(modulePath) as unknown;\n\t\t\tif (isNativeModifiersHelper(helper)) {\n\t\t\t\tnativeModifiersHelper = helper;\n\t\t\t\treturn helper;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Try the next possible packaging location.\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nexport function isNativeModifierPressed(key: ModifierKey): boolean {\n\tconst helper = loadNativeModifiersHelper();\n\tif (!helper) return false;\n\ttry {\n\t\treturn helper.isModifierPressed(key) === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
@@ -13,13 +13,20 @@ function loadNativeModifiersHelper() {
13
13
  if (nativeModifiersHelper !== undefined)
14
14
  return nativeModifiersHelper ?? undefined;
15
15
  nativeModifiersHelper = null;
16
- if (process.platform !== "darwin")
17
- return undefined;
18
16
  const arch = process.arch;
19
17
  if (arch !== "x64" && arch !== "arm64")
20
18
  return undefined;
19
+ let nativePath;
20
+ if (process.platform === "darwin") {
21
+ nativePath = path.join("native", "darwin", "prebuilds", `darwin-${arch}`, "darwin-modifiers.node");
22
+ }
23
+ else if (process.platform === "win32") {
24
+ nativePath = path.join("native", "win32", "prebuilds", `win32-${arch}`, "win32-console-mode.node");
25
+ }
26
+ else {
27
+ return undefined;
28
+ }
21
29
  const moduleDir = path.dirname(fileURLToPath(import.meta.url));
22
- const nativePath = path.join("native", "darwin", "prebuilds", `darwin-${arch}`, "darwin-modifiers.node");
23
30
  const candidates = [
24
31
  path.join(moduleDir, "..", nativePath),
25
32
  path.join(moduleDir, nativePath),
@@ -1 +1 @@
1
- {"version":3,"file":"native-modifiers.js","sourceRoot":"","sources":["../src/native-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAQlD,IAAI,qBAA+D,CAAC;AAEpE,SAAS,uBAAuB,CAAC,KAAc,EAAkC;IAChF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,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,CAAC;IAED,OAAO,SAAS,CAAC;AAAA,CACjB;AAED,MAAM,UAAU,uBAAuB,CAAC,GAAgB,EAAW;IAClE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,IAAI,CAAC;QACJ,OAAO,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AAAA,CACD","sourcesContent":["import { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nexport type ModifierKey = \"shift\" | \"command\" | \"control\" | \"option\";\n\ntype NativeModifiersHelper = {\n\tisModifierPressed: (name: ModifierKey) => boolean;\n};\n\nlet nativeModifiersHelper: NativeModifiersHelper | null | undefined;\n\nfunction isNativeModifiersHelper(value: unknown): value is NativeModifiersHelper {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = (value as { isModifierPressed?: unknown }).isModifierPressed;\n\treturn typeof candidate === \"function\";\n}\n\nfunction loadNativeModifiersHelper(): NativeModifiersHelper | undefined {\n\tif (nativeModifiersHelper !== undefined) return nativeModifiersHelper ?? undefined;\n\tnativeModifiersHelper = null;\n\tif (process.platform !== \"darwin\") return undefined;\n\tconst arch = process.arch;\n\tif (arch !== \"x64\" && arch !== \"arm64\") return undefined;\n\n\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\tconst nativePath = path.join(\"native\", \"darwin\", \"prebuilds\", `darwin-${arch}`, \"darwin-modifiers.node\");\n\tconst candidates = [\n\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\tpath.join(moduleDir, nativePath),\n\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t];\n\n\tfor (const modulePath of candidates) {\n\t\ttry {\n\t\t\tconst helper = cjsRequire(modulePath) as unknown;\n\t\t\tif (isNativeModifiersHelper(helper)) {\n\t\t\t\tnativeModifiersHelper = helper;\n\t\t\t\treturn helper;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Try the next possible packaging location.\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nexport function isNativeModifierPressed(key: ModifierKey): boolean {\n\tconst helper = loadNativeModifiersHelper();\n\tif (!helper) return false;\n\ttry {\n\t\treturn helper.isModifierPressed(key) === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"file":"native-modifiers.js","sourceRoot":"","sources":["../src/native-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAQlD,IAAI,qBAA+D,CAAC;AAEpE,SAAS,uBAAuB,CAAC,KAAc,EAAkC;IAChF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAI,KAAyC,CAAC,iBAAiB,CAAC;IAC/E,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC;AAAA,CACvC;AAED,SAAS,yBAAyB,GAAsC;IACvE,IAAI,qBAAqB,KAAK,SAAS;QAAE,OAAO,qBAAqB,IAAI,SAAS,CAAC;IACnF,qBAAqB,GAAG,IAAI,CAAC;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IAEzD,IAAI,UAAkB,CAAC;IACvB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACnC,UAAU,GAAG,IAAI,CAAC,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B,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AAAA,CACD","sourcesContent":["import { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst cjsRequire = createRequire(import.meta.url);\n\nexport type ModifierKey = \"shift\" | \"command\" | \"control\" | \"option\";\n\ntype NativeModifiersHelper = {\n\tisModifierPressed: (name: ModifierKey) => boolean;\n};\n\nlet nativeModifiersHelper: NativeModifiersHelper | null | undefined;\n\nfunction isNativeModifiersHelper(value: unknown): value is NativeModifiersHelper {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = (value as { isModifierPressed?: unknown }).isModifierPressed;\n\treturn typeof candidate === \"function\";\n}\n\nfunction loadNativeModifiersHelper(): NativeModifiersHelper | undefined {\n\tif (nativeModifiersHelper !== undefined) return nativeModifiersHelper ?? undefined;\n\tnativeModifiersHelper = null;\n\tconst arch = process.arch;\n\tif (arch !== \"x64\" && arch !== \"arm64\") return undefined;\n\n\tlet nativePath: string;\n\tif (process.platform === \"darwin\") {\n\t\tnativePath = path.join(\"native\", \"darwin\", \"prebuilds\", `darwin-${arch}`, \"darwin-modifiers.node\");\n\t} else if (process.platform === \"win32\") {\n\t\tnativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n\t} else {\n\t\treturn undefined;\n\t}\n\n\tconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\tconst candidates = [\n\t\tpath.join(moduleDir, \"..\", nativePath),\n\t\tpath.join(moduleDir, nativePath),\n\t\tpath.join(path.dirname(process.execPath), nativePath),\n\t];\n\n\tfor (const modulePath of candidates) {\n\t\ttry {\n\t\t\tconst helper = cjsRequire(modulePath) as unknown;\n\t\t\tif (isNativeModifiersHelper(helper)) {\n\t\t\t\tnativeModifiersHelper = helper;\n\t\t\t\treturn helper;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Try the next possible packaging location.\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nexport function isNativeModifierPressed(key: ModifierKey): boolean {\n\tconst helper = loadNativeModifiersHelper();\n\tif (!helper) return false;\n\ttry {\n\t\treturn helper.isModifierPressed(key) === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"terminal-colors.d.ts","sourceRoot":"","sources":["../src/terminal-colors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,CAAC;AAwBnD,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CA8B5E;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAM5F","sourcesContent":["export interface RgbColor {\n\tr: number;\n\tg: number;\n\tb: number;\n}\n\nexport type TerminalColorScheme = \"dark\" | \"light\";\n\nfunction hexToRgb(hex: string): RgbColor {\n\tconst normalized = hex.startsWith(\"#\") ? hex.slice(1) : hex;\n\tconst r = parseInt(normalized.slice(0, 2), 16);\n\tconst g = parseInt(normalized.slice(2, 4), 16);\n\tconst b = parseInt(normalized.slice(4, 6), 16);\n\treturn { r, g, b };\n}\n\nfunction parseOscHexChannel(channel: string): number | undefined {\n\tif (!/^[0-9a-f]+$/i.test(channel)) {\n\t\treturn undefined;\n\t}\n\tconst max = 16 ** channel.length - 1;\n\tif (max <= 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.round((parseInt(channel, 16) / max) * 255);\n}\n\nconst OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN = /^\\x1b\\]11;([^\\x07\\x1b]*)(?:\\x07|\\x1b\\\\)$/i;\nconst COLOR_SCHEME_REPORT_PATTERN = /^\\x1b\\[\\?997;(1|2)n$/;\n\nexport function isOsc11BackgroundColorResponse(data: string): boolean {\n\treturn OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN.test(data);\n}\n\nexport function parseOsc11BackgroundColor(data: string): RgbColor | undefined {\n\tconst match = data.match(OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\tconst value = match[1].trim();\n\tif (value.startsWith(\"#\")) {\n\t\tconst hex = value.slice(1);\n\t\tif (/^[0-9a-f]{6}$/i.test(hex)) {\n\t\t\treturn hexToRgb(value);\n\t\t}\n\t\tif (/^[0-9a-f]{12}$/i.test(hex)) {\n\t\t\tconst r = parseOscHexChannel(hex.slice(0, 4));\n\t\t\tconst g = parseOscHexChannel(hex.slice(4, 8));\n\t\t\tconst b = parseOscHexChannel(hex.slice(8, 12));\n\t\t\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst rgbValue = value.replace(/^rgba?:/i, \"\");\n\tconst [red, green, blue] = rgbValue.split(\"/\");\n\tif (red === undefined || green === undefined || blue === undefined) {\n\t\treturn undefined;\n\t}\n\tconst r = parseOscHexChannel(red);\n\tconst g = parseOscHexChannel(green);\n\tconst b = parseOscHexChannel(blue);\n\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n}\n\nexport function parseTerminalColorSchemeReport(data: string): TerminalColorScheme | undefined {\n\tconst match = data.match(COLOR_SCHEME_REPORT_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\treturn match[1] === \"2\" ? \"light\" : \"dark\";\n}\n"]}
1
+ {"version":3,"file":"terminal-colors.d.ts","sourceRoot":"","sources":["../src/terminal-colors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,CAAC;AAwBnD,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CA8B5E;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAM5F","sourcesContent":["export interface RgbColor {\n\tr: number;\n\tg: number;\n\tb: number;\n}\n\nexport type TerminalColorScheme = \"dark\" | \"light\";\n\nfunction hexToRgb(hex: string): RgbColor {\n\tconst normalized = hex.startsWith(\"#\") ? hex.slice(1) : hex;\n\tconst r = parseInt(normalized.slice(0, 2), 16);\n\tconst g = parseInt(normalized.slice(2, 4), 16);\n\tconst b = parseInt(normalized.slice(4, 6), 16);\n\treturn { r, g, b };\n}\n\nfunction parseOscHexChannel(channel: string): number | undefined {\n\tif (!/^[0-9a-f]+$/i.test(channel)) {\n\t\treturn undefined;\n\t}\n\tconst max = 16 ** channel.length - 1;\n\tif (max <= 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.round((parseInt(channel, 16) / max) * 255);\n}\n\nconst OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN = /^\\x1b\\]11;([^\\x07\\x1b]*)(?:\\x07|\\x1b\\\\)$/i;\nconst COLOR_SCHEME_REPORT_PATTERN = /^(?:\\x1b\\[\\?997;(1|2)n)+$/;\n\nexport function isOsc11BackgroundColorResponse(data: string): boolean {\n\treturn OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN.test(data);\n}\n\nexport function parseOsc11BackgroundColor(data: string): RgbColor | undefined {\n\tconst match = data.match(OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\tconst value = match[1].trim();\n\tif (value.startsWith(\"#\")) {\n\t\tconst hex = value.slice(1);\n\t\tif (/^[0-9a-f]{6}$/i.test(hex)) {\n\t\t\treturn hexToRgb(value);\n\t\t}\n\t\tif (/^[0-9a-f]{12}$/i.test(hex)) {\n\t\t\tconst r = parseOscHexChannel(hex.slice(0, 4));\n\t\t\tconst g = parseOscHexChannel(hex.slice(4, 8));\n\t\t\tconst b = parseOscHexChannel(hex.slice(8, 12));\n\t\t\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst rgbValue = value.replace(/^rgba?:/i, \"\");\n\tconst [red, green, blue] = rgbValue.split(\"/\");\n\tif (red === undefined || green === undefined || blue === undefined) {\n\t\treturn undefined;\n\t}\n\tconst r = parseOscHexChannel(red);\n\tconst g = parseOscHexChannel(green);\n\tconst b = parseOscHexChannel(blue);\n\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n}\n\nexport function parseTerminalColorSchemeReport(data: string): TerminalColorScheme | undefined {\n\tconst match = data.match(COLOR_SCHEME_REPORT_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\treturn match[1] === \"2\" ? \"light\" : \"dark\";\n}\n"]}
@@ -16,7 +16,7 @@ function parseOscHexChannel(channel) {
16
16
  return Math.round((parseInt(channel, 16) / max) * 255);
17
17
  }
18
18
  const OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN = /^\x1b\]11;([^\x07\x1b]*)(?:\x07|\x1b\\)$/i;
19
- const COLOR_SCHEME_REPORT_PATTERN = /^\x1b\[\?997;(1|2)n$/;
19
+ const COLOR_SCHEME_REPORT_PATTERN = /^(?:\x1b\[\?997;(1|2)n)+$/;
20
20
  export function isOsc11BackgroundColorResponse(data) {
21
21
  return OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN.test(data);
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"terminal-colors.js","sourceRoot":"","sources":["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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACpE,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CACvF;AAED,MAAM,UAAU,8BAA8B,CAAC,IAAY,EAAmC;IAC7F,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACtD,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAAA,CAC3C","sourcesContent":["export interface RgbColor {\n\tr: number;\n\tg: number;\n\tb: number;\n}\n\nexport type TerminalColorScheme = \"dark\" | \"light\";\n\nfunction hexToRgb(hex: string): RgbColor {\n\tconst normalized = hex.startsWith(\"#\") ? hex.slice(1) : hex;\n\tconst r = parseInt(normalized.slice(0, 2), 16);\n\tconst g = parseInt(normalized.slice(2, 4), 16);\n\tconst b = parseInt(normalized.slice(4, 6), 16);\n\treturn { r, g, b };\n}\n\nfunction parseOscHexChannel(channel: string): number | undefined {\n\tif (!/^[0-9a-f]+$/i.test(channel)) {\n\t\treturn undefined;\n\t}\n\tconst max = 16 ** channel.length - 1;\n\tif (max <= 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.round((parseInt(channel, 16) / max) * 255);\n}\n\nconst OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN = /^\\x1b\\]11;([^\\x07\\x1b]*)(?:\\x07|\\x1b\\\\)$/i;\nconst COLOR_SCHEME_REPORT_PATTERN = /^\\x1b\\[\\?997;(1|2)n$/;\n\nexport function isOsc11BackgroundColorResponse(data: string): boolean {\n\treturn OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN.test(data);\n}\n\nexport function parseOsc11BackgroundColor(data: string): RgbColor | undefined {\n\tconst match = data.match(OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\tconst value = match[1].trim();\n\tif (value.startsWith(\"#\")) {\n\t\tconst hex = value.slice(1);\n\t\tif (/^[0-9a-f]{6}$/i.test(hex)) {\n\t\t\treturn hexToRgb(value);\n\t\t}\n\t\tif (/^[0-9a-f]{12}$/i.test(hex)) {\n\t\t\tconst r = parseOscHexChannel(hex.slice(0, 4));\n\t\t\tconst g = parseOscHexChannel(hex.slice(4, 8));\n\t\t\tconst b = parseOscHexChannel(hex.slice(8, 12));\n\t\t\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst rgbValue = value.replace(/^rgba?:/i, \"\");\n\tconst [red, green, blue] = rgbValue.split(\"/\");\n\tif (red === undefined || green === undefined || blue === undefined) {\n\t\treturn undefined;\n\t}\n\tconst r = parseOscHexChannel(red);\n\tconst g = parseOscHexChannel(green);\n\tconst b = parseOscHexChannel(blue);\n\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n}\n\nexport function parseTerminalColorSchemeReport(data: string): TerminalColorScheme | undefined {\n\tconst match = data.match(COLOR_SCHEME_REPORT_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\treturn match[1] === \"2\" ? \"light\" : \"dark\";\n}\n"]}
1
+ {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KAAK,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACpE,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CACvF;AAED,MAAM,UAAU,8BAA8B,CAAC,IAAY,EAAmC;IAC7F,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACtD,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAAA,CAC3C","sourcesContent":["export interface RgbColor {\n\tr: number;\n\tg: number;\n\tb: number;\n}\n\nexport type TerminalColorScheme = \"dark\" | \"light\";\n\nfunction hexToRgb(hex: string): RgbColor {\n\tconst normalized = hex.startsWith(\"#\") ? hex.slice(1) : hex;\n\tconst r = parseInt(normalized.slice(0, 2), 16);\n\tconst g = parseInt(normalized.slice(2, 4), 16);\n\tconst b = parseInt(normalized.slice(4, 6), 16);\n\treturn { r, g, b };\n}\n\nfunction parseOscHexChannel(channel: string): number | undefined {\n\tif (!/^[0-9a-f]+$/i.test(channel)) {\n\t\treturn undefined;\n\t}\n\tconst max = 16 ** channel.length - 1;\n\tif (max <= 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.round((parseInt(channel, 16) / max) * 255);\n}\n\nconst OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN = /^\\x1b\\]11;([^\\x07\\x1b]*)(?:\\x07|\\x1b\\\\)$/i;\nconst COLOR_SCHEME_REPORT_PATTERN = /^(?:\\x1b\\[\\?997;(1|2)n)+$/;\n\nexport function isOsc11BackgroundColorResponse(data: string): boolean {\n\treturn OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN.test(data);\n}\n\nexport function parseOsc11BackgroundColor(data: string): RgbColor | undefined {\n\tconst match = data.match(OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\tconst value = match[1].trim();\n\tif (value.startsWith(\"#\")) {\n\t\tconst hex = value.slice(1);\n\t\tif (/^[0-9a-f]{6}$/i.test(hex)) {\n\t\t\treturn hexToRgb(value);\n\t\t}\n\t\tif (/^[0-9a-f]{12}$/i.test(hex)) {\n\t\t\tconst r = parseOscHexChannel(hex.slice(0, 4));\n\t\t\tconst g = parseOscHexChannel(hex.slice(4, 8));\n\t\t\tconst b = parseOscHexChannel(hex.slice(8, 12));\n\t\t\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst rgbValue = value.replace(/^rgba?:/i, \"\");\n\tconst [red, green, blue] = rgbValue.split(\"/\");\n\tif (red === undefined || green === undefined || blue === undefined) {\n\t\treturn undefined;\n\t}\n\tconst r = parseOscHexChannel(red);\n\tconst g = parseOscHexChannel(green);\n\tconst b = parseOscHexChannel(blue);\n\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n}\n\nexport function parseTerminalColorSchemeReport(data: string): TerminalColorScheme | undefined {\n\tconst match = data.match(COLOR_SCHEME_REPORT_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\treturn match[1] === \"2\" ? \"light\" : \"dark\";\n}\n"]}
@@ -52,6 +52,8 @@ export declare function deleteKittyImage(imageId: number): string;
52
52
  * Uses uppercase 'A' to also free the image data.
53
53
  */
54
54
  export declare function deleteAllKittyImages(): string;
55
+ /** Delete all visible Kitty placements while retaining their uploaded image data. */
56
+ export declare function deleteAllKittyPlacements(): string;
55
57
  export declare function encodeITerm2(base64Data: string, options?: {
56
58
  width?: number | string;
57
59
  height?: number | string;
@@ -63,6 +65,24 @@ export interface ImageCellSize {
63
65
  columns: number;
64
66
  rows: number;
65
67
  }
68
+ export interface KittyImageMetadata extends ImageCellSize {
69
+ imageId: number;
70
+ widthPx: number;
71
+ heightPx: number;
72
+ }
73
+ export interface KittyImagePlacement {
74
+ imageId: number;
75
+ transmissionGeneration: number;
76
+ transmissionBytes: number;
77
+ estimatedDecodedBytes: number;
78
+ sequence: string;
79
+ replacementLine: string;
80
+ }
81
+ export declare function registerKittyImageMetadata(metadata: KittyImageMetadata): void;
82
+ export declare function getKittyImageMetadata(line: string): KittyImageMetadata | undefined;
83
+ /** Build a placement-only command for an image line emitted by {@link renderImage}. */
84
+ export declare function getKittyImagePlacement(line: string): KittyImagePlacement | undefined;
85
+ export declare function cropKittyImageLine(line: string, hiddenRows: number, visibleRows: number): string;
66
86
  export declare function calculateImageCellSize(imageDimensions: ImageDimensions, maxWidthCells: number, maxHeightCells?: number, cellDimensions?: CellDimensions): ImageCellSize;
67
87
  export declare function calculateImageRows(imageDimensions: ImageDimensions, targetWidthCells: number, cellDimensions?: CellDimensions): number;
68
88
  export declare function getPngDimensions(base64Data: string): ImageDimensions | null;
@@ -72,6 +92,7 @@ export declare function getWebpDimensions(base64Data: string): ImageDimensions |
72
92
  export declare function getImageDimensions(base64Data: string, mimeType: string): ImageDimensions | null;
73
93
  export declare function renderImage(base64Data: string, imageDimensions: ImageDimensions, options?: ImageRenderOptions): {
74
94
  sequence: string;
95
+ columns: number;
75
96
  rows: number;
76
97
  imageId?: number;
77
98
  } | null;