@jrichman/ink 6.3.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 (141) hide show
  1. package/build/colorize.d.ts +3 -0
  2. package/build/colorize.js +48 -0
  3. package/build/colorize.js.map +1 -0
  4. package/build/components/AccessibilityContext.d.ts +3 -0
  5. package/build/components/AccessibilityContext.js +5 -0
  6. package/build/components/AccessibilityContext.js.map +1 -0
  7. package/build/components/App.d.ts +59 -0
  8. package/build/components/App.js +286 -0
  9. package/build/components/App.js.map +1 -0
  10. package/build/components/AppContext.d.ts +11 -0
  11. package/build/components/AppContext.js +11 -0
  12. package/build/components/AppContext.js.map +1 -0
  13. package/build/components/BackgroundContext.d.ts +4 -0
  14. package/build/components/BackgroundContext.js +3 -0
  15. package/build/components/BackgroundContext.js.map +1 -0
  16. package/build/components/Box.d.ts +122 -0
  17. package/build/components/Box.js +34 -0
  18. package/build/components/Box.js.map +1 -0
  19. package/build/components/ErrorOverview.d.ts +6 -0
  20. package/build/components/ErrorOverview.js +84 -0
  21. package/build/components/ErrorOverview.js.map +1 -0
  22. package/build/components/FocusContext.d.ts +16 -0
  23. package/build/components/FocusContext.js +17 -0
  24. package/build/components/FocusContext.js.map +1 -0
  25. package/build/components/Newline.d.ts +13 -0
  26. package/build/components/Newline.js +8 -0
  27. package/build/components/Newline.js.map +1 -0
  28. package/build/components/Spacer.d.ts +7 -0
  29. package/build/components/Spacer.js +11 -0
  30. package/build/components/Spacer.js.map +1 -0
  31. package/build/components/Static.d.ts +24 -0
  32. package/build/components/Static.js +28 -0
  33. package/build/components/Static.js.map +1 -0
  34. package/build/components/StderrContext.d.ts +15 -0
  35. package/build/components/StderrContext.js +13 -0
  36. package/build/components/StderrContext.js.map +1 -0
  37. package/build/components/StdinContext.d.ts +22 -0
  38. package/build/components/StdinContext.js +19 -0
  39. package/build/components/StdinContext.js.map +1 -0
  40. package/build/components/StdoutContext.d.ts +15 -0
  41. package/build/components/StdoutContext.js +13 -0
  42. package/build/components/StdoutContext.js.map +1 -0
  43. package/build/components/Text.d.ts +55 -0
  44. package/build/components/Text.js +50 -0
  45. package/build/components/Text.js.map +1 -0
  46. package/build/components/Transform.d.ts +16 -0
  47. package/build/components/Transform.js +15 -0
  48. package/build/components/Transform.js.map +1 -0
  49. package/build/devtools-window-polyfill.d.ts +1 -0
  50. package/build/devtools-window-polyfill.js +65 -0
  51. package/build/devtools-window-polyfill.js.map +1 -0
  52. package/build/devtools.d.ts +1 -0
  53. package/build/devtools.js +2 -0
  54. package/build/devtools.js.map +1 -0
  55. package/build/dom.d.ts +62 -0
  56. package/build/dom.js +123 -0
  57. package/build/dom.js.map +1 -0
  58. package/build/get-max-width.d.ts +3 -0
  59. package/build/get-max-width.js +10 -0
  60. package/build/get-max-width.js.map +1 -0
  61. package/build/hooks/use-app.d.ts +5 -0
  62. package/build/hooks/use-app.js +8 -0
  63. package/build/hooks/use-app.js.map +1 -0
  64. package/build/hooks/use-focus-manager.d.ts +28 -0
  65. package/build/hooks/use-focus-manager.js +17 -0
  66. package/build/hooks/use-focus-manager.js.map +1 -0
  67. package/build/hooks/use-focus.d.ts +29 -0
  68. package/build/hooks/use-focus.js +42 -0
  69. package/build/hooks/use-focus.js.map +1 -0
  70. package/build/hooks/use-input.d.ts +93 -0
  71. package/build/hooks/use-input.js +93 -0
  72. package/build/hooks/use-input.js.map +1 -0
  73. package/build/hooks/use-is-screen-reader-enabled.d.ts +5 -0
  74. package/build/hooks/use-is-screen-reader-enabled.js +11 -0
  75. package/build/hooks/use-is-screen-reader-enabled.js.map +1 -0
  76. package/build/hooks/use-stderr.d.ts +5 -0
  77. package/build/hooks/use-stderr.js +8 -0
  78. package/build/hooks/use-stderr.js.map +1 -0
  79. package/build/hooks/use-stdin.d.ts +5 -0
  80. package/build/hooks/use-stdin.js +8 -0
  81. package/build/hooks/use-stdin.js.map +1 -0
  82. package/build/hooks/use-stdout.d.ts +5 -0
  83. package/build/hooks/use-stdout.js +8 -0
  84. package/build/hooks/use-stdout.js.map +1 -0
  85. package/build/index.d.ts +28 -0
  86. package/build/index.js +17 -0
  87. package/build/index.js.map +1 -0
  88. package/build/ink.d.ts +43 -0
  89. package/build/ink.js +315 -0
  90. package/build/ink.js.map +1 -0
  91. package/build/instances.d.ts +3 -0
  92. package/build/instances.js +8 -0
  93. package/build/instances.js.map +1 -0
  94. package/build/log-update.d.ts +15 -0
  95. package/build/log-update.js +109 -0
  96. package/build/log-update.js.map +1 -0
  97. package/build/measure-element.d.ts +38 -0
  98. package/build/measure-element.js +118 -0
  99. package/build/measure-element.js.map +1 -0
  100. package/build/measure-text.d.ts +6 -0
  101. package/build/measure-text.js +21 -0
  102. package/build/measure-text.js.map +1 -0
  103. package/build/output.d.ts +36 -0
  104. package/build/output.js +191 -0
  105. package/build/output.js.map +1 -0
  106. package/build/parse-keypress.d.ts +14 -0
  107. package/build/parse-keypress.js +225 -0
  108. package/build/parse-keypress.js.map +1 -0
  109. package/build/reconciler.d.ts +4 -0
  110. package/build/reconciler.js +254 -0
  111. package/build/reconciler.js.map +1 -0
  112. package/build/render-background.d.ts +4 -0
  113. package/build/render-background.js +25 -0
  114. package/build/render-background.js.map +1 -0
  115. package/build/render-border.d.ts +4 -0
  116. package/build/render-border.js +73 -0
  117. package/build/render-border.js.map +1 -0
  118. package/build/render-node-to-output.d.ts +14 -0
  119. package/build/render-node-to-output.js +296 -0
  120. package/build/render-node-to-output.js.map +1 -0
  121. package/build/render.d.ts +87 -0
  122. package/build/render.js +50 -0
  123. package/build/render.js.map +1 -0
  124. package/build/renderer.d.ts +8 -0
  125. package/build/renderer.js +55 -0
  126. package/build/renderer.js.map +1 -0
  127. package/build/scroll.d.ts +8 -0
  128. package/build/scroll.js +35 -0
  129. package/build/scroll.js.map +1 -0
  130. package/build/squash-text-nodes.d.ts +3 -0
  131. package/build/squash-text-nodes.js +35 -0
  132. package/build/squash-text-nodes.js.map +1 -0
  133. package/build/styles.d.ts +260 -0
  134. package/build/styles.js +257 -0
  135. package/build/styles.js.map +1 -0
  136. package/build/wrap-text.d.ts +3 -0
  137. package/build/wrap-text.js +31 -0
  138. package/build/wrap-text.js.map +1 -0
  139. package/license +9 -0
  140. package/package.json +194 -0
  141. package/readme.md +2331 -0
@@ -0,0 +1,84 @@
1
+ import * as fs from 'node:fs';
2
+ import { cwd } from 'node:process';
3
+ import React from 'react';
4
+ import StackUtils from 'stack-utils';
5
+ import codeExcerpt from 'code-excerpt';
6
+ import Box from './Box.js';
7
+ import Text from './Text.js';
8
+ // Error's source file is reported as file:///home/user/file.js
9
+ // This function removes the file://[cwd] part
10
+ const cleanupPath = (path) => {
11
+ return path?.replace(`file://${cwd()}/`, '');
12
+ };
13
+ const stackUtils = new StackUtils({
14
+ cwd: cwd(),
15
+ internals: StackUtils.nodeInternals(),
16
+ });
17
+ export default function ErrorOverview({ error }) {
18
+ const stack = error.stack ? error.stack.split('\n').slice(1) : undefined;
19
+ const origin = stack ? stackUtils.parseLine(stack[0]) : undefined;
20
+ const filePath = cleanupPath(origin?.file);
21
+ let excerpt;
22
+ let lineWidth = 0;
23
+ if (filePath && origin?.line && fs.existsSync(filePath)) {
24
+ const sourceCode = fs.readFileSync(filePath, 'utf8');
25
+ excerpt = codeExcerpt(sourceCode, origin.line);
26
+ if (excerpt) {
27
+ for (const { line } of excerpt) {
28
+ lineWidth = Math.max(lineWidth, String(line).length);
29
+ }
30
+ }
31
+ }
32
+ return (React.createElement(Box, { flexDirection: "column", padding: 1 },
33
+ React.createElement(Box, null,
34
+ React.createElement(Text, { backgroundColor: "red", color: "white" },
35
+ ' ',
36
+ "ERROR",
37
+ ' '),
38
+ React.createElement(Text, null,
39
+ " ",
40
+ error.message)),
41
+ origin && filePath && (React.createElement(Box, { marginTop: 1 },
42
+ React.createElement(Text, { dimColor: true },
43
+ filePath,
44
+ ":",
45
+ origin.line,
46
+ ":",
47
+ origin.column))),
48
+ origin && excerpt && (React.createElement(Box, { marginTop: 1, flexDirection: "column" }, excerpt.map(({ line, value }) => (React.createElement(Box, { key: line },
49
+ React.createElement(Box, { width: lineWidth + 1 },
50
+ React.createElement(Text, { dimColor: line !== origin.line, backgroundColor: line === origin.line ? 'red' : undefined, color: line === origin.line ? 'white' : undefined, "aria-label": line === origin.line
51
+ ? `Line ${line}, error`
52
+ : `Line ${line}` },
53
+ String(line).padStart(lineWidth, ' '),
54
+ ":")),
55
+ React.createElement(Text, { key: line, backgroundColor: line === origin.line ? 'red' : undefined, color: line === origin.line ? 'white' : undefined }, ' ' + value)))))),
56
+ error.stack && (React.createElement(Box, { marginTop: 1, flexDirection: "column" }, error.stack
57
+ .split('\n')
58
+ .slice(1)
59
+ .map(line => {
60
+ const parsedLine = stackUtils.parseLine(line);
61
+ // If the line from the stack cannot be parsed, we print out the unparsed line.
62
+ if (!parsedLine) {
63
+ return (React.createElement(Box, { key: line },
64
+ React.createElement(Text, { dimColor: true }, "- "),
65
+ React.createElement(Text, { dimColor: true, bold: true },
66
+ line,
67
+ "\\t",
68
+ ' ')));
69
+ }
70
+ return (React.createElement(Box, { key: line },
71
+ React.createElement(Text, { dimColor: true }, "- "),
72
+ React.createElement(Text, { dimColor: true, bold: true }, parsedLine.function),
73
+ React.createElement(Text, { dimColor: true, color: "gray", "aria-label": `at ${cleanupPath(parsedLine.file) ?? ''} line ${parsedLine.line} column ${parsedLine.column}` },
74
+ ' ',
75
+ "(",
76
+ cleanupPath(parsedLine.file) ?? '',
77
+ ":",
78
+ parsedLine.line,
79
+ ":",
80
+ parsedLine.column,
81
+ ")")));
82
+ })))));
83
+ }
84
+ //# sourceMappingURL=ErrorOverview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorOverview.js","sourceRoot":"","sources":["../../src/components/ErrorOverview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,GAAG,EAAC,MAAM,cAAc,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OA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,IAAI,CAAC,IAAI,EACjC,SAAS,UAAU,CAAC,IAAI,WAAW,UAAU,CAAC,MAAM,EAAE;oBAErD,GAAG;;oBACF,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;;oBAAG,UAAU,CAAC,IAAI;;oBACrD,UAAU,CAAC,MAAM;wBACZ,CACF,CACN,CAAC;QACH,CAAC,CAAC,CACE,CACN,CACI,CACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ export type Props = {
2
+ readonly activeId?: string;
3
+ readonly add: (id: string, options: {
4
+ autoFocus: boolean;
5
+ }) => void;
6
+ readonly remove: (id: string) => void;
7
+ readonly activate: (id: string) => void;
8
+ readonly deactivate: (id: string) => void;
9
+ readonly enableFocus: () => void;
10
+ readonly disableFocus: () => void;
11
+ readonly focusNext: () => void;
12
+ readonly focusPrevious: () => void;
13
+ readonly focus: (id: string) => void;
14
+ };
15
+ declare const FocusContext: import("react").Context<Props>;
16
+ export default FocusContext;
@@ -0,0 +1,17 @@
1
+ import { createContext } from 'react';
2
+ // eslint-disable-next-line @typescript-eslint/naming-convention
3
+ const FocusContext = createContext({
4
+ activeId: undefined,
5
+ add() { },
6
+ remove() { },
7
+ activate() { },
8
+ deactivate() { },
9
+ enableFocus() { },
10
+ disableFocus() { },
11
+ focusNext() { },
12
+ focusPrevious() { },
13
+ focus() { },
14
+ });
15
+ FocusContext.displayName = 'InternalFocusContext';
16
+ export default FocusContext;
17
+ //# sourceMappingURL=FocusContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FocusContext.js","sourceRoot":"","sources":["../../src/components/FocusContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAepC,gEAAgE;AAChE,MAAM,YAAY,GAAG,aAAa,CAAQ;IACzC,QAAQ,EAAE,SAAS;IACnB,GAAG,KAAI,CAAC;IACR,MAAM,KAAI,CAAC;IACX,QAAQ,KAAI,CAAC;IACb,UAAU,KAAI,CAAC;IACf,WAAW,KAAI,CAAC;IAChB,YAAY,KAAI,CAAC;IACjB,SAAS,KAAI,CAAC;IACd,aAAa,KAAI,CAAC;IAClB,KAAK,KAAI,CAAC;CACV,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAElD,eAAe,YAAY,CAAC"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export type Props = {
3
+ /**
4
+ Number of newlines to insert.
5
+
6
+ @default 1
7
+ */
8
+ readonly count?: number;
9
+ };
10
+ /**
11
+ Adds one or more newline (`\n`) characters. Must be used within `<Text>` components.
12
+ */
13
+ export default function Newline({ count }: Props): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ /**
3
+ Adds one or more newline (`\n`) characters. Must be used within `<Text>` components.
4
+ */
5
+ export default function Newline({ count = 1 }) {
6
+ return React.createElement("ink-text", null, '\n'.repeat(count));
7
+ }
8
+ //# sourceMappingURL=Newline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Newline.js","sourceRoot":"","sources":["../../src/components/Newline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B;;EAEE;AACF,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAC,KAAK,GAAG,CAAC,EAAQ;IACjD,OAAO,sCAAW,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAY,CAAC;AAClD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ /**
3
+ A flexible space that expands along the major axis of its containing layout.
4
+
5
+ It's useful as a shortcut for filling all the available space between elements.
6
+ */
7
+ export default function Spacer(): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import Box from './Box.js';
3
+ /**
4
+ A flexible space that expands along the major axis of its containing layout.
5
+
6
+ It's useful as a shortcut for filling all the available space between elements.
7
+ */
8
+ export default function Spacer() {
9
+ return React.createElement(Box, { flexGrow: 1 });
10
+ }
11
+ //# sourceMappingURL=Spacer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spacer.js","sourceRoot":"","sources":["../../src/components/Spacer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B;;;;EAIE;AACF,MAAM,CAAC,OAAO,UAAU,MAAM;IAC7B,OAAO,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,GAAI,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,24 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type Styles } from '../styles.js';
3
+ export type Props<T> = {
4
+ /**
5
+ Array of items of any type to render using the function you pass as a component child.
6
+ */
7
+ readonly items: T[];
8
+ /**
9
+ Styles to apply to a container of child elements. See <Box> for supported properties.
10
+ */
11
+ readonly style?: Styles;
12
+ /**
13
+ Function that is called to render every item in the `items` array. The first argument is the item itself, and the second argument is the index of that item in the `items` array. Note that a `key` must be assigned to the root component.
14
+ */
15
+ readonly children: (item: T, index: number) => ReactNode;
16
+ };
17
+ /**
18
+ `<Static>` component permanently renders its output above everything else. It's useful for displaying activity like completed tasks or logs—things that don't change after they're rendered (hence the name "Static").
19
+
20
+ It's preferred to use `<Static>` for use cases like these when you can't know or control the number of items that need to be rendered.
21
+
22
+ For example, [Tap](https://github.com/tapjs/node-tap) uses `<Static>` to display a list of completed tests. [Gatsby](https://github.com/gatsbyjs/gatsby) uses it to display a list of generated pages while still displaying a live progress bar.
23
+ */
24
+ export default function Static<T>(props: Props<T>): React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ import React, { useMemo, useState, useLayoutEffect } from 'react';
2
+ /**
3
+ `<Static>` component permanently renders its output above everything else. It's useful for displaying activity like completed tasks or logs—things that don't change after they're rendered (hence the name "Static").
4
+
5
+ It's preferred to use `<Static>` for use cases like these when you can't know or control the number of items that need to be rendered.
6
+
7
+ For example, [Tap](https://github.com/tapjs/node-tap) uses `<Static>` to display a list of completed tests. [Gatsby](https://github.com/gatsbyjs/gatsby) uses it to display a list of generated pages while still displaying a live progress bar.
8
+ */
9
+ export default function Static(props) {
10
+ const { items, children: render, style: customStyle } = props;
11
+ const [index, setIndex] = useState(0);
12
+ const itemsToRender = useMemo(() => {
13
+ return items.slice(index);
14
+ }, [items, index]);
15
+ useLayoutEffect(() => {
16
+ setIndex(items.length);
17
+ }, [items.length]);
18
+ const children = itemsToRender.map((item, itemIndex) => {
19
+ return render(item, index + itemIndex);
20
+ });
21
+ const style = useMemo(() => ({
22
+ position: 'absolute',
23
+ flexDirection: 'column',
24
+ ...customStyle,
25
+ }), [customStyle]);
26
+ return (React.createElement("ink-box", { internal_static: true, style: style }, children));
27
+ }
28
+ //# sourceMappingURL=Static.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Static.js","sourceRoot":"","sources":["../../src/components/Static.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAiB,MAAM,OAAO,CAAC;AAoBhF;;;;;;EAME;AACF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAI,KAAe;IAChD,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC;IAC5D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEtC,MAAM,aAAa,GAAQ,OAAO,CAAC,GAAG,EAAE;QACvC,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAEnB,eAAe,CAAC,GAAG,EAAE;QACpB,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnB,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QACtD,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAW,OAAO,CAC5B,GAAG,EAAE,CAAC,CAAC;QACN,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,QAAQ;QACvB,GAAG,WAAW;KACd,CAAC,EACF,CAAC,WAAW,CAAC,CACb,CAAC;IAEF,OAAO,CACN,iCAAS,eAAe,QAAC,KAAK,EAAE,KAAK,IACnC,QAAQ,CACA,CACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type Props = {
2
+ /**
3
+ Stderr stream passed to `render()` in `options.stderr` or `process.stderr` by default.
4
+ */
5
+ readonly stderr: NodeJS.WriteStream;
6
+ /**
7
+ Write any string to stderr while preserving Ink's output. It's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two. It's similar to `<Static>`, except it can't accept components; it only works with strings.
8
+ */
9
+ readonly write: (data: string) => void;
10
+ };
11
+ /**
12
+ `StderrContext` is a React context that exposes the stderr stream.
13
+ */
14
+ declare const StderrContext: import("react").Context<Props>;
15
+ export default StderrContext;
@@ -0,0 +1,13 @@
1
+ import process from 'node:process';
2
+ import { createContext } from 'react';
3
+ /**
4
+ `StderrContext` is a React context that exposes the stderr stream.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ const StderrContext = createContext({
8
+ stderr: process.stderr,
9
+ write() { },
10
+ });
11
+ StderrContext.displayName = 'InternalStderrContext';
12
+ export default StderrContext;
13
+ //# sourceMappingURL=StderrContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StderrContext.js","sourceRoot":"","sources":["../../src/components/StderrContext.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAcpC;;EAEE;AACF,gEAAgE;AAChE,MAAM,aAAa,GAAG,aAAa,CAAQ;IAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,KAAK,KAAI,CAAC;CACV,CAAC,CAAC;AAEH,aAAa,CAAC,WAAW,GAAG,uBAAuB,CAAC;AAEpD,eAAe,aAAa,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { EventEmitter } from 'node:events';
2
+ export type Props = {
3
+ /**
4
+ The stdin stream passed to `render()` in `options.stdin`, or `process.stdin` by default. Useful if your app needs to handle user input.
5
+ */
6
+ readonly stdin: NodeJS.ReadStream;
7
+ /**
8
+ Ink exposes this function via own `<StdinContext>` to be able to handle Ctrl+C, that's why you should use Ink's `setRawMode` instead of `process.stdin.setRawMode`. If the `stdin` stream passed to Ink does not support setRawMode, this function does nothing.
9
+ */
10
+ readonly setRawMode: (value: boolean) => void;
11
+ /**
12
+ A boolean flag determining if the current `stdin` supports `setRawMode`. A component using `setRawMode` might want to use `isRawModeSupported` to nicely fall back in environments where raw mode is not supported.
13
+ */
14
+ readonly isRawModeSupported: boolean;
15
+ readonly internal_exitOnCtrlC: boolean;
16
+ readonly internal_eventEmitter: EventEmitter;
17
+ };
18
+ /**
19
+ `StdinContext` is a React context that exposes the input stream.
20
+ */
21
+ declare const StdinContext: import("react").Context<Props>;
22
+ export default StdinContext;
@@ -0,0 +1,19 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import process from 'node:process';
3
+ import { createContext } from 'react';
4
+ /**
5
+ `StdinContext` is a React context that exposes the input stream.
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/naming-convention
8
+ const StdinContext = createContext({
9
+ stdin: process.stdin,
10
+ // eslint-disable-next-line @typescript-eslint/naming-convention
11
+ internal_eventEmitter: new EventEmitter(),
12
+ setRawMode() { },
13
+ isRawModeSupported: false,
14
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15
+ internal_exitOnCtrlC: true,
16
+ });
17
+ StdinContext.displayName = 'InternalStdinContext';
18
+ export default StdinContext;
19
+ //# sourceMappingURL=StdinContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StdinContext.js","sourceRoot":"","sources":["../../src/components/StdinContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAuBpC;;EAEE;AACF,gEAAgE;AAChE,MAAM,YAAY,GAAG,aAAa,CAAQ;IACzC,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,gEAAgE;IAChE,qBAAqB,EAAE,IAAI,YAAY,EAAE;IACzC,UAAU,KAAI,CAAC;IACf,kBAAkB,EAAE,KAAK;IACzB,gEAAgE;IAChE,oBAAoB,EAAE,IAAI;CAC1B,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAElD,eAAe,YAAY,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type Props = {
2
+ /**
3
+ Stdout stream passed to `render()` in `options.stdout` or `process.stdout` by default.
4
+ */
5
+ readonly stdout: NodeJS.WriteStream;
6
+ /**
7
+ Write any string to stdout while preserving Ink's output. It's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two. It's similar to `<Static>`, except it can't accept components; it only works with strings.
8
+ */
9
+ readonly write: (data: string) => void;
10
+ };
11
+ /**
12
+ `StdoutContext` is a React context that exposes the stdout stream where Ink renders your app.
13
+ */
14
+ declare const StdoutContext: import("react").Context<Props>;
15
+ export default StdoutContext;
@@ -0,0 +1,13 @@
1
+ import process from 'node:process';
2
+ import { createContext } from 'react';
3
+ /**
4
+ `StdoutContext` is a React context that exposes the stdout stream where Ink renders your app.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ const StdoutContext = createContext({
8
+ stdout: process.stdout,
9
+ write() { },
10
+ });
11
+ StdoutContext.displayName = 'InternalStdoutContext';
12
+ export default StdoutContext;
13
+ //# sourceMappingURL=StdoutContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StdoutContext.js","sourceRoot":"","sources":["../../src/components/StdoutContext.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAcpC;;EAEE;AACF,gEAAgE;AAChE,MAAM,aAAa,GAAG,aAAa,CAAQ;IAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,KAAK,KAAI,CAAC;CACV,CAAC,CAAC;AAEH,aAAa,CAAC,WAAW,GAAG,uBAAuB,CAAC;AAEpD,eAAe,aAAa,CAAC"}
@@ -0,0 +1,55 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type ForegroundColorName } from 'chalk';
3
+ import { type LiteralUnion } from 'type-fest';
4
+ import { type Styles } from '../styles.js';
5
+ export type Props = {
6
+ /**
7
+ A label for the element for screen readers.
8
+ */
9
+ readonly 'aria-label'?: string;
10
+ /**
11
+ Hide the element from screen readers.
12
+ */
13
+ readonly 'aria-hidden'?: boolean;
14
+ /**
15
+ Change text color. Ink uses Chalk under the hood, so all its functionality is supported.
16
+ */
17
+ readonly color?: LiteralUnion<ForegroundColorName, string>;
18
+ /**
19
+ Same as `color`, but for the background.
20
+ */
21
+ readonly backgroundColor?: LiteralUnion<ForegroundColorName, string>;
22
+ /**
23
+ Dim the color (make it less bright).
24
+ */
25
+ readonly dimColor?: boolean;
26
+ /**
27
+ Make the text bold.
28
+ */
29
+ readonly bold?: boolean;
30
+ /**
31
+ Make the text italic.
32
+ */
33
+ readonly italic?: boolean;
34
+ /**
35
+ Make the text underlined.
36
+ */
37
+ readonly underline?: boolean;
38
+ /**
39
+ Make the text crossed out with a line.
40
+ */
41
+ readonly strikethrough?: boolean;
42
+ /**
43
+ Inverse background and foreground colors.
44
+ */
45
+ readonly inverse?: boolean;
46
+ /**
47
+ This property tells Ink to wrap or truncate text if its width is larger than the container. If `wrap` is passed (the default), Ink will wrap text and split it into multiple lines. If `truncate-*` is passed, Ink will truncate text instead, resulting in one line of text with the rest cut off.
48
+ */
49
+ readonly wrap?: Styles['textWrap'];
50
+ readonly children?: ReactNode;
51
+ };
52
+ /**
53
+ This component can display text and change its style to make it bold, underlined, italic, or strikethrough.
54
+ */
55
+ export default function Text({ color, backgroundColor, dimColor, bold, italic, underline, strikethrough, inverse, wrap, children, 'aria-label': ariaLabel, 'aria-hidden': ariaHidden, }: Props): React.JSX.Element | null;
@@ -0,0 +1,50 @@
1
+ import React, { useContext } from 'react';
2
+ import chalk from 'chalk';
3
+ import colorize from '../colorize.js';
4
+ import { accessibilityContext } from './AccessibilityContext.js';
5
+ import { backgroundContext } from './BackgroundContext.js';
6
+ /**
7
+ This component can display text and change its style to make it bold, underlined, italic, or strikethrough.
8
+ */
9
+ export default function Text({ color, backgroundColor, dimColor = false, bold = false, italic = false, underline = false, strikethrough = false, inverse = false, wrap = 'wrap', children, 'aria-label': ariaLabel, 'aria-hidden': ariaHidden = false, }) {
10
+ const { isScreenReaderEnabled } = useContext(accessibilityContext);
11
+ const inheritedBackgroundColor = useContext(backgroundContext);
12
+ const childrenOrAriaLabel = isScreenReaderEnabled && ariaLabel ? ariaLabel : children;
13
+ if (childrenOrAriaLabel === undefined || childrenOrAriaLabel === null) {
14
+ return null;
15
+ }
16
+ const transform = (children) => {
17
+ if (dimColor) {
18
+ children = chalk.dim(children);
19
+ }
20
+ if (color) {
21
+ children = colorize(children, color, 'foreground');
22
+ }
23
+ // Use explicit backgroundColor if provided, otherwise use inherited from parent Box
24
+ const effectiveBackgroundColor = backgroundColor ?? inheritedBackgroundColor;
25
+ if (effectiveBackgroundColor) {
26
+ children = colorize(children, effectiveBackgroundColor, 'background');
27
+ }
28
+ if (bold) {
29
+ children = chalk.bold(children);
30
+ }
31
+ if (italic) {
32
+ children = chalk.italic(children);
33
+ }
34
+ if (underline) {
35
+ children = chalk.underline(children);
36
+ }
37
+ if (strikethrough) {
38
+ children = chalk.strikethrough(children);
39
+ }
40
+ if (inverse) {
41
+ children = chalk.inverse(children);
42
+ }
43
+ return children;
44
+ };
45
+ if (isScreenReaderEnabled && ariaHidden) {
46
+ return null;
47
+ }
48
+ return (React.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: 'row', textWrap: wrap }, internal_transform: transform }, isScreenReaderEnabled && ariaLabel ? ariaLabel : children));
49
+ }
50
+ //# sourceMappingURL=Text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.js","sourceRoot":"","sources":["../../src/components/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,UAAU,EAAiB,MAAM,OAAO,CAAC;AACxD,OAAO,KAAiC,MAAM,OAAO,CAAC;AAEtD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AA6DzD;;EAEE;AACF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC5B,KAAK,EACL,eAAe,EACf,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,KAAK,EACZ,MAAM,GAAG,KAAK,EACd,SAAS,GAAG,KAAK,EACjB,aAAa,GAAG,KAAK,EACrB,OAAO,GAAG,KAAK,EACf,IAAI,GAAG,MAAM,EACb,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,GAAG,KAAK,GAC1B;IACP,MAAM,EAAC,qBAAqB,EAAC,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjE,MAAM,wBAAwB,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,mBAAmB,GACxB,qBAAqB,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;IAE3D,IAAI,mBAAmB,KAAK,SAAS,IAAI,mBAA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EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAC,EACzE,kBAAkB,EAAE,SAAS,IAE5B,qBAAqB,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAChD,CACX,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import React, { type ReactNode } from 'react';
2
+ export type Props = {
3
+ /**
4
+ Screen-reader-specific text to output. If this is set, all children will be ignored.
5
+ */
6
+ readonly accessibilityLabel?: string;
7
+ /**
8
+ Function that transforms children output. It accepts children and must return transformed children as well.
9
+ */
10
+ readonly transform: (children: string, index: number) => string;
11
+ readonly children?: ReactNode;
12
+ };
13
+ /**
14
+ Transform a string representation of React components before they're written to output. For example, you might want to apply a gradient to text, add a clickable link, or create some text effects. These use cases can't accept React nodes as input; they expect a string. That's what the <Transform> component does: it gives you an output string of its child components and lets you transform it in any way.
15
+ */
16
+ export default function Transform({ children, transform, accessibilityLabel, }: Props): React.JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ import React, { useContext } from 'react';
2
+ import { accessibilityContext } from './AccessibilityContext.js';
3
+ /**
4
+ Transform a string representation of React components before they're written to output. For example, you might want to apply a gradient to text, add a clickable link, or create some text effects. These use cases can't accept React nodes as input; they expect a string. That's what the <Transform> component does: it gives you an output string of its child components and lets you transform it in any way.
5
+ */
6
+ export default function Transform({ children, transform, accessibilityLabel, }) {
7
+ const { isScreenReaderEnabled } = useContext(accessibilityContext);
8
+ if (children === undefined || children === null) {
9
+ return null;
10
+ }
11
+ return (React.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: 'row' }, internal_transform: transform }, isScreenReaderEnabled && accessibilityLabel
12
+ ? accessibilityLabel
13
+ : children));
14
+ }
15
+ //# sourceMappingURL=Transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/components/Transform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,UAAU,EAAiB,MAAM,OAAO,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAgB/D;;EAEE;AACF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,QAAQ,EACR,SAAS,EACT,kBAAkB,GACX;IACP,MAAM,EAAC,qBAAqB,EAAC,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAEjE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CACN,kCACC,KAAK,EAAE,EAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAC,EACzD,kBAAkB,EAAE,SAAS,IAE5B,qBAAqB,IAAI,kBAAkB;QAC3C,CAAC,CAAC,kBAAkB;QACpB,CAAC,CAAC,QAAQ,CACD,CACX,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ // Ignoring missing types error to avoid adding another dependency for this hack to work
2
+ import ws from 'ws';
3
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
4
+ const customGlobal = global;
5
+ // These things must exist before importing `react-devtools-core`
6
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
7
+ customGlobal.WebSocket ||= ws;
8
+ customGlobal.window ||= global;
9
+ customGlobal.self ||= global;
10
+ // Filter out Ink's internal components from devtools for a cleaner view.
11
+ // Also, ince `react-devtools-shared` package isn't published on npm, we can't
12
+ // use its types, that's why there are hard-coded values in `type` fields below.
13
+ // See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24
14
+ customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
15
+ {
16
+ // ComponentFilterElementType
17
+ type: 1,
18
+ // ElementTypeHostComponent
19
+ value: 7,
20
+ isEnabled: true,
21
+ },
22
+ {
23
+ // ComponentFilterDisplayName
24
+ type: 2,
25
+ value: 'InternalApp',
26
+ isEnabled: true,
27
+ isValid: true,
28
+ },
29
+ {
30
+ // ComponentFilterDisplayName
31
+ type: 2,
32
+ value: 'InternalAppContext',
33
+ isEnabled: true,
34
+ isValid: true,
35
+ },
36
+ {
37
+ // ComponentFilterDisplayName
38
+ type: 2,
39
+ value: 'InternalStdoutContext',
40
+ isEnabled: true,
41
+ isValid: true,
42
+ },
43
+ {
44
+ // ComponentFilterDisplayName
45
+ type: 2,
46
+ value: 'InternalStderrContext',
47
+ isEnabled: true,
48
+ isValid: true,
49
+ },
50
+ {
51
+ // ComponentFilterDisplayName
52
+ type: 2,
53
+ value: 'InternalStdinContext',
54
+ isEnabled: true,
55
+ isValid: true,
56
+ },
57
+ {
58
+ // ComponentFilterDisplayName
59
+ type: 2,
60
+ value: 'InternalFocusContext',
61
+ isEnabled: true,
62
+ isValid: true,
63
+ },
64
+ ];
65
+ //# sourceMappingURL=devtools-window-polyfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools-window-polyfill.js","sourceRoot":"","sources":["../src/devtools-window-polyfill.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,mEAAmE;AACnE,MAAM,YAAY,GAAG,MAAa,CAAC;AAEnC,iEAAiE;AAEjE,mEAAmE;AACnE,YAAY,CAAC,SAAS,KAAK,EAAE,CAAC;AAE9B,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC;AAE/B,YAAY,CAAC,IAAI,KAAK,MAAM,CAAC;AAE7B,yEAAyE;AACzE,8EAA8E;AAC9E,gFAAgF;AAChF,sIAAsI;AACtI,YAAY,CAAC,MAAM,CAAC,oCAAoC,GAAG;IAC1D;QACC,6BAA6B;QAC7B,IAAI,EAAE,CAAC;QACP,2BAA2B;QAC3B,KAAK,EAAE,CAAC;QACR,SAAS,EAAE,IAAI;KACf;IACD;QACC,6BAA6B;QAC7B,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,aAAa;QACpB,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;KACb;IACD;QACC,6BAA6B;QAC7B,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,oBAAoB;QAC3B,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;KACb;IACD;QACC,6BAA6B;QAC7B,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,uBAAuB;QAC9B,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;KACb;IACD;QACC,6BAA6B;QAC7B,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,uBAAuB;QAC9B,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;KACb;IACD;QACC,6BAA6B;QAC7B,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,sBAAsB;QAC7B,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;KACb;IACD;QACC,6BAA6B;QAC7B,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,sBAAsB;QAC7B,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;KACb;CACD,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=devtools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools.js","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":""}