@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,279 @@
1
+ import { effectScope, getCurrentInstance, getCurrentScope, hasInjectionContext, reactive, shallowReactive } from "vue";
2
+ import { createHooks } from "hookable";
3
+ import { getContext } from "unctx";
4
+ import { appId, chunkErrorEvent, multiApp } from "#build/nuxt.config.mjs";
5
+ export function getNuxtAppCtx(id = appId || "nuxt-app") {
6
+ return getContext(id, {
7
+ asyncContext: !!__NUXT_ASYNC_CONTEXT__ && import.meta.server
8
+ });
9
+ }
10
+ export const NuxtPluginIndicator = "__nuxt_plugin";
11
+ export function createNuxtApp(options) {
12
+ let hydratingCount = 0;
13
+ const nuxtApp = {
14
+ _id: options.id || appId || "nuxt-app",
15
+ _scope: effectScope(),
16
+ provide: void 0,
17
+ versions: {
18
+ get nuxt() {
19
+ return __NUXT_VERSION__;
20
+ },
21
+ get vue() {
22
+ return nuxtApp.vueApp.version;
23
+ }
24
+ },
25
+ payload: shallowReactive({
26
+ ...options.ssrContext?.payload || {},
27
+ data: shallowReactive({}),
28
+ state: reactive({}),
29
+ once: /* @__PURE__ */ new Set(),
30
+ _errors: shallowReactive({})
31
+ }),
32
+ static: {
33
+ data: {}
34
+ },
35
+ runWithContext(fn) {
36
+ if (nuxtApp._scope.active && !getCurrentScope()) {
37
+ return nuxtApp._scope.run(() => callWithNuxt(nuxtApp, fn));
38
+ }
39
+ return callWithNuxt(nuxtApp, fn);
40
+ },
41
+ isHydrating: import.meta.client,
42
+ deferHydration() {
43
+ if (!nuxtApp.isHydrating) {
44
+ return () => {
45
+ };
46
+ }
47
+ hydratingCount++;
48
+ let called = false;
49
+ return () => {
50
+ if (called) {
51
+ return;
52
+ }
53
+ called = true;
54
+ hydratingCount--;
55
+ if (hydratingCount === 0) {
56
+ nuxtApp.isHydrating = false;
57
+ return nuxtApp.callHook("app:suspense:resolve");
58
+ }
59
+ };
60
+ },
61
+ _asyncDataPromises: {},
62
+ _asyncData: shallowReactive({}),
63
+ _payloadRevivers: {},
64
+ ...options
65
+ };
66
+ if (import.meta.server) {
67
+ nuxtApp.payload.serverRendered = true;
68
+ }
69
+ if (import.meta.server && nuxtApp.ssrContext) {
70
+ nuxtApp.payload.path = nuxtApp.ssrContext.url;
71
+ nuxtApp.ssrContext.nuxt = nuxtApp;
72
+ nuxtApp.ssrContext.payload = nuxtApp.payload;
73
+ nuxtApp.ssrContext.config = {
74
+ public: nuxtApp.ssrContext.runtimeConfig.public,
75
+ app: nuxtApp.ssrContext.runtimeConfig.app
76
+ };
77
+ }
78
+ if (import.meta.client) {
79
+ const __NUXT__ = multiApp ? window.__NUXT__?.[nuxtApp._id] : window.__NUXT__;
80
+ if (__NUXT__) {
81
+ for (const key in __NUXT__) {
82
+ switch (key) {
83
+ case "data":
84
+ case "state":
85
+ case "_errors":
86
+ Object.assign(nuxtApp.payload[key], __NUXT__[key]);
87
+ break;
88
+ default:
89
+ nuxtApp.payload[key] = __NUXT__[key];
90
+ }
91
+ }
92
+ }
93
+ }
94
+ nuxtApp.hooks = createHooks();
95
+ nuxtApp.hook = nuxtApp.hooks.hook;
96
+ if (import.meta.server) {
97
+ const contextCaller = async function(hooks, args) {
98
+ for (const hook of hooks) {
99
+ await nuxtApp.runWithContext(() => hook(...args));
100
+ }
101
+ };
102
+ nuxtApp.hooks.callHook = (name, ...args) => nuxtApp.hooks.callHookWith(contextCaller, name, ...args);
103
+ }
104
+ nuxtApp.callHook = nuxtApp.hooks.callHook;
105
+ nuxtApp.provide = (name, value) => {
106
+ const $name = "$" + name;
107
+ defineGetter(nuxtApp, $name, value);
108
+ defineGetter(nuxtApp.vueApp.config.globalProperties, $name, value);
109
+ };
110
+ defineGetter(nuxtApp.vueApp, "$nuxt", nuxtApp);
111
+ defineGetter(nuxtApp.vueApp.config.globalProperties, "$nuxt", nuxtApp);
112
+ if (import.meta.client) {
113
+ if (chunkErrorEvent) {
114
+ window.addEventListener(chunkErrorEvent, (event) => {
115
+ nuxtApp.callHook("app:chunkError", { error: event.payload });
116
+ if (event.payload.message.includes("Unable to preload CSS")) {
117
+ event.preventDefault();
118
+ }
119
+ });
120
+ }
121
+ window.useNuxtApp ||= useNuxtApp;
122
+ const unreg = nuxtApp.hook("app:error", (...args) => {
123
+ console.error("[nuxt] error caught during app initialization", ...args);
124
+ });
125
+ nuxtApp.hook("app:mounted", unreg);
126
+ }
127
+ const runtimeConfig = import.meta.server ? options.ssrContext.runtimeConfig : nuxtApp.payload.config;
128
+ nuxtApp.provide("config", import.meta.client && import.meta.dev ? wrappedConfig(runtimeConfig) : runtimeConfig);
129
+ return nuxtApp;
130
+ }
131
+ export function registerPluginHooks(nuxtApp, plugin) {
132
+ if (plugin.hooks) {
133
+ nuxtApp.hooks.addHooks(plugin.hooks);
134
+ }
135
+ }
136
+ export async function applyPlugin(nuxtApp, plugin) {
137
+ if (typeof plugin === "function") {
138
+ const { provide } = await nuxtApp.runWithContext(() => plugin(nuxtApp)) || {};
139
+ if (provide && typeof provide === "object") {
140
+ for (const key in provide) {
141
+ nuxtApp.provide(key, provide[key]);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ export async function applyPlugins(nuxtApp, plugins) {
147
+ const resolvedPlugins = /* @__PURE__ */ new Set();
148
+ const unresolvedPlugins = [];
149
+ const parallels = [];
150
+ let error = void 0;
151
+ let promiseDepth = 0;
152
+ async function executePlugin(plugin) {
153
+ const unresolvedPluginsForThisPlugin = plugin.dependsOn?.filter((name) => plugins.some((p) => p._name === name) && !resolvedPlugins.has(name)) ?? [];
154
+ if (unresolvedPluginsForThisPlugin.length > 0) {
155
+ unresolvedPlugins.push([new Set(unresolvedPluginsForThisPlugin), plugin]);
156
+ } else {
157
+ const promise = applyPlugin(nuxtApp, plugin).then(async () => {
158
+ if (plugin._name) {
159
+ resolvedPlugins.add(plugin._name);
160
+ await Promise.all(unresolvedPlugins.map(async ([dependsOn, unexecutedPlugin]) => {
161
+ if (dependsOn.has(plugin._name)) {
162
+ dependsOn.delete(plugin._name);
163
+ if (dependsOn.size === 0) {
164
+ promiseDepth++;
165
+ await executePlugin(unexecutedPlugin);
166
+ }
167
+ }
168
+ }));
169
+ }
170
+ }).catch((e) => {
171
+ if (!plugin.parallel && !nuxtApp.payload.error) {
172
+ throw e;
173
+ }
174
+ error ||= e;
175
+ });
176
+ if (plugin.parallel) {
177
+ parallels.push(promise);
178
+ } else {
179
+ await promise;
180
+ }
181
+ }
182
+ }
183
+ for (const plugin of plugins) {
184
+ if (import.meta.server && nuxtApp.ssrContext?.islandContext && plugin.env?.islands === false) {
185
+ continue;
186
+ }
187
+ registerPluginHooks(nuxtApp, plugin);
188
+ }
189
+ for (const plugin of plugins) {
190
+ if (import.meta.server && nuxtApp.ssrContext?.islandContext && plugin.env?.islands === false) {
191
+ continue;
192
+ }
193
+ await executePlugin(plugin);
194
+ }
195
+ await Promise.all(parallels);
196
+ if (promiseDepth) {
197
+ for (let i = 0; i < promiseDepth; i++) {
198
+ await Promise.all(parallels);
199
+ }
200
+ }
201
+ if (error) {
202
+ throw nuxtApp.payload.error || error;
203
+ }
204
+ }
205
+ // @__NO_SIDE_EFFECTS__
206
+ export function defineNuxtPlugin(plugin) {
207
+ if (typeof plugin === "function") {
208
+ return plugin;
209
+ }
210
+ const _name = plugin._name || plugin.name;
211
+ delete plugin.name;
212
+ return Object.assign(plugin.setup || (() => {
213
+ }), plugin, { [NuxtPluginIndicator]: true, _name });
214
+ }
215
+ export const definePayloadPlugin = defineNuxtPlugin;
216
+ export function isNuxtPlugin(plugin) {
217
+ return typeof plugin === "function" && NuxtPluginIndicator in plugin;
218
+ }
219
+ export function callWithNuxt(nuxt, setup, args) {
220
+ const fn = () => args ? setup(...args) : setup();
221
+ const nuxtAppCtx = getNuxtAppCtx(nuxt._id);
222
+ if (import.meta.server) {
223
+ return nuxt.vueApp.runWithContext(() => nuxtAppCtx.callAsync(nuxt, fn));
224
+ } else {
225
+ nuxtAppCtx.set(nuxt);
226
+ return nuxt.vueApp.runWithContext(fn);
227
+ }
228
+ }
229
+ export function tryUseNuxtApp(id) {
230
+ let nuxtAppInstance;
231
+ if (hasInjectionContext()) {
232
+ nuxtAppInstance = getCurrentInstance()?.appContext.app.$nuxt;
233
+ }
234
+ nuxtAppInstance ||= getNuxtAppCtx(id).tryUse();
235
+ return nuxtAppInstance || null;
236
+ }
237
+ export function useNuxtApp(id) {
238
+ const nuxtAppInstance = tryUseNuxtApp(id);
239
+ if (!nuxtAppInstance) {
240
+ if (import.meta.dev) {
241
+ throw new Error("[nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function. This is probably not a Nuxt bug. Find out more at `https://nuxt.com/docs/4.x/guide/concepts/auto-imports#vue-and-nuxt-composables`.");
242
+ } else {
243
+ throw new Error("[nuxt] instance unavailable");
244
+ }
245
+ }
246
+ return nuxtAppInstance;
247
+ }
248
+ // @__NO_SIDE_EFFECTS__
249
+ export function useRuntimeConfig(_event) {
250
+ return useNuxtApp().$config;
251
+ }
252
+ function defineGetter(obj, key, val) {
253
+ Object.defineProperty(obj, key, { get: () => val });
254
+ }
255
+ export function defineAppConfig(config) {
256
+ return config;
257
+ }
258
+ const loggedKeys = /* @__PURE__ */ new Set();
259
+ function wrappedConfig(runtimeConfig) {
260
+ if (!import.meta.dev || import.meta.server) {
261
+ return runtimeConfig;
262
+ }
263
+ const keys = [];
264
+ for (const key in runtimeConfig) {
265
+ keys.push(`\`${key}\``);
266
+ }
267
+ const lastKey = keys.pop();
268
+ return new Proxy(runtimeConfig, {
269
+ get(target, p, receiver) {
270
+ if (typeof p === "string" && p !== "public" && !(p in target) && !p.startsWith("__v")) {
271
+ if (!loggedKeys.has(p)) {
272
+ loggedKeys.add(p);
273
+ console.warn(`[nuxt] Could not access \`${p}\`. The only available runtime config keys on the client side are ${keys.join(", ")} and ${lastKey}. See https://nuxt.com/docs/4.x/guide/going-further/runtime-config for more information.`);
274
+ }
275
+ }
276
+ return Reflect.get(target, p, receiver);
277
+ }
278
+ });
279
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { defineNuxtPlugin } from "../nuxt.js";
2
+ export default defineNuxtPlugin({
3
+ name: "nuxt:browser-devtools-timing",
4
+ enforce: "pre",
5
+ setup(nuxtApp) {
6
+ nuxtApp.hooks.beforeEach((event) => {
7
+ event.__startTime = performance.now();
8
+ });
9
+ nuxtApp.hooks.afterEach((event) => {
10
+ performance.measure(event.name, {
11
+ // @ts-expect-error __startTime is not a public API
12
+ start: event.__startTime,
13
+ detail: {
14
+ devtools: {
15
+ dataType: "track-entry",
16
+ track: "nuxt",
17
+ color: "tertiary-dark"
18
+ }
19
+ }
20
+ });
21
+ });
22
+ }
23
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { nextTick } from "vue";
2
+ import { defineNuxtPlugin } from "../nuxt.js";
3
+ import { onNuxtReady } from "../composables/ready.js";
4
+ import { useError } from "../composables/error.js";
5
+ import layouts from "#build/layouts";
6
+ export default defineNuxtPlugin({
7
+ name: "nuxt:checkIfLayoutUsed",
8
+ setup(nuxtApp) {
9
+ const error = useError();
10
+ function checkIfLayoutUsed() {
11
+ if (!error.value && !nuxtApp._isNuxtLayoutUsed && Object.keys(layouts).length > 0) {
12
+ console.warn("[nuxt] Your project has layouts but the `<NuxtLayout />` component has not been used.");
13
+ }
14
+ }
15
+ if (import.meta.server) {
16
+ nuxtApp.hook("app:rendered", ({ renderResult }) => {
17
+ if (renderResult?.html) {
18
+ nextTick(checkIfLayoutUsed);
19
+ }
20
+ });
21
+ } else {
22
+ onNuxtReady(checkIfLayoutUsed);
23
+ }
24
+ },
25
+ env: {
26
+ islands: false
27
+ }
28
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,39 @@
1
+ import { defineNuxtPlugin } from "../nuxt.js";
2
+ import { getAppManifest } from "../composables/manifest.js";
3
+ import { onNuxtReady } from "../composables/ready.js";
4
+ import { buildAssetsURL } from "#internal/nuxt/paths";
5
+ import { outdatedBuildInterval } from "#build/nuxt.config.mjs";
6
+ export default defineNuxtPlugin((nuxtApp) => {
7
+ if (import.meta.test) {
8
+ return;
9
+ }
10
+ let timeout;
11
+ async function getLatestManifest() {
12
+ let currentManifest;
13
+ try {
14
+ currentManifest = await getAppManifest();
15
+ } catch (e) {
16
+ const err = e;
17
+ if (!("status" in err && (err.status === 404 || err.status === 403))) {
18
+ throw err;
19
+ }
20
+ }
21
+ if (timeout) {
22
+ clearTimeout(timeout);
23
+ }
24
+ timeout = setTimeout(getLatestManifest, outdatedBuildInterval);
25
+ try {
26
+ const meta = await $fetch(buildAssetsURL("builds/latest.json") + `?${Date.now()}`);
27
+ if (meta.id !== currentManifest?.id) {
28
+ nuxtApp.hooks.callHook("app:manifest:update", meta);
29
+ if (timeout) {
30
+ clearTimeout(timeout);
31
+ }
32
+ }
33
+ } catch {
34
+ }
35
+ }
36
+ onNuxtReady(() => {
37
+ timeout = setTimeout(getLatestManifest, outdatedBuildInterval);
38
+ });
39
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import { joinURL } from "ufo";
2
+ import { defineNuxtPlugin, useRuntimeConfig } from "../nuxt.js";
3
+ import { reloadNuxtApp } from "../composables/chunk.js";
4
+ import { addRouteMiddleware } from "../composables/router.js";
5
+ export default defineNuxtPlugin({
6
+ name: "nuxt:chunk-reload-immediate",
7
+ setup(nuxtApp) {
8
+ let currentlyNavigationTo = null;
9
+ addRouteMiddleware((to) => {
10
+ currentlyNavigationTo = to;
11
+ });
12
+ const config = useRuntimeConfig();
13
+ function reloadAppAtPath(to) {
14
+ const path = joinURL(config.app.baseURL, to.fullPath);
15
+ reloadNuxtApp({ path, persistState: true });
16
+ }
17
+ nuxtApp.hook("app:chunkError", () => reloadAppAtPath(currentlyNavigationTo ?? nuxtApp._route));
18
+ nuxtApp.hook("app:manifest:update", () => reloadAppAtPath(nuxtApp._route));
19
+ }
20
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,30 @@
1
+ import { joinURL } from "ufo";
2
+ import { defineNuxtPlugin, useRuntimeConfig } from "../nuxt.js";
3
+ import { useRouter } from "../composables/router.js";
4
+ import { reloadNuxtApp } from "../composables/chunk.js";
5
+ export default defineNuxtPlugin({
6
+ name: "nuxt:chunk-reload",
7
+ setup(nuxtApp) {
8
+ const router = useRouter();
9
+ const config = useRuntimeConfig();
10
+ const chunkErrors = /* @__PURE__ */ new Set();
11
+ router.beforeEach(() => {
12
+ chunkErrors.clear();
13
+ });
14
+ nuxtApp.hook("app:chunkError", ({ error }) => {
15
+ chunkErrors.add(error);
16
+ });
17
+ function reloadAppAtPath(to) {
18
+ const path = joinURL(config.app.baseURL, to.fullPath);
19
+ reloadNuxtApp({ path, persistState: true });
20
+ }
21
+ nuxtApp.hook("app:manifest:update", () => {
22
+ router.beforeResolve(reloadAppAtPath);
23
+ });
24
+ router.onError((error, to) => {
25
+ if (chunkErrors.has(error)) {
26
+ reloadAppAtPath(to);
27
+ }
28
+ });
29
+ }
30
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,37 @@
1
+ import { ref } from "vue";
2
+ import { defineNuxtPlugin } from "../nuxt.js";
3
+ import { useHead } from "../composables/head.js";
4
+ const SUPPORTED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
5
+ export default defineNuxtPlugin({
6
+ name: "nuxt:cross-origin-prefetch",
7
+ setup(nuxtApp) {
8
+ const externalURLs = ref(/* @__PURE__ */ new Set());
9
+ function generateRules() {
10
+ return {
11
+ type: "speculationrules",
12
+ key: "speculationrules",
13
+ innerHTML: JSON.stringify({
14
+ prefetch: [
15
+ {
16
+ source: "list",
17
+ urls: [...externalURLs.value],
18
+ requires: ["anonymous-client-ip-when-cross-origin"]
19
+ }
20
+ ]
21
+ })
22
+ };
23
+ }
24
+ const head = useHead({
25
+ script: [generateRules()]
26
+ });
27
+ nuxtApp.hook("link:prefetch", (url) => {
28
+ for (const protocol of SUPPORTED_PROTOCOLS) {
29
+ if (url.startsWith(protocol) && SUPPORTED_PROTOCOLS.has(new URL(url).protocol)) {
30
+ externalURLs.value.add(url);
31
+ head?.patch({ script: [generateRules()] });
32
+ return;
33
+ }
34
+ }
35
+ });
36
+ }
37
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { createDebugger } from "hookable";
2
+ import { defineNuxtPlugin } from "../nuxt.js";
3
+ export default defineNuxtPlugin({
4
+ name: "nuxt:debug:hooks",
5
+ enforce: "pre",
6
+ setup(nuxtApp) {
7
+ createDebugger(nuxtApp.hooks, { tag: "nuxt-app" });
8
+ }
9
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,60 @@
1
+ import { createConsola } from "consola";
2
+ import { parse } from "devalue";
3
+ import { h } from "vue";
4
+ import { defineNuxtPlugin } from "../nuxt.js";
5
+ import { devLogs, devRootDir } from "#build/nuxt.config.mjs";
6
+ const devRevivers = import.meta.server ? {} : {
7
+ VNode: (data) => h(data.type, data.props),
8
+ URL: (data) => new URL(data)
9
+ };
10
+ export default defineNuxtPlugin(async (nuxtApp) => {
11
+ if (import.meta.test) {
12
+ return;
13
+ }
14
+ if (import.meta.server) {
15
+ nuxtApp.ssrContext.event.context._payloadReducers = nuxtApp.ssrContext._payloadReducers;
16
+ return;
17
+ }
18
+ if (devLogs !== "silent") {
19
+ const logger = createConsola({
20
+ formatOptions: {
21
+ colors: true,
22
+ date: true
23
+ }
24
+ });
25
+ nuxtApp.hook("dev:ssr-logs", (logs) => {
26
+ for (const log of logs) {
27
+ logger.log(normalizeServerLog({ ...log }));
28
+ }
29
+ });
30
+ }
31
+ if (typeof window !== "undefined") {
32
+ const nuxtLogsElement = document.querySelector(`[data-nuxt-logs="${nuxtApp._id}"]`);
33
+ const content = nuxtLogsElement?.textContent;
34
+ const logs = content ? parse(content, { ...devRevivers, ...nuxtApp._payloadRevivers }) : [];
35
+ await nuxtApp.hooks.callHook("dev:ssr-logs", logs);
36
+ }
37
+ });
38
+ function normalizeFilenames(stack) {
39
+ if (!stack) {
40
+ return "";
41
+ }
42
+ let message = "";
43
+ for (const item of stack) {
44
+ const source = item.source.replace(`${devRootDir}/`, "");
45
+ if (item.function) {
46
+ message += ` at ${item.function} (${source})
47
+ `;
48
+ } else {
49
+ message += ` at ${source}
50
+ `;
51
+ }
52
+ }
53
+ return message;
54
+ }
55
+ function normalizeServerLog(log) {
56
+ log.additional = normalizeFilenames(log.stack);
57
+ log.tag = "ssr";
58
+ delete log.stack;
59
+ return log;
60
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { defineNuxtPlugin } from "../nuxt.js";
2
+ import { onNuxtReady } from "../composables/ready.js";
3
+ import { useRouter } from "../composables/router.js";
4
+ export default defineNuxtPlugin(() => {
5
+ const router = useRouter();
6
+ onNuxtReady(() => {
7
+ router.beforeResolve(async () => {
8
+ await new Promise((resolve) => {
9
+ setTimeout(resolve, 100);
10
+ requestAnimationFrame(() => {
11
+ setTimeout(resolve, 0);
12
+ });
13
+ });
14
+ });
15
+ });
16
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,50 @@
1
+ import { defineNuxtPlugin } from "../nuxt.js";
2
+ import { loadPayload } from "../composables/payload.js";
3
+ import { onNuxtReady } from "../composables/ready.js";
4
+ import { useRouter } from "../composables/router.js";
5
+ import { getAppManifest } from "../composables/manifest.js";
6
+ import { appManifest as isAppManifestEnabled, purgeCachedData } from "#build/nuxt.config.mjs";
7
+ export default defineNuxtPlugin({
8
+ name: "nuxt:payload",
9
+ setup(nuxtApp) {
10
+ if (import.meta.dev) {
11
+ return;
12
+ }
13
+ const staticKeysToRemove = /* @__PURE__ */ new Set();
14
+ useRouter().beforeResolve(async (to, from) => {
15
+ if (to.path === from.path) {
16
+ return;
17
+ }
18
+ const payload = await loadPayload(to.path);
19
+ if (!payload) {
20
+ return;
21
+ }
22
+ if (purgeCachedData) {
23
+ for (const key of staticKeysToRemove) {
24
+ delete nuxtApp.static.data[key];
25
+ }
26
+ }
27
+ for (const key in payload.data) {
28
+ if (purgeCachedData) {
29
+ if (!(key in nuxtApp.static.data)) {
30
+ staticKeysToRemove.add(key);
31
+ }
32
+ }
33
+ nuxtApp.static.data[key] = payload.data[key];
34
+ }
35
+ });
36
+ onNuxtReady(() => {
37
+ nuxtApp.hooks.hook("link:prefetch", async (url) => {
38
+ const { hostname } = new URL(url, window.location.href);
39
+ if (hostname === window.location.hostname) {
40
+ await loadPayload(url).catch(() => {
41
+ console.warn("[nuxt] Error preloading payload for", url);
42
+ });
43
+ }
44
+ });
45
+ if (isAppManifestEnabled && navigator.connection?.effectiveType !== "slow-2g") {
46
+ setTimeout(getAppManifest, 1e3);
47
+ }
48
+ });
49
+ }
50
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { defineNuxtPlugin } from "../nuxt.js";
2
+ export default defineNuxtPlugin({
3
+ name: "nuxt:webpack-preload",
4
+ setup(nuxtApp) {
5
+ nuxtApp.vueApp.mixin({
6
+ beforeCreate() {
7
+ const { modules } = this.$nuxt.ssrContext;
8
+ const { __moduleIdentifier } = this.$options;
9
+ modules.add(__moduleIdentifier);
10
+ }
11
+ });
12
+ }
13
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../nuxt.js").Plugin<Record<string, unknown>> & import("../nuxt.js").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;