From daaf86c07a8180ba8c010a7da310e168648a78d9 Mon Sep 17 00:00:00 2001 From: harlan Date: Wed, 22 Jan 2025 16:02:57 +1100 Subject: [PATCH] chore: rollback some types --- packages/nuxt/src/app/components/nuxt-island.ts | 4 ++-- packages/nuxt/src/core/runtime/nitro/renderer.ts | 4 ++-- packages/nuxt/src/head/plugins/unhead-imports.ts | 14 +++----------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/nuxt/src/app/components/nuxt-island.ts b/packages/nuxt/src/app/components/nuxt-island.ts index 22441b0c7e..cdbfb47917 100644 --- a/packages/nuxt/src/app/components/nuxt-island.ts +++ b/packages/nuxt/src/app/components/nuxt-island.ts @@ -7,7 +7,7 @@ import { randomUUID } from 'uncrypto' import { joinURL, withQuery } from 'ufo' import type { FetchResponse } from 'ofetch' -import type { ActiveHeadEntry, ResolvedHead } from '@unhead/vue/types' +import type { ActiveHeadEntry, Head } from '@unhead/vue/types' import type { NuxtIslandResponse } from '../types' import { useNuxtApp, useRuntimeConfig } from '../nuxt' import { prerenderRoutes, useRequestEvent } from '../composables/ssr' @@ -91,7 +91,7 @@ export default defineComponent({ const instance = getCurrentInstance()! const event = useRequestEvent() - let activeHead: ActiveHeadEntry + let activeHead: ActiveHeadEntry // TODO: remove use of `$fetch.raw` when nitro 503 issues on windows dev server are resolved const eventFetch = import.meta.server ? event!.fetch : import.meta.dev ? $fetch.raw : globalThis.fetch diff --git a/packages/nuxt/src/core/runtime/nitro/renderer.ts b/packages/nuxt/src/core/runtime/nitro/renderer.ts index 8dcfe6dfb2..f706de8bfb 100644 --- a/packages/nuxt/src/core/runtime/nitro/renderer.ts +++ b/packages/nuxt/src/core/runtime/nitro/renderer.ts @@ -77,7 +77,7 @@ export interface NuxtIslandContext { export interface NuxtIslandResponse { id?: string html: string - head: Partial + head: Head props?: Record> components?: Record slots?: Record @@ -473,7 +473,7 @@ export default defineRenderHandler(async (event): Promise = {} + const islandHead: Head = {} for (const entry of head.headEntries()) { for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input) as Head)) { const currentValue = islandHead[key as keyof Head] diff --git a/packages/nuxt/src/head/plugins/unhead-imports.ts b/packages/nuxt/src/head/plugins/unhead-imports.ts index 25e0531b9d..cfeda8d840 100644 --- a/packages/nuxt/src/head/plugins/unhead-imports.ts +++ b/packages/nuxt/src/head/plugins/unhead-imports.ts @@ -2,6 +2,7 @@ import { createUnplugin } from 'unplugin' import MagicString from 'magic-string' import type { ImportSpecifier } from 'estree' import { relative } from 'pathe' +import { unheadVueComposablesImports } from '@unhead/vue' import { parseAndWalk, withLocations } from '../../core/utils/parse' import { isJS, isVue } from '../../core/utils' import { distDir } from '../../dirs' @@ -21,15 +22,6 @@ function toImports (specifiers: ImportSpecifier[]) { }) } -const UnheadNuxtContextComposables = [ - 'useHead', - 'useHeadSafe', - 'useServerHeadSafe', - 'useSeoMeta', - 'useServerSeoMeta', - 'useServerHead', -] - /** * To use composable in an async context we need to pass Nuxt context to the Unhead composables. * @@ -58,8 +50,8 @@ export const UnheadImportsPlugin = (options: UnheadImportsPluginOptions) => crea } }) - const importsFromUnhead = importsToAdd.filter(specifier => UnheadNuxtContextComposables.includes(specifier.imported.name)) - const importsFromHead = importsToAdd.filter(specifier => !UnheadNuxtContextComposables.includes(specifier.imported.name)) + const importsFromUnhead = importsToAdd.filter(specifier => unheadVueComposablesImports['@unhead/vue'].includes(specifier.imported.name)) + const importsFromHead = importsToAdd.filter(specifier => !unheadVueComposablesImports['@unhead/vue'].includes(specifier.imported.name)) if (importsFromUnhead.length) { // warn if user has imported from @unhead/vue themselves if (!id.includes('node_modules')) {