Skip to content

Commit

Permalink
feat: bring back disconnected dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 15, 2023
1 parent 924791d commit a81721d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
16 changes: 9 additions & 7 deletions packages/devtools/client/components/DisconnectIndicator.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<template>
<Teleport to="body">
<div
v-if="wsConnectingDebounced" flex="~ col justify-center items-center gap-2"
v-if="wsConnectingDebounced"
flex="~ col justify-center items-center gap-4"
fixed bottom-0 left-0 right-0 top-0 z-2147483646 p5 text-lg backdrop-blur-5 n-glass-effect
>
<div flex="~" mt--10 items-center justify-center>
<NuxtLogo h-14 />
<div flex="~" items-center justify-center>
<NuxtLogo h-8 />
</div>
<div v-if="wsError" flex="~ gap-2" items-center text-rose>
<div border="t base" my2 h-1px w-10 />
<div flex="~ gap-2" items-center text-xl op50>
<NIcon icon="i-carbon-wifi-off" />
WebSocket disconnected
Disconnected from Server
</div>
<div v-else flex="~ gap-2" animate-pulse items-center text-yellow>
<div flex="~ gap-2" animate-pulse items-center text-xl text-orange>
<NIcon icon="i-carbon-circle-dash" animate-spin />
Connecting to the server...
Retrying...
</div>
</div>
</Teleport>
Expand Down
11 changes: 8 additions & 3 deletions packages/devtools/client/composables/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ async function connectVite() {
onMessage(data)
})

// TODO:
// hot.on('vite:connect', (data) => {})
// hot.on('vite:disconnect', (data) => {})
wsConnecting.value = true

hot.on('vite:ws:connect', () => {
wsConnecting.value = false
})
hot.on('vite:ws:disconnect', () => {
wsConnecting.value = true
})

return hot
}
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/plugins/view/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export async function setupDevToolsClient({
return iframe
}

function waitForClientInjection(retry = 10, timeout = 200) {
function waitForClientInjection(retry = 20, timeout = 300) {
let lastError: any
const test = () => {
try {
Expand Down

0 comments on commit a81721d

Please sign in to comment.