@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,142 @@
|
|
|
1
|
+
import { computed, getCurrentScope, onScopeDispose, shallowRef } from "vue";
|
|
2
|
+
import { useNuxtApp } from "../nuxt.js";
|
|
3
|
+
function defaultEstimatedProgress(duration, elapsed) {
|
|
4
|
+
const completionPercentage = elapsed / duration * 100;
|
|
5
|
+
return 2 / Math.PI * 100 * Math.atan(completionPercentage / 50);
|
|
6
|
+
}
|
|
7
|
+
function createLoadingIndicator(opts = {}) {
|
|
8
|
+
const { duration = 2e3, throttle = 200, hideDelay = 500, resetDelay = 400 } = opts;
|
|
9
|
+
const getProgress = opts.estimatedProgress || defaultEstimatedProgress;
|
|
10
|
+
const nuxtApp = useNuxtApp();
|
|
11
|
+
const progress = shallowRef(0);
|
|
12
|
+
const isLoading = shallowRef(false);
|
|
13
|
+
const error = shallowRef(false);
|
|
14
|
+
let done = false;
|
|
15
|
+
let rafId;
|
|
16
|
+
let throttleTimeout;
|
|
17
|
+
let hideTimeout;
|
|
18
|
+
let resetTimeout;
|
|
19
|
+
const start = (opts2 = {}) => {
|
|
20
|
+
_clearTimeouts();
|
|
21
|
+
error.value = false;
|
|
22
|
+
set(0, opts2);
|
|
23
|
+
};
|
|
24
|
+
function set(at = 0, opts2 = {}) {
|
|
25
|
+
if (nuxtApp.isHydrating) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (at >= 100) {
|
|
29
|
+
return finish({ force: opts2.force });
|
|
30
|
+
}
|
|
31
|
+
clear();
|
|
32
|
+
progress.value = at < 0 ? 0 : at;
|
|
33
|
+
const throttleTime = opts2.force ? 0 : throttle;
|
|
34
|
+
if (throttleTime && import.meta.client) {
|
|
35
|
+
throttleTimeout = setTimeout(() => {
|
|
36
|
+
isLoading.value = true;
|
|
37
|
+
_startProgress();
|
|
38
|
+
}, throttleTime);
|
|
39
|
+
} else {
|
|
40
|
+
isLoading.value = true;
|
|
41
|
+
_startProgress();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _hide() {
|
|
45
|
+
if (import.meta.client) {
|
|
46
|
+
hideTimeout = setTimeout(() => {
|
|
47
|
+
isLoading.value = false;
|
|
48
|
+
resetTimeout = setTimeout(() => {
|
|
49
|
+
progress.value = 0;
|
|
50
|
+
}, resetDelay);
|
|
51
|
+
}, hideDelay);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function finish(opts2 = {}) {
|
|
55
|
+
progress.value = 100;
|
|
56
|
+
done = true;
|
|
57
|
+
clear();
|
|
58
|
+
_clearTimeouts();
|
|
59
|
+
if (opts2.error) {
|
|
60
|
+
error.value = true;
|
|
61
|
+
}
|
|
62
|
+
if (opts2.force) {
|
|
63
|
+
progress.value = 0;
|
|
64
|
+
isLoading.value = false;
|
|
65
|
+
} else {
|
|
66
|
+
_hide();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function _clearTimeouts() {
|
|
70
|
+
if (import.meta.client) {
|
|
71
|
+
clearTimeout(hideTimeout);
|
|
72
|
+
clearTimeout(resetTimeout);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function clear() {
|
|
76
|
+
if (import.meta.client) {
|
|
77
|
+
clearTimeout(throttleTimeout);
|
|
78
|
+
cancelAnimationFrame(rafId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function _startProgress() {
|
|
82
|
+
done = false;
|
|
83
|
+
let startTimeStamp;
|
|
84
|
+
function step(timeStamp) {
|
|
85
|
+
if (done) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
startTimeStamp ??= timeStamp;
|
|
89
|
+
const elapsed = timeStamp - startTimeStamp;
|
|
90
|
+
progress.value = Math.max(0, Math.min(100, getProgress(duration, elapsed)));
|
|
91
|
+
if (import.meta.client) {
|
|
92
|
+
rafId = requestAnimationFrame(step);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (import.meta.client) {
|
|
96
|
+
rafId = requestAnimationFrame(step);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
let _cleanup = () => {
|
|
100
|
+
};
|
|
101
|
+
if (import.meta.client) {
|
|
102
|
+
const unsubLoadingStartHook = nuxtApp.hook("page:loading:start", () => {
|
|
103
|
+
start();
|
|
104
|
+
});
|
|
105
|
+
const unsubLoadingFinishHook = nuxtApp.hook("page:loading:end", () => {
|
|
106
|
+
finish();
|
|
107
|
+
});
|
|
108
|
+
const unsubError = nuxtApp.hook("vue:error", () => finish());
|
|
109
|
+
_cleanup = () => {
|
|
110
|
+
unsubError();
|
|
111
|
+
unsubLoadingStartHook();
|
|
112
|
+
unsubLoadingFinishHook();
|
|
113
|
+
clear();
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
_cleanup,
|
|
118
|
+
progress: computed(() => progress.value),
|
|
119
|
+
isLoading: computed(() => isLoading.value),
|
|
120
|
+
error: computed(() => error.value),
|
|
121
|
+
start,
|
|
122
|
+
set,
|
|
123
|
+
finish,
|
|
124
|
+
clear
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export function useLoadingIndicator(opts = {}) {
|
|
128
|
+
const nuxtApp = useNuxtApp();
|
|
129
|
+
const indicator = nuxtApp._loadingIndicator ||= createLoadingIndicator(opts);
|
|
130
|
+
if (import.meta.client && getCurrentScope()) {
|
|
131
|
+
nuxtApp._loadingIndicatorDeps ||= 0;
|
|
132
|
+
nuxtApp._loadingIndicatorDeps++;
|
|
133
|
+
onScopeDispose(() => {
|
|
134
|
+
nuxtApp._loadingIndicatorDeps--;
|
|
135
|
+
if (nuxtApp._loadingIndicatorDeps === 0) {
|
|
136
|
+
indicator._cleanup();
|
|
137
|
+
delete nuxtApp._loadingIndicator;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return indicator;
|
|
142
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MatcherExport } from 'radix3';
|
|
2
|
+
import type { H3Event } from 'h3';
|
|
3
|
+
import type { NitroRouteRules } from 'nitropack/types';
|
|
4
|
+
export interface NuxtAppManifestMeta {
|
|
5
|
+
id: string;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
}
|
|
8
|
+
export interface NuxtAppManifest extends NuxtAppManifestMeta {
|
|
9
|
+
matcher: MatcherExport;
|
|
10
|
+
prerendered: string[];
|
|
11
|
+
}
|
|
12
|
+
/** @since 3.7.4 */
|
|
13
|
+
export declare function getAppManifest(): Promise<NuxtAppManifest>;
|
|
14
|
+
/** @since 3.7.4 */
|
|
15
|
+
export declare function getRouteRules(event: H3Event): Promise<NitroRouteRules>;
|
|
16
|
+
export declare function getRouteRules(options: {
|
|
17
|
+
path: string;
|
|
18
|
+
}): Promise<Record<string, any>>;
|
|
19
|
+
/** @deprecated use `getRouteRules({ path })` instead */
|
|
20
|
+
export declare function getRouteRules(url: string): Promise<Record<string, any>>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createMatcherFromExport, createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
2
|
+
import { defu } from "defu";
|
|
3
|
+
import { useNuxtApp, useRuntimeConfig } from "../nuxt.js";
|
|
4
|
+
import { appManifest as isAppManifestEnabled } from "#build/nuxt.config.mjs";
|
|
5
|
+
import { buildAssetsURL } from "#internal/nuxt/paths";
|
|
6
|
+
let manifest;
|
|
7
|
+
let matcher;
|
|
8
|
+
function fetchManifest() {
|
|
9
|
+
if (!isAppManifestEnabled) {
|
|
10
|
+
throw new Error("[nuxt] app manifest should be enabled with `experimental.appManifest`");
|
|
11
|
+
}
|
|
12
|
+
if (import.meta.server) {
|
|
13
|
+
manifest = import(
|
|
14
|
+
/* webpackIgnore: true */
|
|
15
|
+
/* @vite-ignore */
|
|
16
|
+
"#app-manifest"
|
|
17
|
+
);
|
|
18
|
+
} else {
|
|
19
|
+
manifest = $fetch(buildAssetsURL(`builds/meta/${useRuntimeConfig().app.buildId}.json`), {
|
|
20
|
+
responseType: "json"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
manifest.then((m) => {
|
|
24
|
+
matcher = createMatcherFromExport(m.matcher);
|
|
25
|
+
}).catch((e) => {
|
|
26
|
+
console.error("[nuxt] Error fetching app manifest.", e);
|
|
27
|
+
});
|
|
28
|
+
return manifest;
|
|
29
|
+
}
|
|
30
|
+
export function getAppManifest() {
|
|
31
|
+
if (!isAppManifestEnabled) {
|
|
32
|
+
throw new Error("[nuxt] app manifest should be enabled with `experimental.appManifest`");
|
|
33
|
+
}
|
|
34
|
+
if (import.meta.server) {
|
|
35
|
+
useNuxtApp().ssrContext._preloadManifest = true;
|
|
36
|
+
}
|
|
37
|
+
return manifest || fetchManifest();
|
|
38
|
+
}
|
|
39
|
+
export async function getRouteRules(arg) {
|
|
40
|
+
const path = typeof arg === "string" ? arg : arg.path;
|
|
41
|
+
if (import.meta.server) {
|
|
42
|
+
useNuxtApp().ssrContext._preloadManifest = true;
|
|
43
|
+
const _routeRulesMatcher = toRouteMatcher(
|
|
44
|
+
createRadixRouter({ routes: useRuntimeConfig().nitro.routeRules })
|
|
45
|
+
);
|
|
46
|
+
return defu({}, ..._routeRulesMatcher.matchAll(path).reverse());
|
|
47
|
+
}
|
|
48
|
+
await getAppManifest();
|
|
49
|
+
if (!matcher) {
|
|
50
|
+
console.error("[nuxt] Error creating app manifest matcher.", matcher);
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return defu({}, ...matcher.matchAll(path).reverse());
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.error("[nuxt] Error matching route rules.", e);
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type CallOnceOptions = {
|
|
2
|
+
mode?: 'navigation' | 'render';
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* An SSR-friendly utility to call a method once
|
|
6
|
+
* @param key a unique key ensuring the function can be properly de-duplicated across requests
|
|
7
|
+
* @param fn a function to call
|
|
8
|
+
* @param options Setup the mode, e.g. to re-execute on navigation
|
|
9
|
+
* @see https://nuxt.com/docs/4.x/api/utils/call-once
|
|
10
|
+
* @since 3.9.0
|
|
11
|
+
*/
|
|
12
|
+
export declare function callOnce(key?: string, fn?: (() => any | Promise<any>), options?: CallOnceOptions): Promise<void>;
|
|
13
|
+
export declare function callOnce(fn?: (() => any | Promise<any>), options?: CallOnceOptions): Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useRouter } from "./router.js";
|
|
2
|
+
import { useNuxtApp } from "../nuxt.js";
|
|
3
|
+
let _isHmrUpdating = false;
|
|
4
|
+
export async function callOnce(...args) {
|
|
5
|
+
const autoKey = typeof args[args.length - 1] === "string" ? args.pop() : void 0;
|
|
6
|
+
if (typeof args[0] !== "string") {
|
|
7
|
+
args.unshift(autoKey);
|
|
8
|
+
}
|
|
9
|
+
const [_key, fn, options] = args;
|
|
10
|
+
if (!_key || typeof _key !== "string") {
|
|
11
|
+
throw new TypeError("[nuxt] [callOnce] key must be a string: " + _key);
|
|
12
|
+
}
|
|
13
|
+
if (fn !== void 0 && typeof fn !== "function") {
|
|
14
|
+
throw new Error("[nuxt] [callOnce] fn must be a function: " + fn);
|
|
15
|
+
}
|
|
16
|
+
const nuxtApp = useNuxtApp();
|
|
17
|
+
if (options?.mode === "navigation") {
|
|
18
|
+
let callback = function() {
|
|
19
|
+
nuxtApp.payload.once.delete(_key);
|
|
20
|
+
for (const cleanup of cleanups) {
|
|
21
|
+
cleanup();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const cleanups = [];
|
|
25
|
+
cleanups.push(nuxtApp.hooks.hook("page:start", callback), useRouter().beforeResolve(callback));
|
|
26
|
+
}
|
|
27
|
+
if (nuxtApp.payload.once.has(_key)) {
|
|
28
|
+
if (!import.meta.dev || !_isHmrUpdating) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
nuxtApp._once ||= {};
|
|
33
|
+
nuxtApp._once[_key] ||= fn() || true;
|
|
34
|
+
await nuxtApp._once[_key];
|
|
35
|
+
nuxtApp.payload.once.add(_key);
|
|
36
|
+
delete nuxtApp._once[_key];
|
|
37
|
+
}
|
|
38
|
+
if (import.meta.hot) {
|
|
39
|
+
import.meta.hot.on("vite:beforeUpdate", (payload) => {
|
|
40
|
+
if (payload.updates.some((u) => u.type === "js-update")) {
|
|
41
|
+
_isHmrUpdating = true;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
import.meta.hot.on("vite:afterUpdate", (payload) => {
|
|
45
|
+
if (payload.updates.some((u) => u.type === "js-update")) {
|
|
46
|
+
_isHmrUpdating = false;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { NuxtPayload } from '../nuxt.js';
|
|
2
|
+
interface LoadPayloadOptions {
|
|
3
|
+
fresh?: boolean;
|
|
4
|
+
hash?: string;
|
|
5
|
+
}
|
|
6
|
+
/** @since 3.0.0 */
|
|
7
|
+
export declare function loadPayload(url: string, opts?: LoadPayloadOptions): Promise<Record<string, any> | null>;
|
|
8
|
+
/** @since 3.0.0 */
|
|
9
|
+
export declare function preloadPayload(url: string, opts?: LoadPayloadOptions): Promise<void>;
|
|
10
|
+
/** @since 3.0.0 */
|
|
11
|
+
export declare function isPrerendered(url?: string): Promise<boolean>;
|
|
12
|
+
/** @since 3.4.0 */
|
|
13
|
+
export declare function getNuxtClientPayload(): Promise<Partial<NuxtPayload> | null>;
|
|
14
|
+
export declare function parsePayload(payload: string): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* This is an experimental function for configuring passing rich data from server -> client.
|
|
17
|
+
* @since 3.4.0
|
|
18
|
+
*/
|
|
19
|
+
export declare function definePayloadReducer(name: string, reduce: (data: any) => any): void;
|
|
20
|
+
/**
|
|
21
|
+
* This is an experimental function for configuring passing rich data from server -> client.
|
|
22
|
+
*
|
|
23
|
+
* This function _must_ be called in a Nuxt plugin that is `unshift`ed to the beginning of the Nuxt plugins array.
|
|
24
|
+
* @since 3.4.0
|
|
25
|
+
*/
|
|
26
|
+
export declare function definePayloadReviver(name: string, revive: (data: any) => any | undefined): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { hasProtocol, joinURL } from "ufo";
|
|
2
|
+
import { parse } from "devalue";
|
|
3
|
+
import { getCurrentInstance, onServerPrefetch, reactive } from "vue";
|
|
4
|
+
import { useNuxtApp, useRuntimeConfig } from "../nuxt.js";
|
|
5
|
+
import { useHead } from "./head.js";
|
|
6
|
+
import { useRoute } from "./router.js";
|
|
7
|
+
import { getAppManifest, getRouteRules } from "./manifest.js";
|
|
8
|
+
import { appId, appManifest, multiApp, payloadExtraction, renderJsonPayloads } from "#build/nuxt.config.mjs";
|
|
9
|
+
export async function loadPayload(url, opts = {}) {
|
|
10
|
+
if (import.meta.server || !payloadExtraction) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const shouldLoadPayload = await isPrerendered(url);
|
|
14
|
+
if (!shouldLoadPayload) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const payloadURL = await _getPayloadURL(url, opts);
|
|
18
|
+
return await _importPayload(payloadURL) || null;
|
|
19
|
+
}
|
|
20
|
+
let linkRelType;
|
|
21
|
+
function detectLinkRelType() {
|
|
22
|
+
if (import.meta.server) {
|
|
23
|
+
return "preload";
|
|
24
|
+
}
|
|
25
|
+
if (linkRelType) {
|
|
26
|
+
return linkRelType;
|
|
27
|
+
}
|
|
28
|
+
const relList = document.createElement("link").relList;
|
|
29
|
+
linkRelType = relList && relList.supports && relList.supports("prefetch") ? "prefetch" : "preload";
|
|
30
|
+
return linkRelType;
|
|
31
|
+
}
|
|
32
|
+
export function preloadPayload(url, opts = {}) {
|
|
33
|
+
const nuxtApp = useNuxtApp();
|
|
34
|
+
const promise = _getPayloadURL(url, opts).then((payloadURL) => {
|
|
35
|
+
const link = renderJsonPayloads ? { rel: detectLinkRelType(), as: "fetch", crossorigin: "anonymous", href: payloadURL } : { rel: "modulepreload", crossorigin: "", href: payloadURL };
|
|
36
|
+
if (import.meta.server) {
|
|
37
|
+
nuxtApp.runWithContext(() => useHead({ link: [link] }));
|
|
38
|
+
} else {
|
|
39
|
+
const linkEl = document.createElement("link");
|
|
40
|
+
for (const key of Object.keys(link)) {
|
|
41
|
+
linkEl[key === "crossorigin" ? "crossOrigin" : key] = link[key];
|
|
42
|
+
}
|
|
43
|
+
document.head.appendChild(linkEl);
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
linkEl.addEventListener("load", () => resolve());
|
|
46
|
+
linkEl.addEventListener("error", () => reject());
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (import.meta.server) {
|
|
51
|
+
onServerPrefetch(() => promise);
|
|
52
|
+
}
|
|
53
|
+
return promise;
|
|
54
|
+
}
|
|
55
|
+
const filename = renderJsonPayloads ? "_payload.json" : "_payload.js";
|
|
56
|
+
async function _getPayloadURL(url, opts = {}) {
|
|
57
|
+
const u = new URL(url, "http://localhost");
|
|
58
|
+
if (u.host !== "localhost" || hasProtocol(u.pathname, { acceptRelative: true })) {
|
|
59
|
+
throw new Error("Payload URL must not include hostname: " + url);
|
|
60
|
+
}
|
|
61
|
+
const config = useRuntimeConfig();
|
|
62
|
+
const hash = opts.hash || (opts.fresh ? Date.now() : config.app.buildId);
|
|
63
|
+
const cdnURL = config.app.cdnURL;
|
|
64
|
+
const baseOrCdnURL = cdnURL && await isPrerendered(url) ? cdnURL : config.app.baseURL;
|
|
65
|
+
return joinURL(baseOrCdnURL, u.pathname, filename + (hash ? `?${hash}` : ""));
|
|
66
|
+
}
|
|
67
|
+
async function _importPayload(payloadURL) {
|
|
68
|
+
if (import.meta.server || !payloadExtraction) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const payloadPromise = renderJsonPayloads ? fetch(payloadURL, { cache: "force-cache" }).then((res) => res.text().then(parsePayload)) : import(
|
|
72
|
+
/* webpackIgnore: true */
|
|
73
|
+
/* @vite-ignore */
|
|
74
|
+
payloadURL
|
|
75
|
+
).then((r) => r.default || r);
|
|
76
|
+
try {
|
|
77
|
+
return await payloadPromise;
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.warn("[nuxt] Cannot load payload ", payloadURL, err);
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
export async function isPrerendered(url = useRoute().path) {
|
|
84
|
+
const nuxtApp = useNuxtApp();
|
|
85
|
+
if (!appManifest) {
|
|
86
|
+
return !!nuxtApp.payload.prerenderedAt;
|
|
87
|
+
}
|
|
88
|
+
url = url === "/" ? url : url.replace(/\/$/, "");
|
|
89
|
+
const manifest = await getAppManifest();
|
|
90
|
+
if (manifest.prerendered.includes(url)) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return nuxtApp.runWithContext(async () => {
|
|
94
|
+
const rules = await getRouteRules({ path: url });
|
|
95
|
+
return !!rules.prerender && !rules.redirect;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
let payloadCache = null;
|
|
99
|
+
export async function getNuxtClientPayload() {
|
|
100
|
+
if (import.meta.server) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
if (payloadCache) {
|
|
104
|
+
return payloadCache;
|
|
105
|
+
}
|
|
106
|
+
const el = multiApp ? document.querySelector(`[data-nuxt-data="${appId}"]`) : document.getElementById("__NUXT_DATA__");
|
|
107
|
+
if (!el) {
|
|
108
|
+
return {};
|
|
109
|
+
}
|
|
110
|
+
const inlineData = await parsePayload(el.textContent || "");
|
|
111
|
+
const externalData = el.dataset.src ? await _importPayload(el.dataset.src) : void 0;
|
|
112
|
+
payloadCache = {
|
|
113
|
+
...inlineData,
|
|
114
|
+
...externalData,
|
|
115
|
+
...multiApp ? window.__NUXT__?.[appId] : window.__NUXT__
|
|
116
|
+
};
|
|
117
|
+
if (payloadCache.config?.public) {
|
|
118
|
+
payloadCache.config.public = reactive(payloadCache.config.public);
|
|
119
|
+
}
|
|
120
|
+
return payloadCache;
|
|
121
|
+
}
|
|
122
|
+
export async function parsePayload(payload) {
|
|
123
|
+
return await parse(payload, useNuxtApp()._payloadRevivers);
|
|
124
|
+
}
|
|
125
|
+
export function definePayloadReducer(name, reduce) {
|
|
126
|
+
if (import.meta.server) {
|
|
127
|
+
useNuxtApp().ssrContext._payloadReducers[name] = reduce;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function definePayloadReviver(name, revive) {
|
|
131
|
+
if (import.meta.dev && getCurrentInstance()) {
|
|
132
|
+
console.warn("[nuxt] [definePayloadReviver] This function must be called in a Nuxt plugin that is `unshift`ed to the beginning of the Nuxt plugins array.");
|
|
133
|
+
}
|
|
134
|
+
if (import.meta.client) {
|
|
135
|
+
useNuxtApp()._payloadRevivers[name] = revive;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
import type { RouteLocationRaw, Router } from 'vue-router';
|
|
3
|
+
/**
|
|
4
|
+
* Preload a component or components that have been globally registered.
|
|
5
|
+
* @param components Pascal-cased name or names of components to prefetch
|
|
6
|
+
* @since 3.0.0
|
|
7
|
+
*/
|
|
8
|
+
export declare const preloadComponents: (components: string | string[]) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Prefetch a component or components that have been globally registered.
|
|
11
|
+
* @param components Pascal-cased name or names of components to prefetch
|
|
12
|
+
* @since 3.0.0
|
|
13
|
+
*/
|
|
14
|
+
export declare const prefetchComponents: (components: string | string[]) => Promise<void> | undefined;
|
|
15
|
+
export declare function _loadAsyncComponent(component: Component): any;
|
|
16
|
+
/** @since 3.0.0 */
|
|
17
|
+
export declare function preloadRouteComponents(to: RouteLocationRaw, router?: Router & {
|
|
18
|
+
_routePreloaded?: Set<string>;
|
|
19
|
+
_preloadPromises?: Array<Promise<unknown>>;
|
|
20
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useNuxtApp } from "../nuxt.js";
|
|
2
|
+
import { toArray } from "../utils.js";
|
|
3
|
+
import { useRouter } from "./router.js";
|
|
4
|
+
export const preloadComponents = async (components) => {
|
|
5
|
+
if (import.meta.server) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const nuxtApp = useNuxtApp();
|
|
9
|
+
components = toArray(components);
|
|
10
|
+
await Promise.all(components.map((name) => {
|
|
11
|
+
const component = nuxtApp.vueApp._context.components[name];
|
|
12
|
+
if (component) {
|
|
13
|
+
return _loadAsyncComponent(component);
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
export const prefetchComponents = (components) => {
|
|
18
|
+
if (import.meta.server) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
return preloadComponents(components);
|
|
22
|
+
};
|
|
23
|
+
export function _loadAsyncComponent(component) {
|
|
24
|
+
if (component?.__asyncLoader && !component.__asyncResolved) {
|
|
25
|
+
return component.__asyncLoader();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function preloadRouteComponents(to, router = useRouter()) {
|
|
29
|
+
if (import.meta.server) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const { path, matched } = router.resolve(to);
|
|
33
|
+
if (!matched.length) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
router._routePreloaded ||= /* @__PURE__ */ new Set();
|
|
37
|
+
if (router._routePreloaded.has(path)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const promises = router._preloadPromises ||= [];
|
|
41
|
+
if (promises.length > 4) {
|
|
42
|
+
return Promise.all(promises).then(() => preloadRouteComponents(to, router));
|
|
43
|
+
}
|
|
44
|
+
router._routePreloaded.add(path);
|
|
45
|
+
for (const route of matched) {
|
|
46
|
+
const component = route.components?.default;
|
|
47
|
+
if (typeof component !== "function") {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const promise = Promise.resolve(component()).catch(() => {
|
|
51
|
+
}).finally(() => promises.splice(promises.indexOf(promise)));
|
|
52
|
+
promises.push(promise);
|
|
53
|
+
}
|
|
54
|
+
await Promise.all(promises);
|
|
55
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface Preview {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
state: Record<any, unknown>;
|
|
4
|
+
_initialized?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Options for configuring preview mode.
|
|
8
|
+
*/
|
|
9
|
+
interface PreviewModeOptions<S> {
|
|
10
|
+
/**
|
|
11
|
+
* A function that determines whether preview mode should be enabled based on the current state.
|
|
12
|
+
* @param {Record<any, unknown>} state - The state of the preview.
|
|
13
|
+
* @returns {boolean} A boolean indicating whether the preview mode is enabled.
|
|
14
|
+
*/
|
|
15
|
+
shouldEnable?: (state: Preview['state']) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* A function that retrieves the current state.
|
|
18
|
+
* The `getState` function will append returned values to current state, so be careful not to accidentally overwrite important state.
|
|
19
|
+
* @param {Record<any, unknown>} state - The preview state.
|
|
20
|
+
* @returns {Record<any, unknown>} The preview state.
|
|
21
|
+
*/
|
|
22
|
+
getState?: (state: Preview['state']) => S;
|
|
23
|
+
/**
|
|
24
|
+
* A function to be called when the preview mode is enabled.
|
|
25
|
+
*/
|
|
26
|
+
onEnable?: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* A function to be called when the preview mode is disabled.
|
|
29
|
+
*/
|
|
30
|
+
onDisable?: () => void;
|
|
31
|
+
}
|
|
32
|
+
type EnteredState = Record<any, unknown> | null | undefined | void;
|
|
33
|
+
/** @since 3.11.0 */
|
|
34
|
+
export declare function usePreviewMode<S extends EnteredState>(options?: PreviewModeOptions<S>): {
|
|
35
|
+
enabled: import("vue").Ref<boolean, boolean>;
|
|
36
|
+
state: S extends void ? Preview["state"] : (NonNullable<S> & Preview["state"]);
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { toRef, watch } from "vue";
|
|
2
|
+
import { useState } from "./state.js";
|
|
3
|
+
import { refreshNuxtData } from "./asyncData.js";
|
|
4
|
+
import { useRoute, useRouter } from "./router.js";
|
|
5
|
+
let unregisterRefreshHook;
|
|
6
|
+
export function usePreviewMode(options = {}) {
|
|
7
|
+
const preview = useState("_preview-state", () => ({
|
|
8
|
+
enabled: false,
|
|
9
|
+
state: {}
|
|
10
|
+
}));
|
|
11
|
+
if (preview.value._initialized) {
|
|
12
|
+
return {
|
|
13
|
+
enabled: toRef(preview.value, "enabled"),
|
|
14
|
+
state: preview.value.state
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (import.meta.client) {
|
|
18
|
+
preview.value._initialized = true;
|
|
19
|
+
}
|
|
20
|
+
if (!preview.value.enabled) {
|
|
21
|
+
const shouldEnable = options.shouldEnable ?? defaultShouldEnable;
|
|
22
|
+
const result = shouldEnable(preview.value.state);
|
|
23
|
+
if (typeof result === "boolean") {
|
|
24
|
+
preview.value.enabled = result;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
watch(() => preview.value.enabled, (value) => {
|
|
28
|
+
if (value) {
|
|
29
|
+
const getState = options.getState ?? getDefaultState;
|
|
30
|
+
const newState = getState(preview.value.state);
|
|
31
|
+
if (newState !== preview.value.state) {
|
|
32
|
+
Object.assign(preview.value.state, newState);
|
|
33
|
+
}
|
|
34
|
+
if (import.meta.client && !unregisterRefreshHook) {
|
|
35
|
+
const onEnable = options.onEnable ?? refreshNuxtData;
|
|
36
|
+
onEnable();
|
|
37
|
+
unregisterRefreshHook = options.onDisable ?? useRouter().afterEach(() => refreshNuxtData());
|
|
38
|
+
}
|
|
39
|
+
} else if (unregisterRefreshHook) {
|
|
40
|
+
unregisterRefreshHook();
|
|
41
|
+
unregisterRefreshHook = void 0;
|
|
42
|
+
}
|
|
43
|
+
}, { immediate: true, flush: "sync" });
|
|
44
|
+
return {
|
|
45
|
+
enabled: toRef(preview.value, "enabled"),
|
|
46
|
+
state: preview.value.state
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function defaultShouldEnable() {
|
|
50
|
+
const route = useRoute();
|
|
51
|
+
const previewQueryName = "preview";
|
|
52
|
+
return route.query[previewQueryName] === "true";
|
|
53
|
+
}
|
|
54
|
+
function getDefaultState(state) {
|
|
55
|
+
if (state.token !== void 0) {
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
const route = useRoute();
|
|
59
|
+
state.token = Array.isArray(route.query.token) ? route.query.token[0] : route.query.token;
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useNuxtApp } from "../nuxt.js";
|
|
2
|
+
import { requestIdleCallback } from "../compat/idle-callback.js";
|
|
3
|
+
export const onNuxtReady = (callback) => {
|
|
4
|
+
if (import.meta.server) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const nuxtApp = useNuxtApp();
|
|
8
|
+
if (nuxtApp.isHydrating) {
|
|
9
|
+
nuxtApp.hooks.hookOnce("app:suspense:resolve", () => {
|
|
10
|
+
requestIdleCallback(() => callback());
|
|
11
|
+
});
|
|
12
|
+
} else {
|
|
13
|
+
requestIdleCallback(() => callback());
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
export type Politeness = 'assertive' | 'polite' | 'off';
|
|
3
|
+
export type NuxtRouteAnnouncerOpts = {
|
|
4
|
+
/** @default 'polite' */
|
|
5
|
+
politeness?: Politeness;
|
|
6
|
+
};
|
|
7
|
+
export type RouteAnnouncer = {
|
|
8
|
+
message: Ref<string>;
|
|
9
|
+
politeness: Ref<Politeness>;
|
|
10
|
+
set: (message: string, politeness: Politeness) => void;
|
|
11
|
+
polite: (message: string) => void;
|
|
12
|
+
assertive: (message: string) => void;
|
|
13
|
+
_cleanup: () => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* composable to handle the route announcer
|
|
17
|
+
* @since 3.12.0
|
|
18
|
+
*/
|
|
19
|
+
export declare function useRouteAnnouncer(opts?: Partial<NuxtRouteAnnouncerOpts>): Omit<RouteAnnouncer, '_cleanup'>;
|