@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,205 @@
|
|
|
1
|
+
import { customRef, getCurrentScope, nextTick, onScopeDispose, ref, watch } from "vue";
|
|
2
|
+
import { parse, serialize } from "cookie-es";
|
|
3
|
+
import { deleteCookie, getCookie, getRequestHeader, setCookie } from "h3";
|
|
4
|
+
import destr from "destr";
|
|
5
|
+
import { isEqual } from "ohash";
|
|
6
|
+
import { klona } from "klona";
|
|
7
|
+
import { useNuxtApp } from "../nuxt.js";
|
|
8
|
+
import { useRequestEvent } from "./ssr.js";
|
|
9
|
+
import { cookieStore } from "#build/nuxt.config.mjs";
|
|
10
|
+
const CookieDefaults = {
|
|
11
|
+
path: "/",
|
|
12
|
+
watch: true,
|
|
13
|
+
decode: (val) => destr(decodeURIComponent(val)),
|
|
14
|
+
encode: (val) => encodeURIComponent(typeof val === "string" ? val : JSON.stringify(val))
|
|
15
|
+
};
|
|
16
|
+
const store = import.meta.client && cookieStore ? globalThis.cookieStore : void 0;
|
|
17
|
+
export function useCookie(name, _opts) {
|
|
18
|
+
const opts = { ...CookieDefaults, ..._opts };
|
|
19
|
+
opts.filter ??= (key) => key === name;
|
|
20
|
+
const cookies = readRawCookies(opts) || {};
|
|
21
|
+
let delay;
|
|
22
|
+
if (opts.maxAge !== void 0) {
|
|
23
|
+
delay = opts.maxAge * 1e3;
|
|
24
|
+
} else if (opts.expires) {
|
|
25
|
+
delay = opts.expires.getTime() - Date.now();
|
|
26
|
+
}
|
|
27
|
+
const hasExpired = delay !== void 0 && delay <= 0;
|
|
28
|
+
const shouldSetInitialClientCookie = import.meta.client && (hasExpired || cookies[name] === void 0 || cookies[name] === null);
|
|
29
|
+
const cookieValue = klona(hasExpired ? void 0 : cookies[name] ?? opts.default?.());
|
|
30
|
+
const cookie = import.meta.client && delay && !hasExpired ? cookieRef(cookieValue, delay, opts.watch && opts.watch !== "shallow") : ref(cookieValue);
|
|
31
|
+
if (import.meta.dev && hasExpired) {
|
|
32
|
+
console.warn(`[nuxt] not setting cookie \`${name}\` as it has already expired.`);
|
|
33
|
+
}
|
|
34
|
+
if (import.meta.client) {
|
|
35
|
+
let channel = null;
|
|
36
|
+
try {
|
|
37
|
+
if (!store && typeof BroadcastChannel !== "undefined") {
|
|
38
|
+
channel = new BroadcastChannel(`nuxt:cookies:${name}`);
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
const callback = (force = false) => {
|
|
43
|
+
if (!force) {
|
|
44
|
+
if (opts.readonly || isEqual(cookie.value, cookies[name])) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
writeClientCookie(name, cookie.value, opts);
|
|
49
|
+
cookies[name] = klona(cookie.value);
|
|
50
|
+
channel?.postMessage({ value: opts.encode(cookie.value) });
|
|
51
|
+
};
|
|
52
|
+
const handleChange = (data) => {
|
|
53
|
+
const value = data.refresh ? readRawCookies(opts)?.[name] : opts.decode(data.value);
|
|
54
|
+
watchPaused = true;
|
|
55
|
+
cookie.value = value;
|
|
56
|
+
cookies[name] = klona(value);
|
|
57
|
+
nextTick(() => {
|
|
58
|
+
watchPaused = false;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
let watchPaused = false;
|
|
62
|
+
const hasScope = !!getCurrentScope();
|
|
63
|
+
if (hasScope) {
|
|
64
|
+
onScopeDispose(() => {
|
|
65
|
+
watchPaused = true;
|
|
66
|
+
callback();
|
|
67
|
+
channel?.close();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (store) {
|
|
71
|
+
const changeHandler = (event) => {
|
|
72
|
+
const changedCookie = event.changed.find((c) => c.name === name);
|
|
73
|
+
const removedCookie = event.deleted.find((c) => c.name === name);
|
|
74
|
+
if (changedCookie) {
|
|
75
|
+
handleChange({ value: changedCookie.value });
|
|
76
|
+
}
|
|
77
|
+
if (removedCookie) {
|
|
78
|
+
handleChange({ value: null });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
store.addEventListener("change", changeHandler);
|
|
82
|
+
if (hasScope) {
|
|
83
|
+
onScopeDispose(() => store.removeEventListener("change", changeHandler));
|
|
84
|
+
}
|
|
85
|
+
} else if (channel) {
|
|
86
|
+
channel.onmessage = ({ data }) => handleChange(data);
|
|
87
|
+
}
|
|
88
|
+
if (opts.watch) {
|
|
89
|
+
watch(
|
|
90
|
+
cookie,
|
|
91
|
+
() => {
|
|
92
|
+
if (watchPaused) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
callback();
|
|
96
|
+
},
|
|
97
|
+
{ deep: opts.watch !== "shallow" }
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (shouldSetInitialClientCookie) {
|
|
101
|
+
callback(shouldSetInitialClientCookie);
|
|
102
|
+
}
|
|
103
|
+
} else if (import.meta.server) {
|
|
104
|
+
const nuxtApp = useNuxtApp();
|
|
105
|
+
const writeFinalCookieValue = () => {
|
|
106
|
+
if (opts.readonly || isEqual(cookie.value, cookies[name])) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
nuxtApp._cookies ||= {};
|
|
110
|
+
if (name in nuxtApp._cookies) {
|
|
111
|
+
if (isEqual(cookie.value, nuxtApp._cookies[name])) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (import.meta.dev) {
|
|
115
|
+
console.warn(`[nuxt] cookie \`${name}\` was previously set to \`${opts.encode(nuxtApp._cookies[name])}\` and is being overridden to \`${opts.encode(cookie.value)}\`. This may cause unexpected issues.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
nuxtApp._cookies[name] = cookie.value;
|
|
119
|
+
writeServerCookie(useRequestEvent(nuxtApp), name, cookie.value, opts);
|
|
120
|
+
};
|
|
121
|
+
const unhook = nuxtApp.hooks.hookOnce("app:rendered", writeFinalCookieValue);
|
|
122
|
+
nuxtApp.hooks.hookOnce("app:error", () => {
|
|
123
|
+
unhook();
|
|
124
|
+
return writeFinalCookieValue();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return cookie;
|
|
128
|
+
}
|
|
129
|
+
export function refreshCookie(name) {
|
|
130
|
+
if (import.meta.server || store || typeof BroadcastChannel === "undefined") {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
new BroadcastChannel(`nuxt:cookies:${name}`)?.postMessage({ refresh: true });
|
|
134
|
+
}
|
|
135
|
+
function readRawCookies(opts = {}) {
|
|
136
|
+
if (import.meta.server) {
|
|
137
|
+
return parse(getRequestHeader(useRequestEvent(), "cookie") || "", opts);
|
|
138
|
+
} else if (import.meta.client) {
|
|
139
|
+
return parse(document.cookie, opts);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function serializeCookie(name, value, opts = {}) {
|
|
143
|
+
if (value === null || value === void 0) {
|
|
144
|
+
return serialize(name, value, { ...opts, maxAge: -1 });
|
|
145
|
+
}
|
|
146
|
+
return serialize(name, value, opts);
|
|
147
|
+
}
|
|
148
|
+
function writeClientCookie(name, value, opts = {}) {
|
|
149
|
+
if (import.meta.client) {
|
|
150
|
+
document.cookie = serializeCookie(name, value, opts);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function writeServerCookie(event, name, value, opts = {}) {
|
|
154
|
+
if (event) {
|
|
155
|
+
if (value !== null && value !== void 0) {
|
|
156
|
+
return setCookie(event, name, value, opts);
|
|
157
|
+
}
|
|
158
|
+
if (getCookie(event, name) !== void 0) {
|
|
159
|
+
return deleteCookie(event, name, opts);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const MAX_TIMEOUT_DELAY = 2147483647;
|
|
164
|
+
function cookieRef(value, delay, shouldWatch) {
|
|
165
|
+
let timeout;
|
|
166
|
+
let unsubscribe;
|
|
167
|
+
let elapsed = 0;
|
|
168
|
+
const internalRef = shouldWatch ? ref(value) : { value };
|
|
169
|
+
if (getCurrentScope()) {
|
|
170
|
+
onScopeDispose(() => {
|
|
171
|
+
unsubscribe?.();
|
|
172
|
+
clearTimeout(timeout);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return customRef((track, trigger) => {
|
|
176
|
+
if (shouldWatch) {
|
|
177
|
+
unsubscribe = watch(internalRef, trigger);
|
|
178
|
+
}
|
|
179
|
+
function createExpirationTimeout() {
|
|
180
|
+
elapsed = 0;
|
|
181
|
+
clearTimeout(timeout);
|
|
182
|
+
const timeRemaining = delay - elapsed;
|
|
183
|
+
const timeoutLength = timeRemaining < MAX_TIMEOUT_DELAY ? timeRemaining : MAX_TIMEOUT_DELAY;
|
|
184
|
+
timeout = setTimeout(() => {
|
|
185
|
+
elapsed += timeoutLength;
|
|
186
|
+
if (elapsed < delay) {
|
|
187
|
+
return createExpirationTimeout();
|
|
188
|
+
}
|
|
189
|
+
internalRef.value = void 0;
|
|
190
|
+
trigger();
|
|
191
|
+
}, timeoutLength);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
get() {
|
|
195
|
+
track();
|
|
196
|
+
return internalRef.value;
|
|
197
|
+
},
|
|
198
|
+
set(newValue) {
|
|
199
|
+
createExpirationTimeout();
|
|
200
|
+
internalRef.value = newValue;
|
|
201
|
+
trigger();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { H3Error } from 'h3';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import type { NuxtPayload } from '../nuxt.js';
|
|
4
|
+
export declare const NUXT_ERROR_SIGNATURE = "__nuxt_error";
|
|
5
|
+
/** @since 3.0.0 */
|
|
6
|
+
export declare const useError: () => Ref<NuxtPayload["error"]>;
|
|
7
|
+
export interface NuxtError<DataT = unknown> extends H3Error<DataT> {
|
|
8
|
+
error?: true;
|
|
9
|
+
}
|
|
10
|
+
/** @since 3.0.0 */
|
|
11
|
+
export declare const showError: <DataT = unknown>(error: string | Error | (Partial<NuxtError<DataT>> & {
|
|
12
|
+
status?: number;
|
|
13
|
+
statusText?: string;
|
|
14
|
+
})) => NuxtError<DataT>;
|
|
15
|
+
/** @since 3.0.0 */
|
|
16
|
+
export declare const clearError: (options?: {
|
|
17
|
+
redirect?: string;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
/** @since 3.0.0 */
|
|
20
|
+
export declare const isNuxtError: <DataT = unknown>(error: unknown) => error is NuxtError<DataT>;
|
|
21
|
+
/** @since 3.0.0 */
|
|
22
|
+
export declare const createError: <DataT = unknown>(error: string | Error | (Partial<NuxtError<DataT>> & {
|
|
23
|
+
status?: number;
|
|
24
|
+
statusText?: string;
|
|
25
|
+
})) => NuxtError<DataT>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createError as createH3Error } from "h3";
|
|
2
|
+
import { toRef } from "vue";
|
|
3
|
+
import { useNuxtApp } from "../nuxt.js";
|
|
4
|
+
import { useRouter } from "./router.js";
|
|
5
|
+
export const NUXT_ERROR_SIGNATURE = "__nuxt_error";
|
|
6
|
+
export const useError = /* @__NO_SIDE_EFFECTS__ */ () => toRef(useNuxtApp().payload, "error");
|
|
7
|
+
export const showError = (error) => {
|
|
8
|
+
const nuxtError = createError(error);
|
|
9
|
+
try {
|
|
10
|
+
const error2 = /* @__PURE__ */ useError();
|
|
11
|
+
if (import.meta.client) {
|
|
12
|
+
const nuxtApp = useNuxtApp();
|
|
13
|
+
nuxtApp.hooks.callHook("app:error", nuxtError);
|
|
14
|
+
}
|
|
15
|
+
error2.value ||= nuxtError;
|
|
16
|
+
} catch {
|
|
17
|
+
throw nuxtError;
|
|
18
|
+
}
|
|
19
|
+
return nuxtError;
|
|
20
|
+
};
|
|
21
|
+
export const clearError = async (options = {}) => {
|
|
22
|
+
const nuxtApp = useNuxtApp();
|
|
23
|
+
const error = /* @__PURE__ */ useError();
|
|
24
|
+
nuxtApp.callHook("app:error:cleared", options);
|
|
25
|
+
if (options.redirect) {
|
|
26
|
+
await useRouter().replace(options.redirect);
|
|
27
|
+
}
|
|
28
|
+
error.value = void 0;
|
|
29
|
+
};
|
|
30
|
+
export const isNuxtError = (error) => !!error && typeof error === "object" && NUXT_ERROR_SIGNATURE in error;
|
|
31
|
+
export const createError = (error) => {
|
|
32
|
+
const nuxtError = createH3Error(error);
|
|
33
|
+
Object.defineProperty(nuxtError, NUXT_ERROR_SIGNATURE, {
|
|
34
|
+
value: true,
|
|
35
|
+
configurable: false,
|
|
36
|
+
writable: false
|
|
37
|
+
});
|
|
38
|
+
return nuxtError;
|
|
39
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { FetchError, FetchOptions, ResponseType as _ResponseType } from 'ofetch';
|
|
2
|
+
import type { NitroFetchRequest, TypedInternalResponse, AvailableRouterMethod as _AvailableRouterMethod } from 'nitropack/types';
|
|
3
|
+
import type { MaybeRefOrGetter, Ref } from 'vue';
|
|
4
|
+
import type { AsyncData, AsyncDataOptions, KeysOf, MultiWatchSources, PickFrom } from './asyncData.js';
|
|
5
|
+
type AvailableRouterMethod<R extends NitroFetchRequest> = _AvailableRouterMethod<R> | Uppercase<_AvailableRouterMethod<R>>;
|
|
6
|
+
export type FetchResult<ReqT extends NitroFetchRequest, M extends AvailableRouterMethod<ReqT>> = TypedInternalResponse<ReqT, unknown, Lowercase<M>>;
|
|
7
|
+
type ComputedOptions<T extends Record<string, any>> = {
|
|
8
|
+
[K in keyof T]: T[K] extends Function ? T[K] : ComputedOptions<T[K]> | Ref<T[K]> | T[K];
|
|
9
|
+
};
|
|
10
|
+
interface NitroFetchOptions<R extends NitroFetchRequest, M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>, DataT = any> extends FetchOptions<_ResponseType, DataT> {
|
|
11
|
+
method?: M;
|
|
12
|
+
}
|
|
13
|
+
type ComputedFetchOptions<R extends NitroFetchRequest, M extends AvailableRouterMethod<R>, DataT = any> = ComputedOptions<NitroFetchOptions<R, M, DataT>>;
|
|
14
|
+
export interface UseFetchOptions<ResT, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined, R extends NitroFetchRequest = string & {}, M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>> extends Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'watch'>, Omit<ComputedFetchOptions<R, M, DataT>, 'timeout'> {
|
|
15
|
+
key?: MaybeRefOrGetter<string>;
|
|
16
|
+
$fetch?: typeof globalThis.$fetch;
|
|
17
|
+
watch?: MultiWatchSources | false;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fetch data from an API endpoint with an SSR-friendly composable.
|
|
21
|
+
* See {@link https://nuxt.com/docs/4.x/api/composables/use-fetch}
|
|
22
|
+
* @since 3.0.0
|
|
23
|
+
* @param request The URL to fetch
|
|
24
|
+
* @param opts extends $fetch options and useAsyncData options
|
|
25
|
+
*/
|
|
26
|
+
export declare function useFetch<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: UseFetchOptions<_ResT, DataT, PickKeys, DefaultT, ReqT, Method>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, ErrorT | undefined>;
|
|
27
|
+
export declare function useFetch<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: UseFetchOptions<_ResT, DataT, PickKeys, DefaultT, ReqT, Method>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, ErrorT | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetch data from an API endpoint with an SSR-friendly composable.
|
|
30
|
+
* See {@link https://nuxt.com/docs/4.x/api/composables/use-lazy-fetch}
|
|
31
|
+
* @since 3.0.0
|
|
32
|
+
* @param request The URL to fetch
|
|
33
|
+
* @param opts extends $fetch options and useAsyncData options
|
|
34
|
+
*/
|
|
35
|
+
export declare function useLazyFetch<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: Omit<UseFetchOptions<_ResT, DataT, PickKeys, DefaultT, ReqT, Method>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, ErrorT | undefined>;
|
|
36
|
+
export declare function useLazyFetch<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: Omit<UseFetchOptions<_ResT, DataT, PickKeys, DefaultT, ReqT, Method>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, ErrorT | undefined>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { computed, reactive, toValue, watch } from "vue";
|
|
2
|
+
import { hash } from "ohash";
|
|
3
|
+
import { isPlainObject } from "@vue/shared";
|
|
4
|
+
import { useRequestFetch } from "./ssr.js";
|
|
5
|
+
import { useAsyncData } from "./asyncData.js";
|
|
6
|
+
import { alwaysRunFetchOnKeyChange, fetchDefaults } from "#build/nuxt.config.mjs";
|
|
7
|
+
export function useFetch(request, arg1, arg2) {
|
|
8
|
+
const [opts = {}, autoKey] = typeof arg1 === "string" ? [{}, arg1] : [arg1, arg2];
|
|
9
|
+
const _request = computed(() => toValue(request));
|
|
10
|
+
const key = computed(() => toValue(opts.key) || "$f" + hash([autoKey, typeof _request.value === "string" ? _request.value : "", ...generateOptionSegments(opts)]));
|
|
11
|
+
if (!opts.baseURL && typeof _request.value === "string" && (_request.value[0] === "/" && _request.value[1] === "/")) {
|
|
12
|
+
throw new Error('[nuxt] [useFetch] the request URL must not start with "//".');
|
|
13
|
+
}
|
|
14
|
+
const {
|
|
15
|
+
server,
|
|
16
|
+
lazy,
|
|
17
|
+
default: defaultFn,
|
|
18
|
+
transform,
|
|
19
|
+
pick,
|
|
20
|
+
watch: watchSources,
|
|
21
|
+
immediate,
|
|
22
|
+
getCachedData,
|
|
23
|
+
deep,
|
|
24
|
+
dedupe,
|
|
25
|
+
timeout,
|
|
26
|
+
...fetchOptions
|
|
27
|
+
} = opts;
|
|
28
|
+
const _fetchOptions = reactive({
|
|
29
|
+
...fetchDefaults,
|
|
30
|
+
...fetchOptions,
|
|
31
|
+
cache: typeof opts.cache === "boolean" ? void 0 : opts.cache
|
|
32
|
+
});
|
|
33
|
+
const _asyncDataOptions = {
|
|
34
|
+
server,
|
|
35
|
+
lazy,
|
|
36
|
+
default: defaultFn,
|
|
37
|
+
transform,
|
|
38
|
+
pick,
|
|
39
|
+
immediate,
|
|
40
|
+
getCachedData,
|
|
41
|
+
deep,
|
|
42
|
+
dedupe,
|
|
43
|
+
timeout,
|
|
44
|
+
watch: watchSources === false ? [] : [...watchSources || [], _fetchOptions]
|
|
45
|
+
};
|
|
46
|
+
if (import.meta.dev) {
|
|
47
|
+
_asyncDataOptions._functionName ||= "useFetch";
|
|
48
|
+
}
|
|
49
|
+
if (alwaysRunFetchOnKeyChange && !immediate) {
|
|
50
|
+
let setImmediate = function() {
|
|
51
|
+
_asyncDataOptions.immediate = true;
|
|
52
|
+
};
|
|
53
|
+
watch(key, setImmediate, { flush: "sync", once: true });
|
|
54
|
+
watch([...watchSources || [], _fetchOptions], setImmediate, { flush: "sync", once: true });
|
|
55
|
+
}
|
|
56
|
+
const asyncData = useAsyncData(watchSources === false ? key.value : key, (_, { signal }) => {
|
|
57
|
+
let _$fetch = opts.$fetch || globalThis.$fetch;
|
|
58
|
+
if (import.meta.server && !opts.$fetch) {
|
|
59
|
+
const isLocalFetch = typeof _request.value === "string" && _request.value[0] === "/" && (!toValue(opts.baseURL) || toValue(opts.baseURL)[0] === "/");
|
|
60
|
+
if (isLocalFetch) {
|
|
61
|
+
_$fetch = useRequestFetch();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return _$fetch(_request.value, { signal, ..._fetchOptions });
|
|
65
|
+
}, _asyncDataOptions);
|
|
66
|
+
return asyncData;
|
|
67
|
+
}
|
|
68
|
+
export function useLazyFetch(request, arg1, arg2) {
|
|
69
|
+
const [opts = {}, autoKey] = typeof arg1 === "string" ? [{}, arg1] : [arg1, arg2];
|
|
70
|
+
if (import.meta.dev) {
|
|
71
|
+
opts._functionName ||= "useLazyFetch";
|
|
72
|
+
}
|
|
73
|
+
return useFetch(
|
|
74
|
+
request,
|
|
75
|
+
{
|
|
76
|
+
...opts,
|
|
77
|
+
lazy: true
|
|
78
|
+
},
|
|
79
|
+
// @ts-expect-error we pass an extra argument with the resolved auto-key to prevent another from being injected
|
|
80
|
+
autoKey
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
function generateOptionSegments(opts) {
|
|
84
|
+
const segments = [
|
|
85
|
+
toValue(opts.method)?.toUpperCase() || "GET",
|
|
86
|
+
toValue(opts.baseURL)
|
|
87
|
+
];
|
|
88
|
+
for (const _obj of [opts.query || opts.params]) {
|
|
89
|
+
const obj = toValue(_obj);
|
|
90
|
+
if (!obj) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const unwrapped = {};
|
|
94
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
95
|
+
unwrapped[toValue(key)] = toValue(value);
|
|
96
|
+
}
|
|
97
|
+
segments.push(unwrapped);
|
|
98
|
+
}
|
|
99
|
+
if (opts.body) {
|
|
100
|
+
const value = toValue(opts.body);
|
|
101
|
+
if (!value) {
|
|
102
|
+
segments.push(hash(value));
|
|
103
|
+
} else if (value instanceof ArrayBuffer) {
|
|
104
|
+
segments.push(hash(Object.fromEntries([...new Uint8Array(value).entries()].map(([k, v]) => [k, v.toString()]))));
|
|
105
|
+
} else if (value instanceof FormData) {
|
|
106
|
+
const obj = {};
|
|
107
|
+
for (const entry of value.entries()) {
|
|
108
|
+
const [key, val] = entry;
|
|
109
|
+
obj[key] = val instanceof File ? val.name : val;
|
|
110
|
+
}
|
|
111
|
+
segments.push(hash(obj));
|
|
112
|
+
} else if (isPlainObject(value)) {
|
|
113
|
+
segments.push(hash(reactive(value)));
|
|
114
|
+
} else {
|
|
115
|
+
try {
|
|
116
|
+
segments.push(hash(value));
|
|
117
|
+
} catch {
|
|
118
|
+
console.warn("[useFetch] Failed to hash body", value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return segments;
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { injectHead, useHead, useServerHead, useSeoMeta, useServerSeoMeta, useHeadSafe, useServerHeadSafe } from '#unhead/composables';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { injectHead, useHead, useServerHead, useSeoMeta, useServerSeoMeta, useHeadSafe, useServerHeadSafe } from "#unhead/composables";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NuxtPayload } from '../nuxt.js';
|
|
2
|
+
/**
|
|
3
|
+
* Allows full control of the hydration cycle to set and receive data from the server.
|
|
4
|
+
* @param key a unique key to identify the data in the Nuxt payload
|
|
5
|
+
* @param get a function that returns the value to set the initial data
|
|
6
|
+
* @param set a function that will receive the data on the client-side
|
|
7
|
+
* @since 3.0.0
|
|
8
|
+
*/
|
|
9
|
+
export declare const useHydration: <K extends keyof NuxtPayload, T = NuxtPayload[K]>(key: K, get: () => T, set: (value: T) => void) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useNuxtApp } from "../nuxt.js";
|
|
2
|
+
export const useHydration = (key, get, set) => {
|
|
3
|
+
const nuxtApp = useNuxtApp();
|
|
4
|
+
if (import.meta.server) {
|
|
5
|
+
nuxtApp.hooks.hook("app:rendered", () => {
|
|
6
|
+
nuxtApp.payload[key] = get();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
if (import.meta.client) {
|
|
10
|
+
nuxtApp.hooks.hook("app:created", () => {
|
|
11
|
+
set(nuxtApp.payload[key]);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { defineNuxtComponent } from './component.js';
|
|
2
|
+
export { useAsyncData, useLazyAsyncData, useNuxtData, refreshNuxtData, clearNuxtData } from './asyncData.js';
|
|
3
|
+
export type { AsyncDataOptions, AsyncData, AsyncDataRequestStatus } from './asyncData.js';
|
|
4
|
+
export { useHydration } from './hydrate.js';
|
|
5
|
+
export { callOnce } from './once.js';
|
|
6
|
+
export { useState, clearNuxtState } from './state.js';
|
|
7
|
+
export { clearError, createError, isNuxtError, showError, useError } from './error.js';
|
|
8
|
+
export type { NuxtError } from './error.js';
|
|
9
|
+
export { useFetch, useLazyFetch } from './fetch.js';
|
|
10
|
+
export type { FetchResult, UseFetchOptions } from './fetch.js';
|
|
11
|
+
export { useCookie, refreshCookie } from './cookie.js';
|
|
12
|
+
export type { CookieOptions, CookieRef } from './cookie.js';
|
|
13
|
+
export { onPrehydrate, prerenderRoutes, useRequestHeaders, useRequestEvent, useRequestFetch, setResponseStatus, useResponseHeader } from './ssr.js';
|
|
14
|
+
export { onNuxtReady } from './ready.js';
|
|
15
|
+
export { abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter } from './router.js';
|
|
16
|
+
export type { AddRouteMiddlewareOptions, RouteMiddleware } from './router.js';
|
|
17
|
+
export { preloadComponents, prefetchComponents, preloadRouteComponents } from './preload.js';
|
|
18
|
+
export { isPrerendered, loadPayload, preloadPayload, definePayloadReducer, definePayloadReviver } from './payload.js';
|
|
19
|
+
export { getAppManifest, getRouteRules } from './manifest.js';
|
|
20
|
+
export type { NuxtAppManifest, NuxtAppManifestMeta } from './manifest.js';
|
|
21
|
+
export type { ReloadNuxtAppOptions } from './chunk.js';
|
|
22
|
+
export { reloadNuxtApp } from './chunk.js';
|
|
23
|
+
export { useRequestURL } from './url.js';
|
|
24
|
+
export { usePreviewMode } from './preview.js';
|
|
25
|
+
export { useId } from './id.js';
|
|
26
|
+
export { useRouteAnnouncer } from './route-announcer.js';
|
|
27
|
+
export type { Politeness } from './route-announcer.js';
|
|
28
|
+
export { useRuntimeHook } from './runtime-hook.js';
|
|
29
|
+
export { injectHead, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta } from './head.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { defineNuxtComponent } from "./component.js";
|
|
2
|
+
export { useAsyncData, useLazyAsyncData, useNuxtData, refreshNuxtData, clearNuxtData } from "./asyncData.js";
|
|
3
|
+
export { useHydration } from "./hydrate.js";
|
|
4
|
+
export { callOnce } from "./once.js";
|
|
5
|
+
export { useState, clearNuxtState } from "./state.js";
|
|
6
|
+
export { clearError, createError, isNuxtError, showError, useError } from "./error.js";
|
|
7
|
+
export { useFetch, useLazyFetch } from "./fetch.js";
|
|
8
|
+
export { useCookie, refreshCookie } from "./cookie.js";
|
|
9
|
+
export { onPrehydrate, prerenderRoutes, useRequestHeaders, useRequestEvent, useRequestFetch, setResponseStatus, useResponseHeader } from "./ssr.js";
|
|
10
|
+
export { onNuxtReady } from "./ready.js";
|
|
11
|
+
export { abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter } from "./router.js";
|
|
12
|
+
export { preloadComponents, prefetchComponents, preloadRouteComponents } from "./preload.js";
|
|
13
|
+
export { isPrerendered, loadPayload, preloadPayload, definePayloadReducer, definePayloadReviver } from "./payload.js";
|
|
14
|
+
export { getAppManifest, getRouteRules } from "./manifest.js";
|
|
15
|
+
export { reloadNuxtApp } from "./chunk.js";
|
|
16
|
+
export { useRequestURL } from "./url.js";
|
|
17
|
+
export { usePreviewMode } from "./preview.js";
|
|
18
|
+
export { useId } from "./id.js";
|
|
19
|
+
export { useRouteAnnouncer } from "./route-announcer.js";
|
|
20
|
+
export { useRuntimeHook } from "./runtime-hook.js";
|
|
21
|
+
export { injectHead, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta } from "./head.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AsyncComponentLoader, Component, ComponentPublicInstance, DefineComponent } from 'vue';
|
|
2
|
+
type LazyHydrationComponent<T extends Component, Props> = T & DefineComponent<Props, {}, {}, {}, {}, {}, {}, {
|
|
3
|
+
hydrated: () => void;
|
|
4
|
+
}>;
|
|
5
|
+
export declare function defineLazyHydrationComponent<T extends Component = {
|
|
6
|
+
new (): ComponentPublicInstance;
|
|
7
|
+
}>(strategy: 'visible', source: AsyncComponentLoader<T>): LazyHydrationComponent<T, {
|
|
8
|
+
hydrateOnVisible?: IntersectionObserverInit | true;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function defineLazyHydrationComponent<T extends Component = {
|
|
11
|
+
new (): ComponentPublicInstance;
|
|
12
|
+
}>(strategy: 'idle', source: AsyncComponentLoader<T>): LazyHydrationComponent<T, {
|
|
13
|
+
hydrateOnIdle?: number | true;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function defineLazyHydrationComponent<T extends Component = {
|
|
16
|
+
new (): ComponentPublicInstance;
|
|
17
|
+
}>(strategy: 'interaction', source: AsyncComponentLoader<T>): LazyHydrationComponent<T, {
|
|
18
|
+
hydrateOnInteraction?: keyof HTMLElementEventMap | Array<keyof HTMLElementEventMap>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function defineLazyHydrationComponent<T extends Component = {
|
|
21
|
+
new (): ComponentPublicInstance;
|
|
22
|
+
}>(strategy: 'mediaQuery', source: AsyncComponentLoader<T>): LazyHydrationComponent<T, {
|
|
23
|
+
hydrateOnMediaQuery: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function defineLazyHydrationComponent<T extends Component = {
|
|
26
|
+
new (): ComponentPublicInstance;
|
|
27
|
+
}>(strategy: 'if', source: AsyncComponentLoader<T>): LazyHydrationComponent<T, {
|
|
28
|
+
hydrateWhen: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function defineLazyHydrationComponent<T extends Component = {
|
|
31
|
+
new (): ComponentPublicInstance;
|
|
32
|
+
}>(strategy: 'time', source: AsyncComponentLoader<T>): LazyHydrationComponent<T, {
|
|
33
|
+
hydrateAfter: number | true;
|
|
34
|
+
}>;
|
|
35
|
+
export declare function defineLazyHydrationComponent<T extends Component = {
|
|
36
|
+
new (): ComponentPublicInstance;
|
|
37
|
+
}>(strategy: 'never', source: AsyncComponentLoader<T>): LazyHydrationComponent<T, {
|
|
38
|
+
hydrateNever?: true;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
export type LoadingIndicatorOpts = {
|
|
3
|
+
/** @default 2000 */
|
|
4
|
+
duration: number;
|
|
5
|
+
/** @default 200 */
|
|
6
|
+
throttle: number;
|
|
7
|
+
/** @default 500 */
|
|
8
|
+
hideDelay: number;
|
|
9
|
+
/** @default 400 */
|
|
10
|
+
resetDelay: number;
|
|
11
|
+
/**
|
|
12
|
+
* You can provide a custom function to customize the progress estimation,
|
|
13
|
+
* which is a function that receives the duration of the loading bar (above)
|
|
14
|
+
* and the elapsed time. It should return a value between 0 and 100.
|
|
15
|
+
*/
|
|
16
|
+
estimatedProgress?: (duration: number, elapsed: number) => number;
|
|
17
|
+
};
|
|
18
|
+
export type LoadingIndicator = {
|
|
19
|
+
_cleanup: () => void;
|
|
20
|
+
progress: Ref<number>;
|
|
21
|
+
isLoading: Ref<boolean>;
|
|
22
|
+
error: Ref<boolean>;
|
|
23
|
+
start: (opts?: {
|
|
24
|
+
force?: boolean;
|
|
25
|
+
}) => void;
|
|
26
|
+
set: (value: number, opts?: {
|
|
27
|
+
force?: boolean;
|
|
28
|
+
}) => void;
|
|
29
|
+
finish: (opts?: {
|
|
30
|
+
force?: boolean;
|
|
31
|
+
error?: boolean;
|
|
32
|
+
}) => void;
|
|
33
|
+
clear: () => void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* composable to handle the loading state of the page
|
|
37
|
+
* @since 3.9.0
|
|
38
|
+
*/
|
|
39
|
+
export declare function useLoadingIndicator(opts?: Partial<LoadingIndicatorOpts>): Omit<LoadingIndicator, '_cleanup'>;
|