ink 3.2.0 → 4.1.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 (122) hide show
  1. package/build/colorize.d.ts +3 -3
  2. package/build/colorize.js +30 -35
  3. package/build/colorize.js.map +1 -1
  4. package/build/components/App.d.ts +12 -12
  5. package/build/components/App.js +287 -208
  6. package/build/components/App.js.map +1 -1
  7. package/build/components/AppContext.d.ts +2 -2
  8. package/build/components/AppContext.js +5 -6
  9. package/build/components/AppContext.js.map +1 -1
  10. package/build/components/Box.d.ts +77 -5
  11. package/build/components/Box.js +20 -38
  12. package/build/components/Box.js.map +1 -1
  13. package/build/components/ErrorOverview.d.ts +5 -5
  14. package/build/components/ErrorOverview.js +40 -58
  15. package/build/components/ErrorOverview.js.map +1 -1
  16. package/build/components/FocusContext.d.ts +2 -2
  17. package/build/components/FocusContext.js +13 -14
  18. package/build/components/FocusContext.js.map +1 -1
  19. package/build/components/Newline.d.ts +4 -5
  20. package/build/components/Newline.js +4 -9
  21. package/build/components/Newline.js.map +1 -1
  22. package/build/components/Spacer.d.ts +2 -3
  23. package/build/components/Spacer.js +5 -10
  24. package/build/components/Spacer.js.map +1 -1
  25. package/build/components/Static.d.ts +5 -9
  26. package/build/components/Static.js +12 -33
  27. package/build/components/Static.js.map +1 -1
  28. package/build/components/StderrContext.d.ts +4 -4
  29. package/build/components/StderrContext.js +7 -7
  30. package/build/components/StderrContext.js.map +1 -1
  31. package/build/components/StdinContext.d.ts +4 -4
  32. package/build/components/StdinContext.js +8 -7
  33. package/build/components/StdinContext.js.map +1 -1
  34. package/build/components/StdoutContext.d.ts +4 -4
  35. package/build/components/StdoutContext.js +7 -7
  36. package/build/components/StdoutContext.js.map +1 -1
  37. package/build/components/Text.d.ts +9 -10
  38. package/build/components/Text.js +14 -29
  39. package/build/components/Text.js.map +1 -1
  40. package/build/components/Transform.d.ts +4 -5
  41. package/build/components/Transform.js +4 -11
  42. package/build/components/Transform.js.map +1 -1
  43. package/build/devtools-window-polyfill.js +3 -8
  44. package/build/devtools-window-polyfill.js.map +1 -1
  45. package/build/devtools.d.ts +1 -1
  46. package/build/devtools.js +6 -6
  47. package/build/devtools.js.map +1 -1
  48. package/build/dom.d.ts +17 -20
  49. package/build/dom.js +35 -47
  50. package/build/dom.js.map +1 -1
  51. package/build/get-max-width.d.ts +3 -3
  52. package/build/get-max-width.js +8 -11
  53. package/build/get-max-width.js.map +1 -1
  54. package/build/hooks/use-app.d.ts +1 -1
  55. package/build/hooks/use-app.js +4 -9
  56. package/build/hooks/use-app.js.map +1 -1
  57. package/build/hooks/use-focus-manager.d.ts +3 -3
  58. package/build/hooks/use-focus-manager.js +4 -9
  59. package/build/hooks/use-focus-manager.js.map +1 -1
  60. package/build/hooks/use-focus.d.ts +4 -4
  61. package/build/hooks/use-focus.js +11 -16
  62. package/build/hooks/use-focus.js.map +1 -1
  63. package/build/hooks/use-input.d.ts +5 -5
  64. package/build/hooks/use-input.js +13 -14
  65. package/build/hooks/use-input.js.map +1 -1
  66. package/build/hooks/use-stderr.d.ts +1 -1
  67. package/build/hooks/use-stderr.js +4 -9
  68. package/build/hooks/use-stderr.js.map +1 -1
  69. package/build/hooks/use-stdin.d.ts +1 -1
  70. package/build/hooks/use-stdin.js +4 -9
  71. package/build/hooks/use-stdin.js.map +1 -1
  72. package/build/hooks/use-stdout.d.ts +1 -1
  73. package/build/hooks/use-stdout.js +4 -9
  74. package/build/hooks/use-stdout.js.map +1 -1
  75. package/build/index.d.ts +27 -20
  76. package/build/index.js +15 -32
  77. package/build/index.js.map +1 -1
  78. package/build/ink.d.ts +6 -4
  79. package/build/ink.js +188 -99
  80. package/build/ink.js.map +1 -1
  81. package/build/instances.d.ts +4 -2
  82. package/build/instances.js +2 -3
  83. package/build/instances.js.map +1 -1
  84. package/build/log-update.d.ts +5 -6
  85. package/build/log-update.js +8 -12
  86. package/build/log-update.js.map +1 -1
  87. package/build/measure-element.d.ts +5 -5
  88. package/build/measure-element.js +5 -9
  89. package/build/measure-element.js.map +1 -1
  90. package/build/measure-text.d.ts +4 -4
  91. package/build/measure-text.js +7 -10
  92. package/build/measure-text.js.map +1 -1
  93. package/build/output.d.ts +12 -4
  94. package/build/output.js +108 -31
  95. package/build/output.js.map +1 -1
  96. package/build/reconciler.d.ts +1 -1
  97. package/build/reconciler.js +104 -76
  98. package/build/reconciler.js.map +1 -1
  99. package/build/render-border.d.ts +4 -4
  100. package/build/render-border.js +8 -12
  101. package/build/render-border.js.map +1 -1
  102. package/build/render-node-to-output.d.ts +3 -3
  103. package/build/render-node-to-output.js +44 -24
  104. package/build/render-node-to-output.js.map +1 -1
  105. package/build/render.d.ts +8 -8
  106. package/build/render.js +23 -20
  107. package/build/render.js.map +1 -1
  108. package/build/renderer.d.ts +5 -5
  109. package/build/renderer.js +9 -17
  110. package/build/renderer.js.map +1 -1
  111. package/build/squash-text-nodes.d.ts +1 -1
  112. package/build/squash-text-nodes.js +1 -3
  113. package/build/squash-text-nodes.js.map +1 -1
  114. package/build/styles.d.ts +30 -9
  115. package/build/styles.js +60 -46
  116. package/build/styles.js.map +1 -1
  117. package/build/wrap-text.d.ts +3 -3
  118. package/build/wrap-text.js +9 -12
  119. package/build/wrap-text.js.map +1 -1
  120. package/license +1 -1
  121. package/package.json +87 -67
  122. package/readme.md +202 -57
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_1 = require("react");
1
+ import process from 'node:process';
2
+ import { createContext } from 'react';
4
3
  /**
5
4
  * `StderrContext` is a React context, which exposes stderr stream.
6
5
  */
7
- const StderrContext = react_1.createContext({
8
- stderr: undefined,
9
- write: () => { }
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ const StderrContext = createContext({
8
+ stderr: process.stderr,
9
+ write() { }
10
10
  });
11
11
  StderrContext.displayName = 'InternalStderrContext';
12
- exports.default = StderrContext;
12
+ export default StderrContext;
13
13
  //# sourceMappingURL=StderrContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StderrContext.js","sourceRoot":"","sources":["../../src/components/StderrContext.ts"],"names":[],"mappings":";;AAAA,iCAAoC;AAgBpC;;GAEG;AACH,MAAM,aAAa,GAAG,qBAAa,CAAQ;IAC1C,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;CACf,CAAC,CAAC;AAEH,aAAa,CAAC,WAAW,GAAG,uBAAuB,CAAC;AAEpD,kBAAe,aAAa,CAAC"}
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;AAgBpC;;GAEG;AACH,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"}
@@ -1,10 +1,10 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="react" />
3
- export interface Props {
3
+ export type Props = {
4
4
  /**
5
5
  * Stdin stream passed to `render()` in `options.stdin` or `process.stdin` by default. Useful if your app needs to handle user input.
6
6
  */
7
- readonly stdin?: NodeJS.ReadStream;
7
+ readonly stdin: NodeJS.ReadStream;
8
8
  /**
9
9
  * 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`.
10
10
  * If the `stdin` stream passed to Ink does not support setRawMode, this function does nothing.
@@ -15,7 +15,7 @@ export interface Props {
15
15
  */
16
16
  readonly isRawModeSupported: boolean;
17
17
  readonly internal_exitOnCtrlC: boolean;
18
- }
18
+ };
19
19
  /**
20
20
  * `StdinContext` is a React context, which exposes input stream.
21
21
  */
@@ -1,15 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_1 = require("react");
1
+ import process from 'node:process';
2
+ import { createContext } from 'react';
4
3
  /**
5
4
  * `StdinContext` is a React context, which exposes input stream.
6
5
  */
7
- const StdinContext = react_1.createContext({
8
- stdin: undefined,
9
- setRawMode: () => { },
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ const StdinContext = createContext({
8
+ stdin: process.stdin,
9
+ setRawMode() { },
10
10
  isRawModeSupported: false,
11
+ // eslint-disable-next-line @typescript-eslint/naming-convention
11
12
  internal_exitOnCtrlC: true
12
13
  });
13
14
  StdinContext.displayName = 'InternalStdinContext';
14
- exports.default = StdinContext;
15
+ export default StdinContext;
15
16
  //# sourceMappingURL=StdinContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StdinContext.js","sourceRoot":"","sources":["../../src/components/StdinContext.ts"],"names":[],"mappings":";;AAAA,iCAAoC;AAsBpC;;GAEG;AACH,MAAM,YAAY,GAAG,qBAAa,CAAQ;IACzC,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;IACpB,kBAAkB,EAAE,KAAK;IACzB,oBAAoB,EAAE,IAAI;CAC1B,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAElD,kBAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"StdinContext.js","sourceRoot":"","sources":["../../src/components/StdinContext.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAsBpC;;GAEG;AACH,gEAAgE;AAChE,MAAM,YAAY,GAAG,aAAa,CAAQ;IACzC,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,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"}
@@ -1,17 +1,17 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="react" />
3
- export interface Props {
3
+ export type Props = {
4
4
  /**
5
5
  * Stdout stream passed to `render()` in `options.stdout` or `process.stdout` by default.
6
6
  */
7
- readonly stdout?: NodeJS.WriteStream;
7
+ readonly stdout: NodeJS.WriteStream;
8
8
  /**
9
9
  * Write any string to stdout, while preserving Ink's output.
10
10
  * It's useful when you want to display some external information outside of Ink's rendering and ensure there's no conflict between the two.
11
11
  * It's similar to `<Static>`, except it can't accept components, it only works with strings.
12
12
  */
13
13
  readonly write: (data: string) => void;
14
- }
14
+ };
15
15
  /**
16
16
  * `StdoutContext` is a React context, which exposes stdout stream, where Ink renders your app.
17
17
  */
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_1 = require("react");
1
+ import process from 'node:process';
2
+ import { createContext } from 'react';
4
3
  /**
5
4
  * `StdoutContext` is a React context, which exposes stdout stream, where Ink renders your app.
6
5
  */
7
- const StdoutContext = react_1.createContext({
8
- stdout: undefined,
9
- write: () => { }
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ const StdoutContext = createContext({
8
+ stdout: process.stdout,
9
+ write() { }
10
10
  });
11
11
  StdoutContext.displayName = 'InternalStdoutContext';
12
- exports.default = StdoutContext;
12
+ export default StdoutContext;
13
13
  //# sourceMappingURL=StdoutContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StdoutContext.js","sourceRoot":"","sources":["../../src/components/StdoutContext.ts"],"names":[],"mappings":";;AAAA,iCAAoC;AAgBpC;;GAEG;AACH,MAAM,aAAa,GAAG,qBAAa,CAAQ;IAC1C,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;CACf,CAAC,CAAC;AAEH,aAAa,CAAC,WAAW,GAAG,uBAAuB,CAAC;AAEpD,kBAAe,aAAa,CAAC"}
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;AAgBpC;;GAEG;AACH,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"}
@@ -1,16 +1,16 @@
1
- import { FC, ReactNode } from 'react';
2
- import { ForegroundColor } from 'chalk';
3
- import { Styles } from '../styles';
4
- import { LiteralUnion } from 'type-fest';
5
- export interface Props {
1
+ import { 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
6
  /**
7
7
  * Change text color. Ink uses chalk under the hood, so all its functionality is supported.
8
8
  */
9
- readonly color?: LiteralUnion<typeof ForegroundColor, string>;
9
+ readonly color?: LiteralUnion<ForegroundColorName, string>;
10
10
  /**
11
11
  * Same as `color`, but for background.
12
12
  */
13
- readonly backgroundColor?: LiteralUnion<typeof ForegroundColor, string>;
13
+ readonly backgroundColor?: LiteralUnion<ForegroundColorName, string>;
14
14
  /**
15
15
  * Dim the color (emit a small amount of light).
16
16
  */
@@ -42,9 +42,8 @@ export interface Props {
42
42
  */
43
43
  readonly wrap?: Styles['textWrap'];
44
44
  readonly children?: ReactNode;
45
- }
45
+ };
46
46
  /**
47
47
  * This component can display text, and change its style to make it colorful, bold, underline, italic or strikethrough.
48
48
  */
49
- declare const Text: FC<Props>;
50
- export default Text;
49
+ export default function Text({ color, backgroundColor, dimColor, bold, italic, underline, strikethrough, inverse, wrap, children }: Props): JSX.Element | null;
@@ -1,55 +1,40 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const colorize_1 = __importDefault(require("../colorize"));
1
+ import React from 'react';
2
+ import chalk from 'chalk';
3
+ import colorize from '../colorize.js';
9
4
  /**
10
5
  * This component can display text, and change its style to make it colorful, bold, underline, italic or strikethrough.
11
6
  */
12
- const Text = ({ color, backgroundColor, dimColor, bold, italic, underline, strikethrough, inverse, wrap, children }) => {
7
+ export default function Text({ color, backgroundColor, dimColor = false, bold = false, italic = false, underline = false, strikethrough = false, inverse = false, wrap = 'wrap', children }) {
13
8
  if (children === undefined || children === null) {
14
9
  return null;
15
10
  }
16
11
  const transform = (children) => {
17
12
  if (dimColor) {
18
- children = chalk_1.default.dim(children);
13
+ children = chalk.dim(children);
19
14
  }
20
15
  if (color) {
21
- children = colorize_1.default(children, color, 'foreground');
16
+ children = colorize(children, color, 'foreground');
22
17
  }
23
18
  if (backgroundColor) {
24
- children = colorize_1.default(children, backgroundColor, 'background');
19
+ children = colorize(children, backgroundColor, 'background');
25
20
  }
26
21
  if (bold) {
27
- children = chalk_1.default.bold(children);
22
+ children = chalk.bold(children);
28
23
  }
29
24
  if (italic) {
30
- children = chalk_1.default.italic(children);
25
+ children = chalk.italic(children);
31
26
  }
32
27
  if (underline) {
33
- children = chalk_1.default.underline(children);
28
+ children = chalk.underline(children);
34
29
  }
35
30
  if (strikethrough) {
36
- children = chalk_1.default.strikethrough(children);
31
+ children = chalk.strikethrough(children);
37
32
  }
38
33
  if (inverse) {
39
- children = chalk_1.default.inverse(children);
34
+ children = chalk.inverse(children);
40
35
  }
41
36
  return children;
42
37
  };
43
- return (react_1.default.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: 'row', textWrap: wrap }, internal_transform: transform }, children));
44
- };
45
- Text.displayName = 'Text';
46
- Text.defaultProps = {
47
- dimColor: false,
48
- bold: false,
49
- italic: false,
50
- underline: false,
51
- strikethrough: false,
52
- wrap: 'wrap'
53
- };
54
- exports.default = Text;
38
+ return (React.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: 'row', textWrap: wrap }, internal_transform: transform }, children));
39
+ }
55
40
  //# sourceMappingURL=Text.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.js","sourceRoot":"","sources":["../../src/components/Text.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA2C;AAC3C,kDAA6C;AAC7C,2DAAmC;AAsDnC;;GAEG;AACH,MAAM,IAAI,GAAc,CAAC,EACxB,KAAK,EACL,eAAe,EACf,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,EACT,aAAa,EACb,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,EAAE,EAAE;IACJ,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE;QAChD,OAAO,IAAI,CAAC;KACZ;IAED,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAU,EAAE;QAC9C,IAAI,QAAQ,EAAE;YACb,QAAQ,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAC/B;QAED,IAAI,KAAK,EAAE;YACV,QAAQ,GAAG,kBAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;SACnD;QAED,IAAI,eAAe,EAAE;YACpB,QAAQ,GAAG,kBAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;SAC7D;QAED,IAAI,IAAI,EAAE;YACT,QAAQ,GAAG,eAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAChC;QAED,IAAI,MAAM,EAAE;YACX,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,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from 'react';
2
+ export type Props = {
3
3
  /**
4
4
  * Function which transforms children output. It accepts children and must return transformed children too.
5
5
  */
6
6
  readonly transform: (children: string) => string;
7
7
  readonly children?: ReactNode;
8
- }
8
+ };
9
9
  /**
10
10
  * Transform a string representation of React components before they are written to output.
11
11
  * For example, you might want to apply a gradient to text, add a clickable link or create some text effects.
12
12
  * These use cases can't accept React nodes as input, they are expecting a string.
13
13
  * That's what <Transform> component does, it gives you an output string of its child components and lets you transform it in any way.
14
14
  */
15
- declare const Transform: FC<Props>;
16
- export default Transform;
15
+ export default function Transform({ children, transform }: Props): JSX.Element | null;
@@ -1,21 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
1
+ import React from 'react';
7
2
  /**
8
3
  * Transform a string representation of React components before they are written to output.
9
4
  * For example, you might want to apply a gradient to text, add a clickable link or create some text effects.
10
5
  * These use cases can't accept React nodes as input, they are expecting a string.
11
6
  * That's what <Transform> component does, it gives you an output string of its child components and lets you transform it in any way.
12
7
  */
13
- const Transform = ({ children, transform }) => {
8
+ export default function Transform({ children, transform }) {
14
9
  if (children === undefined || children === null) {
15
10
  return null;
16
11
  }
17
- return (react_1.default.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: 'row' }, internal_transform: transform }, children));
18
- };
19
- Transform.displayName = 'Transform';
20
- exports.default = Transform;
12
+ return (React.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: 'row' }, internal_transform: transform }, children));
13
+ }
21
14
  //# sourceMappingURL=Transform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/components/Transform.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA2C;AAU3C;;;;;GAKG;AACH,MAAM,SAAS,GAAc,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAC,EAAE,EAAE;IACtD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE;QAChD,OAAO,IAAI,CAAC;KACZ;IAED,OAAO,CACN,4CACC,KAAK,EAAE,EAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAC,EACzD,kBAAkB,EAAE,SAAS,IAE5B,QAAQ,CACC,CACX,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;AAEpC,kBAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/components/Transform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAW5C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAQ;IAC7D,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE;QAChD,OAAO,IAAI,CAAC;KACZ;IAED,OAAO,CACN,kCACC,KAAK,EAAE,EAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAC,EACzD,kBAAkB,EAAE,SAAS,IAE5B,QAAQ,CACC,CACX,CAAC;AACH,CAAC"}
@@ -1,15 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
1
  // Ignoring missing types error to avoid adding another dependency for this hack to work
7
- // @ts-ignore
8
- const ws_1 = __importDefault(require("ws"));
2
+ import ws from 'ws';
3
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
9
4
  const customGlobal = global;
10
5
  // These things must exist before importing `react-devtools-core`
11
6
  if (!customGlobal.WebSocket) {
12
- customGlobal.WebSocket = ws_1.default;
7
+ customGlobal.WebSocket = ws;
13
8
  }
14
9
  if (!customGlobal.window) {
15
10
  customGlobal.window = global;
@@ -1 +1 @@
1
- {"version":3,"file":"devtools-window-polyfill.js","sourceRoot":"","sources":["../src/devtools-window-polyfill.ts"],"names":[],"mappings":";;;;;AAAA,wFAAwF;AACxF,aAAa;AACb,4CAAoB;AAEpB,MAAM,YAAY,GAAG,MAAa,CAAC;AAEnC,iEAAiE;AACjE,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;IAC5B,YAAY,CAAC,SAAS,GAAG,YAAE,CAAC;CAC5B;AAED,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;IACzB,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED,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"}
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;AACjE,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;IAC5B,YAAY,CAAC,SAAS,GAAG,EAAE,CAAC;CAC5B;AAED,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;IACzB,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED,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"}
@@ -1 +1 @@
1
- import './devtools-window-polyfill';
1
+ import './devtools-window-polyfill.js';
package/build/devtools.js CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  // eslint-disable-next-line import/no-unassigned-import
4
- require("./devtools-window-polyfill");
5
- // @ts-ignore
6
- const react_devtools_core_1 = require("react-devtools-core");
7
- react_devtools_core_1.connectToDevTools();
2
+ import './devtools-window-polyfill.js';
3
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
+ // @ts-expect-error
5
+ import devtools from 'react-devtools-core';
6
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
7
+ devtools.connectToDevTools();
8
8
  //# sourceMappingURL=devtools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.js","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":";;AAAA,uDAAuD;AACvD,sCAAoC;AAEpC,aAAa;AACb,6DAAsD;AAEtD,uCAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"devtools.js","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,+BAA+B,CAAC;AAEvC,6DAA6D;AAC7D,mBAAmB;AACnB,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAE3C,6DAA6D;AAC5D,QAAgB,CAAC,iBAAiB,EAAE,CAAC"}
package/build/dom.d.ts CHANGED
@@ -1,39 +1,36 @@
1
- /// <reference types="yoga-layout" />
2
- import Yoga from 'yoga-layout-prebuilt';
3
- import { Styles } from './styles';
4
- import { OutputTransformer } from './render-node-to-output';
5
- interface InkNode {
6
- parentNode: DOMElement | null;
7
- yogaNode?: Yoga.YogaNode;
1
+ import { type Node as YogaNode } from 'yoga-wasm-web/auto';
2
+ import { type Styles } from './styles.js';
3
+ import { type OutputTransformer } from './render-node-to-output.js';
4
+ type InkNode = {
5
+ parentNode: DOMElement | undefined;
6
+ yogaNode?: YogaNode;
8
7
  internal_static?: boolean;
9
8
  style: Styles;
10
- }
11
- export declare const TEXT_NAME = "#text";
12
- export declare type TextName = '#text';
13
- export declare type ElementNames = 'ink-root' | 'ink-box' | 'ink-text' | 'ink-virtual-text';
14
- export declare type NodeNames = ElementNames | TextName;
15
- export declare type DOMElement = {
9
+ };
10
+ export type TextName = '#text';
11
+ export type ElementNames = 'ink-root' | 'ink-box' | 'ink-text' | 'ink-virtual-text';
12
+ export type NodeNames = ElementNames | TextName;
13
+ export type DOMElement = {
16
14
  nodeName: ElementNames;
17
- attributes: {
18
- [key: string]: DOMNodeAttribute;
19
- };
15
+ attributes: Record<string, DOMNodeAttribute>;
20
16
  childNodes: DOMNode[];
21
17
  internal_transform?: OutputTransformer;
22
18
  isStaticDirty?: boolean;
23
- staticNode?: any;
19
+ staticNode?: DOMElement;
20
+ onComputeLayout?: () => void;
24
21
  onRender?: () => void;
25
22
  onImmediateRender?: () => void;
26
23
  } & InkNode;
27
- export declare type TextNode = {
24
+ export type TextNode = {
28
25
  nodeName: TextName;
29
26
  nodeValue: string;
30
27
  } & InkNode;
31
- export declare type DOMNode<T = {
28
+ export type DOMNode<T = {
32
29
  nodeName: NodeNames;
33
30
  }> = T extends {
34
31
  nodeName: infer U;
35
32
  } ? U extends '#text' ? TextNode : DOMElement : never;
36
- export declare type DOMNodeAttribute = boolean | string | number;
33
+ export type DOMNodeAttribute = boolean | string | number;
37
34
  export declare const createNode: (nodeName: ElementNames) => DOMElement;
38
35
  export declare const appendChildNode: (node: DOMElement, childNode: DOMElement) => void;
39
36
  export declare const insertBeforeNode: (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode) => void;
package/build/dom.js CHANGED
@@ -1,72 +1,62 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setTextNodeValue = exports.createTextNode = exports.setStyle = exports.setAttribute = exports.removeChildNode = exports.insertBeforeNode = exports.appendChildNode = exports.createNode = exports.TEXT_NAME = void 0;
7
- const yoga_layout_prebuilt_1 = __importDefault(require("yoga-layout-prebuilt"));
8
- const measure_text_1 = __importDefault(require("./measure-text"));
9
- const styles_1 = __importDefault(require("./styles"));
10
- const wrap_text_1 = __importDefault(require("./wrap-text"));
11
- const squash_text_nodes_1 = __importDefault(require("./squash-text-nodes"));
12
- exports.TEXT_NAME = '#text';
13
- exports.createNode = (nodeName) => {
14
- var _a;
1
+ // eslint-disable-next-line n/file-extension-in-import
2
+ import Yoga from 'yoga-wasm-web/auto';
3
+ import measureText from './measure-text.js';
4
+ import applyStyles from './styles.js';
5
+ import wrapText from './wrap-text.js';
6
+ import squashTextNodes from './squash-text-nodes.js';
7
+ export const createNode = (nodeName) => {
15
8
  const node = {
16
9
  nodeName,
17
10
  style: {},
18
11
  attributes: {},
19
12
  childNodes: [],
20
- parentNode: null,
21
- yogaNode: nodeName === 'ink-virtual-text' ? undefined : yoga_layout_prebuilt_1.default.Node.create()
13
+ parentNode: undefined,
14
+ yogaNode: nodeName === 'ink-virtual-text' ? undefined : Yoga.Node.create()
22
15
  };
23
16
  if (nodeName === 'ink-text') {
24
- (_a = node.yogaNode) === null || _a === void 0 ? void 0 : _a.setMeasureFunc(measureTextNode.bind(null, node));
17
+ node.yogaNode?.setMeasureFunc(measureTextNode.bind(null, node));
25
18
  }
26
19
  return node;
27
20
  };
28
- exports.appendChildNode = (node, childNode) => {
29
- var _a;
21
+ export const appendChildNode = (node, childNode) => {
30
22
  if (childNode.parentNode) {
31
- exports.removeChildNode(childNode.parentNode, childNode);
23
+ removeChildNode(childNode.parentNode, childNode);
32
24
  }
33
25
  childNode.parentNode = node;
34
26
  node.childNodes.push(childNode);
35
27
  if (childNode.yogaNode) {
36
- (_a = node.yogaNode) === null || _a === void 0 ? void 0 : _a.insertChild(childNode.yogaNode, node.yogaNode.getChildCount());
28
+ node.yogaNode?.insertChild(childNode.yogaNode, node.yogaNode.getChildCount());
37
29
  }
38
30
  if (node.nodeName === 'ink-text' || node.nodeName === 'ink-virtual-text') {
39
31
  markNodeAsDirty(node);
40
32
  }
41
33
  };
42
- exports.insertBeforeNode = (node, newChildNode, beforeChildNode) => {
43
- var _a, _b;
34
+ export const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
44
35
  if (newChildNode.parentNode) {
45
- exports.removeChildNode(newChildNode.parentNode, newChildNode);
36
+ removeChildNode(newChildNode.parentNode, newChildNode);
46
37
  }
47
38
  newChildNode.parentNode = node;
48
39
  const index = node.childNodes.indexOf(beforeChildNode);
49
40
  if (index >= 0) {
50
41
  node.childNodes.splice(index, 0, newChildNode);
51
42
  if (newChildNode.yogaNode) {
52
- (_a = node.yogaNode) === null || _a === void 0 ? void 0 : _a.insertChild(newChildNode.yogaNode, index);
43
+ node.yogaNode?.insertChild(newChildNode.yogaNode, index);
53
44
  }
54
45
  return;
55
46
  }
56
47
  node.childNodes.push(newChildNode);
57
48
  if (newChildNode.yogaNode) {
58
- (_b = node.yogaNode) === null || _b === void 0 ? void 0 : _b.insertChild(newChildNode.yogaNode, node.yogaNode.getChildCount());
49
+ node.yogaNode?.insertChild(newChildNode.yogaNode, node.yogaNode.getChildCount());
59
50
  }
60
51
  if (node.nodeName === 'ink-text' || node.nodeName === 'ink-virtual-text') {
61
52
  markNodeAsDirty(node);
62
53
  }
63
54
  };
64
- exports.removeChildNode = (node, removeNode) => {
65
- var _a, _b;
55
+ export const removeChildNode = (node, removeNode) => {
66
56
  if (removeNode.yogaNode) {
67
- (_b = (_a = removeNode.parentNode) === null || _a === void 0 ? void 0 : _a.yogaNode) === null || _b === void 0 ? void 0 : _b.removeChild(removeNode.yogaNode);
57
+ removeNode.parentNode?.yogaNode?.removeChild(removeNode.yogaNode);
68
58
  }
69
- removeNode.parentNode = null;
59
+ removeNode.parentNode = undefined;
70
60
  const index = node.childNodes.indexOf(removeNode);
71
61
  if (index >= 0) {
72
62
  node.childNodes.splice(index, 1);
@@ -75,30 +65,29 @@ exports.removeChildNode = (node, removeNode) => {
75
65
  markNodeAsDirty(node);
76
66
  }
77
67
  };
78
- exports.setAttribute = (node, key, value) => {
68
+ export const setAttribute = (node, key, value) => {
79
69
  node.attributes[key] = value;
80
70
  };
81
- exports.setStyle = (node, style) => {
71
+ export const setStyle = (node, style) => {
82
72
  node.style = style;
83
73
  if (node.yogaNode) {
84
- styles_1.default(node.yogaNode, style);
74
+ applyStyles(node.yogaNode, style);
85
75
  }
86
76
  };
87
- exports.createTextNode = (text) => {
77
+ export const createTextNode = (text) => {
88
78
  const node = {
89
79
  nodeName: '#text',
90
80
  nodeValue: text,
91
81
  yogaNode: undefined,
92
- parentNode: null,
82
+ parentNode: undefined,
93
83
  style: {}
94
84
  };
95
- exports.setTextNodeValue(node, text);
85
+ setTextNodeValue(node, text);
96
86
  return node;
97
87
  };
98
88
  const measureTextNode = function (node, width) {
99
- var _a, _b;
100
- const text = node.nodeName === '#text' ? node.nodeValue : squash_text_nodes_1.default(node);
101
- const dimensions = measure_text_1.default(text);
89
+ const text = node.nodeName === '#text' ? node.nodeValue : squashTextNodes(node);
90
+ const dimensions = measureText(text);
102
91
  // Text fits into container, no need to wrap
103
92
  if (dimensions.width <= width) {
104
93
  return dimensions;
@@ -108,23 +97,22 @@ const measureTextNode = function (node, width) {
108
97
  if (dimensions.width >= 1 && width > 0 && width < 1) {
109
98
  return dimensions;
110
99
  }
111
- const textWrap = (_b = (_a = node.style) === null || _a === void 0 ? void 0 : _a.textWrap) !== null && _b !== void 0 ? _b : 'wrap';
112
- const wrappedText = wrap_text_1.default(text, width, textWrap);
113
- return measure_text_1.default(wrappedText);
100
+ const textWrap = node.style?.textWrap ?? 'wrap';
101
+ const wrappedText = wrapText(text, width, textWrap);
102
+ return measureText(wrappedText);
114
103
  };
115
104
  const findClosestYogaNode = (node) => {
116
- var _a;
117
- if (!node || !node.parentNode) {
105
+ if (!node?.parentNode) {
118
106
  return undefined;
119
107
  }
120
- return (_a = node.yogaNode) !== null && _a !== void 0 ? _a : findClosestYogaNode(node.parentNode);
108
+ return node.yogaNode ?? findClosestYogaNode(node.parentNode);
121
109
  };
122
110
  const markNodeAsDirty = (node) => {
123
111
  // Mark closest Yoga node as dirty to measure text dimensions again
124
112
  const yogaNode = findClosestYogaNode(node);
125
- yogaNode === null || yogaNode === void 0 ? void 0 : yogaNode.markDirty();
113
+ yogaNode?.markDirty();
126
114
  };
127
- exports.setTextNodeValue = (node, text) => {
115
+ export const setTextNodeValue = (node, text) => {
128
116
  if (typeof text !== 'string') {
129
117
  text = String(text);
130
118
  }
package/build/dom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":";;;;;;AAAA,gFAAoD;AACpD,kEAAyC;AACzC,sDAA6C;AAC7C,4DAAmC;AACnC,4EAAkD;AAUrC,QAAA,SAAS,GAAG,OAAO,CAAC;AAwCpB,QAAA,UAAU,GAAG,CAAC,QAAsB,EAAc,EAAE;;IAChE,MAAM,IAAI,GAAe;QACxB,QAAQ;QACR,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,QAAQ,KAAK,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,8BAAI,CAAC,IAAI,CAAC,MAAM,EAAE;KAC1E,CAAC;IAEF,IAAI,QAAQ,KAAK,UAAU,EAAE;QAC5B,MAAA,IAAI,CAAC,QAAQ,0CAAE,cAA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AAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAwB,EAAE;IACpE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE;QACtB,OAAO,SAAS,CAAC;KACjB;IAED,OAAO,IAAI,CAAC,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAAc,EAAQ,EAAE;IAChD,mEAAmE;IACnE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAc,EAAE,IAAY,EAAQ,EAAE;IACtE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC7B,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;KACpB;IAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACtB,eAAe,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
- import Yoga from 'yoga-layout-prebuilt';
2
- declare const _default: (yogaNode: Yoga.YogaNode) => number;
3
- export default _default;
1
+ import { type Node as YogaNode } from 'yoga-wasm-web/auto';
2
+ declare const getMaxWidth: (yogaNode: YogaNode) => number;
3
+ export default getMaxWidth;