ink 6.8.0 → 7.0.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 (128) hide show
  1. package/build/components/AnimationContext.d.ts +9 -0
  2. package/build/components/AnimationContext.js +13 -0
  3. package/build/components/AnimationContext.js.map +1 -0
  4. package/build/components/App.d.ts +4 -1
  5. package/build/components/App.js +140 -20
  6. package/build/components/App.js.map +1 -1
  7. package/build/components/AppContext.d.ts +28 -2
  8. package/build/components/AppContext.js +2 -1
  9. package/build/components/AppContext.js.map +1 -1
  10. package/build/components/Box.d.ts +16 -3
  11. package/build/components/ErrorBoundary.d.ts +2 -2
  12. package/build/components/ErrorOverview.js +6 -6
  13. package/build/components/ErrorOverview.js.map +1 -1
  14. package/build/components/Static.js.map +1 -1
  15. package/build/components/StdinContext.d.ts +7 -1
  16. package/build/components/StdinContext.js +1 -0
  17. package/build/components/StdinContext.js.map +1 -1
  18. package/build/components/Text.d.ts +1 -1
  19. package/build/components/Text.js +1 -1
  20. package/build/components/Text.js.map +1 -1
  21. package/build/components/Transform.d.ts +1 -1
  22. package/build/devtools-window-polyfill.js +7 -4
  23. package/build/devtools-window-polyfill.js.map +1 -1
  24. package/build/devtools.js +31 -6
  25. package/build/devtools.js.map +1 -1
  26. package/build/dom.d.ts +5 -1
  27. package/build/dom.js +20 -1
  28. package/build/dom.js.map +1 -1
  29. package/build/hooks/use-animation.d.ts +49 -0
  30. package/build/hooks/use-animation.js +87 -0
  31. package/build/hooks/use-animation.js.map +1 -0
  32. package/build/hooks/use-app.d.ts +5 -2
  33. package/build/hooks/use-app.js +1 -1
  34. package/build/hooks/use-box-metrics.d.ts +59 -0
  35. package/build/hooks/use-box-metrics.js +88 -0
  36. package/build/hooks/use-box-metrics.js.map +1 -0
  37. package/build/hooks/use-cursor.d.ts +1 -1
  38. package/build/hooks/use-cursor.js +1 -1
  39. package/build/hooks/use-focus-manager.d.ts +17 -2
  40. package/build/hooks/use-focus-manager.js +2 -1
  41. package/build/hooks/use-focus-manager.js.map +1 -1
  42. package/build/hooks/use-focus.d.ts +2 -1
  43. package/build/hooks/use-focus.js +5 -4
  44. package/build/hooks/use-focus.js.map +1 -1
  45. package/build/hooks/use-input.d.ts +2 -1
  46. package/build/hooks/use-input.js +82 -80
  47. package/build/hooks/use-input.js.map +1 -1
  48. package/build/hooks/use-is-screen-reader-enabled.d.ts +2 -1
  49. package/build/hooks/use-is-screen-reader-enabled.js +2 -1
  50. package/build/hooks/use-is-screen-reader-enabled.js.map +1 -1
  51. package/build/hooks/use-paste.d.ts +35 -0
  52. package/build/hooks/use-paste.js +62 -0
  53. package/build/hooks/use-paste.js.map +1 -0
  54. package/build/hooks/use-stderr.d.ts +1 -1
  55. package/build/hooks/use-stderr.js +1 -1
  56. package/build/hooks/use-stdin.d.ts +4 -2
  57. package/build/hooks/use-stdin.js +2 -1
  58. package/build/hooks/use-stdin.js.map +1 -1
  59. package/build/hooks/use-stdout.d.ts +1 -1
  60. package/build/hooks/use-stdout.js +1 -1
  61. package/build/hooks/use-window-size.d.ts +18 -0
  62. package/build/hooks/use-window-size.js +22 -0
  63. package/build/hooks/use-window-size.js.map +1 -0
  64. package/build/index.d.ts +8 -1
  65. package/build/index.js +4 -0
  66. package/build/index.js.map +1 -1
  67. package/build/ink.d.ts +48 -3
  68. package/build/ink.js +325 -155
  69. package/build/ink.js.map +1 -1
  70. package/build/input-parser.d.ts +4 -1
  71. package/build/input-parser.js +70 -30
  72. package/build/input-parser.js.map +1 -1
  73. package/build/log-update.d.ts +1 -0
  74. package/build/log-update.js +13 -1
  75. package/build/log-update.js.map +1 -1
  76. package/build/measure-element.d.ts +4 -0
  77. package/build/measure-element.js +4 -0
  78. package/build/measure-element.js.map +1 -1
  79. package/build/output.js +25 -0
  80. package/build/output.js.map +1 -1
  81. package/build/parse-keypress.d.ts +1 -3
  82. package/build/parse-keypress.js +19 -17
  83. package/build/parse-keypress.js.map +1 -1
  84. package/build/reconciler.js +46 -27
  85. package/build/reconciler.js.map +1 -1
  86. package/build/render-border.js +29 -18
  87. package/build/render-border.js.map +1 -1
  88. package/build/render-to-string.js +2 -1
  89. package/build/render-to-string.js.map +1 -1
  90. package/build/render.d.ts +57 -2
  91. package/build/render.js +18 -11
  92. package/build/render.js.map +1 -1
  93. package/build/styles.d.ts +78 -16
  94. package/build/styles.js +102 -31
  95. package/build/styles.js.map +1 -1
  96. package/build/utils.d.ts +9 -2
  97. package/build/utils.js +18 -3
  98. package/build/utils.js.map +1 -1
  99. package/build/wrap-text.js +7 -0
  100. package/build/wrap-text.js.map +1 -1
  101. package/build/write-synchronized.d.ts +1 -1
  102. package/build/write-synchronized.js +4 -2
  103. package/build/write-synchronized.js.map +1 -1
  104. package/package.json +34 -98
  105. package/readme.md +554 -48
  106. package/build/apply-styles.js +0 -175
  107. package/build/build-layout.js +0 -77
  108. package/build/calculate-wrapped-text.js +0 -53
  109. package/build/components/Color.js +0 -62
  110. package/build/components/Cursor.d.ts +0 -83
  111. package/build/components/Cursor.js +0 -53
  112. package/build/components/Cursor.js.map +0 -1
  113. package/build/experimental/apply-style.js +0 -140
  114. package/build/experimental/dom.js +0 -123
  115. package/build/experimental/output.js +0 -91
  116. package/build/experimental/reconciler.js +0 -141
  117. package/build/experimental/renderer.js +0 -81
  118. package/build/hooks/useInput.js +0 -38
  119. package/build/instance.js +0 -205
  120. package/build/layout.d.ts +0 -7
  121. package/build/layout.js +0 -33
  122. package/build/layout.js.map +0 -1
  123. package/build/options.d.ts +0 -52
  124. package/build/options.js +0 -2
  125. package/build/options.js.map +0 -1
  126. package/build/screen-reader-update.d.ts +0 -13
  127. package/build/screen-reader-update.js +0 -38
  128. package/build/screen-reader-update.js.map +0 -1
package/build/layout.js DELETED
@@ -1,33 +0,0 @@
1
- import Yoga from 'yoga-layout';
2
- const getAbsoluteBorderPosition = (node) => {
3
- let currentNode = node;
4
- let x = 0;
5
- let y = 0;
6
- while (currentNode?.parentNode) {
7
- if (!currentNode.yogaNode) {
8
- return undefined;
9
- }
10
- x += currentNode.yogaNode.getComputedLeft();
11
- y += currentNode.yogaNode.getComputedTop();
12
- currentNode = currentNode.parentNode;
13
- }
14
- return { x, y };
15
- };
16
- export const getAbsolutePosition = (node) => {
17
- return getAbsoluteBorderPosition(node);
18
- };
19
- export const getAbsoluteContentPosition = (node) => {
20
- const borderPosition = getAbsoluteBorderPosition(node);
21
- if (!borderPosition || !node.yogaNode) {
22
- return undefined;
23
- }
24
- return {
25
- x: borderPosition.x +
26
- node.yogaNode.getComputedBorder(Yoga.EDGE_LEFT) +
27
- node.yogaNode.getComputedPadding(Yoga.EDGE_LEFT),
28
- y: borderPosition.y +
29
- node.yogaNode.getComputedBorder(Yoga.EDGE_TOP) +
30
- node.yogaNode.getComputedPadding(Yoga.EDGE_TOP),
31
- };
32
- };
33
- //# sourceMappingURL=layout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"layout.js","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAQ/B,MAAM,yBAAyB,GAAG,CAAC,IAAgB,EAAwB,EAAE;IAC5E,IAAI,WAAW,GAA2B,IAAI,CAAC;IAC/C,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,OAAO,WAAW,EAAE,UAAU,EAAE,CAAC;QAChC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;QAC5C,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC3C,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC;IACtC,CAAC;IAED,OAAO,EAAC,CAAC,EAAE,CAAC,EAAC,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAgB,EAAwB,EAAE;IAC7E,OAAO,yBAAyB,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACzC,IAAgB,EACO,EAAE;IACzB,MAAM,cAAc,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO;QACN,CAAC,EACA,cAAc,CAAC,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC;YAC/C,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC;QACjD,CAAC,EACA,cAAc,CAAC,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC;KAChD,CAAC;AACH,CAAC,CAAC"}
@@ -1,52 +0,0 @@
1
- export type CommonOptions = {
2
- /**
3
- * Output stream where app will be rendered.
4
- *
5
- * @default process.stdout
6
- */
7
- stdout?: NodeJS.WriteStream;
8
- /**
9
- * Input stream where app will listen for input.
10
- *
11
- * @default process.stdin
12
- */
13
- stdin?: NodeJS.ReadStream;
14
- /**
15
- * Error stream.
16
- * @default process.stderr
17
- */
18
- stderr?: NodeJS.WriteStream;
19
- /**
20
- * If true, each update will be rendered as a separate output, without replacing the previous one.
21
- *
22
- * @default false
23
- */
24
- debug?: boolean;
25
- /**
26
- * Configure whether Ink should listen to Ctrl+C keyboard input and exit the app. This is needed in case `process.stdin` is in raw mode, because then Ctrl+C is ignored by default and process is expected to handle it manually.
27
- *
28
- * @default true
29
- */
30
- exitOnCtrlC?: boolean;
31
- /**
32
- * Patch console methods to ensure console output doesn't mix with Ink output.
33
- *
34
- * @default true
35
- */
36
- patchConsole?: boolean;
37
- /**
38
- * Enable screen reader support.
39
- * See https://github.com/vadimdemedes/ink/blob/master/readme.md#screen-reader-support
40
- *
41
- * @default process.env['INK_SCREEN_READER'] === 'true'
42
- */
43
- isScreenReaderEnabled?: boolean;
44
- /**
45
- * Maximum frames per second for render updates.
46
- * This controls how frequently the UI can update to prevent excessive re-rendering.
47
- * Higher values allow more frequent updates but may impact performance.
48
- *
49
- * @default 30
50
- */
51
- maxFps?: number;
52
- };
package/build/options.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
1
- import { type WriteStream } from 'node:tty';
2
- declare class ScreenReaderUpdate {
3
- private readonly stdout;
4
- private readonly stderr;
5
- private previousOutput;
6
- private previousLineCount;
7
- constructor(stdout: WriteStream, stderr: WriteStream);
8
- private wrap;
9
- render(output: string): void;
10
- writeStdout(data: string): void;
11
- writeStderr(data: string): void;
12
- }
13
- export default ScreenReaderUpdate;
@@ -1,38 +0,0 @@
1
- import ansiEscapes from 'ansi-escapes';
2
- import wrapAnsi from 'wrap-ansi';
3
- class ScreenReaderUpdate {
4
- stdout;
5
- stderr;
6
- previousOutput = '';
7
- previousLineCount = 0;
8
- constructor(stdout, stderr) {
9
- this.stdout = stdout;
10
- this.stderr = stderr;
11
- }
12
- wrap(output) {
13
- const width = this.stdout.columns || 80;
14
- return wrapAnsi(output, width, { trim: false, hard: true });
15
- }
16
- render(output) {
17
- const wrapped = this.wrap(output);
18
- if (wrapped === this.previousOutput) {
19
- return;
20
- }
21
- const erase = this.previousLineCount > 0 ? ansiEscapes.eraseLines(this.previousLineCount) : '';
22
- this.stdout.write(erase + wrapped);
23
- this.previousOutput = wrapped;
24
- this.previousLineCount = wrapped === '' ? 0 : wrapped.split('\n').length;
25
- }
26
- writeStdout(data) {
27
- const erase = this.previousLineCount > 0 ? ansiEscapes.eraseLines(this.previousLineCount) : '';
28
- this.stdout.write(erase + data + this.previousOutput);
29
- }
30
- writeStderr(data) {
31
- const erase = this.previousLineCount > 0 ? ansiEscapes.eraseLines(this.previousLineCount) : '';
32
- this.stdout.write(erase);
33
- this.stderr.write(data);
34
- this.stdout.write(this.previousOutput);
35
- }
36
- }
37
- export default ScreenReaderUpdate;
38
- //# sourceMappingURL=screen-reader-update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"screen-reader-update.js","sourceRoot":"","sources":["../src/screen-reader-update.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,kBAAkB;IAKH;IACA;IALX,cAAc,GAAG,EAAE,CAAC;IACpB,iBAAiB,GAAG,CAAC,CAAC;IAE9B,YACmB,MAAmB,EACnB,MAAmB;QADnB,WAAM,GAAN,MAAM,CAAa;QACnB,WAAM,GAAN,MAAM,CAAa;IACnC,CAAC;IAEI,IAAI,CAAC,MAAc;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,MAAc;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,OAAO,KAAK,IAAI,CAAC,cAAc,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC;QAEnC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAC3E,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;IACxD,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzC,CAAC;CACF;AAED,eAAe,kBAAkB,CAAC"}