mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 21:10:48 +00:00
Replaces MutableRefObject with RefObject for refs
Updates type annotations across terminal-related hooks and runtime modules to use RefObject instead of MutableRefObject for React refs. Aligns with React's convention for refs not directly assigned via useRef, improving type safety and clarity.
This commit is contained in:
5 files changed
+28
-30
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import type { Terminal as XTerm } from "@xterm/xterm";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import type { MutableRefObject } from "react";
|
||||
import type { RefObject } from "react";
|
||||
import type { Host, TerminalSession } from "../../../types";
|
||||
import type { PendingAuth } from "../runtime/createTerminalSessionStarters";
|
||||
import type { TerminalAuthMethod } from "../TerminalAuthDialog";
|
||||
@@ -16,8 +16,8 @@ export const useTerminalAuthState = ({
|
||||
setProgressLogs,
|
||||
}: {
|
||||
host: Host;
|
||||
pendingAuthRef: MutableRefObject<PendingAuth>;
|
||||
termRef: MutableRefObject<XTerm | null>;
|
||||
pendingAuthRef: RefObject<PendingAuth>;
|
||||
termRef: RefObject<XTerm | null>;
|
||||
onUpdateHost?: (host: Host) => void;
|
||||
onStartSsh: (term: XTerm) => void;
|
||||
setStatus: (status: TerminalSession["status"]) => void;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Terminal as XTerm } from "@xterm/xterm";
|
||||
import { useCallback } from "react";
|
||||
import type { MutableRefObject } from "react";
|
||||
import type { RefObject } from "react";
|
||||
import { logger } from "../../../lib/logger";
|
||||
|
||||
type TerminalBackendWriteApi = {
|
||||
@@ -13,8 +13,8 @@ export const useTerminalContextActions = ({
|
||||
terminalBackend,
|
||||
onHasSelectionChange,
|
||||
}: {
|
||||
termRef: MutableRefObject<XTerm | null>;
|
||||
sessionRef: MutableRefObject<string | null>;
|
||||
termRef: RefObject<XTerm | null>;
|
||||
sessionRef: RefObject<string | null>;
|
||||
terminalBackend: TerminalBackendWriteApi;
|
||||
onHasSelectionChange?: (hasSelection: boolean) => void;
|
||||
}) => {
|
||||
@@ -60,4 +60,3 @@ export const useTerminalContextActions = ({
|
||||
|
||||
return { onCopy, onPaste, onSelectAll, onClear, onSelectWord };
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SearchAddon } from "@xterm/addon-search";
|
||||
import type { Terminal as XTerm } from "@xterm/xterm";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import type { MutableRefObject } from "react";
|
||||
import type { RefObject } from "react";
|
||||
|
||||
type SearchMatchCount = { current: number; total: number } | null;
|
||||
|
||||
@@ -9,8 +9,8 @@ export const useTerminalSearch = ({
|
||||
searchAddonRef,
|
||||
termRef,
|
||||
}: {
|
||||
searchAddonRef: MutableRefObject<SearchAddon | null>;
|
||||
termRef: MutableRefObject<XTerm | null>;
|
||||
searchAddonRef: RefObject<SearchAddon | null>;
|
||||
termRef: RefObject<XTerm | null>;
|
||||
}) => {
|
||||
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
||||
const [searchMatchCount, setSearchMatchCount] = useState<SearchMatchCount>(null);
|
||||
@@ -120,4 +120,3 @@ export const useTerminalSearch = ({
|
||||
handleCloseSearch,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { FitAddon } from "@xterm/addon-fit";
|
||||
import type { SerializeAddon } from "@xterm/addon-serialize";
|
||||
import type { Terminal as XTerm } from "@xterm/xterm";
|
||||
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
||||
import type { Dispatch, RefObject, SetStateAction } from "react";
|
||||
import { logger } from "../../../lib/logger";
|
||||
import type { Host, SSHKey, TerminalSession, TerminalSettings } from "../../../types";
|
||||
|
||||
@@ -60,15 +60,15 @@ export type TerminalSessionStartersContext = {
|
||||
terminalSettings?: TerminalSettings;
|
||||
terminalBackend: TerminalBackendApi;
|
||||
|
||||
sessionRef: MutableRefObject<string | null>;
|
||||
hasConnectedRef: MutableRefObject<boolean>;
|
||||
hasRunStartupCommandRef: MutableRefObject<boolean>;
|
||||
disposeDataRef: MutableRefObject<(() => void) | null>;
|
||||
disposeExitRef: MutableRefObject<(() => void) | null>;
|
||||
fitAddonRef: MutableRefObject<FitAddon | null>;
|
||||
serializeAddonRef: MutableRefObject<SerializeAddon | null>;
|
||||
highlightProcessorRef: MutableRefObject<(text: string) => string>;
|
||||
pendingAuthRef: MutableRefObject<PendingAuth>;
|
||||
sessionRef: RefObject<string | null>;
|
||||
hasConnectedRef: RefObject<boolean>;
|
||||
hasRunStartupCommandRef: RefObject<boolean>;
|
||||
disposeDataRef: RefObject<(() => void) | null>;
|
||||
disposeExitRef: RefObject<(() => void) | null>;
|
||||
fitAddonRef: RefObject<FitAddon | null>;
|
||||
serializeAddonRef: RefObject<SerializeAddon | null>;
|
||||
highlightProcessorRef: RefObject<(text: string) => string>;
|
||||
pendingAuthRef: RefObject<PendingAuth>;
|
||||
|
||||
updateStatus: (next: TerminalSession["status"]) => void;
|
||||
setStatus: Dispatch<SetStateAction<TerminalSession["status"]>>;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { SerializeAddon } from "@xterm/addon-serialize";
|
||||
import { WebLinksAddon } from "@xterm/addon-web-links";
|
||||
import { WebglAddon } from "@xterm/addon-webgl";
|
||||
import { Terminal as XTerm } from "@xterm/xterm";
|
||||
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
||||
import type { Dispatch, RefObject, SetStateAction } from "react";
|
||||
import {
|
||||
checkAppShortcut,
|
||||
getAppLevelActions,
|
||||
@@ -45,18 +45,18 @@ export type CreateXTermRuntimeContext = {
|
||||
host: Host;
|
||||
fontSize: number;
|
||||
terminalTheme: TerminalTheme;
|
||||
terminalSettingsRef: MutableRefObject<TerminalSettings | undefined>;
|
||||
terminalSettingsRef: RefObject<TerminalSettings | undefined>;
|
||||
terminalBackend: TerminalBackendApi;
|
||||
sessionRef: MutableRefObject<string | null>;
|
||||
sessionRef: RefObject<string | null>;
|
||||
|
||||
hotkeySchemeRef: MutableRefObject<"disabled" | "mac" | "pc">;
|
||||
keyBindingsRef: MutableRefObject<KeyBinding[]>;
|
||||
onHotkeyActionRef: MutableRefObject<
|
||||
hotkeySchemeRef: RefObject<"disabled" | "mac" | "pc">;
|
||||
keyBindingsRef: RefObject<KeyBinding[]>;
|
||||
onHotkeyActionRef: RefObject<
|
||||
((action: string, event: KeyboardEvent) => void) | undefined
|
||||
>;
|
||||
|
||||
isBroadcastEnabledRef: MutableRefObject<boolean | undefined>;
|
||||
onBroadcastInputRef: MutableRefObject<
|
||||
isBroadcastEnabledRef: RefObject<boolean | undefined>;
|
||||
onBroadcastInputRef: RefObject<
|
||||
((data: string, sourceSessionId: string) => void) | undefined
|
||||
>;
|
||||
|
||||
@@ -68,7 +68,7 @@ export type CreateXTermRuntimeContext = {
|
||||
hostLabel: string,
|
||||
sessionId: string,
|
||||
) => void;
|
||||
commandBufferRef: MutableRefObject<string>;
|
||||
commandBufferRef: RefObject<string>;
|
||||
setIsSearchOpen: Dispatch<SetStateAction<boolean>>;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user