@nuvin/ink 6.6.7 → 7.0.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ansi-tokenizer.d.ts +38 -0
- package/build/ansi-tokenizer.d.ts.map +1 -0
- package/build/ansi-tokenizer.js +316 -0
- package/build/ansi-tokenizer.js.map +1 -0
- package/build/colorize.d.ts.map +1 -0
- package/build/components/AccessibilityContext.d.ts.map +1 -0
- package/build/components/AnimationContext.d.ts +9 -0
- package/build/components/AnimationContext.d.ts.map +1 -0
- package/build/components/AnimationContext.js +13 -0
- package/build/components/AnimationContext.js.map +1 -0
- package/build/components/App.d.ts +11 -49
- package/build/components/App.d.ts.map +1 -0
- package/build/components/App.js +412 -227
- package/build/components/App.js.map +1 -1
- package/build/components/AppContext.d.ts +33 -3
- package/build/components/AppContext.d.ts.map +1 -0
- package/build/components/AppContext.js +2 -1
- package/build/components/AppContext.js.map +1 -1
- package/build/components/BackgroundContext.d.ts.map +1 -0
- package/build/components/Box.d.ts +15 -8
- package/build/components/Box.d.ts.map +1 -0
- package/build/components/Box.js +12 -10
- package/build/components/Box.js.map +1 -1
- package/build/components/CursorContext.d.ts +11 -0
- package/build/components/CursorContext.d.ts.map +1 -0
- package/build/components/CursorContext.js +8 -0
- package/build/components/CursorContext.js.map +1 -0
- package/build/components/ErrorBoundary.d.ts +18 -0
- package/build/components/ErrorBoundary.d.ts.map +1 -0
- package/build/components/ErrorBoundary.js +23 -0
- package/build/components/ErrorBoundary.js.map +1 -0
- package/build/components/ErrorOverview.d.ts.map +1 -0
- package/build/components/ErrorOverview.js +6 -6
- package/build/components/ErrorOverview.js.map +1 -1
- package/build/components/FocusContext.d.ts.map +1 -0
- package/build/components/Newline.d.ts.map +1 -0
- package/build/components/Spacer.d.ts.map +1 -0
- package/build/components/Static.d.ts.map +1 -0
- package/build/components/Static.js.map +1 -1
- package/build/components/StderrContext.d.ts.map +1 -0
- package/build/components/StdinContext.d.ts +7 -1
- package/build/components/StdinContext.d.ts.map +1 -0
- package/build/components/StdinContext.js +1 -0
- package/build/components/StdinContext.js.map +1 -1
- package/build/components/StdoutContext.d.ts.map +1 -0
- package/build/components/Text.d.ts +1 -1
- package/build/components/Text.d.ts.map +1 -0
- package/build/components/Text.js +1 -1
- package/build/components/Text.js.map +1 -1
- package/build/components/Transform.d.ts +1 -1
- package/build/components/Transform.d.ts.map +1 -0
- package/build/cursor-helpers.d.ts +38 -0
- package/build/cursor-helpers.d.ts.map +1 -0
- package/build/cursor-helpers.js +56 -0
- package/build/cursor-helpers.js.map +1 -0
- package/build/devtools-window-polyfill.d.ts.map +1 -0
- package/build/devtools-window-polyfill.js +7 -4
- package/build/devtools-window-polyfill.js.map +1 -1
- package/build/devtools.d.ts.map +1 -0
- package/build/devtools.js +31 -6
- package/build/devtools.js.map +1 -1
- package/build/diagnostics.d.ts +5 -0
- package/build/diagnostics.d.ts.map +1 -0
- package/build/diagnostics.js +7 -0
- package/build/diagnostics.js.map +1 -0
- package/build/dom.d.ts +5 -1
- package/build/dom.d.ts.map +1 -0
- package/build/dom.js +20 -1
- package/build/dom.js.map +1 -1
- package/build/get-max-width.d.ts.map +1 -0
- package/build/hooks/use-animation.d.ts +49 -0
- package/build/hooks/use-animation.d.ts.map +1 -0
- package/build/hooks/use-animation.js +87 -0
- package/build/hooks/use-animation.js.map +1 -0
- package/build/hooks/use-app.d.ts +5 -2
- package/build/hooks/use-app.d.ts.map +1 -0
- package/build/hooks/use-app.js +1 -1
- package/build/hooks/use-box-metrics.d.ts +59 -0
- package/build/hooks/use-box-metrics.d.ts.map +1 -0
- package/build/hooks/use-box-metrics.js +88 -0
- package/build/hooks/use-box-metrics.js.map +1 -0
- package/build/hooks/use-cursor.d.ts +12 -0
- package/build/hooks/use-cursor.d.ts.map +1 -0
- package/build/hooks/use-cursor.js +29 -0
- package/build/hooks/use-cursor.js.map +1 -0
- package/build/hooks/use-focus-manager.d.ts +17 -2
- package/build/hooks/use-focus-manager.d.ts.map +1 -0
- package/build/hooks/use-focus-manager.js +2 -1
- package/build/hooks/use-focus-manager.js.map +1 -1
- package/build/hooks/use-focus.d.ts +2 -1
- package/build/hooks/use-focus.d.ts.map +1 -0
- package/build/hooks/use-focus.js +5 -4
- package/build/hooks/use-focus.js.map +1 -1
- package/build/hooks/use-input.d.ts +40 -1
- package/build/hooks/use-input.d.ts.map +1 -0
- package/build/hooks/use-input.js +65 -25
- package/build/hooks/use-input.js.map +1 -1
- package/build/hooks/use-is-screen-reader-enabled.d.ts +2 -1
- package/build/hooks/use-is-screen-reader-enabled.d.ts.map +1 -0
- package/build/hooks/use-is-screen-reader-enabled.js +2 -1
- package/build/hooks/use-is-screen-reader-enabled.js.map +1 -1
- package/build/hooks/use-paste.d.ts +35 -0
- package/build/hooks/use-paste.d.ts.map +1 -0
- package/build/hooks/use-paste.js +66 -0
- package/build/hooks/use-paste.js.map +1 -0
- package/build/hooks/use-stderr.d.ts +1 -1
- package/build/hooks/use-stderr.d.ts.map +1 -0
- package/build/hooks/use-stderr.js +1 -1
- package/build/hooks/use-stdin.d.ts +4 -2
- package/build/hooks/use-stdin.d.ts.map +1 -0
- package/build/hooks/use-stdin.js +2 -1
- package/build/hooks/use-stdin.js.map +1 -1
- package/build/hooks/use-stdout.d.ts +1 -1
- package/build/hooks/use-stdout.d.ts.map +1 -0
- package/build/hooks/use-stdout.js +1 -1
- package/build/hooks/use-window-size.d.ts +18 -0
- package/build/hooks/use-window-size.d.ts.map +1 -0
- package/build/hooks/use-window-size.js +22 -0
- package/build/hooks/use-window-size.js.map +1 -0
- package/build/index.d.ts +16 -1
- package/build/index.d.ts.map +1 -0
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build/ink.d.ts +94 -5
- package/build/ink.d.ts.map +1 -0
- package/build/ink.js +586 -81
- package/build/ink.js.map +1 -1
- package/build/input-parser.d.ts +10 -0
- package/build/input-parser.d.ts.map +1 -0
- package/build/input-parser.js +194 -0
- package/build/input-parser.js.map +1 -0
- package/build/instances.d.ts.map +1 -0
- package/build/kitty-keyboard.d.ts +23 -0
- package/build/kitty-keyboard.d.ts.map +1 -0
- package/build/kitty-keyboard.js +32 -0
- package/build/kitty-keyboard.js.map +1 -0
- package/build/log-update.d.ts +7 -1
- package/build/log-update.d.ts.map +1 -0
- package/build/log-update.js +181 -56
- package/build/log-update.js.map +1 -1
- package/build/measure-element.d.ts +15 -3
- package/build/measure-element.d.ts.map +1 -0
- package/build/measure-element.js +31 -5
- package/build/measure-element.js.map +1 -1
- package/build/measure-text.d.ts +2 -0
- package/build/measure-text.d.ts.map +1 -0
- package/build/measure-text.js +13 -11
- package/build/measure-text.js.map +1 -1
- package/build/output.d.ts +2 -1
- package/build/output.d.ts.map +1 -0
- package/build/output.js +62 -58
- package/build/output.js.map +1 -1
- package/build/parse-keypress.d.ts +9 -3
- package/build/parse-keypress.d.ts.map +1 -0
- package/build/parse-keypress.js +283 -13
- package/build/parse-keypress.js.map +1 -1
- package/build/reconciler.d.ts.map +1 -0
- package/build/reconciler.js +57 -37
- package/build/reconciler.js.map +1 -1
- package/build/render-background.d.ts.map +1 -0
- package/build/render-background.js +2 -0
- package/build/render-background.js.map +1 -1
- package/build/render-border.d.ts +1 -1
- package/build/render-border.d.ts.map +1 -0
- package/build/render-border.js +35 -24
- package/build/render-border.js.map +1 -1
- package/build/render-node-to-output.d.ts +1 -1
- package/build/render-node-to-output.d.ts.map +1 -0
- package/build/render-node-to-output.js +35 -18
- package/build/render-node-to-output.js.map +1 -1
- package/build/render-to-string.d.ts +38 -0
- package/build/render-to-string.d.ts.map +1 -0
- package/build/render-to-string.js +116 -0
- package/build/render-to-string.js.map +1 -0
- package/build/render.d.ts +91 -3
- package/build/render.d.ts.map +1 -0
- package/build/render.js +17 -5
- package/build/render.js.map +1 -1
- package/build/renderer.d.ts.map +1 -0
- package/build/sanitize-ansi.d.ts +2 -0
- package/build/sanitize-ansi.d.ts.map +1 -0
- package/build/sanitize-ansi.js +27 -0
- package/build/sanitize-ansi.js.map +1 -0
- package/build/squash-text-nodes.d.ts.map +1 -0
- package/build/squash-text-nodes.js +18 -1
- package/build/squash-text-nodes.js.map +1 -1
- package/build/styles.d.ts +75 -37
- package/build/styles.d.ts.map +1 -0
- package/build/styles.js +87 -44
- package/build/styles.js.map +1 -1
- package/build/utils.d.ts +9 -2
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +18 -3
- package/build/utils.js.map +1 -1
- package/build/wrap-text.d.ts +2 -0
- package/build/wrap-text.d.ts.map +1 -0
- package/build/wrap-text.js +21 -18
- package/build/wrap-text.js.map +1 -1
- package/build/write-synchronized.d.ts +4 -0
- package/build/write-synchronized.d.ts.map +1 -0
- package/build/write-synchronized.js +9 -0
- package/build/write-synchronized.js.map +1 -0
- package/package.json +46 -106
- package/readme.md +850 -64
- package/build/components/FixedLayout.d.ts +0 -12
- package/build/components/FixedLayout.js +0 -19
- package/build/components/FixedLayout.js.map +0 -1
- package/build/components/VirtualizedList.d.ts +0 -21
- package/build/components/VirtualizedList.js +0 -55
- package/build/components/VirtualizedList.js.map +0 -1
- package/build/hooks/use-mouse.d.ts +0 -15
- package/build/hooks/use-mouse.js +0 -121
- package/build/hooks/use-mouse.js.map +0 -1
- package/build/hooks/use-virtualization.d.ts +0 -19
- package/build/hooks/use-virtualization.js +0 -56
- package/build/hooks/use-virtualization.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { getWindowSize } from '../utils.js';
|
|
3
|
+
import useStdout from './use-stdout.js';
|
|
4
|
+
/**
|
|
5
|
+
A React hook that returns the current terminal window dimensions and re-renders the component whenever the terminal is resized.
|
|
6
|
+
*/
|
|
7
|
+
const useWindowSize = () => {
|
|
8
|
+
const { stdout } = useStdout();
|
|
9
|
+
const [size, setSize] = useState(() => getWindowSize(stdout));
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const onResize = () => {
|
|
12
|
+
setSize(getWindowSize(stdout));
|
|
13
|
+
};
|
|
14
|
+
stdout.on('resize', onResize);
|
|
15
|
+
return () => {
|
|
16
|
+
stdout.off('resize', onResize);
|
|
17
|
+
};
|
|
18
|
+
}, [stdout]);
|
|
19
|
+
return size;
|
|
20
|
+
};
|
|
21
|
+
export default useWindowSize;
|
|
22
|
+
//# sourceMappingURL=use-window-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-window-size.js","sourceRoot":"","sources":["../../src/hooks/use-window-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAiBxC;;EAEE;AACF,MAAM,aAAa,GAAG,GAAe,EAAE;IACtC,MAAM,EAAC,MAAM,EAAC,GAAG,SAAS,EAAE,CAAC;IAC7B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAa,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1E,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,QAAQ,GAAG,GAAG,EAAE;YACrB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC;QAEF,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAE9B,OAAO,GAAG,EAAE;YACX,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChC,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export type { RenderOptions, Instance } from './render.js';
|
|
2
2
|
export { default as render } from './render.js';
|
|
3
|
+
export type { RenderToStringOptions } from './render-to-string.js';
|
|
4
|
+
export { default as renderToString } from './render-to-string.js';
|
|
3
5
|
export type { Props as BoxProps, BoxRef } from './components/Box.js';
|
|
4
6
|
export { default as Box } from './components/Box.js';
|
|
5
7
|
export type { Props as TextProps } from './components/Text.js';
|
|
6
8
|
export { default as Text } from './components/Text.js';
|
|
7
9
|
export type { Props as AppProps } from './components/AppContext.js';
|
|
8
|
-
export type {
|
|
10
|
+
export type { PublicProps as StdinProps } from './components/StdinContext.js';
|
|
9
11
|
export type { Props as StdoutProps } from './components/StdoutContext.js';
|
|
10
12
|
export type { Props as StderrProps } from './components/StderrContext.js';
|
|
11
13
|
export type { Props as StaticProps } from './components/Static.js';
|
|
@@ -17,6 +19,7 @@ export { default as Newline } from './components/Newline.js';
|
|
|
17
19
|
export { default as Spacer } from './components/Spacer.js';
|
|
18
20
|
export type { Key } from './hooks/use-input.js';
|
|
19
21
|
export { default as useInput } from './hooks/use-input.js';
|
|
22
|
+
export { default as usePaste } from './hooks/use-paste.js';
|
|
20
23
|
export { default as useApp } from './hooks/use-app.js';
|
|
21
24
|
export { default as useStdin } from './hooks/use-stdin.js';
|
|
22
25
|
export { default as useStdout } from './hooks/use-stdout.js';
|
|
@@ -24,5 +27,17 @@ export { default as useStderr } from './hooks/use-stderr.js';
|
|
|
24
27
|
export { default as useFocus } from './hooks/use-focus.js';
|
|
25
28
|
export { default as useFocusManager } from './hooks/use-focus-manager.js';
|
|
26
29
|
export { default as useIsScreenReaderEnabled } from './hooks/use-is-screen-reader-enabled.js';
|
|
30
|
+
export { default as useCursor } from './hooks/use-cursor.js';
|
|
31
|
+
export type { AnimationResult } from './hooks/use-animation.js';
|
|
32
|
+
export { default as useAnimation } from './hooks/use-animation.js';
|
|
33
|
+
export type { WindowSize } from './hooks/use-window-size.js';
|
|
34
|
+
export { default as useWindowSize } from './hooks/use-window-size.js';
|
|
35
|
+
export type { BoxMetrics, UseBoxMetricsResult } from './hooks/use-box-metrics.js';
|
|
36
|
+
export { default as useBoxMetrics } from './hooks/use-box-metrics.js';
|
|
37
|
+
export type { CursorPosition } from './log-update.js';
|
|
27
38
|
export { default as measureElement } from './measure-element.js';
|
|
39
|
+
export type { InkCacheSizes } from './diagnostics.js';
|
|
40
|
+
export { getInkCacheSizes } from './diagnostics.js';
|
|
28
41
|
export type { DOMElement } from './dom.js';
|
|
42
|
+
export { kittyFlags, kittyModifiers } from './kitty-keyboard.js';
|
|
43
|
+
export type { KittyKeyboardOptions, KittyFlagName } from './kitty-keyboard.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAChE,YAAY,EAAC,KAAK,IAAI,QAAQ,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAC,OAAO,IAAI,GAAG,EAAC,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAC,KAAK,IAAI,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,sBAAsB,CAAC;AACrD,YAAY,EAAC,KAAK,IAAI,QAAQ,EAAC,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAC,WAAW,IAAI,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAC5E,YAAY,EAAC,KAAK,IAAI,WAAW,EAAC,MAAM,+BAA+B,CAAC;AACxE,YAAY,EAAC,KAAK,IAAI,WAAW,EAAC,MAAM,+BAA+B,CAAC;AACxE,YAAY,EAAC,KAAK,IAAI,WAAW,EAA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C,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAC,UAAU,EAAE,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,EAAC,UAAU,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAC/D,YAAY,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as render } from './render.js';
|
|
2
|
+
export { default as renderToString } from './render-to-string.js';
|
|
2
3
|
export { default as Box } from './components/Box.js';
|
|
3
4
|
export { default as Text } from './components/Text.js';
|
|
4
5
|
export { default as Static } from './components/Static.js';
|
|
@@ -6,6 +7,7 @@ export { default as Transform } from './components/Transform.js';
|
|
|
6
7
|
export { default as Newline } from './components/Newline.js';
|
|
7
8
|
export { default as Spacer } from './components/Spacer.js';
|
|
8
9
|
export { default as useInput } from './hooks/use-input.js';
|
|
10
|
+
export { default as usePaste } from './hooks/use-paste.js';
|
|
9
11
|
export { default as useApp } from './hooks/use-app.js';
|
|
10
12
|
export { default as useStdin } from './hooks/use-stdin.js';
|
|
11
13
|
export { default as useStdout } from './hooks/use-stdout.js';
|
|
@@ -13,5 +15,11 @@ export { default as useStderr } from './hooks/use-stderr.js';
|
|
|
13
15
|
export { default as useFocus } from './hooks/use-focus.js';
|
|
14
16
|
export { default as useFocusManager } from './hooks/use-focus-manager.js';
|
|
15
17
|
export { default as useIsScreenReaderEnabled } from './hooks/use-is-screen-reader-enabled.js';
|
|
18
|
+
export { default as useCursor } from './hooks/use-cursor.js';
|
|
19
|
+
export { default as useAnimation } from './hooks/use-animation.js';
|
|
20
|
+
export { default as useWindowSize } from './hooks/use-window-size.js';
|
|
21
|
+
export { default as useBoxMetrics } from './hooks/use-box-metrics.js';
|
|
16
22
|
export { default as measureElement } from './measure-element.js';
|
|
23
|
+
export { getInkCacheSizes } from './diagnostics.js';
|
|
24
|
+
export { kittyFlags, kittyModifiers } from './kitty-keyboard.js';
|
|
17
25
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAC,OAAO,IAAI,GAAG,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,sBAAsB,CAAC;AAMrD,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,uBAAuB,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,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC5F,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC"}
|
package/build/ink.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CursorPosition } from './log-update.js';
|
|
3
|
+
import { type KittyKeyboardOptions } from './kitty-keyboard.js';
|
|
2
4
|
/**
|
|
3
5
|
Performance metrics for a render operation.
|
|
4
6
|
*/
|
|
5
7
|
export type RenderMetrics = {
|
|
8
|
+
/**
|
|
9
|
+
Number of terminal rows in the rendered frame.
|
|
10
|
+
*/
|
|
11
|
+
outputHeight: number;
|
|
12
|
+
/**
|
|
13
|
+
Number of UTF-16 code units in the rendered frame string.
|
|
14
|
+
*/
|
|
15
|
+
outputLength: number;
|
|
6
16
|
/**
|
|
7
17
|
Time spent rendering in milliseconds.
|
|
8
18
|
*/
|
|
@@ -17,38 +27,117 @@ export type Options = {
|
|
|
17
27
|
patchConsole: boolean;
|
|
18
28
|
onRender?: (metrics: RenderMetrics) => void;
|
|
19
29
|
isScreenReaderEnabled?: boolean;
|
|
20
|
-
waitUntilExit?: () => Promise<
|
|
30
|
+
waitUntilExit?: () => Promise<unknown>;
|
|
21
31
|
maxFps?: number;
|
|
22
32
|
incrementalRendering?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
Enable React Concurrent Rendering mode.
|
|
35
|
+
|
|
36
|
+
When enabled:
|
|
37
|
+
- Suspense boundaries work correctly with async data
|
|
38
|
+
- `useTransition` and `useDeferredValue` are fully functional
|
|
39
|
+
- Updates can be interrupted for higher priority work
|
|
40
|
+
|
|
41
|
+
Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
|
|
42
|
+
|
|
43
|
+
@default false
|
|
44
|
+
@experimental
|
|
45
|
+
*/
|
|
46
|
+
concurrent?: boolean;
|
|
47
|
+
kittyKeyboard?: KittyKeyboardOptions;
|
|
48
|
+
/**
|
|
49
|
+
Override automatic interactive mode detection.
|
|
50
|
+
|
|
51
|
+
By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
|
|
52
|
+
|
|
53
|
+
When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
|
|
54
|
+
|
|
55
|
+
Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
|
|
56
|
+
|
|
57
|
+
Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
|
|
58
|
+
|
|
59
|
+
@default true (false if in CI or `stdout.isTTY` is falsy)
|
|
60
|
+
|
|
61
|
+
@see {@link RenderOptions.interactive}
|
|
62
|
+
*/
|
|
63
|
+
interactive?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
|
|
66
|
+
|
|
67
|
+
Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
|
|
68
|
+
|
|
69
|
+
Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
|
|
70
|
+
|
|
71
|
+
Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
|
|
72
|
+
|
|
73
|
+
Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
|
|
74
|
+
|
|
75
|
+
@default false
|
|
76
|
+
|
|
77
|
+
@see {@link RenderOptions.alternateScreen}
|
|
78
|
+
*/
|
|
79
|
+
alternateScreen?: boolean;
|
|
23
80
|
};
|
|
24
81
|
export default class Ink {
|
|
82
|
+
/**
|
|
83
|
+
Whether this instance is using concurrent rendering mode.
|
|
84
|
+
*/
|
|
85
|
+
readonly isConcurrent: boolean;
|
|
25
86
|
private readonly options;
|
|
26
87
|
private readonly log;
|
|
88
|
+
private cursorPosition;
|
|
27
89
|
private readonly throttledLog;
|
|
28
90
|
private readonly isScreenReaderEnabled;
|
|
91
|
+
private readonly interactive;
|
|
92
|
+
private readonly renderThrottleMs;
|
|
93
|
+
private alternateScreen;
|
|
29
94
|
private isUnmounted;
|
|
95
|
+
private isUnmounting;
|
|
30
96
|
private lastOutput;
|
|
97
|
+
private lastOutputToRender;
|
|
31
98
|
private lastOutputHeight;
|
|
32
99
|
private lastTerminalWidth;
|
|
33
100
|
private readonly container;
|
|
34
101
|
private readonly rootNode;
|
|
35
102
|
private fullStaticOutput;
|
|
36
|
-
private exitPromise
|
|
103
|
+
private readonly exitPromise;
|
|
104
|
+
private exitResult;
|
|
105
|
+
private beforeExitHandler?;
|
|
37
106
|
private restoreConsole?;
|
|
38
107
|
private readonly unsubscribeResize?;
|
|
108
|
+
private readonly throttledOnRender?;
|
|
109
|
+
private hasPendingThrottledRender;
|
|
110
|
+
private kittyProtocolEnabled;
|
|
111
|
+
private cancelKittyDetection?;
|
|
112
|
+
private nextRenderCommit?;
|
|
39
113
|
constructor(options: Options);
|
|
40
|
-
getTerminalWidth: () => number;
|
|
41
114
|
resized: () => void;
|
|
42
|
-
resolveExitPromise: () => void;
|
|
115
|
+
resolveExitPromise: (result?: unknown) => void;
|
|
43
116
|
rejectExitPromise: (reason?: Error) => void;
|
|
44
117
|
unsubscribeExit: () => void;
|
|
118
|
+
handleAppExit: (errorOrResult?: unknown) => void;
|
|
119
|
+
setCursorPosition: (position: CursorPosition | undefined) => void;
|
|
120
|
+
restoreLastOutput: () => void;
|
|
45
121
|
calculateLayout: () => void;
|
|
46
122
|
onRender: () => void;
|
|
47
123
|
render(node: ReactNode): void;
|
|
48
124
|
writeToStdout(data: string): void;
|
|
49
125
|
writeToStderr(data: string): void;
|
|
50
126
|
unmount(error?: Error | number | null): void;
|
|
51
|
-
waitUntilExit(): Promise<
|
|
127
|
+
waitUntilExit(): Promise<unknown>;
|
|
128
|
+
waitUntilRenderFlush(): Promise<void>;
|
|
52
129
|
clear(): void;
|
|
53
130
|
patchConsole(): void;
|
|
131
|
+
private setAlternateScreen;
|
|
132
|
+
private resolveInteractiveOption;
|
|
133
|
+
private resolveAlternateScreenOption;
|
|
134
|
+
private shouldSync;
|
|
135
|
+
private writeBestEffort;
|
|
136
|
+
private awaitExit;
|
|
137
|
+
private hasPendingConcurrentWork;
|
|
138
|
+
private awaitNextRender;
|
|
139
|
+
private renderInteractiveFrame;
|
|
140
|
+
private initKittyKeyboard;
|
|
141
|
+
private confirmKittySupport;
|
|
142
|
+
private enableKittyProtocol;
|
|
54
143
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ink.d.ts","sourceRo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