@visulima/tui 2.0.0 → 2.0.1

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 (110) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/components/box.d.ts +25 -25
  3. package/dist/components/canvas.d.ts +26 -31
  4. package/dist/components/cursor.d.ts +39 -44
  5. package/dist/components/error-overview.d.ts +1 -3
  6. package/dist/components/error-overview.js +1 -1
  7. package/dist/components/newline.d.ts +6 -8
  8. package/dist/components/spacer.d.ts +4 -4
  9. package/dist/components/static-render.d.ts +9 -40
  10. package/dist/components/static.d.ts +13 -13
  11. package/dist/components/text.d.ts +34 -47
  12. package/dist/components/transform.d.ts +7 -11
  13. package/dist/core/index.d.ts +11 -11
  14. package/dist/core/index.js +1 -1
  15. package/dist/ink/canvas/index.d.ts +10 -10
  16. package/dist/ink/hooks/use-animation.d.ts +22 -22
  17. package/dist/ink/hooks/use-app.d.ts +3 -3
  18. package/dist/ink/hooks/use-box-metrics.d.ts +16 -16
  19. package/dist/ink/hooks/use-clipboard.d.ts +16 -16
  20. package/dist/ink/hooks/use-color-blindness.d.ts +16 -16
  21. package/dist/ink/hooks/use-console-capture.d.ts +19 -19
  22. package/dist/ink/hooks/use-cursor.d.ts +6 -6
  23. package/dist/ink/hooks/use-focus-manager.d.ts +25 -25
  24. package/dist/ink/hooks/use-focus.d.ts +14 -18
  25. package/dist/ink/hooks/use-form.d.ts +32 -32
  26. package/dist/ink/hooks/use-hotkey.d.ts +17 -17
  27. package/dist/ink/hooks/use-input.d.ts +92 -92
  28. package/dist/ink/hooks/use-input.js +2 -2
  29. package/dist/ink/hooks/use-interval.d.ts +14 -14
  30. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +3 -3
  31. package/dist/ink/hooks/use-key-bindings.d.ts +32 -32
  32. package/dist/ink/hooks/use-key-chord.d.ts +15 -15
  33. package/dist/ink/hooks/use-paste.d.ts +38 -38
  34. package/dist/ink/hooks/use-paste.js +1 -1
  35. package/dist/ink/hooks/use-persistent-state.d.ts +46 -46
  36. package/dist/ink/hooks/use-persistent-state.js +2 -2
  37. package/dist/ink/hooks/use-scroll-acceleration.d.ts +24 -24
  38. package/dist/ink/hooks/use-scroll-input.d.ts +15 -15
  39. package/dist/ink/hooks/use-stderr.d.ts +6 -6
  40. package/dist/ink/hooks/use-stderr.js +1 -1
  41. package/dist/ink/hooks/use-stdin.d.ts +10 -10
  42. package/dist/ink/hooks/use-stdin.js +1 -1
  43. package/dist/ink/hooks/use-stdout.d.ts +6 -6
  44. package/dist/ink/hooks/use-stdout.js +1 -1
  45. package/dist/ink/hooks/use-stopwatch.d.ts +12 -12
  46. package/dist/ink/hooks/use-terminal-palette.d.ts +11 -11
  47. package/dist/ink/hooks/use-text-buffer.d.ts +2 -2
  48. package/dist/ink/hooks/use-text-selection.d.ts +18 -18
  49. package/dist/ink/hooks/use-timeout.d.ts +11 -11
  50. package/dist/ink/hooks/use-timer.d.ts +19 -19
  51. package/dist/ink/hooks/use-window-size.d.ts +8 -8
  52. package/dist/ink/hooks/use-window-size.js +1 -1
  53. package/dist/ink/index.d.ts +109 -122
  54. package/dist/ink/index.js +1 -1
  55. package/dist/ink/mouse/use-element-position.d.ts +6 -6
  56. package/dist/ink/mouse/use-mouse-action.d.ts +1 -1
  57. package/dist/ink/mouse/use-mouse-position.d.ts +1 -1
  58. package/dist/ink/mouse/use-mouse.d.ts +1 -1
  59. package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -3
  60. package/dist/ink/mouse/use-on-mouse-hover.d.ts +2 -2
  61. package/dist/ink/mouse/use-on-mouse-state.d.ts +2 -2
  62. package/dist/ink/public/cursor.d.ts +21 -21
  63. package/dist/ink/public/dom.d.ts +2 -2
  64. package/dist/ink/public/highlighter.d.ts +16 -26
  65. package/dist/ink/public/input.d.ts +6 -6
  66. package/dist/ink/public/styles.d.ts +1 -1
  67. package/dist/ink/public/utils.d.ts +2 -2
  68. package/dist/packem_shared/{DevTools-D9tfChBc.js → DevTools-BxD3PYAN.js} +1 -1
  69. package/dist/packem_shared/MouseProvider-DOcWCRVq.js +1 -0
  70. package/dist/packem_shared/{Renderer-DsskdkUd.js → Renderer-BeS49FNq.js} +1 -1
  71. package/dist/packem_shared/{TuiApp-DjIgv5Sk.js → TuiApp-CCVaiKbf.js} +1 -1
  72. package/dist/packem_shared/app-context.d-DMLw5Nxy.d.ts +56 -0
  73. package/dist/packem_shared/{buffer.d-j_dP5JyC.d.ts → buffer.d-CttIC480.d.ts} +26 -26
  74. package/dist/packem_shared/clipboard.d-nDPQkZ2H.d.ts +23 -0
  75. package/dist/packem_shared/color-matrix.d-sTqnJ23h.d.ts +50 -0
  76. package/dist/packem_shared/{createInlineLoop-BT40Wpmx.js → createInlineLoop-DnEvE2eM.js} +1 -1
  77. package/dist/packem_shared/{dom.d-g-nsYquD.d.ts → dom.d-CLGlidfI.d.ts} +138 -151
  78. package/dist/packem_shared/{input.d-D-Yxqha8.d.ts → input.d-Bb8pWHvp.d.ts} +24 -24
  79. package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +1 -0
  80. package/dist/packem_shared/{mouse-context.d-BfL9xGk_.d.ts → mouse-context.d-W-nszUps.d.ts} +8 -8
  81. package/dist/packem_shared/reconciler-DkwOtC5B.js +1 -0
  82. package/dist/packem_shared/{render-D7aV_hO1.js → render-CuCo-R-l.js} +17 -17
  83. package/dist/packem_shared/{render-DMcWfI6-.js → render-DtQd8qQq.js} +1 -1
  84. package/dist/packem_shared/render.d-DjQhFsiN.d.ts +435 -0
  85. package/dist/packem_shared/{renderToString-DqLFFPvO.js → renderToString-B1LgWcJe.js} +1 -1
  86. package/dist/packem_shared/{selection.d-KWphH--_.d.ts → selection.d-BSAWa4ey.d.ts} +16 -16
  87. package/dist/packem_shared/stderr-context-CR2LLec6.js +1 -0
  88. package/dist/packem_shared/stdin-context-BjMA9Sbi.js +1 -0
  89. package/dist/packem_shared/stdout-context-DAAlQct2.js +1 -0
  90. package/dist/packem_shared/styles.d-CKGQFfm4.d.ts +485 -0
  91. package/dist/packem_shared/{terminal-palette.d-D2SQjfn-.d.ts → terminal-palette.d-JbWHISW-.d.ts} +7 -7
  92. package/dist/packem_shared/utils-CVgM8kTn.js +1 -0
  93. package/dist/react/index.d.ts +160 -178
  94. package/dist/react/index.js +1 -1
  95. package/dist/testing/index.d.ts +151 -151
  96. package/dist/testing/index.js +1 -1
  97. package/index.js +52 -52
  98. package/package.json +9 -9
  99. package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +0 -1
  100. package/dist/packem_shared/app-context.d-CG88lgkg.d.ts +0 -56
  101. package/dist/packem_shared/clipboard.d-D6lZTQ21.d.ts +0 -23
  102. package/dist/packem_shared/color-matrix.d-DSXLsB64.d.ts +0 -50
  103. package/dist/packem_shared/load-native-root-binding-DDikxNox.js +0 -1
  104. package/dist/packem_shared/reconciler-DhUGYWCr.js +0 -1
  105. package/dist/packem_shared/render.d-BvfwvSCx.d.ts +0 -435
  106. package/dist/packem_shared/stderr-context-Bvnik0hL.js +0 -1
  107. package/dist/packem_shared/stdin-context-88AhuztD.js +0 -1
  108. package/dist/packem_shared/stdout-context-BnblEPez.js +0 -1
  109. package/dist/packem_shared/styles.d-D7iZuNC-.d.ts +0 -492
  110. package/dist/packem_shared/utils-C8l_3Dzw.js +0 -1
@@ -1,287 +1,287 @@
1
1
  import { ReactElement } from 'react';
2
- import { R as RenderOptions } from "../packem_shared/render.d-BvfwvSCx.js";
3
- import "../packem_shared/dom.d-g-nsYquD.js";
2
+ import { R as RenderOptions } from "../packem_shared/render.d-DjQhFsiN.js";
3
+ import "../packem_shared/dom.d-CLGlidfI.js";
4
4
  import 'yoga-layout';
5
5
  import "../ink/public/cursor.js";
6
6
  import '@visulima/colorize';
7
- import "../packem_shared/styles.d-D7iZuNC-.js";
7
+ import "../packem_shared/styles.d-CKGQFfm4.js";
8
8
  import 'type-fest';
9
- import "../packem_shared/app-context.d-CG88lgkg.js";
9
+ import "../packem_shared/app-context.d-DMLw5Nxy.js";
10
10
  import 'node:stream';
11
11
  declare const KEY: {
12
12
  readonly backspace: "";
13
13
  readonly ctrlC: "";
14
- readonly delete: "\x1B[3~";
15
- readonly down: "\x1B[B";
16
- readonly end: "\x1B[F";
17
- readonly escape: "\x1B";
18
- readonly home: "\x1B[H";
19
- readonly left: "\x1B[D";
20
- readonly pageDown: "\x1B[6~";
21
- readonly pageUp: "\x1B[5~";
14
+ readonly delete: "[3~";
15
+ readonly down: "";
16
+ readonly end: "";
17
+ readonly escape: "";
18
+ readonly home: "";
19
+ readonly left: "";
20
+ readonly pageDown: "[6~";
21
+ readonly pageUp: "[5~";
22
22
  readonly return: "\r";
23
- readonly right: "\x1B[C";
23
+ readonly right: "";
24
24
  readonly space: " ";
25
- readonly tab: " ";
26
- readonly up: "\x1B[A";
25
+ readonly tab: "\t";
26
+ readonly up: "";
27
27
  };
28
28
  type KeyName = keyof typeof KEY;
29
29
  interface KeySender {
30
30
  /**
31
- * Simulate pressing the backspace key.
32
- */
31
+ * Simulate pressing the backspace key.
32
+ */
33
33
  backspace: () => void;
34
34
  /**
35
- * Simulate pressing the delete key.
36
- */
35
+ * Simulate pressing the delete key.
36
+ */
37
37
  delete: () => void;
38
38
  /**
39
- * Simulate pressing the down arrow key.
40
- */
39
+ * Simulate pressing the down arrow key.
40
+ */
41
41
  down: () => void;
42
42
  /**
43
- * Simulate pressing the end key.
44
- */
43
+ * Simulate pressing the end key.
44
+ */
45
45
  end: () => void;
46
46
  /**
47
- * Simulate pressing the enter/return key.
48
- */
47
+ * Simulate pressing the enter/return key.
48
+ */
49
49
  enter: () => void;
50
50
  /**
51
- * Simulate pressing the escape key.
52
- */
51
+ * Simulate pressing the escape key.
52
+ */
53
53
  escape: () => void;
54
54
  /**
55
- * Simulate pressing the home key.
56
- */
55
+ * Simulate pressing the home key.
56
+ */
57
57
  home: () => void;
58
58
  /**
59
- * Simulate pressing the left arrow key.
60
- */
59
+ * Simulate pressing the left arrow key.
60
+ */
61
61
  left: () => void;
62
62
  /**
63
- * Simulate pressing the page down key.
64
- */
63
+ * Simulate pressing the page down key.
64
+ */
65
65
  pageDown: () => void;
66
66
  /**
67
- * Simulate pressing the page up key.
68
- */
67
+ * Simulate pressing the page up key.
68
+ */
69
69
  pageUp: () => void;
70
70
  /**
71
- * Send a single character as a key press.
72
- */
71
+ * Send a single character as a key press.
72
+ */
73
73
  press: (char: string) => void;
74
74
  /**
75
- * Send arbitrary raw data to stdin.
76
- */
75
+ * Send arbitrary raw data to stdin.
76
+ */
77
77
  raw: (data: string) => void;
78
78
  /**
79
- * Simulate pressing the right arrow key.
80
- */
79
+ * Simulate pressing the right arrow key.
80
+ */
81
81
  right: () => void;
82
82
  /**
83
- * Simulate pressing the space key.
84
- */
83
+ * Simulate pressing the space key.
84
+ */
85
85
  space: () => void;
86
86
  /**
87
- * Simulate pressing the tab key.
88
- */
87
+ * Simulate pressing the tab key.
88
+ */
89
89
  tab: () => void;
90
90
  /**
91
- * Type a string character by character.
92
- */
91
+ * Type a string character by character.
92
+ */
93
93
  type: (text: string) => void;
94
94
  /**
95
- * Simulate pressing the up arrow key.
96
- */
95
+ * Simulate pressing the up arrow key.
96
+ */
97
97
  up: () => void;
98
98
  }
99
99
  declare const createKeySender: (write: (data: string) => void) => KeySender;
100
100
  interface Screen {
101
101
  /**
102
- * Check if the current screen output contains the given text (ANSI-stripped).
103
- */
102
+ * Check if the current screen output contains the given text (ANSI-stripped).
103
+ */
104
104
  contains: (text: string) => boolean;
105
105
  /**
106
- * Get all captured frames with ANSI codes stripped.
107
- */
106
+ * Get all captured frames with ANSI codes stripped.
107
+ */
108
108
  frames: () => string[];
109
109
  /**
110
- * Get a specific line by zero-based index from the current screen output.
111
- */
110
+ * Get a specific line by zero-based index from the current screen output.
111
+ */
112
112
  line: (n: number) => string;
113
113
  /**
114
- * Get all non-empty lines from the current screen output.
115
- */
114
+ * Get all non-empty lines from the current screen output.
115
+ */
116
116
  lines: () => string[];
117
117
  /**
118
- * Check if the current screen output matches the given pattern (ANSI-stripped).
119
- */
118
+ * Check if the current screen output matches the given pattern (ANSI-stripped).
119
+ */
120
120
  matches: (pattern: RegExp) => boolean;
121
121
  /**
122
- * Get all captured frames with ANSI codes preserved.
123
- */
122
+ * Get all captured frames with ANSI codes preserved.
123
+ */
124
124
  rawFrames: () => string[];
125
125
  /**
126
- * Get the last rendered frame with ANSI codes preserved.
127
- */
126
+ * Get the last rendered frame with ANSI codes preserved.
127
+ */
128
128
  rawText: () => string;
129
129
  /**
130
- * Get the last rendered frame with ANSI codes stripped.
131
- */
130
+ * Get the last rendered frame with ANSI codes stripped.
131
+ */
132
132
  text: () => string;
133
133
  }
134
134
  declare const createScreen: (lastFrame: () => string | undefined, allFrames: ReadonlyArray<string>) => Screen;
135
135
  interface WaitForOptions {
136
136
  /**
137
- * Polling interval in milliseconds.
138
- * @default 50
139
- */
137
+ * Polling interval in milliseconds.
138
+ * @default 50
139
+ */
140
140
  interval?: number;
141
141
  /**
142
- * Maximum time to wait in milliseconds before throwing.
143
- * @default 3000
144
- */
142
+ * Maximum time to wait in milliseconds before throwing.
143
+ * @default 3000
144
+ */
145
145
  timeout?: number;
146
146
  }
147
147
  /**
148
- * Wait for a condition to be met by polling at a regular interval.
149
- *
150
- * If `condition` is a string, waits until `screenText()` contains it.
151
- * If `condition` is a function, waits until it stops throwing.
152
- * @throws The last error encountered if the timeout is reached.
153
- */
148
+ * Wait for a condition to be met by polling at a regular interval.
149
+ *
150
+ * If `condition` is a string, waits until `screenText()` contains it.
151
+ * If `condition` is a function, waits until it stops throwing.
152
+ * @throws The last error encountered if the timeout is reached.
153
+ */
154
154
  declare const waitFor: (condition: (() => void) | string, screenText: () => string, options?: WaitForOptions) => Promise<void>;
155
155
  type TestInstanceStdout = {
156
156
  /**
157
- * All rendered frames captured from stdout.
158
- */
157
+ * All rendered frames captured from stdout.
158
+ */
159
159
  readonly frames: ReadonlyArray<string>;
160
160
  /**
161
- * Returns the most recently rendered frame, or `undefined` if no frames have been written.
162
- */
161
+ * Returns the most recently rendered frame, or `undefined` if no frames have been written.
162
+ */
163
163
  lastFrame: () => string | undefined;
164
164
  /**
165
- * Write data to the mock stdout stream (used internally by the renderer).
166
- */
165
+ * Write data to the mock stdout stream (used internally by the renderer).
166
+ */
167
167
  write: (frame: string) => boolean;
168
168
  };
169
169
  type TestInstanceStderr = {
170
170
  /**
171
- * All rendered frames captured from stderr.
172
- */
171
+ * All rendered frames captured from stderr.
172
+ */
173
173
  readonly frames: ReadonlyArray<string>;
174
174
  /**
175
- * Returns the most recently rendered frame, or `undefined` if no frames have been written.
176
- */
175
+ * Returns the most recently rendered frame, or `undefined` if no frames have been written.
176
+ */
177
177
  lastFrame: () => string | undefined;
178
178
  /**
179
- * Write data to the mock stderr stream (used internally by the renderer).
180
- */
179
+ * Write data to the mock stderr stream (used internally by the renderer).
180
+ */
181
181
  write: (frame: string) => boolean;
182
182
  };
183
183
  type TestInstanceStdin = {
184
184
  /**
185
- * Whether the stdin is a TTY.
186
- */
185
+ * Whether the stdin is a TTY.
186
+ */
187
187
  readonly isTTY: boolean;
188
188
  /**
189
- * Simulate user input by writing data to stdin.
190
- */
189
+ * Simulate user input by writing data to stdin.
190
+ */
191
191
  write: (data: string) => boolean;
192
192
  };
193
193
  type TestInstance = {
194
194
  /**
195
- * Unmount the app and clean up resources.
196
- */
195
+ * Unmount the app and clean up resources.
196
+ */
197
197
  cleanup: () => void;
198
198
  /**
199
- * Wait for pending React renders to flush (two microtick delay).
200
- */
199
+ * Wait for pending React renders to flush (two microtick delay).
200
+ */
201
201
  flush: () => Promise<void>;
202
202
  /**
203
- * All rendered frames captured from stdout (shorthand for `stdout.frames`).
204
- */
203
+ * All rendered frames captured from stdout (shorthand for `stdout.frames`).
204
+ */
205
205
  readonly frames: ReadonlyArray<string>;
206
206
  /**
207
- * Keyboard input helpers for simulating key presses.
208
- */
207
+ * Keyboard input helpers for simulating key presses.
208
+ */
209
209
  keys: KeySender;
210
210
  /**
211
- * Returns the most recently rendered frame from stdout (shorthand for `stdout.lastFrame()`).
212
- */
211
+ * Returns the most recently rendered frame from stdout (shorthand for `stdout.lastFrame()`).
212
+ */
213
213
  lastFrame: () => string | undefined;
214
214
  /**
215
- * Replace the previous root node with a new one or update props.
216
- */
215
+ * Replace the previous root node with a new one or update props.
216
+ */
217
217
  rerender: (node: ReactElement) => void;
218
218
  /**
219
- * Screen query helpers for inspecting rendered output with ANSI stripping.
220
- */
219
+ * Screen query helpers for inspecting rendered output with ANSI stripping.
220
+ */
221
221
  screen: Screen;
222
222
  /**
223
- * Mock stderr stream with frame capture.
224
- */
223
+ * Mock stderr stream with frame capture.
224
+ */
225
225
  stderr: TestInstanceStderr;
226
226
  /**
227
- * Mock stdin stream for simulating user input.
228
- */
227
+ * Mock stdin stream for simulating user input.
228
+ */
229
229
  stdin: TestInstanceStdin;
230
230
  /**
231
- * Mock stdout stream with frame capture.
232
- */
231
+ * Mock stdout stream with frame capture.
232
+ */
233
233
  stdout: TestInstanceStdout;
234
234
  /**
235
- * Manually unmount the whole app.
236
- */
235
+ * Manually unmount the whole app.
236
+ */
237
237
  unmount: () => void;
238
238
  /**
239
- * Wait for a condition to be met by polling.
240
- *
241
- * If `condition` is a string, waits until the screen contains it.
242
- * If `condition` is a function, waits until it stops throwing.
243
- */
239
+ * Wait for a condition to be met by polling.
240
+ *
241
+ * If `condition` is a string, waits until the screen contains it.
242
+ * If `condition` is a function, waits until it stops throwing.
243
+ */
244
244
  waitFor: (condition: (() => void) | string, options?: WaitForOptions) => Promise<void>;
245
245
  };
246
246
  type TestRenderOptions = {
247
247
  /**
248
- * Terminal column width for the mock stdout/stderr streams.
249
- * @default 100
250
- */
248
+ * Terminal column width for the mock stdout/stderr streams.
249
+ * @default 100
250
+ */
251
251
  columns?: number;
252
252
  /**
253
- * Additional render options passed through to the underlying render function.
254
- */
253
+ * Additional render options passed through to the underlying render function.
254
+ */
255
255
  options?: Omit<RenderOptions, "debug" | "exitOnCtrlC" | "patchConsole" | "stderr" | "stdin" | "stdout">;
256
256
  };
257
257
  /**
258
- * Render a React element for testing, capturing output in mock streams.
259
- *
260
- * Returns an object with methods to inspect rendered output, simulate input,
261
- * and control the component lifecycle.
262
- * @example
263
- * ```tsx
264
- * import { render } from "@visulima/tui/test";
265
- * import { Text } from "@visulima/tui";
266
- *
267
- * const { lastFrame } = render(<Text>Hello</Text>);
268
- * console.log(lastFrame()); // "Hello"
269
- * ```
270
- */
258
+ * Render a React element for testing, capturing output in mock streams.
259
+ *
260
+ * Returns an object with methods to inspect rendered output, simulate input,
261
+ * and control the component lifecycle.
262
+ * @example
263
+ * ```tsx
264
+ * import { render } from "@visulima/tui/test";
265
+ * import { Text } from "@visulima/tui";
266
+ *
267
+ * const { lastFrame } = render(<Text>Hello</Text>);
268
+ * console.log(lastFrame()); // "Hello"
269
+ * ```
270
+ */
271
271
  declare const testRender: (node: ReactElement, testOptions?: TestRenderOptions) => TestInstance;
272
272
  /**
273
- * Unmount and clean up all rendered test instances.
274
- *
275
- * Call this in your test teardown (e.g., `afterEach`) to ensure
276
- * no test instances leak between tests.
277
- * @example
278
- * ```ts
279
- * import { cleanup } from "@visulima/tui/test";
280
- *
281
- * afterEach(() => {
282
- * cleanup();
283
- * });
284
- * ```
285
- */
273
+ * Unmount and clean up all rendered test instances.
274
+ *
275
+ * Call this in your test teardown (e.g., `afterEach`) to ensure
276
+ * no test instances leak between tests.
277
+ * @example
278
+ * ```ts
279
+ * import { cleanup } from "@visulima/tui/test";
280
+ *
281
+ * afterEach(() => {
282
+ * cleanup();
283
+ * });
284
+ * ```
285
+ */
286
286
  declare const cleanup: () => void;
287
287
  export { KEY, type KeyName, type KeySender, type Screen, TestInstance, TestInstanceStderr, TestInstanceStdin, TestInstanceStdout, TestRenderOptions, type WaitForOptions, cleanup, createKeySender, createScreen, testRender as render, waitFor };
@@ -1 +1 @@
1
- import{createRequire as _}from"node:module";import F from"../packem_shared/render-D7aV_hO1.js";import{createKeySender as x}from"../packem_shared/KEY-C--kOw41.js";import{KEY as K}from"../packem_shared/KEY-C--kOw41.js";import{createScreen as y}from"../packem_shared/createScreen-DoYpyL0V.js";import{waitFor as T}from"../packem_shared/waitFor-CTAki32d.js";const g=_(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return g(t)},m=w("node:events");class b extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class j extends m{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],P=(t,e={})=>{const{columns:n,options:d}=e,s=new b(n),c=new v(n),o=new j,i=F(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:c,stdin:o,stdout:s,...d});u.push(i);const l=y(()=>s.lastFrame(),s.frames),p=x(r=>o.write(r)),f=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:i.cleanup,flush:f,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:i.rerender,screen:l,stderr:c,stdin:o,stdout:s,unmount:i.unmount,async waitFor(r,h){await T(r,()=>l.text(),h)}}},S=()=>{for(const t of u)t.cleanup();u.length=0};export{K as KEY,S as cleanup,x as createKeySender,y as createScreen,P as render,T as waitFor};
1
+ import{createRequire as _}from"node:module";import x from"../packem_shared/render-CuCo-R-l.js";import{createKeySender as y}from"../packem_shared/KEY-C--kOw41.js";import{KEY as Y}from"../packem_shared/KEY-C--kOw41.js";import{createScreen as T}from"../packem_shared/createScreen-DoYpyL0V.js";import{waitFor as b}from"../packem_shared/waitFor-CTAki32d.js";let g;const w=t=>(g??=_(import.meta.url))(t),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return w(t)},m=F("node:events");class j extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class R extends m{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],S=(t,e={})=>{const{columns:n,options:d}=e,s=new j(n),c=new v(n),o=new R,i=x(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:c,stdin:o,stdout:s,...d});u.push(i);const l=T(()=>s.lastFrame(),s.frames),p=y(r=>o.write(r)),f=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:i.cleanup,flush:f,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:i.rerender,screen:l,stderr:c,stdin:o,stdout:s,unmount:i.unmount,async waitFor(r,h){await b(r,()=>l.text(),h)}}},B=()=>{for(const t of u)t.cleanup();u.length=0};export{Y as KEY,B as cleanup,y as createKeySender,T as createScreen,S as render,b as waitFor};