@alchemy.run/sigil 0.0.0-alpha.7 → 0.0.0-alpha.8

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/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { C as bsu, S as ansiEscapes, V as esu, W as link, _ as CSI } from "./sgr
2
2
  import { h as tokenizeAnsi, p as graphemes } from "./tokenize-AjqbvtiT.js";
3
3
  import { t as stringWidth } from "./string-width-CijQwpIk.js";
4
4
  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-DSV01Ulb.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-BNG0xsb7.js";
6
6
  import { a as isTty, i as isSigilDev, o as isWindows, r as isScreenReader, t as isInCi } from "./env-YVw64yZS.js";
7
7
  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
8
  import { u as cliCursor } from "./osc-BFKKSqpg.js";
@@ -424,6 +424,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
424
424
  const internal_eventEmitter = useRef(new EventEmitter());
425
425
  internal_eventEmitter.current.setMaxListeners(Infinity);
426
426
  const readableListenerRef = useRef(void 0);
427
+ const isMountedRef = useRef(true);
427
428
  const pendingInputFlushRef = useRef(void 0);
428
429
  const pendingInputFlushDelayMilliseconds = 20;
429
430
  const clearPendingInputFlush = useCallback(() => {
@@ -614,7 +615,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
614
615
  try {
615
616
  return await (refresh ? refreshTerminalQuery(stdin, stdout) : ensureTerminalQuery(stdin, stdout));
616
617
  } finally {
617
- attachReadableListener();
618
+ if (isMountedRef.current) attachReadableListener();
618
619
  handleSetRawMode(false);
619
620
  }
620
621
  }, [
@@ -817,7 +818,9 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
817
818
  }));
818
819
  }, []);
819
820
  useEffect(() => {
821
+ isMountedRef.current = true;
820
822
  return () => {
823
+ isMountedRef.current = false;
821
824
  const canWriteToStdout = !stdout.destroyed && !stdout.writableEnded;
822
825
  if (interactive && canWriteToStdout) cliCursor.show(stdout);
823
826
  if (isRawModeSupported && (rawModeEnabledCount.current > 0 || pendingDisableRawModeRef.current)) disableRawMode();
package/dist/router.js CHANGED
@@ -1,4 +1,4 @@
1
- import { f as Text, n as useInput, t as useFocus } from "./use-focus-DSV01Ulb.js";
1
+ import { f as Text, n as useInput, t as useFocus } from "./use-focus-BNG0xsb7.js";
2
2
  import { Children, Fragment, createContext, isValidElement, startTransition, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
4
4
  //#region src/router/history.ts
@@ -564,7 +564,7 @@ const detectKittySupport = (stdin, stdout, onSupported) => {
564
564
  //#endregion
565
565
  //#region package.json
566
566
  var name = "@alchemy.run/sigil";
567
- var version = "0.0.0-alpha.7";
567
+ var version = "0.0.0-alpha.8";
568
568
  //#endregion
569
569
  //#region src/reconciler.ts
570
570
  if (isSigilDev) await import("./devtools-DbthxoD1.js").catch(() => {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy.run/sigil",
3
- "version": "0.0.0-alpha.7",
3
+ "version": "0.0.0-alpha.8",
4
4
  "description": "React for CLIs. A self-contained fork of Ink with an integrated TypeScript Yoga layout engine.",
5
5
  "keywords": [
6
6
  "cli",
@@ -109,6 +109,7 @@ export function App({
109
109
  internal_eventEmitter.current.setMaxListeners(Infinity);
110
110
  // Store the currently attached readable listener to avoid stale closure issues
111
111
  const readableListenerRef = useRef<(() => void) | undefined>(undefined);
112
+ const isMountedRef = useRef(true);
112
113
  const pendingInputFlushRef = useRef<NodeJS.Timeout | undefined>(undefined);
113
114
  // Small delay to let chunked escape sequences complete before flushing as literal input.
114
115
  const pendingInputFlushDelayMilliseconds = 20;
@@ -417,7 +418,12 @@ export function App({
417
418
  ? refreshTerminalQuery(stdin, stdout)
418
419
  : ensureTerminalQuery(stdin, stdout));
419
420
  } finally {
420
- attachReadableListener();
421
+ // A slow terminal response may arrive after this renderer has been
422
+ // replaced. Do not leave its reader attached to consume input meant
423
+ // for a subsequent renderer.
424
+ if (isMountedRef.current) {
425
+ attachReadableListener();
426
+ }
421
427
  handleSetRawMode(false);
422
428
  }
423
429
  },
@@ -741,7 +747,10 @@ export function App({
741
747
 
742
748
  // Handle cursor visibility, raw mode, and bracketed paste mode cleanup on unmount
743
749
  useEffect(() => {
750
+ isMountedRef.current = true;
751
+
744
752
  return () => {
753
+ isMountedRef.current = false;
745
754
  const canWriteToStdout = !stdout.destroyed && !stdout.writableEnded;
746
755
 
747
756
  if (interactive && canWriteToStdout) {