@depup/nuxt 4.2.2-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/app.d.ts +1 -0
- package/bin/nuxt.mjs +2 -0
- package/config.cjs +7 -0
- package/config.d.ts +8 -0
- package/config.js +5 -0
- package/dist/app/compat/capi.d.ts +4 -0
- package/dist/app/compat/capi.js +19 -0
- package/dist/app/compat/idle-callback.d.ts +2 -0
- package/dist/app/compat/idle-callback.js +15 -0
- package/dist/app/compat/interval.d.ts +1 -0
- package/dist/app/compat/interval.js +11 -0
- package/dist/app/compat/vue-demi.d.ts +4 -0
- package/dist/app/compat/vue-demi.js +4 -0
- package/dist/app/components/client-fallback.client.d.ts +50 -0
- package/dist/app/components/client-fallback.client.js +50 -0
- package/dist/app/components/client-fallback.server.d.ts +57 -0
- package/dist/app/components/client-fallback.server.js +80 -0
- package/dist/app/components/client-only.d.ts +26 -0
- package/dist/app/components/client-only.js +130 -0
- package/dist/app/components/dev-only.d.ts +11 -0
- package/dist/app/components/dev-only.js +14 -0
- package/dist/app/components/error-404.d.vue.ts +51 -0
- package/dist/app/components/error-404.vue +48 -0
- package/dist/app/components/error-404.vue.d.ts +51 -0
- package/dist/app/components/error-500.d.vue.ts +51 -0
- package/dist/app/components/error-500.vue +46 -0
- package/dist/app/components/error-500.vue.d.ts +51 -0
- package/dist/app/components/index.d.ts +3 -0
- package/dist/app/components/index.js +1 -0
- package/dist/app/components/injections.d.ts +7 -0
- package/dist/app/components/injections.js +2 -0
- package/dist/app/components/island-renderer.d.ts +20 -0
- package/dist/app/components/island-renderer.js +28 -0
- package/dist/app/components/nuxt-error-boundary.d.vue.ts +24 -0
- package/dist/app/components/nuxt-error-boundary.vue +46 -0
- package/dist/app/components/nuxt-error-boundary.vue.d.ts +24 -0
- package/dist/app/components/nuxt-error-page.d.vue.ts +7 -0
- package/dist/app/components/nuxt-error-page.vue +27 -0
- package/dist/app/components/nuxt-error-page.vue.d.ts +7 -0
- package/dist/app/components/nuxt-island.d.ts +70 -0
- package/dist/app/components/nuxt-island.js +331 -0
- package/dist/app/components/nuxt-layout.d.ts +14 -0
- package/dist/app/components/nuxt-layout.js +171 -0
- package/dist/app/components/nuxt-link.d.ts +101 -0
- package/dist/app/components/nuxt-link.js +409 -0
- package/dist/app/components/nuxt-loading-indicator.d.ts +78 -0
- package/dist/app/components/nuxt-loading-indicator.js +75 -0
- package/dist/app/components/nuxt-root.d.vue.ts +3 -0
- package/dist/app/components/nuxt-root.vue +60 -0
- package/dist/app/components/nuxt-root.vue.d.ts +3 -0
- package/dist/app/components/nuxt-route-announcer.d.ts +26 -0
- package/dist/app/components/nuxt-route-announcer.js +48 -0
- package/dist/app/components/nuxt-stubs.d.ts +6 -0
- package/dist/app/components/nuxt-stubs.js +14 -0
- package/dist/app/components/nuxt-teleport-island-component.d.ts +22 -0
- package/dist/app/components/nuxt-teleport-island-component.js +38 -0
- package/dist/app/components/nuxt-teleport-island-slot.d.ts +32 -0
- package/dist/app/components/nuxt-teleport-island-slot.js +53 -0
- package/dist/app/components/nuxt-time.d.vue.ts +37 -0
- package/dist/app/components/nuxt-time.vue +148 -0
- package/dist/app/components/nuxt-time.vue.d.ts +37 -0
- package/dist/app/components/route-provider.d.ts +48 -0
- package/dist/app/components/route-provider.js +49 -0
- package/dist/app/components/server-placeholder.d.ts +2 -0
- package/dist/app/components/server-placeholder.js +7 -0
- package/dist/app/components/test-component-wrapper.d.ts +4 -0
- package/dist/app/components/test-component-wrapper.js +27 -0
- package/dist/app/components/utils.d.ts +48 -0
- package/dist/app/components/utils.js +126 -0
- package/dist/app/components/welcome.d.vue.ts +24 -0
- package/dist/app/components/welcome.vue +34 -0
- package/dist/app/components/welcome.vue.d.ts +24 -0
- package/dist/app/composables/asyncContext.d.ts +2 -0
- package/dist/app/composables/asyncContext.js +7 -0
- package/dist/app/composables/asyncData.d.ts +146 -0
- package/dist/app/composables/asyncData.js +491 -0
- package/dist/app/composables/chunk.d.ts +25 -0
- package/dist/app/composables/chunk.js +30 -0
- package/dist/app/composables/component.d.ts +4 -0
- package/dist/app/composables/component.js +82 -0
- package/dist/app/composables/cookie.d.ts +22 -0
- package/dist/app/composables/cookie.js +205 -0
- package/dist/app/composables/error.d.ts +25 -0
- package/dist/app/composables/error.js +39 -0
- package/dist/app/composables/fetch.d.ts +37 -0
- package/dist/app/composables/fetch.js +123 -0
- package/dist/app/composables/head.d.ts +1 -0
- package/dist/app/composables/head.js +1 -0
- package/dist/app/composables/hydrate.d.ts +9 -0
- package/dist/app/composables/hydrate.js +14 -0
- package/dist/app/composables/id.d.ts +3 -0
- package/dist/app/composables/id.js +2 -0
- package/dist/app/composables/index.d.ts +29 -0
- package/dist/app/composables/index.js +21 -0
- package/dist/app/composables/lazy-hydration.d.ts +40 -0
- package/dist/app/composables/lazy-hydration.js +2 -0
- package/dist/app/composables/loading-indicator.d.ts +39 -0
- package/dist/app/composables/loading-indicator.js +142 -0
- package/dist/app/composables/manifest.d.ts +20 -0
- package/dist/app/composables/manifest.js +59 -0
- package/dist/app/composables/once.d.ts +14 -0
- package/dist/app/composables/once.js +49 -0
- package/dist/app/composables/payload.d.ts +27 -0
- package/dist/app/composables/payload.js +137 -0
- package/dist/app/composables/preload.d.ts +20 -0
- package/dist/app/composables/preload.js +55 -0
- package/dist/app/composables/preview.d.ts +38 -0
- package/dist/app/composables/preview.js +61 -0
- package/dist/app/composables/ready.d.ts +2 -0
- package/dist/app/composables/ready.js +15 -0
- package/dist/app/composables/route-announcer.d.ts +19 -0
- package/dist/app/composables/route-announcer.js +55 -0
- package/dist/app/composables/router.d.ts +96 -0
- package/dist/app/composables/router.js +197 -0
- package/dist/app/composables/runtime-hook.d.ts +9 -0
- package/dist/app/composables/runtime-hook.js +7 -0
- package/dist/app/composables/script-stubs.d.ts +32 -0
- package/dist/app/composables/script-stubs.js +104 -0
- package/dist/app/composables/ssr.d.ts +33 -0
- package/dist/app/composables/ssr.js +113 -0
- package/dist/app/composables/state.d.ts +11 -0
- package/dist/app/composables/state.js +40 -0
- package/dist/app/composables/url.d.ts +3 -0
- package/dist/app/composables/url.js +8 -0
- package/dist/app/config.d.ts +14 -0
- package/dist/app/config.js +72 -0
- package/dist/app/entry-spa.d.ts +2 -0
- package/dist/app/entry-spa.js +2 -0
- package/dist/app/entry.async.d.ts +3 -0
- package/dist/app/entry.async.js +5 -0
- package/dist/app/entry.d.ts +7 -0
- package/dist/app/entry.js +78 -0
- package/dist/app/index.d.ts +12 -0
- package/dist/app/index.js +8 -0
- package/dist/app/middleware/manifest-route-rule.d.ts +2 -0
- package/dist/app/middleware/manifest-route-rule.js +17 -0
- package/dist/app/nuxt.d.ts +271 -0
- package/dist/app/nuxt.js +279 -0
- package/dist/app/plugins/browser-devtools-timing.client.d.ts +2 -0
- package/dist/app/plugins/browser-devtools-timing.client.js +23 -0
- package/dist/app/plugins/check-if-layout-used.d.ts +2 -0
- package/dist/app/plugins/check-if-layout-used.js +28 -0
- package/dist/app/plugins/check-outdated-build.client.d.ts +2 -0
- package/dist/app/plugins/check-outdated-build.client.js +39 -0
- package/dist/app/plugins/chunk-reload-immediate.client.d.ts +2 -0
- package/dist/app/plugins/chunk-reload-immediate.client.js +20 -0
- package/dist/app/plugins/chunk-reload.client.d.ts +2 -0
- package/dist/app/plugins/chunk-reload.client.js +30 -0
- package/dist/app/plugins/cross-origin-prefetch.client.d.ts +2 -0
- package/dist/app/plugins/cross-origin-prefetch.client.js +37 -0
- package/dist/app/plugins/debug-hooks.d.ts +2 -0
- package/dist/app/plugins/debug-hooks.js +9 -0
- package/dist/app/plugins/dev-server-logs.d.ts +2 -0
- package/dist/app/plugins/dev-server-logs.js +60 -0
- package/dist/app/plugins/navigation-repaint.client.d.ts +2 -0
- package/dist/app/plugins/navigation-repaint.client.js +16 -0
- package/dist/app/plugins/payload.client.d.ts +2 -0
- package/dist/app/plugins/payload.client.js +50 -0
- package/dist/app/plugins/preload.server.d.ts +2 -0
- package/dist/app/plugins/preload.server.js +13 -0
- package/dist/app/plugins/restore-state.client.d.ts +2 -0
- package/dist/app/plugins/restore-state.client.js +18 -0
- package/dist/app/plugins/revive-payload.client.d.ts +2 -0
- package/dist/app/plugins/revive-payload.client.js +44 -0
- package/dist/app/plugins/revive-payload.server.d.ts +2 -0
- package/dist/app/plugins/revive-payload.server.js +26 -0
- package/dist/app/plugins/router.d.ts +59 -0
- package/dist/app/plugins/router.js +222 -0
- package/dist/app/plugins/utils.d.ts +1 -0
- package/dist/app/plugins/utils.js +4 -0
- package/dist/app/plugins/view-transitions.client.d.ts +2 -0
- package/dist/app/plugins/view-transitions.client.js +55 -0
- package/dist/app/plugins/warn.dev.server.d.ts +2 -0
- package/dist/app/plugins/warn.dev.server.js +6 -0
- package/dist/app/types/augments.d.ts +49 -0
- package/dist/app/types/augments.js +0 -0
- package/dist/app/types.d.ts +39 -0
- package/dist/app/types.js +0 -0
- package/dist/app/utils.d.ts +13 -0
- package/dist/app/utils.js +34 -0
- package/dist/components/runtime/client-component.d.ts +2 -0
- package/dist/components/runtime/client-component.js +59 -0
- package/dist/components/runtime/lazy-hydrated-component.d.ts +124 -0
- package/dist/components/runtime/lazy-hydrated-component.js +101 -0
- package/dist/components/runtime/server-component.d.ts +20 -0
- package/dist/components/runtime/server-component.js +69 -0
- package/dist/head/runtime/components.d.ts +1058 -0
- package/dist/head/runtime/components.js +297 -0
- package/dist/head/runtime/composables.d.ts +25 -0
- package/dist/head/runtime/composables.js +47 -0
- package/dist/head/runtime/plugins/unhead.d.ts +2 -0
- package/dist/head/runtime/plugins/unhead.js +31 -0
- package/dist/head/runtime/types.d.ts +7 -0
- package/dist/head/runtime/types.js +0 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +6974 -0
- package/dist/pages/runtime/app.d.vue.ts +3 -0
- package/dist/pages/runtime/app.vue +6 -0
- package/dist/pages/runtime/app.vue.d.ts +3 -0
- package/dist/pages/runtime/component-stub.d.ts +2 -0
- package/dist/pages/runtime/component-stub.js +1 -0
- package/dist/pages/runtime/composables.d.ts +58 -0
- package/dist/pages/runtime/composables.js +24 -0
- package/dist/pages/runtime/index.d.ts +3 -0
- package/dist/pages/runtime/index.js +1 -0
- package/dist/pages/runtime/page-placeholder.d.ts +4 -0
- package/dist/pages/runtime/page-placeholder.js +11 -0
- package/dist/pages/runtime/page.d.ts +30 -0
- package/dist/pages/runtime/page.js +212 -0
- package/dist/pages/runtime/plugins/check-if-page-unused.d.ts +2 -0
- package/dist/pages/runtime/plugins/check-if-page-unused.js +29 -0
- package/dist/pages/runtime/plugins/prefetch.client.d.ts +2 -0
- package/dist/pages/runtime/plugins/prefetch.client.js +41 -0
- package/dist/pages/runtime/plugins/prerender.server.d.ts +2 -0
- package/dist/pages/runtime/plugins/prerender.server.js +47 -0
- package/dist/pages/runtime/plugins/router.d.ts +6 -0
- package/dist/pages/runtime/plugins/router.js +236 -0
- package/dist/pages/runtime/router.options.d.ts +3 -0
- package/dist/pages/runtime/router.options.js +60 -0
- package/dist/pages/runtime/utils.d.ts +11 -0
- package/dist/pages/runtime/utils.js +18 -0
- package/dist/pages/runtime/validate.d.ts +2 -0
- package/dist/pages/runtime/validate.js +23 -0
- package/kit.d.ts +1 -0
- package/kit.js +1 -0
- package/package.json +156 -0
- package/schema.d.ts +1 -0
- package/schema.js +1 -0
- package/types.d.mts +14 -0
- package/types.d.ts +14 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { KeepAliveProps, TransitionProps, UnwrapRef } from 'vue';
|
|
2
|
+
import type { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteRecordRaw, RouteRecordRedirectOption } from 'vue-router';
|
|
3
|
+
import type { NitroRouteConfig } from 'nitropack/types';
|
|
4
|
+
import type { NuxtError } from 'nuxt/app';
|
|
5
|
+
export interface PageMeta {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
/**
|
|
8
|
+
* Validate whether a given route can validly be rendered with this page.
|
|
9
|
+
*
|
|
10
|
+
* Return true if it is valid, or false if not. If another match can't be found,
|
|
11
|
+
* this will mean a 404. You can also directly return an object with
|
|
12
|
+
* statusCode/statusMessage to respond immediately with an error (other matches
|
|
13
|
+
* will not be checked).
|
|
14
|
+
*/
|
|
15
|
+
validate?: (route: RouteLocationNormalized) => boolean | Partial<NuxtError> | Promise<boolean | Partial<NuxtError>>;
|
|
16
|
+
/**
|
|
17
|
+
* Where to redirect if the route is directly matched. The redirection happens
|
|
18
|
+
* before any navigation guard and triggers a new navigation with the new
|
|
19
|
+
* target location.
|
|
20
|
+
*/
|
|
21
|
+
redirect?: RouteRecordRedirectOption;
|
|
22
|
+
/**
|
|
23
|
+
* Aliases for the record. Allows defining extra paths that will behave like a
|
|
24
|
+
* copy of the record. Allows having paths shorthands like `/users/:id` and
|
|
25
|
+
* `/u/:id`. All `alias` and `path` values must share the same params.
|
|
26
|
+
*/
|
|
27
|
+
alias?: string | string[];
|
|
28
|
+
pageTransition?: boolean | TransitionProps;
|
|
29
|
+
layoutTransition?: boolean | TransitionProps;
|
|
30
|
+
key?: false | string | ((route: RouteLocationNormalizedLoaded) => string);
|
|
31
|
+
keepalive?: boolean | KeepAliveProps;
|
|
32
|
+
/** You may define a name for this page's route. */
|
|
33
|
+
name?: string;
|
|
34
|
+
/** You may define a path matcher, if you have a more complex pattern than can be expressed with the file name. */
|
|
35
|
+
path?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Allows accessing the route `params` as props passed to the page component.
|
|
38
|
+
* @see https://router.vuejs.org/guide/essentials/passing-props
|
|
39
|
+
*/
|
|
40
|
+
props?: RouteRecordRaw['props'];
|
|
41
|
+
/** Set to `false` to avoid scrolling to top on page navigations */
|
|
42
|
+
scrollToTop?: boolean | ((to: RouteLocationNormalizedLoaded, from: RouteLocationNormalizedLoaded) => boolean);
|
|
43
|
+
}
|
|
44
|
+
declare module 'vue-router' {
|
|
45
|
+
interface RouteMeta extends UnwrapRef<PageMeta> {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export declare const definePageMeta: (meta: PageMeta) => void;
|
|
49
|
+
/**
|
|
50
|
+
* You can define route rules for the current page. Matching route rules will be created, based on the page's _path_.
|
|
51
|
+
*
|
|
52
|
+
* For example, a rule defined in `~/pages/foo/bar.vue` will be applied to `/foo/bar` requests. A rule in
|
|
53
|
+
* `~/pages/foo/[id].vue` will be applied to `/foo/**` requests.
|
|
54
|
+
*
|
|
55
|
+
* For more control, such as if you are using a custom `path` or `alias` set in the page's `definePageMeta`, you
|
|
56
|
+
* should set `routeRules` directly within your `nuxt.config`.
|
|
57
|
+
*/
|
|
58
|
+
export declare const defineRouteRules: (rules: NitroRouteConfig) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getCurrentInstance } from "vue";
|
|
2
|
+
import { useRoute } from "vue-router";
|
|
3
|
+
import { useNuxtApp } from "#app/nuxt";
|
|
4
|
+
const warnRuntimeUsage = (method) => {
|
|
5
|
+
console.warn(
|
|
6
|
+
`${method}() is a compiler-hint helper that is only usable inside the script block of a single file component which is also a page. Its arguments should be compiled away and passing it at runtime has no effect.`
|
|
7
|
+
);
|
|
8
|
+
};
|
|
9
|
+
export const definePageMeta = (meta) => {
|
|
10
|
+
if (import.meta.dev) {
|
|
11
|
+
const component = getCurrentInstance()?.type;
|
|
12
|
+
try {
|
|
13
|
+
const isRouteComponent = component && useRoute().matched.some((p) => Object.values(p.components || {}).includes(component));
|
|
14
|
+
const isRenderingServerPage = import.meta.server && useNuxtApp().ssrContext?.islandContext;
|
|
15
|
+
if (isRouteComponent || isRenderingServerPage || component?.__clientOnlyPage) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
warnRuntimeUsage("definePageMeta");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const defineRouteRules = /* @__NO_SIDE_EFFECTS__ */ (rules) => {
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePageMeta, defineRouteRules } from "./composables.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineComponent } from "vue";
|
|
2
|
+
import { devPagesDir } from "#build/nuxt.config.mjs";
|
|
3
|
+
export default defineComponent({
|
|
4
|
+
name: "NuxtPage",
|
|
5
|
+
setup(_, props) {
|
|
6
|
+
if (import.meta.dev) {
|
|
7
|
+
console.warn(`Create a Vue component in the \`${devPagesDir}/\` directory to enable \`<NuxtPage>\``);
|
|
8
|
+
}
|
|
9
|
+
return () => props.slots.default?.();
|
|
10
|
+
}
|
|
11
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AllowedComponentProps, ComponentCustomProps, ComponentPublicInstance, KeepAliveProps, TransitionProps, VNode, VNodeProps } from 'vue';
|
|
2
|
+
import type { RouteLocationNormalizedLoaded, RouterViewProps } from 'vue-router';
|
|
3
|
+
import type { RouterViewSlotProps } from './utils.js';
|
|
4
|
+
export interface NuxtPageProps extends RouterViewProps {
|
|
5
|
+
/**
|
|
6
|
+
* Define global transitions for all pages rendered with the `NuxtPage` component.
|
|
7
|
+
*/
|
|
8
|
+
transition?: boolean | TransitionProps;
|
|
9
|
+
/**
|
|
10
|
+
* Control state preservation of pages rendered with the `NuxtPage` component.
|
|
11
|
+
*/
|
|
12
|
+
keepalive?: boolean | KeepAliveProps;
|
|
13
|
+
/**
|
|
14
|
+
* Control when the `NuxtPage` component is re-rendered.
|
|
15
|
+
*/
|
|
16
|
+
pageKey?: string | ((route: RouteLocationNormalizedLoaded) => string);
|
|
17
|
+
}
|
|
18
|
+
declare const _default: {
|
|
19
|
+
new (): {
|
|
20
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & NuxtPageProps;
|
|
21
|
+
$slots: {
|
|
22
|
+
default?: (routeProps: RouterViewSlotProps) => VNode[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Reference to the page component instance
|
|
26
|
+
*/
|
|
27
|
+
pageRef: Element | ComponentPublicInstance | null;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Fragment, Suspense, defineComponent, h, inject, nextTick, onBeforeUnmount, ref, watch } from "vue";
|
|
2
|
+
import { RouterView } from "vue-router";
|
|
3
|
+
import { defu } from "defu";
|
|
4
|
+
import { generateRouteKey, toArray, wrapInKeepAlive } from "./utils.js";
|
|
5
|
+
import { RouteProvider, defineRouteProvider } from "#app/components/route-provider";
|
|
6
|
+
import { useNuxtApp } from "#app/nuxt";
|
|
7
|
+
import { useRouter } from "#app/composables/router";
|
|
8
|
+
import { _wrapInTransition } from "#app/components/utils";
|
|
9
|
+
import { LayoutMetaSymbol, PageRouteSymbol } from "#app/components/injections";
|
|
10
|
+
import { appKeepalive as defaultKeepaliveConfig, appPageTransition as defaultPageTransition } from "#build/nuxt.config.mjs";
|
|
11
|
+
const _routeProviders = import.meta.dev ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new WeakMap();
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
name: "NuxtPage",
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
props: {
|
|
16
|
+
name: {
|
|
17
|
+
type: String
|
|
18
|
+
},
|
|
19
|
+
transition: {
|
|
20
|
+
type: [Boolean, Object],
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
keepalive: {
|
|
24
|
+
type: [Boolean, Object],
|
|
25
|
+
default: void 0
|
|
26
|
+
},
|
|
27
|
+
route: {
|
|
28
|
+
type: Object
|
|
29
|
+
},
|
|
30
|
+
pageKey: {
|
|
31
|
+
type: [Function, String],
|
|
32
|
+
default: null
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
setup(props, { attrs, slots, expose }) {
|
|
36
|
+
const nuxtApp = useNuxtApp();
|
|
37
|
+
const pageRef = ref();
|
|
38
|
+
const forkRoute = inject(PageRouteSymbol, null);
|
|
39
|
+
let previousPageKey;
|
|
40
|
+
expose({ pageRef });
|
|
41
|
+
const _layoutMeta = inject(LayoutMetaSymbol, null);
|
|
42
|
+
let vnode;
|
|
43
|
+
const done = nuxtApp.deferHydration();
|
|
44
|
+
if (import.meta.client && nuxtApp.isHydrating) {
|
|
45
|
+
const removeErrorHook = nuxtApp.hooks.hookOnce("app:error", done);
|
|
46
|
+
useRouter().beforeEach(removeErrorHook);
|
|
47
|
+
}
|
|
48
|
+
if (import.meta.client && props.pageKey) {
|
|
49
|
+
watch(() => props.pageKey, (next, prev) => {
|
|
50
|
+
if (next !== prev) {
|
|
51
|
+
nuxtApp.callHook("page:loading:start");
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (import.meta.dev) {
|
|
56
|
+
nuxtApp._isNuxtPageUsed = true;
|
|
57
|
+
}
|
|
58
|
+
let pageLoadingEndHookAlreadyCalled = false;
|
|
59
|
+
if (import.meta.client) {
|
|
60
|
+
const unsub = useRouter().beforeResolve(() => {
|
|
61
|
+
pageLoadingEndHookAlreadyCalled = false;
|
|
62
|
+
});
|
|
63
|
+
onBeforeUnmount(() => {
|
|
64
|
+
unsub();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return () => {
|
|
68
|
+
return h(RouterView, { name: props.name, route: props.route, ...attrs }, {
|
|
69
|
+
default: import.meta.server ? (routeProps) => {
|
|
70
|
+
return h(Suspense, { suspensible: true }, {
|
|
71
|
+
default() {
|
|
72
|
+
return h(RouteProvider, {
|
|
73
|
+
vnode: slots.default ? normalizeSlot(slots.default, routeProps) : routeProps.Component,
|
|
74
|
+
route: routeProps.route,
|
|
75
|
+
vnodeRef: pageRef
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} : (routeProps) => {
|
|
80
|
+
const isRenderingNewRouteInOldFork = haveParentRoutesRendered(forkRoute, routeProps.route, routeProps.Component);
|
|
81
|
+
const hasSameChildren = forkRoute && forkRoute.matched.length === routeProps.route.matched.length;
|
|
82
|
+
if (!routeProps.Component) {
|
|
83
|
+
if (vnode && !hasSameChildren) {
|
|
84
|
+
return vnode;
|
|
85
|
+
}
|
|
86
|
+
done();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (vnode && _layoutMeta && !_layoutMeta.isCurrent(routeProps.route)) {
|
|
90
|
+
return vnode;
|
|
91
|
+
}
|
|
92
|
+
if (isRenderingNewRouteInOldFork && forkRoute && (!_layoutMeta || _layoutMeta?.isCurrent(forkRoute))) {
|
|
93
|
+
if (hasSameChildren) {
|
|
94
|
+
return vnode;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const key = generateRouteKey(routeProps, props.pageKey);
|
|
99
|
+
const willRenderAnotherChild = hasChildrenRoutes(forkRoute, routeProps.route, routeProps.Component);
|
|
100
|
+
if (!nuxtApp.isHydrating && previousPageKey === key && !willRenderAnotherChild) {
|
|
101
|
+
nextTick(() => {
|
|
102
|
+
pageLoadingEndHookAlreadyCalled = true;
|
|
103
|
+
nuxtApp.callHook("page:loading:end");
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
previousPageKey = key;
|
|
107
|
+
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition);
|
|
108
|
+
const transitionProps = hasTransition && _mergeTransitionProps([
|
|
109
|
+
props.transition,
|
|
110
|
+
routeProps.route.meta.pageTransition,
|
|
111
|
+
defaultPageTransition,
|
|
112
|
+
{
|
|
113
|
+
onAfterLeave() {
|
|
114
|
+
delete nuxtApp._runningTransition;
|
|
115
|
+
nuxtApp.callHook("page:transition:finish", routeProps.Component);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]);
|
|
119
|
+
const keepaliveConfig = props.keepalive ?? routeProps.route.meta.keepalive ?? defaultKeepaliveConfig;
|
|
120
|
+
vnode = _wrapInTransition(
|
|
121
|
+
hasTransition && transitionProps,
|
|
122
|
+
wrapInKeepAlive(
|
|
123
|
+
keepaliveConfig,
|
|
124
|
+
h(Suspense, {
|
|
125
|
+
suspensible: true,
|
|
126
|
+
onPending: () => {
|
|
127
|
+
if (hasTransition) {
|
|
128
|
+
nuxtApp._runningTransition = true;
|
|
129
|
+
}
|
|
130
|
+
nuxtApp.callHook("page:start", routeProps.Component);
|
|
131
|
+
},
|
|
132
|
+
onResolve: async () => {
|
|
133
|
+
await nextTick();
|
|
134
|
+
try {
|
|
135
|
+
nuxtApp._route.sync?.();
|
|
136
|
+
await nuxtApp.callHook("page:finish", routeProps.Component);
|
|
137
|
+
delete nuxtApp._runningTransition;
|
|
138
|
+
if (!pageLoadingEndHookAlreadyCalled && !willRenderAnotherChild) {
|
|
139
|
+
pageLoadingEndHookAlreadyCalled = true;
|
|
140
|
+
await nuxtApp.callHook("page:loading:end");
|
|
141
|
+
}
|
|
142
|
+
} finally {
|
|
143
|
+
done();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
default: () => {
|
|
148
|
+
const routeProviderProps = {
|
|
149
|
+
key: key || void 0,
|
|
150
|
+
vnode: slots.default ? normalizeSlot(slots.default, routeProps) : routeProps.Component,
|
|
151
|
+
route: routeProps.route,
|
|
152
|
+
renderKey: key || void 0,
|
|
153
|
+
trackRootNodes: hasTransition,
|
|
154
|
+
vnodeRef: pageRef
|
|
155
|
+
};
|
|
156
|
+
if (!keepaliveConfig) {
|
|
157
|
+
return h(RouteProvider, routeProviderProps);
|
|
158
|
+
}
|
|
159
|
+
const routerComponentType = routeProps.Component.type;
|
|
160
|
+
const routeProviderKey = import.meta.dev ? routerComponentType.name || routerComponentType.__name : routerComponentType;
|
|
161
|
+
let PageRouteProvider = _routeProviders.get(routeProviderKey);
|
|
162
|
+
if (!PageRouteProvider) {
|
|
163
|
+
PageRouteProvider = defineRouteProvider(routerComponentType.name || routerComponentType.__name);
|
|
164
|
+
_routeProviders.set(routeProviderKey, PageRouteProvider);
|
|
165
|
+
}
|
|
166
|
+
return h(PageRouteProvider, routeProviderProps);
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
)
|
|
170
|
+
).default();
|
|
171
|
+
return vnode;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
function _mergeTransitionProps(routeProps) {
|
|
178
|
+
const _props = [];
|
|
179
|
+
for (const prop of routeProps) {
|
|
180
|
+
if (!prop) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
_props.push({
|
|
184
|
+
...prop,
|
|
185
|
+
onAfterLeave: prop.onAfterLeave ? toArray(prop.onAfterLeave) : void 0
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return defu(..._props);
|
|
189
|
+
}
|
|
190
|
+
function haveParentRoutesRendered(fork, newRoute, Component) {
|
|
191
|
+
if (!fork) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
const index = newRoute.matched.findIndex((m) => m.components?.default === Component?.type);
|
|
195
|
+
if (!index || index === -1) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return newRoute.matched.slice(0, index).some(
|
|
199
|
+
(c, i) => c.components?.default !== fork.matched[i]?.components?.default
|
|
200
|
+
) || Component && generateRouteKey({ route: newRoute, Component }) !== generateRouteKey({ route: fork, Component });
|
|
201
|
+
}
|
|
202
|
+
function hasChildrenRoutes(fork, newRoute, Component) {
|
|
203
|
+
if (!fork) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
const index = newRoute.matched.findIndex((m) => m.components?.default === Component?.type);
|
|
207
|
+
return index < newRoute.matched.length - 1;
|
|
208
|
+
}
|
|
209
|
+
function normalizeSlot(slot, data) {
|
|
210
|
+
const slotContent = slot(data);
|
|
211
|
+
return slotContent.length === 1 ? h(slotContent[0]) : h(Fragment, void 0, slotContent);
|
|
212
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { nextTick } from "vue";
|
|
2
|
+
import { defineNuxtPlugin } from "#app/nuxt";
|
|
3
|
+
import { onNuxtReady } from "#app/composables/ready";
|
|
4
|
+
import { useError } from "#app/composables/error";
|
|
5
|
+
export default defineNuxtPlugin({
|
|
6
|
+
name: "nuxt:checkIfPageUnused",
|
|
7
|
+
setup(nuxtApp) {
|
|
8
|
+
const error = useError();
|
|
9
|
+
function checkIfPageUnused() {
|
|
10
|
+
if (!error.value && !nuxtApp._isNuxtPageUsed) {
|
|
11
|
+
console.warn(
|
|
12
|
+
"[nuxt] Your project has pages but the `<NuxtPage />` component has not been used. You might be using the `<RouterView />` component instead, which will not work correctly in Nuxt. You can set `pages: false` in `nuxt.config` if you do not wish to use the Nuxt `vue-router` integration."
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (import.meta.server) {
|
|
17
|
+
nuxtApp.hook("app:rendered", ({ renderResult }) => {
|
|
18
|
+
if (renderResult?.html) {
|
|
19
|
+
nextTick(checkIfPageUnused);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
onNuxtReady(checkIfPageUnused);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
env: {
|
|
27
|
+
islands: false
|
|
28
|
+
}
|
|
29
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { hasProtocol } from "ufo";
|
|
2
|
+
import { toArray } from "../utils.js";
|
|
3
|
+
import { defineNuxtPlugin } from "#app/nuxt";
|
|
4
|
+
import { useRouter } from "#app/composables/router";
|
|
5
|
+
import layouts from "#build/layouts";
|
|
6
|
+
import { namedMiddleware } from "#build/middleware";
|
|
7
|
+
import { _loadAsyncComponent } from "#app/composables/preload";
|
|
8
|
+
export default defineNuxtPlugin({
|
|
9
|
+
name: "nuxt:prefetch",
|
|
10
|
+
setup(nuxtApp) {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
nuxtApp.hooks.hook("app:mounted", () => {
|
|
13
|
+
router.beforeEach(async (to) => {
|
|
14
|
+
const layout = to?.meta?.layout;
|
|
15
|
+
if (layout && typeof layouts[layout] === "function") {
|
|
16
|
+
await layouts[layout]();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
nuxtApp.hooks.hook("link:prefetch", (url) => {
|
|
21
|
+
if (hasProtocol(url)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const route = router.resolve(url);
|
|
25
|
+
if (!route) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const layout = route.meta.layout;
|
|
29
|
+
let middleware = toArray(route.meta.middleware);
|
|
30
|
+
middleware = middleware.filter((m) => typeof m === "string");
|
|
31
|
+
for (const name of middleware) {
|
|
32
|
+
if (typeof namedMiddleware[name] === "function") {
|
|
33
|
+
namedMiddleware[name]();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (typeof layout === "string" && layout in layouts) {
|
|
37
|
+
_loadAsyncComponent(layouts[layout]);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { joinURL } from "ufo";
|
|
2
|
+
import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
3
|
+
import defu from "defu";
|
|
4
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#app/nuxt";
|
|
5
|
+
import { prerenderRoutes } from "#app/composables/ssr";
|
|
6
|
+
import _routes from "#build/routes";
|
|
7
|
+
import routerOptions, { hashMode } from "#build/router.options";
|
|
8
|
+
import { crawlLinks } from "#build/nuxt.config.mjs";
|
|
9
|
+
let routes;
|
|
10
|
+
let _routeRulesMatcher = void 0;
|
|
11
|
+
export default defineNuxtPlugin(async () => {
|
|
12
|
+
if (!import.meta.server || !import.meta.prerender || hashMode) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (routes && !routes.length) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const routeRules = useRuntimeConfig().nitro.routeRules;
|
|
19
|
+
if (!crawlLinks && routeRules && Object.values(routeRules).some((r) => r.prerender)) {
|
|
20
|
+
_routeRulesMatcher = toRouteMatcher(createRadixRouter({ routes: routeRules }));
|
|
21
|
+
}
|
|
22
|
+
routes ||= Array.from(processRoutes(await routerOptions.routes?.(_routes) ?? _routes));
|
|
23
|
+
const batch = routes.splice(0, 10);
|
|
24
|
+
prerenderRoutes(batch);
|
|
25
|
+
});
|
|
26
|
+
const OPTIONAL_PARAM_RE = /^\/?:.*(?:\?|\(\.\*\)\*)$/;
|
|
27
|
+
function shouldPrerender(path) {
|
|
28
|
+
return !_routeRulesMatcher || defu({}, ..._routeRulesMatcher.matchAll(path).reverse()).prerender;
|
|
29
|
+
}
|
|
30
|
+
function processRoutes(routes2, currentPath = "/", routesToPrerender = /* @__PURE__ */ new Set()) {
|
|
31
|
+
for (const route of routes2) {
|
|
32
|
+
if (OPTIONAL_PARAM_RE.test(route.path) && !route.children?.length && shouldPrerender(currentPath)) {
|
|
33
|
+
routesToPrerender.add(currentPath);
|
|
34
|
+
}
|
|
35
|
+
if (route.path.includes(":")) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const fullPath = joinURL(currentPath, route.path);
|
|
39
|
+
if (shouldPrerender(fullPath)) {
|
|
40
|
+
routesToPrerender.add(fullPath);
|
|
41
|
+
}
|
|
42
|
+
if (route.children) {
|
|
43
|
+
processRoutes(route.children, fullPath, routesToPrerender);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return routesToPrerender;
|
|
47
|
+
}
|