@alchemy.run/sigil 0.0.0-alpha.2 → 0.0.0-alpha.4

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 (107) hide show
  1. package/README.md +2 -4
  2. package/THIRD_PARTY_NOTICES.md +31 -22
  3. package/dist/ansi.d.ts +17 -14
  4. package/dist/ansi.js +7 -2
  5. package/dist/{devtools-BhYGjb7h.js → devtools-DbthxoD1.js} +22 -23
  6. package/dist/index.d.ts +125 -288
  7. package/dist/index.js +2460 -2864
  8. package/dist/{truncate-CBiyyZzw.js → truncate-Cr6xVFMa.js} +447 -273
  9. package/package.json +3 -9
  10. package/src/ansi/chalk.ts +8 -51
  11. package/src/ansi/cursor.ts +2 -4
  12. package/src/ansi/east-asian-width.ts +44 -0
  13. package/src/ansi/escapes.ts +4 -26
  14. package/src/ansi/index.ts +12 -14
  15. package/src/ansi/sgr.ts +2 -5
  16. package/src/ansi/slice.ts +1 -1
  17. package/src/ansi/string-width.ts +91 -206
  18. package/src/ansi/strip.ts +13 -33
  19. package/src/ansi/supports-color.ts +8 -14
  20. package/src/ansi/tokenize.ts +94 -166
  21. package/src/ansi/truncate.ts +5 -3
  22. package/src/ansi/wrap.ts +13 -14
  23. package/src/ansi-tokenizer.ts +1 -1
  24. package/src/colorize.ts +1 -1
  25. package/src/components/App.tsx +14 -14
  26. package/src/components/BackgroundContext.ts +2 -2
  27. package/src/components/Box.tsx +51 -59
  28. package/src/components/CursorContext.ts +1 -1
  29. package/src/components/ErrorBoundary.tsx +2 -1
  30. package/src/components/ErrorOverview.tsx +9 -7
  31. package/src/components/Newline.tsx +1 -0
  32. package/src/components/Spacer.tsx +2 -1
  33. package/src/components/Static.tsx +2 -1
  34. package/src/components/StderrContext.ts +0 -2
  35. package/src/components/StdinContext.ts +0 -1
  36. package/src/components/StdoutContext.ts +1 -3
  37. package/src/components/Text.tsx +7 -6
  38. package/src/components/Transform.tsx +2 -1
  39. package/src/cursor-position.ts +1 -1
  40. package/src/devtools.ts +84 -24
  41. package/src/dom.ts +7 -7
  42. package/src/env.ts +12 -0
  43. package/src/get-max-width.ts +1 -1
  44. package/src/global.d.ts +3 -4
  45. package/src/{boxes.ts → glyphs.ts} +17 -18
  46. package/src/hooks/use-animation.ts +1 -1
  47. package/src/hooks/use-app.ts +1 -1
  48. package/src/hooks/use-box-metrics.ts +1 -1
  49. package/src/hooks/use-cursor.ts +2 -2
  50. package/src/hooks/use-focus-manager.ts +1 -1
  51. package/src/hooks/use-focus.ts +5 -6
  52. package/src/hooks/use-input.ts +4 -4
  53. package/src/hooks/use-is-screen-reader-enabled.ts +1 -1
  54. package/src/hooks/use-paste.ts +2 -2
  55. package/src/hooks/use-stderr.ts +1 -1
  56. package/src/hooks/use-stdin.ts +1 -1
  57. package/src/hooks/use-stdout.ts +1 -1
  58. package/src/hooks/use-window-size.ts +2 -2
  59. package/src/index.ts +44 -44
  60. package/src/ink.tsx +536 -720
  61. package/src/input-parser.ts +1 -1
  62. package/src/instances.ts +1 -1
  63. package/src/kitty-keyboard.ts +128 -0
  64. package/src/log-update.ts +4 -4
  65. package/src/measure-element.ts +1 -1
  66. package/src/measure-text.ts +2 -2
  67. package/src/output.ts +4 -4
  68. package/src/parse-keypress.ts +4 -5
  69. package/src/parse-stack-line.ts +0 -1
  70. package/src/patch-console.ts +44 -0
  71. package/src/reconciler.ts +13 -60
  72. package/src/render-background.ts +3 -3
  73. package/src/render-border.ts +6 -6
  74. package/src/render-node-to-output.ts +13 -11
  75. package/src/render-to-string.ts +4 -4
  76. package/src/render.ts +9 -10
  77. package/src/renderer.ts +3 -3
  78. package/src/sanitize-ansi.ts +1 -1
  79. package/src/signal-exit.ts +4 -5
  80. package/src/squash-text-nodes.ts +2 -2
  81. package/src/stream.ts +2 -4
  82. package/src/styles.ts +6 -6
  83. package/src/terminal-size.ts +9 -8
  84. package/src/types.ts +1 -6
  85. package/src/utils.ts +2 -2
  86. package/src/wrap-text.ts +4 -4
  87. package/src/yoga/config.ts +2 -2
  88. package/src/yoga/core/absoluteLayout.ts +15 -15
  89. package/src/yoga/core/baseline.ts +3 -3
  90. package/src/yoga/core/cache.ts +4 -4
  91. package/src/yoga/core/calculateLayout.ts +33 -27
  92. package/src/yoga/core/config.ts +1 -1
  93. package/src/yoga/core/flexLine.ts +3 -3
  94. package/src/yoga/core/helpers.ts +3 -3
  95. package/src/yoga/core/layoutResults.ts +4 -4
  96. package/src/yoga/core/node.ts +16 -16
  97. package/src/yoga/core/pixelGrid.ts +4 -4
  98. package/src/yoga/core/style.ts +11 -11
  99. package/src/yoga/core/types.ts +2 -2
  100. package/src/yoga/index.ts +6 -6
  101. package/src/yoga/node.ts +8 -8
  102. package/src/ansi/widest-line.ts +0 -12
  103. package/src/auto-bind.ts +0 -41
  104. package/src/devtools-window-polyfill.ts +0 -73
  105. package/src/indent-string.ts +0 -16
  106. package/src/is-in-ci.ts +0 -7
  107. package/src/write-synchronized.ts +0 -9
package/README.md CHANGED
@@ -1,7 +1,3 @@
1
- [![](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
2
-
3
- ---
4
-
5
1
  <div align="center">
6
2
  <br>
7
3
  <h1>Sigil</h1>
@@ -22,6 +18,8 @@ The documentation below is inherited from Ink; the API is unchanged apart from i
22
18
 
23
19
  ---
24
20
 
21
+ [![](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
22
+
25
23
  Ink provides the same component-based UI building experience that React offers in the browser, but for command-line apps.
26
24
  It uses [Yoga](https://github.com/facebook/yoga) to build Flexbox layouts in the terminal, so most CSS-like properties are available in Ink as well.
27
25
  If you are already familiar with React, you already know Ink.
@@ -40,33 +40,16 @@ SOFTWARE.
40
40
  ## Packages by Sindre Sorhus (MIT)
41
41
 
42
42
  Portions of `src/ansi/` and `src/` are derived from the following packages:
43
- `ansi-escapes`, `ansi-regex`, `ansi-styles`, `auto-bind`, `chalk`, `cli-boxes`,
44
- `cli-cursor`, `cli-truncate`, `get-east-asian-width`, `indent-string`,
45
- `is-fullwidth-code-point`, `is-in-ci`, `quick-lru`, `restore-cursor`,
46
- `slice-ansi`, `string-width`, `strip-ansi`, `terminal-size`, `type-fest`,
47
- `widest-line`, `wrap-ansi`.
43
+ `ansi-escapes`, `ansi-styles`, `chalk`, `cli-boxes`,
44
+ `cli-cursor`, `cli-truncate`, `get-east-asian-width`,
45
+ `is-fullwidth-code-point`, `quick-lru`, `restore-cursor`,
46
+ `slice-ansi`, `terminal-size`, `type-fest`, `wrap-ansi`.
48
47
 
49
48
  MIT License
50
49
 
51
50
  Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
52
51
 
53
- Permission is hereby granted, free of charge, to any person obtaining a copy
54
- of this software and associated documentation files (the "Software"), to deal
55
- in the Software without restriction, including without limitation the rights
56
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57
- copies of the Software, and to permit persons to whom the Software is
58
- furnished to do so, subject to the following conditions:
59
-
60
- The above copyright notice and this permission notice shall be included in all
61
- copies or substantial portions of the Software.
62
-
63
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
69
- SOFTWARE.
52
+ Licensed under the MIT License (text above).
70
53
 
71
54
  ## supports-color (MIT)
72
55
 
@@ -112,6 +95,32 @@ Copyright (c) 2016-2022 Isaac Z. Schlueter <i@izs.me>, James Talmage
112
95
 
113
96
  Licensed under the MIT License (text above).
114
97
 
98
+ ## fast-string-truncated-width (MIT)
99
+
100
+ `src/ansi/string-width.ts` is derived from `fast-string-truncated-width`.
101
+
102
+ The MIT License (MIT)
103
+
104
+ Copyright (c) 2024-present Fabio Spampinato
105
+
106
+ Licensed under the MIT License (text above).
107
+
108
+ ## es-toolkit (MIT)
109
+
110
+ `src/throttle.ts` is derived from `throttle` in `es-toolkit/compat`.
111
+
112
+ Copyright (c) 2024 Viva Republica, Inc.
113
+
114
+ Licensed under the MIT License (text above).
115
+
116
+ ## enquirer (MIT)
117
+
118
+ `src/parse-keypress.ts` is derived from `enquirer`'s `lib/keypress.js`.
119
+
120
+ Copyright (c) 2016-present, Jon Schlinkert and Contributors.
121
+
122
+ Licensed under the MIT License (text above).
123
+
115
124
  ## signal-exit (ISC)
116
125
 
117
126
  `src/signal-exit.ts` is a minimal reimplementation of `signal-exit`'s
package/dist/ansi.d.ts CHANGED
@@ -49,7 +49,7 @@ declare const eraseEndLine: string;
49
49
  declare const eraseLine: string;
50
50
  declare const eraseScreen: string;
51
51
  declare const eraseLines: (count: number) => string;
52
- declare const clearTerminal: string;
52
+ declare const clearTerminal = "";
53
53
  declare const enterAlternativeScreen: string;
54
54
  declare const exitAlternativeScreen: string;
55
55
  declare const cursorShow: string;
@@ -102,14 +102,8 @@ declare const cliCursor: {
102
102
  };
103
103
  //#endregion
104
104
  //#region src/ansi/string-width.d.ts
105
- type StringWidthOptions = {
106
- readonly ambiguousIsNarrow?: boolean;
107
- readonly countAnsiEscapeCodes?: boolean;
108
- };
109
- declare function stringWidth(input: string, options?: StringWidthOptions): number;
110
- //#endregion
111
- //#region src/ansi/widest-line.d.ts
112
- declare const widestLine: (string: string) => number;
105
+ declare const stringWidth: (input: string) => number;
106
+ declare const widestLine: (text: string) => number;
113
107
  //#endregion
114
108
  //#region src/ansi/east-asian-width.d.ts
115
109
  type EastAsianWidthType = "ambiguous" | "fullwidth" | "halfwidth" | "narrow" | "neutral" | "wide";
@@ -136,13 +130,22 @@ declare function eastAsianWidthType(codePoint: number): EastAsianWidthType;
136
130
  declare function eastAsianWidth(codePoint: number, { ambiguousAsWide }?: {
137
131
  ambiguousAsWide?: boolean;
138
132
  }): 1 | 2;
133
+ /**
134
+ Grapheme-cluster width test shared by the tokenizer (slice/clip path): the
135
+ base code point's East Asian Width, plus emoji presentation rules.
136
+ */
137
+ declare function isFullwidthGrapheme(grapheme: string, baseCodePoint: number): boolean;
138
+ /**
139
+ Wide code points not covered by string-width's CJKT script regex or emoji
140
+ regex — the fallback bucket of its block parser. A disjoint decomposition of
141
+ the `wide` table above, kept alongside it so the width data lives in one
142
+ module.
143
+ */
144
+ declare const isWideNotCJKTNotEmoji: (x: number) => boolean;
139
145
  declare function isFullwidthCodePoint(codePoint: number): boolean;
140
146
  //#endregion
141
147
  //#region src/ansi/strip.d.ts
142
- declare function ansiRegex({ onlyFirst }?: {
143
- onlyFirst?: boolean;
144
- }): RegExp;
145
- declare function stripAnsi(string: string): string;
148
+ declare const stripAnsi: (input: string) => string;
146
149
  //#endregion
147
150
  //#region src/ansi/slice.d.ts
148
151
  declare function sliceAnsi(string: string, start: number, end?: number): string;
@@ -220,4 +223,4 @@ declare function diffAnsiCodes(from: readonly AnsiCode[], to: readonly AnsiCode[
220
223
  declare function styledCharsFromTokens(tokens: readonly Token[]): StyledChar[];
221
224
  declare function styledCharsToString(chars: readonly StyledChar[]): string;
222
225
  //#endregion
223
- export { AnsiCode, AnsiToken, BEL, BackgroundColorName, C1_CSI, C1_ST, CSI, CharToken, ControlToken, DEL, ESC, EastAsianWidthType, ForegroundColorName, ModifierName, OSC, ST, StyleName, StylePair, StyledChar, Token, ambiguousMaximumCodePoint, ambiguousMinimalCodePoint, ambiguousRanges, ansi256ToAnsi, ansiCodesToString, ansiEscapes, ansiRegex, background, backgroundColorNames, bsu, chalk, clearTerminal, cliCursor, codes, cursorDown, cursorHide, cursorLeft, cursorNextLine, cursorShow, cursorTo, cursorUp, diffAnsiCodes, disableBracketedPaste, eastAsianWidth, eastAsianWidthType, enableBracketedPaste, endCodesSet, enterAlternativeScreen, eraseEndLine, eraseLine, eraseLines, eraseScreen, esu, exitAlternativeScreen, foreground, foregroundColorNames, fullwidthMaximumCodePoint, fullwidthMinimalCodePoint, fullwidthRanges, getCategory, getEndCode, getLinkStartCode, halfwidthMaximumCodePoint, halfwidthMinimalCodePoint, halfwidthRanges, hexToAnsi, hexToAnsi256, hexToRgb, isAmbiguous, isFullWidth, isFullwidthCodePoint, isIntensityCode, isWide, kittyQuery, link, modifierNames, narrowMaximumCodePoint, narrowMinimalCodePoint, narrowRanges, pasteEnd, pasteStart, popKittyKeyboard, pushKittyKeyboard, reduceAnsiCodes, reduceAnsiCodesIncremental, rgbToAnsi, rgbToAnsi256, sliceAnsi, stringWidth, stripAnsi, styledCharsFromTokens, styledCharsToString, styles, supportsColor, tokenize, cliTruncate as truncateAnsi, undoAnsiCodes, wideMaximumCodePoint, wideMinimalCodePoint, wideRanges, widestLine, wrapAnsi };
226
+ export { AnsiCode, AnsiToken, BEL, BackgroundColorName, C1_CSI, C1_ST, CSI, CharToken, ControlToken, DEL, ESC, EastAsianWidthType, ForegroundColorName, ModifierName, OSC, ST, StyleName, StylePair, StyledChar, Token, ambiguousMaximumCodePoint, ambiguousMinimalCodePoint, ambiguousRanges, ansi256ToAnsi, ansiCodesToString, ansiEscapes, background, backgroundColorNames, bsu, chalk, clearTerminal, cliCursor, codes, cursorDown, cursorHide, cursorLeft, cursorNextLine, cursorShow, cursorTo, cursorUp, diffAnsiCodes, disableBracketedPaste, eastAsianWidth, eastAsianWidthType, enableBracketedPaste, endCodesSet, enterAlternativeScreen, eraseEndLine, eraseLine, eraseLines, eraseScreen, esu, exitAlternativeScreen, foreground, foregroundColorNames, fullwidthMaximumCodePoint, fullwidthMinimalCodePoint, fullwidthRanges, getCategory, getEndCode, getLinkStartCode, halfwidthMaximumCodePoint, halfwidthMinimalCodePoint, halfwidthRanges, hexToAnsi, hexToAnsi256, hexToRgb, isAmbiguous, isFullWidth, isFullwidthCodePoint, isFullwidthGrapheme, isIntensityCode, isWide, isWideNotCJKTNotEmoji, kittyQuery, link, modifierNames, narrowMaximumCodePoint, narrowMinimalCodePoint, narrowRanges, pasteEnd, pasteStart, popKittyKeyboard, pushKittyKeyboard, reduceAnsiCodes, reduceAnsiCodesIncremental, rgbToAnsi, rgbToAnsi256, sliceAnsi, stringWidth, stripAnsi, styledCharsFromTokens, styledCharsToString, styles, supportsColor, tokenize, cliTruncate as truncateAnsi, undoAnsiCodes, wideMaximumCodePoint, wideMinimalCodePoint, wideRanges, widestLine, wrapAnsi };
package/dist/ansi.js CHANGED
@@ -1,2 +1,7 @@
1
- import { $ as hexToAnsi256, A as fullwidthMinimalCodePoint, At as esu, B as narrowMaximumCodePoint, C as stripAnsi, Ct as disableBracketedPaste, D as eastAsianWidth, Dt as eraseLine, E as ambiguousRanges, Et as eraseEndLine, F as halfwidthRanges, Ft as pasteStart, G as wideRanges, H as narrowRanges, I as isAmbiguous, It as popKittyKeyboard, J as backgroundColorNames, K as ansi256ToAnsi, L as isFullWidth, Lt as pushKittyKeyboard, M as getCategory, Mt as kittyQuery, N as halfwidthMaximumCodePoint, Nt as link, O as eastAsianWidthType, Ot as eraseLines, P as halfwidthMinimalCodePoint, Pt as pasteEnd, Q as hexToAnsi, R as isFullwidthCodePoint, S as ansiRegex, St as cursorUp, T as ambiguousMinimalCodePoint, Tt as enterAlternativeScreen, U as wideMaximumCodePoint, V as narrowMinimalCodePoint, W as wideMinimalCodePoint, X as foreground, Y as codes, Z as foregroundColorNames, _ as supportsColor, _t as cursorHide, a as endCodesSet, at as BEL, b as wrapAnsi, bt as cursorShow, c as isIntensityCode, ct as CSI, d as styledCharsFromTokens, dt as OSC, et as hexToRgb, f as styledCharsToString, ft as ST, g as chalk, gt as cursorDown, h as widestLine, ht as clearTerminal, i as diffAnsiCodes, it as styles, j as fullwidthRanges, jt as exitAlternativeScreen, k as fullwidthMaximumCodePoint, kt as eraseScreen, l as reduceAnsiCodes, lt as DEL, m as undoAnsiCodes, mt as bsu, n as sliceAnsi, nt as rgbToAnsi, o as getEndCode, ot as C1_CSI, p as tokenize, pt as ansiEscapes, q as background, r as ansiCodesToString, rt as rgbToAnsi256, s as getLinkStartCode, st as C1_ST, t as cliTruncate, tt as modifierNames, u as reduceAnsiCodesIncremental, ut as ESC, v as cliCursor, vt as cursorLeft, w as ambiguousMaximumCodePoint, wt as enableBracketedPaste, x as stringWidth, xt as cursorTo, yt as cursorNextLine, z as isWide } from "./truncate-CBiyyZzw.js";
2
- export { BEL, C1_CSI, C1_ST, CSI, DEL, ESC, OSC, ST, ambiguousMaximumCodePoint, ambiguousMinimalCodePoint, ambiguousRanges, ansi256ToAnsi, ansiCodesToString, ansiEscapes, ansiRegex, background, backgroundColorNames, bsu, chalk, clearTerminal, cliCursor, codes, cursorDown, cursorHide, cursorLeft, cursorNextLine, cursorShow, cursorTo, cursorUp, diffAnsiCodes, disableBracketedPaste, eastAsianWidth, eastAsianWidthType, enableBracketedPaste, endCodesSet, enterAlternativeScreen, eraseEndLine, eraseLine, eraseLines, eraseScreen, esu, exitAlternativeScreen, foreground, foregroundColorNames, fullwidthMaximumCodePoint, fullwidthMinimalCodePoint, fullwidthRanges, getCategory, getEndCode, getLinkStartCode, halfwidthMaximumCodePoint, halfwidthMinimalCodePoint, halfwidthRanges, hexToAnsi, hexToAnsi256, hexToRgb, isAmbiguous, isFullWidth, isFullwidthCodePoint, isIntensityCode, isWide, kittyQuery, link, modifierNames, narrowMaximumCodePoint, narrowMinimalCodePoint, narrowRanges, pasteEnd, pasteStart, popKittyKeyboard, pushKittyKeyboard, reduceAnsiCodes, reduceAnsiCodesIncremental, rgbToAnsi, rgbToAnsi256, sliceAnsi, stringWidth, stripAnsi, styledCharsFromTokens, styledCharsToString, styles, supportsColor, tokenize, cliTruncate as truncateAnsi, undoAnsiCodes, wideMaximumCodePoint, wideMinimalCodePoint, wideRanges, widestLine, wrapAnsi };
1
+ import { $ as wideRanges, A as ambiguousMaximumCodePoint, At as cursorUp, B as halfwidthMinimalCodePoint, Bt as kittyQuery, Ct as clearTerminal, D as wrapAnsi, Dt as cursorNextLine, Et as cursorLeft, F as fullwidthMaximumCodePoint, Ft as eraseLine, G as isFullwidthGrapheme, Gt as pushKittyKeyboard, H as isAmbiguous, Ht as pasteEnd, I as fullwidthMinimalCodePoint, It as eraseLines, J as narrowMaximumCodePoint, K as isWide, L as fullwidthRanges, Lt as eraseScreen, M as ambiguousRanges, Mt as enableBracketedPaste, N as eastAsianWidth, Nt as enterAlternativeScreen, O as stringWidth, Ot as cursorShow, P as eastAsianWidthType, Pt as eraseEndLine, Q as wideMinimalCodePoint, R as getCategory, Rt as esu, St as bsu, Tt as cursorHide, U as isFullWidth, Ut as pasteStart, V as halfwidthRanges, Vt as link, W as isFullwidthCodePoint, Wt as popKittyKeyboard, X as narrowRanges, Y as narrowMinimalCodePoint, Z as wideMaximumCodePoint, _ as chalk, _t as DEL, a as endCodesSet, at as foregroundColorNames, bt as ST, c as isIntensityCode, ct as hexToRgb, d as styledCharsFromTokens, dt as rgbToAnsi256, et as ansi256ToAnsi, f as styledCharsToString, ft as styles, gt as CSI, ht as C1_ST, i as diffAnsiCodes, it as foreground, j as ambiguousMinimalCodePoint, jt as disableBracketedPaste, k as widestLine, kt as cursorTo, l as reduceAnsiCodes, lt as modifierNames, m as undoAnsiCodes, mt as C1_CSI, n as sliceAnsi, nt as backgroundColorNames, o as getEndCode, ot as hexToAnsi, p as tokenize, pt as BEL, q as isWideNotCJKTNotEmoji, r as ansiCodesToString, rt as codes, s as getLinkStartCode, st as hexToAnsi256, t as cliTruncate, tt as background, u as reduceAnsiCodesIncremental, ut as rgbToAnsi, v as supportsColor, vt as ESC, wt as cursorDown, xt as ansiEscapes, y as cliCursor, yt as OSC, z as halfwidthMaximumCodePoint, zt as exitAlternativeScreen } from "./truncate-Cr6xVFMa.js";
2
+ import { stripVTControlCharacters } from "node:util";
3
+ //#region src/ansi/strip.ts
4
+ const colonSgrRegex = /(?:\u001B\[|\u009B)[\d;]*:[\d;:]*m/g;
5
+ const stripAnsi = (input) => stripVTControlCharacters(input.replaceAll(colonSgrRegex, ""));
6
+ //#endregion
7
+ export { BEL, C1_CSI, C1_ST, CSI, DEL, ESC, OSC, ST, ambiguousMaximumCodePoint, ambiguousMinimalCodePoint, ambiguousRanges, ansi256ToAnsi, ansiCodesToString, ansiEscapes, background, backgroundColorNames, bsu, chalk, clearTerminal, cliCursor, codes, cursorDown, cursorHide, cursorLeft, cursorNextLine, cursorShow, cursorTo, cursorUp, diffAnsiCodes, disableBracketedPaste, eastAsianWidth, eastAsianWidthType, enableBracketedPaste, endCodesSet, enterAlternativeScreen, eraseEndLine, eraseLine, eraseLines, eraseScreen, esu, exitAlternativeScreen, foreground, foregroundColorNames, fullwidthMaximumCodePoint, fullwidthMinimalCodePoint, fullwidthRanges, getCategory, getEndCode, getLinkStartCode, halfwidthMaximumCodePoint, halfwidthMinimalCodePoint, halfwidthRanges, hexToAnsi, hexToAnsi256, hexToRgb, isAmbiguous, isFullWidth, isFullwidthCodePoint, isFullwidthGrapheme, isIntensityCode, isWide, isWideNotCJKTNotEmoji, kittyQuery, link, modifierNames, narrowMaximumCodePoint, narrowMinimalCodePoint, narrowRanges, pasteEnd, pasteStart, popKittyKeyboard, pushKittyKeyboard, reduceAnsiCodes, reduceAnsiCodesIncremental, rgbToAnsi, rgbToAnsi256, sliceAnsi, stringWidth, stripAnsi, styledCharsFromTokens, styledCharsToString, styles, supportsColor, tokenize, cliTruncate as truncateAnsi, undoAnsiCodes, wideMaximumCodePoint, wideMinimalCodePoint, wideRanges, widestLine, wrapAnsi };
@@ -1,11 +1,11 @@
1
- import ws from "ws";
2
- import devtools from "react-devtools-core";
3
- //#region src/devtools-window-polyfill.ts
4
- const customGlobal = globalThis;
5
- customGlobal.WebSocket ||= ws;
6
- customGlobal.window ||= globalThis;
7
- customGlobal.self ||= globalThis;
8
- customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
1
+ import { setTimeout } from "node:timers";
2
+ //#region src/devtools.ts
3
+ Object.defineProperties(globalThis, {
4
+ ws: { value: WebSocket },
5
+ window: { value: globalThis },
6
+ self: { value: globalThis }
7
+ });
8
+ Object.defineProperty(globalThis, "__REACT_DEVTOOLS_COMPONENT_FILTERS__", { value: [
9
9
  {
10
10
  type: 1,
11
11
  value: 7,
@@ -47,28 +47,27 @@ customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
47
47
  isEnabled: true,
48
48
  isValid: true
49
49
  }
50
- ];
51
- //#endregion
52
- //#region src/devtools.ts
53
- const isDevToolsReachable = async () => new Promise((resolve) => {
54
- const socket = new ws("ws://localhost:8097");
50
+ ] });
51
+ const isDevToolsReachable = () => new Promise((resolve) => {
52
+ const socket = new WebSocket("ws://localhost:8097");
53
+ const settle = (reachable) => {
54
+ clearTimeout(timeout);
55
+ socket.close();
56
+ resolve(reachable);
57
+ };
55
58
  const timeout = setTimeout(() => {
56
- socket.terminate();
57
- resolve(false);
59
+ settle(false);
58
60
  }, 2e3);
59
61
  timeout.unref();
60
- socket.on("open", () => {
61
- clearTimeout(timeout);
62
- socket.terminate();
63
- resolve(true);
62
+ socket.addEventListener("open", () => {
63
+ settle(true);
64
64
  });
65
- socket.on("error", () => {
66
- clearTimeout(timeout);
67
- socket.terminate();
68
- resolve(false);
65
+ socket.addEventListener("error", () => {
66
+ settle(false);
69
67
  });
70
68
  });
71
69
  if (await isDevToolsReachable()) {
70
+ const devtools = await import("react-devtools-core");
72
71
  devtools.initialize();
73
72
  devtools.connectToDevTools();
74
73
  } else console.warn("SIGIL_DEV is set to true, but the React DevTools server is not running. Start it with:\n\n$ npx react-devtools\n");