nuxt-nightly 4.2.0-29336619.cf102e88 → 4.2.0-29344147.7bcc4ca3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/composables/payload.js +1 -1
- package/dist/app/types/augments.d.ts +0 -26
- package/dist/app/types.d.ts +35 -2
- package/dist/index.mjs +30 -770
- package/package.json +6 -13
- package/types.d.mts +1 -38
- package/types.d.ts +1 -38
- package/dist/core/runtime/nitro/handlers/error.d.ts +0 -3
- package/dist/core/runtime/nitro/handlers/error.js +0 -63
- package/dist/core/runtime/nitro/handlers/island.d.ts +0 -4
- package/dist/core/runtime/nitro/handlers/island.js +0 -100
- package/dist/core/runtime/nitro/handlers/renderer.d.ts +0 -16
- package/dist/core/runtime/nitro/handlers/renderer.js +0 -237
- package/dist/core/runtime/nitro/middleware/no-ssr.d.ts +0 -2
- package/dist/core/runtime/nitro/middleware/no-ssr.js +0 -7
- package/dist/core/runtime/nitro/plugins/dev-server-logs.d.ts +0 -3
- package/dist/core/runtime/nitro/plugins/dev-server-logs.js +0 -82
- package/dist/core/runtime/nitro/templates/error-500.d.ts +0 -2
- package/dist/core/runtime/nitro/templates/error-500.js +0 -6
- package/dist/core/runtime/nitro/utils/app-config.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/app-config.js +0 -25
- package/dist/core/runtime/nitro/utils/cache-driver.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/cache-driver.js +0 -34
- package/dist/core/runtime/nitro/utils/cache.d.ts +0 -8
- package/dist/core/runtime/nitro/utils/cache.js +0 -18
- package/dist/core/runtime/nitro/utils/config.d.ts +0 -1
- package/dist/core/runtime/nitro/utils/config.js +0 -1
- package/dist/core/runtime/nitro/utils/dev.d.ts +0 -1
- package/dist/core/runtime/nitro/utils/dev.js +0 -328
- package/dist/core/runtime/nitro/utils/error.d.ts +0 -6
- package/dist/core/runtime/nitro/utils/error.js +0 -11
- package/dist/core/runtime/nitro/utils/paths.d.ts +0 -4
- package/dist/core/runtime/nitro/utils/paths.js +0 -16
- package/dist/core/runtime/nitro/utils/renderer/app.d.ts +0 -7
- package/dist/core/runtime/nitro/utils/renderer/app.js +0 -32
- package/dist/core/runtime/nitro/utils/renderer/build-files.d.ts +0 -22
- package/dist/core/runtime/nitro/utils/renderer/build-files.js +0 -86
- package/dist/core/runtime/nitro/utils/renderer/inline-styles.d.ts +0 -2
- package/dist/core/runtime/nitro/utils/renderer/inline-styles.js +0 -13
- package/dist/core/runtime/nitro/utils/renderer/islands.d.ts +0 -36
- package/dist/core/runtime/nitro/utils/renderer/islands.js +0 -82
- package/dist/core/runtime/nitro/utils/renderer/payload.d.ts +0 -37
- package/dist/core/runtime/nitro/utils/renderer/payload.js +0 -66
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-nightly",
|
|
3
|
-
"version": "4.2.0-
|
|
3
|
+
"version": "4.2.0-29344147.7bcc4ca3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@dxup/nuxt": "^0.1.0",
|
|
68
68
|
"@nuxt/cli": "npm:@nuxt/cli-nightly@latest",
|
|
69
|
-
"@nuxt/devalue": "^2.0.2",
|
|
70
69
|
"@nuxt/devtools": "^2.6.5",
|
|
71
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.2.0-
|
|
72
|
-
"@nuxt/
|
|
70
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.2.0-29344147.7bcc4ca3",
|
|
71
|
+
"@nuxt/nitro-server": "npm:@nuxt/nitro-server-nightly@4.2.0-29344147.7bcc4ca3",
|
|
72
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-29344147.7bcc4ca3",
|
|
73
73
|
"@nuxt/telemetry": "^2.6.6",
|
|
74
|
-
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.2.0-
|
|
74
|
+
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.2.0-29344147.7bcc4ca3",
|
|
75
75
|
"@unhead/vue": "^2.0.14",
|
|
76
76
|
"@vue/shared": "^3.5.22",
|
|
77
77
|
"c12": "^3.3.0",
|
|
@@ -83,9 +83,7 @@
|
|
|
83
83
|
"destr": "^2.0.5",
|
|
84
84
|
"devalue": "^5.3.2",
|
|
85
85
|
"errx": "^0.1.0",
|
|
86
|
-
"esbuild": "^0.25.10",
|
|
87
86
|
"escape-string-regexp": "^5.0.0",
|
|
88
|
-
"estree-walker": "^3.0.3",
|
|
89
87
|
"exsolve": "^1.0.7",
|
|
90
88
|
"h3": "^1.15.4",
|
|
91
89
|
"hookable": "^5.5.3",
|
|
@@ -96,9 +94,7 @@
|
|
|
96
94
|
"knitwork": "^1.2.0",
|
|
97
95
|
"magic-string": "^0.30.19",
|
|
98
96
|
"mlly": "^1.8.0",
|
|
99
|
-
"mocked-exports": "^0.1.1",
|
|
100
97
|
"nanotar": "^0.2.0",
|
|
101
|
-
"nitropack": "^2.12.7",
|
|
102
98
|
"nypm": "^0.6.2",
|
|
103
99
|
"ofetch": "^1.4.1",
|
|
104
100
|
"ohash": "^2.0.11",
|
|
@@ -113,7 +109,6 @@
|
|
|
113
109
|
"radix3": "^1.1.2",
|
|
114
110
|
"scule": "^1.3.0",
|
|
115
111
|
"semver": "^7.7.3",
|
|
116
|
-
"seroval": "^1.3.2",
|
|
117
112
|
"std-env": "^3.9.0",
|
|
118
113
|
"tinyglobby": "^0.2.15",
|
|
119
114
|
"ufo": "^1.6.1",
|
|
@@ -123,11 +118,8 @@
|
|
|
123
118
|
"unimport": "^5.4.1",
|
|
124
119
|
"unplugin": "^2.3.10",
|
|
125
120
|
"unplugin-vue-router": "^0.15.0",
|
|
126
|
-
"unstorage": "^1.17.1",
|
|
127
121
|
"untyped": "^2.0.0",
|
|
128
122
|
"vue": "^3.5.22",
|
|
129
|
-
"vue-bundle-renderer": "^2.2.0",
|
|
130
|
-
"vue-devtools-stub": "^0.1.0",
|
|
131
123
|
"vue-router": "^4.5.1"
|
|
132
124
|
},
|
|
133
125
|
"devDependencies": {
|
|
@@ -140,6 +132,7 @@
|
|
|
140
132
|
"unbuild": "3.6.1",
|
|
141
133
|
"vite": "7.1.9",
|
|
142
134
|
"vitest": "3.2.4",
|
|
135
|
+
"vue-bundle-renderer": "2.2.0",
|
|
143
136
|
"vue-sfc-transformer": "0.1.17"
|
|
144
137
|
},
|
|
145
138
|
"peerDependencies": {
|
package/types.d.mts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { H3Event } from 'h3'
|
|
4
|
-
import type { LogObject } from 'consola'
|
|
5
|
-
import type { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from './dist/app/types.js'
|
|
6
|
-
import type { RuntimeConfig, SchemaDefinition } from 'nuxt/schema'
|
|
1
|
+
import type { SchemaDefinition } from 'nuxt/schema'
|
|
7
2
|
import type { DefineNuxtConfig } from 'nuxt/config'
|
|
8
3
|
|
|
9
4
|
export * from './dist/index.js'
|
|
@@ -17,35 +12,3 @@ declare global {
|
|
|
17
12
|
readonly env: ImportMetaEnv
|
|
18
13
|
}
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
// Note: Keep in sync with packages/nuxt/src/core/templates.ts
|
|
22
|
-
declare module 'nitropack' {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
24
|
-
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
25
|
-
interface NitroRouteConfig {
|
|
26
|
-
ssr?: boolean
|
|
27
|
-
noScripts?: boolean
|
|
28
|
-
/** @deprecated Use `noScripts` instead */
|
|
29
|
-
experimentalNoScripts?: boolean
|
|
30
|
-
}
|
|
31
|
-
interface NitroRuntimeHooks {
|
|
32
|
-
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
33
|
-
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
|
|
34
|
-
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
declare module 'nitropack/types' {
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
39
|
-
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
40
|
-
interface NitroRouteConfig {
|
|
41
|
-
ssr?: boolean
|
|
42
|
-
noScripts?: boolean
|
|
43
|
-
/** @deprecated Use `noScripts` instead */
|
|
44
|
-
experimentalNoScripts?: boolean
|
|
45
|
-
}
|
|
46
|
-
interface NitroRuntimeHooks {
|
|
47
|
-
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
48
|
-
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
|
|
49
|
-
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
50
|
-
}
|
|
51
|
-
}
|
package/types.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { H3Event } from 'h3'
|
|
4
|
-
import type { LogObject } from 'consola'
|
|
5
|
-
import type { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from './dist/app/types'
|
|
6
|
-
import type { RuntimeConfig, SchemaDefinition } from 'nuxt/schema'
|
|
1
|
+
import type { SchemaDefinition } from 'nuxt/schema'
|
|
7
2
|
import type { DefineNuxtConfig } from 'nuxt/config'
|
|
8
3
|
|
|
9
4
|
export * from './dist/index'
|
|
@@ -17,35 +12,3 @@ declare global {
|
|
|
17
12
|
readonly env: ImportMetaEnv
|
|
18
13
|
}
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
// Note: Keep in sync with packages/nuxt/src/core/templates.ts
|
|
22
|
-
declare module 'nitropack' {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
24
|
-
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
25
|
-
interface NitroRouteConfig {
|
|
26
|
-
ssr?: boolean
|
|
27
|
-
noScripts?: boolean
|
|
28
|
-
/** @deprecated Use `noScripts` instead */
|
|
29
|
-
experimentalNoScripts?: boolean
|
|
30
|
-
}
|
|
31
|
-
interface NitroRuntimeHooks {
|
|
32
|
-
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
33
|
-
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
|
|
34
|
-
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
declare module 'nitropack/types' {
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
39
|
-
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
40
|
-
interface NitroRouteConfig {
|
|
41
|
-
ssr?: boolean
|
|
42
|
-
noScripts?: boolean
|
|
43
|
-
/** @deprecated Use `noScripts` instead */
|
|
44
|
-
experimentalNoScripts?: boolean
|
|
45
|
-
}
|
|
46
|
-
interface NitroRuntimeHooks {
|
|
47
|
-
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
48
|
-
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
|
|
49
|
-
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { joinURL, withQuery, withoutBase } from "ufo";
|
|
2
|
-
import { appendResponseHeader, getRequestHeaders, send, setResponseHeader, setResponseHeaders, setResponseStatus } from "h3";
|
|
3
|
-
import { useNitroApp, useRuntimeConfig } from "nitropack/runtime";
|
|
4
|
-
import { isJsonRequest } from "../utils/error.js";
|
|
5
|
-
import { generateErrorOverlayHTML } from "../utils/dev.js";
|
|
6
|
-
export default (async function errorhandler(error, event, { defaultHandler }) {
|
|
7
|
-
if (event.handled || isJsonRequest(event)) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const defaultRes = await defaultHandler(error, event, { json: true });
|
|
11
|
-
const statusCode = error.statusCode || 500;
|
|
12
|
-
if (statusCode === 404 && defaultRes.status === 302) {
|
|
13
|
-
setResponseHeaders(event, defaultRes.headers);
|
|
14
|
-
setResponseStatus(event, defaultRes.status, defaultRes.statusText);
|
|
15
|
-
return send(event, JSON.stringify(defaultRes.body, null, 2));
|
|
16
|
-
}
|
|
17
|
-
if (import.meta.dev && typeof defaultRes.body !== "string" && Array.isArray(defaultRes.body.stack)) {
|
|
18
|
-
defaultRes.body.stack = defaultRes.body.stack.join("\n");
|
|
19
|
-
}
|
|
20
|
-
const errorObject = defaultRes.body;
|
|
21
|
-
const url = new URL(errorObject.url);
|
|
22
|
-
errorObject.url = withoutBase(url.pathname, useRuntimeConfig(event).app.baseURL) + url.search + url.hash;
|
|
23
|
-
errorObject.message ||= "Server Error";
|
|
24
|
-
errorObject.data ||= error.data;
|
|
25
|
-
errorObject.statusMessage ||= error.statusMessage;
|
|
26
|
-
delete defaultRes.headers["content-type"];
|
|
27
|
-
delete defaultRes.headers["content-security-policy"];
|
|
28
|
-
setResponseHeaders(event, defaultRes.headers);
|
|
29
|
-
const reqHeaders = getRequestHeaders(event);
|
|
30
|
-
const isRenderingError = event.path.startsWith("/__nuxt_error") || !!reqHeaders["x-nuxt-error"];
|
|
31
|
-
const res = isRenderingError ? null : await useNitroApp().localFetch(
|
|
32
|
-
withQuery(joinURL(useRuntimeConfig(event).app.baseURL, "/__nuxt_error"), errorObject),
|
|
33
|
-
{
|
|
34
|
-
headers: { ...reqHeaders, "x-nuxt-error": "true" },
|
|
35
|
-
redirect: "manual"
|
|
36
|
-
}
|
|
37
|
-
).catch(() => null);
|
|
38
|
-
if (event.handled) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!res) {
|
|
42
|
-
const { template } = await import("../templates/error-500.js");
|
|
43
|
-
if (import.meta.dev) {
|
|
44
|
-
errorObject.description = errorObject.message;
|
|
45
|
-
}
|
|
46
|
-
setResponseHeader(event, "Content-Type", "text/html;charset=UTF-8");
|
|
47
|
-
return send(event, template(errorObject));
|
|
48
|
-
}
|
|
49
|
-
const html = await res.text();
|
|
50
|
-
for (const [header, value] of res.headers.entries()) {
|
|
51
|
-
if (header === "set-cookie") {
|
|
52
|
-
appendResponseHeader(event, header, value);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
setResponseHeader(event, header, value);
|
|
56
|
-
}
|
|
57
|
-
setResponseStatus(event, res.status && res.status !== 200 ? res.status : defaultRes.status, res.statusText || defaultRes.statusText);
|
|
58
|
-
if (import.meta.dev) {
|
|
59
|
-
const prettyResponse = await defaultHandler(error, event, { json: false });
|
|
60
|
-
return send(event, html.replace("</body>", `${generateErrorOverlayHTML(prettyResponse.body)}</body>`));
|
|
61
|
-
}
|
|
62
|
-
return send(event, html);
|
|
63
|
-
});
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { RenderResponse } from 'nitropack/types';
|
|
2
|
-
import type { NuxtIslandResponse } from '../utils/renderer/islands.js';
|
|
3
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<NuxtIslandResponse | Partial<RenderResponse>>>;
|
|
4
|
-
export default _default;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { useNitroApp } from "nitropack/runtime";
|
|
2
|
-
import { destr } from "destr";
|
|
3
|
-
import { defineEventHandler, getQuery, readBody, setResponseHeaders } from "h3";
|
|
4
|
-
import { resolveUnrefHeadInput } from "@unhead/vue";
|
|
5
|
-
import { getRequestDependencies } from "vue-bundle-renderer/runtime";
|
|
6
|
-
import { getQuery as getURLQuery } from "ufo";
|
|
7
|
-
import { islandCache, islandPropCache } from "../utils/cache.js";
|
|
8
|
-
import { createSSRContext } from "../utils/renderer/app.js";
|
|
9
|
-
import { getSSRRenderer } from "../utils/renderer/build-files.js";
|
|
10
|
-
import { renderInlineStyles } from "../utils/renderer/inline-styles.js";
|
|
11
|
-
import { getClientIslandResponse, getServerComponentHTML, getSlotIslandResponse } from "../utils/renderer/islands.js";
|
|
12
|
-
const ISLAND_SUFFIX_RE = /\.json(?:\?.*)?$/;
|
|
13
|
-
export default defineEventHandler(async (event) => {
|
|
14
|
-
const nitroApp = useNitroApp();
|
|
15
|
-
setResponseHeaders(event, {
|
|
16
|
-
"content-type": "application/json;charset=utf-8",
|
|
17
|
-
"x-powered-by": "Nuxt"
|
|
18
|
-
});
|
|
19
|
-
if (import.meta.prerender && event.path && await islandCache.hasItem(event.path)) {
|
|
20
|
-
return islandCache.getItem(event.path);
|
|
21
|
-
}
|
|
22
|
-
const islandContext = await getIslandContext(event);
|
|
23
|
-
const ssrContext = {
|
|
24
|
-
...createSSRContext(event),
|
|
25
|
-
islandContext,
|
|
26
|
-
noSSR: false,
|
|
27
|
-
url: islandContext.url
|
|
28
|
-
};
|
|
29
|
-
const renderer = await getSSRRenderer();
|
|
30
|
-
const renderResult = await renderer.renderToString(ssrContext).catch(async (err) => {
|
|
31
|
-
await ssrContext.nuxt?.hooks.callHook("app:error", err);
|
|
32
|
-
throw err;
|
|
33
|
-
});
|
|
34
|
-
if (ssrContext.payload?.error) {
|
|
35
|
-
throw ssrContext.payload.error;
|
|
36
|
-
}
|
|
37
|
-
const inlinedStyles = await renderInlineStyles(ssrContext.modules ?? []);
|
|
38
|
-
await ssrContext.nuxt?.hooks.callHook("app:rendered", { ssrContext, renderResult });
|
|
39
|
-
if (inlinedStyles.length) {
|
|
40
|
-
ssrContext.head.push({ style: inlinedStyles });
|
|
41
|
-
}
|
|
42
|
-
if (import.meta.dev) {
|
|
43
|
-
const { styles } = getRequestDependencies(ssrContext, renderer.rendererContext);
|
|
44
|
-
const link = [];
|
|
45
|
-
for (const resource of Object.values(styles)) {
|
|
46
|
-
if ("inline" in getURLQuery(resource.file)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (resource.file.includes("scoped") && !resource.file.includes("pages/")) {
|
|
50
|
-
link.push({ rel: "stylesheet", href: renderer.rendererContext.buildAssetsURL(resource.file), crossorigin: "" });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (link.length) {
|
|
54
|
-
ssrContext.head.push({ link }, { mode: "server" });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const islandHead = {};
|
|
58
|
-
for (const entry of ssrContext.head.entries.values()) {
|
|
59
|
-
for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input))) {
|
|
60
|
-
const currentValue = islandHead[key];
|
|
61
|
-
if (Array.isArray(currentValue)) {
|
|
62
|
-
currentValue.push(...value);
|
|
63
|
-
}
|
|
64
|
-
islandHead[key] = value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const islandResponse = {
|
|
68
|
-
id: islandContext.id,
|
|
69
|
-
head: islandHead,
|
|
70
|
-
html: getServerComponentHTML(renderResult.html),
|
|
71
|
-
components: getClientIslandResponse(ssrContext),
|
|
72
|
-
slots: getSlotIslandResponse(ssrContext)
|
|
73
|
-
};
|
|
74
|
-
await nitroApp.hooks.callHook("render:island", islandResponse, { event, islandContext });
|
|
75
|
-
if (import.meta.prerender) {
|
|
76
|
-
await islandCache.setItem(`/__nuxt_island/${islandContext.name}_${islandContext.id}.json`, islandResponse);
|
|
77
|
-
await islandPropCache.setItem(`/__nuxt_island/${islandContext.name}_${islandContext.id}.json`, event.path);
|
|
78
|
-
}
|
|
79
|
-
return islandResponse;
|
|
80
|
-
});
|
|
81
|
-
async function getIslandContext(event) {
|
|
82
|
-
let url = event.path || "";
|
|
83
|
-
if (import.meta.prerender && event.path && await islandPropCache.hasItem(event.path)) {
|
|
84
|
-
url = await islandPropCache.getItem(event.path);
|
|
85
|
-
}
|
|
86
|
-
const componentParts = url.substring("/__nuxt_island".length + 1).replace(ISLAND_SUFFIX_RE, "").split("_");
|
|
87
|
-
const hashId = componentParts.length > 1 ? componentParts.pop() : void 0;
|
|
88
|
-
const componentName = componentParts.join("_");
|
|
89
|
-
const context = event.method === "GET" ? getQuery(event) : await readBody(event);
|
|
90
|
-
const ctx = {
|
|
91
|
-
url: "/",
|
|
92
|
-
...context,
|
|
93
|
-
id: hashId,
|
|
94
|
-
name: componentName,
|
|
95
|
-
props: destr(context.props) || {},
|
|
96
|
-
slots: {},
|
|
97
|
-
components: {}
|
|
98
|
-
};
|
|
99
|
-
return ctx;
|
|
100
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface NuxtRenderHTMLContext {
|
|
2
|
-
htmlAttrs: string[];
|
|
3
|
-
head: string[];
|
|
4
|
-
bodyAttrs: string[];
|
|
5
|
-
bodyPrepend: string[];
|
|
6
|
-
body: string[];
|
|
7
|
-
bodyAppend: string[];
|
|
8
|
-
}
|
|
9
|
-
export interface NuxtRenderResponse {
|
|
10
|
-
body: string;
|
|
11
|
-
statusCode: number;
|
|
12
|
-
statusMessage?: string;
|
|
13
|
-
headers: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
16
|
-
export default _default;
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import {
|
|
3
|
-
getPrefetchLinks,
|
|
4
|
-
getPreloadLinks,
|
|
5
|
-
getRequestDependencies,
|
|
6
|
-
renderResourceHeaders
|
|
7
|
-
} from "vue-bundle-renderer/runtime";
|
|
8
|
-
import { appendResponseHeader, createError, getQuery, getResponseStatus, getResponseStatusText, writeEarlyHints } from "h3";
|
|
9
|
-
import { getQuery as getURLQuery, joinURL } from "ufo";
|
|
10
|
-
import { propsToString, renderSSRHead } from "@unhead/vue/server";
|
|
11
|
-
import destr from "destr";
|
|
12
|
-
import { defineRenderHandler, getRouteRules, useNitroApp } from "nitropack/runtime";
|
|
13
|
-
import { getRenderer } from "../utils/renderer/build-files.js";
|
|
14
|
-
import { payloadCache } from "../utils/cache.js";
|
|
15
|
-
import { renderPayloadJsonScript, renderPayloadResponse, renderPayloadScript, splitPayload } from "../utils/renderer/payload.js";
|
|
16
|
-
import { createSSRContext, setSSRError } from "../utils/renderer/app.js";
|
|
17
|
-
import { renderInlineStyles } from "../utils/renderer/inline-styles.js";
|
|
18
|
-
import { replaceIslandTeleports } from "../utils/renderer/islands.js";
|
|
19
|
-
import { renderSSRHeadOptions } from "#internal/unhead.config.mjs";
|
|
20
|
-
import { appHead, appTeleportAttrs, appTeleportTag, componentIslands, appManifest as isAppManifestEnabled } from "#internal/nuxt.config.mjs";
|
|
21
|
-
import entryIds from "#internal/nuxt/entry-ids.mjs";
|
|
22
|
-
import { entryFileName } from "#internal/entry-chunk.mjs";
|
|
23
|
-
import { buildAssetsURL, publicAssetsURL } from "#internal/nuxt/paths";
|
|
24
|
-
import { relative } from "pathe";
|
|
25
|
-
globalThis.__buildAssetsURL = buildAssetsURL;
|
|
26
|
-
globalThis.__publicAssetsURL = publicAssetsURL;
|
|
27
|
-
if (process.env.NUXT_ASYNC_CONTEXT && !("AsyncLocalStorage" in globalThis)) {
|
|
28
|
-
globalThis.AsyncLocalStorage = AsyncLocalStorage;
|
|
29
|
-
}
|
|
30
|
-
const HAS_APP_TELEPORTS = !!(appTeleportTag && appTeleportAttrs.id);
|
|
31
|
-
const APP_TELEPORT_OPEN_TAG = HAS_APP_TELEPORTS ? `<${appTeleportTag}${propsToString(appTeleportAttrs)}>` : "";
|
|
32
|
-
const APP_TELEPORT_CLOSE_TAG = HAS_APP_TELEPORTS ? `</${appTeleportTag}>` : "";
|
|
33
|
-
const PAYLOAD_URL_RE = process.env.NUXT_JSON_PAYLOADS ? /^[^?]*\/_payload.json(?:\?.*)?$/ : /^[^?]*\/_payload.js(?:\?.*)?$/;
|
|
34
|
-
const PAYLOAD_FILENAME = process.env.NUXT_JSON_PAYLOADS ? "_payload.json" : "_payload.js";
|
|
35
|
-
let entryPath;
|
|
36
|
-
export default defineRenderHandler(async (event) => {
|
|
37
|
-
const nitroApp = useNitroApp();
|
|
38
|
-
const ssrError = event.path.startsWith("/__nuxt_error") ? getQuery(event) : null;
|
|
39
|
-
if (ssrError && !("__unenv__" in event.node.req)) {
|
|
40
|
-
throw createError({
|
|
41
|
-
statusCode: 404,
|
|
42
|
-
statusMessage: "Page Not Found: /__nuxt_error"
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const ssrContext = createSSRContext(event);
|
|
46
|
-
const headEntryOptions = { mode: "server" };
|
|
47
|
-
ssrContext.head.push(appHead, headEntryOptions);
|
|
48
|
-
if (ssrError) {
|
|
49
|
-
ssrError.statusCode &&= Number.parseInt(ssrError.statusCode);
|
|
50
|
-
if (process.env.PARSE_ERROR_DATA && typeof ssrError.data === "string") {
|
|
51
|
-
try {
|
|
52
|
-
ssrError.data = destr(ssrError.data);
|
|
53
|
-
} catch {
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
setSSRError(ssrContext, ssrError);
|
|
57
|
-
}
|
|
58
|
-
const isRenderingPayload = process.env.NUXT_PAYLOAD_EXTRACTION && PAYLOAD_URL_RE.test(ssrContext.url);
|
|
59
|
-
if (isRenderingPayload) {
|
|
60
|
-
const url = ssrContext.url.substring(0, ssrContext.url.lastIndexOf("/")) || "/";
|
|
61
|
-
ssrContext.url = url;
|
|
62
|
-
event._path = event.node.req.url = url;
|
|
63
|
-
if (import.meta.prerender && await payloadCache.hasItem(url)) {
|
|
64
|
-
return payloadCache.getItem(url);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const routeOptions = getRouteRules(event);
|
|
68
|
-
if (routeOptions.ssr === false) {
|
|
69
|
-
ssrContext.noSSR = true;
|
|
70
|
-
}
|
|
71
|
-
const _PAYLOAD_EXTRACTION = import.meta.prerender && process.env.NUXT_PAYLOAD_EXTRACTION && !ssrContext.noSSR;
|
|
72
|
-
const payloadURL = _PAYLOAD_EXTRACTION ? joinURL(ssrContext.runtimeConfig.app.cdnURL || ssrContext.runtimeConfig.app.baseURL, ssrContext.url.replace(/\?.*$/, ""), PAYLOAD_FILENAME) + "?" + ssrContext.runtimeConfig.app.buildId : void 0;
|
|
73
|
-
const renderer = await getRenderer(ssrContext);
|
|
74
|
-
if (process.env.NUXT_EARLY_HINTS && !isRenderingPayload && !import.meta.prerender) {
|
|
75
|
-
const { link: link2 } = renderResourceHeaders({}, renderer.rendererContext);
|
|
76
|
-
if (link2) {
|
|
77
|
-
writeEarlyHints(event, link2);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (process.env.NUXT_INLINE_STYLES) {
|
|
81
|
-
for (const id of entryIds) {
|
|
82
|
-
ssrContext.modules.add(id);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const _rendered = await renderer.renderToString(ssrContext).catch(async (error) => {
|
|
86
|
-
if (ssrContext._renderResponse && error.message === "skipping render") {
|
|
87
|
-
return {};
|
|
88
|
-
}
|
|
89
|
-
const _err = !ssrError && ssrContext.payload?.error || error;
|
|
90
|
-
await ssrContext.nuxt?.hooks.callHook("app:error", _err);
|
|
91
|
-
throw _err;
|
|
92
|
-
});
|
|
93
|
-
const inlinedStyles = process.env.NUXT_INLINE_STYLES && !ssrContext._renderResponse && !isRenderingPayload ? await renderInlineStyles(ssrContext.modules ?? []) : [];
|
|
94
|
-
await ssrContext.nuxt?.hooks.callHook("app:rendered", { ssrContext, renderResult: _rendered });
|
|
95
|
-
if (ssrContext._renderResponse) {
|
|
96
|
-
return ssrContext._renderResponse;
|
|
97
|
-
}
|
|
98
|
-
if (ssrContext.payload?.error && !ssrError) {
|
|
99
|
-
throw ssrContext.payload.error;
|
|
100
|
-
}
|
|
101
|
-
if (isRenderingPayload) {
|
|
102
|
-
const response = renderPayloadResponse(ssrContext);
|
|
103
|
-
if (import.meta.prerender) {
|
|
104
|
-
await payloadCache.setItem(ssrContext.url, response);
|
|
105
|
-
}
|
|
106
|
-
return response;
|
|
107
|
-
}
|
|
108
|
-
if (_PAYLOAD_EXTRACTION) {
|
|
109
|
-
appendResponseHeader(event, "x-nitro-prerender", joinURL(ssrContext.url.replace(/\?.*$/, ""), PAYLOAD_FILENAME));
|
|
110
|
-
await payloadCache.setItem(ssrContext.url.replace(/\/$/, ""), renderPayloadResponse(ssrContext));
|
|
111
|
-
}
|
|
112
|
-
const NO_SCRIPTS = process.env.NUXT_NO_SCRIPTS || routeOptions.noScripts;
|
|
113
|
-
const { styles, scripts } = getRequestDependencies(ssrContext, renderer.rendererContext);
|
|
114
|
-
if (entryFileName && !NO_SCRIPTS) {
|
|
115
|
-
let path = entryPath;
|
|
116
|
-
if (!path) {
|
|
117
|
-
path = buildAssetsURL(entryFileName);
|
|
118
|
-
if (ssrContext.runtimeConfig.app.cdnURL || /^(?:\/|\.+\/)/.test(path)) {
|
|
119
|
-
entryPath = path;
|
|
120
|
-
} else {
|
|
121
|
-
path = relative(event.path.replace(/\/[^/]+$/, "/"), joinURL("/", path));
|
|
122
|
-
if (!/^(?:\/|\.+\/)/.test(path)) {
|
|
123
|
-
path = `./${path}`;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
ssrContext.head.push({
|
|
128
|
-
script: [{
|
|
129
|
-
tagPosition: "head",
|
|
130
|
-
tagPriority: -2,
|
|
131
|
-
type: "importmap",
|
|
132
|
-
innerHTML: JSON.stringify({ imports: { "#entry": path } })
|
|
133
|
-
}]
|
|
134
|
-
}, headEntryOptions);
|
|
135
|
-
}
|
|
136
|
-
if (_PAYLOAD_EXTRACTION && !NO_SCRIPTS) {
|
|
137
|
-
ssrContext.head.push({
|
|
138
|
-
link: [
|
|
139
|
-
process.env.NUXT_JSON_PAYLOADS ? { rel: "preload", as: "fetch", crossorigin: "anonymous", href: payloadURL } : { rel: "modulepreload", crossorigin: "", href: payloadURL }
|
|
140
|
-
]
|
|
141
|
-
}, headEntryOptions);
|
|
142
|
-
}
|
|
143
|
-
if (isAppManifestEnabled && ssrContext._preloadManifest && !NO_SCRIPTS) {
|
|
144
|
-
ssrContext.head.push({
|
|
145
|
-
link: [
|
|
146
|
-
{ rel: "preload", as: "fetch", fetchpriority: "low", crossorigin: "anonymous", href: buildAssetsURL(`builds/meta/${ssrContext.runtimeConfig.app.buildId}.json`) }
|
|
147
|
-
]
|
|
148
|
-
}, { ...headEntryOptions, tagPriority: "low" });
|
|
149
|
-
}
|
|
150
|
-
if (inlinedStyles.length) {
|
|
151
|
-
ssrContext.head.push({ style: inlinedStyles });
|
|
152
|
-
}
|
|
153
|
-
const link = [];
|
|
154
|
-
for (const resource of Object.values(styles)) {
|
|
155
|
-
if (import.meta.dev && "inline" in getURLQuery(resource.file)) {
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
link.push({ rel: "stylesheet", href: renderer.rendererContext.buildAssetsURL(resource.file), crossorigin: "" });
|
|
159
|
-
}
|
|
160
|
-
if (link.length) {
|
|
161
|
-
ssrContext.head.push({ link }, headEntryOptions);
|
|
162
|
-
}
|
|
163
|
-
if (!NO_SCRIPTS) {
|
|
164
|
-
ssrContext.head.push({
|
|
165
|
-
link: getPreloadLinks(ssrContext, renderer.rendererContext)
|
|
166
|
-
}, headEntryOptions);
|
|
167
|
-
ssrContext.head.push({
|
|
168
|
-
link: getPrefetchLinks(ssrContext, renderer.rendererContext)
|
|
169
|
-
}, headEntryOptions);
|
|
170
|
-
ssrContext.head.push({
|
|
171
|
-
script: _PAYLOAD_EXTRACTION ? process.env.NUXT_JSON_PAYLOADS ? renderPayloadJsonScript({ ssrContext, data: splitPayload(ssrContext).initial, src: payloadURL }) : renderPayloadScript({ ssrContext, data: splitPayload(ssrContext).initial, src: payloadURL }) : process.env.NUXT_JSON_PAYLOADS ? renderPayloadJsonScript({ ssrContext, data: ssrContext.payload }) : renderPayloadScript({ ssrContext, data: ssrContext.payload })
|
|
172
|
-
}, {
|
|
173
|
-
...headEntryOptions,
|
|
174
|
-
// this should come before another end of body scripts
|
|
175
|
-
tagPosition: "bodyClose",
|
|
176
|
-
tagPriority: "high"
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
if (!routeOptions.noScripts) {
|
|
180
|
-
const tagPosition = _PAYLOAD_EXTRACTION && !process.env.NUXT_JSON_PAYLOADS ? "bodyClose" : "head";
|
|
181
|
-
ssrContext.head.push({
|
|
182
|
-
script: Object.values(scripts).map((resource) => ({
|
|
183
|
-
type: resource.module ? "module" : null,
|
|
184
|
-
src: renderer.rendererContext.buildAssetsURL(resource.file),
|
|
185
|
-
defer: resource.module ? null : true,
|
|
186
|
-
// if we are rendering script tag payloads that import an async payload
|
|
187
|
-
// we need to ensure this resolves before executing the Nuxt entry
|
|
188
|
-
tagPosition,
|
|
189
|
-
crossorigin: ""
|
|
190
|
-
}))
|
|
191
|
-
}, headEntryOptions);
|
|
192
|
-
}
|
|
193
|
-
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(ssrContext.head, renderSSRHeadOptions);
|
|
194
|
-
const htmlContext = {
|
|
195
|
-
htmlAttrs: htmlAttrs ? [htmlAttrs] : [],
|
|
196
|
-
head: normalizeChunks([headTags]),
|
|
197
|
-
bodyAttrs: bodyAttrs ? [bodyAttrs] : [],
|
|
198
|
-
bodyPrepend: normalizeChunks([bodyTagsOpen, ssrContext.teleports?.body]),
|
|
199
|
-
body: [
|
|
200
|
-
componentIslands ? replaceIslandTeleports(ssrContext, _rendered.html) : _rendered.html,
|
|
201
|
-
APP_TELEPORT_OPEN_TAG + (HAS_APP_TELEPORTS ? joinTags([ssrContext.teleports?.[`#${appTeleportAttrs.id}`]]) : "") + APP_TELEPORT_CLOSE_TAG
|
|
202
|
-
],
|
|
203
|
-
bodyAppend: [bodyTags]
|
|
204
|
-
};
|
|
205
|
-
await nitroApp.hooks.callHook("render:html", htmlContext, { event });
|
|
206
|
-
return {
|
|
207
|
-
body: renderHTMLDocument(htmlContext),
|
|
208
|
-
statusCode: getResponseStatus(event),
|
|
209
|
-
statusMessage: getResponseStatusText(event),
|
|
210
|
-
headers: {
|
|
211
|
-
"content-type": "text/html;charset=utf-8",
|
|
212
|
-
"x-powered-by": "Nuxt"
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
});
|
|
216
|
-
function normalizeChunks(chunks) {
|
|
217
|
-
const result = [];
|
|
218
|
-
for (const _chunk of chunks) {
|
|
219
|
-
const chunk = _chunk?.trim();
|
|
220
|
-
if (chunk) {
|
|
221
|
-
result.push(chunk);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
function joinTags(tags) {
|
|
227
|
-
return tags.join("");
|
|
228
|
-
}
|
|
229
|
-
function joinAttrs(chunks) {
|
|
230
|
-
if (chunks.length === 0) {
|
|
231
|
-
return "";
|
|
232
|
-
}
|
|
233
|
-
return " " + chunks.join(" ");
|
|
234
|
-
}
|
|
235
|
-
function renderHTMLDocument(html) {
|
|
236
|
-
return `<!DOCTYPE html><html${joinAttrs(html.htmlAttrs)}><head>${joinTags(html.head)}</head><body${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body></html>`;
|
|
237
|
-
}
|