Skip to content

Commit 4c54247

Browse files
danielroeantfu
andauthoredSep 10, 2024··
fix: use explicit imports of types (#715)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 07a213b commit 4c54247

19 files changed

+792
-680
lines changed
 

‎docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@nuxt/devtools": "^1.4.1",
1515
"@nuxt/fonts": "^0.7.2",
1616
"@nuxt/image": "1.8.0",
17-
"@nuxt/ui-pro": "^1.4.1",
17+
"@nuxt/ui-pro": "^1.4.2",
1818
"@nuxthq/studio": "^2.0.3",
1919
"@nuxtjs/plausible": "^1.0.2",
2020
"@vueuse/core": "^11.0.3",

‎docs/pnpm-lock.yaml

+562-359
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/devtools-kit/src/runtime/host-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { shallowRef } from 'vue'
2+
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools-kit/types'
23
import type { Ref } from 'vue'
3-
import type { NuxtDevtoolsHostClient } from '../types'
44

55
let clientRef: Ref<NuxtDevtoolsHostClient | undefined> | undefined
66
const fns = [] as ((client: NuxtDevtoolsHostClient) => void)[]

‎packages/devtools-kit/src/runtime/iframe-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { shallowRef, triggerRef } from 'vue'
2+
import type { NuxtDevtoolsIframeClient } from '@nuxt/devtools-kit/types'
23
import type { Ref } from 'vue'
3-
import type { NuxtDevtoolsIframeClient } from '../types'
44

55
let clientRef: Ref<NuxtDevtoolsIframeClient | undefined> | undefined
66
const hasSetup = false

‎packages/devtools/client/pages/modules/virtual-files.vue

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ function toShortPath(path: string) {
4040
const files = computed(() => {
4141
if (!data.value)
4242
return []
43-
return data
44-
.value
43+
return data.value
4544
.entries
46-
// Hide Nuxt dist files, as they are aliased as `#build`
4745
.filter(i => !i.id.startsWith(`${data.value?.rootDir || ''}/.nuxt/`))
4846
.sort((a, b) => a.id.localeCompare(b.id))
4947
})

‎packages/devtools/src/integrations/plugin-metrics.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,12 @@ function ${WRAPPER_KEY} (plugin, src) {
5757
.map(([, name, path]) => ({ name, path }))
5858

5959
content = content.replace(/\nexport default\s*\[([\s\S]*)\]/, (_, itemsRaw: string) => {
60-
const items = itemsRaw
61-
.split(',')
62-
.map(i => i.trim())
63-
.map((i) => {
64-
const importItem = imports.find(({ name }) => name === i)
65-
if (!importItem)
66-
return i
67-
return `${WRAPPER_KEY}(${i}, ${JSON.stringify(importItem.path)})`
68-
})
60+
const items = itemsRaw.split(',').map(i => i.trim()).map((i) => {
61+
const importItem = imports.find(({ name }) => name === i)
62+
if (!importItem)
63+
return i
64+
return `${WRAPPER_KEY}(${i}, ${JSON.stringify(importItem.path)})`
65+
})
6966
return `\n${snippets}\nexport default [\n${items.join(',\n')}\n]\n`
7067
})
7168

‎packages/devtools/src/runtime/function-metrics-helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @unimport-disable
22
import { parse as parseStrackTrace } from 'error-stack-parser-es'
33
import { markRaw, reactive } from 'vue'
4+
import type { TimelineEventFunction, TimelineMetrics } from '@nuxt/devtools/types'
45
import { useObjectStorage } from './plugins/view/utils'
5-
import type { TimelineEventFunction, TimelineMetrics } from '../types'
66

77
const nonLiteralSymbol = Symbol('nuxt-devtools-fn-metrics-non-literal')
88

‎packages/devtools/src/runtime/plugins/devtools.client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { shallowReactive, watchEffect } from 'vue'
22

3+
import type { TimelineServerState } from '@nuxt/devtools/types'
34
import type { Router } from 'vue-router'
4-
import { setupHooksDebug } from '../shared/hooks'
55

6-
import type { TimelineServerState } from '../../types'
6+
import { setupHooksDebug } from '../shared/hooks'
77
// eslint-disable-next-line ts/ban-ts-comment
88
// @ts-ignore tsconfig
99
import { defineNuxtPlugin, useRouter, useState } from '#imports'

‎packages/devtools/src/runtime/plugins/devtools.server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineNuxtPlugin, useState } from '#imports'
2-
import type { TimelineServerState } from '../../types'
2+
import type { TimelineServerState } from '@nuxt/devtools/types'
33

44
export default defineNuxtPlugin(() => {
55
// record ssr start time

‎packages/devtools/src/runtime/plugins/view/FrameBox.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
22
import { ref, watchEffect } from 'vue'
3+
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools/types'
34
import { PANEL_MAX, PANEL_MIN, popupWindow, state } from './state'
45
import { useEventListener } from './utils'
5-
import type { NuxtDevtoolsHostClient } from '../../../types'
66
77
const props = defineProps<{
88
client: NuxtDevtoolsHostClient

‎packages/devtools/src/runtime/plugins/view/Main.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script setup lang="ts">
22
import { computed, onMounted, reactive, ref, watchEffect } from 'vue'
3+
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools/types'
34
import type { CSSProperties } from 'vue'
45
import { settings } from '../../settings'
56
import FrameBox from './FrameBox.vue'
67
import { state } from './state'
78
import { millisecondToHumanreadable, useElementBounding, useEventListener, useScreenSafeArea } from './utils'
8-
import type { NuxtDevtoolsHostClient } from '../../../types'
99
1010
const props = defineProps<{
1111
client: NuxtDevtoolsHostClient

‎packages/devtools/src/runtime/plugins/view/client.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { setIframeServerContext } from '@vue/devtools-kit'
22
import { createHooks } from 'hookable'
33
import { debounce } from 'perfect-debounce'
44
import { computed, createApp, h, markRaw, ref, shallowReactive, shallowRef, watch } from 'vue'
5+
6+
import type { NuxtDevtoolsHostClient, TimelineEventRoute, TimelineMetrics } from '@nuxt/devtools/types'
57
import type { $Fetch } from 'ofetch'
68
import type { Ref } from 'vue'
79
import type { Router } from 'vue-router'
10+
811
import { initTimelineMetrics } from '../../function-metrics-helpers'
912
import Main from './Main.vue'
1013
import { popupWindow, state } from './state'
11-
import type { NuxtDevtoolsHostClient, TimelineEventRoute, TimelineMetrics } from '../../../types'
1214

1315
// eslint-disable-next-line ts/ban-ts-comment
1416
// @ts-ignore tsconfig

‎packages/devtools/src/runtime/plugins/view/state.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { shallowRef } from 'vue'
2+
import type { DevToolsFrameState } from '@nuxt/devtools/types'
23
import { useObjectStorage } from './utils'
3-
import type { DevToolsFrameState } from '../../../types'
44

55
export const PANEL_PADDING = 10
66
export const PANEL_MIN = 20

‎packages/devtools/src/runtime/settings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-expect-error virtual module
22
import _settings from '#build/devtools/settings'
33

4-
import type { NuxtDevToolsOptions } from '../types'
4+
import type { NuxtDevToolsOptions } from '@nuxt/devtools/types'
55

66
export const settings = _settings as {
77
ui: NuxtDevToolsOptions['ui']

‎packages/devtools/src/runtime/shared/hooks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { HookInfo } from '@nuxt/devtools/types'
12
import type { Hookable } from 'hookable'
2-
import type { HookInfo } from '../../types'
33

44
export function setupHooksDebug<T extends Hookable<any>>(hooks: T) {
55
const serverHooks: Record<string, HookInfo> = {}

‎packages/devtools/src/runtime/use-nuxt-devtools.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { shallowRef } from 'vue'
2+
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools/types'
23
import type { Ref } from 'vue'
3-
import type { NuxtDevtoolsHostClient } from '../types'
44

55
/**
66
* Get Nuxt DevTools client for host app

‎packages/devtools/src/server-rpc/server-routes.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ export function setupServerRoutesRPC({ nuxt, refresh }: NuxtDevtoolsServerContex
4141
method: item.method,
4242
type: item.route?.startsWith('/api') ? 'api' : 'route',
4343
})),
44-
...nitro.options
45-
.handlers
46-
.filter(item => !item.route?.startsWith('/_nitro') && !item.route?.startsWith('/__nuxt') && !item.middleware)
47-
.map(item => ({
48-
route: item.route,
49-
filepath: item.handler,
50-
method: item.method,
51-
type: 'runtime',
52-
})),
44+
...nitro.options.handlers.filter(item => !item.route?.startsWith('/_nitro') && !item.route?.startsWith('/__nuxt') && !item.middleware).map(item => ({
45+
route: item.route,
46+
filepath: item.handler,
47+
method: item.method,
48+
type: 'runtime',
49+
})),
5350
] as ServerRouteInfo[]
5451
})()
5552

0 commit comments

Comments
 (0)