ink 3.0.7 → 3.2.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 (58) hide show
  1. package/build/components/App.d.ts +1 -0
  2. package/build/components/App.js +19 -5
  3. package/build/components/App.js.map +1 -1
  4. package/build/components/FocusContext.d.ts +1 -0
  5. package/build/components/FocusContext.js +2 -1
  6. package/build/components/FocusContext.js.map +1 -1
  7. package/build/components/Static.d.ts +1 -1
  8. package/build/components/Text.d.ts +2 -2
  9. package/build/components/Text.js.map +1 -1
  10. package/build/{test.d.ts → devtools-window-polyfill.d.ts} +0 -0
  11. package/build/devtools-window-polyfill.js +72 -0
  12. package/build/devtools-window-polyfill.js.map +1 -0
  13. package/build/devtools.d.ts +1 -1
  14. package/build/devtools.js +2 -69
  15. package/build/devtools.js.map +1 -1
  16. package/build/hooks/use-focus-manager.d.ts +5 -0
  17. package/build/hooks/use-focus-manager.js +2 -1
  18. package/build/hooks/use-focus-manager.js.map +1 -1
  19. package/build/hooks/use-focus.d.ts +9 -1
  20. package/build/hooks/use-focus.js +7 -4
  21. package/build/hooks/use-focus.js.map +1 -1
  22. package/build/hooks/use-input.d.ts +1 -1
  23. package/build/hooks/use-input.js +1 -1
  24. package/build/ink.js +3 -1
  25. package/build/ink.js.map +1 -1
  26. package/build/output.js +3 -3
  27. package/build/output.js.map +1 -1
  28. package/build/reconciler.d.ts +1 -1
  29. package/build/reconciler.js +7 -4
  30. package/build/reconciler.js.map +1 -1
  31. package/package.json +12 -13
  32. package/readme.md +51 -7
  33. package/build/apply-styles.d.ts +0 -25
  34. package/build/apply-styles.js +0 -164
  35. package/build/apply-styles.js.map +0 -1
  36. package/build/build-layout.d.ts +0 -9
  37. package/build/build-layout.js +0 -63
  38. package/build/build-layout.js.map +0 -1
  39. package/build/calculate-wrapped-text.d.ts +0 -1
  40. package/build/calculate-wrapped-text.js +0 -34
  41. package/build/calculate-wrapped-text.js.map +0 -1
  42. package/build/components/Color.d.ts +0 -17
  43. package/build/components/Color.js +0 -91
  44. package/build/components/Color.js.map +0 -1
  45. package/build/components/DeprecatedStatic.d.ts +0 -33
  46. package/build/components/DeprecatedStatic.js +0 -84
  47. package/build/components/DeprecatedStatic.js.map +0 -1
  48. package/build/components/Error.d.ts +0 -0
  49. package/build/components/Error.js +0 -2
  50. package/build/components/Error.js.map +0 -1
  51. package/build/components/Focus.d.ts +0 -55
  52. package/build/components/Focus.js +0 -229
  53. package/build/components/Focus.js.map +0 -1
  54. package/build/draw-border.d.ts +0 -4
  55. package/build/draw-border.js +0 -48
  56. package/build/draw-border.js.map +0 -1
  57. package/build/test.js +0 -8
  58. package/build/test.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ink",
3
- "version": "3.0.7",
3
+ "version": "3.2.0",
4
4
  "description": "React for CLI",
5
5
  "license": "MIT",
6
6
  "repository": "vadimdemedes/ink",
@@ -17,8 +17,7 @@
17
17
  "scripts": {
18
18
  "build": "tsc",
19
19
  "prepare": "npm run build",
20
- "test": "tsc --noEmit && xo && FORCE_COLOR=true ava",
21
- "cast": "svg-term --command='node media/demo.js' --out=media/demo.svg --from=100 --window --width=50 --height=8 --term=iterm2 --profile=Snazzy"
20
+ "test": "tsc --noEmit && xo && FORCE_COLOR=true ava"
22
21
  },
23
22
  "files": [
24
23
  "build"
@@ -49,17 +48,17 @@
49
48
  "is-ci": "^2.0.0",
50
49
  "lodash": "^4.17.20",
51
50
  "patch-console": "^1.0.0",
52
- "react-devtools-core": "^4.6.0",
53
- "react-reconciler": "^0.24.0",
54
- "scheduler": "^0.18.0",
51
+ "react-devtools-core": "^4.19.1",
52
+ "react-reconciler": "^0.26.2",
53
+ "scheduler": "^0.20.2",
55
54
  "signal-exit": "^3.0.2",
56
55
  "slice-ansi": "^3.0.0",
57
56
  "stack-utils": "^2.0.2",
58
- "string-length": "^3.1.0",
57
+ "string-width": "^4.2.2",
59
58
  "type-fest": "^0.12.0",
60
59
  "widest-line": "^3.1.0",
61
60
  "wrap-ansi": "^6.2.0",
62
- "ws": "^7.2.5",
61
+ "ws": "^7.5.5",
63
62
  "yoga-layout-prebuilt": "^1.9.6"
64
63
  },
65
64
  "devDependencies": {
@@ -67,9 +66,9 @@
67
66
  "@types/is-ci": "^2.0.0",
68
67
  "@types/lodash": "^4.14.161",
69
68
  "@types/node": "*",
70
- "@types/react": "^16.9.41",
71
- "@types/react-reconciler": "^0.18.0",
72
- "@types/scheduler": "^0.16.1",
69
+ "@types/react": "^17.0.27",
70
+ "@types/react-reconciler": "^0.26.4",
71
+ "@types/scheduler": "^0.16.2",
73
72
  "@types/signal-exit": "^3.0.0",
74
73
  "@types/sinon": "^9.0.4",
75
74
  "@types/slice-ansi": "^4.0.0",
@@ -92,10 +91,9 @@
92
91
  "node-pty": "^0.9.0",
93
92
  "p-queue": "^6.2.1",
94
93
  "prettier": "^2.0.4",
95
- "react": "^16.9.0",
94
+ "react": "^17.0.2",
96
95
  "sinon": "^8.1.1",
97
96
  "strip-ansi": "^6.0.0",
98
- "svg-term-cli": "^2.1.1",
99
97
  "ts-node": "7.0.0",
100
98
  "typescript": "^3.8.3",
101
99
  "xo": "^0.28.0"
@@ -150,6 +148,7 @@
150
148
  ],
151
149
  "unicorn/filename-case": "off",
152
150
  "react/prop-types": "off",
151
+ "react/default-props-match-prop-types": "off",
153
152
  "unicorn/prevent-abbreviations": "off",
154
153
  "react/require-default-props": "warn",
155
154
  "react/jsx-curly-brace-presence": "off",
package/readme.md CHANGED
@@ -61,9 +61,7 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
61
61
  ## Who's Using Ink?
62
62
 
63
63
  - [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing fast websites.
64
- - [Parcel](https://parceljs.org) - Blazing fast, zero configuration web application bundler.
65
64
  - [tap](https://node-tap.org) - A Test-Anything-Protocol library for JavaScript.
66
- - [Yarn 2](https://yarnpkg.com) - Fast, reliable, and secure dependency management for JavaScript.
67
65
  - [Terraform CDK](https://github.com/hashicorp/terraform-cdk) - CDK (Cloud Development Kit) for HashiCorp Terraform.
68
66
  - [Twilio's SIGNAL](https://github.com/twilio-labs/plugin-signal2020) - CLI for Twilio's SIGNAL conference. [Blog post](https://www.twilio.com/blog/building-conference-cli-in-react).
69
67
  - [Typewriter](https://github.com/segmentio/typewriter) - Generates strongly-typed [Segment](https://segment.com) analytics clients from arbitrary JSON Schema.
@@ -89,6 +87,9 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
89
87
  - [garson](https://github.com/goliney/garson) - Build interactive config-based command-line interfaces.
90
88
  - [git-contrib-calendar](https://github.com/giannisp/git-contrib-calendar) - Display a contributions calendar for any git repository.
91
89
  - [gitgud](https://github.com/GitGud-org/GitGud) - An interactive command-line GUI for Git.
90
+ - [Autarky](https://github.com/pranshuchittora/autarky) - An interactive CLI to find and delete old `node_modules` directories in order to free up disk space.
91
+ - [fast-cli](https://github.com/sindresorhus/fast-cli) - Test your download and upload speed.
92
+ - [tasuku](https://github.com/privatenumber/tasuku) - Minimal task runner.
92
93
 
93
94
  ## Contents
94
95
 
@@ -125,6 +126,12 @@ $ cd my-ink-cli
125
126
  $ npx create-ink-app
126
127
  ```
127
128
 
129
+ Alternatively, create a TypeScript project:
130
+
131
+ ```
132
+ $ npx create-ink-app --typescript
133
+ ```
134
+
128
135
  <details><summary>Manual setup</summary>
129
136
  <p>
130
137
  Ink requires the same Babel setup as you would do for regular React-based apps in the browser.
@@ -343,11 +350,11 @@ It's like `<div style="display: flex">` in the browser.
343
350
  ```jsx
344
351
  import {render, Box, Text} from 'ink';
345
352
 
346
- const Example = () => {
353
+ const Example = () => (
347
354
  <Box margin={2}>
348
355
  <Text>This is a box with margin</Text>
349
- </Box>;
350
- };
356
+ </Box>
357
+ );
351
358
 
352
359
  render(<Example />);
353
360
  ```
@@ -1075,7 +1082,7 @@ Output of child components.
1075
1082
  ### useInput(inputHandler, options?)
1076
1083
 
1077
1084
  This hook is used for handling user input.
1078
- It's a more convienient alternative to using `useStdin` and listening to `data` events.
1085
+ It's a more convenient alternative to using `useStdin` and listening to `data` events.
1079
1086
  The callback you pass to `useInput` is called for each character when user enters any input.
1080
1087
  However, if user pastes text and it's more than one character, the callback will be called only once and the whole string will be passed as `input`.
1081
1088
  You can find a full example of using `useInput` at [examples/use-input](examples/use-input/use-input.js).
@@ -1435,6 +1442,13 @@ Default: `true`
1435
1442
  Enable or disable this component's focus, while still maintaining its position in the list of focusable components.
1436
1443
  This is useful for inputs that are temporarily disabled.
1437
1444
 
1445
+ ##### id
1446
+
1447
+ Type: `string`\
1448
+ Required: `false`
1449
+
1450
+ Set a component's focus ID, which can be used to programmatically focus the component. This is useful for large interfaces with many focusable elements, to avoid having to cycle through all of them.
1451
+
1438
1452
  ```jsx
1439
1453
  import {render, useFocus, Text} from 'ink';
1440
1454
 
@@ -1447,7 +1461,7 @@ const Example = () => {
1447
1461
  render(<Example />);
1448
1462
  ```
1449
1463
 
1450
- See example in [examples/use-focus](examples/use-focus/use-focus.js).
1464
+ See example in [examples/use-focus](examples/use-focus/use-focus.js) and [examples/use-focus-with-id](examples/use-focus/use-focus-with-id.js).
1451
1465
 
1452
1466
  ### useFocusManager()
1453
1467
 
@@ -1536,6 +1550,32 @@ const Example = () => {
1536
1550
  };
1537
1551
  ```
1538
1552
 
1553
+ #### focus(id)
1554
+
1555
+ ##### id
1556
+
1557
+ Type: `string`
1558
+
1559
+ Switch focus to the component with the given [`id`](#id).
1560
+ If there's no component with that ID, focus will be given to the next focusable component.
1561
+
1562
+ ```js
1563
+ import {useFocusManager, useInput} from 'ink';
1564
+
1565
+ const Example = () => {
1566
+ const {focus} = useFocusManager();
1567
+
1568
+ useInput(input => {
1569
+ if (input === 's') {
1570
+ // Focus the component with focus ID 'someId'
1571
+ focus('someId');
1572
+ }
1573
+ });
1574
+
1575
+ return …
1576
+ };
1577
+ ```
1578
+
1539
1579
  ## API
1540
1580
 
1541
1581
  #### render(tree, options?)
@@ -1741,6 +1781,9 @@ You can even inspect and change the props of components, and see the results imm
1741
1781
  - [ink-markdown](https://github.com/cameronhunter/ink-markdown) - Render syntax highlighted Markdown.
1742
1782
  - [ink-quicksearch-input](https://github.com/Eximchain/ink-quicksearch-input) - Select component with fast quicksearch-like navigation.
1743
1783
  - [ink-confirm-input](https://github.com/kevva/ink-confirm-input) - Yes/No confirmation input.
1784
+ - [ink-syntax-highlight](https://github.com/vsashyn/ink-syntax-highlight) - Code syntax highlighting.
1785
+ - [ink-form](https://github.com/lukasbach/ink-form) - Form component.
1786
+ - [ink-task-list](https://github.com/privatenumber/ink-task-list) - Task list component.
1744
1787
 
1745
1788
  ## Useful Hooks
1746
1789
 
@@ -1759,6 +1802,7 @@ You can even inspect and change the props of components, and see the results imm
1759
1802
  - [Write to stdout](examples/use-stdout/use-stdout.js) - Write to stdout bypassing main Ink output.
1760
1803
  - [Write to stderr](examples/use-stderr/use-stderr.js) - Write to stderr bypassing main Ink output.
1761
1804
  - [Static](examples/static/static.js) - Use `<Static>` to render permanent output.
1805
+ - [Child process](examples/subprocess-output) - Render output from a child process.
1762
1806
 
1763
1807
  ## Maintainers
1764
1808
 
@@ -1,25 +0,0 @@
1
- import type { YogaNode } from 'yoga-layout-prebuilt';
2
- export interface Styles {
3
- textWrap?: 'wrap' | 'end' | 'middle' | 'truncate-end' | 'truncate' | 'truncate-middle' | 'truncate-start';
4
- position?: 'absolute' | 'relative';
5
- marginTop?: number;
6
- marginBottom?: number;
7
- marginLeft?: number;
8
- marginRight?: number;
9
- paddingTop?: number;
10
- paddingBottom?: number;
11
- paddingLeft?: number;
12
- paddingRight?: number;
13
- flexGrow?: number;
14
- flexShrink?: number;
15
- flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
16
- flexBasis?: number | string;
17
- alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch';
18
- justifyContent?: 'flex-start' | 'flex-end' | 'space-between' | 'space-around' | 'center';
19
- width?: number | string;
20
- height?: number | string;
21
- minWidth?: number | string;
22
- minHeight?: number | string;
23
- display?: 'flex' | 'none';
24
- }
25
- export declare const applyStyles: (node: YogaNode, style?: Styles) => void;
@@ -1,164 +0,0 @@
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.applyStyles = void 0;
7
- /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
8
- const yoga_layout_prebuilt_1 = __importDefault(require("yoga-layout-prebuilt"));
9
- const applyPositionStyles = (node, style) => {
10
- if ('position' in style) {
11
- node.setPositionType(style.position === 'absolute'
12
- ? yoga_layout_prebuilt_1.default.POSITION_TYPE_ABSOLUTE
13
- : yoga_layout_prebuilt_1.default.POSITION_TYPE_RELATIVE);
14
- }
15
- };
16
- const applyMarginStyles = (node, style) => {
17
- if ('marginLeft' in style) {
18
- node.setMargin(yoga_layout_prebuilt_1.default.EDGE_START, style.marginLeft || 0);
19
- }
20
- if ('marginRight' in style) {
21
- node.setMargin(yoga_layout_prebuilt_1.default.EDGE_END, style.marginRight || 0);
22
- }
23
- if ('marginTop' in style) {
24
- node.setMargin(yoga_layout_prebuilt_1.default.EDGE_TOP, style.marginTop || 0);
25
- }
26
- if ('marginBottom' in style) {
27
- node.setMargin(yoga_layout_prebuilt_1.default.EDGE_BOTTOM, style.marginBottom || 0);
28
- }
29
- };
30
- const applyPaddingStyles = (node, style) => {
31
- if ('paddingLeft' in style) {
32
- node.setPadding(yoga_layout_prebuilt_1.default.EDGE_LEFT, style.paddingLeft || 0);
33
- }
34
- if ('paddingRight' in style) {
35
- node.setPadding(yoga_layout_prebuilt_1.default.EDGE_RIGHT, style.paddingRight || 0);
36
- }
37
- if ('paddingTop' in style) {
38
- node.setPadding(yoga_layout_prebuilt_1.default.EDGE_TOP, style.paddingTop || 0);
39
- }
40
- if ('paddingBottom' in style) {
41
- node.setPadding(yoga_layout_prebuilt_1.default.EDGE_BOTTOM, style.paddingBottom || 0);
42
- }
43
- };
44
- const applyFlexStyles = (node, style) => {
45
- var _a;
46
- if ('flexGrow' in style) {
47
- node.setFlexGrow((_a = style.flexGrow) !== null && _a !== void 0 ? _a : 0);
48
- }
49
- if ('flexShrink' in style) {
50
- node.setFlexShrink(typeof style.flexShrink === 'number' ? style.flexShrink : 1);
51
- }
52
- if ('flexDirection' in style) {
53
- if (style.flexDirection === 'row') {
54
- node.setFlexDirection(yoga_layout_prebuilt_1.default.FLEX_DIRECTION_ROW);
55
- }
56
- if (style.flexDirection === 'row-reverse') {
57
- node.setFlexDirection(yoga_layout_prebuilt_1.default.FLEX_DIRECTION_ROW_REVERSE);
58
- }
59
- if (style.flexDirection === 'column') {
60
- node.setFlexDirection(yoga_layout_prebuilt_1.default.FLEX_DIRECTION_COLUMN);
61
- }
62
- if (style.flexDirection === 'column-reverse') {
63
- node.setFlexDirection(yoga_layout_prebuilt_1.default.FLEX_DIRECTION_COLUMN_REVERSE);
64
- }
65
- }
66
- if ('flexBasis' in style) {
67
- if (typeof style.flexBasis === 'number') {
68
- node.setFlexBasis(style.flexBasis);
69
- }
70
- else if (typeof style.flexBasis === 'string') {
71
- node.setFlexBasisPercent(Number.parseInt(style.flexBasis, 10));
72
- }
73
- else {
74
- // This should be replaced with node.setFlexBasisAuto() when new Yoga release is out
75
- node.setFlexBasis(NaN);
76
- }
77
- }
78
- if ('alignItems' in style) {
79
- if (style.alignItems === 'stretch' || !style.alignItems) {
80
- node.setAlignItems(yoga_layout_prebuilt_1.default.ALIGN_STRETCH);
81
- }
82
- if (style.alignItems === 'flex-start') {
83
- node.setAlignItems(yoga_layout_prebuilt_1.default.ALIGN_FLEX_START);
84
- }
85
- if (style.alignItems === 'center') {
86
- node.setAlignItems(yoga_layout_prebuilt_1.default.ALIGN_CENTER);
87
- }
88
- if (style.alignItems === 'flex-end') {
89
- node.setAlignItems(yoga_layout_prebuilt_1.default.ALIGN_FLEX_END);
90
- }
91
- }
92
- if ('justifyContent' in style) {
93
- if (style.justifyContent === 'flex-start' || !style.justifyContent) {
94
- node.setJustifyContent(yoga_layout_prebuilt_1.default.JUSTIFY_FLEX_START);
95
- }
96
- if (style.justifyContent === 'center') {
97
- node.setJustifyContent(yoga_layout_prebuilt_1.default.JUSTIFY_CENTER);
98
- }
99
- if (style.justifyContent === 'flex-end') {
100
- node.setJustifyContent(yoga_layout_prebuilt_1.default.JUSTIFY_FLEX_END);
101
- }
102
- if (style.justifyContent === 'space-between') {
103
- node.setJustifyContent(yoga_layout_prebuilt_1.default.JUSTIFY_SPACE_BETWEEN);
104
- }
105
- if (style.justifyContent === 'space-around') {
106
- node.setJustifyContent(yoga_layout_prebuilt_1.default.JUSTIFY_SPACE_AROUND);
107
- }
108
- }
109
- };
110
- const applyDimensionStyles = (node, style) => {
111
- var _a, _b;
112
- if ('width' in style) {
113
- if (typeof style.width === 'number') {
114
- node.setWidth(style.width);
115
- }
116
- else if (typeof style.width === 'string') {
117
- node.setWidthPercent(Number.parseInt(style.width, 10));
118
- }
119
- else {
120
- node.setWidthAuto();
121
- }
122
- }
123
- if ('height' in style) {
124
- if (typeof style.height === 'number') {
125
- node.setHeight(style.height);
126
- }
127
- else if (typeof style.height === 'string') {
128
- node.setHeightPercent(Number.parseInt(style.height, 10));
129
- }
130
- else {
131
- node.setHeightAuto();
132
- }
133
- }
134
- if ('minWidth' in style) {
135
- if (typeof style.minWidth === 'string') {
136
- node.setMinWidthPercent(Number.parseInt(style.minWidth, 10));
137
- }
138
- else {
139
- node.setMinWidth((_a = style.minWidth) !== null && _a !== void 0 ? _a : 0);
140
- }
141
- }
142
- if ('minHeight' in style) {
143
- if (typeof style.minHeight === 'string') {
144
- node.setMinHeightPercent(Number.parseInt(style.minHeight, 10));
145
- }
146
- else {
147
- node.setMinHeight((_b = style.minHeight) !== null && _b !== void 0 ? _b : 0);
148
- }
149
- }
150
- };
151
- const applyDisplayStyles = (node, style) => {
152
- if ('display' in style) {
153
- node.setDisplay(style.display === 'flex' ? yoga_layout_prebuilt_1.default.DISPLAY_FLEX : yoga_layout_prebuilt_1.default.DISPLAY_NONE);
154
- }
155
- };
156
- exports.applyStyles = (node, style = {}) => {
157
- applyPositionStyles(node, style);
158
- applyMarginStyles(node, style);
159
- applyPaddingStyles(node, style);
160
- applyFlexStyles(node, style);
161
- applyDimensionStyles(node, style);
162
- applyDisplayStyles(node, style);
163
- };
164
- //# sourceMappingURL=apply-styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apply-styles.js","sourceRoot":"","sources":["../src/apply-styles.ts"],"names":[],"mappings":";;;;;;AAAA,iEAAiE;AACjE,gFAAwC;AAuCxC,MAAM,mBAAmB,GAAG,CAAC,IAAmB,EAAE,KAAa,EAAQ,EAAE;IACxE,IAAI,UAAU,IAAI,KAAK,EAAE;QACxB,IAAI,CAAC,eAAe,CACnB,KAAK,CAAC,QAAQ,KAAK,UAAU;YAC5B,CAAC,CAAC,8BAAI,CAAC,sBAAsB;YAC7B,CAAC,CAAC,8BAAI,CAAC,sBAAsB,CAC9B,CAAC;KACF;AACF,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,IAAmB,EAAE,KAAa,EAAQ,EAAE;IACtE,IAAI,YAAY,IAAI,KAAK,EAAE;QAC1B,IAAI,CAAC,SAAS,CAAC,8BAAI,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;KACvD;IAED,IAAI,aAAa,IAAI,KAAK,EAAE;QAC3B,IAAI,CAAC,SAAS,CAAC,8BAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;KACtD;IAED,IAAI,WAAW,IAAI,KAAK,EAAE;QACzB,IAAI,CAAC,SAAS,CAAC,8BAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;KACpD;IAED,IAAI,cAAc,IAAI,KAAK,EAAE;QAC5B,IAAI,CAAC,SAAS,CAAC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KACF;AACF,CAAC,CAAC;AAEW,QAAA,WAAW,GAAG,CAAC,IAAc,EAAE,QAAgB,EAAE,EAAQ,EAAE;IACvE,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjC,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- /// <reference types="yoga-layout" />
2
- import Yoga from 'yoga-layout-prebuilt';
3
- interface BuildLayoutOptions {
4
- config: Yoga.YogaConfig;
5
- terminalWidth: number;
6
- skipStaticElements: boolean;
7
- }
8
- export declare const buildLayout: (node: import("./dom").TextNode | import("./dom").DOMElement, options: BuildLayoutOptions) => import("./dom").TextNode | import("./dom").DOMElement;
9
- export {};
@@ -1,63 +0,0 @@
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 yoga_layout_prebuilt_1 = __importDefault(require("yoga-layout-prebuilt"));
7
- const apply_styles_1 = require("./apply-styles");
8
- const measure_text_1 = require("./measure-text");
9
- // Traverse the node tree, create Yoga nodes and assign styles to each Yoga node
10
- exports.buildLayout = (node, options) => {
11
- const { config, terminalWidth, skipStaticElements } = options;
12
- const yogaNode = yoga_layout_prebuilt_1.default.Node.createWithConfig(config);
13
- node.yogaNode = yogaNode;
14
- const { style } = node;
15
- console.log('HERE');
16
- // Root node of the tree
17
- if (node.nodeName === 'ROOT') {
18
- // `terminalWidth` can be `undefined` if env isn't a TTY
19
- yogaNode.setWidth(terminalWidth || 100);
20
- if (node.childNodes.length > 0) {
21
- const childNodes = node.childNodes.filter(childNode => {
22
- return skipStaticElements ? !childNode.unstable__static : true;
23
- });
24
- for (const [index, childNode] of Object.entries(childNodes)) {
25
- const { yogaNode: childYogaNode } = exports.buildLayout(childNode, options);
26
- if (childYogaNode) {
27
- yogaNode.insertChild(childYogaNode, Number.parseInt(index, 10));
28
- }
29
- }
30
- }
31
- return node;
32
- }
33
- // Apply margin, padding, flex, etc styles
34
- apply_styles_1.applyStyles(yogaNode, style);
35
- if (node.nodeName === '#text') {
36
- // Nodes with only text have a child Yoga node dedicated for that text
37
- if (node.nodeValue) {
38
- applySize(yogaNode, node.nodeValue, style.width, style.height);
39
- }
40
- }
41
- else if (node.textContent) {
42
- // Nodes with only text have a child Yoga node dedicated for that text
43
- applySize(yogaNode, node.textContent, style.width, style.height);
44
- }
45
- else {
46
- const childNodes = node.childNodes.filter(childNode => {
47
- return skipStaticElements ? !childNode.unstable__static : true;
48
- });
49
- for (const [index, childNode] of Object.entries(childNodes)) {
50
- const { yogaNode: childYogaNode } = exports.buildLayout(childNode, options);
51
- if (childYogaNode) {
52
- yogaNode.insertChild(childYogaNode, Number.parseInt(index, 10));
53
- }
54
- }
55
- }
56
- return node;
57
- };
58
- const applySize = (yogaNode, text, nodeWidth, nodeHeight) => {
59
- const { width, height } = measure_text_1.measureText(text);
60
- yogaNode.setWidth(nodeWidth !== null && nodeWidth !== void 0 ? nodeWidth : width);
61
- yogaNode.setHeight(nodeHeight !== null && nodeHeight !== void 0 ? nodeHeight : height);
62
- };
63
- //# sourceMappingURL=build-layout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-layout.js","sourceRoot":"","sources":["../src/build-layout.ts"],"names":[],"mappings":";;;;;AAAA,gFAAwC;AACxC,iDAA2C;AAC3C,iDAA2C;AAS3C,gFAAgF;AACnE,QAAA,WAAW,GAAG,CAC1B,IAAa,EACb,OAA2B,EACjB,EAAE;IACZ,MAAM,EAAC,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAC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| import("./dom").DOMElement) => void;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const measure_text_1 = require("./measure-text");
4
- const wrap_text_1 = require("./wrap-text");
5
- const get_max_width_1 = require("./get-max-width");
6
- // Since we need to know the width of text container to wrap text, we have to calculate layout twice
7
- // This function is executed after first layout calculation to reassign width and height of text nodes
8
- exports.calculateWrappedText = (node) => {
9
- var _a;
10
- if (node.nodeName !== '#text') {
11
- if (node.textContent &&
12
- typeof ((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.style.textWrap) === 'string') {
13
- const { yogaNode: parentYogaNode } = node.parentNode;
14
- const maxWidth = parentYogaNode ? get_max_width_1.getMaxWidth(parentYogaNode) : 0;
15
- const { yogaNode } = node;
16
- if (yogaNode) {
17
- const currentWidth = yogaNode.getComputedWidth();
18
- if (currentWidth > maxWidth) {
19
- const { textWrap } = node.parentNode.style;
20
- const wrappedText = wrap_text_1.wrapText(node.textContent, maxWidth, {
21
- textWrap
22
- });
23
- const { width, height } = measure_text_1.measureText(wrappedText);
24
- yogaNode.setWidth(width);
25
- yogaNode.setHeight(height);
26
- }
27
- }
28
- }
29
- for (const childNode of node.childNodes) {
30
- exports.calculateWrappedText(childNode);
31
- }
32
- }
33
- };
34
- //# sourceMappingURL=calculate-wrapped-text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculate-wrapped-text.js","sourceRoot":"","sources":["../src/calculate-wrapped-text.ts"],"names":[],"mappings":";;AAAA,iDAA2C;AAC3C,2CAAqC;AACrC,mDAA4C;AAG5C,oGAAoG;AACpG,sGAAsG;AACzF,QAAA,oBAAoB,GAAG,CAAC,IAAa,EAAQ,EAAE;;IAC3D,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE;QAC9B,IACC,IAAI,CAAC,WAAW;YAChB,cAAO,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC,QAAQ,CAAA,KAAK,QAAQ,EAClD;YACD,MAAM,EAAC,QAAQ,EAAE,cAAc,EAAC,GAAG,IAAI,CAAC,UAAU,CAAC;YACnD,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,2BAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAClE,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;YACxB,IAAI,QAAQ,EAAE;gBACb,MAAM,YAAY,GAAG,QAAQ,CAAC,gBAAgB,EAAE,CAAC;gBAEjD,IAAI,YAAY,GAAG,QAAQ,EAAE;oBAC5B,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;oBACzC,MAAM,WAAW,GAAG,oBAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE;wBACxD,QAAQ;qBACR,CAAC,CAAC;oBACH,MAAM,EAAC,KAAK,EAAE,MAAM,EAAC,GAAG,0BAAW,CAAC,WAAW,CAAC,CAAC;oBAEjD,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;oBACzB,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;iBAC3B;aACD;SACD;QAED,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACxC,4BAAoB,CAAC,SAAS,CAAC,CAAC;SAChC;KACD;AACF,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import type { ReactNode } from 'react';
3
- import chalk from 'chalk';
4
- import type { Chalk } from 'chalk';
5
- import type { Except } from 'type-fest';
6
- declare type Colors = typeof chalk.ForegroundColor | typeof chalk.BackgroundColor | typeof chalk.Modifiers;
7
- declare type ChalkFunctions = Except<Except<Chalk, 'Instance' | 'level'>, Colors>;
8
- declare type ChalkFunctionProps = {
9
- [K in keyof ChalkFunctions]: Parameters<ChalkFunctions[K]> extends [string] ? string : Parameters<ChalkFunctions[K]>;
10
- };
11
- declare type ChalkBooleanProps = Record<Colors, boolean>;
12
- declare type ChalkProps = Partial<ChalkBooleanProps & ChalkFunctionProps>;
13
- export declare type Props = ChalkProps & {
14
- children: ReactNode;
15
- };
16
- declare const _default: React.NamedExoticComponent<Props>;
17
- export default _default;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const react_1 = __importStar(require("react"));
37
- const prop_types_1 = __importDefault(require("prop-types"));
38
- const arrify_1 = __importDefault(require("arrify"));
39
- const chalk_1 = __importDefault(require("chalk"));
40
- const Transform_1 = __importDefault(require("./Transform"));
41
- const methods = [
42
- 'hex',
43
- 'hsl',
44
- 'hsv',
45
- 'hwb',
46
- 'rgb',
47
- 'keyword',
48
- 'bgHex',
49
- 'bgHsl',
50
- 'bgHsv',
51
- 'bgHwb',
52
- 'bgRgb',
53
- 'bgKeyword',
54
- 'ansi',
55
- 'ansi256',
56
- 'bgAnsi',
57
- 'bgAnsi256'
58
- ];
59
- /**
60
- * The `<Color>` compoment is a simple wrapper around the `chalk` API. It supports all of the `chalk`'s methods as `props`.
61
- */
62
- const Color = (_a) => {
63
- var { children } = _a, colorProps = __rest(_a, ["children"]);
64
- if (children === '') {
65
- return null;
66
- }
67
- const transform = (children) => {
68
- // @ts-ignore
69
- Object.keys(colorProps).forEach((method) => {
70
- if (colorProps[method]) {
71
- if (methods.includes(method)) {
72
- children = chalk_1.default[method](...arrify_1.default(colorProps[method]))(children);
73
- }
74
- else if (typeof chalk_1.default[method] === 'function') {
75
- children = chalk_1.default[method](children);
76
- }
77
- }
78
- });
79
- return children;
80
- };
81
- return react_1.default.createElement(Transform_1.default, { transform: transform }, children);
82
- };
83
- Color.displayName = 'Color';
84
- Color.propTypes = {
85
- children: prop_types_1.default.node
86
- };
87
- Color.defaultProps = {
88
- children: ''
89
- };
90
- exports.default = react_1.memo(Color);
91
- //# sourceMappingURL=Color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Color.js","sourceRoot":"","sources":["../../src/components/Color.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkC;AAElC,4DAAmC;AACnC,oDAA4B;AAC5B,kDAA0B;AAG1B,4DAAoC;AAqBpC,MAAM,OAAO,GAAG;IACf,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,SAAS;IACT,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,WAAW;IACX,MAAM;IACN,SAAS;IACT,QAAQ;IACR,WAAW;CACX,CAAC;AAEF;;GAEG;AACH,MAAM,KAAK,GAAc,CA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