@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,40 @@
1
+ import { isRef, toRef } from "vue";
2
+ import { useNuxtApp } from "../nuxt.js";
3
+ import { toArray } from "../utils.js";
4
+ const useStateKeyPrefix = "$s";
5
+ export function useState(...args) {
6
+ const autoKey = typeof args[args.length - 1] === "string" ? args.pop() : void 0;
7
+ if (typeof args[0] !== "string") {
8
+ args.unshift(autoKey);
9
+ }
10
+ const [_key, init] = args;
11
+ if (!_key || typeof _key !== "string") {
12
+ throw new TypeError("[nuxt] [useState] key must be a string: " + _key);
13
+ }
14
+ if (init !== void 0 && typeof init !== "function") {
15
+ throw new Error("[nuxt] [useState] init must be a function: " + init);
16
+ }
17
+ const key = useStateKeyPrefix + _key;
18
+ const nuxtApp = useNuxtApp();
19
+ const state = toRef(nuxtApp.payload.state, key);
20
+ if (state.value === void 0 && init) {
21
+ const initialValue = init();
22
+ if (isRef(initialValue)) {
23
+ nuxtApp.payload.state[key] = initialValue;
24
+ return initialValue;
25
+ }
26
+ state.value = initialValue;
27
+ }
28
+ return state;
29
+ }
30
+ export function clearNuxtState(keys) {
31
+ const nuxtApp = useNuxtApp();
32
+ const _allKeys = Object.keys(nuxtApp.payload.state).map((key) => key.substring(useStateKeyPrefix.length));
33
+ const _keys = !keys ? _allKeys : typeof keys === "function" ? _allKeys.filter(keys) : toArray(keys);
34
+ for (const _key of _keys) {
35
+ const key = useStateKeyPrefix + _key;
36
+ if (key in nuxtApp.payload.state) {
37
+ nuxtApp.payload.state[key] = void 0;
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,3 @@
1
+ import { getRequestURL } from 'h3';
2
+ /** @since 3.5.0 */
3
+ export declare function useRequestURL(opts?: Parameters<typeof getRequestURL>[1]): URL;
@@ -0,0 +1,8 @@
1
+ import { getRequestURL } from "h3";
2
+ import { useRequestEvent } from "./ssr.js";
3
+ export function useRequestURL(opts) {
4
+ if (import.meta.server) {
5
+ return getRequestURL(useRequestEvent(), opts);
6
+ }
7
+ return new URL(globalThis.location.href);
8
+ }
@@ -0,0 +1,14 @@
1
+ import type { AppConfig } from 'nuxt/schema';
2
+ type DeepPartial<T> = T extends Function ? T : T extends Record<string, any> ? {
3
+ [P in keyof T]?: DeepPartial<T[P]>;
4
+ } : T;
5
+ export declare const _getAppConfig: () => AppConfig;
6
+ export declare function useAppConfig(): AppConfig;
7
+ export declare function _replaceAppConfig(newConfig: AppConfig): void;
8
+ /**
9
+ * Deep assign the current appConfig with the new one.
10
+ *
11
+ * Will preserve existing properties.
12
+ */
13
+ export declare function updateAppConfig(appConfig: DeepPartial<AppConfig>): void;
14
+ export {};
@@ -0,0 +1,72 @@
1
+ import { reactive } from "vue";
2
+ import { klona } from "klona";
3
+ import { useNuxtApp } from "./nuxt.js";
4
+ import __appConfig from "#build/app.config.mjs";
5
+ export const _getAppConfig = () => __appConfig;
6
+ function isPojoOrArray(val) {
7
+ return Array.isArray(val) || !!val && typeof val === "object" && val.constructor?.name === "Object";
8
+ }
9
+ function deepDelete(obj, newObj) {
10
+ if (Array.isArray(obj) && Array.isArray(newObj)) {
11
+ obj.length = 0;
12
+ obj.push(...newObj);
13
+ return;
14
+ }
15
+ for (const key in obj) {
16
+ const val = newObj[key];
17
+ if (!(key in newObj)) {
18
+ delete obj[key];
19
+ }
20
+ if (isPojoOrArray(val)) {
21
+ deepDelete(obj[key], newObj[key]);
22
+ }
23
+ }
24
+ }
25
+ function deepAssign(obj, newObj) {
26
+ for (const key in newObj) {
27
+ if (key === "__proto__" || key === "constructor") {
28
+ continue;
29
+ }
30
+ const val = newObj[key];
31
+ if (isPojoOrArray(val)) {
32
+ const defaultVal = Array.isArray(val) ? [] : {};
33
+ if (Array.isArray(obj[key]) !== Array.isArray(val)) {
34
+ obj[key] = defaultVal;
35
+ } else {
36
+ obj[key] ??= defaultVal;
37
+ }
38
+ deepAssign(obj[key], val);
39
+ } else {
40
+ obj[key] = val;
41
+ }
42
+ }
43
+ }
44
+ export function useAppConfig() {
45
+ const nuxtApp = useNuxtApp();
46
+ nuxtApp._appConfig ||= import.meta.server ? klona(__appConfig) : reactive(__appConfig);
47
+ return nuxtApp._appConfig;
48
+ }
49
+ export function _replaceAppConfig(newConfig) {
50
+ const appConfig = useAppConfig();
51
+ deepAssign(appConfig, newConfig);
52
+ deepDelete(appConfig, newConfig);
53
+ }
54
+ export function updateAppConfig(appConfig) {
55
+ const _appConfig = useAppConfig();
56
+ deepAssign(_appConfig, appConfig);
57
+ }
58
+ if (import.meta.dev) {
59
+ if (import.meta.hot) {
60
+ import.meta.hot.accept((newModule) => {
61
+ const newConfig = newModule?._getAppConfig();
62
+ if (newConfig) {
63
+ _replaceAppConfig(newConfig);
64
+ }
65
+ });
66
+ }
67
+ if (import.meta.webpackHot) {
68
+ import.meta.webpackHot.accept("#build/app.config.mjs", () => {
69
+ _replaceAppConfig(__appConfig);
70
+ });
71
+ }
72
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => void;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export default () => {
2
+ };
@@ -0,0 +1,3 @@
1
+ import type { CreateOptions } from './nuxt.js';
2
+ declare const entry: (ctx?: CreateOptions["ssrContext"]) => Promise<any>;
3
+ export default entry;
@@ -0,0 +1,5 @@
1
+ const entry = import.meta.server ? (ctx) => import("#app/entry").then((m) => m.default(ctx)) : () => import("#app/entry").then((m) => m.default);
2
+ if (import.meta.client) {
3
+ entry();
4
+ }
5
+ export default entry;
@@ -0,0 +1,7 @@
1
+ import type { App } from 'vue';
2
+ import '#build/fetch.mjs';
3
+ import '#build/global-polyfills.mjs';
4
+ import type { CreateOptions } from './nuxt.js';
5
+ import '#build/css';
6
+ declare const _default: (ssrContext?: CreateOptions["ssrContext"]) => Promise<App<Element>>;
7
+ export default _default;
@@ -0,0 +1,78 @@
1
+ import { createApp, createSSRApp, nextTick } from "vue";
2
+ import "#build/fetch.mjs";
3
+ import "#build/global-polyfills.mjs";
4
+ import { applyPlugins, createNuxtApp } from "./nuxt.js";
5
+ import { createError } from "./composables/error.js";
6
+ import "#build/css";
7
+ import plugins from "#build/plugins";
8
+ import RootComponent from "#build/root-component.mjs";
9
+ import { appId, appSpaLoaderAttrs, multiApp, spaLoadingTemplateOutside, vueAppRootContainer } from "#build/nuxt.config.mjs";
10
+ let entry;
11
+ if (import.meta.server) {
12
+ entry = async function createNuxtAppServer(ssrContext) {
13
+ const vueApp = createApp(RootComponent);
14
+ const nuxt = createNuxtApp({ vueApp, ssrContext });
15
+ try {
16
+ await applyPlugins(nuxt, plugins);
17
+ await nuxt.hooks.callHook("app:created", vueApp);
18
+ } catch (error) {
19
+ await nuxt.hooks.callHook("app:error", error);
20
+ nuxt.payload.error ||= createError(error);
21
+ }
22
+ if (ssrContext?._renderResponse) {
23
+ throw new Error("skipping render");
24
+ }
25
+ return vueApp;
26
+ };
27
+ }
28
+ if (import.meta.client) {
29
+ if (import.meta.dev && import.meta.webpackHot) {
30
+ import.meta.webpackHot.accept();
31
+ }
32
+ let vueAppPromise;
33
+ entry = async function initApp() {
34
+ if (vueAppPromise) {
35
+ return vueAppPromise;
36
+ }
37
+ const isSSR = Boolean(
38
+ (multiApp ? window.__NUXT__?.[appId] : window.__NUXT__)?.serverRendered ?? (multiApp ? document.querySelector(`[data-nuxt-data="${appId}"]`) : document.getElementById("__NUXT_DATA__"))?.dataset.ssr === "true"
39
+ );
40
+ const vueApp = isSSR ? createSSRApp(RootComponent) : createApp(RootComponent);
41
+ const nuxt = createNuxtApp({ vueApp });
42
+ async function handleVueError(error) {
43
+ await nuxt.callHook("app:error", error);
44
+ nuxt.payload.error ||= createError(error);
45
+ }
46
+ vueApp.config.errorHandler = handleVueError;
47
+ nuxt.hook("app:suspense:resolve", () => {
48
+ if (vueApp.config.errorHandler === handleVueError) {
49
+ vueApp.config.errorHandler = void 0;
50
+ }
51
+ });
52
+ if (spaLoadingTemplateOutside && !isSSR && appSpaLoaderAttrs.id) {
53
+ nuxt.hook("app:suspense:resolve", () => {
54
+ document.getElementById(appSpaLoaderAttrs.id)?.remove();
55
+ });
56
+ }
57
+ try {
58
+ await applyPlugins(nuxt, plugins);
59
+ } catch (err) {
60
+ handleVueError(err);
61
+ }
62
+ try {
63
+ await nuxt.hooks.callHook("app:created", vueApp);
64
+ await nuxt.hooks.callHook("app:beforeMount", vueApp);
65
+ vueApp.mount(vueAppRootContainer);
66
+ await nuxt.hooks.callHook("app:mounted", vueApp);
67
+ await nextTick();
68
+ } catch (err) {
69
+ handleVueError(err);
70
+ }
71
+ return vueApp;
72
+ };
73
+ vueAppPromise = entry().catch((error) => {
74
+ console.error("Error while mounting app:", error);
75
+ throw error;
76
+ });
77
+ }
78
+ export default (ssrContext) => entry(ssrContext);
@@ -0,0 +1,12 @@
1
+ import '../../dist/app/types/augments.js';
2
+ export { applyPlugin, applyPlugins, callWithNuxt, createNuxtApp, defineAppConfig, defineNuxtPlugin, definePayloadPlugin, isNuxtPlugin, registerPluginHooks, tryUseNuxtApp, useNuxtApp, useRuntimeConfig } from './nuxt.js';
3
+ export type { CreateOptions, NuxtApp, NuxtPayload, NuxtPluginIndicator, NuxtSSRContext, ObjectPlugin, Plugin, PluginEnvContext, PluginMeta, ResolvedPluginMeta, RuntimeNuxtHooks } from './nuxt.js';
4
+ export { defineNuxtComponent, useAsyncData, useLazyAsyncData, useNuxtData, refreshNuxtData, clearNuxtData, useHydration, callOnce, useState, clearNuxtState, clearError, createError, isNuxtError, showError, useError, useFetch, useLazyFetch, useCookie, refreshCookie, onPrehydrate, prerenderRoutes, useRequestHeaders, useRequestEvent, useRequestFetch, setResponseStatus, useResponseHeader, onNuxtReady, abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter, preloadComponents, prefetchComponents, preloadRouteComponents, isPrerendered, loadPayload, preloadPayload, definePayloadReducer, definePayloadReviver, getAppManifest, getRouteRules, reloadNuxtApp, useRequestURL, usePreviewMode, useId, useRouteAnnouncer, useHead, useHeadSafe, useServerSeoMeta, useServerHeadSafe, useServerHead, useSeoMeta, injectHead, useRuntimeHook } from './composables/index.js';
5
+ export type { AddRouteMiddlewareOptions, AsyncData, AsyncDataOptions, AsyncDataRequestStatus, CookieOptions, CookieRef, FetchResult, NuxtAppManifest, NuxtAppManifestMeta, NuxtError, Politeness, ReloadNuxtAppOptions, RouteMiddleware, UseFetchOptions } from './composables/index.js';
6
+ export { defineNuxtLink } from './components/index.js';
7
+ export type { NuxtLinkOptions, NuxtLinkProps, NuxtTimeProps } from './components/index.js';
8
+ export { _getAppConfig, updateAppConfig, useAppConfig } from './config.js';
9
+ export { cancelIdleCallback, requestIdleCallback } from './compat/idle-callback.js';
10
+ export type { NuxtAppLiterals, NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext, PageMeta, NuxtPageProps } from './types.js';
11
+ export declare const isVue2 = false;
12
+ export declare const isVue3 = true;
@@ -0,0 +1,8 @@
1
+ import "../../dist/app/types/augments";
2
+ export { applyPlugin, applyPlugins, callWithNuxt, createNuxtApp, defineAppConfig, defineNuxtPlugin, definePayloadPlugin, isNuxtPlugin, registerPluginHooks, tryUseNuxtApp, useNuxtApp, useRuntimeConfig } from "./nuxt.js";
3
+ export { defineNuxtComponent, useAsyncData, useLazyAsyncData, useNuxtData, refreshNuxtData, clearNuxtData, useHydration, callOnce, useState, clearNuxtState, clearError, createError, isNuxtError, showError, useError, useFetch, useLazyFetch, useCookie, refreshCookie, onPrehydrate, prerenderRoutes, useRequestHeaders, useRequestEvent, useRequestFetch, setResponseStatus, useResponseHeader, onNuxtReady, abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter, preloadComponents, prefetchComponents, preloadRouteComponents, isPrerendered, loadPayload, preloadPayload, definePayloadReducer, definePayloadReviver, getAppManifest, getRouteRules, reloadNuxtApp, useRequestURL, usePreviewMode, useId, useRouteAnnouncer, useHead, useHeadSafe, useServerSeoMeta, useServerHeadSafe, useServerHead, useSeoMeta, injectHead, useRuntimeHook } from "./composables/index.js";
4
+ export { defineNuxtLink } from "./components/index.js";
5
+ export { _getAppConfig, updateAppConfig, useAppConfig } from "./config.js";
6
+ export { cancelIdleCallback, requestIdleCallback } from "./compat/idle-callback.js";
7
+ export const isVue2 = false;
8
+ export const isVue3 = true;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../composables/router.js").RouteMiddleware;
2
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { hasProtocol } from "ufo";
2
+ import { defineNuxtRouteMiddleware } from "../composables/router.js";
3
+ import { getRouteRules } from "../composables/manifest.js";
4
+ export default defineNuxtRouteMiddleware(async (to) => {
5
+ if (import.meta.server || import.meta.test) {
6
+ return;
7
+ }
8
+ const rules = await getRouteRules({ path: to.path });
9
+ if (rules.redirect) {
10
+ const path = rules.redirect.includes("#") ? rules.redirect : rules.redirect + to.hash;
11
+ if (hasProtocol(path, { acceptRelative: true })) {
12
+ window.location.href = path;
13
+ return false;
14
+ }
15
+ return path;
16
+ }
17
+ });
@@ -0,0 +1,271 @@
1
+ import type { App, EffectScope, Ref, VNode, onErrorCaptured } from 'vue';
2
+ import type { RouteLocationNormalizedLoaded } from 'vue-router';
3
+ import type { Hookable } from 'hookable';
4
+ import type { SSRContext, createRenderer } from 'vue-bundle-renderer/runtime';
5
+ import type { EventHandlerRequest, H3Event } from 'h3';
6
+ import type { RenderResponse } from 'nitropack/types';
7
+ import type { LogObject } from 'consola';
8
+ import type { VueHeadClient } from '@unhead/vue/types';
9
+ import type { NuxtAppLiterals } from 'nuxt/app';
10
+ import type { NuxtIslandContext } from './types.js';
11
+ import type { RouteMiddleware } from './composables/router.js';
12
+ import type { NuxtError } from './composables/error.js';
13
+ import type { AsyncDataExecuteOptions, AsyncDataRequestStatus } from './composables/asyncData.js';
14
+ import type { NuxtAppManifestMeta } from './composables/manifest.js';
15
+ import type { LoadingIndicator } from './composables/loading-indicator.js';
16
+ import type { RouteAnnouncer } from './composables/route-announcer.js';
17
+ import type { AppConfig, AppConfigInput, RuntimeConfig } from 'nuxt/schema';
18
+ export declare function getNuxtAppCtx(id?: any): import("unctx/index").UseContext<NuxtApp>;
19
+ type HookResult = Promise<void> | void;
20
+ type AppRenderedContext = {
21
+ ssrContext: NuxtApp['ssrContext'];
22
+ renderResult: null | Awaited<ReturnType<ReturnType<typeof createRenderer>['renderToString']>>;
23
+ };
24
+ export interface RuntimeNuxtHooks {
25
+ 'app:created': (app: App<Element>) => HookResult;
26
+ 'app:beforeMount': (app: App<Element>) => HookResult;
27
+ 'app:mounted': (app: App<Element>) => HookResult;
28
+ 'app:rendered': (ctx: AppRenderedContext) => HookResult;
29
+ 'app:redirected': () => HookResult;
30
+ 'app:suspense:resolve': (Component?: VNode) => HookResult;
31
+ 'app:error': (err: any) => HookResult;
32
+ 'app:error:cleared': (options: {
33
+ redirect?: string;
34
+ }) => HookResult;
35
+ 'app:chunkError': (options: {
36
+ error: any;
37
+ }) => HookResult;
38
+ 'app:data:refresh': (keys?: string[]) => HookResult;
39
+ 'app:manifest:update': (meta?: NuxtAppManifestMeta) => HookResult;
40
+ 'dev:ssr-logs': (logs: LogObject[]) => HookResult;
41
+ 'link:prefetch': (link: string) => HookResult;
42
+ 'page:start': (Component?: VNode) => HookResult;
43
+ 'page:finish': (Component?: VNode) => HookResult;
44
+ 'page:transition:finish': (Component?: VNode) => HookResult;
45
+ 'page:view-transition:start': (transition: ViewTransition) => HookResult;
46
+ 'page:loading:start': () => HookResult;
47
+ 'page:loading:end': () => HookResult;
48
+ 'vue:setup': () => void;
49
+ 'vue:error': (...args: Parameters<Parameters<typeof onErrorCaptured>[0]>) => HookResult;
50
+ }
51
+ export interface NuxtSSRContext extends SSRContext {
52
+ url: string;
53
+ event: H3Event;
54
+ runtimeConfig: RuntimeConfig;
55
+ noSSR: boolean;
56
+ /** whether we are rendering an SSR error */
57
+ error?: boolean;
58
+ nuxt: _NuxtApp;
59
+ payload: Partial<NuxtPayload>;
60
+ head: VueHeadClient;
61
+ /** This is used solely to render runtime config with SPA renderer. */
62
+ config?: Pick<RuntimeConfig, 'public' | 'app'>;
63
+ teleports?: Record<string, string>;
64
+ islandContext?: NuxtIslandContext;
65
+ /** @internal */
66
+ _renderResponse?: Partial<RenderResponse>;
67
+ /** @internal */
68
+ _payloadReducers: Record<string, (data: any) => any>;
69
+ /** @internal */
70
+ _sharedPrerenderCache?: {
71
+ get<T = unknown>(key: string): Promise<T> | undefined;
72
+ set<T>(key: string, value: Promise<T>): Promise<void>;
73
+ };
74
+ /** @internal */
75
+ _preloadManifest?: boolean;
76
+ }
77
+ export interface NuxtPayload {
78
+ path?: string;
79
+ serverRendered?: boolean;
80
+ prerenderedAt?: number;
81
+ data: Record<string, any>;
82
+ state: Record<string, any>;
83
+ once: Set<string>;
84
+ config?: Pick<RuntimeConfig, 'public' | 'app'>;
85
+ error?: NuxtError | undefined;
86
+ _errors: Record<string, NuxtError | undefined>;
87
+ [key: string]: unknown;
88
+ }
89
+ interface _NuxtApp {
90
+ vueApp: App<Element>;
91
+ versions: Record<string, string>;
92
+ hooks: Hookable<RuntimeNuxtHooks>;
93
+ hook: _NuxtApp['hooks']['hook'];
94
+ callHook: _NuxtApp['hooks']['callHook'];
95
+ runWithContext: <T extends () => any>(fn: T) => ReturnType<T> | Promise<Awaited<ReturnType<T>>>;
96
+ [key: string]: unknown;
97
+ /** @internal */
98
+ _cookies?: Record<string, unknown>;
99
+ /**
100
+ * The id of the Nuxt application.
101
+ * @internal */
102
+ _id: string;
103
+ /** @internal */
104
+ _scope: EffectScope;
105
+ /** @internal */
106
+ _asyncDataPromises: Record<string, Promise<any> | undefined>;
107
+ /** @internal */
108
+ _asyncData: Record<string, {
109
+ data: Ref<unknown>;
110
+ pending: Ref<boolean>;
111
+ error: Ref<Error | undefined>;
112
+ status: Ref<AsyncDataRequestStatus>;
113
+ execute: (opts?: AsyncDataExecuteOptions) => Promise<void>;
114
+ /** @internal */
115
+ _default: () => unknown;
116
+ /** @internal */
117
+ _deps: number;
118
+ /** @internal */
119
+ _off: () => void;
120
+ /** @internal */
121
+ _init: boolean;
122
+ /** @internal */
123
+ _execute: (opts?: AsyncDataExecuteOptions) => Promise<void>;
124
+ /** @internal */
125
+ _hash?: Record<string, string | undefined>;
126
+ /** @internal */
127
+ _abortController?: AbortController;
128
+ } | undefined>;
129
+ /** @internal */
130
+ _loadingIndicator?: LoadingIndicator;
131
+ /** @internal */
132
+ _loadingIndicatorDeps?: number;
133
+ /** @internal */
134
+ _middleware: {
135
+ global: RouteMiddleware[];
136
+ named: Record<string, RouteMiddleware>;
137
+ };
138
+ /** @internal */
139
+ _processingMiddleware?: string | boolean;
140
+ /** @internal */
141
+ _once: {
142
+ [key: string]: Promise<any>;
143
+ };
144
+ /** @internal */
145
+ _observer?: {
146
+ observe: (element: Element, callback: () => void) => () => void;
147
+ };
148
+ /** @internal */
149
+ _appConfig: AppConfig;
150
+ /** @internal */
151
+ _route: RouteLocationNormalizedLoaded & {
152
+ sync?: () => void;
153
+ };
154
+ /** @internal */
155
+ _islandPromises?: Record<string, Promise<any>>;
156
+ /** @internal */
157
+ _payloadRevivers: Record<string, (data: any) => any>;
158
+ /** @internal */
159
+ _routeAnnouncer?: RouteAnnouncer;
160
+ /** @internal */
161
+ _routeAnnouncerDeps?: number;
162
+ $config: RuntimeConfig;
163
+ isHydrating?: boolean;
164
+ deferHydration: () => () => void | Promise<void>;
165
+ ssrContext?: NuxtSSRContext;
166
+ payload: NuxtPayload;
167
+ static: {
168
+ data: Record<string, any>;
169
+ };
170
+ provide: (name: string, value: any) => void;
171
+ }
172
+ export interface NuxtApp extends _NuxtApp {
173
+ }
174
+ export declare const NuxtPluginIndicator = "__nuxt_plugin";
175
+ export interface PluginMeta {
176
+ name?: string;
177
+ enforce?: 'pre' | 'default' | 'post';
178
+ /**
179
+ * Await for other named plugins to finish before running this plugin.
180
+ */
181
+ dependsOn?: NuxtAppLiterals['pluginName'][];
182
+ /**
183
+ * This allows more granular control over plugin order and should only be used by advanced users.
184
+ * It overrides the value of `enforce` and is used to sort plugins.
185
+ */
186
+ order?: number;
187
+ }
188
+ export interface PluginEnvContext {
189
+ /**
190
+ * This enable the plugin for islands components.
191
+ * Require `experimental.componentsIslands`.
192
+ * @default true
193
+ */
194
+ islands?: boolean;
195
+ }
196
+ export interface ResolvedPluginMeta {
197
+ name?: string;
198
+ parallel?: boolean;
199
+ }
200
+ export interface Plugin<Injections extends Record<string, unknown> = Record<string, unknown>> {
201
+ (nuxt: _NuxtApp): Promise<void> | Promise<{
202
+ provide?: Injections;
203
+ }> | void | {
204
+ provide?: Injections;
205
+ };
206
+ [NuxtPluginIndicator]?: true;
207
+ meta?: ResolvedPluginMeta;
208
+ }
209
+ export interface ObjectPlugin<Injections extends Record<string, unknown> = Record<string, unknown>> extends PluginMeta {
210
+ hooks?: Partial<RuntimeNuxtHooks>;
211
+ setup?: Plugin<Injections>;
212
+ env?: PluginEnvContext;
213
+ /**
214
+ * Execute plugin in parallel with other parallel plugins.
215
+ * @default false
216
+ */
217
+ parallel?: boolean;
218
+ /**
219
+ * @internal
220
+ */
221
+ _name?: string;
222
+ }
223
+ /** @deprecated Use `ObjectPlugin` */
224
+ export type ObjectPluginInput<Injections extends Record<string, unknown> = Record<string, unknown>> = ObjectPlugin<Injections>;
225
+ export interface CreateOptions {
226
+ vueApp: NuxtApp['vueApp'];
227
+ ssrContext?: NuxtApp['ssrContext'];
228
+ /**
229
+ * The id of the Nuxt application, overrides the default id specified in the Nuxt config (default: `nuxt-app`).
230
+ */
231
+ id?: NuxtApp['_id'];
232
+ }
233
+ /** @since 3.0.0 */
234
+ export declare function createNuxtApp(options: CreateOptions): NuxtApp;
235
+ /** @since 3.12.0 */
236
+ export declare function registerPluginHooks(nuxtApp: NuxtApp, plugin: Plugin & ObjectPlugin<any>): void;
237
+ /** @since 3.0.0 */
238
+ export declare function applyPlugin(nuxtApp: NuxtApp, plugin: Plugin & ObjectPlugin<any>): Promise<void>;
239
+ /** @since 3.0.0 */
240
+ export declare function applyPlugins(nuxtApp: NuxtApp, plugins: Array<Plugin & ObjectPlugin<any>>): Promise<void>;
241
+ /** @since 3.0.0 */
242
+ export declare function defineNuxtPlugin<T extends Record<string, unknown>>(plugin: Plugin<T> | ObjectPlugin<T>): Plugin<T> & ObjectPlugin<T>;
243
+ export declare const definePayloadPlugin: typeof defineNuxtPlugin;
244
+ /** @since 3.0.0 */
245
+ export declare function isNuxtPlugin(plugin: unknown): plugin is Function & Record<"__nuxt_plugin", unknown>;
246
+ /**
247
+ * Ensures that the setup function passed in has access to the Nuxt instance via `useNuxtApp`.
248
+ * @param nuxt A Nuxt instance
249
+ * @param setup The function to call
250
+ * @since 3.0.0
251
+ */
252
+ export declare function callWithNuxt<T extends (...args: any[]) => any>(nuxt: NuxtApp | _NuxtApp, setup: T, args?: Parameters<T>): ReturnType<T> | Promise<ReturnType<T>>;
253
+ /**
254
+ * Returns the current Nuxt instance.
255
+ *
256
+ * Returns `null` if Nuxt instance is unavailable.
257
+ * @since 3.10.0
258
+ */
259
+ export declare function tryUseNuxtApp(): NuxtApp | null;
260
+ /**
261
+ * Returns the current Nuxt instance.
262
+ *
263
+ * Throws an error if Nuxt instance is unavailable.
264
+ * @since 3.0.0
265
+ */
266
+ export declare function useNuxtApp(): NuxtApp;
267
+ /** @since 3.0.0 */
268
+ export declare function useRuntimeConfig(_event?: H3Event<EventHandlerRequest>): RuntimeConfig;
269
+ /** @since 3.0.0 */
270
+ export declare function defineAppConfig<C extends AppConfigInput>(config: C): C;
271
+ export {};