nuxt-nightly 4.2.0-29338985.3c38d1f8 → 4.2.0-29344151.f836eca0
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 +29 -769
- 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
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRenderer
|
|
3
|
-
} from "vue-bundle-renderer/runtime";
|
|
4
|
-
import { renderToString as _renderToString } from "vue/server-renderer";
|
|
5
|
-
import { propsToString } from "@unhead/vue/server";
|
|
6
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
7
|
-
import { appRootAttrs, appRootTag, appSpaLoaderAttrs, appSpaLoaderTag, spaLoadingTemplateOutside } from "#internal/nuxt.config.mjs";
|
|
8
|
-
import { buildAssetsURL } from "#internal/nuxt/paths";
|
|
9
|
-
const APP_ROOT_OPEN_TAG = `<${appRootTag}${propsToString(appRootAttrs)}>`;
|
|
10
|
-
const APP_ROOT_CLOSE_TAG = `</${appRootTag}>`;
|
|
11
|
-
const getServerEntry = () => import("#build/dist/server/server.mjs").then((r) => r.default || r);
|
|
12
|
-
const getClientManifest = () => import("#build/dist/server/client.manifest.mjs").then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
|
|
13
|
-
const getPrecomputedDependencies = () => import("#build/dist/server/client.precomputed.mjs").then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
|
|
14
|
-
export const getSSRRenderer = lazyCachedFunction(async () => {
|
|
15
|
-
const createSSRApp = await getServerEntry();
|
|
16
|
-
if (!createSSRApp) {
|
|
17
|
-
throw new Error("Server bundle is not available");
|
|
18
|
-
}
|
|
19
|
-
const precomputed = import.meta.dev ? void 0 : await getPrecomputedDependencies();
|
|
20
|
-
const renderer = createRenderer(createSSRApp, {
|
|
21
|
-
precomputed,
|
|
22
|
-
manifest: import.meta.dev ? await getClientManifest() : void 0,
|
|
23
|
-
renderToString,
|
|
24
|
-
buildAssetsURL
|
|
25
|
-
});
|
|
26
|
-
async function renderToString(input, context) {
|
|
27
|
-
const html = await _renderToString(input, context);
|
|
28
|
-
if (import.meta.dev && process.env.NUXT_VITE_NODE_OPTIONS) {
|
|
29
|
-
renderer.rendererContext.updateManifest(await getClientManifest());
|
|
30
|
-
}
|
|
31
|
-
return APP_ROOT_OPEN_TAG + html + APP_ROOT_CLOSE_TAG;
|
|
32
|
-
}
|
|
33
|
-
return renderer;
|
|
34
|
-
});
|
|
35
|
-
const getSPARenderer = lazyCachedFunction(async () => {
|
|
36
|
-
const precomputed = import.meta.dev ? void 0 : await getPrecomputedDependencies();
|
|
37
|
-
const spaTemplate = await import("#spa-template").then((r) => r.template).catch(() => "").then((r) => {
|
|
38
|
-
if (spaLoadingTemplateOutside) {
|
|
39
|
-
const APP_SPA_LOADER_OPEN_TAG = `<${appSpaLoaderTag}${propsToString(appSpaLoaderAttrs)}>`;
|
|
40
|
-
const APP_SPA_LOADER_CLOSE_TAG = `</${appSpaLoaderTag}>`;
|
|
41
|
-
const appTemplate = APP_ROOT_OPEN_TAG + APP_ROOT_CLOSE_TAG;
|
|
42
|
-
const loaderTemplate = r ? APP_SPA_LOADER_OPEN_TAG + r + APP_SPA_LOADER_CLOSE_TAG : "";
|
|
43
|
-
return appTemplate + loaderTemplate;
|
|
44
|
-
} else {
|
|
45
|
-
return APP_ROOT_OPEN_TAG + r + APP_ROOT_CLOSE_TAG;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const renderer = createRenderer(() => () => {
|
|
49
|
-
}, {
|
|
50
|
-
precomputed,
|
|
51
|
-
manifest: import.meta.dev ? await getClientManifest() : void 0,
|
|
52
|
-
renderToString: () => spaTemplate,
|
|
53
|
-
buildAssetsURL
|
|
54
|
-
});
|
|
55
|
-
const result = await renderer.renderToString({});
|
|
56
|
-
const renderToString = (ssrContext) => {
|
|
57
|
-
const config = useRuntimeConfig(ssrContext.event);
|
|
58
|
-
ssrContext.modules ||= /* @__PURE__ */ new Set();
|
|
59
|
-
ssrContext.payload.serverRendered = false;
|
|
60
|
-
ssrContext.config = {
|
|
61
|
-
public: config.public,
|
|
62
|
-
app: config.app
|
|
63
|
-
};
|
|
64
|
-
return Promise.resolve(result);
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
rendererContext: renderer.rendererContext,
|
|
68
|
-
renderToString
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
function lazyCachedFunction(fn) {
|
|
72
|
-
let res = null;
|
|
73
|
-
return () => {
|
|
74
|
-
if (res === null) {
|
|
75
|
-
res = fn().catch((err) => {
|
|
76
|
-
res = null;
|
|
77
|
-
throw err;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
return res;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
export function getRenderer(ssrContext) {
|
|
84
|
-
return process.env.NUXT_NO_SSR || ssrContext.noSSR ? getSPARenderer() : getSSRRenderer();
|
|
85
|
-
}
|
|
86
|
-
export const getSSRStyles = lazyCachedFunction(() => import("#build/dist/server/styles.mjs").then((r) => r.default || r));
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getSSRStyles } from "./build-files.js";
|
|
2
|
-
export async function renderInlineStyles(usedModules) {
|
|
3
|
-
const styleMap = await getSSRStyles();
|
|
4
|
-
const inlinedStyles = /* @__PURE__ */ new Set();
|
|
5
|
-
for (const mod of usedModules) {
|
|
6
|
-
if (mod in styleMap && styleMap[mod]) {
|
|
7
|
-
for (const style of await styleMap[mod]()) {
|
|
8
|
-
inlinedStyles.add(style);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return Array.from(inlinedStyles).map((style) => ({ innerHTML: style }));
|
|
13
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { SerializableHead } from '@unhead/vue/types';
|
|
2
|
-
import type { NuxtSSRContext } from '#app/nuxt';
|
|
3
|
-
/**
|
|
4
|
-
* remove the root node from the html body
|
|
5
|
-
*/
|
|
6
|
-
export declare function getServerComponentHTML(body: string): string;
|
|
7
|
-
export declare function getSlotIslandResponse(ssrContext: NuxtSSRContext): NuxtIslandResponse['slots'];
|
|
8
|
-
export declare function getClientIslandResponse(ssrContext: NuxtSSRContext): NuxtIslandResponse['components'];
|
|
9
|
-
export declare function getComponentSlotTeleport(clientUid: string, teleports: Record<string, string>): Record<string, string>;
|
|
10
|
-
export declare function replaceIslandTeleports(ssrContext: NuxtSSRContext, html: string): string;
|
|
11
|
-
export interface NuxtIslandSlotResponse {
|
|
12
|
-
props: Array<unknown>;
|
|
13
|
-
fallback?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface NuxtIslandContext {
|
|
16
|
-
id?: string;
|
|
17
|
-
name: string;
|
|
18
|
-
props?: Record<string, any>;
|
|
19
|
-
url: string;
|
|
20
|
-
slots: Record<string, Omit<NuxtIslandSlotResponse, 'html' | 'fallback'>>;
|
|
21
|
-
components: Record<string, Omit<NuxtIslandClientResponse, 'html'>>;
|
|
22
|
-
}
|
|
23
|
-
export interface NuxtIslandResponse {
|
|
24
|
-
id?: string;
|
|
25
|
-
html: string;
|
|
26
|
-
head: SerializableHead;
|
|
27
|
-
props?: Record<string, Record<string, any>>;
|
|
28
|
-
components?: Record<string, NuxtIslandClientResponse>;
|
|
29
|
-
slots?: Record<string, NuxtIslandSlotResponse>;
|
|
30
|
-
}
|
|
31
|
-
export interface NuxtIslandClientResponse {
|
|
32
|
-
html: string;
|
|
33
|
-
props: unknown;
|
|
34
|
-
chunk: string;
|
|
35
|
-
slots?: Record<string, string>;
|
|
36
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { appRootTag } from "#internal/nuxt.config.mjs";
|
|
2
|
-
const ROOT_NODE_REGEX = new RegExp(`^<${appRootTag}[^>]*>([\\s\\S]*)<\\/${appRootTag}>$`);
|
|
3
|
-
export function getServerComponentHTML(body) {
|
|
4
|
-
const match = body.match(ROOT_NODE_REGEX);
|
|
5
|
-
return match?.[1] || body;
|
|
6
|
-
}
|
|
7
|
-
const SSR_SLOT_TELEPORT_MARKER = /^uid=([^;]*);slot=(.*)$/;
|
|
8
|
-
const SSR_CLIENT_TELEPORT_MARKER = /^uid=([^;]*);client=(.*)$/;
|
|
9
|
-
const SSR_CLIENT_SLOT_MARKER = /^island-slot=([^;]*);(.*)$/;
|
|
10
|
-
export function getSlotIslandResponse(ssrContext) {
|
|
11
|
-
if (!ssrContext.islandContext || !Object.keys(ssrContext.islandContext.slots).length) {
|
|
12
|
-
return void 0;
|
|
13
|
-
}
|
|
14
|
-
const response = {};
|
|
15
|
-
for (const [name, slot] of Object.entries(ssrContext.islandContext.slots)) {
|
|
16
|
-
response[name] = {
|
|
17
|
-
...slot,
|
|
18
|
-
fallback: ssrContext.teleports?.[`island-fallback=${name}`]
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return response;
|
|
22
|
-
}
|
|
23
|
-
export function getClientIslandResponse(ssrContext) {
|
|
24
|
-
if (!ssrContext.islandContext || !Object.keys(ssrContext.islandContext.components).length) {
|
|
25
|
-
return void 0;
|
|
26
|
-
}
|
|
27
|
-
const response = {};
|
|
28
|
-
for (const [clientUid, component] of Object.entries(ssrContext.islandContext.components)) {
|
|
29
|
-
const html = ssrContext.teleports?.[clientUid]?.replaceAll("<!--teleport start anchor-->", "") || "";
|
|
30
|
-
response[clientUid] = {
|
|
31
|
-
...component,
|
|
32
|
-
html,
|
|
33
|
-
slots: getComponentSlotTeleport(clientUid, ssrContext.teleports ?? {})
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return response;
|
|
37
|
-
}
|
|
38
|
-
export function getComponentSlotTeleport(clientUid, teleports) {
|
|
39
|
-
const entries = Object.entries(teleports);
|
|
40
|
-
const slots = {};
|
|
41
|
-
for (const [key, value] of entries) {
|
|
42
|
-
const match = key.match(SSR_CLIENT_SLOT_MARKER);
|
|
43
|
-
if (match) {
|
|
44
|
-
const [, id, slot] = match;
|
|
45
|
-
if (!slot || clientUid !== id) {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
slots[slot] = value;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return slots;
|
|
52
|
-
}
|
|
53
|
-
export function replaceIslandTeleports(ssrContext, html) {
|
|
54
|
-
const { teleports, islandContext } = ssrContext;
|
|
55
|
-
if (islandContext || !teleports) {
|
|
56
|
-
return html;
|
|
57
|
-
}
|
|
58
|
-
for (const key in teleports) {
|
|
59
|
-
const matchClientComp = key.match(SSR_CLIENT_TELEPORT_MARKER);
|
|
60
|
-
if (matchClientComp) {
|
|
61
|
-
const [, uid, clientId] = matchClientComp;
|
|
62
|
-
if (!uid || !clientId) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
html = html.replace(new RegExp(` data-island-uid="${uid}" data-island-component="${clientId}"[^>]*>`), (full) => {
|
|
66
|
-
return full + teleports[key];
|
|
67
|
-
});
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const matchSlot = key.match(SSR_SLOT_TELEPORT_MARKER);
|
|
71
|
-
if (matchSlot) {
|
|
72
|
-
const [, uid, slot] = matchSlot;
|
|
73
|
-
if (!uid || !slot) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
html = html.replace(new RegExp(` data-island-uid="${uid}" data-island-slot="${slot}"[^>]*>`), (full) => {
|
|
77
|
-
return full + teleports[key];
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return html;
|
|
82
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Script } from '@unhead/vue';
|
|
2
|
-
import type { NuxtSSRContext } from 'nuxt/app';
|
|
3
|
-
export declare function renderPayloadResponse(ssrContext: NuxtSSRContext): {
|
|
4
|
-
body: string;
|
|
5
|
-
statusCode: number;
|
|
6
|
-
statusMessage: string;
|
|
7
|
-
headers: {
|
|
8
|
-
'content-type': string;
|
|
9
|
-
'x-powered-by': string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export declare function renderPayloadJsonScript(opts: {
|
|
13
|
-
ssrContext: NuxtSSRContext;
|
|
14
|
-
data?: any;
|
|
15
|
-
src?: string;
|
|
16
|
-
}): Script[];
|
|
17
|
-
export declare function renderPayloadScript(opts: {
|
|
18
|
-
ssrContext: NuxtSSRContext;
|
|
19
|
-
data?: any;
|
|
20
|
-
src?: string;
|
|
21
|
-
}): Script[];
|
|
22
|
-
export declare function splitPayload(ssrContext: NuxtSSRContext): {
|
|
23
|
-
initial: {
|
|
24
|
-
prerenderedAt: number | undefined;
|
|
25
|
-
path?: string | undefined;
|
|
26
|
-
serverRendered?: boolean | undefined;
|
|
27
|
-
state?: Record<string, any> | undefined;
|
|
28
|
-
once?: Set<string> | undefined;
|
|
29
|
-
config?: Pick<import("@nuxt/schema").RuntimeConfig, "public" | "app"> | undefined;
|
|
30
|
-
error?: import("nuxt/app").NuxtError<unknown> | undefined;
|
|
31
|
-
_errors?: Record<string, import("nuxt/app").NuxtError<unknown> | undefined> | undefined;
|
|
32
|
-
};
|
|
33
|
-
payload: {
|
|
34
|
-
data: Record<string, any> | undefined;
|
|
35
|
-
prerenderedAt: number | undefined;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { getResponseStatus, getResponseStatusText } from "h3";
|
|
2
|
-
import devalue from "@nuxt/devalue";
|
|
3
|
-
import { stringify, uneval } from "devalue";
|
|
4
|
-
import { appId, multiApp } from "#internal/nuxt.config.mjs";
|
|
5
|
-
export function renderPayloadResponse(ssrContext) {
|
|
6
|
-
return {
|
|
7
|
-
body: process.env.NUXT_JSON_PAYLOADS ? stringify(splitPayload(ssrContext).payload, ssrContext._payloadReducers) : `export default ${devalue(splitPayload(ssrContext).payload)}`,
|
|
8
|
-
statusCode: getResponseStatus(ssrContext.event),
|
|
9
|
-
statusMessage: getResponseStatusText(ssrContext.event),
|
|
10
|
-
headers: {
|
|
11
|
-
"content-type": process.env.NUXT_JSON_PAYLOADS ? "application/json;charset=utf-8" : "text/javascript;charset=utf-8",
|
|
12
|
-
"x-powered-by": "Nuxt"
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function renderPayloadJsonScript(opts) {
|
|
17
|
-
const contents = opts.data ? stringify(opts.data, opts.ssrContext._payloadReducers) : "";
|
|
18
|
-
const payload = {
|
|
19
|
-
"type": "application/json",
|
|
20
|
-
"innerHTML": contents,
|
|
21
|
-
"data-nuxt-data": appId,
|
|
22
|
-
"data-ssr": !(process.env.NUXT_NO_SSR || opts.ssrContext.noSSR)
|
|
23
|
-
};
|
|
24
|
-
if (!multiApp) {
|
|
25
|
-
payload.id = "__NUXT_DATA__";
|
|
26
|
-
}
|
|
27
|
-
if (opts.src) {
|
|
28
|
-
payload["data-src"] = opts.src;
|
|
29
|
-
}
|
|
30
|
-
const config = uneval(opts.ssrContext.config);
|
|
31
|
-
return [
|
|
32
|
-
payload,
|
|
33
|
-
{
|
|
34
|
-
innerHTML: multiApp ? `window.__NUXT__=window.__NUXT__||{};window.__NUXT__[${JSON.stringify(appId)}]={config:${config}}` : `window.__NUXT__={};window.__NUXT__.config=${config}`
|
|
35
|
-
}
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
export function renderPayloadScript(opts) {
|
|
39
|
-
opts.data.config = opts.ssrContext.config;
|
|
40
|
-
const _PAYLOAD_EXTRACTION = import.meta.prerender && process.env.NUXT_PAYLOAD_EXTRACTION && !opts.ssrContext.noSSR;
|
|
41
|
-
const nuxtData = devalue(opts.data);
|
|
42
|
-
if (_PAYLOAD_EXTRACTION) {
|
|
43
|
-
const singleAppPayload2 = `import p from "${opts.src}";window.__NUXT__={...p,...(${nuxtData})}`;
|
|
44
|
-
const multiAppPayload2 = `import p from "${opts.src}";window.__NUXT__=window.__NUXT__||{};window.__NUXT__[${JSON.stringify(appId)}]={...p,...(${nuxtData})}`;
|
|
45
|
-
return [
|
|
46
|
-
{
|
|
47
|
-
type: "module",
|
|
48
|
-
innerHTML: multiApp ? multiAppPayload2 : singleAppPayload2
|
|
49
|
-
}
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
const singleAppPayload = `window.__NUXT__=${nuxtData}`;
|
|
53
|
-
const multiAppPayload = `window.__NUXT__=window.__NUXT__||{};window.__NUXT__[${JSON.stringify(appId)}]=${nuxtData}`;
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
innerHTML: multiApp ? multiAppPayload : singleAppPayload
|
|
57
|
-
}
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
export function splitPayload(ssrContext) {
|
|
61
|
-
const { data, prerenderedAt, ...initial } = ssrContext.payload;
|
|
62
|
-
return {
|
|
63
|
-
initial: { ...initial, prerenderedAt },
|
|
64
|
-
payload: { data, prerenderedAt }
|
|
65
|
-
};
|
|
66
|
-
}
|