mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-23 17:10:07 +00:00
chore: maybe fix failing tests
This commit is contained in:
parent
2e00c1fbe1
commit
a714a8611f
@ -46,7 +46,7 @@
|
|||||||
"@nuxt/vite-builder": "workspace:*",
|
"@nuxt/vite-builder": "workspace:*",
|
||||||
"@nuxt/webpack-builder": "workspace:*",
|
"@nuxt/webpack-builder": "workspace:*",
|
||||||
"@types/node": "22.13.2",
|
"@types/node": "22.13.2",
|
||||||
"@unhead/vue": "2.0.0-alpha.13",
|
"@unhead/vue": "2.0.0-alpha.14",
|
||||||
"@vue/compiler-core": "3.5.13",
|
"@vue/compiler-core": "3.5.13",
|
||||||
"@vue/compiler-dom": "3.5.13",
|
"@vue/compiler-dom": "3.5.13",
|
||||||
"@vue/shared": "3.5.13",
|
"@vue/shared": "3.5.13",
|
||||||
@ -83,7 +83,7 @@
|
|||||||
"@types/babel__helper-plugin-utils": "7.10.3",
|
"@types/babel__helper-plugin-utils": "7.10.3",
|
||||||
"@types/node": "22.13.2",
|
"@types/node": "22.13.2",
|
||||||
"@types/semver": "7.5.8",
|
"@types/semver": "7.5.8",
|
||||||
"@unhead/vue": "2.0.0-alpha.13",
|
"@unhead/vue": "2.0.0-alpha.14",
|
||||||
"@vitest/coverage-v8": "3.0.5",
|
"@vitest/coverage-v8": "3.0.5",
|
||||||
"@vue/test-utils": "2.4.6",
|
"@vue/test-utils": "2.4.6",
|
||||||
"acorn": "8.14.0",
|
"acorn": "8.14.0",
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
"@nuxt/schema": "workspace:*",
|
"@nuxt/schema": "workspace:*",
|
||||||
"@nuxt/telemetry": "^2.6.5",
|
"@nuxt/telemetry": "^2.6.5",
|
||||||
"@nuxt/vite-builder": "workspace:*",
|
"@nuxt/vite-builder": "workspace:*",
|
||||||
"@unhead/vue": "^2.0.0-alpha.13",
|
"@unhead/vue": "^2.0.0-alpha.14",
|
||||||
"@vue/shared": "^3.5.13",
|
"@vue/shared": "^3.5.13",
|
||||||
"acorn": "8.14.0",
|
"acorn": "8.14.0",
|
||||||
"c12": "^2.0.2",
|
"c12": "^2.0.2",
|
||||||
|
@ -17,6 +17,7 @@ import destr from 'destr'
|
|||||||
import { getQuery as getURLQuery, joinURL, withoutTrailingSlash } from 'ufo'
|
import { getQuery as getURLQuery, joinURL, withoutTrailingSlash } from 'ufo'
|
||||||
import { renderToString as _renderToString } from 'vue/server-renderer'
|
import { renderToString as _renderToString } from 'vue/server-renderer'
|
||||||
import { createHead, propsToString, renderSSRHead } from '@unhead/vue/server'
|
import { createHead, propsToString, renderSSRHead } from '@unhead/vue/server'
|
||||||
|
import { resolveUnrefHeadInput } from '@unhead/vue/utils'
|
||||||
import type { Head, HeadEntryOptions, Link, ResolvedHead, Script, Style } from '@unhead/vue/types'
|
import type { Head, HeadEntryOptions, Link, ResolvedHead, Script, Style } from '@unhead/vue/types'
|
||||||
|
|
||||||
import { defineRenderHandler, getRouteRules, useNitroApp, useRuntimeConfig, useStorage } from 'nitro/runtime'
|
import { defineRenderHandler, getRouteRules, useNitroApp, useRuntimeConfig, useStorage } from 'nitro/runtime'
|
||||||
@ -467,21 +468,17 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
|||||||
}, headEntryOptions)
|
}, headEntryOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
const tags = await head.resolveTags()
|
|
||||||
|
|
||||||
// Response for component islands
|
// Response for component islands
|
||||||
if (isRenderingIsland && islandContext) {
|
if (isRenderingIsland && islandContext) {
|
||||||
const islandHead: ResolvedHead = {}
|
const islandHead: ResolvedHead = {}
|
||||||
for (const tag of tags) {
|
// TODO migrate to using resolved tags to minify the payload
|
||||||
const currentValue = islandHead[tag.tag as keyof Head]
|
for (const entry of head.entries.values()) {
|
||||||
if (['meta', 'link', 'style', 'script', 'noscript'].includes(tag.tag)) {
|
for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input) as Head)) {
|
||||||
const value = currentValue || []
|
const currentValue = islandHead[key as keyof ResolvedHead]
|
||||||
;(value as any[]).push(tag.props)
|
if (Array.isArray(currentValue)) {
|
||||||
// @ts-expect-error type juggling
|
currentValue.push(...value)
|
||||||
islandHead[tag.tag as keyof Head] = value
|
}
|
||||||
} else {
|
islandHead[key as keyof ResolvedHead] = value
|
||||||
// @ts-expect-error type juggling
|
|
||||||
islandHead[tag.tag as keyof Head] = { innerHTML: tag.innerHTML, textContent: tag.textContent, ...tag.props }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,11 +512,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
|||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove certain tags for nuxt islands
|
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(head, renderSSRHeadOptions)
|
||||||
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(head, {
|
|
||||||
...renderSSRHeadOptions,
|
|
||||||
resolvedTags: tags,
|
|
||||||
})
|
|
||||||
|
|
||||||
// Create render context
|
// Create render context
|
||||||
const htmlContext: NuxtRenderHTMLContext = {
|
const htmlContext: NuxtRenderHTMLContext = {
|
||||||
|
@ -14,7 +14,7 @@ overrides:
|
|||||||
'@nuxt/vite-builder': workspace:*
|
'@nuxt/vite-builder': workspace:*
|
||||||
'@nuxt/webpack-builder': workspace:*
|
'@nuxt/webpack-builder': workspace:*
|
||||||
'@types/node': 22.13.2
|
'@types/node': 22.13.2
|
||||||
'@unhead/vue': 2.0.0-alpha.13
|
'@unhead/vue': 2.0.0-alpha.14
|
||||||
'@vue/compiler-core': 3.5.13
|
'@vue/compiler-core': 3.5.13
|
||||||
'@vue/compiler-dom': 3.5.13
|
'@vue/compiler-dom': 3.5.13
|
||||||
'@vue/shared': 3.5.13
|
'@vue/shared': 3.5.13
|
||||||
@ -85,8 +85,8 @@ importers:
|
|||||||
specifier: 7.5.8
|
specifier: 7.5.8
|
||||||
version: 7.5.8
|
version: 7.5.8
|
||||||
'@unhead/vue':
|
'@unhead/vue':
|
||||||
specifier: 2.0.0-alpha.13
|
specifier: 2.0.0-alpha.14
|
||||||
version: 2.0.0-alpha.13(vue@3.5.13(typescript@5.7.3))
|
version: 2.0.0-alpha.14(vue@3.5.13(typescript@5.7.3))
|
||||||
'@vitest/coverage-v8':
|
'@vitest/coverage-v8':
|
||||||
specifier: 3.0.5
|
specifier: 3.0.5
|
||||||
version: 3.0.5(vitest@3.0.5(@types/debug@4.1.12)(@types/node@22.13.2)(happy-dom@17.1.0)(jiti@2.4.2)(terser@5.32.0)(tsx@4.19.2)(yaml@2.7.0))
|
version: 3.0.5(vitest@3.0.5(@types/debug@4.1.12)(@types/node@22.13.2)(happy-dom@17.1.0)(jiti@2.4.2)(terser@5.32.0)(tsx@4.19.2)(yaml@2.7.0))
|
||||||
@ -338,8 +338,8 @@ importers:
|
|||||||
specifier: 22.13.2
|
specifier: 22.13.2
|
||||||
version: 22.13.2
|
version: 22.13.2
|
||||||
'@unhead/vue':
|
'@unhead/vue':
|
||||||
specifier: 2.0.0-alpha.13
|
specifier: 2.0.0-alpha.14
|
||||||
version: 2.0.0-alpha.13(vue@3.5.13(typescript@5.7.3))
|
version: 2.0.0-alpha.14(vue@3.5.13(typescript@5.7.3))
|
||||||
'@vue/shared':
|
'@vue/shared':
|
||||||
specifier: 3.5.13
|
specifier: 3.5.13
|
||||||
version: 3.5.13
|
version: 3.5.13
|
||||||
@ -502,7 +502,7 @@ importers:
|
|||||||
devDependencies:
|
devDependencies:
|
||||||
'@nuxt/scripts':
|
'@nuxt/scripts':
|
||||||
specifier: 0.10.1
|
specifier: 0.10.1
|
||||||
version: 0.10.1(@types/google.maps@3.58.1)(@types/vimeo__player@2.18.3)(@types/youtube@0.1.0)(@unhead/vue@2.0.0-alpha.13(vue@3.5.13(typescript@5.7.3)))(typescript@5.7.3)
|
version: 0.10.1(@types/google.maps@3.58.1)(@types/vimeo__player@2.18.3)(@types/youtube@0.1.0)(@unhead/vue@2.0.0-alpha.14(vue@3.5.13(typescript@5.7.3)))(typescript@5.7.3)
|
||||||
'@parcel/watcher':
|
'@parcel/watcher':
|
||||||
specifier: 2.5.1
|
specifier: 2.5.1
|
||||||
version: 2.5.1
|
version: 2.5.1
|
||||||
@ -2118,7 +2118,7 @@ packages:
|
|||||||
'@types/google.maps': ^3.58.1
|
'@types/google.maps': ^3.58.1
|
||||||
'@types/vimeo__player': ^2.18.3
|
'@types/vimeo__player': ^2.18.3
|
||||||
'@types/youtube': ^0.1.0
|
'@types/youtube': ^0.1.0
|
||||||
'@unhead/vue': 2.0.0-alpha.13
|
'@unhead/vue': 2.0.0-alpha.14
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
'@stripe/stripe-js':
|
'@stripe/stripe-js':
|
||||||
optional: true
|
optional: true
|
||||||
@ -2919,8 +2919,8 @@ packages:
|
|||||||
'@ungap/structured-clone@1.2.0':
|
'@ungap/structured-clone@1.2.0':
|
||||||
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
|
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
|
||||||
|
|
||||||
'@unhead/vue@2.0.0-alpha.13':
|
'@unhead/vue@2.0.0-alpha.14':
|
||||||
resolution: {integrity: sha512-rp1eKnXeXdrmt39JQRlQXJTYKuJOiyJ+kqqp06PifhtNv3jk0/5eXMJBeG01Rj2mOHa7/ABforoIdIxQotIzDA==}
|
resolution: {integrity: sha512-XQteFcROXVbPjK3bEFX/0ffzB8XAOPibZo10djaPSzP9KHEuDF/GFwY2R8NBXboSGhlZ9SqUOCKSfuCgji2nuA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: 3.5.13
|
vue: 3.5.13
|
||||||
|
|
||||||
@ -7301,8 +7301,8 @@ packages:
|
|||||||
unenv@1.10.0:
|
unenv@1.10.0:
|
||||||
resolution: {integrity: sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==}
|
resolution: {integrity: sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==}
|
||||||
|
|
||||||
unhead@2.0.0-alpha.13:
|
unhead@2.0.0-alpha.14:
|
||||||
resolution: {integrity: sha512-fekwwUZtWKNwGY+VXKtugsBAcQN5X4Rc/ctXjVu8OZ8w6KCu+ST7eOC7ac1HVK8vN7fb0SKaSqWCNlw3NZFzRA==}
|
resolution: {integrity: sha512-mg8aYvi9kHBjj++LGRg/PPUPEU2wbaiV1O8IV90UaCSzWzVgy6i345uZU8++zLApbWqY4XSibYLGYrB4EHO7rQ==}
|
||||||
|
|
||||||
unicode-emoji-modifier-base@1.0.0:
|
unicode-emoji-modifier-base@1.0.0:
|
||||||
resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==}
|
resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==}
|
||||||
@ -8854,10 +8854,10 @@ snapshots:
|
|||||||
string-width: 4.2.3
|
string-width: 4.2.3
|
||||||
webpack: 5.98.0
|
webpack: 5.98.0
|
||||||
|
|
||||||
'@nuxt/scripts@0.10.1(@types/google.maps@3.58.1)(@types/vimeo__player@2.18.3)(@types/youtube@0.1.0)(@unhead/vue@2.0.0-alpha.13(vue@3.5.13(typescript@5.7.3)))(typescript@5.7.3)':
|
'@nuxt/scripts@0.10.1(@types/google.maps@3.58.1)(@types/vimeo__player@2.18.3)(@types/youtube@0.1.0)(@unhead/vue@2.0.0-alpha.14(vue@3.5.13(typescript@5.7.3)))(typescript@5.7.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@nuxt/kit': link:packages/kit
|
'@nuxt/kit': link:packages/kit
|
||||||
'@unhead/vue': 2.0.0-alpha.13(vue@3.5.13(typescript@5.7.3))
|
'@unhead/vue': 2.0.0-alpha.14(vue@3.5.13(typescript@5.7.3))
|
||||||
'@vueuse/core': 12.5.0(typescript@5.7.3)
|
'@vueuse/core': 12.5.0(typescript@5.7.3)
|
||||||
consola: 3.4.0
|
consola: 3.4.0
|
||||||
defu: 6.1.4
|
defu: 6.1.4
|
||||||
@ -9839,10 +9839,10 @@ snapshots:
|
|||||||
|
|
||||||
'@ungap/structured-clone@1.2.0': {}
|
'@ungap/structured-clone@1.2.0': {}
|
||||||
|
|
||||||
'@unhead/vue@2.0.0-alpha.13(vue@3.5.13(typescript@5.7.3))':
|
'@unhead/vue@2.0.0-alpha.14(vue@3.5.13(typescript@5.7.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
hookable: 5.5.3
|
hookable: 5.5.3
|
||||||
unhead: 2.0.0-alpha.13
|
unhead: 2.0.0-alpha.14
|
||||||
vue: 3.5.13(typescript@5.7.3)
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
|
||||||
'@unocss/astro@65.4.3(rollup@4.34.6)(vite@6.1.0(@types/node@22.13.2)(jiti@2.4.2)(sass@1.78.0)(terser@5.32.0)(tsx@4.19.2)(yaml@2.7.0))(vue@3.5.13(typescript@5.7.3))':
|
'@unocss/astro@65.4.3(rollup@4.34.6)(vite@6.1.0(@types/node@22.13.2)(jiti@2.4.2)(sass@1.78.0)(terser@5.32.0)(tsx@4.19.2)(yaml@2.7.0))(vue@3.5.13(typescript@5.7.3))':
|
||||||
@ -15098,7 +15098,7 @@ snapshots:
|
|||||||
node-fetch-native: 1.6.6
|
node-fetch-native: 1.6.6
|
||||||
pathe: 1.1.2
|
pathe: 1.1.2
|
||||||
|
|
||||||
unhead@2.0.0-alpha.13:
|
unhead@2.0.0-alpha.14:
|
||||||
dependencies:
|
dependencies:
|
||||||
hookable: 5.5.3
|
hookable: 5.5.3
|
||||||
|
|
||||||
|
@ -1016,7 +1016,9 @@ describe('head tags', () => {
|
|||||||
expect(headHtml).toContain('<meta name="description" content="overriding with an inline useHead call">')
|
expect(headHtml).toContain('<meta name="description" content="overriding with an inline useHead call">')
|
||||||
expect(headHtml).toMatch(/<html[^>]*class="html-attrs-test"/)
|
expect(headHtml).toMatch(/<html[^>]*class="html-attrs-test"/)
|
||||||
expect(headHtml).toMatch(/<body[^>]*class="body-attrs-test"/)
|
expect(headHtml).toMatch(/<body[^>]*class="body-attrs-test"/)
|
||||||
expect(headHtml).toContain('<script src="https://a-body-appended-script.com"></script></body>')
|
|
||||||
|
const bodyHtml = headHtml.match(/<body[^>]*>(.*)<\/body>/s)![1]
|
||||||
|
expect(bodyHtml).toContain('<script src="https://a-body-appended-script.com"></script>')
|
||||||
|
|
||||||
const indexHtml = await $fetch<string>('/')
|
const indexHtml = await $fetch<string>('/')
|
||||||
// should render charset by default
|
// should render charset by default
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { TemplateParamsPlugin } from '@unhead/vue/plugins'
|
||||||
|
|
||||||
|
// Unhead v2 requires an opt-in to template params
|
||||||
|
const head = injectHead()
|
||||||
|
head.use(TemplateParamsPlugin)
|
||||||
|
|
||||||
const description = ref('head script setup description for %site.name')
|
const description = ref('head script setup description for %site.name')
|
||||||
const siteName = ref()
|
const siteName = ref()
|
||||||
// server meta
|
// server meta
|
||||||
|
Loading…
Reference in New Issue
Block a user