Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use explicit imports of types #715

Merged
merged 3 commits into from
Sep 10, 2024
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 docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@nuxt/devtools": "^1.4.1",
"@nuxt/fonts": "^0.7.2",
"@nuxt/image": "1.8.0",
"@nuxt/ui-pro": "^1.4.1",
"@nuxt/ui-pro": "^1.4.2",
"@nuxthq/studio": "^2.0.3",
"@nuxtjs/plausible": "^1.0.2",
"@vueuse/core": "^11.0.3",
Expand Down
921 changes: 562 additions & 359 deletions docs/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/devtools-kit/src/runtime/host-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallowRef } from 'vue'
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools-kit/types'
import type { Ref } from 'vue'
import type { NuxtDevtoolsHostClient } from '../types'

let clientRef: Ref<NuxtDevtoolsHostClient | undefined> | undefined
const fns = [] as ((client: NuxtDevtoolsHostClient) => void)[]
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-kit/src/runtime/iframe-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallowRef, triggerRef } from 'vue'
import type { NuxtDevtoolsIframeClient } from '@nuxt/devtools-kit/types'
import type { Ref } from 'vue'
import type { NuxtDevtoolsIframeClient } from '../types'

let clientRef: Ref<NuxtDevtoolsIframeClient | undefined> | undefined
const hasSetup = false
Expand Down
4 changes: 1 addition & 3 deletions packages/devtools/client/pages/modules/virtual-files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ function toShortPath(path: string) {
const files = computed(() => {
if (!data.value)
return []
return data
.value
return data.value
.entries
// Hide Nuxt dist files, as they are aliased as `#build`
.filter(i => !i.id.startsWith(`${data.value?.rootDir || ''}/.nuxt/`))
.sort((a, b) => a.id.localeCompare(b.id))
})
Expand Down
15 changes: 6 additions & 9 deletions packages/devtools/src/integrations/plugin-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ function ${WRAPPER_KEY} (plugin, src) {
.map(([, name, path]) => ({ name, path }))

content = content.replace(/\nexport default\s*\[([\s\S]*)\]/, (_, itemsRaw: string) => {
const items = itemsRaw
.split(',')
.map(i => i.trim())
.map((i) => {
const importItem = imports.find(({ name }) => name === i)
if (!importItem)
return i
return `${WRAPPER_KEY}(${i}, ${JSON.stringify(importItem.path)})`
})
const items = itemsRaw.split(',').map(i => i.trim()).map((i) => {
const importItem = imports.find(({ name }) => name === i)
if (!importItem)
return i
return `${WRAPPER_KEY}(${i}, ${JSON.stringify(importItem.path)})`
})
return `\n${snippets}\nexport default [\n${items.join(',\n')}\n]\n`
})

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/function-metrics-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @unimport-disable
import { parse as parseStrackTrace } from 'error-stack-parser-es'
import { markRaw, reactive } from 'vue'
import type { TimelineEventFunction, TimelineMetrics } from '@nuxt/devtools/types'
import { useObjectStorage } from './plugins/view/utils'
import type { TimelineEventFunction, TimelineMetrics } from '../types'

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

Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/src/runtime/plugins/devtools.client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { shallowReactive, watchEffect } from 'vue'

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

import type { TimelineServerState } from '../../types'
import { setupHooksDebug } from '../shared/hooks'
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore tsconfig
import { defineNuxtPlugin, useRouter, useState } from '#imports'
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/plugins/devtools.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineNuxtPlugin, useState } from '#imports'
import type { TimelineServerState } from '../../types'
import type { TimelineServerState } from '@nuxt/devtools/types'

export default defineNuxtPlugin(() => {
// record ssr start time
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/plugins/view/FrameBox.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { ref, watchEffect } from 'vue'
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools/types'
import { PANEL_MAX, PANEL_MIN, popupWindow, state } from './state'
import { useEventListener } from './utils'
import type { NuxtDevtoolsHostClient } from '../../../types'

const props = defineProps<{
client: NuxtDevtoolsHostClient
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/plugins/view/Main.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref, watchEffect } from 'vue'
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools/types'
import type { CSSProperties } from 'vue'
import { settings } from '../../settings'
import FrameBox from './FrameBox.vue'
import { state } from './state'
import { millisecondToHumanreadable, useElementBounding, useEventListener, useScreenSafeArea } from './utils'
import type { NuxtDevtoolsHostClient } from '../../../types'

const props = defineProps<{
client: NuxtDevtoolsHostClient
Expand Down
4 changes: 3 additions & 1 deletion packages/devtools/src/runtime/plugins/view/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { setIframeServerContext } from '@vue/devtools-kit'
import { createHooks } from 'hookable'
import { debounce } from 'perfect-debounce'
import { computed, createApp, h, markRaw, ref, shallowReactive, shallowRef, watch } from 'vue'

import type { NuxtDevtoolsHostClient, TimelineEventRoute, TimelineMetrics } from '@nuxt/devtools/types'
import type { $Fetch } from 'ofetch'
import type { Ref } from 'vue'
import type { Router } from 'vue-router'

import { initTimelineMetrics } from '../../function-metrics-helpers'
import Main from './Main.vue'
import { popupWindow, state } from './state'
import type { NuxtDevtoolsHostClient, TimelineEventRoute, TimelineMetrics } from '../../../types'

// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore tsconfig
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/plugins/view/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallowRef } from 'vue'
import type { DevToolsFrameState } from '@nuxt/devtools/types'
import { useObjectStorage } from './utils'
import type { DevToolsFrameState } from '../../../types'

export const PANEL_PADDING = 10
export const PANEL_MIN = 20
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-expect-error virtual module
import _settings from '#build/devtools/settings'

import type { NuxtDevToolsOptions } from '../types'
import type { NuxtDevToolsOptions } from '@nuxt/devtools/types'

export const settings = _settings as {
ui: NuxtDevToolsOptions['ui']
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/shared/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HookInfo } from '@nuxt/devtools/types'
import type { Hookable } from 'hookable'
import type { HookInfo } from '../../types'

export function setupHooksDebug<T extends Hookable<any>>(hooks: T) {
const serverHooks: Record<string, HookInfo> = {}
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/use-nuxt-devtools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallowRef } from 'vue'
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools/types'
import type { Ref } from 'vue'
import type { NuxtDevtoolsHostClient } from '../types'

/**
* Get Nuxt DevTools client for host app
Expand Down
15 changes: 6 additions & 9 deletions packages/devtools/src/server-rpc/server-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ export function setupServerRoutesRPC({ nuxt, refresh }: NuxtDevtoolsServerContex
method: item.method,
type: item.route?.startsWith('/api') ? 'api' : 'route',
})),
...nitro.options
.handlers
.filter(item => !item.route?.startsWith('/_nitro') && !item.route?.startsWith('/__nuxt') && !item.middleware)
.map(item => ({
route: item.route,
filepath: item.handler,
method: item.method,
type: 'runtime',
})),
...nitro.options.handlers.filter(item => !item.route?.startsWith('/_nitro') && !item.route?.startsWith('/__nuxt') && !item.middleware).map(item => ({
route: item.route,
filepath: item.handler,
method: item.method,
type: 'runtime',
})),
] as ServerRouteInfo[]
})()

Expand Down
Loading