@detergent-software/atk 9.6.1-dev.10 → 9.6.1-dev.12

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 (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/commands/_app.d.ts.map +1 -1
  3. package/build/commands/_app.js +12 -1
  4. package/build/commands/_app.js.map +1 -1
  5. package/build/commands/browse.d.ts +5 -2
  6. package/build/commands/browse.d.ts.map +1 -1
  7. package/build/commands/browse.js +17 -13
  8. package/build/commands/browse.js.map +1 -1
  9. package/build/commands/list.d.ts +5 -2
  10. package/build/commands/list.d.ts.map +1 -1
  11. package/build/commands/list.js +18 -13
  12. package/build/commands/list.js.map +1 -1
  13. package/build/components/BrowseList.d.ts.map +1 -1
  14. package/build/components/BrowseList.js +25 -33
  15. package/build/components/BrowseList.js.map +1 -1
  16. package/build/components/CutDetail.d.ts +14 -0
  17. package/build/components/CutDetail.d.ts.map +1 -0
  18. package/build/components/CutDetail.js +14 -0
  19. package/build/components/CutDetail.js.map +1 -0
  20. package/build/components/FilterBar.js +1 -1
  21. package/build/components/FilterBar.js.map +1 -1
  22. package/build/components/Header.d.ts +3 -1
  23. package/build/components/Header.d.ts.map +1 -1
  24. package/build/components/Header.js +4 -1
  25. package/build/components/Header.js.map +1 -1
  26. package/build/components/HelpBar.d.ts +1 -1
  27. package/build/components/HelpBar.js +1 -1
  28. package/build/components/ListBrowseList.d.ts.map +1 -1
  29. package/build/components/ListBrowseList.js +17 -25
  30. package/build/components/ListBrowseList.js.map +1 -1
  31. package/build/components/MeasuredBox.d.ts +20 -0
  32. package/build/components/MeasuredBox.d.ts.map +1 -0
  33. package/build/components/MeasuredBox.js +14 -0
  34. package/build/components/MeasuredBox.js.map +1 -0
  35. package/build/hooks/useListState.d.ts.map +1 -1
  36. package/build/hooks/useListState.js +6 -1
  37. package/build/hooks/useListState.js.map +1 -1
  38. package/build/hooks/useMeasuredRows.d.ts +10 -0
  39. package/build/hooks/useMeasuredRows.d.ts.map +1 -0
  40. package/build/hooks/useMeasuredRows.js +23 -0
  41. package/build/hooks/useMeasuredRows.js.map +1 -0
  42. package/build/hooks/useShell.d.ts +23 -0
  43. package/build/hooks/useShell.d.ts.map +1 -0
  44. package/build/hooks/useShell.js +28 -0
  45. package/build/hooks/useShell.js.map +1 -0
  46. package/build/lib/list-window.d.ts +37 -0
  47. package/build/lib/list-window.d.ts.map +1 -0
  48. package/build/lib/list-window.js +46 -0
  49. package/build/lib/list-window.js.map +1 -0
  50. package/build/lib/screen-rows.d.ts +15 -0
  51. package/build/lib/screen-rows.d.ts.map +1 -0
  52. package/build/lib/screen-rows.js +17 -0
  53. package/build/lib/screen-rows.js.map +1 -0
  54. package/package.json +1 -1
@@ -0,0 +1,23 @@
1
+ export interface Shell {
2
+ /** The rows the App shell draws around the command: its margins, header, update banner and notices */
3
+ rows: number;
4
+ /** Asks the shell for its one-line header while a full-screen screen is up */
5
+ setFullScreen: (fullScreen: boolean) => void;
6
+ }
7
+ /** A command rendered outside the App shell (most tests) has no shell around it. */
8
+ export declare const ShellContext: import("react").Context<Shell>;
9
+ /** Whether the command, run with these options, shows a screen that sizes itself to the terminal */
10
+ export type FullScreenWhen = (options: Record<string, unknown>) => boolean;
11
+ /**
12
+ * Whether a command's component, run with `options`, shows a full-screen screen, by its `fullScreen` predicate
13
+ * (`List.fullScreen = (options) => options['tree'] !== true`). The shell starts with the one-line header for it, so
14
+ * the art never shows for a frame before {@link useFullScreenShell} asks.
15
+ */
16
+ export declare function declaresFullScreen(component: object, options: Record<string, unknown>): boolean;
17
+ /**
18
+ * For a screen that sizes itself to the terminal (`browse`, `list`): the shell draws its one-line header while the
19
+ * screen is mounted, and this returns the rows the shell really takes, which grow when the update banner or a notice
20
+ * arrives.
21
+ */
22
+ export declare function useFullScreenShell(): number;
23
+ //# sourceMappingURL=useShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useShell.d.ts","sourceRoot":"","sources":["../../src/hooks/useShell.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,KAAK;IACpB,sGAAsG;IACtG,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,oFAAoF;AACpF,eAAO,MAAM,YAAY,gCAA6D,CAAC;AAEvF,oGAAoG;AACpG,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;AAE3E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAE/F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAO3C"}
@@ -0,0 +1,28 @@
1
+ import { createContext, useContext, useLayoutEffect } from 'react';
2
+ /** A command rendered outside the App shell (most tests) has no shell around it. */
3
+ export const ShellContext = createContext({ rows: 0, setFullScreen: () => { } });
4
+ /**
5
+ * Whether a command's component, run with `options`, shows a full-screen screen, by its `fullScreen` predicate
6
+ * (`List.fullScreen = (options) => options['tree'] !== true`). The shell starts with the one-line header for it, so
7
+ * the art never shows for a frame before {@link useFullScreenShell} asks.
8
+ */
9
+ export function declaresFullScreen(component, options) {
10
+ return hasFullScreenWhen(component) && component.fullScreen(options);
11
+ }
12
+ /**
13
+ * For a screen that sizes itself to the terminal (`browse`, `list`): the shell draws its one-line header while the
14
+ * screen is mounted, and this returns the rows the shell really takes, which grow when the update banner or a notice
15
+ * arrives.
16
+ */
17
+ export function useFullScreenShell() {
18
+ const { rows, setFullScreen } = useContext(ShellContext);
19
+ useLayoutEffect(() => {
20
+ setFullScreen(true);
21
+ return () => setFullScreen(false);
22
+ }, [setFullScreen]);
23
+ return rows;
24
+ }
25
+ function hasFullScreenWhen(component) {
26
+ return 'fullScreen' in component && typeof component.fullScreen === 'function';
27
+ }
28
+ //# sourceMappingURL=useShell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useShell.js","sourceRoot":"","sources":["../../src/hooks/useShell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AASnE,oFAAoF;AACpF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAKvF;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB,EAAE,OAAgC;IACpF,OAAO,iBAAiB,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACzD,eAAe,CAAC,GAAG,EAAE;QACnB,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,OAAO,YAAY,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;AACjF,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Which rows `atk browse` and `atk list` draw: the viewport holds the column header, the "▲ N more above" line when
3
+ * the window starts past the first row, the rows (an expanded row takes its detail's lines too), and the "▼ N more
4
+ * below" line when rows remain after the last one drawn.
5
+ */
6
+ export interface ListWindow {
7
+ /** The rows hidden after the window */
8
+ below: number;
9
+ /** The expanded row's detail lines that fit; fewer than its whole detail when the rest is cut */
10
+ detailLines: number;
11
+ /** The rows drawn, in order */
12
+ indexes: number[];
13
+ /** The first row drawn, which is also the count of rows hidden before it */
14
+ start: number;
15
+ }
16
+ /** A list's rows, its cursor, its expanded row and the lines it has, for {@link fitListWindow}. */
17
+ export interface ListWindowInput {
18
+ /** The number of rows in the list */
19
+ count: number;
20
+ /** The cursor's row */
21
+ cursorIndex: number;
22
+ /** The expanded row, or null */
23
+ expandedIndex: null | number;
24
+ /** The expanded row's detail lines, below the row itself */
25
+ expandedLines: number;
26
+ /** The state's first row, for a collapsed list */
27
+ scrollOffset: number;
28
+ /** The lines the list has, the column header included */
29
+ viewportHeight: number;
30
+ }
31
+ /**
32
+ * The rows that fit from the state's `scrollOffset`, as the lists always drew them, unless that leaves out the
33
+ * cursor's row: then the window starts later, until the cursor's row fits with all of its detail, or at the cursor's
34
+ * row with its detail cut to the lines left. The cursor's row is always drawn.
35
+ */
36
+ export declare function fitListWindow(input: ListWindowInput): ListWindow;
37
+ //# sourceMappingURL=list-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-window.d.ts","sourceRoot":"","sources":["../../src/lib/list-window.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,aAAa,EAAE,IAAI,GAAG,MAAM,CAAC;IAC7B,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,CAehE"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The rows that fit from the state's `scrollOffset`, as the lists always drew them, unless that leaves out the
3
+ * cursor's row: then the window starts later, until the cursor's row fits with all of its detail, or at the cursor's
4
+ * row with its detail cut to the lines left. The cursor's row is always drawn.
5
+ */
6
+ export function fitListWindow(input) {
7
+ const { count, cursorIndex, expandedIndex, expandedLines, scrollOffset } = input;
8
+ if (count === 0)
9
+ return { below: 0, detailLines: 0, indexes: [], start: 0 };
10
+ const cursor = Math.min(Math.max(0, cursorIndex), count - 1);
11
+ const first = Math.min(scrollOffset, cursor);
12
+ for (let start = first; start <= cursor; start++) {
13
+ const window = fitFrom(input, start);
14
+ if (window.indexes.includes(cursor))
15
+ return window;
16
+ }
17
+ // Not even the cursor's row alone, with all of its detail: draw it first and cut the detail
18
+ const room = rowsRoom(input.viewportHeight, cursor, cursor, count);
19
+ const detailLines = cursor === expandedIndex ? Math.max(0, Math.min(expandedLines, room - 1)) : 0;
20
+ return { below: count - cursor - 1, detailLines, indexes: [cursor], start: cursor };
21
+ }
22
+ /** The rows that fit from `start`, each whole, stopping at the first that doesn't. */
23
+ function fitFrom({ count, expandedIndex, expandedLines, viewportHeight }, start) {
24
+ const indexes = [];
25
+ let used = 0;
26
+ let detailLines = 0;
27
+ for (let i = start; i < count; i++) {
28
+ const detail = i === expandedIndex ? expandedLines : 0;
29
+ if (used + 1 + detail > rowsRoom(viewportHeight, start, i, count))
30
+ break;
31
+ indexes.push(i);
32
+ used += 1 + detail;
33
+ if (detail > 0)
34
+ detailLines = detail;
35
+ }
36
+ const last = indexes.at(-1) ?? start - 1;
37
+ return { below: count - last - 1, detailLines, indexes, start };
38
+ }
39
+ /**
40
+ * The lines left for rows in a window from `start` whose last row is `last`: the viewport less the column header,
41
+ * the "▲" line when `start` is past the first row, and the "▼" line when rows remain after `last`.
42
+ */
43
+ function rowsRoom(viewportHeight, start, last, count) {
44
+ return viewportHeight - 1 - (start > 0 ? 1 : 0) - (last < count - 1 ? 1 : 0);
45
+ }
46
+ //# sourceMappingURL=list-window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-window.js","sourceRoot":"","sources":["../../src/lib/list-window.ts"],"names":[],"mappings":"AAgCA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IACjF,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAE5E,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC7C,KAAK,IAAI,KAAK,GAAG,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC;IACrD,CAAC;IAED,4FAA4F;IAC5F,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE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;IAClF,OAAO,cAAc,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The rows `browse` and `list` draw besides their list's viewport: the filter bar (4), the list's border (2) and the
3
+ * help or action bar (3). The column header and the scroll markers are inside the viewport.
4
+ */
5
+ export declare const SCREEN_CHROME_ROWS = 9;
6
+ /** The fewest rows a list's viewport gets: its column header, "▲ more above", one row and "▼ more below". */
7
+ export declare const MIN_VIEWPORT_ROWS = 4;
8
+ /**
9
+ * The rows left for a full-screen list's viewport on a terminal `terminalRows` tall, once `otherRows` (the App
10
+ * shell's and the screen's own warnings) are drawn. The frame stays one row short of the terminal: once a frame is as
11
+ * tall as the terminal, Ink clears the whole terminal on every render, which flickers and leaves lines behind
12
+ * (ATK-961). A terminal too short for {@link MIN_VIEWPORT_ROWS} gets the minimum anyway, and its frame overflows.
13
+ */
14
+ export declare function viewportRows(terminalRows: number, otherRows: number): number;
15
+ //# sourceMappingURL=screen-rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen-rows.d.ts","sourceRoot":"","sources":["../../src/lib/screen-rows.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,6GAA6G;AAC7G,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The rows `browse` and `list` draw besides their list's viewport: the filter bar (4), the list's border (2) and the
3
+ * help or action bar (3). The column header and the scroll markers are inside the viewport.
4
+ */
5
+ export const SCREEN_CHROME_ROWS = 9;
6
+ /** The fewest rows a list's viewport gets: its column header, "▲ more above", one row and "▼ more below". */
7
+ export const MIN_VIEWPORT_ROWS = 4;
8
+ /**
9
+ * The rows left for a full-screen list's viewport on a terminal `terminalRows` tall, once `otherRows` (the App
10
+ * shell's and the screen's own warnings) are drawn. The frame stays one row short of the terminal: once a frame is as
11
+ * tall as the terminal, Ink clears the whole terminal on every render, which flickers and leaves lines behind
12
+ * (ATK-961). A terminal too short for {@link MIN_VIEWPORT_ROWS} gets the minimum anyway, and its frame overflows.
13
+ */
14
+ export function viewportRows(terminalRows, otherRows) {
15
+ return Math.max(MIN_VIEWPORT_ROWS, terminalRows - 1 - otherRows - SCREEN_CHROME_ROWS);
16
+ }
17
+ //# sourceMappingURL=screen-rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen-rows.js","sourceRoot":"","sources":["../../src/lib/screen-rows.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,6GAA6G;AAC7G,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,YAAoB,EAAE,SAAiB;IAClE,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,GAAG,kBAAkB,CAAC,CAAC;AACxF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@detergent-software/atk",
3
- "version": "9.6.1-dev.10",
3
+ "version": "9.6.1-dev.12",
4
4
  "description": "Agentic Tool Kit — CLI for managing AI coding tool assets.",
5
5
  "type": "module",
6
6
  "bin": {