chore: rollback some types

This commit is contained in:
harlan 2025-01-22 16:02:57 +11:00
parent 0ce81cba96
commit daaf86c07a
3 changed files with 7 additions and 15 deletions

View File

@ -7,7 +7,7 @@ import { randomUUID } from 'uncrypto'
import { joinURL, withQuery } from 'ufo' import { joinURL, withQuery } from 'ufo'
import type { FetchResponse } from 'ofetch' 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 type { NuxtIslandResponse } from '../types'
import { useNuxtApp, useRuntimeConfig } from '../nuxt' import { useNuxtApp, useRuntimeConfig } from '../nuxt'
import { prerenderRoutes, useRequestEvent } from '../composables/ssr' import { prerenderRoutes, useRequestEvent } from '../composables/ssr'
@ -91,7 +91,7 @@ export default defineComponent({
const instance = getCurrentInstance()! const instance = getCurrentInstance()!
const event = useRequestEvent() const event = useRequestEvent()
let activeHead: ActiveHeadEntry<ResolvedHead> let activeHead: ActiveHeadEntry<Head>
// TODO: remove use of `$fetch.raw` when nitro 503 issues on windows dev server are resolved // 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 const eventFetch = import.meta.server ? event!.fetch : import.meta.dev ? $fetch.raw : globalThis.fetch

View File

@ -77,7 +77,7 @@ export interface NuxtIslandContext {
export interface NuxtIslandResponse { export interface NuxtIslandResponse {
id?: string id?: string
html: string html: string
head: Partial<ResolvedHead> head: Head
props?: Record<string, Record<string, any>> props?: Record<string, Record<string, any>>
components?: Record<string, NuxtIslandClientResponse> components?: Record<string, NuxtIslandClientResponse>
slots?: Record<string, NuxtIslandSlotResponse> slots?: Record<string, NuxtIslandSlotResponse>
@ -473,7 +473,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
// Response for component islands // Response for component islands
if (isRenderingIsland && islandContext) { if (isRenderingIsland && islandContext) {
const islandHead: Partial<ResolvedHead> = {} const islandHead: Head = {}
for (const entry of head.headEntries()) { for (const entry of head.headEntries()) {
for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input) as Head)) { for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input) as Head)) {
const currentValue = islandHead[key as keyof Head] const currentValue = islandHead[key as keyof Head]

View File

@ -2,6 +2,7 @@ import { createUnplugin } from 'unplugin'
import MagicString from 'magic-string' import MagicString from 'magic-string'
import type { ImportSpecifier } from 'estree' import type { ImportSpecifier } from 'estree'
import { relative } from 'pathe' import { relative } from 'pathe'
import { unheadVueComposablesImports } from '@unhead/vue'
import { parseAndWalk, withLocations } from '../../core/utils/parse' import { parseAndWalk, withLocations } from '../../core/utils/parse'
import { isJS, isVue } from '../../core/utils' import { isJS, isVue } from '../../core/utils'
import { distDir } from '../../dirs' 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. * 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 importsFromUnhead = importsToAdd.filter(specifier => unheadVueComposablesImports['@unhead/vue'].includes(specifier.imported.name))
const importsFromHead = importsToAdd.filter(specifier => !UnheadNuxtContextComposables.includes(specifier.imported.name)) const importsFromHead = importsToAdd.filter(specifier => !unheadVueComposablesImports['@unhead/vue'].includes(specifier.imported.name))
if (importsFromUnhead.length) { if (importsFromUnhead.length) {
// warn if user has imported from @unhead/vue themselves // warn if user has imported from @unhead/vue themselves
if (!id.includes('node_modules')) { if (!id.includes('node_modules')) {