@alchemy.run/sigil 0.0.0-alpha.10 → 0.0.0-alpha.11
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.
- package/THIRD_PARTY_NOTICES.md +28 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +181 -179
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +227 -0
- package/dist/jsx-runtime-XtwIVFsg.js +255 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +8 -0
- package/dist/react-CTZ_8dwh.js +1197 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +49 -0
- package/dist/router.js +44 -42
- package/dist/use-focus-B5npZrJU.js +18736 -0
- package/package.json +22 -8
- package/src/ansi/strip.ts +2 -2
- package/src/jsx-dev-runtime.ts +3 -0
- package/src/jsx-runtime.ts +6 -0
- package/src/react.ts +53 -0
- package/src/reconciler.ts +51 -0
- package/dist/use-focus-CcCIdCWA.js +0 -1337
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import { r as __toESM, t as require_react } from "./react-CTZ_8dwh.js";
|
|
2
|
+
import { _ as squashTextNodes, a as reconciler, b as require_react_reconciler, c as kittyModifiers, d as FocusContext, f as Text, g as transformAnsiLine, h as emitLayoutListeners, i as useStdinContext, l as resolveFlags, m as createNode, n as useInput, o as detectKittySupport, p as addLayoutListener, r as useStdin, s as kittyFlags, t as useFocus, u as StdinContext, v as accessibilityContext, y as require_constants } from "./use-focus-B5npZrJU.js";
|
|
1
3
|
import { C as bsu, S as ansiEscapes, V as esu, W as link, _ as CSI } from "./sgr-BhwaWAJB.js";
|
|
2
4
|
import { h as tokenizeAnsi, p as graphemes } from "./tokenize-AjqbvtiT.js";
|
|
3
5
|
import { t as stringWidth } from "./string-width-CijQwpIk.js";
|
|
4
6
|
import { n as sliceAnsi, r as wrapAnsi } from "./truncate-D31fhU6i.js";
|
|
5
|
-
import { _ as squashTextNodes, a as reconciler, c as kittyModifiers, d as FocusContext, f as Text, g as transformAnsiLine, h as emitLayoutListeners, i as useStdinContext, l as resolveFlags, m as createNode, n as useInput, o as detectKittySupport, p as addLayoutListener, r as useStdin, s as kittyFlags, t as useFocus, u as StdinContext, v as accessibilityContext } from "./use-focus-CcCIdCWA.js";
|
|
6
7
|
import { a as isTty, i as isSigilDev, o as isWindows, r as isScreenReader, t as isInCi } from "./env-YVw64yZS.js";
|
|
7
8
|
import { a as detectTerminal, i as detectHyperlinkSupport, n as detectCapabilities, o as detectUnicodeSupport, r as detectColorLevel, s as signalExit, t as createSupportsColor } from "./detect-B3dL4Q11.js";
|
|
8
9
|
import { u as cliCursor } from "./osc-BFKKSqpg.js";
|
|
9
10
|
import { a as registerTerminalIntegration, c as ensureTerminalQuery, f as queryTerminal, i as getCapabilities, l as getTerminalQuery, o as getRawModeStream, p as refreshTerminalQuery, r as capabilities, s as applyTerminalQuery, u as getTerminalQueryPromise } from "./color-policy-BAC9-TZX.js";
|
|
10
11
|
import { a as buildCursorSuffix, c as hideCursorEscape, i as buildCursorOnlySequence, o as buildReturnToBottomPrefix, s as cursorPositionChanged, t as TerminalSession } from "./session-DDQ5V300.js";
|
|
11
12
|
import { t as Yoga } from "./yoga-5jKhYCJC.js";
|
|
13
|
+
import { t as require_jsx_runtime } from "./jsx-runtime-XtwIVFsg.js";
|
|
12
14
|
import { r as createCell, t as cellAttributes } from "./cell-_ZVhbfl0.js";
|
|
13
15
|
import { i as semanticTextStyleToCellStyle, n as mergeSemanticTextStyles, t as emptySemanticTextStyle } from "./semantic-text-style-DIMzC7xt.js";
|
|
14
16
|
import { a as samplePaint } from "./sample-Cqw1bjUL.js";
|
|
@@ -20,16 +22,14 @@ import "./color-CkbalRqK.js";
|
|
|
20
22
|
import { PassThrough, Stream } from "node:stream";
|
|
21
23
|
import { setImmediate as setImmediate$1 } from "node:timers/promises";
|
|
22
24
|
import { isNativeError } from "node:util/types";
|
|
23
|
-
import { PureComponent, createContext, useCallback, useContext, useEffect, useEffectEvent, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
24
|
-
import "react-reconciler";
|
|
25
|
-
import { ConcurrentRoot, LegacyRoot } from "react-reconciler/constants.js";
|
|
26
25
|
import { EventEmitter } from "node:events";
|
|
27
26
|
import { existsSync, readFileSync } from "node:fs";
|
|
28
27
|
import { cwd } from "node:process";
|
|
29
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
28
|
import { Console } from "node:console";
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
require_react_reconciler();
|
|
30
|
+
var import_constants = require_constants();
|
|
31
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
32
|
+
const animationContext = (0, import_react.createContext)({
|
|
33
33
|
renderThrottleMs: 0,
|
|
34
34
|
subscribe() {
|
|
35
35
|
return {
|
|
@@ -48,7 +48,7 @@ const noopSuspension = {
|
|
|
48
48
|
async resume() {},
|
|
49
49
|
async [Symbol.asyncDispose]() {}
|
|
50
50
|
};
|
|
51
|
-
const AppContext = createContext({
|
|
51
|
+
const AppContext = (0, import_react.createContext)({
|
|
52
52
|
exit(_errorOrResult) {},
|
|
53
53
|
async waitUntilRenderFlush() {},
|
|
54
54
|
suspendTerminal: (async (callback) => {
|
|
@@ -62,7 +62,7 @@ const AppContext = createContext({
|
|
|
62
62
|
AppContext.displayName = "InternalAppContext";
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region src/components/CursorContext.ts
|
|
65
|
-
const CursorContext = createContext({ setCursorPosition() {} });
|
|
65
|
+
const CursorContext = (0, import_react.createContext)({ setCursorPosition() {} });
|
|
66
66
|
CursorContext.displayName = "InternalCursorContext";
|
|
67
67
|
//#endregion
|
|
68
68
|
//#region src/code-excerpt.ts
|
|
@@ -168,14 +168,15 @@ const BOXES = {
|
|
|
168
168
|
//#endregion
|
|
169
169
|
//#region src/components/Box.tsx
|
|
170
170
|
/** @jsxImportSource react */
|
|
171
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
171
172
|
/**
|
|
172
173
|
`<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
|
|
173
174
|
*/
|
|
174
175
|
function Box({ children, ref, backgroundColor, "aria-label": ariaLabel, "aria-hidden": ariaHidden, "aria-role": role, "aria-state": ariaState, ...style }) {
|
|
175
|
-
const { isScreenReaderEnabled } = useContext(accessibilityContext);
|
|
176
|
-
const label = ariaLabel ? /* @__PURE__ */ jsx("ink-text", { children: ariaLabel }) : void 0;
|
|
176
|
+
const { isScreenReaderEnabled } = (0, import_react.useContext)(accessibilityContext);
|
|
177
|
+
const label = ariaLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ink-text", { children: ariaLabel }) : void 0;
|
|
177
178
|
if (isScreenReaderEnabled && ariaHidden) return null;
|
|
178
|
-
return /* @__PURE__ */ jsx("ink-box", {
|
|
179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ink-box", {
|
|
179
180
|
ref,
|
|
180
181
|
style: {
|
|
181
182
|
flexWrap: "nowrap",
|
|
@@ -273,11 +274,11 @@ function ErrorOverview({ error }) {
|
|
|
273
274
|
excerpt = codeExcerpt(sourceCode, origin.line);
|
|
274
275
|
if (excerpt) for (const { line } of excerpt) lineWidth = Math.max(lineWidth, String(line).length);
|
|
275
276
|
}
|
|
276
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
|
|
277
278
|
flexDirection: "column",
|
|
278
279
|
padding: 1,
|
|
279
280
|
children: [
|
|
280
|
-
/* @__PURE__ */ jsxs(Box, { children: [/* @__PURE__ */ jsxs(Text, {
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
281
282
|
backgroundColor: "red",
|
|
282
283
|
color: "white",
|
|
283
284
|
children: [
|
|
@@ -285,10 +286,10 @@ function ErrorOverview({ error }) {
|
|
|
285
286
|
"ERROR",
|
|
286
287
|
" "
|
|
287
288
|
]
|
|
288
|
-
}), /* @__PURE__ */ jsxs(Text, { children: [" ", error.message] })] }),
|
|
289
|
-
origin && filePath ? /* @__PURE__ */ jsx(Box, {
|
|
289
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [" ", error.message] })] }),
|
|
290
|
+
origin && filePath ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
290
291
|
marginTop: 1,
|
|
291
|
-
children: /* @__PURE__ */ jsxs(Text, {
|
|
292
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
292
293
|
dimColor: true,
|
|
293
294
|
children: [
|
|
294
295
|
filePath,
|
|
@@ -299,25 +300,25 @@ function ErrorOverview({ error }) {
|
|
|
299
300
|
]
|
|
300
301
|
})
|
|
301
302
|
}) : null,
|
|
302
|
-
origin && excerpt ? /* @__PURE__ */ jsx(Box, {
|
|
303
|
+
origin && excerpt ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
303
304
|
marginTop: 1,
|
|
304
305
|
flexDirection: "column",
|
|
305
|
-
children: excerpt.map(({ line, value }) => /* @__PURE__ */ jsxs(Box, { children: [/* @__PURE__ */ jsx(Box, {
|
|
306
|
+
children: excerpt.map(({ line, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
306
307
|
width: lineWidth + 1,
|
|
307
|
-
children: /* @__PURE__ */ jsxs(Text, {
|
|
308
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
308
309
|
dimColor: line !== origin.line,
|
|
309
310
|
backgroundColor: line === origin.line ? "red" : void 0,
|
|
310
311
|
color: line === origin.line ? "white" : void 0,
|
|
311
312
|
"aria-label": line === origin.line ? `Line ${line}, error` : `Line ${line}`,
|
|
312
313
|
children: [String(line).padStart(lineWidth, " "), ":"]
|
|
313
314
|
})
|
|
314
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
315
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
315
316
|
backgroundColor: line === origin.line ? "red" : void 0,
|
|
316
317
|
color: line === origin.line ? "white" : void 0,
|
|
317
318
|
children: " " + value
|
|
318
319
|
}, line)] }, line))
|
|
319
320
|
}) : null,
|
|
320
|
-
error.stack ? /* @__PURE__ */ jsx(Box, {
|
|
321
|
+
error.stack ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
321
322
|
marginTop: 1,
|
|
322
323
|
flexDirection: "column",
|
|
323
324
|
children: error.stack.split("\n").slice(1).map((line) => {
|
|
@@ -325,10 +326,10 @@ function ErrorOverview({ error }) {
|
|
|
325
326
|
const lineCount = stackLineCounts.get(line) ?? 0;
|
|
326
327
|
stackLineCounts.set(line, lineCount + 1);
|
|
327
328
|
const key = `${line}-${lineCount}`;
|
|
328
|
-
if (!parsedLine?.file || !parsedLine.line || !parsedLine.column) return /* @__PURE__ */ jsxs(Box, { children: [/* @__PURE__ */ jsx(Text, {
|
|
329
|
+
if (!parsedLine?.file || !parsedLine.line || !parsedLine.column) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
329
330
|
dimColor: true,
|
|
330
331
|
children: "- "
|
|
331
|
-
}), /* @__PURE__ */ jsxs(Text, {
|
|
332
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
332
333
|
dimColor: true,
|
|
333
334
|
bold: true,
|
|
334
335
|
children: [
|
|
@@ -337,17 +338,17 @@ function ErrorOverview({ error }) {
|
|
|
337
338
|
" "
|
|
338
339
|
]
|
|
339
340
|
})] }, key);
|
|
340
|
-
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
341
|
-
/* @__PURE__ */ jsx(Text, {
|
|
341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
342
343
|
dimColor: true,
|
|
343
344
|
children: "- "
|
|
344
345
|
}),
|
|
345
|
-
/* @__PURE__ */ jsx(Text, {
|
|
346
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
346
347
|
dimColor: true,
|
|
347
348
|
bold: true,
|
|
348
349
|
children: parsedLine.function
|
|
349
350
|
}),
|
|
350
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
351
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
351
352
|
dimColor: true,
|
|
352
353
|
color: "gray",
|
|
353
354
|
"aria-label": `at ${cleanupPath(parsedLine.file) ?? ""} line ${parsedLine.line} column ${parsedLine.column}`,
|
|
@@ -371,7 +372,7 @@ function ErrorOverview({ error }) {
|
|
|
371
372
|
//#endregion
|
|
372
373
|
//#region src/components/ErrorBoundary.tsx
|
|
373
374
|
/** @jsxImportSource react */
|
|
374
|
-
var ErrorBoundary = class extends PureComponent {
|
|
375
|
+
var ErrorBoundary = class extends import_react.PureComponent {
|
|
375
376
|
static displayName = "InternalErrorBoundary";
|
|
376
377
|
static getDerivedStateFromError(error) {
|
|
377
378
|
return { error };
|
|
@@ -381,7 +382,7 @@ var ErrorBoundary = class extends PureComponent {
|
|
|
381
382
|
this.props.onError(error);
|
|
382
383
|
}
|
|
383
384
|
render() {
|
|
384
|
-
if (this.state.error) return /* @__PURE__ */ jsx(ErrorOverview, { error: this.state.error });
|
|
385
|
+
if (this.state.error) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorOverview, { error: this.state.error });
|
|
385
386
|
return this.props.children;
|
|
386
387
|
}
|
|
387
388
|
};
|
|
@@ -390,7 +391,7 @@ var ErrorBoundary = class extends PureComponent {
|
|
|
390
391
|
/**
|
|
391
392
|
`StderrContext` is a React context that exposes the stderr stream.
|
|
392
393
|
*/
|
|
393
|
-
const StderrContext = createContext({
|
|
394
|
+
const StderrContext = (0, import_react.createContext)({
|
|
394
395
|
stderr: process.stderr,
|
|
395
396
|
write() {}
|
|
396
397
|
});
|
|
@@ -400,7 +401,7 @@ StderrContext.displayName = "InternalStderrContext";
|
|
|
400
401
|
/**
|
|
401
402
|
`StdoutContext` is a React context that exposes the stdout stream where Ink renders your app.
|
|
402
403
|
*/
|
|
403
|
-
const StdoutContext = createContext({
|
|
404
|
+
const StdoutContext = (0, import_react.createContext)({
|
|
404
405
|
stdout: process.stdout,
|
|
405
406
|
write() {}
|
|
406
407
|
});
|
|
@@ -412,32 +413,32 @@ const tab = " ";
|
|
|
412
413
|
const shiftTab = `${CSI}Z`;
|
|
413
414
|
const escape = "\x1B";
|
|
414
415
|
function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, exitOnCtrlC, onExit, onWaitUntilRenderFlush, onSuspendTerminal, onRegisterInputControl, setCursorPosition, interactive, renderThrottleMs, terminalInput }) {
|
|
415
|
-
const [isFocusEnabled, setIsFocusEnabled] = useState(true);
|
|
416
|
-
const [activeFocusId, setActiveFocusId] = useState(void 0);
|
|
417
|
-
const [, setFocusables] = useState([]);
|
|
418
|
-
const focusablesCountRef = useRef(0);
|
|
419
|
-
const animationSubscribersRef = useRef(/* @__PURE__ */ new Map());
|
|
420
|
-
const animationTimerRef = useRef(void 0);
|
|
421
|
-
const rawModeEnabledCount = useRef(0);
|
|
422
|
-
const pendingDisableRawModeRef = useRef(false);
|
|
423
|
-
const bracketedPasteModeEnabledCount = useRef(0);
|
|
424
|
-
const internal_eventEmitter = useRef(new EventEmitter());
|
|
416
|
+
const [isFocusEnabled, setIsFocusEnabled] = (0, import_react.useState)(true);
|
|
417
|
+
const [activeFocusId, setActiveFocusId] = (0, import_react.useState)(void 0);
|
|
418
|
+
const [, setFocusables] = (0, import_react.useState)([]);
|
|
419
|
+
const focusablesCountRef = (0, import_react.useRef)(0);
|
|
420
|
+
const animationSubscribersRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
421
|
+
const animationTimerRef = (0, import_react.useRef)(void 0);
|
|
422
|
+
const rawModeEnabledCount = (0, import_react.useRef)(0);
|
|
423
|
+
const pendingDisableRawModeRef = (0, import_react.useRef)(false);
|
|
424
|
+
const bracketedPasteModeEnabledCount = (0, import_react.useRef)(0);
|
|
425
|
+
const internal_eventEmitter = (0, import_react.useRef)(new EventEmitter());
|
|
425
426
|
internal_eventEmitter.current.setMaxListeners(Infinity);
|
|
426
|
-
const readableListenerRef = useRef(void 0);
|
|
427
|
-
const isMountedRef = useRef(true);
|
|
428
|
-
const pendingInputFlushRef = useRef(void 0);
|
|
427
|
+
const readableListenerRef = (0, import_react.useRef)(void 0);
|
|
428
|
+
const isMountedRef = (0, import_react.useRef)(true);
|
|
429
|
+
const pendingInputFlushRef = (0, import_react.useRef)(void 0);
|
|
429
430
|
const pendingInputFlushDelayMilliseconds = 20;
|
|
430
|
-
const clearPendingInputFlush = useCallback(() => {
|
|
431
|
+
const clearPendingInputFlush = (0, import_react.useCallback)(() => {
|
|
431
432
|
if (!pendingInputFlushRef.current) return;
|
|
432
433
|
clearTimeout(pendingInputFlushRef.current);
|
|
433
434
|
pendingInputFlushRef.current = void 0;
|
|
434
435
|
}, []);
|
|
435
|
-
const clearAnimationTimer = useCallback(() => {
|
|
436
|
+
const clearAnimationTimer = (0, import_react.useCallback)(() => {
|
|
436
437
|
if (!animationTimerRef.current) return;
|
|
437
438
|
clearTimeout(animationTimerRef.current);
|
|
438
439
|
animationTimerRef.current = void 0;
|
|
439
440
|
}, []);
|
|
440
|
-
const scheduleAnimationTick = useCallback(() => {
|
|
441
|
+
const scheduleAnimationTick = (0, import_react.useCallback)(() => {
|
|
441
442
|
clearAnimationTimer();
|
|
442
443
|
if (animationSubscribersRef.current.size === 0) return;
|
|
443
444
|
let nextDueTime = Number.POSITIVE_INFINITY;
|
|
@@ -456,7 +457,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
456
457
|
scheduleAnimationTick();
|
|
457
458
|
}, delay);
|
|
458
459
|
}, [clearAnimationTimer]);
|
|
459
|
-
const animationSubscribe = useCallback((callback, interval) => {
|
|
460
|
+
const animationSubscribe = (0, import_react.useCallback)((callback, interval) => {
|
|
460
461
|
const startTime = performance.now();
|
|
461
462
|
animationSubscribersRef.current.set(callback, {
|
|
462
463
|
callback,
|
|
@@ -477,19 +478,19 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
477
478
|
}
|
|
478
479
|
};
|
|
479
480
|
}, [clearAnimationTimer, scheduleAnimationTick]);
|
|
480
|
-
useEffect(() => {
|
|
481
|
+
(0, import_react.useEffect)(() => {
|
|
481
482
|
return () => {
|
|
482
483
|
clearAnimationTimer();
|
|
483
484
|
};
|
|
484
485
|
}, [clearAnimationTimer]);
|
|
485
486
|
const rawModeStdin = getRawModeStream(stdin);
|
|
486
487
|
const isRawModeSupported = rawModeStdin !== void 0;
|
|
487
|
-
const detachReadableListener = useCallback(() => {
|
|
488
|
+
const detachReadableListener = (0, import_react.useCallback)(() => {
|
|
488
489
|
if (!readableListenerRef.current) return;
|
|
489
490
|
stdin.removeListener("readable", readableListenerRef.current);
|
|
490
491
|
readableListenerRef.current = void 0;
|
|
491
492
|
}, [stdin]);
|
|
492
|
-
const clearInputState = useCallback(() => {
|
|
493
|
+
const clearInputState = (0, import_react.useCallback)(() => {
|
|
493
494
|
terminalInput.reset();
|
|
494
495
|
clearPendingInputFlush();
|
|
495
496
|
detachReadableListener();
|
|
@@ -498,7 +499,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
498
499
|
detachReadableListener,
|
|
499
500
|
terminalInput
|
|
500
501
|
]);
|
|
501
|
-
const disableRawMode = useCallback(() => {
|
|
502
|
+
const disableRawMode = (0, import_react.useCallback)(() => {
|
|
502
503
|
if (!rawModeStdin) return;
|
|
503
504
|
pendingDisableRawModeRef.current = false;
|
|
504
505
|
rawModeStdin.setRawMode(false);
|
|
@@ -506,7 +507,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
506
507
|
rawModeEnabledCount.current = 0;
|
|
507
508
|
clearInputState();
|
|
508
509
|
}, [rawModeStdin, clearInputState]);
|
|
509
|
-
const handleExit = useCallback((errorOrResult) => {
|
|
510
|
+
const handleExit = (0, import_react.useCallback)((errorOrResult) => {
|
|
510
511
|
if (isRawModeSupported && (rawModeEnabledCount.current > 0 || pendingDisableRawModeRef.current)) disableRawMode();
|
|
511
512
|
onExit(errorOrResult);
|
|
512
513
|
}, [
|
|
@@ -514,7 +515,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
514
515
|
disableRawMode,
|
|
515
516
|
onExit
|
|
516
517
|
]);
|
|
517
|
-
const handleInput = useCallback((input) => {
|
|
518
|
+
const handleInput = (0, import_react.useCallback)((input) => {
|
|
518
519
|
if (input === "" && exitOnCtrlC) {
|
|
519
520
|
handleExit();
|
|
520
521
|
return;
|
|
@@ -525,11 +526,11 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
525
526
|
handleExit,
|
|
526
527
|
isFocusEnabled
|
|
527
528
|
]);
|
|
528
|
-
const emitInput = useCallback((input) => {
|
|
529
|
+
const emitInput = (0, import_react.useCallback)((input) => {
|
|
529
530
|
handleInput(input);
|
|
530
531
|
internal_eventEmitter.current.emit("input", input);
|
|
531
532
|
}, [handleInput]);
|
|
532
|
-
const schedulePendingInputFlush = useCallback(() => {
|
|
533
|
+
const schedulePendingInputFlush = (0, import_react.useCallback)(() => {
|
|
533
534
|
clearPendingInputFlush();
|
|
534
535
|
pendingInputFlushRef.current = setTimeout(() => {
|
|
535
536
|
pendingInputFlushRef.current = void 0;
|
|
@@ -542,7 +543,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
542
543
|
emitInput,
|
|
543
544
|
terminalInput
|
|
544
545
|
]);
|
|
545
|
-
const handleReadable = useCallback(() => {
|
|
546
|
+
const handleReadable = (0, import_react.useCallback)(() => {
|
|
546
547
|
clearPendingInputFlush();
|
|
547
548
|
let chunk;
|
|
548
549
|
while ((chunk = stdin.read()) !== null) {
|
|
@@ -564,12 +565,12 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
564
565
|
schedulePendingInputFlush,
|
|
565
566
|
terminalInput
|
|
566
567
|
]);
|
|
567
|
-
const attachReadableListener = useCallback(() => {
|
|
568
|
+
const attachReadableListener = (0, import_react.useCallback)(() => {
|
|
568
569
|
if (readableListenerRef.current) return;
|
|
569
570
|
readableListenerRef.current = handleReadable;
|
|
570
571
|
stdin.addListener("readable", handleReadable);
|
|
571
572
|
}, [stdin, handleReadable]);
|
|
572
|
-
const handleSetRawMode = useCallback((isEnabled) => {
|
|
573
|
+
const handleSetRawMode = (0, import_react.useCallback)((isEnabled) => {
|
|
573
574
|
if (!rawModeStdin) {
|
|
574
575
|
if (stdin === process.stdin) throw new Error("Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported");
|
|
575
576
|
else throw new Error("Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported");
|
|
@@ -604,7 +605,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
604
605
|
clearInputState,
|
|
605
606
|
disableRawMode
|
|
606
607
|
]);
|
|
607
|
-
const handleQueryTerminal = useCallback(async ({ refresh = false } = {}) => {
|
|
608
|
+
const handleQueryTerminal = (0, import_react.useCallback)(async ({ refresh = false } = {}) => {
|
|
608
609
|
if (!interactive || !isRawModeSupported || !stdout.isTTY) return;
|
|
609
610
|
if (!refresh) {
|
|
610
611
|
const existing = getTerminalQueryPromise(stdout);
|
|
@@ -627,13 +628,13 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
627
628
|
detachReadableListener,
|
|
628
629
|
attachReadableListener
|
|
629
630
|
]);
|
|
630
|
-
const reportFeedActiveRef = useRef(false);
|
|
631
|
-
const handleSetReportFeed = useCallback((active) => {
|
|
631
|
+
const reportFeedActiveRef = (0, import_react.useRef)(false);
|
|
632
|
+
const handleSetReportFeed = (0, import_react.useCallback)((active) => {
|
|
632
633
|
if (active === reportFeedActiveRef.current || !isRawModeSupported) return;
|
|
633
634
|
reportFeedActiveRef.current = active;
|
|
634
635
|
handleSetRawMode(active);
|
|
635
636
|
}, [isRawModeSupported, handleSetRawMode]);
|
|
636
|
-
useInsertionEffect(() => {
|
|
637
|
+
(0, import_react.useInsertionEffect)(() => {
|
|
637
638
|
const unregister = registerTerminalIntegration(stdout, {
|
|
638
639
|
runQuery: handleQueryTerminal,
|
|
639
640
|
setReportFeed: handleSetReportFeed
|
|
@@ -647,7 +648,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
647
648
|
handleQueryTerminal,
|
|
648
649
|
handleSetReportFeed
|
|
649
650
|
]);
|
|
650
|
-
const handleSetBracketedPasteMode = useCallback((isEnabled) => {
|
|
651
|
+
const handleSetBracketedPasteMode = (0, import_react.useCallback)((isEnabled) => {
|
|
651
652
|
if (!stdout.isTTY) return;
|
|
652
653
|
if (isEnabled) {
|
|
653
654
|
if (bracketedPasteModeEnabledCount.current === 0) stdout.write(ansiEscapes.enableBracketedPaste);
|
|
@@ -657,11 +658,11 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
657
658
|
if (bracketedPasteModeEnabledCount.current === 0) return;
|
|
658
659
|
if (--bracketedPasteModeEnabledCount.current === 0) stdout.write(ansiEscapes.disableBracketedPaste);
|
|
659
660
|
}, [stdout]);
|
|
660
|
-
const suspendedInputStateRef = useRef({
|
|
661
|
+
const suspendedInputStateRef = (0, import_react.useRef)({
|
|
661
662
|
rawMode: false,
|
|
662
663
|
bracketedPaste: false
|
|
663
664
|
});
|
|
664
|
-
const pauseInput = useCallback(() => {
|
|
665
|
+
const pauseInput = (0, import_react.useCallback)(() => {
|
|
665
666
|
const wasRawMode = isRawModeSupported && rawModeEnabledCount.current > 0;
|
|
666
667
|
const wasBracketedPaste = bracketedPasteModeEnabledCount.current > 0;
|
|
667
668
|
suspendedInputStateRef.current = {
|
|
@@ -682,7 +683,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
682
683
|
stdout,
|
|
683
684
|
clearInputState
|
|
684
685
|
]);
|
|
685
|
-
const resumeInput = useCallback(() => {
|
|
686
|
+
const resumeInput = (0, import_react.useCallback)(() => {
|
|
686
687
|
const { rawMode, bracketedPaste } = suspendedInputStateRef.current;
|
|
687
688
|
if (rawMode) {
|
|
688
689
|
rawModeStdin?.setEncoding("utf8");
|
|
@@ -698,14 +699,14 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
698
699
|
stdout,
|
|
699
700
|
attachReadableListener
|
|
700
701
|
]);
|
|
701
|
-
useInsertionEffect(() => {
|
|
702
|
+
(0, import_react.useInsertionEffect)(() => {
|
|
702
703
|
onRegisterInputControl(pauseInput, resumeInput);
|
|
703
704
|
}, [
|
|
704
705
|
onRegisterInputControl,
|
|
705
706
|
pauseInput,
|
|
706
707
|
resumeInput
|
|
707
708
|
]);
|
|
708
|
-
const findNextFocusable = useCallback((currentFocusables, currentActiveFocusId) => {
|
|
709
|
+
const findNextFocusable = (0, import_react.useCallback)((currentFocusables, currentActiveFocusId) => {
|
|
709
710
|
const activeIndex = currentFocusables.findIndex((focusable) => {
|
|
710
711
|
return focusable.id === currentActiveFocusId;
|
|
711
712
|
});
|
|
@@ -714,7 +715,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
714
715
|
if (focusable?.isActive) return focusable.id;
|
|
715
716
|
}
|
|
716
717
|
}, []);
|
|
717
|
-
const findPreviousFocusable = useCallback((currentFocusables, currentActiveFocusId) => {
|
|
718
|
+
const findPreviousFocusable = (0, import_react.useCallback)((currentFocusables, currentActiveFocusId) => {
|
|
718
719
|
const activeIndex = currentFocusables.findIndex((focusable) => {
|
|
719
720
|
return focusable.id === currentActiveFocusId;
|
|
720
721
|
});
|
|
@@ -723,7 +724,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
723
724
|
if (focusable?.isActive) return focusable.id;
|
|
724
725
|
}
|
|
725
726
|
}, []);
|
|
726
|
-
const focusNext = useCallback(() => {
|
|
727
|
+
const focusNext = (0, import_react.useCallback)(() => {
|
|
727
728
|
setFocusables((currentFocusables) => {
|
|
728
729
|
setActiveFocusId((currentActiveFocusId) => {
|
|
729
730
|
const firstFocusableId = currentFocusables.find((focusable) => focusable.isActive)?.id;
|
|
@@ -732,7 +733,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
732
733
|
return currentFocusables;
|
|
733
734
|
});
|
|
734
735
|
}, [findNextFocusable]);
|
|
735
|
-
const focusPrevious = useCallback(() => {
|
|
736
|
+
const focusPrevious = (0, import_react.useCallback)(() => {
|
|
736
737
|
setFocusables((currentFocusables) => {
|
|
737
738
|
setActiveFocusId((currentActiveFocusId) => {
|
|
738
739
|
const lastFocusableId = currentFocusables.findLast((focusable) => focusable.isActive)?.id;
|
|
@@ -741,7 +742,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
741
742
|
return currentFocusables;
|
|
742
743
|
});
|
|
743
744
|
}, [findPreviousFocusable]);
|
|
744
|
-
useEffect(() => {
|
|
745
|
+
(0, import_react.useEffect)(() => {
|
|
745
746
|
const handleTabNavigation = (input) => {
|
|
746
747
|
if (!isFocusEnabled || focusablesCountRef.current === 0) return;
|
|
747
748
|
if (input === tab) focusNext();
|
|
@@ -757,19 +758,19 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
757
758
|
focusNext,
|
|
758
759
|
focusPrevious
|
|
759
760
|
]);
|
|
760
|
-
const enableFocus = useCallback(() => {
|
|
761
|
+
const enableFocus = (0, import_react.useCallback)(() => {
|
|
761
762
|
setIsFocusEnabled(true);
|
|
762
763
|
}, []);
|
|
763
|
-
const disableFocus = useCallback(() => {
|
|
764
|
+
const disableFocus = (0, import_react.useCallback)(() => {
|
|
764
765
|
setIsFocusEnabled(false);
|
|
765
766
|
}, []);
|
|
766
|
-
const focus = useCallback((id) => {
|
|
767
|
+
const focus = (0, import_react.useCallback)((id) => {
|
|
767
768
|
setFocusables((currentFocusables) => {
|
|
768
769
|
if (currentFocusables.some((focusable) => focusable?.id === id)) setActiveFocusId(id);
|
|
769
770
|
return currentFocusables;
|
|
770
771
|
});
|
|
771
772
|
}, []);
|
|
772
|
-
const addFocusable = useCallback((id, { autoFocus }) => {
|
|
773
|
+
const addFocusable = (0, import_react.useCallback)((id, { autoFocus }) => {
|
|
773
774
|
setFocusables((currentFocusables) => {
|
|
774
775
|
focusablesCountRef.current = currentFocusables.length + 1;
|
|
775
776
|
return [...currentFocusables, {
|
|
@@ -782,7 +783,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
782
783
|
return currentActiveFocusId;
|
|
783
784
|
});
|
|
784
785
|
}, []);
|
|
785
|
-
const removeFocusable = useCallback((id) => {
|
|
786
|
+
const removeFocusable = (0, import_react.useCallback)((id) => {
|
|
786
787
|
setActiveFocusId((currentActiveFocusId) => {
|
|
787
788
|
if (currentActiveFocusId === id) return;
|
|
788
789
|
return currentActiveFocusId;
|
|
@@ -795,7 +796,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
795
796
|
return filtered;
|
|
796
797
|
});
|
|
797
798
|
}, []);
|
|
798
|
-
const activateFocusable = useCallback((id) => {
|
|
799
|
+
const activateFocusable = (0, import_react.useCallback)((id) => {
|
|
799
800
|
setFocusables((currentFocusables) => currentFocusables.map((focusable) => {
|
|
800
801
|
if (focusable.id !== id) return focusable;
|
|
801
802
|
return {
|
|
@@ -804,7 +805,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
804
805
|
};
|
|
805
806
|
}));
|
|
806
807
|
}, []);
|
|
807
|
-
const deactivateFocusable = useCallback((id) => {
|
|
808
|
+
const deactivateFocusable = (0, import_react.useCallback)((id) => {
|
|
808
809
|
setActiveFocusId((currentActiveFocusId) => {
|
|
809
810
|
if (currentActiveFocusId === id) return;
|
|
810
811
|
return currentActiveFocusId;
|
|
@@ -817,7 +818,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
817
818
|
};
|
|
818
819
|
}));
|
|
819
820
|
}, []);
|
|
820
|
-
useEffect(() => {
|
|
821
|
+
(0, import_react.useEffect)(() => {
|
|
821
822
|
isMountedRef.current = true;
|
|
822
823
|
return () => {
|
|
823
824
|
isMountedRef.current = false;
|
|
@@ -835,7 +836,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
835
836
|
disableRawMode,
|
|
836
837
|
interactive
|
|
837
838
|
]);
|
|
838
|
-
const appContextValue = useMemo(() => ({
|
|
839
|
+
const appContextValue = (0, import_react.useMemo)(() => ({
|
|
839
840
|
exit: handleExit,
|
|
840
841
|
waitUntilRenderFlush: onWaitUntilRenderFlush,
|
|
841
842
|
suspendTerminal: onSuspendTerminal
|
|
@@ -844,7 +845,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
844
845
|
onWaitUntilRenderFlush,
|
|
845
846
|
onSuspendTerminal
|
|
846
847
|
]);
|
|
847
|
-
const stdinContextValue = useMemo(() => ({
|
|
848
|
+
const stdinContextValue = (0, import_react.useMemo)(() => ({
|
|
848
849
|
stdin,
|
|
849
850
|
setRawMode: handleSetRawMode,
|
|
850
851
|
setBracketedPasteMode: handleSetBracketedPasteMode,
|
|
@@ -858,16 +859,16 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
858
859
|
isRawModeSupported,
|
|
859
860
|
exitOnCtrlC
|
|
860
861
|
]);
|
|
861
|
-
const stdoutContextValue = useMemo(() => ({
|
|
862
|
+
const stdoutContextValue = (0, import_react.useMemo)(() => ({
|
|
862
863
|
stdout,
|
|
863
864
|
write: writeToStdout
|
|
864
865
|
}), [stdout, writeToStdout]);
|
|
865
|
-
const stderrContextValue = useMemo(() => ({
|
|
866
|
+
const stderrContextValue = (0, import_react.useMemo)(() => ({
|
|
866
867
|
stderr,
|
|
867
868
|
write: writeToStderr
|
|
868
869
|
}), [stderr, writeToStderr]);
|
|
869
|
-
const cursorContextValue = useMemo(() => ({ setCursorPosition }), [setCursorPosition]);
|
|
870
|
-
const focusContextValue = useMemo(() => ({
|
|
870
|
+
const cursorContextValue = (0, import_react.useMemo)(() => ({ setCursorPosition }), [setCursorPosition]);
|
|
871
|
+
const focusContextValue = (0, import_react.useMemo)(() => ({
|
|
871
872
|
activeId: activeFocusId,
|
|
872
873
|
add: addFocusable,
|
|
873
874
|
remove: removeFocusable,
|
|
@@ -890,25 +891,25 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
890
891
|
focusPrevious,
|
|
891
892
|
focus
|
|
892
893
|
]);
|
|
893
|
-
const animationContextValue = useMemo(() => ({
|
|
894
|
+
const animationContextValue = (0, import_react.useMemo)(() => ({
|
|
894
895
|
renderThrottleMs,
|
|
895
896
|
subscribe: animationSubscribe
|
|
896
897
|
}), [animationSubscribe, renderThrottleMs]);
|
|
897
|
-
return /* @__PURE__ */ jsx(AppContext.Provider, {
|
|
898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppContext.Provider, {
|
|
898
899
|
value: appContextValue,
|
|
899
|
-
children: /* @__PURE__ */ jsx(StdinContext.Provider, {
|
|
900
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StdinContext.Provider, {
|
|
900
901
|
value: stdinContextValue,
|
|
901
|
-
children: /* @__PURE__ */ jsx(StdoutContext.Provider, {
|
|
902
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StdoutContext.Provider, {
|
|
902
903
|
value: stdoutContextValue,
|
|
903
|
-
children: /* @__PURE__ */ jsx(StderrContext.Provider, {
|
|
904
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StderrContext.Provider, {
|
|
904
905
|
value: stderrContextValue,
|
|
905
|
-
children: /* @__PURE__ */ jsx(FocusContext.Provider, {
|
|
906
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusContext.Provider, {
|
|
906
907
|
value: focusContextValue,
|
|
907
|
-
children: /* @__PURE__ */ jsx(animationContext.Provider, {
|
|
908
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(animationContext.Provider, {
|
|
908
909
|
value: animationContextValue,
|
|
909
|
-
children: /* @__PURE__ */ jsx(CursorContext.Provider, {
|
|
910
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CursorContext.Provider, {
|
|
910
911
|
value: cursorContextValue,
|
|
911
|
-
children: /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
912
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
|
|
912
913
|
onError: handleExit,
|
|
913
914
|
children
|
|
914
915
|
})
|
|
@@ -924,7 +925,7 @@ App.displayName = "InternalApp";
|
|
|
924
925
|
//#endregion
|
|
925
926
|
//#region src/components/TerminalOscContext.ts
|
|
926
927
|
const noop$1 = () => {};
|
|
927
|
-
const TerminalOscContext = createContext({
|
|
928
|
+
const TerminalOscContext = (0, import_react.createContext)({
|
|
928
929
|
publishProgress: noop$1,
|
|
929
930
|
copyToClipboard: noop$1,
|
|
930
931
|
publishTitle: noop$1,
|
|
@@ -1799,7 +1800,7 @@ const createInk = (options) => {
|
|
|
1799
1800
|
let nextRenderCommit;
|
|
1800
1801
|
let pauseInput;
|
|
1801
1802
|
let resumeInput;
|
|
1802
|
-
const rootTag = isConcurrent ? ConcurrentRoot : LegacyRoot;
|
|
1803
|
+
const rootTag = isConcurrent ? import_constants.ConcurrentRoot : import_constants.LegacyRoot;
|
|
1803
1804
|
const container = reconciler.createContainer(rootNode, rootTag, null, false, null, "id", () => {}, () => {}, () => {}, () => {});
|
|
1804
1805
|
const unsubscribeExit = signalExit(unmount, { alwaysLast: false });
|
|
1805
1806
|
setAlternateScreen(Boolean(options.alternateScreen));
|
|
@@ -1975,11 +1976,11 @@ const createInk = (options) => {
|
|
|
1975
1976
|
renderInteractiveFrame(output, outputHeight, hasStaticOutput ? staticOutput : "", screen, false);
|
|
1976
1977
|
}
|
|
1977
1978
|
function render(node) {
|
|
1978
|
-
const tree = /* @__PURE__ */ jsx(accessibilityContext.Provider, {
|
|
1979
|
+
const tree = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(accessibilityContext.Provider, {
|
|
1979
1980
|
value: { isScreenReaderEnabled },
|
|
1980
|
-
children: /* @__PURE__ */ jsx(TerminalOscContext.Provider, {
|
|
1981
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TerminalOscContext.Provider, {
|
|
1981
1982
|
value: terminalOsc,
|
|
1982
|
-
children: /* @__PURE__ */ jsx(App, {
|
|
1983
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
1983
1984
|
stdin: options.stdin,
|
|
1984
1985
|
stdout: options.stdout,
|
|
1985
1986
|
stderr: options.stderr,
|
|
@@ -2451,7 +2452,7 @@ const renderToString = (node, options) => {
|
|
|
2451
2452
|
if (staticOutput && staticOutput !== "\n") capturedStaticOutput += staticOutput;
|
|
2452
2453
|
};
|
|
2453
2454
|
let uncaughtError;
|
|
2454
|
-
const container = reconciler.createContainer(rootNode, LegacyRoot, null, false, null, "render-to-string", (error) => {
|
|
2455
|
+
const container = reconciler.createContainer(rootNode, import_constants.LegacyRoot, null, false, null, "render-to-string", (error) => {
|
|
2455
2456
|
uncaughtError ??= error;
|
|
2456
2457
|
}, () => {}, () => {}, () => {});
|
|
2457
2458
|
reconciler.updateContainerSync(node, container, null, () => {});
|
|
@@ -2476,12 +2477,12 @@ const renderToString = (node, options) => {
|
|
|
2476
2477
|
* Ordinary `Text` continues to strip terminal control sequences.
|
|
2477
2478
|
*/
|
|
2478
2479
|
function AnsiText({ children, wrap = "wrap", "aria-label": ariaLabel, "aria-hidden": ariaHidden = false }) {
|
|
2479
|
-
const { isScreenReaderEnabled } = useContext(accessibilityContext);
|
|
2480
|
+
const { isScreenReaderEnabled } = (0, import_react.useContext)(accessibilityContext);
|
|
2480
2481
|
if (isScreenReaderEnabled) {
|
|
2481
2482
|
if (ariaHidden) return null;
|
|
2482
|
-
return /* @__PURE__ */ jsx(Text, { children: ariaLabel ?? stripAnsi(children) });
|
|
2483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: ariaLabel ?? stripAnsi(children) });
|
|
2483
2484
|
}
|
|
2484
|
-
return /* @__PURE__ */ jsx("ink-text", {
|
|
2485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ink-text", {
|
|
2485
2486
|
style: {
|
|
2486
2487
|
flexGrow: 0,
|
|
2487
2488
|
flexShrink: 1,
|
|
@@ -2504,22 +2505,22 @@ For example, [Tap](https://github.com/tapjs/node-tap) uses `<Static>` to display
|
|
|
2504
2505
|
*/
|
|
2505
2506
|
function Static(props) {
|
|
2506
2507
|
const { items, children: render, style: customStyle } = props;
|
|
2507
|
-
const [index, setIndex] = useState(0);
|
|
2508
|
-
const itemsToRender = useMemo(() => {
|
|
2508
|
+
const [index, setIndex] = (0, import_react.useState)(0);
|
|
2509
|
+
const itemsToRender = (0, import_react.useMemo)(() => {
|
|
2509
2510
|
return items.slice(index);
|
|
2510
2511
|
}, [items, index]);
|
|
2511
|
-
useLayoutEffect(() => {
|
|
2512
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
2512
2513
|
setIndex(items.length);
|
|
2513
2514
|
}, [items.length]);
|
|
2514
2515
|
const children = itemsToRender.map((item, itemIndex) => {
|
|
2515
2516
|
return render(item, index + itemIndex);
|
|
2516
2517
|
});
|
|
2517
|
-
const style = useMemo(() => ({
|
|
2518
|
+
const style = (0, import_react.useMemo)(() => ({
|
|
2518
2519
|
position: "absolute",
|
|
2519
2520
|
flexDirection: "column",
|
|
2520
2521
|
...customStyle
|
|
2521
2522
|
}), [customStyle]);
|
|
2522
|
-
return /* @__PURE__ */ jsx("ink-box", {
|
|
2523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ink-box", {
|
|
2523
2524
|
internal_static: true,
|
|
2524
2525
|
style,
|
|
2525
2526
|
children
|
|
@@ -2532,9 +2533,9 @@ function Static(props) {
|
|
|
2532
2533
|
Transform a string representation of React components before they're written to output. For example, you might want to apply a gradient to text, add a clickable link, or create some text effects. These use cases can't accept React nodes as input; they expect a string. That's what the <Transform> component does: it gives you an output string of its child components and lets you transform it in any way.
|
|
2533
2534
|
*/
|
|
2534
2535
|
function Transform({ children, transform, accessibilityLabel }) {
|
|
2535
|
-
const { isScreenReaderEnabled } = useContext(accessibilityContext);
|
|
2536
|
+
const { isScreenReaderEnabled } = (0, import_react.useContext)(accessibilityContext);
|
|
2536
2537
|
if (children === void 0 || children === null) return null;
|
|
2537
|
-
return /* @__PURE__ */ jsx("ink-text", {
|
|
2538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ink-text", {
|
|
2538
2539
|
style: {
|
|
2539
2540
|
flexGrow: 0,
|
|
2540
2541
|
flexShrink: 1,
|
|
@@ -2549,9 +2550,10 @@ function Transform({ children, transform, accessibilityLabel }) {
|
|
|
2549
2550
|
/**
|
|
2550
2551
|
A React hook that returns the stdout stream where Ink renders your app.
|
|
2551
2552
|
*/
|
|
2552
|
-
const useStdout = () => useContext(StdoutContext);
|
|
2553
|
+
const useStdout = () => (0, import_react.useContext)(StdoutContext);
|
|
2553
2554
|
//#endregion
|
|
2554
2555
|
//#region src/components/Hyperlink.tsx
|
|
2556
|
+
/** @jsxImportSource react */
|
|
2555
2557
|
/**
|
|
2556
2558
|
A clickable OSC 8 hyperlink — the counterpart to the router's `<Link>`, which
|
|
2557
2559
|
navigates between screens. On terminals without hyperlink support it falls
|
|
@@ -2563,9 +2565,9 @@ back to `text (url)`.
|
|
|
2563
2565
|
*/
|
|
2564
2566
|
function Hyperlink({ url, fallback = true, children, ...textProps }) {
|
|
2565
2567
|
const { stdout } = useStdout();
|
|
2566
|
-
if (!detectHyperlinkSupport(stdout)) return /* @__PURE__ */ jsxs(Text, {
|
|
2568
|
+
if (!detectHyperlinkSupport(stdout)) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
2567
2569
|
...textProps,
|
|
2568
|
-
children: [children, fallback ? /* @__PURE__ */ jsxs(Text, {
|
|
2570
|
+
children: [children, fallback ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
2569
2571
|
dimColor: true,
|
|
2570
2572
|
children: [
|
|
2571
2573
|
" (",
|
|
@@ -2574,9 +2576,9 @@ function Hyperlink({ url, fallback = true, children, ...textProps }) {
|
|
|
2574
2576
|
]
|
|
2575
2577
|
}) : null]
|
|
2576
2578
|
});
|
|
2577
|
-
return /* @__PURE__ */ jsx(Transform, {
|
|
2579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Transform, {
|
|
2578
2580
|
transform: (text) => link(text, url),
|
|
2579
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
2581
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
2580
2582
|
...textProps,
|
|
2581
2583
|
children
|
|
2582
2584
|
})
|
|
@@ -2588,7 +2590,7 @@ function Hyperlink({ url, fallback = true, children, ...textProps }) {
|
|
|
2588
2590
|
Adds one or more newline (`\n`) characters. Must be used within `<Text>` components.
|
|
2589
2591
|
*/
|
|
2590
2592
|
function Newline({ count = 1 }) {
|
|
2591
|
-
return /* @__PURE__ */ jsx("ink-text", { children: "\n".repeat(count) });
|
|
2593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ink-text", { children: "\n".repeat(count) });
|
|
2592
2594
|
}
|
|
2593
2595
|
//#endregion
|
|
2594
2596
|
//#region src/components/Spacer.tsx
|
|
@@ -2599,7 +2601,7 @@ A flexible space that expands along the major axis of its containing layout.
|
|
|
2599
2601
|
It's useful as a shortcut for filling all the available space between elements.
|
|
2600
2602
|
*/
|
|
2601
2603
|
function Spacer() {
|
|
2602
|
-
return /* @__PURE__ */ jsx(Box, { flexGrow: 1 });
|
|
2604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { flexGrow: 1 });
|
|
2603
2605
|
}
|
|
2604
2606
|
//#endregion
|
|
2605
2607
|
//#region src/virtual-scroll.ts
|
|
@@ -2687,18 +2689,18 @@ return (
|
|
|
2687
2689
|
```
|
|
2688
2690
|
*/
|
|
2689
2691
|
const useVirtualScroll = (options) => {
|
|
2690
|
-
const [position, setPosition] = useState(0);
|
|
2692
|
+
const [position, setPosition] = (0, import_react.useState)(0);
|
|
2691
2693
|
const window = virtualScrollWindow({
|
|
2692
2694
|
...options,
|
|
2693
2695
|
scrollTop: position
|
|
2694
2696
|
});
|
|
2695
|
-
useEffect(() => {
|
|
2697
|
+
(0, import_react.useEffect)(() => {
|
|
2696
2698
|
if (window.scrollTop !== position) setPosition(window.scrollTop);
|
|
2697
2699
|
}, [window.scrollTop, position]);
|
|
2698
|
-
const scrollTo = useCallback((top) => {
|
|
2700
|
+
const scrollTo = (0, import_react.useCallback)((top) => {
|
|
2699
2701
|
setPosition(top);
|
|
2700
2702
|
}, []);
|
|
2701
|
-
const scrollBy = useCallback((delta) => {
|
|
2703
|
+
const scrollBy = (0, import_react.useCallback)((delta) => {
|
|
2702
2704
|
setPosition((current) => current + delta);
|
|
2703
2705
|
}, []);
|
|
2704
2706
|
return {
|
|
@@ -2724,16 +2726,16 @@ Until the first layout pass has measured the viewport, every item is rendered
|
|
|
2724
2726
|
inside the clipped box so the first frame already looks right.
|
|
2725
2727
|
*/
|
|
2726
2728
|
function VirtualList({ items, itemHeight, renderItem, getKey, focusedIndex, height }) {
|
|
2727
|
-
const ref = useRef(null);
|
|
2728
|
-
const [measured, setMeasured] = useState();
|
|
2729
|
+
const ref = (0, import_react.useRef)(null);
|
|
2730
|
+
const [measured, setMeasured] = (0, import_react.useState)();
|
|
2729
2731
|
const measure = () => {
|
|
2730
2732
|
const next = ref.current?.yogaNode?.getComputedHeight();
|
|
2731
2733
|
if (next !== void 0) setMeasured((previous) => previous === next ? previous : next);
|
|
2732
2734
|
};
|
|
2733
|
-
useLayoutEffect(() => {
|
|
2735
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
2734
2736
|
if (height === void 0) measure();
|
|
2735
2737
|
});
|
|
2736
|
-
useEffect(() => {
|
|
2738
|
+
(0, import_react.useEffect)(() => {
|
|
2737
2739
|
if (height !== void 0) return;
|
|
2738
2740
|
const root = rootOf(ref.current);
|
|
2739
2741
|
return root ? addLayoutListener(root, measure) : void 0;
|
|
@@ -2749,7 +2751,7 @@ function VirtualList({ items, itemHeight, renderItem, getKey, focusedIndex, heig
|
|
|
2749
2751
|
const start = windowed ? window.start : 0;
|
|
2750
2752
|
const end = windowed ? window.end : items.length;
|
|
2751
2753
|
const offset = windowed ? window.offset : 0;
|
|
2752
|
-
return /* @__PURE__ */ jsx(Box, {
|
|
2754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
2753
2755
|
ref,
|
|
2754
2756
|
flexDirection: "column",
|
|
2755
2757
|
overflowY: "hidden",
|
|
@@ -2761,13 +2763,13 @@ function VirtualList({ items, itemHeight, renderItem, getKey, focusedIndex, heig
|
|
|
2761
2763
|
height,
|
|
2762
2764
|
flexShrink: 0
|
|
2763
2765
|
},
|
|
2764
|
-
children: /* @__PURE__ */ jsx(Box, {
|
|
2766
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
2765
2767
|
flexDirection: "column",
|
|
2766
2768
|
flexShrink: 0,
|
|
2767
2769
|
marginTop: offset,
|
|
2768
2770
|
children: items.slice(start, end).map((item, sliceIndex) => {
|
|
2769
2771
|
const index = start + sliceIndex;
|
|
2770
|
-
return /* @__PURE__ */ jsx(Box, {
|
|
2772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
2771
2773
|
flexDirection: "column",
|
|
2772
2774
|
flexShrink: 0,
|
|
2773
2775
|
children: renderItem(item, index)
|
|
@@ -2792,8 +2794,8 @@ const useCapabilities = () => {
|
|
|
2792
2794
|
const { stdout } = useStdout();
|
|
2793
2795
|
const { stdin } = useStdinContext();
|
|
2794
2796
|
const store = getCapabilities(stdin, stdout);
|
|
2795
|
-
const capabilities = useSyncExternalStore(store.subscribe, () => store.current);
|
|
2796
|
-
useEffect(() => {
|
|
2797
|
+
const capabilities = (0, import_react.useSyncExternalStore)(store.subscribe, () => store.current);
|
|
2798
|
+
(0, import_react.useEffect)(() => {
|
|
2797
2799
|
store.query();
|
|
2798
2800
|
}, [store]);
|
|
2799
2801
|
return capabilities;
|
|
@@ -2820,8 +2822,8 @@ const useCapabilitiesChange = (onChange) => {
|
|
|
2820
2822
|
const { stdout } = useStdout();
|
|
2821
2823
|
const { stdin } = useStdinContext();
|
|
2822
2824
|
const store = getCapabilities(stdin, stdout);
|
|
2823
|
-
const handleChange = useEffectEvent(onChange);
|
|
2824
|
-
useEffect(() => {
|
|
2825
|
+
const handleChange = (0, import_react.useEffectEvent)(onChange);
|
|
2826
|
+
(0, import_react.useEffect)(() => {
|
|
2825
2827
|
let previous = store.current;
|
|
2826
2828
|
const unsubscribe = store.subscribe((next) => {
|
|
2827
2829
|
const before = previous;
|
|
@@ -2861,7 +2863,7 @@ return …
|
|
|
2861
2863
|
*/
|
|
2862
2864
|
const usePaste = (handler, options = {}) => {
|
|
2863
2865
|
const { setRawMode, setBracketedPasteMode, internal_eventEmitter } = useStdinContext();
|
|
2864
|
-
useEffect(() => {
|
|
2866
|
+
(0, import_react.useEffect)(() => {
|
|
2865
2867
|
if (options.isActive === false) return;
|
|
2866
2868
|
setRawMode(true);
|
|
2867
2869
|
setBracketedPasteMode(true);
|
|
@@ -2874,12 +2876,12 @@ const usePaste = (handler, options = {}) => {
|
|
|
2874
2876
|
setRawMode,
|
|
2875
2877
|
setBracketedPasteMode
|
|
2876
2878
|
]);
|
|
2877
|
-
const handlePaste = useEffectEvent((text) => {
|
|
2879
|
+
const handlePaste = (0, import_react.useEffectEvent)((text) => {
|
|
2878
2880
|
reconciler.discreteUpdates(() => {
|
|
2879
2881
|
handler(text);
|
|
2880
2882
|
});
|
|
2881
2883
|
});
|
|
2882
|
-
useEffect(() => {
|
|
2884
|
+
(0, import_react.useEffect)(() => {
|
|
2883
2885
|
if (options.isActive === false) return;
|
|
2884
2886
|
internal_eventEmitter.on("paste", handlePaste);
|
|
2885
2887
|
return () => {
|
|
@@ -2892,20 +2894,20 @@ const usePaste = (handler, options = {}) => {
|
|
|
2892
2894
|
/**
|
|
2893
2895
|
A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
|
|
2894
2896
|
*/
|
|
2895
|
-
const useApp = () => useContext(AppContext);
|
|
2897
|
+
const useApp = () => (0, import_react.useContext)(AppContext);
|
|
2896
2898
|
//#endregion
|
|
2897
2899
|
//#region src/hooks/use-stderr.ts
|
|
2898
2900
|
/**
|
|
2899
2901
|
A React hook that returns the stderr stream.
|
|
2900
2902
|
*/
|
|
2901
|
-
const useStderr = () => useContext(StderrContext);
|
|
2903
|
+
const useStderr = () => (0, import_react.useContext)(StderrContext);
|
|
2902
2904
|
//#endregion
|
|
2903
2905
|
//#region src/hooks/use-focus-manager.ts
|
|
2904
2906
|
/**
|
|
2905
2907
|
A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
|
|
2906
2908
|
*/
|
|
2907
2909
|
const useFocusManager = () => {
|
|
2908
|
-
const focusContext = useContext(FocusContext);
|
|
2910
|
+
const focusContext = (0, import_react.useContext)(FocusContext);
|
|
2909
2911
|
return {
|
|
2910
2912
|
enableFocus: focusContext.enableFocus,
|
|
2911
2913
|
disableFocus: focusContext.disableFocus,
|
|
@@ -2922,7 +2924,7 @@ A React hook that returns whether a screen reader is enabled.
|
|
|
2922
2924
|
This is useful when you want to render different output for screen readers.
|
|
2923
2925
|
*/
|
|
2924
2926
|
const useIsScreenReaderEnabled = () => {
|
|
2925
|
-
const { isScreenReaderEnabled } = useContext(accessibilityContext);
|
|
2927
|
+
const { isScreenReaderEnabled } = (0, import_react.useContext)(accessibilityContext);
|
|
2926
2928
|
return isScreenReaderEnabled;
|
|
2927
2929
|
};
|
|
2928
2930
|
//#endregion
|
|
@@ -2935,12 +2937,12 @@ Setting a cursor position makes the cursor visible at the specified coordinates
|
|
|
2935
2937
|
Pass `undefined` to hide the cursor.
|
|
2936
2938
|
*/
|
|
2937
2939
|
const useCursor = () => {
|
|
2938
|
-
const context = useContext(CursorContext);
|
|
2939
|
-
const positionRef = useRef(void 0);
|
|
2940
|
-
const setCursorPosition = useCallback((position) => {
|
|
2940
|
+
const context = (0, import_react.useContext)(CursorContext);
|
|
2941
|
+
const positionRef = (0, import_react.useRef)(void 0);
|
|
2942
|
+
const setCursorPosition = (0, import_react.useCallback)((position) => {
|
|
2941
2943
|
positionRef.current = position;
|
|
2942
2944
|
}, []);
|
|
2943
|
-
useInsertionEffect(() => {
|
|
2945
|
+
(0, import_react.useInsertionEffect)(() => {
|
|
2944
2946
|
context.setCursorPosition(positionRef.current);
|
|
2945
2947
|
return () => {
|
|
2946
2948
|
context.setCursorPosition(void 0);
|
|
@@ -2975,22 +2977,22 @@ return <Text>{characters[frame % characters.length]}</Text>;
|
|
|
2975
2977
|
function useAnimation(options) {
|
|
2976
2978
|
const { interval = defaultAnimationInterval, isActive = true } = options ?? {};
|
|
2977
2979
|
const safeInterval = normalizeAnimationInterval(interval);
|
|
2978
|
-
const { subscribe, renderThrottleMs } = useContext(animationContext);
|
|
2979
|
-
const [resetKey, setResetKey] = useState(0);
|
|
2980
|
-
const [animState, setAnimState] = useState(zeroAnimState);
|
|
2981
|
-
const nextRenderTimeRef = useRef(0);
|
|
2982
|
-
const lastRenderTimeRef = useRef(0);
|
|
2983
|
-
const previousOptionsRef = useRef({
|
|
2980
|
+
const { subscribe, renderThrottleMs } = (0, import_react.useContext)(animationContext);
|
|
2981
|
+
const [resetKey, setResetKey] = (0, import_react.useState)(0);
|
|
2982
|
+
const [animState, setAnimState] = (0, import_react.useState)(zeroAnimState);
|
|
2983
|
+
const nextRenderTimeRef = (0, import_react.useRef)(0);
|
|
2984
|
+
const lastRenderTimeRef = (0, import_react.useRef)(0);
|
|
2985
|
+
const previousOptionsRef = (0, import_react.useRef)({
|
|
2984
2986
|
isActive,
|
|
2985
2987
|
safeInterval,
|
|
2986
2988
|
resetKey
|
|
2987
2989
|
});
|
|
2988
2990
|
const previousOptions = previousOptionsRef.current;
|
|
2989
2991
|
const shouldReset = isActive && (safeInterval !== previousOptions.safeInterval || !previousOptions.isActive || resetKey !== previousOptions.resetKey);
|
|
2990
|
-
const reset = useCallback(() => {
|
|
2992
|
+
const reset = (0, import_react.useCallback)(() => {
|
|
2991
2993
|
setResetKey((k) => k + 1);
|
|
2992
2994
|
}, []);
|
|
2993
|
-
useLayoutEffect(() => {
|
|
2995
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
2994
2996
|
if (!isActive) return;
|
|
2995
2997
|
setAnimState(zeroAnimState);
|
|
2996
2998
|
let startTime = 0;
|
|
@@ -3017,7 +3019,7 @@ function useAnimation(options) {
|
|
|
3017
3019
|
renderThrottleMs,
|
|
3018
3020
|
resetKey
|
|
3019
3021
|
]);
|
|
3020
|
-
useLayoutEffect(() => {
|
|
3022
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
3021
3023
|
previousOptionsRef.current = {
|
|
3022
3024
|
isActive,
|
|
3023
3025
|
safeInterval,
|
|
@@ -3044,48 +3046,48 @@ function normalizeAnimationInterval(interval) {
|
|
|
3044
3046
|
//#endregion
|
|
3045
3047
|
//#region src/hooks/use-terminal-osc.ts
|
|
3046
3048
|
const useProgress = ({ state, value }) => {
|
|
3047
|
-
const terminal = useContext(TerminalOscContext);
|
|
3048
|
-
const owner = useRef(void 0);
|
|
3049
|
+
const terminal = (0, import_react.useContext)(TerminalOscContext);
|
|
3050
|
+
const owner = (0, import_react.useRef)(void 0);
|
|
3049
3051
|
owner.current ??= Symbol("terminal-progress");
|
|
3050
|
-
useEffect(() => {
|
|
3052
|
+
(0, import_react.useEffect)(() => {
|
|
3051
3053
|
terminal.publishProgress(owner.current, state, value);
|
|
3052
3054
|
}, [
|
|
3053
3055
|
state,
|
|
3054
3056
|
terminal,
|
|
3055
3057
|
value
|
|
3056
3058
|
]);
|
|
3057
|
-
useEffect(() => {
|
|
3059
|
+
(0, import_react.useEffect)(() => {
|
|
3058
3060
|
return () => {
|
|
3059
3061
|
terminal.publishProgress(owner.current, "inactive");
|
|
3060
3062
|
};
|
|
3061
3063
|
}, [terminal]);
|
|
3062
3064
|
};
|
|
3063
3065
|
const useClipboard = () => {
|
|
3064
|
-
const terminal = useContext(TerminalOscContext);
|
|
3065
|
-
return useCallback((text, selection) => terminal.copyToClipboard(text, selection), [terminal]);
|
|
3066
|
+
const terminal = (0, import_react.useContext)(TerminalOscContext);
|
|
3067
|
+
return (0, import_react.useCallback)((text, selection) => terminal.copyToClipboard(text, selection), [terminal]);
|
|
3066
3068
|
};
|
|
3067
3069
|
const useTitle = (title) => {
|
|
3068
|
-
const terminal = useContext(TerminalOscContext);
|
|
3069
|
-
const owner = useRef(void 0);
|
|
3070
|
+
const terminal = (0, import_react.useContext)(TerminalOscContext);
|
|
3071
|
+
const owner = (0, import_react.useRef)(void 0);
|
|
3070
3072
|
owner.current ??= Symbol("terminal-title");
|
|
3071
|
-
useEffect(() => {
|
|
3073
|
+
(0, import_react.useEffect)(() => {
|
|
3072
3074
|
terminal.publishTitle(owner.current, title);
|
|
3073
3075
|
}, [terminal, title]);
|
|
3074
|
-
useEffect(() => () => terminal.publishTitle(owner.current, void 0), [terminal]);
|
|
3076
|
+
(0, import_react.useEffect)(() => () => terminal.publishTitle(owner.current, void 0), [terminal]);
|
|
3075
3077
|
};
|
|
3076
3078
|
const useWorkingDirectory = (directory) => {
|
|
3077
|
-
const terminal = useContext(TerminalOscContext);
|
|
3078
|
-
useEffect(() => {
|
|
3079
|
+
const terminal = (0, import_react.useContext)(TerminalOscContext);
|
|
3080
|
+
(0, import_react.useEffect)(() => {
|
|
3079
3081
|
terminal.setWorkingDirectory(directory);
|
|
3080
3082
|
}, [directory, terminal]);
|
|
3081
3083
|
};
|
|
3082
3084
|
const useNotification = () => {
|
|
3083
|
-
const terminal = useContext(TerminalOscContext);
|
|
3084
|
-
return useCallback((title) => terminal.notify(title), [terminal]);
|
|
3085
|
+
const terminal = (0, import_react.useContext)(TerminalOscContext);
|
|
3086
|
+
return (0, import_react.useCallback)((title) => terminal.notify(title), [terminal]);
|
|
3085
3087
|
};
|
|
3086
3088
|
const usePointerShape = (shape) => {
|
|
3087
|
-
const terminal = useContext(TerminalOscContext);
|
|
3088
|
-
useEffect(() => {
|
|
3089
|
+
const terminal = (0, import_react.useContext)(TerminalOscContext);
|
|
3090
|
+
(0, import_react.useEffect)(() => {
|
|
3089
3091
|
terminal.setPointerShape(shape);
|
|
3090
3092
|
}, [shape, terminal]);
|
|
3091
3093
|
};
|
|
@@ -3104,8 +3106,8 @@ const useWindowSize = () => {
|
|
|
3104
3106
|
const { stdin } = useStdinContext();
|
|
3105
3107
|
const { stdout } = useStdout();
|
|
3106
3108
|
const store = getCapabilities(stdin, stdout);
|
|
3107
|
-
const { size } = useSyncExternalStore(store.subscribe, () => store.current);
|
|
3108
|
-
return useMemo(() => ({
|
|
3109
|
+
const { size } = (0, import_react.useSyncExternalStore)(store.subscribe, () => store.current);
|
|
3110
|
+
return (0, import_react.useMemo)(() => ({
|
|
3109
3111
|
columns: size.columns,
|
|
3110
3112
|
rows: size.rows
|
|
3111
3113
|
}), [size.columns, size.rows]);
|
|
@@ -3150,22 +3152,22 @@ return (
|
|
|
3150
3152
|
```
|
|
3151
3153
|
*/
|
|
3152
3154
|
const useBoxMetrics = (ref) => {
|
|
3153
|
-
const [metrics, setMetrics] = useState(emptyMetrics);
|
|
3154
|
-
const [hasMeasured, setHasMeasured] = useState(false);
|
|
3155
|
-
const updateMetrics = useCallback(() => {
|
|
3155
|
+
const [metrics, setMetrics] = (0, import_react.useState)(emptyMetrics);
|
|
3156
|
+
const [hasMeasured, setHasMeasured] = (0, import_react.useState)(false);
|
|
3157
|
+
const updateMetrics = (0, import_react.useCallback)(() => {
|
|
3156
3158
|
const layout = ref.current?.yogaNode?.getComputedLayout() ?? emptyMetrics;
|
|
3157
3159
|
setMetrics((previousMetrics) => {
|
|
3158
3160
|
return previousMetrics.width !== layout.width || previousMetrics.height !== layout.height || previousMetrics.left !== layout.left || previousMetrics.top !== layout.top ? layout : previousMetrics;
|
|
3159
3161
|
});
|
|
3160
3162
|
setHasMeasured(Boolean(ref.current));
|
|
3161
3163
|
}, [ref]);
|
|
3162
|
-
useEffect(updateMetrics);
|
|
3163
|
-
useEffect(() => {
|
|
3164
|
+
(0, import_react.useEffect)(updateMetrics);
|
|
3165
|
+
(0, import_react.useEffect)(() => {
|
|
3164
3166
|
const rootNode = findRootNode(ref.current);
|
|
3165
3167
|
if (!rootNode) return;
|
|
3166
3168
|
return addLayoutListener(rootNode, updateMetrics);
|
|
3167
3169
|
});
|
|
3168
|
-
return useMemo(() => ({
|
|
3170
|
+
return (0, import_react.useMemo)(() => ({
|
|
3169
3171
|
...metrics,
|
|
3170
3172
|
hasMeasured
|
|
3171
3173
|
}), [metrics, hasMeasured]);
|