vinext 0.0.39 → 0.0.41
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/README.md +1 -1
- package/dist/build/standalone.js +7 -0
- package/dist/build/standalone.js.map +1 -1
- package/dist/check.js +2 -2
- package/dist/check.js.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +185 -264
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +205 -199
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +81 -6
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +2 -2
- package/dist/init.js.map +1 -1
- package/dist/plugins/fonts.js +1 -0
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/server-externals-manifest.d.ts +11 -1
- package/dist/plugins/server-externals-manifest.js +10 -3
- package/dist/plugins/server-externals-manifest.js.map +1 -1
- package/dist/routing/app-router.d.ts +10 -2
- package/dist/routing/app-router.js +37 -22
- package/dist/routing/app-router.js.map +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +1 -0
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-render.d.ts +1 -0
- package/dist/server/app-page-render.js +2 -0
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-response.d.ts +4 -1
- package/dist/server/app-page-response.js +14 -8
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +79 -0
- package/dist/server/app-page-route-wiring.js +167 -0
- package/dist/server/app-page-route-wiring.js.map +1 -0
- package/dist/server/app-page-stream.d.ts +4 -1
- package/dist/server/app-page-stream.js +5 -1
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-response.js +6 -2
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.d.ts +6 -1
- package/dist/server/app-router-entry.js +9 -2
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +3 -1
- package/dist/server/app-ssr-entry.js +17 -17
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +4 -4
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/csp.d.ts +12 -0
- package/dist/server/csp.js +46 -0
- package/dist/server/csp.js.map +1 -0
- package/dist/server/dev-server.js +20 -14
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/html.d.ts +4 -1
- package/dist/server/html.js +11 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/middleware-response-headers.d.ts +12 -0
- package/dist/server/middleware-response-headers.js +23 -0
- package/dist/server/middleware-response-headers.js.map +1 -0
- package/dist/server/pages-page-data.d.ts +1 -0
- package/dist/server/pages-page-data.js +2 -2
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +2 -1
- package/dist/server/pages-page-response.js +16 -14
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +41 -14
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +14 -1
- package/dist/server/request-pipeline.js +55 -1
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/worker-utils.d.ts +4 -1
- package/dist/server/worker-utils.js +31 -1
- package/dist/server/worker-utils.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +14 -5
- package/dist/shims/error-boundary.js +23 -3
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/navigation.d.ts +16 -1
- package/dist/shims/navigation.js +18 -3
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.js +127 -38
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script-nonce-context.d.ts +12 -0
- package/dist/shims/script-nonce-context.js +17 -0
- package/dist/shims/script-nonce-context.js.map +1 -0
- package/dist/shims/script.js +41 -10
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +17 -4
- package/dist/shims/server.js +97 -74
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +28 -0
- package/dist/shims/slot.js +49 -0
- package/dist/shims/slot.js.map +1 -0
- package/dist/shims/url-safety.js +25 -4
- package/dist/shims/url-safety.js.map +1 -1
- package/package.json +7 -8
|
@@ -21,6 +21,7 @@ const _pagesPageDataPath = resolveEntryPath("../server/pages-page-data.js", impo
|
|
|
21
21
|
const _pagesNodeCompatPath = resolveEntryPath("../server/pages-node-compat.js", import.meta.url);
|
|
22
22
|
const _pagesApiRoutePath = resolveEntryPath("../server/pages-api-route.js", import.meta.url);
|
|
23
23
|
const _isrCachePath = resolveEntryPath("../server/isr-cache.js", import.meta.url);
|
|
24
|
+
const _cspPath = resolveEntryPath("../server/csp.js", import.meta.url);
|
|
24
25
|
/**
|
|
25
26
|
* Generate the virtual SSR server entry module.
|
|
26
27
|
* This is the entry point for `vite build --ssr`.
|
|
@@ -204,7 +205,7 @@ import { runWithServerInsertedHTMLState } from "vinext/navigation-state";
|
|
|
204
205
|
import { runWithHeadState } from "vinext/head-state";
|
|
205
206
|
import "vinext/i18n-state";
|
|
206
207
|
import { setI18nContext } from "vinext/i18n-context";
|
|
207
|
-
import { safeJsonStringify } from "vinext/html";
|
|
208
|
+
import { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from "vinext/html";
|
|
208
209
|
import { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from "next/font/google";
|
|
209
210
|
import { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from "next/font/local";
|
|
210
211
|
import { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath("../config/config-matchers.js", import.meta.url))};
|
|
@@ -220,6 +221,7 @@ import {
|
|
|
220
221
|
isrCacheKey as __sharedIsrCacheKey,
|
|
221
222
|
triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,
|
|
222
223
|
} from ${JSON.stringify(_isrCachePath)};
|
|
224
|
+
import { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};
|
|
223
225
|
import { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};
|
|
224
226
|
import { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};
|
|
225
227
|
${instrumentationImportCode}
|
|
@@ -318,13 +320,14 @@ function patternToNextFormat(pattern) {
|
|
|
318
320
|
.replace(/:([\\w]+)/g, "[$1]");
|
|
319
321
|
}
|
|
320
322
|
|
|
321
|
-
function collectAssetTags(manifest, moduleIds) {
|
|
323
|
+
function collectAssetTags(manifest, moduleIds, scriptNonce) {
|
|
322
324
|
// Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)
|
|
323
325
|
const m = (manifest && Object.keys(manifest).length > 0)
|
|
324
326
|
? manifest
|
|
325
327
|
: (typeof globalThis !== "undefined" && globalThis.__VINEXT_SSR_MANIFEST__) || null;
|
|
326
328
|
const tags = [];
|
|
327
329
|
const seen = new Set();
|
|
330
|
+
const nonceAttr = __createNonceAttribute(scriptNonce);
|
|
328
331
|
|
|
329
332
|
// Load the set of lazy chunk filenames (only reachable via dynamic imports).
|
|
330
333
|
// These should NOT get <link rel="modulepreload"> or <script type="module">
|
|
@@ -337,8 +340,8 @@ function collectAssetTags(manifest, moduleIds) {
|
|
|
337
340
|
if (typeof globalThis !== "undefined" && globalThis.__VINEXT_CLIENT_ENTRY__) {
|
|
338
341
|
const entry = globalThis.__VINEXT_CLIENT_ENTRY__;
|
|
339
342
|
seen.add(entry);
|
|
340
|
-
tags.push('<link rel="modulepreload" href="/' + entry + '" />');
|
|
341
|
-
tags.push('<script type="module" src="/' + entry + '" crossorigin><\/script>');
|
|
343
|
+
tags.push('<link rel="modulepreload"' + nonceAttr + ' href="/' + entry + '" />');
|
|
344
|
+
tags.push('<script type="module"' + nonceAttr + ' src="/' + entry + '" crossorigin><\/script>');
|
|
342
345
|
}
|
|
343
346
|
if (m) {
|
|
344
347
|
// Always inject shared chunks (framework, vinext runtime, entry) and
|
|
@@ -413,13 +416,13 @@ function collectAssetTags(manifest, moduleIds) {
|
|
|
413
416
|
if (seen.has(tf)) continue;
|
|
414
417
|
seen.add(tf);
|
|
415
418
|
if (tf.endsWith(".css")) {
|
|
416
|
-
tags.push('<link rel="stylesheet" href="/' + tf + '" />');
|
|
419
|
+
tags.push('<link rel="stylesheet"' + nonceAttr + ' href="/' + tf + '" />');
|
|
417
420
|
} else if (tf.endsWith(".js")) {
|
|
418
421
|
// Skip lazy chunks — they are behind dynamic import() boundaries
|
|
419
422
|
// (React.lazy, next/dynamic) and should only be fetched on demand.
|
|
420
423
|
if (lazySet && lazySet.has(tf)) continue;
|
|
421
|
-
tags.push('<link rel="modulepreload" href="/' + tf + '" />');
|
|
422
|
-
tags.push('<script type="module" src="/' + tf + '" crossorigin><\/script>');
|
|
424
|
+
tags.push('<link rel="modulepreload"' + nonceAttr + ' href="/' + tf + '" />');
|
|
425
|
+
tags.push('<script type="module"' + nonceAttr + ' src="/' + tf + '" crossorigin><\/script>');
|
|
423
426
|
}
|
|
424
427
|
}
|
|
425
428
|
}
|
|
@@ -473,12 +476,12 @@ function parseCookieLocaleFromHeader(cookieHeader) {
|
|
|
473
476
|
return null;
|
|
474
477
|
}
|
|
475
478
|
|
|
476
|
-
export async function renderPage(request, url, manifest, ctx) {
|
|
477
|
-
if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest));
|
|
478
|
-
return _renderPage(request, url, manifest);
|
|
479
|
+
export async function renderPage(request, url, manifest, ctx, middlewareHeaders) {
|
|
480
|
+
if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders));
|
|
481
|
+
return _renderPage(request, url, manifest, middlewareHeaders);
|
|
479
482
|
}
|
|
480
483
|
|
|
481
|
-
async function _renderPage(request, url, manifest) {
|
|
484
|
+
async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
482
485
|
const localeInfo = i18nConfig
|
|
483
486
|
? resolvePagesI18nRequest(
|
|
484
487
|
url,
|
|
@@ -506,198 +509,201 @@ async function _renderPage(request, url, manifest) {
|
|
|
506
509
|
{ status: 404, headers: { "Content-Type": "text/html" } });
|
|
507
510
|
}
|
|
508
511
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
512
|
+
const { route, params } = match;
|
|
513
|
+
const __uCtx = _createUnifiedCtx({
|
|
514
|
+
executionContext: _getRequestExecutionContext(),
|
|
515
|
+
});
|
|
516
|
+
return _runWithUnifiedCtx(__uCtx, async () => {
|
|
517
|
+
ensureFetchPatch();
|
|
518
|
+
try {
|
|
519
|
+
const routePattern = patternToNextFormat(route.pattern);
|
|
520
|
+
if (typeof setSSRContext === "function") {
|
|
521
|
+
setSSRContext({
|
|
522
|
+
pathname: routePattern,
|
|
523
|
+
query: { ...params, ...parseQuery(routeUrl) },
|
|
524
|
+
asPath: routeUrl,
|
|
525
|
+
locale: locale,
|
|
526
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
527
|
+
defaultLocale: currentDefaultLocale,
|
|
528
|
+
domainLocales: domainLocales,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
528
531
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
532
|
+
if (i18nConfig) {
|
|
533
|
+
setI18nContext({
|
|
534
|
+
locale: locale,
|
|
535
|
+
locales: i18nConfig.locales,
|
|
536
|
+
defaultLocale: currentDefaultLocale,
|
|
537
|
+
domainLocales: domainLocales,
|
|
538
|
+
hostname: new URL(request.url).hostname,
|
|
539
|
+
});
|
|
540
|
+
}
|
|
538
541
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
} catch (e) { /* font preloads not available */ }
|
|
556
|
-
const query = parseQuery(routeUrl);
|
|
557
|
-
const pageDataResult = await __resolvePagesPageData({
|
|
558
|
-
applyRequestContexts() {
|
|
559
|
-
if (typeof setSSRContext === "function") {
|
|
560
|
-
setSSRContext({
|
|
561
|
-
pathname: routePattern,
|
|
562
|
-
query: { ...params, ...query },
|
|
563
|
-
asPath: routeUrl,
|
|
564
|
-
locale: locale,
|
|
565
|
-
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
566
|
-
defaultLocale: currentDefaultLocale,
|
|
567
|
-
domainLocales: domainLocales,
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
if (i18nConfig) {
|
|
571
|
-
setI18nContext({
|
|
572
|
-
locale: locale,
|
|
573
|
-
locales: i18nConfig.locales,
|
|
574
|
-
defaultLocale: currentDefaultLocale,
|
|
575
|
-
domainLocales: domainLocales,
|
|
576
|
-
hostname: new URL(request.url).hostname,
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
buildId,
|
|
581
|
-
createGsspReqRes() {
|
|
582
|
-
return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });
|
|
583
|
-
},
|
|
584
|
-
createPageElement(currentPageProps) {
|
|
585
|
-
var currentElement = AppComponent
|
|
586
|
-
? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })
|
|
587
|
-
: React.createElement(PageComponent, currentPageProps);
|
|
588
|
-
return wrapWithRouterContext(currentElement);
|
|
589
|
-
},
|
|
590
|
-
fontLinkHeader: _fontLinkHeader,
|
|
591
|
-
i18n: {
|
|
592
|
-
locale: locale,
|
|
593
|
-
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
594
|
-
defaultLocale: currentDefaultLocale,
|
|
595
|
-
domainLocales: domainLocales,
|
|
596
|
-
},
|
|
597
|
-
isrCacheKey,
|
|
598
|
-
isrGet,
|
|
599
|
-
isrSet,
|
|
600
|
-
pageModule,
|
|
601
|
-
params,
|
|
602
|
-
query,
|
|
603
|
-
renderIsrPassToStringAsync,
|
|
604
|
-
route: {
|
|
605
|
-
isDynamic: route.isDynamic,
|
|
606
|
-
},
|
|
607
|
-
routePattern,
|
|
608
|
-
routeUrl,
|
|
609
|
-
runInFreshUnifiedContext(callback) {
|
|
610
|
-
var revalCtx = _createUnifiedCtx({
|
|
611
|
-
executionContext: _getRequestExecutionContext(),
|
|
612
|
-
});
|
|
613
|
-
return _runWithUnifiedCtx(revalCtx, async () => {
|
|
614
|
-
ensureFetchPatch();
|
|
615
|
-
return callback();
|
|
616
|
-
});
|
|
617
|
-
},
|
|
618
|
-
safeJsonStringify,
|
|
619
|
-
sanitizeDestination: sanitizeDestinationLocal,
|
|
620
|
-
triggerBackgroundRegeneration,
|
|
621
|
-
});
|
|
622
|
-
if (pageDataResult.kind === "response") {
|
|
623
|
-
return pageDataResult.response;
|
|
624
|
-
}
|
|
625
|
-
let pageProps = pageDataResult.pageProps;
|
|
626
|
-
var gsspRes = pageDataResult.gsspRes;
|
|
627
|
-
let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;
|
|
628
|
-
|
|
629
|
-
const pageModuleIds = route.filePath ? [route.filePath] : [];
|
|
630
|
-
const assetTags = collectAssetTags(manifest, pageModuleIds);
|
|
631
|
-
|
|
632
|
-
return __renderPagesPageResponse({
|
|
633
|
-
assetTags,
|
|
634
|
-
buildId,
|
|
635
|
-
clearSsrContext() {
|
|
636
|
-
if (typeof setSSRContext === "function") setSSRContext(null);
|
|
637
|
-
},
|
|
638
|
-
createPageElement(currentPageProps) {
|
|
639
|
-
var currentElement;
|
|
640
|
-
if (AppComponent) {
|
|
641
|
-
currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });
|
|
642
|
-
} else {
|
|
643
|
-
currentElement = React.createElement(PageComponent, currentPageProps);
|
|
644
|
-
}
|
|
645
|
-
return wrapWithRouterContext(currentElement);
|
|
646
|
-
},
|
|
647
|
-
DocumentComponent,
|
|
648
|
-
flushPreloads: typeof flushPreloads === "function" ? flushPreloads : undefined,
|
|
649
|
-
fontLinkHeader: _fontLinkHeader,
|
|
650
|
-
fontPreloads: _allFp,
|
|
651
|
-
getFontLinks() {
|
|
652
|
-
try {
|
|
653
|
-
return typeof _getSSRFontLinks === "function" ? _getSSRFontLinks() : [];
|
|
654
|
-
} catch (e) {
|
|
655
|
-
return [];
|
|
656
|
-
}
|
|
657
|
-
},
|
|
658
|
-
getFontStyles() {
|
|
659
|
-
try {
|
|
660
|
-
var allFontStyles = [];
|
|
661
|
-
if (typeof _getSSRFontStylesGoogle === "function") allFontStyles.push(..._getSSRFontStylesGoogle());
|
|
662
|
-
if (typeof _getSSRFontStylesLocal === "function") allFontStyles.push(..._getSSRFontStylesLocal());
|
|
663
|
-
return allFontStyles;
|
|
664
|
-
} catch (e) {
|
|
665
|
-
return [];
|
|
542
|
+
const pageModule = route.module;
|
|
543
|
+
const PageComponent = pageModule.default;
|
|
544
|
+
if (!PageComponent) {
|
|
545
|
+
return new Response("Page has no default export", { status: 500 });
|
|
546
|
+
}
|
|
547
|
+
const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);
|
|
548
|
+
// Build font Link header early so it's available for ISR cached responses too.
|
|
549
|
+
// Font preloads are module-level state populated at import time and persist across requests.
|
|
550
|
+
var _fontLinkHeader = "";
|
|
551
|
+
var _allFp = [];
|
|
552
|
+
try {
|
|
553
|
+
var _fpGoogle = typeof _getSSRFontPreloadsGoogle === "function" ? _getSSRFontPreloadsGoogle() : [];
|
|
554
|
+
var _fpLocal = typeof _getSSRFontPreloadsLocal === "function" ? _getSSRFontPreloadsLocal() : [];
|
|
555
|
+
_allFp = _fpGoogle.concat(_fpLocal);
|
|
556
|
+
if (_allFp.length > 0) {
|
|
557
|
+
_fontLinkHeader = _allFp.map(function(p) { return "<" + p.href + ">; rel=preload; as=font; type=" + p.type + "; crossorigin"; }).join(", ");
|
|
666
558
|
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
559
|
+
} catch (e) { /* font preloads not available */ }
|
|
560
|
+
const query = parseQuery(routeUrl);
|
|
561
|
+
const pageDataResult = await __resolvePagesPageData({
|
|
562
|
+
applyRequestContexts() {
|
|
563
|
+
if (typeof setSSRContext === "function") {
|
|
564
|
+
setSSRContext({
|
|
565
|
+
pathname: routePattern,
|
|
566
|
+
query: { ...params, ...query },
|
|
567
|
+
asPath: routeUrl,
|
|
568
|
+
locale: locale,
|
|
569
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
570
|
+
defaultLocale: currentDefaultLocale,
|
|
571
|
+
domainLocales: domainLocales,
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
if (i18nConfig) {
|
|
575
|
+
setI18nContext({
|
|
576
|
+
locale: locale,
|
|
577
|
+
locales: i18nConfig.locales,
|
|
578
|
+
defaultLocale: currentDefaultLocale,
|
|
579
|
+
domainLocales: domainLocales,
|
|
580
|
+
hostname: new URL(request.url).hostname,
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
buildId,
|
|
585
|
+
createGsspReqRes() {
|
|
586
|
+
return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });
|
|
587
|
+
},
|
|
588
|
+
createPageElement(currentPageProps) {
|
|
589
|
+
var currentElement = AppComponent
|
|
590
|
+
? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })
|
|
591
|
+
: React.createElement(PageComponent, currentPageProps);
|
|
592
|
+
return wrapWithRouterContext(currentElement);
|
|
593
|
+
},
|
|
594
|
+
fontLinkHeader: _fontLinkHeader,
|
|
595
|
+
i18n: {
|
|
596
|
+
locale: locale,
|
|
597
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
598
|
+
defaultLocale: currentDefaultLocale,
|
|
599
|
+
domainLocales: domainLocales,
|
|
600
|
+
},
|
|
601
|
+
isrCacheKey,
|
|
602
|
+
isrGet,
|
|
603
|
+
isrSet,
|
|
604
|
+
pageModule,
|
|
605
|
+
params,
|
|
606
|
+
query,
|
|
607
|
+
renderIsrPassToStringAsync,
|
|
608
|
+
route: {
|
|
609
|
+
isDynamic: route.isDynamic,
|
|
610
|
+
},
|
|
611
|
+
routePattern,
|
|
612
|
+
routeUrl,
|
|
613
|
+
runInFreshUnifiedContext(callback) {
|
|
614
|
+
var revalCtx = _createUnifiedCtx({
|
|
615
|
+
executionContext: _getRequestExecutionContext(),
|
|
616
|
+
});
|
|
617
|
+
return _runWithUnifiedCtx(revalCtx, async () => {
|
|
618
|
+
ensureFetchPatch();
|
|
619
|
+
return callback();
|
|
620
|
+
});
|
|
621
|
+
},
|
|
622
|
+
safeJsonStringify,
|
|
623
|
+
sanitizeDestination: sanitizeDestinationLocal,
|
|
624
|
+
scriptNonce,
|
|
625
|
+
triggerBackgroundRegeneration,
|
|
626
|
+
});
|
|
627
|
+
if (pageDataResult.kind === "response") {
|
|
628
|
+
return pageDataResult.response;
|
|
629
|
+
}
|
|
630
|
+
let pageProps = pageDataResult.pageProps;
|
|
631
|
+
var gsspRes = pageDataResult.gsspRes;
|
|
632
|
+
let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;
|
|
633
|
+
|
|
634
|
+
const pageModuleIds = route.filePath ? [route.filePath] : [];
|
|
635
|
+
const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);
|
|
636
|
+
|
|
637
|
+
return __renderPagesPageResponse({
|
|
638
|
+
assetTags,
|
|
639
|
+
buildId,
|
|
640
|
+
clearSsrContext() {
|
|
641
|
+
if (typeof setSSRContext === "function") setSSRContext(null);
|
|
642
|
+
},
|
|
643
|
+
createPageElement(currentPageProps) {
|
|
644
|
+
var currentElement;
|
|
645
|
+
if (AppComponent) {
|
|
646
|
+
currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });
|
|
647
|
+
} else {
|
|
648
|
+
currentElement = React.createElement(PageComponent, currentPageProps);
|
|
649
|
+
}
|
|
650
|
+
return wrapWithRouterContext(currentElement);
|
|
651
|
+
},
|
|
652
|
+
DocumentComponent,
|
|
653
|
+
flushPreloads: typeof flushPreloads === "function" ? flushPreloads : undefined,
|
|
654
|
+
fontLinkHeader: _fontLinkHeader,
|
|
655
|
+
fontPreloads: _allFp,
|
|
656
|
+
getFontLinks() {
|
|
657
|
+
try {
|
|
658
|
+
return typeof _getSSRFontLinks === "function" ? _getSSRFontLinks() : [];
|
|
659
|
+
} catch (e) {
|
|
660
|
+
return [];
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
getFontStyles() {
|
|
664
|
+
try {
|
|
665
|
+
var allFontStyles = [];
|
|
666
|
+
if (typeof _getSSRFontStylesGoogle === "function") allFontStyles.push(..._getSSRFontStylesGoogle());
|
|
667
|
+
if (typeof _getSSRFontStylesLocal === "function") allFontStyles.push(..._getSSRFontStylesLocal());
|
|
668
|
+
return allFontStyles;
|
|
669
|
+
} catch (e) {
|
|
670
|
+
return [];
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
getSSRHeadHTML: typeof getSSRHeadHTML === "function" ? getSSRHeadHTML : undefined,
|
|
674
|
+
gsspRes,
|
|
675
|
+
isrCacheKey,
|
|
676
|
+
isrRevalidateSeconds,
|
|
677
|
+
isrSet,
|
|
678
|
+
i18n: {
|
|
679
|
+
locale: locale,
|
|
680
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
681
|
+
defaultLocale: currentDefaultLocale,
|
|
682
|
+
domainLocales: domainLocales,
|
|
683
|
+
},
|
|
684
|
+
pageProps,
|
|
685
|
+
params,
|
|
686
|
+
renderDocumentToString(element) {
|
|
687
|
+
return renderToStringAsync(element);
|
|
688
|
+
},
|
|
689
|
+
renderIsrPassToStringAsync,
|
|
690
|
+
renderToReadableStream(element) {
|
|
691
|
+
return renderToReadableStream(element);
|
|
692
|
+
},
|
|
693
|
+
resetSSRHead: typeof resetSSRHead === "function" ? resetSSRHead : undefined,
|
|
694
|
+
routePattern,
|
|
695
|
+
routeUrl,
|
|
696
|
+
safeJsonStringify,
|
|
697
|
+
scriptNonce,
|
|
698
|
+
});
|
|
693
699
|
} catch (e) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
700
|
+
console.error("[vinext] SSR error:", e);
|
|
701
|
+
_reportRequestError(
|
|
702
|
+
e instanceof Error ? e : new Error(String(e)),
|
|
703
|
+
{ path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },
|
|
704
|
+
{ routerKind: "Pages Router", routePath: route.pattern, routeType: "render" },
|
|
705
|
+
).catch(() => { /* ignore reporting errors */ });
|
|
706
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
701
707
|
}
|
|
702
708
|
});
|
|
703
709
|
}
|