From 28711a96af40a5355ec8de53ece02cfae3fe1e8d Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 18 Nov 2024 16:40:33 +0100 Subject: [PATCH] Completely removed remix forge integration (#165) * Potential fix for ws issue * Potential fix for ws issue --- package-lock.json | 4 +- package.json | 3 +- src/client/components/NewRouteForm.tsx | 2 +- src/client/hooks/useRemixForgeSocket.ts | 54 ++----------------------- src/client/layout/Tabs.tsx | 23 +---------- src/client/tabs/TerminalTab.tsx | 4 +- 6 files changed, 10 insertions(+), 80 deletions(-) diff --git a/package-lock.json b/package-lock.json index 988166e..7b9edde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "remix-development-tools", - "version": "4.7.6", + "version": "4.7.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "remix-development-tools", - "version": "4.7.6", + "version": "4.7.7", "license": "MIT", "workspaces": [ ".", diff --git a/package.json b/package.json index 4e54117..2823a00 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "remix-development-tools", "description": "Remix development tools - a set of tools for developing/debugging Remix.run apps", "author": "Alem Tuzlak", - "version": "4.7.6", + "version": "4.7.7", "license": "MIT", "keywords": [ "remix", @@ -139,7 +139,6 @@ "react-d3-tree": "^3.6.2", "react-diff-viewer-continued": "^3.3.1", "react-hotkeys-hook": "^4.5.0", - "react-use-websocket": "^4.8.1", "tailwind-merge": "^1.14.0" } } diff --git a/src/client/components/NewRouteForm.tsx b/src/client/components/NewRouteForm.tsx index 76e156b..1ec04d1 100644 --- a/src/client/components/NewRouteForm.tsx +++ b/src/client/components/NewRouteForm.tsx @@ -30,7 +30,7 @@ const DEFAULT_VALUES = { const NewRouteForm = () => { const { sendJsonMessage } = useRemixForgeSocket({ - onMessage: (e) => { + onMessage: (e: { data: any }) => { const messageData = e.data if (messageData.type === "route_added") { setNewRouteInfo(DEFAULT_VALUES) diff --git a/src/client/hooks/useRemixForgeSocket.ts b/src/client/hooks/useRemixForgeSocket.ts index 3f7a940..c56ff8f 100644 --- a/src/client/hooks/useRemixForgeSocket.ts +++ b/src/client/hooks/useRemixForgeSocket.ts @@ -1,53 +1,5 @@ -import { useState } from "react" -import { type Options, ReadyState } from "react-use-websocket" -import useWebSocket from "react-use-websocket" -import { useSettingsContext, useTerminalContext } from "../context/useRDTContext.js" - -const RETRY_COUNT = 2 - -export const useRemixForgeSocket = (options?: Options) => { - const { settings, setSettings } = useSettingsContext() - const { terminals, toggleTerminalLock, setProcessId } = useTerminalContext() - const { shouldConnectWithForge, port } = settings - const [retryCount, setRetryCount] = useState(0) - const opts: Options = { - ...options, - share: true, - shouldReconnect: () => true, - reconnectAttempts: RETRY_COUNT, - reconnectInterval: 0, - onClose: (e) => { - // connection closed by remix forge - if (e.code === 1005) { - setSettings({ shouldConnectWithForge: false }) - setRetryCount(0) - for (const terminal of terminals) { - toggleTerminalLock(terminal.id, false) - setProcessId(terminal.id, undefined) - } - - return - } - if (retryCount < RETRY_COUNT) { - return setRetryCount(retryCount + 1) - } - setSettings({ shouldConnectWithForge: false }) - }, - } - - const properties = useWebSocket(`ws://localhost:${port}`, opts, shouldConnectWithForge) - - const connectionStatus = { - [ReadyState.CONNECTING]: "Connecting", - [ReadyState.OPEN]: "Open", - [ReadyState.CLOSING]: "Closing", - [ReadyState.CLOSED]: "Closed", - [ReadyState.UNINSTANTIATED]: "Uninstantiated", - }[properties.readyState] - const isConnected = properties.readyState === ReadyState.OPEN - const isConnecting = properties.readyState === ReadyState.CONNECTING - - return { ...properties, connectionStatus, isConnected, isConnecting } +export const useRemixForgeSocket = (options?: any) => { + return { sendJsonMessage: (obj: any) => {}, isConnected: false, isConnecting: false } } interface RemixForgeMessage extends Record { @@ -56,7 +8,7 @@ interface RemixForgeMessage extends Record { data?: string } -export const useRemixForgeSocketExternal = (options?: Options) => { +export const useRemixForgeSocketExternal = (options?: any) => { const { sendJsonMessage, ...rest } = useRemixForgeSocket(options) const sendJsonMessageExternal = (message: RemixForgeMessage) => { sendJsonMessage({ ...message, type: "plugin" }) diff --git a/src/client/layout/Tabs.tsx b/src/client/layout/Tabs.tsx index fb7053d..c1ca29a 100644 --- a/src/client/layout/Tabs.tsx +++ b/src/client/layout/Tabs.tsx @@ -67,13 +67,12 @@ const Tab = ({ } const Tabs = ({ plugins, setIsOpen }: TabsProps) => { - const { settings, setSettings } = useSettingsContext() + const { settings } = useSettingsContext() const { htmlErrors } = useHtmlErrors() const { setPersistOpen } = usePersistOpen() const { activeTab } = settings const { isConnected, isConnecting } = useRemixForgeSocket() const { visibleTabs } = useTabs(isConnected, isConnecting, plugins) - const shouldShowConnectToForge = !isConnected || isConnecting const scrollRef = useHorizontalScroll() const { setDetachedWindowOwner, detachedWindowOwner, detachedWindow } = useDetachedWindowControls() const handleDetachment = () => { @@ -117,26 +116,6 @@ const Tabs = ({ plugins, setIsOpen }: TabsProps) => { /> ))}
- {shouldShowConnectToForge && ( - , - icon: , - }} - className={twMerge( - clsx( - isConnecting && "pointer-events-none animate-pulse cursor-default", - "mt-auto w-full ", - detachedWindow ? "mr-0" : "" - ) - )} - onClick={() => setSettings({ shouldConnectWithForge: true })} - /> - )} {!detachedWindow && setIsOpen && ( <> {!detachedWindowOwner && ( diff --git a/src/client/tabs/TerminalTab.tsx b/src/client/tabs/TerminalTab.tsx index 0909b97..6f9621d 100644 --- a/src/client/tabs/TerminalTab.tsx +++ b/src/client/tabs/TerminalTab.tsx @@ -39,7 +39,7 @@ const Terminal = ({ onClose, terminal, projectCommands }: TerminalProps) => { }, [terminal.output]) const { sendJsonMessage } = useRemixForgeSocket({ - onMessage: (message) => { + onMessage: (message: any) => { try { const data = JSON.parse(message.data) // Check if command was sent from this terminal @@ -149,7 +149,7 @@ const TerminalTab = () => { const { terminals, addOrRemoveTerminal } = useTerminalContext() const [projectCommands, setProjectCommands] = useState>() const { sendJsonMessage } = useRemixForgeSocket({ - onMessage: (message) => { + onMessage: (message: any) => { try { const data = JSON.parse(message.data) if (data.type === "commands") {