@alchemy.run/sigil 0.0.0-alpha.1 → 0.0.0-alpha.3

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 (121) hide show
  1. package/README.md +299 -299
  2. package/dist/ansi.d.ts +223 -0
  3. package/dist/ansi.js +2 -0
  4. package/dist/{devtools-QpCMm9JH.mjs → devtools-BhYGjb7h.js} +1 -1
  5. package/dist/index-DDVME65c.d.ts +919 -0
  6. package/dist/index.d.ts +1658 -0
  7. package/dist/index.js +4652 -0
  8. package/dist/sgr-CMfEpjSk.d.ts +91 -0
  9. package/dist/truncate-CBiyyZzw.js +2156 -0
  10. package/dist/yoga-5jKhYCJC.js +3465 -0
  11. package/dist/yoga.d.ts +2 -0
  12. package/dist/yoga.js +2 -0
  13. package/package.json +37 -17
  14. package/src/ansi/chalk.ts +179 -0
  15. package/src/ansi/cursor.ts +48 -0
  16. package/src/ansi/east-asian-width.ts +215 -0
  17. package/src/ansi/escapes.ts +128 -0
  18. package/src/ansi/index.ts +27 -0
  19. package/src/ansi/sgr.ts +237 -0
  20. package/src/ansi/slice.ts +43 -0
  21. package/src/ansi/string-width.ts +236 -0
  22. package/src/ansi/strip.ts +33 -0
  23. package/src/ansi/supports-color.ts +213 -0
  24. package/src/ansi/tokenize.ts +453 -0
  25. package/src/ansi/truncate.ts +194 -0
  26. package/src/ansi/widest-line.ts +12 -0
  27. package/src/ansi/wrap.ts +766 -0
  28. package/src/ansi-tokenizer.ts +510 -0
  29. package/src/auto-bind.ts +41 -0
  30. package/src/boxes.ts +100 -0
  31. package/src/code-excerpt.ts +39 -0
  32. package/src/colorize.ts +60 -0
  33. package/src/components/AccessibilityContext.ts +5 -0
  34. package/src/components/AnimationContext.ts +24 -0
  35. package/src/components/App.tsx +782 -0
  36. package/src/components/AppContext.ts +111 -0
  37. package/src/components/BackgroundContext.ts +8 -0
  38. package/src/components/Box.tsx +117 -0
  39. package/src/components/CursorContext.ts +19 -0
  40. package/src/components/ErrorBoundary.tsx +39 -0
  41. package/src/components/ErrorOverview.tsx +134 -0
  42. package/src/components/FocusContext.ts +30 -0
  43. package/src/components/Newline.tsx +16 -0
  44. package/src/components/Spacer.tsx +11 -0
  45. package/src/components/Static.tsx +60 -0
  46. package/src/components/StderrContext.ts +26 -0
  47. package/src/components/StdinContext.ts +49 -0
  48. package/src/components/StdoutContext.ts +28 -0
  49. package/src/components/Text.tsx +145 -0
  50. package/src/components/Transform.tsx +38 -0
  51. package/src/cursor-position.ts +103 -0
  52. package/src/devtools-window-polyfill.ts +73 -0
  53. package/src/devtools.ts +43 -0
  54. package/src/dom.ts +292 -0
  55. package/src/get-max-width.ts +11 -0
  56. package/src/global.d.ts +36 -0
  57. package/src/hooks/use-animation.ts +142 -0
  58. package/src/hooks/use-app.ts +8 -0
  59. package/src/hooks/use-box-metrics.ts +134 -0
  60. package/src/hooks/use-cursor.ts +33 -0
  61. package/src/hooks/use-focus-manager.ts +62 -0
  62. package/src/hooks/use-focus.ts +83 -0
  63. package/src/hooks/use-input.ts +267 -0
  64. package/src/hooks/use-is-screen-reader-enabled.ts +12 -0
  65. package/src/hooks/use-paste.ts +78 -0
  66. package/src/hooks/use-stderr.ts +8 -0
  67. package/src/hooks/use-stdin.ts +10 -0
  68. package/src/hooks/use-stdout.ts +8 -0
  69. package/src/hooks/use-window-size.ts +41 -0
  70. package/src/indent-string.ts +16 -0
  71. package/src/index.ts +44 -0
  72. package/src/ink.tsx +1507 -0
  73. package/src/input-parser.ts +283 -0
  74. package/src/instances.ts +9 -0
  75. package/src/is-in-ci.ts +7 -0
  76. package/src/kitty-keyboard.ts +57 -0
  77. package/src/log-update.ts +370 -0
  78. package/src/measure-element.ts +62 -0
  79. package/src/measure-text.ts +31 -0
  80. package/src/output.ts +308 -0
  81. package/src/parse-keypress.ts +516 -0
  82. package/src/parse-stack-line.ts +139 -0
  83. package/src/patch-console.ts +62 -0
  84. package/src/quick-lru.ts +85 -0
  85. package/src/reconciler.ts +451 -0
  86. package/src/render-background.ts +38 -0
  87. package/src/render-border.ts +134 -0
  88. package/src/render-node-to-output.ts +191 -0
  89. package/src/render-to-string.ts +131 -0
  90. package/src/render.ts +276 -0
  91. package/src/renderer.ts +73 -0
  92. package/src/sanitize-ansi.ts +33 -0
  93. package/src/signal-exit.ts +107 -0
  94. package/src/squash-text-nodes.ts +40 -0
  95. package/src/stream.ts +30 -0
  96. package/src/styles.ts +748 -0
  97. package/src/terminal-size.ts +57 -0
  98. package/src/throttle.ts +73 -0
  99. package/src/types.ts +15 -0
  100. package/src/utils.ts +40 -0
  101. package/src/wrap-text.ts +50 -0
  102. package/src/write-synchronized.ts +9 -0
  103. package/src/yoga/config.ts +57 -0
  104. package/src/yoga/core/absoluteLayout.ts +626 -0
  105. package/src/yoga/core/baseline.ts +66 -0
  106. package/src/yoga/core/cache.ts +136 -0
  107. package/src/yoga/core/calculateLayout.ts +2920 -0
  108. package/src/yoga/core/config.ts +104 -0
  109. package/src/yoga/core/flexLine.ts +177 -0
  110. package/src/yoga/core/helpers.ts +293 -0
  111. package/src/yoga/core/layoutResults.ts +167 -0
  112. package/src/yoga/core/node.ts +611 -0
  113. package/src/yoga/core/numeric.ts +44 -0
  114. package/src/yoga/core/pixelGrid.ts +151 -0
  115. package/src/yoga/core/style.ts +887 -0
  116. package/src/yoga/core/types.ts +224 -0
  117. package/src/yoga/generated/YGEnums.ts +263 -0
  118. package/src/yoga/index.ts +19 -0
  119. package/src/yoga/node.ts +1140 -0
  120. package/dist/index.d.mts +0 -2379
  121. package/dist/index.mjs +0 -10072
package/README.md CHANGED
@@ -60,19 +60,19 @@ import React, { useState, useEffect } from "react";
60
60
  import { render, Text } from "@alchemy.run/sigil";
61
61
 
62
62
  const Counter = () => {
63
- const [counter, setCounter] = useState(0);
63
+ const [counter, setCounter] = useState(0);
64
64
 
65
- useEffect(() => {
66
- const timer = setInterval(() => {
67
- setCounter((previousCounter) => previousCounter + 1);
68
- }, 100);
65
+ useEffect(() => {
66
+ const timer = setInterval(() => {
67
+ setCounter((previousCounter) => previousCounter + 1);
68
+ }, 100);
69
69
 
70
- return () => {
71
- clearInterval(timer);
72
- };
73
- }, []);
70
+ return () => {
71
+ clearInterval(timer);
72
+ };
73
+ }, []);
74
74
 
75
- return <Text color="green">{counter} tests passed</Text>;
75
+ return <Text color="green">{counter} tests passed</Text>;
76
76
  };
77
77
 
78
78
  render(<Counter />);
@@ -202,7 +202,7 @@ npm install --save-dev @babel/preset-react
202
202
 
203
203
  ```json
204
204
  {
205
- "presets": ["@babel/preset-react"]
205
+ "presets": ["@babel/preset-react"]
206
206
  }
207
207
  ```
208
208
 
@@ -266,18 +266,18 @@ This component can display text and change its style to make it bold, underlined
266
266
  import { render, Text } from "@alchemy.run/sigil";
267
267
 
268
268
  const Example = () => (
269
- <>
270
- <Text color="green">I am green</Text>
271
- <Text color="black" backgroundColor="white">
272
- I am black on white
273
- </Text>
274
- <Text color="#ffffff">I am white</Text>
275
- <Text bold>I am bold</Text>
276
- <Text italic>I am italic</Text>
277
- <Text underline>I am underline</Text>
278
- <Text strikethrough>I am strikethrough</Text>
279
- <Text inverse>I am inversed</Text>
280
- </>
269
+ <>
270
+ <Text color="green">I am green</Text>
271
+ <Text color="black" backgroundColor="white">
272
+ I am black on white
273
+ </Text>
274
+ <Text color="#ffffff">I am white</Text>
275
+ <Text bold>I am bold</Text>
276
+ <Text italic>I am italic</Text>
277
+ <Text underline>I am underline</Text>
278
+ <Text strikethrough>I am strikethrough</Text>
279
+ <Text inverse>I am inversed</Text>
280
+ </>
281
281
  );
282
282
 
283
283
  render(<Example />);
@@ -324,7 +324,7 @@ Dim the color (make it less bright).
324
324
 
325
325
  ```jsx
326
326
  <Text color="red" dimColor>
327
- Dimmed Red
327
+ Dimmed Red
328
328
  </Text>
329
329
  ```
330
330
 
@@ -367,7 +367,7 @@ Invert background and foreground colors.
367
367
 
368
368
  ```jsx
369
369
  <Text inverse color="yellow">
370
- Inversed Yellow
370
+ Inversed Yellow
371
371
  </Text>
372
372
  ```
373
373
 
@@ -421,9 +421,9 @@ It's like `<div style="display: flex">` in the browser.
421
421
  import { render, Box, Text } from "@alchemy.run/sigil";
422
422
 
423
423
  const Example = () => (
424
- <Box margin={2}>
425
- <Text>This is a box with margin</Text>
426
- </Box>
424
+ <Box margin={2}>
425
+ <Text>This is a box with margin</Text>
426
+ </Box>
427
427
  );
428
428
 
429
429
  render(<Example />);
@@ -440,17 +440,17 @@ You can also set it as a percentage, which will calculate the width based on the
440
440
 
441
441
  ```jsx
442
442
  <Box width={4}>
443
- <Text>X</Text>
443
+ <Text>X</Text>
444
444
  </Box>
445
445
  //=> 'X '
446
446
  ```
447
447
 
448
448
  ```jsx
449
449
  <Box width={10}>
450
- <Box width="50%">
451
- <Text>X</Text>
452
- </Box>
453
- <Text>Y</Text>
450
+ <Box width="50%">
451
+ <Text>X</Text>
452
+ </Box>
453
+ <Text>Y</Text>
454
454
  </Box>
455
455
  //=> 'X Y'
456
456
  ```
@@ -464,17 +464,17 @@ You can also set it as a percentage, which will calculate the height based on th
464
464
 
465
465
  ```jsx
466
466
  <Box height={4}>
467
- <Text>X</Text>
467
+ <Text>X</Text>
468
468
  </Box>
469
469
  //=> 'X\n\n\n'
470
470
  ```
471
471
 
472
472
  ```jsx
473
473
  <Box height={6} flexDirection="column">
474
- <Box height="50%">
475
- <Text>X</Text>
476
- </Box>
477
- <Text>Y</Text>
474
+ <Box height="50%">
475
+ <Text>X</Text>
476
+ </Box>
477
+ <Text>Y</Text>
478
478
  </Box>
479
479
  //=> 'X\n\n\nY\n\n'
480
480
  ```
@@ -648,9 +648,9 @@ Size of the gap between an element's columns and rows. A shorthand for `columnGa
648
648
 
649
649
  ```jsx
650
650
  <Box gap={1} width={3} flexWrap="wrap">
651
- <Text>A</Text>
652
- <Text>B</Text>
653
- <Text>C</Text>
651
+ <Text>A</Text>
652
+ <Text>B</Text>
653
+ <Text>C</Text>
654
654
  </Box>
655
655
  // A B
656
656
  //
@@ -666,8 +666,8 @@ Size of the gap between an element's columns.
666
666
 
667
667
  ```jsx
668
668
  <Box columnGap={1}>
669
- <Text>A</Text>
670
- <Text>B</Text>
669
+ <Text>A</Text>
670
+ <Text>B</Text>
671
671
  </Box>
672
672
  // A B
673
673
  ```
@@ -681,8 +681,8 @@ Size of the gap between an element's rows.
681
681
 
682
682
  ```jsx
683
683
  <Box flexDirection="column" rowGap={1}>
684
- <Text>A</Text>
685
- <Text>B</Text>
684
+ <Text>A</Text>
685
+ <Text>B</Text>
686
686
  </Box>
687
687
  // A
688
688
  //
@@ -700,10 +700,10 @@ See [flex-grow](https://css-tricks.com/almanac/properties/f/flex-grow/).
700
700
 
701
701
  ```jsx
702
702
  <Box>
703
- <Text>Label:</Text>
704
- <Box flexGrow={1}>
705
- <Text>Fills all remaining space</Text>
706
- </Box>
703
+ <Text>Label:</Text>
704
+ <Box flexGrow={1}>
705
+ <Text>Fills all remaining space</Text>
706
+ </Box>
707
707
  </Box>
708
708
  ```
709
709
 
@@ -716,12 +716,12 @@ See [flex-shrink](https://css-tricks.com/almanac/properties/f/flex-shrink/).
716
716
 
717
717
  ```jsx
718
718
  <Box width={20}>
719
- <Box flexShrink={2} width={10}>
720
- <Text>Will be 1/4</Text>
721
- </Box>
722
- <Box width={10}>
723
- <Text>Will be 3/4</Text>
724
- </Box>
719
+ <Box flexShrink={2} width={10}>
720
+ <Text>Will be 1/4</Text>
721
+ </Box>
722
+ <Box width={10}>
723
+ <Text>Will be 3/4</Text>
724
+ </Box>
725
725
  </Box>
726
726
  ```
727
727
 
@@ -733,20 +733,20 @@ See [flex-basis](https://css-tricks.com/almanac/properties/f/flex-basis/).
733
733
 
734
734
  ```jsx
735
735
  <Box width={6}>
736
- <Box flexBasis={3}>
737
- <Text>X</Text>
738
- </Box>
739
- <Text>Y</Text>
736
+ <Box flexBasis={3}>
737
+ <Text>X</Text>
738
+ </Box>
739
+ <Text>Y</Text>
740
740
  </Box>
741
741
  //=> 'X Y'
742
742
  ```
743
743
 
744
744
  ```jsx
745
745
  <Box width={6}>
746
- <Box flexBasis="50%">
747
- <Text>X</Text>
748
- </Box>
749
- <Text>Y</Text>
746
+ <Box flexBasis="50%">
747
+ <Text>X</Text>
748
+ </Box>
749
+ <Text>Y</Text>
750
750
  </Box>
751
751
  //=> 'X Y'
752
752
  ```
@@ -799,8 +799,8 @@ See [flex-wrap](https://css-tricks.com/almanac/properties/f/flex-wrap/).
799
799
 
800
800
  ```jsx
801
801
  <Box width={2} flexWrap="wrap">
802
- <Text>A</Text>
803
- <Text>BC</Text>
802
+ <Text>A</Text>
803
+ <Text>BC</Text>
804
804
  </Box>
805
805
  // A
806
806
  // B C
@@ -808,9 +808,9 @@ See [flex-wrap](https://css-tricks.com/almanac/properties/f/flex-wrap/).
808
808
 
809
809
  ```jsx
810
810
  <Box flexDirection="column" height={2} flexWrap="wrap">
811
- <Text>A</Text>
812
- <Text>B</Text>
813
- <Text>C</Text>
811
+ <Text>A</Text>
812
+ <Text>B</Text>
813
+ <Text>C</Text>
814
814
  </Box>
815
815
  // A C
816
816
  // B
@@ -1049,37 +1049,37 @@ Ink uses border styles from the [`cli-boxes`](https://github.com/sindresorhus/cl
1049
1049
 
1050
1050
  ```jsx
1051
1051
  <Box flexDirection="column">
1052
- <Box>
1053
- <Box borderStyle="single" marginRight={2}>
1054
- <Text>single</Text>
1055
- </Box>
1056
-
1057
- <Box borderStyle="double" marginRight={2}>
1058
- <Text>double</Text>
1059
- </Box>
1060
-
1061
- <Box borderStyle="round" marginRight={2}>
1062
- <Text>round</Text>
1063
- </Box>
1064
-
1065
- <Box borderStyle="bold">
1066
- <Text>bold</Text>
1067
- </Box>
1068
- </Box>
1069
-
1070
- <Box marginTop={1}>
1071
- <Box borderStyle="singleDouble" marginRight={2}>
1072
- <Text>singleDouble</Text>
1073
- </Box>
1074
-
1075
- <Box borderStyle="doubleSingle" marginRight={2}>
1076
- <Text>doubleSingle</Text>
1077
- </Box>
1078
-
1079
- <Box borderStyle="classic">
1080
- <Text>classic</Text>
1081
- </Box>
1082
- </Box>
1052
+ <Box>
1053
+ <Box borderStyle="single" marginRight={2}>
1054
+ <Text>single</Text>
1055
+ </Box>
1056
+
1057
+ <Box borderStyle="double" marginRight={2}>
1058
+ <Text>double</Text>
1059
+ </Box>
1060
+
1061
+ <Box borderStyle="round" marginRight={2}>
1062
+ <Text>round</Text>
1063
+ </Box>
1064
+
1065
+ <Box borderStyle="bold">
1066
+ <Text>bold</Text>
1067
+ </Box>
1068
+ </Box>
1069
+
1070
+ <Box marginTop={1}>
1071
+ <Box borderStyle="singleDouble" marginRight={2}>
1072
+ <Text>singleDouble</Text>
1073
+ </Box>
1074
+
1075
+ <Box borderStyle="doubleSingle" marginRight={2}>
1076
+ <Text>doubleSingle</Text>
1077
+ </Box>
1078
+
1079
+ <Box borderStyle="classic">
1080
+ <Text>classic</Text>
1081
+ </Box>
1082
+ </Box>
1083
1083
  </Box>
1084
1084
  ```
1085
1085
 
@@ -1089,18 +1089,18 @@ Alternatively, pass a custom border style like so:
1089
1089
 
1090
1090
  ```jsx
1091
1091
  <Box
1092
- borderStyle={{
1093
- topLeft: "↘",
1094
- top: "↓",
1095
- topRight: "↙",
1096
- left: "→",
1097
- bottomLeft: "↗",
1098
- bottom: "↑",
1099
- bottomRight: "↖",
1100
- right: "←",
1101
- }}
1092
+ borderStyle={{
1093
+ topLeft: "↘",
1094
+ top: "↓",
1095
+ topRight: "↙",
1096
+ left: "→",
1097
+ bottomLeft: "↗",
1098
+ bottom: "↑",
1099
+ bottomRight: "↖",
1100
+ right: "←",
1101
+ }}
1102
1102
  >
1103
- <Text>Custom</Text>
1103
+ <Text>Custom</Text>
1104
1104
  </Box>
1105
1105
  ```
1106
1106
 
@@ -1115,7 +1115,7 @@ A shorthand for setting `borderTopColor`, `borderRightColor`, `borderBottomColor
1115
1115
 
1116
1116
  ```jsx
1117
1117
  <Box borderStyle="round" borderColor="green">
1118
- <Text>Green Rounded Box</Text>
1118
+ <Text>Green Rounded Box</Text>
1119
1119
  </Box>
1120
1120
  ```
1121
1121
 
@@ -1130,7 +1130,7 @@ Accepts the same values as [`color`](#color) in `<Text>` component.
1130
1130
 
1131
1131
  ```jsx
1132
1132
  <Box borderStyle="round" borderTopColor="green">
1133
- <Text>Hello world</Text>
1133
+ <Text>Hello world</Text>
1134
1134
  </Box>
1135
1135
  ```
1136
1136
 
@@ -1143,7 +1143,7 @@ Accepts the same values as [`color`](#color) in `<Text>` component.
1143
1143
 
1144
1144
  ```jsx
1145
1145
  <Box borderStyle="round" borderRightColor="green">
1146
- <Text>Hello world</Text>
1146
+ <Text>Hello world</Text>
1147
1147
  </Box>
1148
1148
  ```
1149
1149
 
@@ -1156,7 +1156,7 @@ Accepts the same values as [`color`](#color) in `<Text>` component.
1156
1156
 
1157
1157
  ```jsx
1158
1158
  <Box borderStyle="round" borderBottomColor="green">
1159
- <Text>Hello world</Text>
1159
+ <Text>Hello world</Text>
1160
1160
  </Box>
1161
1161
  ```
1162
1162
 
@@ -1169,7 +1169,7 @@ Accepts the same values as [`color`](#color) in `<Text>` component.
1169
1169
 
1170
1170
  ```jsx
1171
1171
  <Box borderStyle="round" borderLeftColor="green">
1172
- <Text>Hello world</Text>
1172
+ <Text>Hello world</Text>
1173
1173
  </Box>
1174
1174
  ```
1175
1175
 
@@ -1183,7 +1183,7 @@ A shorthand for setting `borderTopDimColor`, `borderBottomDimColor`, `borderLeft
1183
1183
 
1184
1184
  ```jsx
1185
1185
  <Box borderStyle="round" borderDimColor>
1186
- <Text>Hello world</Text>
1186
+ <Text>Hello world</Text>
1187
1187
  </Box>
1188
1188
  ```
1189
1189
 
@@ -1196,7 +1196,7 @@ Dim the top border color.
1196
1196
 
1197
1197
  ```jsx
1198
1198
  <Box borderStyle="round" borderTopDimColor>
1199
- <Text>Hello world</Text>
1199
+ <Text>Hello world</Text>
1200
1200
  </Box>
1201
1201
  ```
1202
1202
 
@@ -1209,7 +1209,7 @@ Dim the bottom border color.
1209
1209
 
1210
1210
  ```jsx
1211
1211
  <Box borderStyle="round" borderBottomDimColor>
1212
- <Text>Hello world</Text>
1212
+ <Text>Hello world</Text>
1213
1213
  </Box>
1214
1214
  ```
1215
1215
 
@@ -1222,7 +1222,7 @@ Dim the left border color.
1222
1222
 
1223
1223
  ```jsx
1224
1224
  <Box borderStyle="round" borderLeftDimColor>
1225
- <Text>Hello world</Text>
1225
+ <Text>Hello world</Text>
1226
1226
  </Box>
1227
1227
  ```
1228
1228
 
@@ -1235,7 +1235,7 @@ Dim the right border color.
1235
1235
 
1236
1236
  ```jsx
1237
1237
  <Box borderStyle="round" borderRightDimColor>
1238
- <Text>Hello world</Text>
1238
+ <Text>Hello world</Text>
1239
1239
  </Box>
1240
1240
  ```
1241
1241
 
@@ -1249,7 +1249,7 @@ A shorthand for setting `borderTopBackgroundColor`, `borderRightBackgroundColor`
1249
1249
 
1250
1250
  ```jsx
1251
1251
  <Box borderStyle="round" borderColor="white" borderBackgroundColor="green">
1252
- <Text>Hello world</Text>
1252
+ <Text>Hello world</Text>
1253
1253
  </Box>
1254
1254
  ```
1255
1255
 
@@ -1263,7 +1263,7 @@ Falls back to `borderBackgroundColor` if not specified.
1263
1263
 
1264
1264
  ```jsx
1265
1265
  <Box borderStyle="round" borderColor="white" borderTopBackgroundColor="green">
1266
- <Text>Hello world</Text>
1266
+ <Text>Hello world</Text>
1267
1267
  </Box>
1268
1268
  ```
1269
1269
 
@@ -1277,7 +1277,7 @@ Falls back to `borderBackgroundColor` if not specified.
1277
1277
 
1278
1278
  ```jsx
1279
1279
  <Box borderStyle="round" borderColor="white" borderBottomBackgroundColor="green">
1280
- <Text>Hello world</Text>
1280
+ <Text>Hello world</Text>
1281
1281
  </Box>
1282
1282
  ```
1283
1283
 
@@ -1291,7 +1291,7 @@ Falls back to `borderBackgroundColor` if not specified.
1291
1291
 
1292
1292
  ```jsx
1293
1293
  <Box borderStyle="round" borderColor="white" borderRightBackgroundColor="green">
1294
- <Text>Hello world</Text>
1294
+ <Text>Hello world</Text>
1295
1295
  </Box>
1296
1296
  ```
1297
1297
 
@@ -1305,7 +1305,7 @@ Falls back to `borderBackgroundColor` if not specified.
1305
1305
 
1306
1306
  ```jsx
1307
1307
  <Box borderStyle="round" borderColor="white" borderLeftBackgroundColor="green">
1308
- <Text>Hello world</Text>
1308
+ <Text>Hello world</Text>
1309
1309
  </Box>
1310
1310
  ```
1311
1311
 
@@ -1349,17 +1349,17 @@ Accepts the same values as [`color`](#color) in the `<Text>` component.
1349
1349
 
1350
1350
  ```jsx
1351
1351
  <Box flexDirection="column">
1352
- <Box backgroundColor="red" width={20} height={5} alignSelf="flex-start">
1353
- <Text>Red background</Text>
1354
- </Box>
1352
+ <Box backgroundColor="red" width={20} height={5} alignSelf="flex-start">
1353
+ <Text>Red background</Text>
1354
+ </Box>
1355
1355
 
1356
- <Box backgroundColor="#FF8800" width={20} height={3} marginTop={1} alignSelf="flex-start">
1357
- <Text>Orange background</Text>
1358
- </Box>
1356
+ <Box backgroundColor="#FF8800" width={20} height={3} marginTop={1} alignSelf="flex-start">
1357
+ <Text>Orange background</Text>
1358
+ </Box>
1359
1359
 
1360
- <Box backgroundColor="rgb(0, 255, 0)" width={20} height={3} marginTop={1} alignSelf="flex-start">
1361
- <Text>Green background</Text>
1362
- </Box>
1360
+ <Box backgroundColor="rgb(0, 255, 0)" width={20} height={3} marginTop={1} alignSelf="flex-start">
1361
+ <Text>Green background</Text>
1362
+ </Box>
1363
1363
  </Box>
1364
1364
  ```
1365
1365
 
@@ -1367,9 +1367,9 @@ The background color fills the entire `<Box>` area and is inherited by child `<T
1367
1367
 
1368
1368
  ```jsx
1369
1369
  <Box backgroundColor="blue" alignSelf="flex-start">
1370
- <Text>Blue inherited </Text>
1371
- <Text backgroundColor="yellow">Yellow override </Text>
1372
- <Text>Blue inherited again</Text>
1370
+ <Text>Blue inherited </Text>
1371
+ <Text backgroundColor="yellow">Yellow override </Text>
1372
+ <Text>Blue inherited again</Text>
1373
1373
  </Box>
1374
1374
  ```
1375
1375
 
@@ -1377,7 +1377,7 @@ Background colors work with borders and padding:
1377
1377
 
1378
1378
  ```jsx
1379
1379
  <Box backgroundColor="cyan" borderStyle="round" padding={1} alignSelf="flex-start">
1380
- <Text>Background with border and padding</Text>
1380
+ <Text>Background with border and padding</Text>
1381
1381
  </Box>
1382
1382
  ```
1383
1383
 
@@ -1399,11 +1399,11 @@ Number of newlines to insert.
1399
1399
  import { render, Text, Newline } from "@alchemy.run/sigil";
1400
1400
 
1401
1401
  const Example = () => (
1402
- <Text>
1403
- <Text color="green">Hello</Text>
1404
- <Newline />
1405
- <Text color="red">World</Text>
1406
- </Text>
1402
+ <Text>
1403
+ <Text color="green">Hello</Text>
1404
+ <Newline />
1405
+ <Text color="red">World</Text>
1406
+ </Text>
1407
1407
  );
1408
1408
 
1409
1409
  render(<Example />);
@@ -1427,11 +1427,11 @@ For example, using `<Spacer>` in a `<Box>` with default flex direction (`row`) w
1427
1427
  import { render, Box, Text, Spacer } from "@alchemy.run/sigil";
1428
1428
 
1429
1429
  const Example = () => (
1430
- <Box>
1431
- <Text>Left</Text>
1432
- <Spacer />
1433
- <Text>Right</Text>
1434
- </Box>
1430
+ <Box>
1431
+ <Text>Left</Text>
1432
+ <Spacer />
1433
+ <Text>Right</Text>
1434
+ </Box>
1435
1435
  );
1436
1436
 
1437
1437
  render(<Example />);
@@ -1444,11 +1444,11 @@ Note that the container needs to be tall enough to see this in effect.
1444
1444
  import { render, Box, Text, Spacer } from "@alchemy.run/sigil";
1445
1445
 
1446
1446
  const Example = () => (
1447
- <Box flexDirection="column" height={10}>
1448
- <Text>Top</Text>
1449
- <Spacer />
1450
- <Text>Bottom</Text>
1451
- </Box>
1447
+ <Box flexDirection="column" height={10}>
1448
+ <Text>Top</Text>
1449
+ <Spacer />
1450
+ <Text>Bottom</Text>
1451
+ </Box>
1452
1452
  );
1453
1453
 
1454
1454
  render(<Example />);
@@ -1472,51 +1472,51 @@ import React, { useState, useEffect } from "react";
1472
1472
  import { render, Static, Box, Text } from "@alchemy.run/sigil";
1473
1473
 
1474
1474
  const Example = () => {
1475
- const [tests, setTests] = useState([]);
1476
-
1477
- useEffect(() => {
1478
- let completedTests = 0;
1479
- let timer;
1480
-
1481
- const run = () => {
1482
- // Fake 10 completed tests
1483
- if (completedTests++ < 10) {
1484
- setTests((previousTests) => [
1485
- ...previousTests,
1486
- {
1487
- id: previousTests.length,
1488
- title: `Test #${previousTests.length + 1}`,
1489
- },
1490
- ]);
1491
-
1492
- timer = setTimeout(run, 100);
1493
- }
1494
- };
1495
-
1496
- run();
1497
-
1498
- return () => {
1499
- clearTimeout(timer);
1500
- };
1501
- }, []);
1502
-
1503
- return (
1504
- <>
1505
- {/* This part will be rendered once to the terminal */}
1506
- <Static items={tests}>
1507
- {(test) => (
1508
- <Box key={test.id}>
1509
- <Text color="green">✔ {test.title}</Text>
1510
- </Box>
1511
- )}
1512
- </Static>
1513
-
1514
- {/* This part keeps updating as state changes */}
1515
- <Box marginTop={1}>
1516
- <Text dimColor>Completed tests: {tests.length}</Text>
1517
- </Box>
1518
- </>
1519
- );
1475
+ const [tests, setTests] = useState([]);
1476
+
1477
+ useEffect(() => {
1478
+ let completedTests = 0;
1479
+ let timer;
1480
+
1481
+ const run = () => {
1482
+ // Fake 10 completed tests
1483
+ if (completedTests++ < 10) {
1484
+ setTests((previousTests) => [
1485
+ ...previousTests,
1486
+ {
1487
+ id: previousTests.length,
1488
+ title: `Test #${previousTests.length + 1}`,
1489
+ },
1490
+ ]);
1491
+
1492
+ timer = setTimeout(run, 100);
1493
+ }
1494
+ };
1495
+
1496
+ run();
1497
+
1498
+ return () => {
1499
+ clearTimeout(timer);
1500
+ };
1501
+ }, []);
1502
+
1503
+ return (
1504
+ <>
1505
+ {/* This part will be rendered once to the terminal */}
1506
+ <Static items={tests}>
1507
+ {(test) => (
1508
+ <Box key={test.id}>
1509
+ <Text color="green">✔ {test.title}</Text>
1510
+ </Box>
1511
+ )}
1512
+ </Static>
1513
+
1514
+ {/* This part keeps updating as state changes */}
1515
+ <Box marginTop={1}>
1516
+ <Text dimColor>Completed tests: {tests.length}</Text>
1517
+ </Box>
1518
+ </>
1519
+ );
1520
1520
  };
1521
1521
 
1522
1522
  render(<Example />);
@@ -1558,16 +1558,16 @@ Note that a `key` must be assigned to the root component.
1558
1558
 
1559
1559
  ```jsx
1560
1560
  <Static items={["a", "b", "c"]}>
1561
- {(item, index) => {
1562
- // This function is called for every item in ['a', 'b', 'c']
1563
- // `item` is 'a', 'b', 'c'
1564
- // `index` is 0, 1, 2
1565
- return (
1566
- <Box key={index}>
1567
- <Text>Item: {item}</Text>
1568
- </Box>
1569
- );
1570
- }}
1561
+ {(item, index) => {
1562
+ // This function is called for every item in ['a', 'b', 'c']
1563
+ // `item` is 'a', 'b', 'c'
1564
+ // `index` is 0, 1, 2
1565
+ return (
1566
+ <Box key={index}>
1567
+ <Text>Item: {item}</Text>
1568
+ </Box>
1569
+ );
1570
+ }}
1571
1571
  </Static>
1572
1572
  ```
1573
1573
 
@@ -1588,9 +1588,9 @@ That's what the `<Transform>` component does: it gives you an output string of i
1588
1588
  import { render, Transform } from "@alchemy.run/sigil";
1589
1589
 
1590
1590
  const Example = () => (
1591
- <Transform transform={(output) => output.toUpperCase()}>
1592
- <Text>Hello World</Text>
1593
- </Transform>
1591
+ <Transform transform={(output) => output.toUpperCase()}>
1592
+ <Text>Hello World</Text>
1593
+ </Transform>
1594
1594
  );
1595
1595
 
1596
1596
  render(<Example />);
@@ -1606,18 +1606,18 @@ For example, to implement a hanging indent component, you can indent all the lin
1606
1606
  import { render, Transform } from "@alchemy.run/sigil";
1607
1607
 
1608
1608
  const HangingIndent = ({ indent = 4, children }) => (
1609
- <Transform transform={(line, index) => (index === 0 ? line : " ".repeat(indent) + line)}>
1610
- {children}
1611
- </Transform>
1609
+ <Transform transform={(line, index) => (index === 0 ? line : " ".repeat(indent) + line)}>
1610
+ {children}
1611
+ </Transform>
1612
1612
  );
1613
1613
 
1614
1614
  const text =
1615
- "WHEN I WROTE the following pages, or rather the bulk of them, " +
1616
- "I lived alone, in the woods, a mile from any neighbor, in a " +
1617
- "house which I had built myself, on the shore of Walden Pond, " +
1618
- "in Concord, Massachusetts, and earned my living by the labor " +
1619
- "of my hands only. I lived there two years and two months. At " +
1620
- "present I am a sojourner in civilized life again.";
1615
+ "WHEN I WROTE the following pages, or rather the bulk of them, " +
1616
+ "I lived alone, in the woods, a mile from any neighbor, in a " +
1617
+ "house which I had built myself, on the shore of Walden Pond, " +
1618
+ "in Concord, Massachusetts, and earned my living by the labor " +
1619
+ "of my hands only. I lived there two years and two months. At " +
1620
+ "present I am a sojourner in civilized life again.";
1621
1621
 
1622
1622
  render(<HangingIndent indent={4}>{text}</HangingIndent>);
1623
1623
  ```
@@ -1955,7 +1955,7 @@ import { useApp } from "@alchemy.run/sigil";
1955
1955
  const { suspendTerminal } = useApp();
1956
1956
 
1957
1957
  await suspendTerminal(async () => {
1958
- await runEditor();
1958
+ await runEditor();
1959
1959
  });
1960
1960
  ```
1961
1961
 
@@ -1965,9 +1965,9 @@ When called without a callback, it returns a suspension you resume yourself. `re
1965
1965
  const suspension = await suspendTerminal();
1966
1966
 
1967
1967
  try {
1968
- await runEditor();
1968
+ await runEditor();
1969
1969
  } finally {
1970
- await suspension.resume();
1970
+ await suspension.resume();
1971
1971
  }
1972
1972
  ```
1973
1973
 
@@ -2013,9 +2013,9 @@ A component using `setRawMode` might want to use `isRawModeSupported` to nicely
2013
2013
  import { useStdin } from "@alchemy.run/sigil";
2014
2014
 
2015
2015
  const Example = () => {
2016
- const { isRawModeSupported } = useStdin();
2016
+ const { isRawModeSupported } = useStdin();
2017
2017
 
2018
- return isRawModeSupported ? <MyInputComponent /> : <MyComponentThatDoesntUseInput />;
2018
+ return isRawModeSupported ? <MyInputComponent /> : <MyComponentThatDoesntUseInput />;
2019
2019
  };
2020
2020
  ```
2021
2021
 
@@ -2116,14 +2116,14 @@ import { useRef } from "react";
2116
2116
  import { Box, Text, useBoxMetrics } from "@alchemy.run/sigil";
2117
2117
 
2118
2118
  const Example = () => {
2119
- const ref = useRef(null);
2120
- const { width, height, left, top, hasMeasured } = useBoxMetrics(ref);
2121
-
2122
- return (
2123
- <Box ref={ref}>
2124
- <Text>{hasMeasured ? `${width}x${height} at ${left},${top}` : "Measuring..."}</Text>
2125
- </Box>
2126
- );
2119
+ const ref = useRef(null);
2120
+ const { width, height, left, top, hasMeasured } = useBoxMetrics(ref);
2121
+
2122
+ return (
2123
+ <Box ref={ref}>
2124
+ <Text>{hasMeasured ? `${width}x${height} at ${left},${top}` : "Measuring..."}</Text>
2125
+ </Box>
2126
+ );
2127
2127
  };
2128
2128
  ```
2129
2129
 
@@ -2217,13 +2217,13 @@ A React hook that returns the current terminal dimensions and re-renders the com
2217
2217
  import { Text, useWindowSize } from "@alchemy.run/sigil";
2218
2218
 
2219
2219
  const Example = () => {
2220
- const { columns, rows } = useWindowSize();
2220
+ const { columns, rows } = useWindowSize();
2221
2221
 
2222
- return (
2223
- <Text>
2224
- {columns}x{rows}
2225
- </Text>
2226
- );
2222
+ return (
2223
+ <Text>
2224
+ {columns}x{rows}
2225
+ </Text>
2226
+ );
2227
2227
  };
2228
2228
  ```
2229
2229
 
@@ -2277,9 +2277,9 @@ Set a component's focus ID, which can be used to programmatically focus the comp
2277
2277
  import { render, useFocus, Text } from "@alchemy.run/sigil";
2278
2278
 
2279
2279
  const Example = () => {
2280
- const { isFocused } = useFocus();
2280
+ const { isFocused } = useFocus();
2281
2281
 
2282
- return <Text>{isFocused ? "I am focused" : "I am not focused"}</Text>;
2282
+ return <Text>{isFocused ? "I am focused" : "I am not focused"}</Text>;
2283
2283
  };
2284
2284
 
2285
2285
  render(<Example />);
@@ -2413,9 +2413,9 @@ The ID of the currently focused component, or `undefined` if no component is foc
2413
2413
  import { Text, useFocusManager } from "@alchemy.run/sigil";
2414
2414
 
2415
2415
  const Example = () => {
2416
- const { activeId } = useFocusManager();
2416
+ const { activeId } = useFocusManager();
2417
2417
 
2418
- return <Text>Focused: {activeId ?? "none"}</Text>;
2418
+ return <Text>Focused: {activeId ?? "none"}</Text>;
2419
2419
  };
2420
2420
  ```
2421
2421
 
@@ -2430,21 +2430,21 @@ import { Box, Text, useCursor } from "@alchemy.run/sigil";
2430
2430
  import stringWidth from "string-width";
2431
2431
 
2432
2432
  const TextInput = () => {
2433
- const [text, setText] = useState("");
2434
- const { setCursorPosition } = useCursor();
2435
-
2436
- const prompt = "> ";
2437
- setCursorPosition({ x: stringWidth(prompt + text), y: 1 });
2438
-
2439
- return (
2440
- <Box flexDirection="column">
2441
- <Text>Type here:</Text>
2442
- <Text>
2443
- {prompt}
2444
- {text}
2445
- </Text>
2446
- </Box>
2447
- );
2433
+ const [text, setText] = useState("");
2434
+ const { setCursorPosition } = useCursor();
2435
+
2436
+ const prompt = "> ";
2437
+ setCursorPosition({ x: stringWidth(prompt + text), y: 1 });
2438
+
2439
+ return (
2440
+ <Box flexDirection="column">
2441
+ <Text>Type here:</Text>
2442
+ <Text>
2443
+ {prompt}
2444
+ {text}
2445
+ </Text>
2446
+ </Box>
2447
+ );
2448
2448
  };
2449
2449
  ```
2450
2450
 
@@ -2481,11 +2481,11 @@ This is useful when you want to render different output for screen readers.
2481
2481
  import { useIsScreenReaderEnabled, Text } from "@alchemy.run/sigil";
2482
2482
 
2483
2483
  const Example = () => {
2484
- const isScreenReaderEnabled = useIsScreenReaderEnabled();
2484
+ const isScreenReaderEnabled = useIsScreenReaderEnabled();
2485
2485
 
2486
- return (
2487
- <Text>{isScreenReaderEnabled ? "Screen reader is enabled" : "Screen reader is disabled"}</Text>
2488
- );
2486
+ return (
2487
+ <Text>{isScreenReaderEnabled ? "Screen reader is enabled" : "Screen reader is disabled"}</Text>
2488
+ );
2489
2489
  };
2490
2490
  ```
2491
2491
 
@@ -2497,10 +2497,10 @@ A React hook that drives animations. Returns a frame counter, elapsed time, fram
2497
2497
  import { Text, useAnimation } from "@alchemy.run/sigil";
2498
2498
 
2499
2499
  const Spinner = () => {
2500
- const { frame } = useAnimation({ interval: 80 });
2501
- const characters = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
2500
+ const { frame } = useAnimation({ interval: 80 });
2501
+ const characters = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
2502
2502
 
2503
- return <Text>{characters[frame % characters.length]}</Text>;
2503
+ return <Text>{characters[frame % characters.length]}</Text>;
2504
2504
  };
2505
2505
  ```
2506
2506
 
@@ -2622,11 +2622,11 @@ Return `true` to take ownership of a chunk: Ink will not display it, letting the
2622
2622
  const [transcript, setTranscript] = useState([]);
2623
2623
 
2624
2624
  render(<App transcript={transcript} />, {
2625
- patchConsole: "stdio",
2626
- onCapturedOutput(stream, data) {
2627
- setTranscript((previous) => [...previous, { stream, data }]);
2628
- return true;
2629
- },
2625
+ patchConsole: "stdio",
2626
+ onCapturedOutput(stream, data) {
2627
+ setTranscript((previous) => [...previous, { stream, data }]);
2628
+ return true;
2629
+ },
2630
2630
  });
2631
2631
  ```
2632
2632
 
@@ -2642,7 +2642,7 @@ To run code after output is flushed, use [`waitUntilRenderFlush()`](#waituntilre
2642
2642
  ###### isScreenReaderEnabled
2643
2643
 
2644
2644
  Type: `boolean`\
2645
- Default: `process.env['INK_SCREEN_READER'] === 'true'`
2645
+ Default: `process.env['SIGIL_SCREEN_READER'] === 'true'`
2646
2646
 
2647
2647
  Enable screen reader support. See [Screen Reader Support](#screen-reader-support).
2648
2648
 
@@ -2748,10 +2748,10 @@ render(<MyApp />, { kittyKeyboard: { mode: "auto" } });
2748
2748
  import { render } from "@alchemy.run/sigil";
2749
2749
 
2750
2750
  render(<MyApp />, {
2751
- kittyKeyboard: {
2752
- mode: "enabled",
2753
- flags: ["disambiguateEscapeCodes", "reportEventTypes"],
2754
- },
2751
+ kittyKeyboard: {
2752
+ mode: "enabled",
2753
+ flags: ["disambiguateEscapeCodes", "reportEventTypes"],
2754
+ },
2755
2755
  });
2756
2756
  ```
2757
2757
 
@@ -2803,9 +2803,9 @@ Useful for generating documentation, writing output to files, testing, or any sc
2803
2803
  import { renderToString, Text, Box } from "@alchemy.run/sigil";
2804
2804
 
2805
2805
  const output = renderToString(
2806
- <Box padding={1}>
2807
- <Text color="green">Hello World</Text>
2808
- </Box>,
2806
+ <Box padding={1}>
2807
+ <Text color="green">Hello World</Text>
2808
+ </Box>,
2809
2809
  );
2810
2810
 
2811
2811
  console.log(output);
@@ -2836,7 +2836,7 @@ Width of the virtual terminal in columns. Controls where text wrapping occurs.
2836
2836
 
2837
2837
  ```jsx
2838
2838
  const output = renderToString(<Text>{"A".repeat(100)}</Text>, {
2839
- columns: 40,
2839
+ columns: 40,
2840
2840
  });
2841
2841
  // Text wraps at 40 columns
2842
2842
  ```
@@ -2938,20 +2938,20 @@ See [Refs](https://reactjs.org/docs/refs-and-the-dom.html) for more information
2938
2938
  import { render, measureElement, Box, Text } from "@alchemy.run/sigil";
2939
2939
 
2940
2940
  const Example = () => {
2941
- const ref = useRef();
2942
-
2943
- useEffect(() => {
2944
- const { x, y, width, height } = measureElement(ref.current);
2945
- // x = 0, y = 0, width = 100, height = 1
2946
- }, []);
2947
-
2948
- return (
2949
- <Box width={100}>
2950
- <Box ref={ref}>
2951
- <Text>This box will stretch to 100 width</Text>
2952
- </Box>
2953
- </Box>
2954
- );
2941
+ const ref = useRef();
2942
+
2943
+ useEffect(() => {
2944
+ const { x, y, width, height } = measureElement(ref.current);
2945
+ // x = 0, y = 0, width = 100, height = 1
2946
+ }, []);
2947
+
2948
+ return (
2949
+ <Box width={100}>
2950
+ <Box ref={ref}>
2951
+ <Text>This box will stretch to 100 width</Text>
2952
+ </Box>
2953
+ </Box>
2954
+ );
2955
2955
  };
2956
2956
 
2957
2957
  render(<Example />);
@@ -2979,10 +2979,10 @@ Check out [ink-testing-library](https://github.com/vadimdemedes/ink-testing-libr
2979
2979
 
2980
2980
  ![](media/devtools.jpg)
2981
2981
 
2982
- Ink supports [React Devtools](https://github.com/facebook/react/tree/master/packages/react-devtools) out of the box. To enable integration with React Devtools in your Ink-based CLI, first ensure you have installed the optional `react-devtools-core` dependency, and then run your app with the `DEV=true` environment variable:
2982
+ Ink supports [React Devtools](https://github.com/facebook/react/tree/master/packages/react-devtools) out of the box. To enable integration with React Devtools in your Ink-based CLI, first ensure you have installed the optional `react-devtools-core` dependency, and then run your app with the `SIGIL_DEV=true` environment variable:
2983
2983
 
2984
2984
  ```sh
2985
- DEV=true my-cli
2985
+ SIGIL_DEV=true my-cli
2986
2986
  ```
2987
2987
 
2988
2988
  Then, start React Devtools itself:
@@ -3001,7 +3001,7 @@ You can even inspect and change the props of components, and see the results imm
3001
3001
 
3002
3002
  Ink has basic support for screen readers.
3003
3003
 
3004
- To enable it, you can either pass the `isScreenReaderEnabled` option to the `render` function or set the `INK_SCREEN_READER` environment variable to `true`.
3004
+ To enable it, you can either pass the `isScreenReaderEnabled` option to the `render` function or set the `SIGIL_SCREEN_READER` environment variable to `true`.
3005
3005
 
3006
3006
  Ink implements a small subset of functionality from the [ARIA specification](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA).
3007
3007
 
@@ -3015,7 +3015,7 @@ For example, for this code:
3015
3015
 
3016
3016
  ```jsx
3017
3017
  <Box aria-role="checkbox" aria-state={{ checked: true }}>
3018
- <Text>Accept terms and conditions</Text>
3018
+ <Text>Accept terms and conditions</Text>
3019
3019
  </Box>
3020
3020
  ```
3021
3021
 
@@ -3031,8 +3031,8 @@ For example, if you are building a progress bar, you can use `aria-label` to pro
3031
3031
 
3032
3032
  ```jsx
3033
3033
  <Box>
3034
- <Box width="50%" height={1} backgroundColor="green" />
3035
- <Text aria-label="Progress: 50%">50%</Text>
3034
+ <Box width="50%" height={1} backgroundColor="green" />
3035
+ <Text aria-label="Progress: 50%">50%</Text>
3036
3036
  </Box>
3037
3037
  ```
3038
3038