8000 Merge branch 'main' into remix-development-tools · forge-42/react-router-devtools@3bf30a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3bf30a4

Browse files
committed
Merge branch 'main' into remix-development-tools
2 parents 758e3f5 + 28711a9 commit 3bf30a4

File tree

6 files changed

+10
-80
lines changed

6 files changed

+10
-80
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "remix-development-tools",
33
"description": "Remix development tools - a set of tools for developing/debugging Remix.run apps [deprecated branch]",
44
"author": "Alem Tuzlak",
5-
"version": "4.7.6",
5+
"version": "4.7.7",
66
"license": "MIT",
77
"keywords": [
88
"remix",
@@ -139,7 +139,6 @@
139139
"react-d3-tree": "^3.6.2",
140140
"react-diff-viewer-continued": "^3.3.1",
141141
"react-hotkeys-hook": "^4.5.0",
142-
"react-use-websocket": "^4.8.1",
143142
"tailwind-merge": "^1.14.0"
144143
}
145144
}

src/client/components/NewRouteForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const DEFAULT_VALUES = {
3030

3131
const NewRouteForm = () => {
3232
const { sendJsonMessage } = useRemixForgeSocket({
33-
onMessage: (e) => {
33+
onMessage: (e: { data: any }) => {
3434
const messageData = e.data
3535
if (messageData.type === "route_added") {
3636
setNewRouteInfo(DEFAULT_VALUES)

src/client/hooks/useRemixForgeSocket.ts

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,5 @@
1-
import { useState } from "react"
2-
import { type Options, ReadyState } from "react-use-websocket"
3-
import useWebSocket from "react-use-websocket"
4-
import { useSettingsContext, useTerminalContext } from "../context/useRDTContext.js"
5-
6-
const RETRY_COUNT = 2
7-
8-
export const useRemixForgeSocket = (options?: Options) => {
9-
const { settings, setSettings } = useSettingsContext()
10-
const { terminals, toggleTerminalLock, setProcessId } = useTerminalContext()
11-
const { shouldConnectWithForge, port } = settings
12-
const [retryCount, setRetryCount] = useState( 8000 0)
13-
const opts: Options = {
14-
...options,
15-
share: true,
16-
shouldReconnect: () => true,
17-
reconnectAttempts: RETRY_COUNT,
18-
reconnectInterval: 0,
19-
onClose: (e) => {
20-
// connection closed by remix forge
21-
if (e.code === 1005) {
22-
setSettings({ shouldConnectWithForge: false })
23-
setRetryCount(0)
24-
for (const terminal of terminals) {
25-
toggleTerminalLock(terminal.id, false)
26-
setProcessId(terminal.id, undefined)
27-
}
28-
29-
return
30-
}
31-
if (retryCount < RETRY_COUNT) {
32-
return setRetryCount(retryCount + 1)
33-
}
34-
setSettings({ shouldConnectWithForge: false })
35-
},
36-
}
37-
38-
const properties = useWebSocket(`ws://localhost:${port}`, opts, shouldConnectWithForge)
39-
40-
const connectionStatus = {
41-
[ReadyState.CONNECTING]: "Connecting",
42-
[ReadyState.OPEN]: "Open",
43-
[ReadyState.CLOSING]: "Closing",
44-
[ReadyState.CLOSED]: "Closed",
45-
[ReadyState.UNINSTANTIATED]: "Uninstantiated",
46-
}[properties.readyState]
47-
const isConnected = properties.readyState === ReadyState.OPEN
48-
const isConnecting = properties.readyState === ReadyState.CONNECTING
49-
50-
return { ...properties, connectionStatus, isConnected, isConnecting }
1+
export const useRemixForgeSocket = (options?: any) => {
2+
return { sendJsonMessage: (obj: any) => {}, isConnected: false, isConnecting: false }
513
}
524

535
interface RemixForgeMessage extends Record<string, unknown> {
@@ -56,7 +8,7 @@ interface RemixForgeMessage extends Record<string, unknown> {
568
data?: string
579
}
5810

59-
export const useRemixForgeSocketExternal = (options?: Options) => {
11+
export const useRemixForgeSocketExternal = (options?: any) => {
6012
const { sendJsonMessage, ...rest } = useRemixForgeSocket(options)
6113
const sendJsonMessageExternal = (message: RemixForgeMessage) => {
6214
sendJsonMessage({ ...message, type: "plugin" })

src/client/layout/Tabs.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ const Tab = ({
6767
}
6868

6969
const Tabs = ({ plugins, setIsOpen }: TabsProps) => {
70-
const { settings, setSettings } = useSettingsContext()
70+
const { settings } = useSettingsContext()
7171
const { htmlErrors } = useHtmlErrors()
7272
const { setPersistOpen } = usePersistOpen()
7373
const { activeTab } = settings
7474
const { isConnected, isConnecting } = useRemixForgeSocket()
7575
const { visibleTabs } = useTabs(isConnected, isConnecting, plugins)
76-
const shouldShowConnectToForge = !isConnected || isConnecting
7776
const scrollRef = useHorizontalScroll()
7877
const { setDetachedWindowOwner, detachedWindowOwner, detachedWindow } = useDetachedWindowControls()
7978
const handleDetachment = () => {
@@ -117,26 +116,6 @@ const Tabs = ({ plugins, setIsOpen }: TabsProps) => {
117116
/>
118117
))}
119118
<div className={clsx("mt-auto flex w-full flex-col items-center")}>
120-
{shouldShowConnectToForge && (
121-
<Tab
122-
tab={{
123-
id: "connect",
124-
name: isConnecting ? "Connecting to Forge..." : "Connect to Remix Forge",
125-
requiresForge: false,
126-
hideTimeline: false,
127-
component: <></>,
128-
icon: <Icon name="Radio" size="md" />,
129-
}}
130-
className={twMerge(
131-
clsx(
132-
isConnecting && "pointer-events-none animate-pulse cursor-default",
133-
"mt-auto w-full ",
134-
detachedWindow ? "mr-0" : ""
135-
)
136-
)}
137-
onClick={() => setSettings({ shouldConnectWithForge: true })}
138-
/>
139-
)}
140119
{!detachedWindow && setIsOpen && (
141120
<>
142121
{!detachedWindowOwner && (

src/client/tabs/TerminalTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Terminal = ({ onClose, terminal, projectCommands }: TerminalProps) => {
3939
}, [terminal.output])
4040

4141
const { sendJsonMessage } = useRemixForgeSocket({
42-
onMessage: (message) => {
42+
onMessage: (message: any) => {
4343
try {
4444
const data = JSON.parse(message.data)
4545
// Check if command was sent from this terminal
@@ -149,7 +149,7 @@ const TerminalTab = () => {
149149
const { terminals, addOrRemoveTerminal } = useTerminalContext()
150150
const [projectCommands, setProjectCommands] = useState<Record<string, string>>()
151151
const { sendJsonMessage } = useRemixForgeSocket({
152-
onMessage: (message) => {
152+
onMessage: (message: any) => {
153153
try {
154154
const data = JSON.parse(message.data)
155155
if (data.type === "commands") {

0 commit comments

Comments
 (0)
0