freeink 6.2.3-freeink.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/LICENSE +9 -0
  2. package/NOTICE.md +18 -0
  3. package/README.md +62 -0
  4. package/UPSTREAM.md +15 -0
  5. package/build/colorize.d.ts +3 -0
  6. package/build/colorize.js +48 -0
  7. package/build/colorize.js.map +1 -0
  8. package/build/components/AccessibilityContext.d.ts +3 -0
  9. package/build/components/AccessibilityContext.js +5 -0
  10. package/build/components/AccessibilityContext.js.map +1 -0
  11. package/build/components/App.d.ts +59 -0
  12. package/build/components/App.js +286 -0
  13. package/build/components/App.js.map +1 -0
  14. package/build/components/AppContext.d.ts +11 -0
  15. package/build/components/AppContext.js +11 -0
  16. package/build/components/AppContext.js.map +1 -0
  17. package/build/components/BackgroundContext.d.ts +4 -0
  18. package/build/components/BackgroundContext.js +3 -0
  19. package/build/components/BackgroundContext.js.map +1 -0
  20. package/build/components/Box.d.ts +117 -0
  21. package/build/components/Box.js +34 -0
  22. package/build/components/Box.js.map +1 -0
  23. package/build/components/ErrorOverview.d.ts +6 -0
  24. package/build/components/ErrorOverview.js +84 -0
  25. package/build/components/ErrorOverview.js.map +1 -0
  26. package/build/components/FocusContext.d.ts +16 -0
  27. package/build/components/FocusContext.js +17 -0
  28. package/build/components/FocusContext.js.map +1 -0
  29. package/build/components/Newline.d.ts +13 -0
  30. package/build/components/Newline.js +8 -0
  31. package/build/components/Newline.js.map +1 -0
  32. package/build/components/Spacer.d.ts +6 -0
  33. package/build/components/Spacer.js +10 -0
  34. package/build/components/Spacer.js.map +1 -0
  35. package/build/components/Static.d.ts +31 -0
  36. package/build/components/Static.js +33 -0
  37. package/build/components/Static.js.map +1 -0
  38. package/build/components/StderrContext.d.ts +17 -0
  39. package/build/components/StderrContext.js +13 -0
  40. package/build/components/StderrContext.js.map +1 -0
  41. package/build/components/StdinContext.d.ts +23 -0
  42. package/build/components/StdinContext.js +19 -0
  43. package/build/components/StdinContext.js.map +1 -0
  44. package/build/components/StdoutContext.d.ts +17 -0
  45. package/build/components/StdoutContext.js +13 -0
  46. package/build/components/StdoutContext.js.map +1 -0
  47. package/build/components/Text.d.ts +57 -0
  48. package/build/components/Text.js +50 -0
  49. package/build/components/Text.js.map +1 -0
  50. package/build/components/Transform.d.ts +20 -0
  51. package/build/components/Transform.js +18 -0
  52. package/build/components/Transform.js.map +1 -0
  53. package/build/devtools-window-polyfill.d.ts +1 -0
  54. package/build/devtools-window-polyfill.js +65 -0
  55. package/build/devtools-window-polyfill.js.map +1 -0
  56. package/build/devtools.d.ts +1 -0
  57. package/build/devtools.js +9 -0
  58. package/build/devtools.js.map +1 -0
  59. package/build/dom.d.ts +56 -0
  60. package/build/dom.js +123 -0
  61. package/build/dom.js.map +1 -0
  62. package/build/get-max-width.d.ts +3 -0
  63. package/build/get-max-width.js +10 -0
  64. package/build/get-max-width.js.map +1 -0
  65. package/build/hooks/use-app.d.ts +5 -0
  66. package/build/hooks/use-app.js +8 -0
  67. package/build/hooks/use-app.js.map +1 -0
  68. package/build/hooks/use-focus-manager.d.ts +34 -0
  69. package/build/hooks/use-focus-manager.js +18 -0
  70. package/build/hooks/use-focus-manager.js.map +1 -0
  71. package/build/hooks/use-focus.d.ts +34 -0
  72. package/build/hooks/use-focus.js +47 -0
  73. package/build/hooks/use-focus.js.map +1 -0
  74. package/build/hooks/use-input.d.ts +97 -0
  75. package/build/hooks/use-input.js +96 -0
  76. package/build/hooks/use-input.js.map +1 -0
  77. package/build/hooks/use-is-screen-reader-enabled.d.ts +6 -0
  78. package/build/hooks/use-is-screen-reader-enabled.js +12 -0
  79. package/build/hooks/use-is-screen-reader-enabled.js.map +1 -0
  80. package/build/hooks/use-stderr.d.ts +5 -0
  81. package/build/hooks/use-stderr.js +8 -0
  82. package/build/hooks/use-stderr.js.map +1 -0
  83. package/build/hooks/use-stdin.d.ts +5 -0
  84. package/build/hooks/use-stdin.js +8 -0
  85. package/build/hooks/use-stdin.js.map +1 -0
  86. package/build/hooks/use-stdout.d.ts +5 -0
  87. package/build/hooks/use-stdout.js +8 -0
  88. package/build/hooks/use-stdout.js.map +1 -0
  89. package/build/index.d.ts +28 -0
  90. package/build/index.js +17 -0
  91. package/build/index.js.map +1 -0
  92. package/build/ink.d.ts +40 -0
  93. package/build/ink.js +295 -0
  94. package/build/ink.js.map +1 -0
  95. package/build/instances.d.ts +3 -0
  96. package/build/instances.js +8 -0
  97. package/build/instances.js.map +1 -0
  98. package/build/log-update.d.ts +13 -0
  99. package/build/log-update.js +42 -0
  100. package/build/log-update.js.map +1 -0
  101. package/build/measure-element.d.ts +16 -0
  102. package/build/measure-element.js +9 -0
  103. package/build/measure-element.js.map +1 -0
  104. package/build/measure-text.d.ts +6 -0
  105. package/build/measure-text.js +21 -0
  106. package/build/measure-text.js.map +1 -0
  107. package/build/output.d.ts +35 -0
  108. package/build/output.js +150 -0
  109. package/build/output.js.map +1 -0
  110. package/build/parse-keypress.d.ts +14 -0
  111. package/build/parse-keypress.js +225 -0
  112. package/build/parse-keypress.js.map +1 -0
  113. package/build/reconciler.d.ts +4 -0
  114. package/build/reconciler.js +254 -0
  115. package/build/reconciler.js.map +1 -0
  116. package/build/render-background.d.ts +4 -0
  117. package/build/render-background.js +25 -0
  118. package/build/render-background.js.map +1 -0
  119. package/build/render-border.d.ts +4 -0
  120. package/build/render-border.js +73 -0
  121. package/build/render-border.js.map +1 -0
  122. package/build/render-node-to-output.d.ts +14 -0
  123. package/build/render-node-to-output.js +147 -0
  124. package/build/render-node-to-output.js.map +1 -0
  125. package/build/render.d.ts +70 -0
  126. package/build/render.js +48 -0
  127. package/build/render.js.map +1 -0
  128. package/build/renderer.d.ts +8 -0
  129. package/build/renderer.js +55 -0
  130. package/build/renderer.js.map +1 -0
  131. package/build/squash-text-nodes.d.ts +3 -0
  132. package/build/squash-text-nodes.js +35 -0
  133. package/build/squash-text-nodes.js.map +1 -0
  134. package/build/styles.d.ts +249 -0
  135. package/build/styles.js +232 -0
  136. package/build/styles.js.map +1 -0
  137. package/build/wrap-text.d.ts +3 -0
  138. package/build/wrap-text.js +31 -0
  139. package/build/wrap-text.js.map +1 -0
  140. package/package.json +194 -0
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Vadym Demedes <vadimdemedes@hey.com> (github.com/vadimdemedes)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/NOTICE.md ADDED
@@ -0,0 +1,18 @@
1
+ # Notice
2
+
3
+ FreeInk is a neutral redistribution of Ink.
4
+
5
+ Upstream project:
6
+
7
+ - Name: Ink
8
+ - URL: <https://github.com/vadimdemedes/ink>
9
+ - npm package: `ink@6.2.3`
10
+ - Git tag: `v6.2.3`
11
+ - Git commit: `48dde206c7f465ca54433c98102e4e9d1d13bf33`
12
+ - License: MIT
13
+
14
+ The original Ink copyright and MIT license text are preserved in [LICENSE](LICENSE).
15
+
16
+ This FreeInk release base changes package identity and documentation only. Runtime source behavior is intended to remain equivalent to the upstream source at the tag and commit listed above.
17
+
18
+ FreeInk is independent from and not endorsed by the original Ink maintainers.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # FreeInk
2
+
3
+ FreeInk is a neutral redistribution of [Ink](https://github.com/vadimdemedes/ink), a React renderer for command-line interfaces.
4
+
5
+ This package is based on upstream `ink@6.2.3`, tag `v6.2.3`, commit `48dde206c7f465ca54433c98102e4e9d1d13bf33`.
6
+ The first FreeInk package version is `6.2.3-freeink.0`.
7
+
8
+ FreeInk keeps the upstream MIT license and attribution. Changes in this release base are limited to package identity and documentation for a reproducible redistribution.
9
+
10
+ FreeInk is independent from and not endorsed by the original Ink maintainers.
11
+
12
+ ## Install
13
+
14
+ Install FreeInk directly:
15
+
16
+ ```sh
17
+ npm install freeink react
18
+ ```
19
+
20
+ Use FreeInk as an npm alias replacement for Ink:
21
+
22
+ ```json
23
+ {
24
+ "dependencies": {
25
+ "ink": "npm:freeink@6.2.3-freeink.0",
26
+ "react": "^19.1.0"
27
+ }
28
+ }
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ When installed as `freeink`:
34
+
35
+ ```jsx
36
+ import React from 'react';
37
+ import {render, Text} from 'freeink';
38
+
39
+ const App = () => <Text color="green">Hello from FreeInk</Text>;
40
+
41
+ render(<App />);
42
+ ```
43
+
44
+ When installed through the npm alias shown above, existing imports can continue to use `ink`:
45
+
46
+ ```jsx
47
+ import React from 'react';
48
+ import {render, Text} from 'ink';
49
+
50
+ const App = () => <Text color="green">Hello from FreeInk</Text>;
51
+
52
+ render(<App />);
53
+ ```
54
+
55
+ ## Upstream
56
+
57
+ - Upstream project: <https://github.com/vadimdemedes/ink>
58
+ - Upstream npm package: `ink@6.2.3`
59
+ - Upstream tag: `v6.2.3`
60
+ - Upstream commit: `48dde206c7f465ca54433c98102e4e9d1d13bf33`
61
+
62
+ See [UPSTREAM.md](UPSTREAM.md), [NOTICE.md](NOTICE.md), and [RELEASE_PROCESS.md](RELEASE_PROCESS.md) for provenance and release details.
package/UPSTREAM.md ADDED
@@ -0,0 +1,15 @@
1
+ # Upstream Source
2
+
3
+ FreeInk `6.2.3-freeink.0` is based on:
4
+
5
+ - Upstream repository: <https://github.com/vadimdemedes/ink>
6
+ - Upstream npm package: `ink@6.2.3`
7
+ - Upstream tag: `v6.2.3`
8
+ - Upstream commit: `48dde206c7f465ca54433c98102e4e9d1d13bf33`
9
+ - License: MIT
10
+
11
+ The upstream source was checked out at `v6.2.3` and transferred into this repository without the upstream `.git` directory.
12
+
13
+ Future updates must record the new upstream npm version, tag, commit, and release-review result before any FreeInk package is published.
14
+
15
+ TODO before public repository metadata is added to npm: set `repository`, `homepage`, and `bugs` only after the GitHub repository is public and stable.
@@ -0,0 +1,3 @@
1
+ type ColorType = 'foreground' | 'background';
2
+ declare const colorize: (str: string, color: string | undefined, type: ColorType) => string;
3
+ export default colorize;
@@ -0,0 +1,48 @@
1
+ import chalk from 'chalk';
2
+ const rgbRegex = /^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/;
3
+ const ansiRegex = /^ansi256\(\s?(\d+)\s?\)$/;
4
+ const isNamedColor = (color) => {
5
+ return color in chalk;
6
+ };
7
+ const colorize = (str, color, type) => {
8
+ if (!color) {
9
+ return str;
10
+ }
11
+ if (isNamedColor(color)) {
12
+ if (type === 'foreground') {
13
+ return chalk[color](str);
14
+ }
15
+ const methodName = `bg${color[0].toUpperCase() + color.slice(1)}`;
16
+ return chalk[methodName](str);
17
+ }
18
+ if (color.startsWith('#')) {
19
+ return type === 'foreground'
20
+ ? chalk.hex(color)(str)
21
+ : chalk.bgHex(color)(str);
22
+ }
23
+ if (color.startsWith('ansi256')) {
24
+ const matches = ansiRegex.exec(color);
25
+ if (!matches) {
26
+ return str;
27
+ }
28
+ const value = Number(matches[1]);
29
+ return type === 'foreground'
30
+ ? chalk.ansi256(value)(str)
31
+ : chalk.bgAnsi256(value)(str);
32
+ }
33
+ if (color.startsWith('rgb')) {
34
+ const matches = rgbRegex.exec(color);
35
+ if (!matches) {
36
+ return str;
37
+ }
38
+ const firstValue = Number(matches[1]);
39
+ const secondValue = Number(matches[2]);
40
+ const thirdValue = Number(matches[3]);
41
+ return type === 'foreground'
42
+ ? chalk.rgb(firstValue, secondValue, thirdValue)(str)
43
+ : chalk.bgRgb(firstValue, secondValue, thirdValue)(str);
44
+ }
45
+ return str;
46
+ };
47
+ export default colorize;
48
+ //# sourceMappingURL=colorize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorize.js","sourceRoot":"","sources":["../src/colorize.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAIhF,MAAM,QAAQ,GAAG,wCAAwC,CAAC;AAC1D,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAE7C,MAAM,YAAY,GAAG,CAAC,KAAa,EAAgC,EAAE;IACpE,OAAO,KAAK,IAAI,KAAK,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAChB,GAAW,EACX,KAAyB,EACzB,IAAe,EACN,EAAE;IACX,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,UAAU,GAAG,KAClB,KAAK,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CACxC,EAAyB,CAAC;QAE1B,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,KAAK,YAAY;YAC3B,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;YACvB,CAAC,CAAC,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AAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const accessibilityContext: import("react").Context<{
2
+ isScreenReaderEnabled: boolean;
3
+ }>;
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+ export const accessibilityContext = createContext({
3
+ isScreenReaderEnabled: false,
4
+ });
5
+ //# sourceMappingURL=AccessibilityContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessibilityContext.js","sourceRoot":"","sources":["../../src/components/AccessibilityContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;IACjD,qBAAqB,EAAE,KAAK;CAC5B,CAAC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import React, { PureComponent, type ReactNode } from 'react';
3
+ type Props = {
4
+ readonly children: ReactNode;
5
+ readonly stdin: NodeJS.ReadStream;
6
+ readonly stdout: NodeJS.WriteStream;
7
+ readonly stderr: NodeJS.WriteStream;
8
+ readonly writeToStdout: (data: string) => void;
9
+ readonly writeToStderr: (data: string) => void;
10
+ readonly exitOnCtrlC: boolean;
11
+ readonly onExit: (error?: Error) => void;
12
+ };
13
+ type State = {
14
+ readonly isFocusEnabled: boolean;
15
+ readonly activeFocusId?: string;
16
+ readonly focusables: Focusable[];
17
+ readonly error?: Error;
18
+ };
19
+ type Focusable = {
20
+ readonly id: string;
21
+ readonly isActive: boolean;
22
+ };
23
+ export default class App extends PureComponent<Props, State> {
24
+ static displayName: string;
25
+ static getDerivedStateFromError(error: Error): {
26
+ error: Error;
27
+ };
28
+ state: {
29
+ isFocusEnabled: boolean;
30
+ activeFocusId: undefined;
31
+ focusables: never[];
32
+ error: undefined;
33
+ };
34
+ rawModeEnabledCount: number;
35
+ internal_eventEmitter: EventEmitter<[never]>;
36
+ isRawModeSupported(): boolean;
37
+ render(): React.JSX.Element;
38
+ componentDidMount(): void;
39
+ componentWillUnmount(): void;
40
+ componentDidCatch(error: Error): void;
41
+ handleSetRawMode: (isEnabled: boolean) => void;
42
+ handleReadable: () => void;
43
+ handleInput: (input: string) => void;
44
+ handleExit: (error?: Error) => void;
45
+ enableFocus: () => void;
46
+ disableFocus: () => void;
47
+ focus: (id: string) => void;
48
+ focusNext: () => void;
49
+ focusPrevious: () => void;
50
+ addFocusable: (id: string, { autoFocus }: {
51
+ autoFocus: boolean;
52
+ }) => void;
53
+ removeFocusable: (id: string) => void;
54
+ activateFocusable: (id: string) => void;
55
+ deactivateFocusable: (id: string) => void;
56
+ findNextFocusable: (state: State) => string | undefined;
57
+ findPreviousFocusable: (state: State) => string | undefined;
58
+ }
59
+ export {};
@@ -0,0 +1,286 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import process from 'node:process';
3
+ import React, { PureComponent } from 'react';
4
+ import cliCursor from 'cli-cursor';
5
+ import AppContext from './AppContext.js';
6
+ import StdinContext from './StdinContext.js';
7
+ import StdoutContext from './StdoutContext.js';
8
+ import StderrContext from './StderrContext.js';
9
+ import FocusContext from './FocusContext.js';
10
+ import ErrorOverview from './ErrorOverview.js';
11
+ const tab = '\t';
12
+ const shiftTab = '\u001B[Z';
13
+ const escape = '\u001B';
14
+ // Root component for all Ink apps
15
+ // It renders stdin and stdout contexts, so that children can access them if needed
16
+ // It also handles Ctrl+C exiting and cursor visibility
17
+ export default class App extends PureComponent {
18
+ static displayName = 'InternalApp';
19
+ static getDerivedStateFromError(error) {
20
+ return { error };
21
+ }
22
+ state = {
23
+ isFocusEnabled: true,
24
+ activeFocusId: undefined,
25
+ focusables: [],
26
+ error: undefined,
27
+ };
28
+ // Count how many components enabled raw mode to avoid disabling
29
+ // raw mode until all components don't need it anymore
30
+ rawModeEnabledCount = 0;
31
+ // eslint-disable-next-line @typescript-eslint/naming-convention
32
+ internal_eventEmitter = new EventEmitter();
33
+ // Determines if TTY is supported on the provided stdin
34
+ isRawModeSupported() {
35
+ return this.props.stdin.isTTY;
36
+ }
37
+ render() {
38
+ return (React.createElement(AppContext.Provider
39
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
40
+ , {
41
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
42
+ value: {
43
+ exit: this.handleExit,
44
+ } },
45
+ React.createElement(StdinContext.Provider
46
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
47
+ , {
48
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
49
+ value: {
50
+ stdin: this.props.stdin,
51
+ setRawMode: this.handleSetRawMode,
52
+ isRawModeSupported: this.isRawModeSupported(),
53
+ // eslint-disable-next-line @typescript-eslint/naming-convention
54
+ internal_exitOnCtrlC: this.props.exitOnCtrlC,
55
+ // eslint-disable-next-line @typescript-eslint/naming-convention
56
+ internal_eventEmitter: this.internal_eventEmitter,
57
+ } },
58
+ React.createElement(StdoutContext.Provider
59
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
60
+ , {
61
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
62
+ value: {
63
+ stdout: this.props.stdout,
64
+ write: this.props.writeToStdout,
65
+ } },
66
+ React.createElement(StderrContext.Provider
67
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
68
+ , {
69
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
70
+ value: {
71
+ stderr: this.props.stderr,
72
+ write: this.props.writeToStderr,
73
+ } },
74
+ React.createElement(FocusContext.Provider
75
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
76
+ , {
77
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
78
+ value: {
79
+ activeId: this.state.activeFocusId,
80
+ add: this.addFocusable,
81
+ remove: this.removeFocusable,
82
+ activate: this.activateFocusable,
83
+ deactivate: this.deactivateFocusable,
84
+ enableFocus: this.enableFocus,
85
+ disableFocus: this.disableFocus,
86
+ focusNext: this.focusNext,
87
+ focusPrevious: this.focusPrevious,
88
+ focus: this.focus,
89
+ } }, this.state.error ? (React.createElement(ErrorOverview, { error: this.state.error })) : (this.props.children)))))));
90
+ }
91
+ componentDidMount() {
92
+ cliCursor.hide(this.props.stdout);
93
+ }
94
+ componentWillUnmount() {
95
+ cliCursor.show(this.props.stdout);
96
+ // ignore calling setRawMode on an handle stdin it cannot be called
97
+ if (this.isRawModeSupported()) {
98
+ this.handleSetRawMode(false);
99
+ }
100
+ }
101
+ componentDidCatch(error) {
102
+ this.handleExit(error);
103
+ }
104
+ handleSetRawMode = (isEnabled) => {
105
+ const { stdin } = this.props;
106
+ if (!this.isRawModeSupported()) {
107
+ if (stdin === process.stdin) {
108
+ throw new Error('Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
109
+ }
110
+ else {
111
+ throw new Error('Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
112
+ }
113
+ }
114
+ stdin.setEncoding('utf8');
115
+ if (isEnabled) {
116
+ // Ensure raw mode is enabled only once
117
+ if (this.rawModeEnabledCount === 0) {
118
+ stdin.ref();
119
+ stdin.setRawMode(true);
120
+ stdin.addListener('readable', this.handleReadable);
121
+ }
122
+ this.rawModeEnabledCount++;
123
+ return;
124
+ }
125
+ // Disable raw mode only when no components left that are using it
126
+ if (--this.rawModeEnabledCount === 0) {
127
+ stdin.setRawMode(false);
128
+ stdin.removeListener('readable', this.handleReadable);
129
+ stdin.unref();
130
+ }
131
+ };
132
+ handleReadable = () => {
133
+ let chunk;
134
+ // eslint-disable-next-line @typescript-eslint/ban-types
135
+ while ((chunk = this.props.stdin.read()) !== null) {
136
+ this.handleInput(chunk);
137
+ this.internal_eventEmitter.emit('input', chunk);
138
+ }
139
+ };
140
+ handleInput = (input) => {
141
+ // Exit on Ctrl+C
142
+ // eslint-disable-next-line unicorn/no-hex-escape
143
+ if (input === '\x03' && this.props.exitOnCtrlC) {
144
+ this.handleExit();
145
+ }
146
+ // Reset focus when there's an active focused component on Esc
147
+ if (input === escape && this.state.activeFocusId) {
148
+ this.setState({
149
+ activeFocusId: undefined,
150
+ });
151
+ }
152
+ if (this.state.isFocusEnabled && this.state.focusables.length > 0) {
153
+ if (input === tab) {
154
+ this.focusNext();
155
+ }
156
+ if (input === shiftTab) {
157
+ this.focusPrevious();
158
+ }
159
+ }
160
+ };
161
+ handleExit = (error) => {
162
+ if (this.isRawModeSupported()) {
163
+ this.handleSetRawMode(false);
164
+ }
165
+ this.props.onExit(error);
166
+ };
167
+ enableFocus = () => {
168
+ this.setState({
169
+ isFocusEnabled: true,
170
+ });
171
+ };
172
+ disableFocus = () => {
173
+ this.setState({
174
+ isFocusEnabled: false,
175
+ });
176
+ };
177
+ focus = (id) => {
178
+ this.setState(previousState => {
179
+ const hasFocusableId = previousState.focusables.some(focusable => focusable?.id === id);
180
+ if (!hasFocusableId) {
181
+ return previousState;
182
+ }
183
+ return { activeFocusId: id };
184
+ });
185
+ };
186
+ focusNext = () => {
187
+ this.setState(previousState => {
188
+ const firstFocusableId = previousState.focusables.find(focusable => focusable.isActive)?.id;
189
+ const nextFocusableId = this.findNextFocusable(previousState);
190
+ return {
191
+ activeFocusId: nextFocusableId ?? firstFocusableId,
192
+ };
193
+ });
194
+ };
195
+ focusPrevious = () => {
196
+ this.setState(previousState => {
197
+ const lastFocusableId = previousState.focusables.findLast(focusable => focusable.isActive)?.id;
198
+ const previousFocusableId = this.findPreviousFocusable(previousState);
199
+ return {
200
+ activeFocusId: previousFocusableId ?? lastFocusableId,
201
+ };
202
+ });
203
+ };
204
+ addFocusable = (id, { autoFocus }) => {
205
+ this.setState(previousState => {
206
+ let nextFocusId = previousState.activeFocusId;
207
+ if (!nextFocusId && autoFocus) {
208
+ nextFocusId = id;
209
+ }
210
+ return {
211
+ activeFocusId: nextFocusId,
212
+ focusables: [
213
+ ...previousState.focusables,
214
+ {
215
+ id,
216
+ isActive: true,
217
+ },
218
+ ],
219
+ };
220
+ });
221
+ };
222
+ removeFocusable = (id) => {
223
+ this.setState(previousState => ({
224
+ activeFocusId: previousState.activeFocusId === id
225
+ ? undefined
226
+ : previousState.activeFocusId,
227
+ focusables: previousState.focusables.filter(focusable => {
228
+ return focusable.id !== id;
229
+ }),
230
+ }));
231
+ };
232
+ activateFocusable = (id) => {
233
+ this.setState(previousState => ({
234
+ focusables: previousState.focusables.map(focusable => {
235
+ if (focusable.id !== id) {
236
+ return focusable;
237
+ }
238
+ return {
239
+ id,
240
+ isActive: true,
241
+ };
242
+ }),
243
+ }));
244
+ };
245
+ deactivateFocusable = (id) => {
246
+ this.setState(previousState => ({
247
+ activeFocusId: previousState.activeFocusId === id
248
+ ? undefined
249
+ : previousState.activeFocusId,
250
+ focusables: previousState.focusables.map(focusable => {
251
+ if (focusable.id !== id) {
252
+ return focusable;
253
+ }
254
+ return {
255
+ id,
256
+ isActive: false,
257
+ };
258
+ }),
259
+ }));
260
+ };
261
+ findNextFocusable = (state) => {
262
+ const activeIndex = state.focusables.findIndex(focusable => {
263
+ return focusable.id === state.activeFocusId;
264
+ });
265
+ for (let index = activeIndex + 1; index < state.focusables.length; index++) {
266
+ const focusable = state.focusables[index];
267
+ if (focusable?.isActive) {
268
+ return focusable.id;
269
+ }
270
+ }
271
+ return undefined;
272
+ };
273
+ findPreviousFocusable = (state) => {
274
+ const activeIndex = state.focusables.findIndex(focusable => {
275
+ return focusable.id === state.activeFocusId;
276
+ });
277
+ for (let index = activeIndex - 1; index >= 0; index--) {
278
+ const focusable = state.focusables[index];
279
+ if (focusable?.isActive) {
280
+ return focusable.id;
281
+ }
282
+ }
283
+ return undefined;
284
+ };
285
+ }
286
+ //# sourceMappingURL=App.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App.js","sourceRoot":"","sources":["../../src/components/App.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,KAAK,EAAE,EAAC,aAAa,EAAiB,MAAM,OA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AAC,CAAC;QAEH,KACC,IAAI,KAAK,GAAG,WAAW,GAAG,CAAC,EAC3B,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAC/B,KAAK,EAAE,EACN,CAAC;YACF,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAE1C,IAAI,SAAS,EAAE,QAAQ,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC,EAAE,CAAC;YACrB,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC;IAEF,qBAAqB,GAAG,CAAC,KAAY,EAAsB,EAAE;QAC5D,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;YAC1D,OAAO,SAAS,CAAC,EAAE,KAAK,KAAK,CAAC,aAAa,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,KAAK,IAAI,KAAK,GAAG,WAAW,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAE1C,IAAI,SAAS,EAAE,QAAQ,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC,EAAE,CAAC;YACrB,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type Props = {
2
+ /**
3
+ * Exit (unmount) the whole Ink app.
4
+ */
5
+ readonly exit: (error?: Error) => void;
6
+ };
7
+ /**
8
+ * `AppContext` is a React context, which exposes a method to manually exit the app (unmount).
9
+ */
10
+ declare const AppContext: import("react").Context<Props>;
11
+ export default AppContext;
@@ -0,0 +1,11 @@
1
+ import { createContext } from 'react';
2
+ /**
3
+ * `AppContext` is a React context, which exposes a method to manually exit the app (unmount).
4
+ */
5
+ // eslint-disable-next-line @typescript-eslint/naming-convention
6
+ const AppContext = createContext({
7
+ exit() { },
8
+ });
9
+ AppContext.displayName = 'InternalAppContext';
10
+ export default AppContext;
11
+ //# sourceMappingURL=AppContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppContext.js","sourceRoot":"","sources":["../../src/components/AppContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AASpC;;GAEG;AACH,gEAAgE;AAChE,MAAM,UAAU,GAAG,aAAa,CAAQ;IACvC,IAAI,KAAI,CAAC;CACT,CAAC,CAAC;AAEH,UAAU,CAAC,WAAW,GAAG,oBAAoB,CAAC;AAE9C,eAAe,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type LiteralUnion } from 'type-fest';
2
+ import { type ForegroundColorName } from 'ansi-styles';
3
+ export type BackgroundColor = LiteralUnion<ForegroundColorName, string>;
4
+ export declare const backgroundContext: import("react").Context<BackgroundColor | undefined>;
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ export const backgroundContext = createContext(undefined);
3
+ //# sourceMappingURL=BackgroundContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackgroundContext.js","sourceRoot":"","sources":["../../src/components/BackgroundContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAMpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAC7C,SAAS,CACT,CAAC"}