@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.
Files changed (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/app.d.ts +1 -0
  4. package/bin/nuxt.mjs +2 -0
  5. package/config.cjs +7 -0
  6. package/config.d.ts +8 -0
  7. package/config.js +5 -0
  8. package/dist/app/compat/capi.d.ts +4 -0
  9. package/dist/app/compat/capi.js +19 -0
  10. package/dist/app/compat/idle-callback.d.ts +2 -0
  11. package/dist/app/compat/idle-callback.js +15 -0
  12. package/dist/app/compat/interval.d.ts +1 -0
  13. package/dist/app/compat/interval.js +11 -0
  14. package/dist/app/compat/vue-demi.d.ts +4 -0
  15. package/dist/app/compat/vue-demi.js +4 -0
  16. package/dist/app/components/client-fallback.client.d.ts +50 -0
  17. package/dist/app/components/client-fallback.client.js +50 -0
  18. package/dist/app/components/client-fallback.server.d.ts +57 -0
  19. package/dist/app/components/client-fallback.server.js +80 -0
  20. package/dist/app/components/client-only.d.ts +26 -0
  21. package/dist/app/components/client-only.js +130 -0
  22. package/dist/app/components/dev-only.d.ts +11 -0
  23. package/dist/app/components/dev-only.js +14 -0
  24. package/dist/app/components/error-404.d.vue.ts +51 -0
  25. package/dist/app/components/error-404.vue +48 -0
  26. package/dist/app/components/error-404.vue.d.ts +51 -0
  27. package/dist/app/components/error-500.d.vue.ts +51 -0
  28. package/dist/app/components/error-500.vue +46 -0
  29. package/dist/app/components/error-500.vue.d.ts +51 -0
  30. package/dist/app/components/index.d.ts +3 -0
  31. package/dist/app/components/index.js +1 -0
  32. package/dist/app/components/injections.d.ts +7 -0
  33. package/dist/app/components/injections.js +2 -0
  34. package/dist/app/components/island-renderer.d.ts +20 -0
  35. package/dist/app/components/island-renderer.js +28 -0
  36. package/dist/app/components/nuxt-error-boundary.d.vue.ts +24 -0
  37. package/dist/app/components/nuxt-error-boundary.vue +46 -0
  38. package/dist/app/components/nuxt-error-boundary.vue.d.ts +24 -0
  39. package/dist/app/components/nuxt-error-page.d.vue.ts +7 -0
  40. package/dist/app/components/nuxt-error-page.vue +27 -0
  41. package/dist/app/components/nuxt-error-page.vue.d.ts +7 -0
  42. package/dist/app/components/nuxt-island.d.ts +70 -0
  43. package/dist/app/components/nuxt-island.js +331 -0
  44. package/dist/app/components/nuxt-layout.d.ts +14 -0
  45. package/dist/app/components/nuxt-layout.js +171 -0
  46. package/dist/app/components/nuxt-link.d.ts +101 -0
  47. package/dist/app/components/nuxt-link.js +409 -0
  48. package/dist/app/components/nuxt-loading-indicator.d.ts +78 -0
  49. package/dist/app/components/nuxt-loading-indicator.js +75 -0
  50. package/dist/app/components/nuxt-root.d.vue.ts +3 -0
  51. package/dist/app/components/nuxt-root.vue +60 -0
  52. package/dist/app/components/nuxt-root.vue.d.ts +3 -0
  53. package/dist/app/components/nuxt-route-announcer.d.ts +26 -0
  54. package/dist/app/components/nuxt-route-announcer.js +48 -0
  55. package/dist/app/components/nuxt-stubs.d.ts +6 -0
  56. package/dist/app/components/nuxt-stubs.js +14 -0
  57. package/dist/app/components/nuxt-teleport-island-component.d.ts +22 -0
  58. package/dist/app/components/nuxt-teleport-island-component.js +38 -0
  59. package/dist/app/components/nuxt-teleport-island-slot.d.ts +32 -0
  60. package/dist/app/components/nuxt-teleport-island-slot.js +53 -0
  61. package/dist/app/components/nuxt-time.d.vue.ts +37 -0
  62. package/dist/app/components/nuxt-time.vue +148 -0
  63. package/dist/app/components/nuxt-time.vue.d.ts +37 -0
  64. package/dist/app/components/route-provider.d.ts +48 -0
  65. package/dist/app/components/route-provider.js +49 -0
  66. package/dist/app/components/server-placeholder.d.ts +2 -0
  67. package/dist/app/components/server-placeholder.js +7 -0
  68. package/dist/app/components/test-component-wrapper.d.ts +4 -0
  69. package/dist/app/components/test-component-wrapper.js +27 -0
  70. package/dist/app/components/utils.d.ts +48 -0
  71. package/dist/app/components/utils.js +126 -0
  72. package/dist/app/components/welcome.d.vue.ts +24 -0
  73. package/dist/app/components/welcome.vue +34 -0
  74. package/dist/app/components/welcome.vue.d.ts +24 -0
  75. package/dist/app/composables/asyncContext.d.ts +2 -0
  76. package/dist/app/composables/asyncContext.js +7 -0
  77. package/dist/app/composables/asyncData.d.ts +146 -0
  78. package/dist/app/composables/asyncData.js +491 -0
  79. package/dist/app/composables/chunk.d.ts +25 -0
  80. package/dist/app/composables/chunk.js +30 -0
  81. package/dist/app/composables/component.d.ts +4 -0
  82. package/dist/app/composables/component.js +82 -0
  83. package/dist/app/composables/cookie.d.ts +22 -0
  84. package/dist/app/composables/cookie.js +205 -0
  85. package/dist/app/composables/error.d.ts +25 -0
  86. package/dist/app/composables/error.js +39 -0
  87. package/dist/app/composables/fetch.d.ts +37 -0
  88. package/dist/app/composables/fetch.js +123 -0
  89. package/dist/app/composables/head.d.ts +1 -0
  90. package/dist/app/composables/head.js +1 -0
  91. package/dist/app/composables/hydrate.d.ts +9 -0
  92. package/dist/app/composables/hydrate.js +14 -0
  93. package/dist/app/composables/id.d.ts +3 -0
  94. package/dist/app/composables/id.js +2 -0
  95. package/dist/app/composables/index.d.ts +29 -0
  96. package/dist/app/composables/index.js +21 -0
  97. package/dist/app/composables/lazy-hydration.d.ts +40 -0
  98. package/dist/app/composables/lazy-hydration.js +2 -0
  99. package/dist/app/composables/loading-indicator.d.ts +39 -0
  100. package/dist/app/composables/loading-indicator.js +142 -0
  101. package/dist/app/composables/manifest.d.ts +20 -0
  102. package/dist/app/composables/manifest.js +59 -0
  103. package/dist/app/composables/once.d.ts +14 -0
  104. package/dist/app/composables/once.js +49 -0
  105. package/dist/app/composables/payload.d.ts +27 -0
  106. package/dist/app/composables/payload.js +137 -0
  107. package/dist/app/composables/preload.d.ts +20 -0
  108. package/dist/app/composables/preload.js +55 -0
  109. package/dist/app/composables/preview.d.ts +38 -0
  110. package/dist/app/composables/preview.js +61 -0
  111. package/dist/app/composables/ready.d.ts +2 -0
  112. package/dist/app/composables/ready.js +15 -0
  113. package/dist/app/composables/route-announcer.d.ts +19 -0
  114. package/dist/app/composables/route-announcer.js +55 -0
  115. package/dist/app/composables/router.d.ts +96 -0
  116. package/dist/app/composables/router.js +197 -0
  117. package/dist/app/composables/runtime-hook.d.ts +9 -0
  118. package/dist/app/composables/runtime-hook.js +7 -0
  119. package/dist/app/composables/script-stubs.d.ts +32 -0
  120. package/dist/app/composables/script-stubs.js +104 -0
  121. package/dist/app/composables/ssr.d.ts +33 -0
  122. package/dist/app/composables/ssr.js +113 -0
  123. package/dist/app/composables/state.d.ts +11 -0
  124. package/dist/app/composables/state.js +40 -0
  125. package/dist/app/composables/url.d.ts +3 -0
  126. package/dist/app/composables/url.js +8 -0
  127. package/dist/app/config.d.ts +14 -0
  128. package/dist/app/config.js +72 -0
  129. package/dist/app/entry-spa.d.ts +2 -0
  130. package/dist/app/entry-spa.js +2 -0
  131. package/dist/app/entry.async.d.ts +3 -0
  132. package/dist/app/entry.async.js +5 -0
  133. package/dist/app/entry.d.ts +7 -0
  134. package/dist/app/entry.js +78 -0
  135. package/dist/app/index.d.ts +12 -0
  136. package/dist/app/index.js +8 -0
  137. package/dist/app/middleware/manifest-route-rule.d.ts +2 -0
  138. package/dist/app/middleware/manifest-route-rule.js +17 -0
  139. package/dist/app/nuxt.d.ts +271 -0
  140. package/dist/app/nuxt.js +279 -0
  141. package/dist/app/plugins/browser-devtools-timing.client.d.ts +2 -0
  142. package/dist/app/plugins/browser-devtools-timing.client.js +23 -0
  143. package/dist/app/plugins/check-if-layout-used.d.ts +2 -0
  144. package/dist/app/plugins/check-if-layout-used.js +28 -0
  145. package/dist/app/plugins/check-outdated-build.client.d.ts +2 -0
  146. package/dist/app/plugins/check-outdated-build.client.js +39 -0
  147. package/dist/app/plugins/chunk-reload-immediate.client.d.ts +2 -0
  148. package/dist/app/plugins/chunk-reload-immediate.client.js +20 -0
  149. package/dist/app/plugins/chunk-reload.client.d.ts +2 -0
  150. package/dist/app/plugins/chunk-reload.client.js +30 -0
  151. package/dist/app/plugins/cross-origin-prefetch.client.d.ts +2 -0
  152. package/dist/app/plugins/cross-origin-prefetch.client.js +37 -0
  153. package/dist/app/plugins/debug-hooks.d.ts +2 -0
  154. package/dist/app/plugins/debug-hooks.js +9 -0
  155. package/dist/app/plugins/dev-server-logs.d.ts +2 -0
  156. package/dist/app/plugins/dev-server-logs.js +60 -0
  157. package/dist/app/plugins/navigation-repaint.client.d.ts +2 -0
  158. package/dist/app/plugins/navigation-repaint.client.js +16 -0
  159. package/dist/app/plugins/payload.client.d.ts +2 -0
  160. package/dist/app/plugins/payload.client.js +50 -0
  161. package/dist/app/plugins/preload.server.d.ts +2 -0
  162. package/dist/app/plugins/preload.server.js +13 -0
  163. package/dist/app/plugins/restore-state.client.d.ts +2 -0
  164. package/dist/app/plugins/restore-state.client.js +18 -0
  165. package/dist/app/plugins/revive-payload.client.d.ts +2 -0
  166. package/dist/app/plugins/revive-payload.client.js +44 -0
  167. package/dist/app/plugins/revive-payload.server.d.ts +2 -0
  168. package/dist/app/plugins/revive-payload.server.js +26 -0
  169. package/dist/app/plugins/router.d.ts +59 -0
  170. package/dist/app/plugins/router.js +222 -0
  171. package/dist/app/plugins/utils.d.ts +1 -0
  172. package/dist/app/plugins/utils.js +4 -0
  173. package/dist/app/plugins/view-transitions.client.d.ts +2 -0
  174. package/dist/app/plugins/view-transitions.client.js +55 -0
  175. package/dist/app/plugins/warn.dev.server.d.ts +2 -0
  176. package/dist/app/plugins/warn.dev.server.js +6 -0
  177. package/dist/app/types/augments.d.ts +49 -0
  178. package/dist/app/types/augments.js +0 -0
  179. package/dist/app/types.d.ts +39 -0
  180. package/dist/app/types.js +0 -0
  181. package/dist/app/utils.d.ts +13 -0
  182. package/dist/app/utils.js +34 -0
  183. package/dist/components/runtime/client-component.d.ts +2 -0
  184. package/dist/components/runtime/client-component.js +59 -0
  185. package/dist/components/runtime/lazy-hydrated-component.d.ts +124 -0
  186. package/dist/components/runtime/lazy-hydrated-component.js +101 -0
  187. package/dist/components/runtime/server-component.d.ts +20 -0
  188. package/dist/components/runtime/server-component.js +69 -0
  189. package/dist/head/runtime/components.d.ts +1058 -0
  190. package/dist/head/runtime/components.js +297 -0
  191. package/dist/head/runtime/composables.d.ts +25 -0
  192. package/dist/head/runtime/composables.js +47 -0
  193. package/dist/head/runtime/plugins/unhead.d.ts +2 -0
  194. package/dist/head/runtime/plugins/unhead.js +31 -0
  195. package/dist/head/runtime/types.d.ts +7 -0
  196. package/dist/head/runtime/types.js +0 -0
  197. package/dist/index.d.mts +9 -0
  198. package/dist/index.d.ts +9 -0
  199. package/dist/index.mjs +6974 -0
  200. package/dist/pages/runtime/app.d.vue.ts +3 -0
  201. package/dist/pages/runtime/app.vue +6 -0
  202. package/dist/pages/runtime/app.vue.d.ts +3 -0
  203. package/dist/pages/runtime/component-stub.d.ts +2 -0
  204. package/dist/pages/runtime/component-stub.js +1 -0
  205. package/dist/pages/runtime/composables.d.ts +58 -0
  206. package/dist/pages/runtime/composables.js +24 -0
  207. package/dist/pages/runtime/index.d.ts +3 -0
  208. package/dist/pages/runtime/index.js +1 -0
  209. package/dist/pages/runtime/page-placeholder.d.ts +4 -0
  210. package/dist/pages/runtime/page-placeholder.js +11 -0
  211. package/dist/pages/runtime/page.d.ts +30 -0
  212. package/dist/pages/runtime/page.js +212 -0
  213. package/dist/pages/runtime/plugins/check-if-page-unused.d.ts +2 -0
  214. package/dist/pages/runtime/plugins/check-if-page-unused.js +29 -0
  215. package/dist/pages/runtime/plugins/prefetch.client.d.ts +2 -0
  216. package/dist/pages/runtime/plugins/prefetch.client.js +41 -0
  217. package/dist/pages/runtime/plugins/prerender.server.d.ts +2 -0
  218. package/dist/pages/runtime/plugins/prerender.server.js +47 -0
  219. package/dist/pages/runtime/plugins/router.d.ts +6 -0
  220. package/dist/pages/runtime/plugins/router.js +236 -0
  221. package/dist/pages/runtime/router.options.d.ts +3 -0
  222. package/dist/pages/runtime/router.options.js +60 -0
  223. package/dist/pages/runtime/utils.d.ts +11 -0
  224. package/dist/pages/runtime/utils.js +18 -0
  225. package/dist/pages/runtime/validate.d.ts +2 -0
  226. package/dist/pages/runtime/validate.js +23 -0
  227. package/kit.d.ts +1 -0
  228. package/kit.js +1 -0
  229. package/package.json +156 -0
  230. package/schema.d.ts +1 -0
  231. package/schema.js +1 -0
  232. package/types.d.mts +14 -0
  233. package/types.d.ts +14 -0
@@ -0,0 +1,55 @@
1
+ import { getCurrentScope, onScopeDispose, shallowRef } from "vue";
2
+ import { useNuxtApp } from "../nuxt.js";
3
+ import { injectHead } from "./head.js";
4
+ function createRouteAnnouncer(opts = {}) {
5
+ const message = shallowRef("");
6
+ const politeness = shallowRef(opts.politeness || "polite");
7
+ const activeHead = injectHead();
8
+ function set(messageValue = "", politenessSetting = "polite") {
9
+ message.value = messageValue;
10
+ politeness.value = politenessSetting;
11
+ }
12
+ function polite(message2) {
13
+ return set(message2, "polite");
14
+ }
15
+ function assertive(message2) {
16
+ return set(message2, "assertive");
17
+ }
18
+ function _updateMessageWithPageHeading() {
19
+ set(document?.title?.trim(), politeness.value);
20
+ }
21
+ function _cleanup() {
22
+ activeHead?.hooks?.removeHook("dom:rendered", _updateMessageWithPageHeading);
23
+ }
24
+ _updateMessageWithPageHeading();
25
+ activeHead?.hooks?.hook("dom:rendered", () => {
26
+ _updateMessageWithPageHeading();
27
+ });
28
+ return {
29
+ _cleanup,
30
+ message,
31
+ politeness,
32
+ set,
33
+ polite,
34
+ assertive
35
+ };
36
+ }
37
+ export function useRouteAnnouncer(opts = {}) {
38
+ const nuxtApp = useNuxtApp();
39
+ const announcer = nuxtApp._routeAnnouncer ||= createRouteAnnouncer(opts);
40
+ if (opts.politeness !== announcer.politeness.value) {
41
+ announcer.politeness.value = opts.politeness || "polite";
42
+ }
43
+ if (import.meta.client && getCurrentScope()) {
44
+ nuxtApp._routeAnnouncerDeps ||= 0;
45
+ nuxtApp._routeAnnouncerDeps++;
46
+ onScopeDispose(() => {
47
+ nuxtApp._routeAnnouncerDeps--;
48
+ if (nuxtApp._routeAnnouncerDeps === 0) {
49
+ announcer._cleanup();
50
+ delete nuxtApp._routeAnnouncer;
51
+ }
52
+ });
53
+ }
54
+ return announcer;
55
+ }
@@ -0,0 +1,96 @@
1
+ import type { NavigationFailure, NavigationGuard, RouteLocationNormalized, RouteLocationRaw, useRoute as _useRoute, useRouter as _useRouter } from 'vue-router';
2
+ import type { PageMeta } from '../../pages/runtime/composables.js';
3
+ import type { NuxtError } from './error.js';
4
+ /** @since 3.0.0 */
5
+ export declare const useRouter: typeof _useRouter;
6
+ /** @since 3.0.0 */
7
+ export declare const useRoute: typeof _useRoute;
8
+ /** @since 3.0.0 */
9
+ export declare const onBeforeRouteLeave: (guard: NavigationGuard) => void;
10
+ /** @since 3.0.0 */
11
+ export declare const onBeforeRouteUpdate: (guard: NavigationGuard) => void;
12
+ export interface RouteMiddleware {
13
+ (to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>;
14
+ }
15
+ /** @since 3.0.0 */
16
+ export declare function defineNuxtRouteMiddleware(middleware: RouteMiddleware): RouteMiddleware;
17
+ export interface AddRouteMiddlewareOptions {
18
+ global?: boolean;
19
+ }
20
+ interface AddRouteMiddleware {
21
+ (name: string, middleware: RouteMiddleware, options?: AddRouteMiddlewareOptions): void;
22
+ (middleware: RouteMiddleware): void;
23
+ }
24
+ /** @since 3.0.0 */
25
+ export declare const addRouteMiddleware: AddRouteMiddleware;
26
+ type Without<T, U> = {
27
+ [P in Exclude<keyof T, keyof U>]?: never;
28
+ };
29
+ type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
30
+ export type OpenWindowFeatures = {
31
+ popup?: boolean;
32
+ noopener?: boolean;
33
+ noreferrer?: boolean;
34
+ } & XOR<{
35
+ width?: number;
36
+ }, {
37
+ innerWidth?: number;
38
+ }> & XOR<{
39
+ height?: number;
40
+ }, {
41
+ innerHeight?: number;
42
+ }> & XOR<{
43
+ left?: number;
44
+ }, {
45
+ screenX?: number;
46
+ }> & XOR<{
47
+ top?: number;
48
+ }, {
49
+ screenY?: number;
50
+ }>;
51
+ export type OpenOptions = {
52
+ target: '_blank' | '_parent' | '_self' | '_top' | (string & {});
53
+ windowFeatures?: OpenWindowFeatures;
54
+ };
55
+ export interface NavigateToOptions {
56
+ /**
57
+ * Whether or not the given route should replace the current route in the navigation history, rather than push it.
58
+ */
59
+ replace?: boolean;
60
+ /**
61
+ * The status code to emit with the navigation. Defaults to `302 Found` when used on server side redirects.
62
+ */
63
+ redirectCode?: number;
64
+ /**
65
+ * Whether or not the given route is a website/resource from a different origin. By default, navigating to external resources without setting `external: true` would result in an error.
66
+ */
67
+ external?: boolean;
68
+ open?: OpenOptions;
69
+ }
70
+ /**
71
+ * A helper that aids in programmatic navigation within your Nuxt application.
72
+ *
73
+ * Can be called on the server and on the client, within pages, route middleware, plugins, and more.
74
+ * @param {RouteLocationRaw | undefined | null} [to] - The route to navigate to. Accepts a route object, string path, `undefined`, or `null`. Defaults to '/'.
75
+ * @param {NavigateToOptions} [options] - Optional customization for controlling the behavior of the navigation.
76
+ * @returns {Promise<void | NavigationFailure | false> | false | void | RouteLocationRaw} The navigation result, which varies depending on context and options.
77
+ * @see https://nuxt.com/docs/4.x/api/utils/navigate-to
78
+ * @since 3.0.0
79
+ */
80
+ export declare const navigateTo: (to: RouteLocationRaw | undefined | null, options?: NavigateToOptions) => Promise<void | NavigationFailure | false> | false | void | RouteLocationRaw;
81
+ /**
82
+ * This will abort navigation within a Nuxt route middleware handler.
83
+ * @since 3.0.0
84
+ */
85
+ export declare const abortNavigation: (err?: string | Partial<NuxtError>) => boolean;
86
+ /** @since 3.0.0 */
87
+ export declare const setPageLayout: (layout: unknown extends PageMeta["layout"] ? string : PageMeta["layout"]) => void;
88
+ /**
89
+ * @internal
90
+ */
91
+ export declare function resolveRouteObject(to: Exclude<RouteLocationRaw, string>): string;
92
+ /**
93
+ * @internal
94
+ */
95
+ export declare function encodeURL(location: string, isExternalHost?: boolean): string;
96
+ export {};
@@ -0,0 +1,197 @@
1
+ import { getCurrentInstance, hasInjectionContext, inject, onScopeDispose } from "vue";
2
+ import { sanitizeStatusCode } from "h3";
3
+ import { hasProtocol, isScriptProtocol, joinURL, parseQuery, parseURL, withQuery } from "ufo";
4
+ import { useNuxtApp, useRuntimeConfig } from "../nuxt.js";
5
+ import { PageRouteSymbol } from "../components/injections.js";
6
+ import { createError, showError } from "./error.js";
7
+ import { getUserTrace } from "../utils.js";
8
+ export const useRouter = () => {
9
+ return useNuxtApp()?.$router;
10
+ };
11
+ export const useRoute = () => {
12
+ if (import.meta.dev && !getCurrentInstance() && isProcessingMiddleware()) {
13
+ const middleware = useNuxtApp()._processingMiddleware;
14
+ const trace = getUserTrace().map(({ source, line, column }) => `at ${source}:${line}:${column}`).join("\n");
15
+ console.warn(`[nuxt] \`useRoute\` was called within middleware${typeof middleware === "string" ? ` (\`${middleware}\`)` : ""}. This may lead to misleading results. Instead, use the (to, from) arguments passed to the middleware to access the new and old routes. Learn more: https://nuxt.com/docs/4.x/directory-structure/app/middleware#accessing-route-in-middleware` + ("\n" + trace));
16
+ }
17
+ if (hasInjectionContext()) {
18
+ return inject(PageRouteSymbol, useNuxtApp()._route);
19
+ }
20
+ return useNuxtApp()._route;
21
+ };
22
+ export const onBeforeRouteLeave = (guard) => {
23
+ const unsubscribe = useRouter().beforeEach((to, from, next) => {
24
+ if (to === from) {
25
+ return;
26
+ }
27
+ return guard(to, from, next);
28
+ });
29
+ onScopeDispose(unsubscribe);
30
+ };
31
+ export const onBeforeRouteUpdate = (guard) => {
32
+ const unsubscribe = useRouter().beforeEach(guard);
33
+ onScopeDispose(unsubscribe);
34
+ };
35
+ // @__NO_SIDE_EFFECTS__
36
+ export function defineNuxtRouteMiddleware(middleware) {
37
+ return middleware;
38
+ }
39
+ export const addRouteMiddleware = (name, middleware, options = {}) => {
40
+ const nuxtApp = useNuxtApp();
41
+ const global = options.global || typeof name !== "string";
42
+ const mw = typeof name !== "string" ? name : middleware;
43
+ if (!mw) {
44
+ console.warn("[nuxt] No route middleware passed to `addRouteMiddleware`.", name);
45
+ return;
46
+ }
47
+ if (global) {
48
+ nuxtApp._middleware.global.push(mw);
49
+ } else {
50
+ nuxtApp._middleware.named[name] = mw;
51
+ }
52
+ };
53
+ const isProcessingMiddleware = () => {
54
+ try {
55
+ if (useNuxtApp()._processingMiddleware) {
56
+ return true;
57
+ }
58
+ } catch {
59
+ return false;
60
+ }
61
+ return false;
62
+ };
63
+ const URL_QUOTE_RE = /"/g;
64
+ export const navigateTo = (to, options) => {
65
+ to ||= "/";
66
+ const toPath = typeof to === "string" ? to : "path" in to ? resolveRouteObject(to) : useRouter().resolve(to).href;
67
+ if (import.meta.client && options?.open) {
68
+ const { target = "_blank", windowFeatures = {} } = options.open;
69
+ const features = [];
70
+ for (const [feature, value] of Object.entries(windowFeatures)) {
71
+ if (value !== void 0) {
72
+ features.push(`${feature.toLowerCase()}=${value}`);
73
+ }
74
+ }
75
+ open(toPath, target, features.join(", "));
76
+ return Promise.resolve();
77
+ }
78
+ const isExternalHost = hasProtocol(toPath, { acceptRelative: true });
79
+ const isExternal = options?.external || isExternalHost;
80
+ if (isExternal) {
81
+ if (!options?.external) {
82
+ throw new Error("Navigating to an external URL is not allowed by default. Use `navigateTo(url, { external: true })`.");
83
+ }
84
+ const { protocol } = new URL(toPath, import.meta.client ? window.location.href : "http://localhost");
85
+ if (protocol && isScriptProtocol(protocol)) {
86
+ throw new Error(`Cannot navigate to a URL with '${protocol}' protocol.`);
87
+ }
88
+ }
89
+ const inMiddleware = isProcessingMiddleware();
90
+ if (import.meta.client && !isExternal && inMiddleware) {
91
+ if (options?.replace) {
92
+ if (typeof to === "string") {
93
+ const { pathname, search, hash } = parseURL(to);
94
+ return {
95
+ path: pathname,
96
+ ...search && { query: parseQuery(search) },
97
+ ...hash && { hash },
98
+ replace: true
99
+ };
100
+ }
101
+ return { ...to, replace: true };
102
+ }
103
+ return to;
104
+ }
105
+ const router = useRouter();
106
+ const nuxtApp = useNuxtApp();
107
+ if (import.meta.server) {
108
+ if (nuxtApp.ssrContext) {
109
+ const fullPath = typeof to === "string" || isExternal ? toPath : router.resolve(to).fullPath || "/";
110
+ const location2 = isExternal ? toPath : joinURL(useRuntimeConfig().app.baseURL, fullPath);
111
+ const redirect = async function(response) {
112
+ await nuxtApp.callHook("app:redirected");
113
+ const encodedLoc = location2.replace(URL_QUOTE_RE, "%22");
114
+ const encodedHeader = encodeURL(location2, isExternalHost);
115
+ nuxtApp.ssrContext._renderResponse = {
116
+ statusCode: sanitizeStatusCode(options?.redirectCode || 302, 302),
117
+ body: `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head></html>`,
118
+ headers: { location: encodedHeader }
119
+ };
120
+ return response;
121
+ };
122
+ if (!isExternal && inMiddleware) {
123
+ router.afterEach((final) => final.fullPath === fullPath ? redirect(false) : void 0);
124
+ return to;
125
+ }
126
+ return redirect(!inMiddleware ? void 0 : (
127
+ /* abort route navigation */
128
+ false
129
+ ));
130
+ }
131
+ }
132
+ if (isExternal) {
133
+ nuxtApp._scope.stop();
134
+ if (options?.replace) {
135
+ location.replace(toPath);
136
+ } else {
137
+ location.href = toPath;
138
+ }
139
+ if (inMiddleware) {
140
+ if (!nuxtApp.isHydrating) {
141
+ return false;
142
+ }
143
+ return new Promise(() => {
144
+ });
145
+ }
146
+ return Promise.resolve();
147
+ }
148
+ return options?.replace ? router.replace(to) : router.push(to);
149
+ };
150
+ export const abortNavigation = (err) => {
151
+ if (import.meta.dev && !isProcessingMiddleware()) {
152
+ throw new Error("abortNavigation() is only usable inside a route middleware handler.");
153
+ }
154
+ if (!err) {
155
+ return false;
156
+ }
157
+ err = createError(err);
158
+ if (err.fatal) {
159
+ useNuxtApp().runWithContext(() => showError(err));
160
+ }
161
+ throw err;
162
+ };
163
+ export const setPageLayout = (layout) => {
164
+ const nuxtApp = useNuxtApp();
165
+ if (import.meta.server) {
166
+ if (import.meta.dev && getCurrentInstance() && nuxtApp.payload.state._layout !== layout) {
167
+ console.warn("[warn] [nuxt] `setPageLayout` should not be called to change the layout on the server within a component as this will cause hydration errors.");
168
+ }
169
+ nuxtApp.payload.state._layout = layout;
170
+ }
171
+ if (import.meta.dev && nuxtApp.isHydrating && nuxtApp.payload.serverRendered && nuxtApp.payload.state._layout !== layout) {
172
+ console.warn("[warn] [nuxt] `setPageLayout` should not be called to change the layout during hydration as this will cause hydration errors.");
173
+ }
174
+ const inMiddleware = isProcessingMiddleware();
175
+ if (inMiddleware || import.meta.server || nuxtApp.isHydrating) {
176
+ const unsubscribe = useRouter().beforeResolve((to) => {
177
+ to.meta.layout = layout;
178
+ unsubscribe();
179
+ });
180
+ }
181
+ if (!inMiddleware) {
182
+ useRoute().meta.layout = layout;
183
+ }
184
+ };
185
+ export function resolveRouteObject(to) {
186
+ return withQuery(to.path || "", to.query || {}) + (to.hash || "");
187
+ }
188
+ export function encodeURL(location2, isExternalHost = false) {
189
+ const url = new URL(location2, "http://localhost");
190
+ if (!isExternalHost) {
191
+ return url.pathname + url.search + url.hash;
192
+ }
193
+ if (location2.startsWith("//")) {
194
+ return url.toString().replace(url.protocol, "");
195
+ }
196
+ return url.toString();
197
+ }
@@ -0,0 +1,9 @@
1
+ import type { HookCallback } from 'hookable';
2
+ import type { RuntimeNuxtHooks } from '../nuxt.js';
3
+ /**
4
+ * Registers a runtime hook in a Nuxt application and ensures it is properly disposed of when the scope is destroyed.
5
+ * @param name - The name of the hook to register.
6
+ * @param fn - The callback function to be executed when the hook is triggered.
7
+ * @since 3.14.0
8
+ */
9
+ export declare function useRuntimeHook<THookName extends keyof RuntimeNuxtHooks>(name: THookName, fn: RuntimeNuxtHooks[THookName] extends HookCallback ? RuntimeNuxtHooks[THookName] : never): void;
@@ -0,0 +1,7 @@
1
+ import { onScopeDispose } from "vue";
2
+ import { useNuxtApp } from "../nuxt.js";
3
+ export function useRuntimeHook(name, fn) {
4
+ const nuxtApp = useNuxtApp();
5
+ const unregister = nuxtApp.hook(name, fn);
6
+ onScopeDispose(unregister);
7
+ }
@@ -0,0 +1,32 @@
1
+ import type { UseScriptInput } from '@unhead/vue/scripts';
2
+ export declare function useScript<T extends Record<string | symbol, any>>(input: UseScriptInput, options?: Record<string, unknown>): void;
3
+ export declare function useScriptTriggerElement(...args: unknown[]): void;
4
+ export declare function useScriptTriggerConsent(...args: unknown[]): void;
5
+ export declare function useScriptEventPage(...args: unknown[]): void;
6
+ export declare function useScriptGoogleAnalytics(...args: unknown[]): void;
7
+ export declare function useScriptPlausibleAnalytics(...args: unknown[]): void;
8
+ export declare function useScriptCloudflareWebAnalytics(...args: unknown[]): void;
9
+ export declare function useScriptCrisp(...args: unknown[]): void;
10
+ export declare function useScriptFathomAnalytics(...args: unknown[]): void;
11
+ export declare function useScriptMatomoAnalytics(...args: unknown[]): void;
12
+ export declare function useScriptGoogleTagManager(...args: unknown[]): void;
13
+ export declare function useScriptSegment(...args: unknown[]): void;
14
+ export declare function useScriptClarity(...args: unknown[]): void;
15
+ export declare function useScriptMetaPixel(...args: unknown[]): void;
16
+ export declare function useScriptXPixel(...args: unknown[]): void;
17
+ export declare function useScriptIntercom(...args: unknown[]): void;
18
+ export declare function useScriptHotjar(...args: unknown[]): void;
19
+ export declare function useScriptStripe(...args: unknown[]): void;
20
+ export declare function useScriptLemonSqueezy(...args: unknown[]): void;
21
+ export declare function useScriptVimeoPlayer(...args: unknown[]): void;
22
+ export declare function useScriptYouTubeIframe(...args: unknown[]): void;
23
+ export declare function useScriptGoogleMaps(...args: unknown[]): void;
24
+ export declare function useScriptNpm(...args: unknown[]): void;
25
+ export declare function useScriptGoogleAdsense(...args: unknown[]): void;
26
+ export declare function useScriptYouTubePlayer(...args: unknown[]): void;
27
+ export declare function useScriptUmamiAnalytics(...args: unknown[]): void;
28
+ export declare function useScriptSnapchatPixel(...args: unknown[]): void;
29
+ export declare function useScriptRybbitAnalytics(...args: unknown[]): void;
30
+ export declare function useScriptDatabuddyAnalytics(...args: unknown[]): void;
31
+ export declare function useScriptRedditPixel(...args: unknown[]): void;
32
+ export declare function useScriptPayPal(...args: unknown[]): void;
@@ -0,0 +1,104 @@
1
+ import { createError } from "./error.js";
2
+ function renderStubMessage(name) {
3
+ const message = `\`${name}\` is provided by @nuxt/scripts. Check your console to install it or run 'npx nuxt module add @nuxt/scripts' to install it.`;
4
+ if (import.meta.client) {
5
+ throw createError({
6
+ fatal: true,
7
+ statusCode: 500,
8
+ statusMessage: message
9
+ });
10
+ }
11
+ }
12
+ export function useScript(input, options) {
13
+ renderStubMessage("useScript");
14
+ }
15
+ export function useScriptTriggerElement(...args) {
16
+ renderStubMessage("useScriptTriggerElement");
17
+ }
18
+ export function useScriptTriggerConsent(...args) {
19
+ renderStubMessage("useScriptTriggerConsent");
20
+ }
21
+ export function useScriptEventPage(...args) {
22
+ renderStubMessage("useScriptEventPage");
23
+ }
24
+ export function useScriptGoogleAnalytics(...args) {
25
+ renderStubMessage("useScriptGoogleAnalytics");
26
+ }
27
+ export function useScriptPlausibleAnalytics(...args) {
28
+ renderStubMessage("useScriptPlausibleAnalytics");
29
+ }
30
+ export function useScriptCloudflareWebAnalytics(...args) {
31
+ renderStubMessage("useScriptCloudflareWebAnalytics");
32
+ }
33
+ export function useScriptCrisp(...args) {
34
+ renderStubMessage("useScriptCrisp");
35
+ }
36
+ export function useScriptFathomAnalytics(...args) {
37
+ renderStubMessage("useScriptFathomAnalytics");
38
+ }
39
+ export function useScriptMatomoAnalytics(...args) {
40
+ renderStubMessage("useScriptMatomoAnalytics");
41
+ }
42
+ export function useScriptGoogleTagManager(...args) {
43
+ renderStubMessage("useScriptGoogleTagManager");
44
+ }
45
+ export function useScriptSegment(...args) {
46
+ renderStubMessage("useScriptSegment");
47
+ }
48
+ export function useScriptClarity(...args) {
49
+ renderStubMessage("useScriptClarity");
50
+ }
51
+ export function useScriptMetaPixel(...args) {
52
+ renderStubMessage("useScriptMetaPixel");
53
+ }
54
+ export function useScriptXPixel(...args) {
55
+ renderStubMessage("useScriptXPixel");
56
+ }
57
+ export function useScriptIntercom(...args) {
58
+ renderStubMessage("useScriptIntercom");
59
+ }
60
+ export function useScriptHotjar(...args) {
61
+ renderStubMessage("useScriptHotjar");
62
+ }
63
+ export function useScriptStripe(...args) {
64
+ renderStubMessage("useScriptStripe");
65
+ }
66
+ export function useScriptLemonSqueezy(...args) {
67
+ renderStubMessage("useScriptLemonSqueezy");
68
+ }
69
+ export function useScriptVimeoPlayer(...args) {
70
+ renderStubMessage("useScriptVimeoPlayer");
71
+ }
72
+ export function useScriptYouTubeIframe(...args) {
73
+ renderStubMessage("useScriptYouTubeIframe");
74
+ }
75
+ export function useScriptGoogleMaps(...args) {
76
+ renderStubMessage("useScriptGoogleMaps");
77
+ }
78
+ export function useScriptNpm(...args) {
79
+ renderStubMessage("useScriptNpm");
80
+ }
81
+ export function useScriptGoogleAdsense(...args) {
82
+ renderStubMessage("useScriptGoogleAdsense");
83
+ }
84
+ export function useScriptYouTubePlayer(...args) {
85
+ renderStubMessage("useScriptYouTubePlayer");
86
+ }
87
+ export function useScriptUmamiAnalytics(...args) {
88
+ renderStubMessage("useScriptUmamiAnalytics");
89
+ }
90
+ export function useScriptSnapchatPixel(...args) {
91
+ renderStubMessage("useScriptSnapchatPixel");
92
+ }
93
+ export function useScriptRybbitAnalytics(...args) {
94
+ renderStubMessage("useScriptRybbitAnalytics");
95
+ }
96
+ export function useScriptDatabuddyAnalytics(...args) {
97
+ renderStubMessage("useScriptDatabuddyAnalytics");
98
+ }
99
+ export function useScriptRedditPixel(...args) {
100
+ renderStubMessage("useScriptRedditPixel");
101
+ }
102
+ export function useScriptPayPal(...args) {
103
+ renderStubMessage("useScriptPayPal");
104
+ }
@@ -0,0 +1,33 @@
1
+ import type { H3Event } from 'h3';
2
+ import type { H3Event$Fetch } from 'nitropack/types';
3
+ import type { NuxtApp } from '../nuxt.js';
4
+ /** @since 3.0.0 */
5
+ export declare function useRequestEvent(nuxtApp?: NuxtApp): H3Event<import("h3").EventHandlerRequest> | undefined;
6
+ /** @since 3.0.0 */
7
+ export declare function useRequestHeaders<K extends string = string>(include: K[]): {
8
+ [key in Lowercase<K>]?: string;
9
+ };
10
+ export declare function useRequestHeaders(): Readonly<Record<string, string>>;
11
+ /** @since 3.9.0 */
12
+ export declare function useRequestHeader(header: string): string | undefined;
13
+ /** @since 3.2.0 */
14
+ export declare function useRequestFetch(): H3Event$Fetch | typeof global.$fetch;
15
+ /** @since 3.0.0 */
16
+ export declare function setResponseStatus(event: H3Event, code?: number, message?: string): void;
17
+ /** @deprecated Pass `event` as first option. */
18
+ export declare function setResponseStatus(code: number, message?: string): void;
19
+ /** @since 3.14.0 */
20
+ export declare function useResponseHeader(header: string): import("vue").Ref<any, any>;
21
+ /** @since 3.8.0 */
22
+ export declare function prerenderRoutes(path: string | string[]): void;
23
+ /**
24
+ * `onPrehydrate` is a composable lifecycle hook that allows you to run a callback on the client immediately before
25
+ * Nuxt hydrates the page. This is an advanced feature.
26
+ *
27
+ * The callback will be stringified and inlined in the HTML so it should not have any external
28
+ * dependencies (such as auto-imports) or refer to variables defined outside the callback.
29
+ *
30
+ * The callback will run before Nuxt runtime initializes so it should not rely on the Nuxt or Vue context.
31
+ * @since 3.12.0
32
+ */
33
+ export declare function onPrehydrate(callback: (el: HTMLElement) => void): void;
@@ -0,0 +1,113 @@
1
+ import { setResponseStatus as _setResponseStatus, appendHeader, getRequestHeader, getRequestHeaders, getResponseHeader, removeResponseHeader, setResponseHeader } from "h3";
2
+ import { computed, getCurrentInstance, ref } from "vue";
3
+ import { useNuxtApp } from "../nuxt.js";
4
+ import { toArray } from "../utils.js";
5
+ import { useHead } from "./head.js";
6
+ export function useRequestEvent(nuxtApp) {
7
+ if (import.meta.client) {
8
+ return;
9
+ }
10
+ nuxtApp ||= useNuxtApp();
11
+ return nuxtApp.ssrContext?.event;
12
+ }
13
+ export function useRequestHeaders(include) {
14
+ if (import.meta.client) {
15
+ return {};
16
+ }
17
+ const event = useRequestEvent();
18
+ const _headers = event ? getRequestHeaders(event) : {};
19
+ if (!include || !event) {
20
+ return _headers;
21
+ }
22
+ const headers = /* @__PURE__ */ Object.create(null);
23
+ for (const _key of include) {
24
+ const key = _key.toLowerCase();
25
+ const header = _headers[key];
26
+ if (header) {
27
+ headers[key] = header;
28
+ }
29
+ }
30
+ return headers;
31
+ }
32
+ export function useRequestHeader(header) {
33
+ if (import.meta.client) {
34
+ return void 0;
35
+ }
36
+ const event = useRequestEvent();
37
+ return event ? getRequestHeader(event, header) : void 0;
38
+ }
39
+ export function useRequestFetch() {
40
+ if (import.meta.client) {
41
+ return globalThis.$fetch;
42
+ }
43
+ return useRequestEvent()?.$fetch || globalThis.$fetch;
44
+ }
45
+ export function setResponseStatus(arg1, arg2, arg3) {
46
+ if (import.meta.client) {
47
+ return;
48
+ }
49
+ if (arg1 && typeof arg1 !== "number") {
50
+ return _setResponseStatus(arg1, arg2, arg3);
51
+ }
52
+ const event = useRequestEvent();
53
+ if (event) {
54
+ return _setResponseStatus(event, arg1, arg2);
55
+ }
56
+ }
57
+ export function useResponseHeader(header) {
58
+ if (import.meta.client) {
59
+ if (import.meta.dev) {
60
+ return computed({
61
+ get: () => void 0,
62
+ set: () => console.warn("[nuxt] Setting response headers is not supported in the browser.")
63
+ });
64
+ }
65
+ return ref();
66
+ }
67
+ const event = useRequestEvent();
68
+ return computed({
69
+ get() {
70
+ return getResponseHeader(event, header);
71
+ },
72
+ set(newValue) {
73
+ if (!newValue) {
74
+ return removeResponseHeader(event, header);
75
+ }
76
+ return setResponseHeader(event, header, newValue);
77
+ }
78
+ });
79
+ }
80
+ export function prerenderRoutes(path) {
81
+ if (!import.meta.server || !import.meta.prerender) {
82
+ return;
83
+ }
84
+ const paths = toArray(path);
85
+ appendHeader(useRequestEvent(), "x-nitro-prerender", paths.map((p) => encodeURIComponent(p)).join(", "));
86
+ }
87
+ const PREHYDRATE_ATTR_KEY = "data-prehydrate-id";
88
+ export function onPrehydrate(callback, key) {
89
+ if (import.meta.client) {
90
+ return;
91
+ }
92
+ if (typeof callback !== "string") {
93
+ throw new TypeError("[nuxt] To transform a callback into a string, `onPrehydrate` must be processed by the Nuxt build pipeline. If it is called in a third-party library, make sure to add the library to `build.transpile`.");
94
+ }
95
+ const vm = getCurrentInstance();
96
+ if (vm && key) {
97
+ vm.attrs[PREHYDRATE_ATTR_KEY] ||= "";
98
+ key = ":" + key + ":";
99
+ if (!vm.attrs[PREHYDRATE_ATTR_KEY].includes(key)) {
100
+ vm.attrs[PREHYDRATE_ATTR_KEY] += key;
101
+ }
102
+ }
103
+ const code = vm && key ? `document.querySelectorAll('[${PREHYDRATE_ATTR_KEY}*=${JSON.stringify(key)}]').forEach` + callback : callback + "()";
104
+ useHead({
105
+ script: [{
106
+ key: vm && key ? key : void 0,
107
+ tagPosition: "bodyClose",
108
+ tagPriority: "critical",
109
+ innerHTML: code
110
+ }]
111
+ });
112
+ return vm && key ? vm.attrs[PREHYDRATE_ATTR_KEY] : void 0;
113
+ }
@@ -0,0 +1,11 @@
1
+ import type { Ref } from 'vue';
2
+ /**
3
+ * Create a global reactive ref that will be hydrated but not shared across ssr requests
4
+ * @since 3.0.0
5
+ * @param key a unique key ensuring that data fetching can be properly de-duplicated across requests
6
+ * @param init a function that provides initial value for the state when it's not initiated
7
+ */
8
+ export declare function useState<T>(key?: string, init?: (() => T | Ref<T>)): Ref<T>;
9
+ export declare function useState<T>(init?: (() => T | Ref<T>)): Ref<T>;
10
+ /** @since 3.6.0 */
11
+ export declare function clearNuxtState(keys?: string | string[] | ((key: string) => boolean)): void;