@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,236 @@
1
+ import { isReadonly, reactive, shallowReactive, shallowRef } from "vue";
2
+ import { START_LOCATION, createMemoryHistory, createRouter, createWebHashHistory, createWebHistory } from "vue-router";
3
+ import { isSamePath, withoutBase } from "ufo";
4
+ import { toArray } from "../utils.js";
5
+ import { getRouteRules } from "#app/composables/manifest";
6
+ import { defineNuxtPlugin, useRuntimeConfig } from "#app/nuxt";
7
+ import { clearError, createError, isNuxtError, showError, useError } from "#app/composables/error";
8
+ import { navigateTo } from "#app/composables/router";
9
+ import { appManifest as isAppManifestEnabled } from "#build/nuxt.config.mjs";
10
+ import _routes, { handleHotUpdate } from "#build/routes";
11
+ import routerOptions, { hashMode } from "#build/router.options";
12
+ import { globalMiddleware, namedMiddleware } from "#build/middleware";
13
+ function createCurrentLocation(base, location, renderedPath) {
14
+ const { pathname, search, hash } = location;
15
+ const hashPos = base.indexOf("#");
16
+ if (hashPos > -1) {
17
+ const slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
18
+ let pathFromHash = hash.slice(slicePos);
19
+ if (pathFromHash[0] !== "/") {
20
+ pathFromHash = "/" + pathFromHash;
21
+ }
22
+ return withoutBase(pathFromHash, "");
23
+ }
24
+ const displayedPath = withoutBase(pathname, base);
25
+ const path = !renderedPath || isSamePath(displayedPath, renderedPath) ? displayedPath : renderedPath;
26
+ return path + (path.includes("?") ? "" : search) + hash;
27
+ }
28
+ const plugin = defineNuxtPlugin({
29
+ name: "nuxt:router",
30
+ enforce: "pre",
31
+ async setup(nuxtApp) {
32
+ let routerBase = useRuntimeConfig().app.baseURL;
33
+ if (hashMode && !routerBase.includes("#")) {
34
+ routerBase += "#";
35
+ }
36
+ const history = routerOptions.history?.(routerBase) ?? (import.meta.client ? hashMode ? createWebHashHistory(routerBase) : createWebHistory(routerBase) : createMemoryHistory(routerBase));
37
+ const routes = routerOptions.routes ? await routerOptions.routes(_routes) ?? _routes : _routes;
38
+ let startPosition;
39
+ const router = createRouter({
40
+ ...routerOptions,
41
+ scrollBehavior: (to, from, savedPosition) => {
42
+ if (from === START_LOCATION) {
43
+ startPosition = savedPosition;
44
+ return;
45
+ }
46
+ if (routerOptions.scrollBehavior) {
47
+ router.options.scrollBehavior = routerOptions.scrollBehavior;
48
+ if ("scrollRestoration" in window.history) {
49
+ const unsub = router.beforeEach(() => {
50
+ unsub();
51
+ window.history.scrollRestoration = "manual";
52
+ });
53
+ }
54
+ return routerOptions.scrollBehavior(to, START_LOCATION, startPosition || savedPosition);
55
+ }
56
+ },
57
+ history,
58
+ routes
59
+ });
60
+ if (import.meta.hot) {
61
+ handleHotUpdate(router, routerOptions.routes ? routerOptions.routes : (routes2) => routes2);
62
+ }
63
+ if (import.meta.client && "scrollRestoration" in window.history) {
64
+ window.history.scrollRestoration = "auto";
65
+ }
66
+ nuxtApp.vueApp.use(router);
67
+ const previousRoute = shallowRef(router.currentRoute.value);
68
+ router.afterEach((_to, from) => {
69
+ previousRoute.value = from;
70
+ });
71
+ Object.defineProperty(nuxtApp.vueApp.config.globalProperties, "previousRoute", {
72
+ get: () => previousRoute.value
73
+ });
74
+ const initialURL = import.meta.server ? nuxtApp.ssrContext.url : createCurrentLocation(routerBase, window.location, nuxtApp.payload.path);
75
+ const _route = shallowRef(router.currentRoute.value);
76
+ const syncCurrentRoute = () => {
77
+ _route.value = router.currentRoute.value;
78
+ };
79
+ router.afterEach((to, from) => {
80
+ if (to.matched.at(-1)?.components?.default === from.matched.at(-1)?.components?.default) {
81
+ syncCurrentRoute();
82
+ }
83
+ });
84
+ const route = { sync: syncCurrentRoute };
85
+ for (const key in _route.value) {
86
+ Object.defineProperty(route, key, {
87
+ get: () => _route.value[key],
88
+ enumerable: true
89
+ });
90
+ }
91
+ nuxtApp._route = shallowReactive(route);
92
+ nuxtApp._middleware ||= {
93
+ global: [],
94
+ named: {}
95
+ };
96
+ const error = useError();
97
+ if (import.meta.client || !nuxtApp.ssrContext?.islandContext) {
98
+ router.afterEach(async (to, _from, failure) => {
99
+ delete nuxtApp._processingMiddleware;
100
+ if (import.meta.client && !nuxtApp.isHydrating && error.value) {
101
+ await nuxtApp.runWithContext(clearError);
102
+ }
103
+ if (failure) {
104
+ await nuxtApp.callHook("page:loading:end");
105
+ }
106
+ if (import.meta.server && failure?.type === 4) {
107
+ return;
108
+ }
109
+ if (import.meta.server && to.redirectedFrom && to.fullPath !== initialURL) {
110
+ await nuxtApp.runWithContext(() => navigateTo(to.fullPath || "/"));
111
+ }
112
+ });
113
+ }
114
+ try {
115
+ if (import.meta.server) {
116
+ await router.push(initialURL);
117
+ }
118
+ await router.isReady();
119
+ } catch (error2) {
120
+ await nuxtApp.runWithContext(() => showError(error2));
121
+ }
122
+ const resolvedInitialRoute = import.meta.client && initialURL !== router.currentRoute.value.fullPath ? router.resolve(initialURL) : router.currentRoute.value;
123
+ syncCurrentRoute();
124
+ if (import.meta.server && nuxtApp.ssrContext?.islandContext) {
125
+ return { provide: { router } };
126
+ }
127
+ const initialLayout = nuxtApp.payload.state._layout;
128
+ router.beforeEach(async (to, from) => {
129
+ await nuxtApp.callHook("page:loading:start");
130
+ to.meta = reactive(to.meta);
131
+ if (nuxtApp.isHydrating && initialLayout && !isReadonly(to.meta.layout)) {
132
+ to.meta.layout = initialLayout;
133
+ }
134
+ nuxtApp._processingMiddleware = true;
135
+ if (import.meta.client || !nuxtApp.ssrContext?.islandContext) {
136
+ const middlewareEntries = /* @__PURE__ */ new Set([...globalMiddleware, ...nuxtApp._middleware.global]);
137
+ for (const component of to.matched) {
138
+ const componentMiddleware = component.meta.middleware;
139
+ if (!componentMiddleware) {
140
+ continue;
141
+ }
142
+ for (const entry of toArray(componentMiddleware)) {
143
+ middlewareEntries.add(entry);
144
+ }
145
+ }
146
+ if (isAppManifestEnabled) {
147
+ const routeRules = await nuxtApp.runWithContext(() => getRouteRules({ path: to.path }));
148
+ if (routeRules.appMiddleware) {
149
+ for (const key in routeRules.appMiddleware) {
150
+ if (routeRules.appMiddleware[key]) {
151
+ middlewareEntries.add(key);
152
+ } else {
153
+ middlewareEntries.delete(key);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ for (const entry of middlewareEntries) {
159
+ const middleware = typeof entry === "string" ? nuxtApp._middleware.named[entry] || await namedMiddleware[entry]?.().then((r) => r.default || r) : entry;
160
+ if (!middleware) {
161
+ if (import.meta.dev) {
162
+ throw new Error(`Unknown route middleware: '${entry}'. Valid middleware: ${Object.keys(namedMiddleware).map((mw) => `'${mw}'`).join(", ")}.`);
163
+ }
164
+ throw new Error(`Unknown route middleware: '${entry}'.`);
165
+ }
166
+ try {
167
+ if (import.meta.dev) {
168
+ nuxtApp._processingMiddleware = middleware._path || (typeof entry === "string" ? entry : true);
169
+ }
170
+ const result = await nuxtApp.runWithContext(() => middleware(to, from));
171
+ if (import.meta.server || !nuxtApp.payload.serverRendered && nuxtApp.isHydrating) {
172
+ if (result === false || result instanceof Error) {
173
+ const error2 = result || createError({
174
+ statusCode: 404,
175
+ statusMessage: `Page Not Found: ${initialURL}`
176
+ });
177
+ await nuxtApp.runWithContext(() => showError(error2));
178
+ return false;
179
+ }
180
+ }
181
+ if (result === true) {
182
+ continue;
183
+ }
184
+ if (result === false) {
185
+ return result;
186
+ }
187
+ if (result) {
188
+ if (isNuxtError(result) && result.fatal) {
189
+ await nuxtApp.runWithContext(() => showError(result));
190
+ }
191
+ return result;
192
+ }
193
+ } catch (err) {
194
+ const error2 = createError(err);
195
+ if (error2.fatal) {
196
+ await nuxtApp.runWithContext(() => showError(error2));
197
+ }
198
+ return error2;
199
+ }
200
+ }
201
+ }
202
+ });
203
+ router.onError(async () => {
204
+ delete nuxtApp._processingMiddleware;
205
+ await nuxtApp.callHook("page:loading:end");
206
+ });
207
+ router.afterEach((to) => {
208
+ if (to.matched.length === 0) {
209
+ return nuxtApp.runWithContext(() => showError(createError({
210
+ statusCode: 404,
211
+ fatal: false,
212
+ statusMessage: `Page not found: ${to.fullPath}`,
213
+ data: {
214
+ path: to.fullPath
215
+ }
216
+ })));
217
+ }
218
+ });
219
+ nuxtApp.hooks.hookOnce("app:created", async () => {
220
+ try {
221
+ if ("name" in resolvedInitialRoute) {
222
+ resolvedInitialRoute.name = void 0;
223
+ }
224
+ await router.replace({
225
+ ...resolvedInitialRoute,
226
+ force: true
227
+ });
228
+ router.options.scrollBehavior = routerOptions.scrollBehavior;
229
+ } catch (error2) {
230
+ await nuxtApp.runWithContext(() => showError(error2));
231
+ }
232
+ });
233
+ return { provide: { router } };
234
+ }
235
+ });
236
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { RouterConfig } from 'nuxt/schema';
2
+ declare const _default: RouterConfig;
3
+ export default _default;
@@ -0,0 +1,60 @@
1
+ import { START_LOCATION } from "vue-router";
2
+ import { useNuxtApp } from "#app/nuxt";
3
+ import { isChangingPage } from "#app/components/utils";
4
+ import { useRouter } from "#app/composables/router";
5
+ export default {
6
+ scrollBehavior(to, from, savedPosition) {
7
+ const nuxtApp = useNuxtApp();
8
+ const hashScrollBehaviour = useRouter().options?.scrollBehaviorType ?? "auto";
9
+ if (to.path.replace(/\/$/, "") === from.path.replace(/\/$/, "")) {
10
+ if (from.hash && !to.hash) {
11
+ return { left: 0, top: 0 };
12
+ }
13
+ if (to.hash) {
14
+ return { el: to.hash, top: _getHashElementScrollMarginTop(to.hash), behavior: hashScrollBehaviour };
15
+ }
16
+ return false;
17
+ }
18
+ const routeAllowsScrollToTop = typeof to.meta.scrollToTop === "function" ? to.meta.scrollToTop(to, from) : to.meta.scrollToTop;
19
+ if (routeAllowsScrollToTop === false) {
20
+ return false;
21
+ }
22
+ const hookToWait = nuxtApp._runningTransition ? "page:transition:finish" : "page:loading:end";
23
+ return new Promise((resolve) => {
24
+ if (from === START_LOCATION) {
25
+ resolve(_calculatePosition(to, from, savedPosition, hashScrollBehaviour));
26
+ return;
27
+ }
28
+ nuxtApp.hooks.hookOnce(hookToWait, () => {
29
+ requestAnimationFrame(() => resolve(_calculatePosition(to, from, savedPosition, hashScrollBehaviour)));
30
+ });
31
+ });
32
+ }
33
+ };
34
+ function _getHashElementScrollMarginTop(selector) {
35
+ try {
36
+ const elem = document.querySelector(selector);
37
+ if (elem) {
38
+ return (Number.parseFloat(getComputedStyle(elem).scrollMarginTop) || 0) + (Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0);
39
+ }
40
+ } catch {
41
+ }
42
+ return 0;
43
+ }
44
+ function _calculatePosition(to, from, savedPosition, defaultHashScrollBehaviour) {
45
+ if (savedPosition) {
46
+ return savedPosition;
47
+ }
48
+ const isPageNavigation = isChangingPage(to, from);
49
+ if (to.hash) {
50
+ return {
51
+ el: to.hash,
52
+ top: _getHashElementScrollMarginTop(to.hash),
53
+ behavior: isPageNavigation ? defaultHashScrollBehaviour : "instant"
54
+ };
55
+ }
56
+ return {
57
+ left: 0,
58
+ top: 0
59
+ };
60
+ }
@@ -0,0 +1,11 @@
1
+ import type { RouteLocationNormalizedLoaded, RouterView } from 'vue-router';
2
+ type InstanceOf<T> = T extends new (...args: any[]) => infer R ? R : never;
3
+ type RouterViewSlot = Exclude<InstanceOf<typeof RouterView>['$slots']['default'], undefined>;
4
+ export type RouterViewSlotProps = Parameters<RouterViewSlot>[0];
5
+ export declare const generateRouteKey: (routeProps: RouterViewSlotProps, override?: string | ((route: RouteLocationNormalizedLoaded) => string)) => string | false | undefined;
6
+ export declare const wrapInKeepAlive: (props: any, children: any) => {
7
+ default: () => any;
8
+ };
9
+ /** @since 3.9.0 */
10
+ export declare function toArray<T>(value: T | T[]): T[];
11
+ export {};
@@ -0,0 +1,18 @@
1
+ import { KeepAlive, h } from "vue";
2
+ const ROUTE_KEY_PARENTHESES_RE = /(:\w+)\([^)]+\)/g;
3
+ const ROUTE_KEY_SYMBOLS_RE = /(:\w+)[?+*]/g;
4
+ const ROUTE_KEY_NORMAL_RE = /:\w+/g;
5
+ const interpolatePath = (route, match) => {
6
+ return match.path.replace(ROUTE_KEY_PARENTHESES_RE, "$1").replace(ROUTE_KEY_SYMBOLS_RE, "$1").replace(ROUTE_KEY_NORMAL_RE, (r) => route.params[r.slice(1)]?.toString() || "");
7
+ };
8
+ export const generateRouteKey = (routeProps, override) => {
9
+ const matchedRoute = routeProps.route.matched.find((m) => m.components?.default === routeProps.Component.type);
10
+ const source = override ?? matchedRoute?.meta.key ?? (matchedRoute && interpolatePath(routeProps.route, matchedRoute));
11
+ return typeof source === "function" ? source(routeProps.route) : source;
12
+ };
13
+ export const wrapInKeepAlive = (props, children) => {
14
+ return { default: () => import.meta.client && props ? h(KeepAlive, props === true ? {} : props, children) : children };
15
+ };
16
+ export function toArray(value) {
17
+ return Array.isArray(value) ? value : [value];
18
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { createError } from "#app/composables/error";
2
+ import { defineNuxtRouteMiddleware } from "#app/composables/router";
3
+ export default defineNuxtRouteMiddleware(async (to, from) => {
4
+ if (!to.meta?.validate) {
5
+ return;
6
+ }
7
+ const result = await Promise.resolve(to.meta.validate(to));
8
+ if (result === true) {
9
+ return;
10
+ }
11
+ const error = createError({
12
+ fatal: import.meta.client,
13
+ statusCode: result && result.statusCode || 404,
14
+ statusMessage: result && result.statusMessage || `Page Not Found: ${to.fullPath}`,
15
+ data: {
16
+ path: to.fullPath
17
+ }
18
+ });
19
+ if (typeof window !== "undefined") {
20
+ window.history.pushState({}, "", from.fullPath);
21
+ }
22
+ return error;
23
+ });
package/kit.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@nuxt/kit'
package/kit.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@nuxt/kit'
package/package.json ADDED
@@ -0,0 +1,156 @@
1
+ {
2
+ "name": "@depup/nuxt",
3
+ "version": "4.2.2-depup.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/nuxt/nuxt.git",
7
+ "directory": "packages/nuxt"
8
+ },
9
+ "homepage": "https://nuxt.com",
10
+ "description": "Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.",
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "types": "./types.d.ts",
14
+ "bin": {
15
+ "nuxi": "bin/nuxt.mjs",
16
+ "nuxt": "bin/nuxt.mjs"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./types.d.mts",
21
+ "import": "./dist/index.mjs"
22
+ },
23
+ "./config": {
24
+ "types": "./config.d.ts",
25
+ "import": "./config.js",
26
+ "require": "./config.cjs"
27
+ },
28
+ "./schema": {
29
+ "types": "./schema.d.ts",
30
+ "import": "./schema.js"
31
+ },
32
+ "./kit": {
33
+ "types": "./kit.d.ts",
34
+ "import": "./kit.js"
35
+ },
36
+ "./app": {
37
+ "types": "./dist/app/index.d.ts",
38
+ "import": "./dist/app/index.js"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "imports": {
43
+ "#app": {
44
+ "types": "./dist/app/index.d.ts",
45
+ "import": "./dist/app/index.js"
46
+ },
47
+ "#app/nuxt": {
48
+ "types": "./dist/app/nuxt.d.ts",
49
+ "import": "./dist/app/nuxt.js"
50
+ },
51
+ "#unhead/composables": {
52
+ "types": "./dist/head/runtime/composables.d.ts",
53
+ "import": "./dist/head/runtime/composables.js"
54
+ }
55
+ },
56
+ "files": [
57
+ "app.d.ts",
58
+ "bin",
59
+ "types.d.ts",
60
+ "types.d.mts",
61
+ "dist",
62
+ "config.*",
63
+ "kit.*",
64
+ "schema.*"
65
+ ],
66
+ "dependencies": {
67
+ "@dxup/nuxt": "^0.3.2",
68
+ "@nuxt/cli": "^3.32.0",
69
+ "@nuxt/devtools": "^3.1.1",
70
+ "@nuxt/telemetry": "^2.6.6",
71
+ "@unhead/vue": "^2.1.2",
72
+ "@vue/shared": "^3.5.26",
73
+ "c12": "^3.3.3",
74
+ "chokidar": "^5.0.0",
75
+ "compatx": "^0.2.0",
76
+ "consola": "^3.4.2",
77
+ "cookie-es": "^2.0.0",
78
+ "defu": "^6.1.4",
79
+ "destr": "^2.0.5",
80
+ "devalue": "^5.6.1",
81
+ "errx": "^0.1.0",
82
+ "escape-string-regexp": "^5.0.0",
83
+ "exsolve": "^1.0.8",
84
+ "h3": "^2.0.1-rc.7",
85
+ "hookable": "^6.0.1",
86
+ "ignore": "^7.0.5",
87
+ "impound": "^1.0.0",
88
+ "jiti": "^2.6.1",
89
+ "klona": "^2.0.6",
90
+ "knitwork": "^1.3.0",
91
+ "magic-string": "^0.30.21",
92
+ "mlly": "^1.8.0",
93
+ "nanotar": "^0.2.0",
94
+ "nypm": "^0.6.2",
95
+ "ofetch": "^1.5.1",
96
+ "ohash": "^2.0.11",
97
+ "on-change": "^6.0.1",
98
+ "oxc-minify": "^0.108.0",
99
+ "oxc-parser": "^0.108.0",
100
+ "oxc-transform": "^0.108.0",
101
+ "oxc-walker": "^0.6.0",
102
+ "pathe": "^2.0.3",
103
+ "perfect-debounce": "^2.0.0",
104
+ "pkg-types": "^2.3.0",
105
+ "radix3": "^1.1.2",
106
+ "scule": "^1.3.0",
107
+ "semver": "^7.7.3",
108
+ "std-env": "^3.10.0",
109
+ "tinyglobby": "^0.2.15",
110
+ "ufo": "^1.6.2",
111
+ "ultrahtml": "^1.6.0",
112
+ "uncrypto": "^0.1.3",
113
+ "unctx": "^2.5.0",
114
+ "unimport": "^5.6.0",
115
+ "unplugin": "^2.3.11",
116
+ "unplugin-vue-router": "^0.19.2",
117
+ "untyped": "^2.0.0",
118
+ "vue": "^3.5.26",
119
+ "vue-router": "^4.6.4",
120
+ "@nuxt/kit": "4.2.2",
121
+ "@nuxt/nitro-server": "4.2.2",
122
+ "@nuxt/schema": "4.2.2",
123
+ "@nuxt/vite-builder": "4.2.2"
124
+ },
125
+ "devDependencies": {
126
+ "@nuxt/scripts": "^0.13.2",
127
+ "@parcel/watcher": "^2.5.4",
128
+ "@types/estree": "1.0.8",
129
+ "@vitejs/plugin-vue": "^6.0.3",
130
+ "@vitejs/plugin-vue-jsx": "^5.1.3",
131
+ "@vue/compiler-sfc": "^3.5.26",
132
+ "unbuild": "3.6.1",
133
+ "vite": "^7.3.1",
134
+ "vitest": "^4.0.17",
135
+ "vue-bundle-renderer": "2.2.0",
136
+ "vue-sfc-transformer": "0.1.17"
137
+ },
138
+ "peerDependencies": {
139
+ "@parcel/watcher": "^2.1.0",
140
+ "@types/node": ">=18.12.0"
141
+ },
142
+ "peerDependenciesMeta": {
143
+ "@parcel/watcher": {
144
+ "optional": true
145
+ },
146
+ "@types/node": {
147
+ "optional": true
148
+ }
149
+ },
150
+ "engines": {
151
+ "node": "^20.19.0 || >=22.12.0"
152
+ },
153
+ "scripts": {
154
+ "test:attw": "attw --pack"
155
+ }
156
+ }
package/schema.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@nuxt/schema'
package/schema.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@nuxt/schema'
package/types.d.mts ADDED
@@ -0,0 +1,14 @@
1
+ import type { SchemaDefinition } from 'nuxt/schema'
2
+ import type { DefineNuxtConfig } from 'nuxt/config'
3
+
4
+ export * from './dist/index.js'
5
+
6
+ declare global {
7
+ const defineNuxtConfig: DefineNuxtConfig
8
+ const defineNuxtSchema: (schema: SchemaDefinition) => SchemaDefinition
9
+
10
+ interface ImportMeta {
11
+ url: string
12
+ readonly env: ImportMetaEnv
13
+ }
14
+ }
package/types.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { SchemaDefinition } from 'nuxt/schema'
2
+ import type { DefineNuxtConfig } from 'nuxt/config'
3
+
4
+ export * from './dist/index'
5
+
6
+ declare global {
7
+ const defineNuxtConfig: DefineNuxtConfig
8
+ const defineNuxtSchema: (schema: SchemaDefinition) => SchemaDefinition
9
+
10
+ interface ImportMeta {
11
+ url: string
12
+ readonly env: ImportMetaEnv
13
+ }
14
+ }