mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
Compare commits
21 Commits
d57a94ef93
...
1654f5c08e
Author | SHA1 | Date | |
---|---|---|---|
|
1654f5c08e | ||
|
edc299a043 | ||
|
ad3ab4d310 | ||
|
23b1af766b | ||
|
0646244a30 | ||
|
df749b9b5b | ||
|
d218a835f3 | ||
|
d4e2b44f4c | ||
|
8eeaed5164 | ||
|
25a21f4d5a | ||
|
1edb8d2d7a | ||
|
2984d3f66a | ||
|
9e83d05e17 | ||
|
50255cb5c1 | ||
|
b5ec8f643a | ||
|
390f88bdf6 | ||
|
c90f321fb2 | ||
|
b99d5660e4 | ||
|
b73ff33136 | ||
|
c759cf3f35 | ||
|
d5cf708041 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -248,7 +248,7 @@ jobs:
|
|||||||
TEST_PAYLOAD: ${{ matrix.payload }}
|
TEST_PAYLOAD: ${{ matrix.payload }}
|
||||||
SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }}
|
SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }}
|
||||||
|
|
||||||
- uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2
|
- uses: codecov/codecov-action@985343d70564a82044c1b7fcb84c2fa05405c1a2 # v5.0.4
|
||||||
if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on'
|
if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on'
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
@ -91,7 +91,7 @@
|
|||||||
"devalue": "5.1.1",
|
"devalue": "5.1.1",
|
||||||
"eslint": "9.15.0",
|
"eslint": "9.15.0",
|
||||||
"eslint-plugin-no-only-tests": "3.3.0",
|
"eslint-plugin-no-only-tests": "3.3.0",
|
||||||
"eslint-plugin-perfectionist": "4.0.2",
|
"eslint-plugin-perfectionist": "4.0.3",
|
||||||
"eslint-typegen": "0.3.2",
|
"eslint-typegen": "0.3.2",
|
||||||
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
||||||
"happy-dom": "15.11.6",
|
"happy-dom": "15.11.6",
|
||||||
@ -118,7 +118,7 @@
|
|||||||
"vue-router": "4.4.5",
|
"vue-router": "4.4.5",
|
||||||
"vue-tsc": "2.1.10"
|
"vue-tsc": "2.1.10"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.13.2",
|
"packageManager": "pnpm@9.14.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^16.10.0 || >=18.0.0"
|
"node": "^16.10.0 || >=18.0.0"
|
||||||
},
|
},
|
||||||
|
@ -41,7 +41,6 @@ export default defineComponent({
|
|||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
const pageRef = ref()
|
const pageRef = ref()
|
||||||
const forkRoute = inject(PageRouteSymbol, null)
|
const forkRoute = inject(PageRouteSymbol, null)
|
||||||
let previousPageKey: string | undefined | false
|
|
||||||
|
|
||||||
expose({ pageRef })
|
expose({ pageRef })
|
||||||
|
|
||||||
@ -97,10 +96,6 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const key = generateRouteKey(routeProps, props.pageKey)
|
const key = generateRouteKey(routeProps, props.pageKey)
|
||||||
if (!nuxtApp.isHydrating && !hasChildrenRoutes(forkRoute, routeProps.route, routeProps.Component) && previousPageKey === key) {
|
|
||||||
nuxtApp.callHook('page:loading:end')
|
|
||||||
}
|
|
||||||
previousPageKey = key
|
|
||||||
|
|
||||||
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition)
|
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition)
|
||||||
const transitionProps = hasTransition && _mergeTransitionProps([
|
const transitionProps = hasTransition && _mergeTransitionProps([
|
||||||
@ -161,10 +156,3 @@ function haveParentRoutesRendered (fork: RouteLocationNormalizedLoaded | null, n
|
|||||||
(c, i) => c.components?.default !== fork.matched[i]?.components?.default) ||
|
(c, i) => c.components?.default !== fork.matched[i]?.components?.default) ||
|
||||||
(Component && generateRouteKey({ route: newRoute, Component }) !== generateRouteKey({ route: fork, Component }))
|
(Component && generateRouteKey({ route: newRoute, Component }) !== generateRouteKey({ route: fork, Component }))
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasChildrenRoutes (fork: RouteLocationNormalizedLoaded | null, newRoute: RouteLocationNormalizedLoaded, Component?: VNode) {
|
|
||||||
if (!fork) { return false }
|
|
||||||
|
|
||||||
const index = newRoute.matched.findIndex(m => m.components?.default === Component?.type)
|
|
||||||
return index < newRoute.matched.length - 1
|
|
||||||
}
|
|
||||||
|
@ -114,8 +114,8 @@ importers:
|
|||||||
specifier: 3.3.0
|
specifier: 3.3.0
|
||||||
version: 3.3.0
|
version: 3.3.0
|
||||||
eslint-plugin-perfectionist:
|
eslint-plugin-perfectionist:
|
||||||
specifier: 4.0.2
|
specifier: 4.0.3
|
||||||
version: 4.0.2(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
version: 4.0.3(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
||||||
eslint-typegen:
|
eslint-typegen:
|
||||||
specifier: 0.3.2
|
specifier: 0.3.2
|
||||||
version: 0.3.2(eslint@9.15.0(jiti@2.4.0))
|
version: 0.3.2(eslint@9.15.0(jiti@2.4.0))
|
||||||
@ -4373,8 +4373,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q==}
|
resolution: {integrity: sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q==}
|
||||||
engines: {node: '>=5.0.0'}
|
engines: {node: '>=5.0.0'}
|
||||||
|
|
||||||
eslint-plugin-perfectionist@4.0.2:
|
eslint-plugin-perfectionist@4.0.3:
|
||||||
resolution: {integrity: sha512-zWdgyg2SdHqhp/P9d9vKwo5qD9is28xMAGzBslHqkZz5mVIikjyz1qvuJ4yS7Wrsf4KlbGorORefb4Kbe7Puzg==}
|
resolution: {integrity: sha512-CyafnreF6boy4lf1XaF72U8NbkwrfjU/mOf1y6doaDMS9zGXhUU1DSk+ZPf/rVwCf1PL1m+rhHqFs+IcB8kDmA==}
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
engines: {node: ^18.0.0 || >=20.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: '>=8.0.0'
|
eslint: '>=8.0.0'
|
||||||
@ -11519,7 +11519,7 @@ snapshots:
|
|||||||
|
|
||||||
eslint-plugin-no-only-tests@3.3.0: {}
|
eslint-plugin-no-only-tests@3.3.0: {}
|
||||||
|
|
||||||
eslint-plugin-perfectionist@4.0.2(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3):
|
eslint-plugin-perfectionist@4.0.3(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.15.0
|
'@typescript-eslint/types': 8.15.0
|
||||||
'@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
'@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
|
||||||
|
@ -625,6 +625,44 @@ describe('pages', () => {
|
|||||||
const html = await $fetch('/prerender/test')
|
const html = await $fetch('/prerender/test')
|
||||||
expect(html).toContain('should be prerendered: true')
|
expect(html).toContain('should be prerendered: true')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should trigger page:loading:end only once', async () => {
|
||||||
|
const { page, consoleLogs } = await renderPage('/')
|
||||||
|
|
||||||
|
await page.getByText('to page load hook').click()
|
||||||
|
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/page-load-hook')
|
||||||
|
const loadingEndLogs = consoleLogs.filter(c => c.text.includes('page:loading:end'))
|
||||||
|
expect(loadingEndLogs.length).toBe(1)
|
||||||
|
|
||||||
|
await page.close()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should hide nuxt page load indicator after navigate back from nested page', async () => {
|
||||||
|
const LOAD_INDICATOR_SELECTOR = '.nuxt-loading-indicator'
|
||||||
|
const { page } = await renderPage('/')
|
||||||
|
await page.getByText('to page nuxt load indicator').click()
|
||||||
|
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/nested/xyz')
|
||||||
|
|
||||||
|
await page.waitForSelector(LOAD_INDICATOR_SELECTOR)
|
||||||
|
let isVisible = await page.isVisible(LOAD_INDICATOR_SELECTOR)
|
||||||
|
expect(isVisible).toBe(true)
|
||||||
|
|
||||||
|
await page.waitForSelector(LOAD_INDICATOR_SELECTOR, { state: 'hidden' })
|
||||||
|
isVisible = await page.isVisible(LOAD_INDICATOR_SELECTOR)
|
||||||
|
expect(isVisible).toBe(false)
|
||||||
|
|
||||||
|
await page.goBack()
|
||||||
|
|
||||||
|
await page.waitForSelector(LOAD_INDICATOR_SELECTOR)
|
||||||
|
isVisible = await page.isVisible(LOAD_INDICATOR_SELECTOR)
|
||||||
|
expect(isVisible).toBe(true)
|
||||||
|
|
||||||
|
await page.waitForSelector(LOAD_INDICATOR_SELECTOR, { state: 'hidden' })
|
||||||
|
isVisible = await page.isVisible(LOAD_INDICATOR_SELECTOR)
|
||||||
|
expect(isVisible).toBe(false)
|
||||||
|
|
||||||
|
await page.close()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('nuxt composables', () => {
|
describe('nuxt composables', () => {
|
||||||
|
7
test/fixtures/basic/pages/index.vue
vendored
7
test/fixtures/basic/pages/index.vue
vendored
@ -3,6 +3,7 @@
|
|||||||
<Head>
|
<Head>
|
||||||
<Title>Basic fixture</Title>
|
<Title>Basic fixture</Title>
|
||||||
</Head>
|
</Head>
|
||||||
|
<NuxtLoadingIndicator :throttle="0" />
|
||||||
<h1>Hello Nuxt 3!</h1>
|
<h1>Hello Nuxt 3!</h1>
|
||||||
<div>RuntimeConfig | testConfig: {{ config.public.testConfig }}</div>
|
<div>RuntimeConfig | testConfig: {{ config.public.testConfig }}</div>
|
||||||
<div>Composable | foo: {{ foo }}</div>
|
<div>Composable | foo: {{ foo }}</div>
|
||||||
@ -94,6 +95,12 @@
|
|||||||
<NuxtLink to="/server-page">
|
<NuxtLink to="/server-page">
|
||||||
to server page
|
to server page
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
<NuxtLink to="/page-load-hook">
|
||||||
|
to page load hook
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink to="/nested/xyz">
|
||||||
|
to page nuxt load indicator
|
||||||
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
5
test/fixtures/basic/pages/page-load-hook.vue
vendored
Normal file
5
test/fixtures/basic/pages/page-load-hook.vue
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Page for hook tests.
|
||||||
|
</div>
|
||||||
|
</template>
|
8
test/fixtures/basic/plugins/page-hook-plugin.ts
vendored
Normal file
8
test/fixtures/basic/plugins/page-hook-plugin.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
|
const route = useRoute()
|
||||||
|
nuxtApp.hook('page:loading:end', () => {
|
||||||
|
if (route.path === '/page-load-hook') {
|
||||||
|
console.log('page:loading:end')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user