green-screen-react 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1069,7 +1069,9 @@ function GreenScreenTerminal({
1069
1069
  autoSignedIn,
1070
1070
  autoFocusDisabled = false,
1071
1071
  bootLoader,
1072
+ bootLoaderReady,
1072
1073
  headerRight,
1074
+ statusActions,
1073
1075
  overlay,
1074
1076
  onNotification,
1075
1077
  onScreenChange,
@@ -1118,13 +1120,14 @@ function GreenScreenTerminal({
1118
1120
  const sendText = useCallback3(async (text) => _sendText(text), [_sendText]);
1119
1121
  const sendKey = useCallback3(async (key) => _sendKey(key), [_sendKey]);
1120
1122
  const [optimisticEdits, setOptimisticEdits] = useState5([]);
1121
- const prevScreenSigForEdits = useRef4(void 0);
1123
+ const prevScreenContentForEdits = useRef4(void 0);
1122
1124
  useEffect4(() => {
1123
- if (rawScreenData?.screen_signature && rawScreenData.screen_signature !== prevScreenSigForEdits.current) {
1124
- prevScreenSigForEdits.current = rawScreenData.screen_signature;
1125
+ const content = rawScreenData?.content;
1126
+ if (content && content !== prevScreenContentForEdits.current) {
1127
+ prevScreenContentForEdits.current = content;
1125
1128
  setOptimisticEdits([]);
1126
1129
  }
1127
- }, [rawScreenData?.screen_signature]);
1130
+ }, [rawScreenData?.content]);
1128
1131
  const [inputText, setInputText] = useState5("");
1129
1132
  const [isFocused, setIsFocused] = useState5(false);
1130
1133
  const [showSignInHint, setShowSignInHint] = useState5(false);
@@ -1222,13 +1225,15 @@ function GreenScreenTerminal({
1222
1225
  const [showBootLoader, setShowBootLoader] = useState5(bootLoader !== false);
1223
1226
  const [bootFadingOut, setBootFadingOut] = useState5(false);
1224
1227
  useEffect4(() => {
1225
- if (screenData?.content && showBootLoader) {
1228
+ if (!showBootLoader) return;
1229
+ const shouldDismiss = bootLoaderReady !== void 0 ? bootLoaderReady : !!screenData?.content;
1230
+ if (shouldDismiss) {
1226
1231
  setBootFadingOut(true);
1227
1232
  setShowBootLoader(false);
1228
1233
  const timer = setTimeout(() => setBootFadingOut(false), 400);
1229
1234
  return () => clearTimeout(timer);
1230
1235
  }
1231
- }, [screenData?.content, showBootLoader]);
1236
+ }, [screenData?.content, showBootLoader, bootLoaderReady]);
1232
1237
  const FOCUS_STORAGE_KEY = "gs-terminal-focused";
1233
1238
  useEffect4(() => {
1234
1239
  if (!autoFocusDisabled && !readOnly) {
@@ -1463,7 +1468,7 @@ function GreenScreenTerminal({
1463
1468
  }
1464
1469
  return /* @__PURE__ */ jsx4("div", { style: { width: `${screenData?.cols || profile.defaultCols}ch`, height: `${(screenData?.rows || profile.defaultRows) * 21}px`, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsxs4("div", { style: { textAlign: "center" }, children: [
1465
1470
  /* @__PURE__ */ jsx4("div", { style: { color: "#808080", marginBottom: "12px" }, children: /* @__PURE__ */ jsx4(TerminalIcon, { size: 40 }) }),
1466
- /* @__PURE__ */ jsx4("p", { style: { fontFamily: "var(--gs-font)", fontSize: "12px", color: "#808080" }, children: connStatus?.connected ? "Waiting for screen data..." : "Not connected" }),
1471
+ /* @__PURE__ */ jsx4("p", { style: { fontFamily: "var(--gs-font)", fontSize: "12px", color: connStatus?.status === "connecting" ? "#f59e0b" : connStatus?.status === "loading" ? "#94a3b8" : "#808080" }, children: connStatus?.connected ? "Waiting for screen data..." : connStatus?.status === "connecting" ? "Connecting..." : connStatus?.status === "loading" ? "Loading..." : "Not connected" }),
1467
1472
  !connStatus?.connected && isUsingDefaultAdapter && /* @__PURE__ */ jsxs4("p", { style: { fontFamily: "var(--gs-font)", fontSize: "11px", color: "#606060", marginTop: "8px" }, children: [
1468
1473
  "Start the proxy: ",
1469
1474
  /* @__PURE__ */ jsx4("code", { style: { color: "#10b981" }, children: "npx green-screen-proxy --mock" })
@@ -1484,7 +1489,7 @@ function GreenScreenTerminal({
1484
1489
  const cursor = getCursorPos();
1485
1490
  const hasCursor = screenData.cursor_row !== void 0 && screenData.cursor_col !== void 0;
1486
1491
  const cursorInInputField = hasCursor && fields.some(
1487
- (f) => f.is_input && f.row === cursor.row && cursor.col >= f.col && cursor.col < f.col + f.length
1492
+ (f) => f.is_input && !f.is_non_display && f.row === cursor.row && cursor.col >= f.col && cursor.col < f.col + f.length
1488
1493
  );
1489
1494
  return /* @__PURE__ */ jsxs4("div", { style: { fontFamily: "var(--gs-font)", fontSize: "13px", position: "relative", width: `${cols}ch` }, children: [
1490
1495
  rows.map((line, index) => {
@@ -1546,8 +1551,9 @@ function GreenScreenTerminal({
1546
1551
  screenData?.insert_mode && /* @__PURE__ */ jsx4("span", { className: "gs-badge-ins", children: "INS" })
1547
1552
  ] }),
1548
1553
  /* @__PURE__ */ jsxs4("div", { className: "gs-header-right", children: [
1549
- connStatus?.status && /* @__PURE__ */ jsx4(KeyIcon, { size: 12, style: { color: getStatusColor(connStatus.status) } }),
1550
- connStatus && (connStatus.connected ? /* @__PURE__ */ jsx4(WifiIcon, { size: 12, style: { color: "var(--gs-green, #10b981)" } }) : /* @__PURE__ */ jsx4(WifiOffIcon, { size: 12, style: { color: "#FF6B00" } })),
1554
+ connStatus?.status && connStatus.status !== "loading" && /* @__PURE__ */ jsx4(KeyIcon, { size: 12, style: { color: getStatusColor(connStatus.status) } }),
1555
+ connStatus && connStatus.status !== "loading" && (connStatus.connected ? /* @__PURE__ */ jsx4(WifiIcon, { size: 12, style: { color: "var(--gs-green, #10b981)" } }) : /* @__PURE__ */ jsx4(WifiOffIcon, { size: 12, style: { color: "#FF6B00" } })),
1556
+ statusActions,
1551
1557
  onMinimize && /* @__PURE__ */ jsx4("button", { onClick: (e) => {
1552
1558
  e.stopPropagation();
1553
1559
  onMinimize();
@@ -1569,7 +1575,7 @@ function GreenScreenTerminal({
1569
1575
  screenData?.insert_mode && /* @__PURE__ */ jsx4("span", { className: "gs-badge-ins", children: "INS" })
1570
1576
  ] }),
1571
1577
  /* @__PURE__ */ jsxs4("div", { className: "gs-header-right", children: [
1572
- connStatus && /* @__PURE__ */ jsx4("div", { className: "gs-status-group", children: connStatus.connected ? /* @__PURE__ */ jsxs4(Fragment, { children: [
1578
+ connStatus && connStatus.status !== "loading" && /* @__PURE__ */ jsx4("div", { className: "gs-status-group", children: connStatus.connected ? /* @__PURE__ */ jsxs4(Fragment, { children: [
1573
1579
  /* @__PURE__ */ jsx4(WifiIcon, { size: 12, style: { color: "var(--gs-green, #10b981)" } }),
1574
1580
  /* @__PURE__ */ jsx4("span", { className: "gs-host", children: connStatus.host })
1575
1581
  ] }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
@@ -1581,6 +1587,7 @@ function GreenScreenTerminal({
1581
1587
  /* @__PURE__ */ jsx4(KeyIcon, { size: 12, style: { color: getStatusColor(connStatus.status) } }),
1582
1588
  connStatus.username && /* @__PURE__ */ jsx4("span", { className: "gs-host", children: connStatus.username })
1583
1589
  ] }),
1590
+ statusActions,
1584
1591
  /* @__PURE__ */ jsx4("button", { onClick: (e) => {
1585
1592
  e.stopPropagation();
1586
1593
  setShowShortcuts((s) => !s);
@@ -1640,7 +1647,8 @@ function GreenScreenTerminal({
1640
1647
  ] }),
1641
1648
  connStatus && !connStatus.connected && screenData && /* @__PURE__ */ jsxs4("div", { className: "gs-overlay", children: [
1642
1649
  /* @__PURE__ */ jsx4(WifiOffIcon, { size: 28 }),
1643
- /* @__PURE__ */ jsx4("span", { children: isAutoReconnecting || reconnecting ? "Reconnecting..." : "Disconnected" })
1650
+ /* @__PURE__ */ jsx4("span", { children: isAutoReconnecting || reconnecting ? "Reconnecting..." : connStatus?.status === "connecting" ? "Connecting..." : "Disconnected" }),
1651
+ connStatus.error && !isAutoReconnecting && !reconnecting && /* @__PURE__ */ jsx4("span", { style: { fontSize: "0.75em", opacity: 0.7, maxWidth: "80%", textAlign: "center", wordBreak: "break-word" }, children: connStatus.error })
1644
1652
  ] }),
1645
1653
  /* @__PURE__ */ jsx4(
1646
1654
  "input",