Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/devtools/client/components/StorageDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async function renameCurrentItem() {
>
<span font-bold>{{ name }}</span><br>
<span text-sm>{{ storage.driver }} driver</span><br>
<FilepathItem v-if="storage.base" text-xs :filepath="storage.base" />
<FilepathItem v-if="'base' in storage && storage.base" text-xs :filepath="storage.base" />
</NCard>
</NPanelGrids>
</template>
4 changes: 2 additions & 2 deletions packages/devtools/client/components/TimelineSegment.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { UseTimeAgoOptions } from '@vueuse/core'
import type { TimelineEvent, TimelineEventNormalized, TimelineEventsSegment } from '../../types'
import { useTimeAgo } from '@vueuse/core'
import { useIntervalFn, useTimeAgo } from '@vueuse/core'
const props = defineProps<{
segment: TimelineEventsSegment
Expand All @@ -12,7 +12,7 @@ const emit = defineEmits<{
}>()
const timeAgo = useTimeAgo(() => props.segment.start, {
updateInterval: 1000,
scheduler: cb => useIntervalFn(cb, 1000),
showSecond: true,
controls: false,
messages: ({
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools/src/server-rpc/server-routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { NuxtDevtoolsServerContext, ServerFunctions, ServerRouteInfo } from '../types'
import type { AnyNitro } from '../utils/nitro-compat'
import { debounce } from 'perfect-debounce'
import { onDevReload } from '../utils/nitro-compat'

export function setupServerRoutesRPC({ nuxt, refresh }: NuxtDevtoolsServerContext) {
let nitro: AnyNitro | undefined
Expand All @@ -25,7 +26,7 @@ export function setupServerRoutesRPC({ nuxt, refresh }: NuxtDevtoolsServerContex
// both Nitro v2 and v3 and fires on any server-dir change, which is a
// coarser signal but debounced re-scans are cheap either way.
unhookDevReload?.()
unhookDevReload = _nitro.hooks.hook('dev:reload', () => refreshDebounced())
unhookDevReload = onDevReload(_nitro, () => refreshDebounced())
})

nuxt.hook('close', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools/src/server-rpc/server-tasks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { NuxtDevtoolsServerContext, ScannedNitroTasks, ServerFunctions } from '../types'
import type { AnyNitro } from '../utils/nitro-compat'
import { debounce } from 'perfect-debounce'
import { onDevReload } from '../utils/nitro-compat'

export function setupServerTasksRPC({ nuxt, refresh }: NuxtDevtoolsServerContext) {
let nitro: AnyNitro | undefined
Expand All @@ -21,7 +22,7 @@ export function setupServerTasksRPC({ nuxt, refresh }: NuxtDevtoolsServerContext
// See the equivalent comment in `server-routes.ts`: this used to watch
// Nitro's internal `src` storage mount, which Nitro v3 no longer exposes.
unhookDevReload?.()
unhookDevReload = _nitro.hooks.hook('dev:reload', () => refreshDebounced())
unhookDevReload = onDevReload(_nitro, () => refreshDebounced())
})

nuxt.hook('close', () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/devtools/src/utils/nitro-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ export type AnyNitroConfig = HasNitroV2 extends true
export type AnyStorageMounts = HasNitroV2 extends true
? (HasNitroV3 extends true ? StorageMountsV2 | StorageMountsV3 : StorageMountsV2)
: StorageMountsV3

/** `nitro.hooks.hook` is a union of two generic signatures when both engines are installed, which TS can't call. */
export function onDevReload(nitro: AnyNitro, callback: () => void): () => void {
// `dev:reload` exists on both Nitro v2 and v3.
return (nitro.hooks as NitroV2['hooks']).hook('dev:reload', callback)
}
Loading