vike 0.4.238 → 0.4.239
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/cjs/node/prerender/resolvePrerenderConfig.js +3 -2
- package/dist/cjs/node/runtime/index.js +3 -3
- package/dist/cjs/node/runtime/page-files/setup.js +3 -1
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +2 -9
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/csp.js +47 -0
- package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +1 -1
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/cjs/node/runtime/renderPage/headersResponse.js +48 -0
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +8 -6
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +5 -3
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
- package/dist/cjs/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
- package/dist/cjs/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/stream.js +1 -1
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +17 -38
- package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/node/vite/onLoad.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginCommon.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +4 -3
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +20 -22
- package/dist/cjs/shared/createGlobalContextShared.js +4 -22
- package/dist/cjs/shared/createPageContextShared.js +2 -2
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +62 -43
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +16 -1
- package/dist/cjs/utils/assertNodeVersion.js +3 -1
- package/dist/cjs/utils/assertVersion.js +26 -5
- package/dist/cjs/utils/joinEnglish.js +2 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +39 -16
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +97 -83
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +38 -10
- package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
- package/dist/esm/client/runtime-client-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +43 -28
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +39 -16
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +38 -10
- package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +38 -10
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +1 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -3
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +4 -3
- package/dist/esm/node/prerender/runPrerender.d.ts +57 -14
- package/dist/esm/node/runtime/globalContext.d.ts +152 -40
- package/dist/esm/node/runtime/index.d.ts +3 -3
- package/dist/esm/node/runtime/index.js +3 -3
- package/dist/esm/node/runtime/page-files/setup.js +3 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -9
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +52 -10
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/csp.d.ts +12 -0
- package/dist/esm/node/runtime/renderPage/csp.js +45 -0
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -1
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/esm/node/runtime/renderPage/headersResponse.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/headersResponse.js +46 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
- package/dist/esm/node/runtime/renderPage/html/injectAssets/inferHtmlTags.d.ts +10 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +7 -5
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage/html/injectAssets/mergeScriptTags.d.ts +3 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +6 -4
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
- package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.d.ts +6 -5
- package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
- package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/stream.js +1 -1
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +62 -15
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +18 -39
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +114 -28
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
- package/dist/esm/node/runtime/renderPage.d.ts +52 -10
- package/dist/esm/node/runtime/renderPage.js +1 -1
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/esm/node/vite/plugins/pluginCommon.js +1 -1
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +4 -3
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +4 -8
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +22 -24
- package/dist/esm/shared/createGlobalContextShared.d.ts +73 -17
- package/dist/esm/shared/createGlobalContextShared.js +5 -23
- package/dist/esm/shared/createPageContextShared.d.ts +2 -7
- package/dist/esm/shared/createPageContextShared.js +2 -2
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/execHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +91 -31
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +62 -43
- package/dist/esm/types/Config/ConfigResolved.d.ts +8 -0
- package/dist/esm/types/Config.d.ts +14 -6
- package/dist/esm/types/PageContext.d.ts +8 -25
- package/dist/esm/types/VikeNamespace.d.ts +0 -27
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +16 -1
- package/dist/esm/utils/assertNodeVersion.js +3 -1
- package/dist/esm/utils/assertVersion.d.ts +4 -3
- package/dist/esm/utils/assertVersion.js +23 -5
- package/dist/esm/utils/joinEnglish.js +2 -1
- package/package.json +2 -2
- package/dist/cjs/types/Config/helpers.js +0 -2
- package/dist/esm/node/runtime/html/injectAssets/inferHtmlTags.d.ts +0 -9
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +0 -2
- package/dist/esm/types/Config/PageContextConfig.d.ts +0 -15
- package/dist/esm/types/Config/helpers.d.ts +0 -10
- package/dist/esm/types/Config/helpers.js +0 -1
- /package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
- /package/dist/cjs/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/stream.d.ts +0 -0
- /package/dist/esm/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
|
@@ -4,7 +4,7 @@ export type { PreloadFilter };
|
|
|
4
4
|
export type { InjectFilterEntry };
|
|
5
5
|
import type { PageContextInjectAssets } from '../injectAssets.js';
|
|
6
6
|
import type { StreamFromReactStreamingPackage } from '../stream/react-streaming.js';
|
|
7
|
-
import type { PageAsset } from '../../
|
|
7
|
+
import type { PageAsset } from '../../getPageAssets.js';
|
|
8
8
|
type PreloadFilter = null | ((assets: InjectFilterEntry[]) => InjectFilterEntry[]);
|
|
9
9
|
type PreloadFilterInject = false | 'HTML_BEGIN' | 'HTML_END';
|
|
10
10
|
/** Filter what assets vike injects in the HTML.
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { getHtmlTags };
|
|
2
|
-
import { assert, assertWarning, assertUsage, isObject, freezePartial } from '
|
|
2
|
+
import { assert, assertWarning, assertUsage, isObject, freezePartial } from '../../../utils.js';
|
|
3
3
|
import { getGlobalContextClientSerialized, getPageContextClientSerialized, } from '../serializeContext.js';
|
|
4
4
|
import { sanitizeJson } from './sanitizeJson.js';
|
|
5
5
|
import { inferAssetTag, inferPreloadTag } from './inferHtmlTags.js';
|
|
6
6
|
import { mergeScriptTags } from './mergeScriptTags.js';
|
|
7
|
-
import { getPageConfig } from '
|
|
8
|
-
import { getConfigValueRuntime } from '
|
|
7
|
+
import { getPageConfig } from '../../../../../shared/page-configs/helpers.js';
|
|
8
|
+
import { getConfigValueRuntime } from '../../../../../shared/page-configs/getConfigValueRuntime.js';
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
|
-
import { getConfigDefinedAt } from '
|
|
11
|
-
import { htmlElementId_globalContext, htmlElementId_pageContext } from '
|
|
12
|
-
import { isFontFallback } from '../../
|
|
10
|
+
import { getConfigDefinedAt } from '../../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
11
|
+
import { htmlElementId_globalContext, htmlElementId_pageContext } from '../../../../../shared/htmlElementIds.js';
|
|
12
|
+
import { isFontFallback } from '../../isFontFallback.js';
|
|
13
|
+
import { inferNonceAttr } from '../../csp.js';
|
|
13
14
|
const stamp = '__injectFilterEntry';
|
|
14
15
|
async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript, isStream) {
|
|
15
16
|
assert([true, false].includes(pageContext._isHtmlOnly));
|
|
@@ -76,7 +77,7 @@ async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectF
|
|
|
76
77
|
.forEach((asset) => {
|
|
77
78
|
if (!asset.inject)
|
|
78
79
|
return;
|
|
79
|
-
const htmlTag = asset.isEntry ? inferAssetTag(asset) : inferPreloadTag(asset);
|
|
80
|
+
const htmlTag = asset.isEntry ? inferAssetTag(asset, pageContext) : inferPreloadTag(asset);
|
|
80
81
|
htmlTags.push({ htmlTag, position: asset.inject });
|
|
81
82
|
});
|
|
82
83
|
// ==========
|
|
@@ -137,7 +138,7 @@ async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectF
|
|
|
137
138
|
});
|
|
138
139
|
}
|
|
139
140
|
// The JavaScript entry <script> tag
|
|
140
|
-
const scriptEntry = mergeScriptEntries(pageAssets, viteDevScript);
|
|
141
|
+
const scriptEntry = mergeScriptEntries(pageAssets, viteDevScript, pageContext);
|
|
141
142
|
if (scriptEntry) {
|
|
142
143
|
htmlTags.push({
|
|
143
144
|
htmlTag: scriptEntry,
|
|
@@ -158,9 +159,9 @@ async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectF
|
|
|
158
159
|
});
|
|
159
160
|
return htmlTags;
|
|
160
161
|
}
|
|
161
|
-
function mergeScriptEntries(pageAssets, viteDevScript) {
|
|
162
|
+
function mergeScriptEntries(pageAssets, viteDevScript, pageContext) {
|
|
162
163
|
const scriptEntries = pageAssets.filter((pageAsset) => pageAsset.isEntry && pageAsset.assetType === 'script');
|
|
163
|
-
let scriptEntry = `${viteDevScript}${scriptEntries.map((asset) => inferAssetTag(asset)).join('')}`;
|
|
164
|
+
let scriptEntry = `${viteDevScript}${scriptEntries.map((asset) => inferAssetTag(asset, pageContext)).join('')}`;
|
|
164
165
|
// We merge scripts to avoid the infamous HMR preamble error.
|
|
165
166
|
// - Infamous HMR preamble error:
|
|
166
167
|
// ```browser-console
|
|
@@ -178,12 +179,13 @@ function mergeScriptEntries(pageAssets, viteDevScript) {
|
|
|
178
179
|
// ```
|
|
179
180
|
// - Maybe an alternative would be to make Vike's client runtime entry <script> tag non-async. Would that work? Would it be a performance issue?
|
|
180
181
|
// - The entry <script> shouldn't be `<script defer>` upon HTML streaming, otherwise progressive hydration while SSR streaming won't work.
|
|
181
|
-
scriptEntry = mergeScriptTags(scriptEntry);
|
|
182
|
+
scriptEntry = mergeScriptTags(scriptEntry, pageContext);
|
|
182
183
|
return scriptEntry;
|
|
183
184
|
}
|
|
184
185
|
function getPageContextJsonScriptTag(pageContext) {
|
|
185
186
|
const pageContextClientSerialized = sanitizeJson(getPageContextClientSerialized(pageContext, true));
|
|
186
|
-
const
|
|
187
|
+
const nonceAttr = inferNonceAttr(pageContext);
|
|
188
|
+
const htmlTag = `<script id="${htmlElementId_pageContext}" type="application/json"${nonceAttr}>${pageContextClientSerialized}</script>`;
|
|
187
189
|
// Used by contra.com https://github.com/gajus
|
|
188
190
|
// @ts-expect-error
|
|
189
191
|
pageContext._pageContextHtmlTag = htmlTag;
|
|
@@ -191,7 +193,8 @@ function getPageContextJsonScriptTag(pageContext) {
|
|
|
191
193
|
}
|
|
192
194
|
function getGlobalContextJsonScriptTag(pageContext) {
|
|
193
195
|
const globalContextClientSerialized = sanitizeJson(getGlobalContextClientSerialized(pageContext, true));
|
|
194
|
-
const
|
|
196
|
+
const nonceAttr = inferNonceAttr(pageContext);
|
|
197
|
+
const htmlTag = `<script id="${htmlElementId_globalContext}" type="application/json"${nonceAttr}>${globalContextClientSerialized}</script>`;
|
|
195
198
|
return htmlTag;
|
|
196
199
|
}
|
|
197
200
|
function assertInjectFilterEntries(injectFilterEntries) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getViteDevScript };
|
|
2
|
-
import type { GlobalContextServerInternal } from '
|
|
2
|
+
import type { GlobalContextServerInternal } from '../../../globalContext.js';
|
|
3
3
|
declare function getViteDevScript(pageContext: {
|
|
4
4
|
_globalContext: GlobalContextServerInternal;
|
|
5
5
|
}): Promise<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getViteDevScript };
|
|
2
|
-
import { assert, assertUsage, assertWarning, getViteRPC } from '
|
|
2
|
+
import { assert, assertUsage, assertWarning, getViteRPC } from '../../../utils.js';
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
const reachOutCTA = 'Create a new GitHub issue to discuss a solution.';
|
|
5
5
|
async function getViteDevScript(pageContext) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { inferAssetTag };
|
|
2
|
+
export { inferPreloadTag };
|
|
3
|
+
export { inferEarlyHintLink };
|
|
4
|
+
export { scriptCommonAttrs };
|
|
5
|
+
import type { PageAsset } from '../../getPageAssets.js';
|
|
6
|
+
import { type PageContextCspNonce } from '../../csp.js';
|
|
7
|
+
declare const scriptCommonAttrs = "type=\"module\" async";
|
|
8
|
+
declare function inferPreloadTag(pageAsset: PageAsset): string;
|
|
9
|
+
declare function inferAssetTag(pageAsset: PageAsset, pageContext: PageContextCspNonce): string;
|
|
10
|
+
declare function inferEarlyHintLink(pageAsset: PageAsset): string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { inferAssetTag };
|
|
2
2
|
export { inferPreloadTag };
|
|
3
3
|
export { inferEarlyHintLink };
|
|
4
|
-
export {
|
|
5
|
-
import { assert } from '
|
|
4
|
+
export { scriptCommonAttrs };
|
|
5
|
+
import { assert } from '../../../utils.js';
|
|
6
|
+
import { inferNonceAttr } from '../../csp.js';
|
|
6
7
|
// We can't use `defer` here. With `defer`, the entry script won't start before `</body>` has been parsed, preventing progressive hydration during SSR streaming, see https://github.com/vikejs/vike/pull/1271
|
|
7
|
-
const
|
|
8
|
+
const scriptCommonAttrs = 'type="module" async';
|
|
8
9
|
function inferPreloadTag(pageAsset) {
|
|
9
10
|
const { src, assetType, mediaType } = pageAsset;
|
|
10
11
|
const rel = getRel(pageAsset);
|
|
@@ -20,11 +21,12 @@ function inferPreloadTag(pageAsset) {
|
|
|
20
21
|
.join(' ');
|
|
21
22
|
return `<link ${attributes}>`;
|
|
22
23
|
}
|
|
23
|
-
function inferAssetTag(pageAsset) {
|
|
24
|
+
function inferAssetTag(pageAsset, pageContext) {
|
|
24
25
|
const { src, assetType, mediaType } = pageAsset;
|
|
25
26
|
if (assetType === 'script') {
|
|
26
27
|
assert(mediaType === 'text/javascript');
|
|
27
|
-
|
|
28
|
+
const nonceAttr = inferNonceAttr(pageContext);
|
|
29
|
+
return `<script src="${src}" ${scriptCommonAttrs}${nonceAttr}></script>`;
|
|
28
30
|
}
|
|
29
31
|
if (assetType === 'style') {
|
|
30
32
|
// WARNING: if changing following line, then also update https://github.com/vikejs/vike/blob/fae90a15d88e5e87ca9fcbb54cf2dc8773d2f229/vike/client/shared/removeFoucBuster.ts#L29
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { injectAssets__public };
|
|
2
|
-
import { assertUsage, assertWarning, castProp, hasProp } from '
|
|
2
|
+
import { assertUsage, assertWarning, castProp, hasProp } from '../../../utils.js';
|
|
3
3
|
import { injectHtmlTagsToString } from '../injectAssets.js';
|
|
4
4
|
// TO-DO/next-major-release: remove
|
|
5
5
|
async function injectAssets__public(htmlString, pageContext) {
|
|
@@ -6,7 +6,7 @@ export { joinHtmlTags };
|
|
|
6
6
|
// Only needed for unit tests
|
|
7
7
|
export { injectAtOpeningTag };
|
|
8
8
|
export { injectAtClosingTag };
|
|
9
|
-
import { assert, assertUsage, slice } from '
|
|
9
|
+
import { assert, assertUsage, slice } from '../../../utils.js';
|
|
10
10
|
function injectHtmlTags(htmlString, htmlTags, position) {
|
|
11
11
|
const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === position));
|
|
12
12
|
if (htmlFragment) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { mergeScriptTags };
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { inferNonceAttr } from '../../csp.js';
|
|
3
|
+
import { assert } from '../../../utils.js';
|
|
4
|
+
import { scriptCommonAttrs } from './inferHtmlTags.js';
|
|
4
5
|
const scriptRE = /(<script\b(?:\s[^>]*>|>))(.*?)<\/script>/gims;
|
|
5
6
|
const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
6
7
|
const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
7
|
-
function mergeScriptTags(scriptTagsHtml) {
|
|
8
|
+
function mergeScriptTags(scriptTagsHtml, pageContext) {
|
|
8
9
|
let scriptTag = '';
|
|
9
10
|
const scripts = parseScripts(scriptTagsHtml);
|
|
10
11
|
// We need to merge module scripts to ensure execution order
|
|
@@ -33,7 +34,8 @@ function mergeScriptTags(scriptTagsHtml) {
|
|
|
33
34
|
}
|
|
34
35
|
});
|
|
35
36
|
if (contents.length > 0) {
|
|
36
|
-
|
|
37
|
+
const nonceAttr = inferNonceAttr(pageContext);
|
|
38
|
+
scriptTag += `<script ${scriptCommonAttrs}${nonceAttr}>\n${contents.join('\n')}\n</script>`;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -2,12 +2,12 @@ export { injectHtmlTagsToString };
|
|
|
2
2
|
export { injectHtmlTagsToStream };
|
|
3
3
|
export type { PageContextInjectAssets };
|
|
4
4
|
export type { PageContextPromise };
|
|
5
|
-
import type { PageAsset } from '../
|
|
5
|
+
import type { PageAsset } from '../getPageAssets.js';
|
|
6
6
|
import type { HtmlPart } from './renderHtml.js';
|
|
7
7
|
import { type PreloadFilter } from './injectAssets/getHtmlTags.js';
|
|
8
8
|
import type { StreamFromReactStreamingPackage } from './stream/react-streaming.js';
|
|
9
9
|
import type { PageContextSerialization } from './serializeContext.js';
|
|
10
|
-
import type { GlobalContextServerInternal } from '
|
|
10
|
+
import type { GlobalContextServerInternal } from '../../globalContext.js';
|
|
11
11
|
type PageContextInjectAssets = {
|
|
12
12
|
urlPathname: string;
|
|
13
13
|
__getPageAssets: () => Promise<PageAsset[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { injectHtmlTagsToString };
|
|
2
2
|
export { injectHtmlTagsToStream };
|
|
3
|
-
import { assert, isCallable, isPromise } from '
|
|
4
|
-
import { assertPageContextProvidedByUser } from '
|
|
3
|
+
import { assert, isCallable, isPromise } from '../../utils.js';
|
|
4
|
+
import { assertPageContextProvidedByUser } from '../../../../shared/assertPageContextProvidedByUser.js';
|
|
5
5
|
import { joinHtmlTags, injectHtmlTags, createHtmlHeadIfMissing, injectHtmlTagsUsingStream, } from './injectAssets/injectHtmlTags.js';
|
|
6
6
|
import { getHtmlTags } from './injectAssets/getHtmlTags.js';
|
|
7
7
|
import { getViteDevScript } from './injectAssets/getViteDevScript.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getPropVal };
|
|
2
2
|
export { setPropVal };
|
|
3
3
|
export { getPropKeys };
|
|
4
|
-
import { isObject } from '
|
|
4
|
+
import { isObject } from '../../utils.js';
|
|
5
5
|
// Get a nested property from an object using a dot-separated path such as 'user.id'
|
|
6
6
|
function getPropVal(obj, prop) {
|
|
7
7
|
const keys = getPropKeys(prop);
|
|
@@ -9,7 +9,7 @@ export type { DocumentHtml };
|
|
|
9
9
|
export type { TemplateWrapped };
|
|
10
10
|
import type { PageContextInjectAssets } from './injectAssets.js';
|
|
11
11
|
import { StreamProviderAny, StreamTypePatch, StreamProviderNormalized } from './stream.js';
|
|
12
|
-
import type { PageAsset } from '../
|
|
12
|
+
import type { PageAsset } from '../getPageAssets.js';
|
|
13
13
|
import type { PreloadFilter } from './injectAssets/getHtmlTags.js';
|
|
14
14
|
type DocumentHtml = TemplateWrapped | EscapedString | StreamProviderAny;
|
|
15
15
|
type HtmlRender = string | StreamProviderNormalized;
|
|
@@ -3,7 +3,7 @@ export { dangerouslySkipEscape };
|
|
|
3
3
|
export { renderDocumentHtml };
|
|
4
4
|
export { isDocumentHtml };
|
|
5
5
|
export { getHtmlString };
|
|
6
|
-
import { assert, assertUsage, assertWarning, checkType, escapeHtml, hasProp, isHtml, isPromise, objectAssign, } from '
|
|
6
|
+
import { assert, assertUsage, assertWarning, checkType, escapeHtml, hasProp, isHtml, isPromise, objectAssign, } from '../../utils.js';
|
|
7
7
|
import { injectHtmlTagsToString, injectHtmlTagsToStream } from './injectAssets.js';
|
|
8
8
|
import { processStream, isStream, streamToString, } from './stream.js';
|
|
9
9
|
import { isStreamFromReactStreamingPackage } from './stream/react-streaming.js';
|
|
@@ -4,10 +4,11 @@ export { getGlobalContextClientSerialized };
|
|
|
4
4
|
export type { PageContextSerialization };
|
|
5
5
|
export type { PassToClient };
|
|
6
6
|
export type { PassToClientPublic };
|
|
7
|
-
import type { UrlRedirect } from '
|
|
8
|
-
import type { GlobalContextServerInternal } from '
|
|
9
|
-
import type { PageContextCreated } from '../
|
|
10
|
-
import type { PageContextBegin } from '
|
|
7
|
+
import type { UrlRedirect } from '../../../../shared/route/abort.js';
|
|
8
|
+
import type { GlobalContextServerInternal } from '../../globalContext.js';
|
|
9
|
+
import type { PageContextCreated } from '../createPageContextServerSide.js';
|
|
10
|
+
import type { PageContextBegin } from '../../renderPage.js';
|
|
11
|
+
import type { PageContextCspNonce } from '../csp.js';
|
|
11
12
|
type PageContextSerialization = PageContextCreated & {
|
|
12
13
|
pageId: string;
|
|
13
14
|
routeParams: Record<string, string>;
|
|
@@ -17,7 +18,7 @@ type PageContextSerialization = PageContextCreated & {
|
|
|
17
18
|
_pageContextInit: Record<string, unknown>;
|
|
18
19
|
_globalContext: GlobalContextServerInternal;
|
|
19
20
|
_isPageContextJsonRequest: null | PageContextBegin['_isPageContextJsonRequest'];
|
|
20
|
-
};
|
|
21
|
+
} & PageContextCspNonce;
|
|
21
22
|
declare function getPageContextClientSerialized(pageContext: PageContextSerialization, isHtmlJsonScript: boolean): string;
|
|
22
23
|
declare function getGlobalContextClientSerialized(pageContext: PageContextSerialization, isHtmlJsonScript: boolean): string;
|
|
23
24
|
type PassToClient = string[];
|
|
@@ -2,13 +2,13 @@ export { getPageContextClientSerialized };
|
|
|
2
2
|
export { getPageContextClientSerializedAbort };
|
|
3
3
|
export { getGlobalContextClientSerialized };
|
|
4
4
|
import { stringify, isJsonSerializerError } from '@brillout/json-serializer/stringify';
|
|
5
|
-
import { assert, assertUsage, assertWarning, getPropAccessNotation, hasProp, unique } from '
|
|
6
|
-
import { isErrorPage } from '
|
|
7
|
-
import { addIs404ToPageProps } from '
|
|
5
|
+
import { assert, assertUsage, assertWarning, getPropAccessNotation, hasProp, unique } from '../../utils.js';
|
|
6
|
+
import { isErrorPage } from '../../../../shared/error-page.js';
|
|
7
|
+
import { addIs404ToPageProps } from '../../../../shared/addIs404ToPageProps.js';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
|
-
import { NOT_SERIALIZABLE } from '
|
|
10
|
-
import { pageContextInitIsPassedToClient } from '
|
|
11
|
-
import { isServerSideError } from '
|
|
9
|
+
import { NOT_SERIALIZABLE } from '../../../../shared/NOT_SERIALIZABLE.js';
|
|
10
|
+
import { pageContextInitIsPassedToClient } from '../../../../shared/misc/pageContextInitIsPassedToClient.js';
|
|
11
|
+
import { isServerSideError } from '../../../../shared/misc/isServerSideError.js';
|
|
12
12
|
import { getPropKeys, getPropVal, setPropVal } from './propKeys.js';
|
|
13
13
|
const passToClientBuiltInPageContext = [
|
|
14
14
|
'abortReason',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { isStreamFromReactStreamingPackage };
|
|
3
3
|
export { streamFromReactStreamingPackageToString };
|
|
4
4
|
export { getStreamOfReactStreamingPackage };
|
|
5
|
-
import { assert, assertUsage, hasProp, isVikeReactApp } from '
|
|
5
|
+
import { assert, assertUsage, hasProp, isVikeReactApp } from '../../../utils.js';
|
|
6
6
|
import { streamPipeNodeToString, streamReadableWebToString } from '../stream.js';
|
|
7
7
|
function streamFromReactStreamingPackageToString(stream) {
|
|
8
8
|
if (stream.pipe) {
|
|
@@ -19,7 +19,7 @@ export { streamReadableWebToString };
|
|
|
19
19
|
export { streamPipeNodeToString };
|
|
20
20
|
export { isStreamWritableWeb };
|
|
21
21
|
export { isStreamWritableNode };
|
|
22
|
-
import { assert, assertUsage, checkType, isObject, hasProp, objectAssign, capitalizeFirstLetter, assertWarning, isCallable, createDebugger, isBug, } from '
|
|
22
|
+
import { assert, assertUsage, checkType, isObject, hasProp, objectAssign, capitalizeFirstLetter, assertWarning, isCallable, createDebugger, isBug, } from '../../utils.js';
|
|
23
23
|
import { getStreamOfReactStreamingPackage, isStreamFromReactStreamingPackage, streamFromReactStreamingPackageToString, } from './stream/react-streaming.js';
|
|
24
24
|
import { import_ } from '@brillout/import';
|
|
25
25
|
import pc from '@brillout/picocolors';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { loadPageConfigsLazyServerSide };
|
|
2
2
|
export type { PageContext_loadPageConfigsLazyServerSide };
|
|
3
3
|
export type { PageConfigsLazy };
|
|
4
|
-
|
|
4
|
+
export type { PageContextAfterPageEntryLoaded };
|
|
5
|
+
import { type PageContextConfig } from '../../../shared/getPageFiles.js';
|
|
5
6
|
import { PromiseType } from '../utils.js';
|
|
6
7
|
import { type PageAsset } from './getPageAssets.js';
|
|
7
8
|
import type { PageConfigRuntime } from '../../../types/PageConfig.js';
|
|
8
|
-
import type { PassToClient } from '
|
|
9
|
+
import type { PassToClient } from './html/serializeContext.js';
|
|
9
10
|
import type { PageContextAfterRoute } from '../../../shared/route/index.js';
|
|
10
11
|
import type { PageContextCreated } from './createPageContextServerSide.js';
|
|
11
12
|
type PageContext_loadPageConfigsLazyServerSide = PageContextCreated & PageContextAfterRoute & {
|
|
@@ -24,23 +25,51 @@ declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPage
|
|
|
24
25
|
headers?: Record<string, string>;
|
|
25
26
|
} & {
|
|
26
27
|
_globalContext: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
_globalConfigPublic: {
|
|
29
|
+
pages: {
|
|
30
|
+
[k: string]: {
|
|
31
|
+
config: import("../../../types/index.js").ConfigResolved;
|
|
32
|
+
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
33
|
+
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
34
|
+
_from: import("../../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
35
|
+
} & ({
|
|
36
|
+
route: import("../../../types/Config.js").Route;
|
|
37
|
+
isErrorPage?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
route?: undefined;
|
|
40
|
+
isErrorPage: true;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
35
43
|
config: import("../../../types/index.js").ConfigResolved;
|
|
36
44
|
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
37
45
|
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
38
46
|
_from: import("../../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
39
47
|
};
|
|
40
|
-
config: import("../../../types/index.js").ConfigResolved;
|
|
41
48
|
pages: {
|
|
42
|
-
[k: string]:
|
|
49
|
+
[k: string]: {
|
|
50
|
+
config: import("../../../types/index.js").ConfigResolved;
|
|
51
|
+
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
52
|
+
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
53
|
+
_from: import("../../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
54
|
+
} & ({
|
|
55
|
+
route: import("../../../types/Config.js").Route;
|
|
56
|
+
isErrorPage?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
route?: undefined;
|
|
59
|
+
isErrorPage: true;
|
|
60
|
+
});
|
|
43
61
|
};
|
|
62
|
+
config: import("../../../types/index.js").ConfigResolved;
|
|
63
|
+
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
64
|
+
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
65
|
+
_from: import("../../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
66
|
+
isGlobalContext: true;
|
|
67
|
+
_isOriginalObject: true;
|
|
68
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
69
|
+
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
70
|
+
_pageConfigs: PageConfigRuntime[];
|
|
71
|
+
_pageConfigGlobal: import("../../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
72
|
+
_allPageIds: string[];
|
|
44
73
|
} & (({
|
|
45
74
|
_isProduction: false;
|
|
46
75
|
_isPrerendering: false;
|
|
@@ -92,6 +121,20 @@ declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPage
|
|
|
92
121
|
_urlHandler: ((url: string) => string) | null;
|
|
93
122
|
isClientSideNavigation: boolean;
|
|
94
123
|
} & {
|
|
124
|
+
pages: {
|
|
125
|
+
[k: string]: {
|
|
126
|
+
config: import("../../../types/index.js").ConfigResolved;
|
|
127
|
+
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
128
|
+
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
129
|
+
_from: import("../../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
130
|
+
} & ({
|
|
131
|
+
route: import("../../../types/Config.js").Route;
|
|
132
|
+
isErrorPage?: undefined;
|
|
133
|
+
} | {
|
|
134
|
+
route?: undefined;
|
|
135
|
+
isErrorPage: true;
|
|
136
|
+
});
|
|
137
|
+
};
|
|
95
138
|
config: import("../../../types/index.js").ConfigResolved;
|
|
96
139
|
_source: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
97
140
|
_sources: import("../../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
@@ -107,15 +150,19 @@ declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPage
|
|
|
107
150
|
pageId: string;
|
|
108
151
|
} & {
|
|
109
152
|
_pageConfig: PageConfigRuntime | null;
|
|
110
|
-
} & {
|
|
111
|
-
_pageConfig: null | PageConfigRuntime;
|
|
112
|
-
} & VikeConfigPublicPageLazyLoaded & {
|
|
153
|
+
} & PageContextConfig & {
|
|
113
154
|
_pageConfig: null | PageConfigRuntime;
|
|
155
|
+
} & {
|
|
156
|
+
cspNonce: string | null;
|
|
114
157
|
} & {
|
|
115
158
|
Page: unknown;
|
|
116
159
|
_isHtmlOnly: boolean;
|
|
117
160
|
_passToClient: PassToClient;
|
|
161
|
+
} & {
|
|
118
162
|
headersResponse: Headers;
|
|
119
163
|
} & {
|
|
120
164
|
__getPageAssets: () => Promise<PageAsset[]>;
|
|
121
165
|
}>;
|
|
166
|
+
type PageContextAfterPageEntryLoaded = PageContext_loadPageConfigsLazyServerSide & {
|
|
167
|
+
_pageConfig: null | PageConfigRuntime;
|
|
168
|
+
} & PageContextConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { loadPageConfigsLazyServerSide };
|
|
2
2
|
import { getPageFilesServerSide } from '../../../shared/getPageFiles.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolvePageContextConfig } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
4
4
|
import { analyzePageClientSideInit } from '../../../shared/getPageFiles/analyzePageClientSide.js';
|
|
5
5
|
import { assertUsage, assertWarning, hasProp, isArray, isObject, objectAssign, updateType, } from '../utils.js';
|
|
6
6
|
import { getPageAssets } from './getPageAssets.js';
|
|
@@ -8,13 +8,14 @@ import { findPageConfig } from '../../../shared/page-configs/findPageConfig.js';
|
|
|
8
8
|
import { analyzePage } from './analyzePage.js';
|
|
9
9
|
import { loadAndParseVirtualFilePageEntry } from '../../../shared/page-configs/loadAndParseVirtualFilePageEntry.js';
|
|
10
10
|
import { execHookServer } from './execHookServer.js';
|
|
11
|
-
import {
|
|
11
|
+
import { resolveHeadersResponseEarly } from './headersResponse.js';
|
|
12
|
+
import { resolvePageContextCspNone } from './csp.js';
|
|
12
13
|
async function loadPageConfigsLazyServerSide(pageContext) {
|
|
13
14
|
objectAssign(pageContext, {
|
|
14
15
|
_pageConfig: findPageConfig(pageContext._globalContext._pageConfigs, pageContext.pageId),
|
|
15
16
|
});
|
|
16
17
|
// Load the page's + files
|
|
17
|
-
|
|
18
|
+
objectAssign(pageContext, await loadPageUserFiles(pageContext));
|
|
18
19
|
// Resolve new computed pageContext properties
|
|
19
20
|
updateType(pageContext, await resolvePageContext(pageContext));
|
|
20
21
|
// Execute +onCreatePageContext
|
|
@@ -53,12 +54,13 @@ async function resolvePageContext(pageContext) {
|
|
|
53
54
|
passToClient.push(...valS);
|
|
54
55
|
});
|
|
55
56
|
}
|
|
57
|
+
objectAssign(pageContext, await resolvePageContextCspNone(pageContext));
|
|
56
58
|
objectAssign(pageContext, {
|
|
57
59
|
Page: pageContext.exports.Page,
|
|
58
60
|
_isHtmlOnly: isHtmlOnly,
|
|
59
61
|
_passToClient: passToClient,
|
|
60
|
-
headersResponse: resolveHeadersResponse(pageContext),
|
|
61
62
|
});
|
|
63
|
+
objectAssign(pageContext, await resolveHeadersResponseEarly(pageContext));
|
|
62
64
|
objectAssign(pageContext, {
|
|
63
65
|
__getPageAssets: async () => {
|
|
64
66
|
if ('_pageAssets' in pageContext) {
|
|
@@ -101,43 +103,20 @@ async function resolvePageContext(pageContext) {
|
|
|
101
103
|
return pageContext;
|
|
102
104
|
}
|
|
103
105
|
async function loadPageUserFiles(pageContext) {
|
|
104
|
-
const [{
|
|
105
|
-
|
|
106
|
+
const [{ pageContextAddendum }] = await Promise.all([
|
|
107
|
+
(async () => {
|
|
108
|
+
const pageFilesServerSide = getPageFilesServerSide(pageContext._pageFilesAll, pageContext.pageId);
|
|
109
|
+
const isDev = !pageContext._globalContext._isProduction;
|
|
110
|
+
const pageConfigLoaded = !pageContext._pageConfig
|
|
111
|
+
? null
|
|
112
|
+
: await loadAndParseVirtualFilePageEntry(pageContext._pageConfig, isDev);
|
|
113
|
+
await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
|
|
114
|
+
const pageContextAddendum = resolvePageContextConfig(pageFilesServerSide, pageConfigLoaded, pageContext._globalContext._pageConfigGlobal);
|
|
115
|
+
return { pageContextAddendum };
|
|
116
|
+
})(),
|
|
106
117
|
analyzePageClientSideInit(pageContext._globalContext._pageFilesAll, pageContext.pageId, {
|
|
107
118
|
sharedPageFilesAlreadyLoaded: true,
|
|
108
119
|
}),
|
|
109
120
|
]);
|
|
110
|
-
|
|
111
|
-
return pageContext;
|
|
112
|
-
}
|
|
113
|
-
async function loadPageUserFiles_v1Design(pageContext) {
|
|
114
|
-
const pageFilesServerSide = getPageFilesServerSide(pageContext._pageFilesAll, pageContext.pageId);
|
|
115
|
-
const isDev = !pageContext._globalContext._isProduction;
|
|
116
|
-
const pageConfigLoaded = !pageContext._pageConfig
|
|
117
|
-
? null
|
|
118
|
-
: await loadAndParseVirtualFilePageEntry(pageContext._pageConfig, isDev);
|
|
119
|
-
await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
|
|
120
|
-
const configPublicPageLazy = resolveVikeConfigPublicPageLazyLoaded(pageFilesServerSide, pageConfigLoaded, pageContext._globalContext._pageConfigGlobal);
|
|
121
|
-
return {
|
|
122
|
-
configPublicPageLazy,
|
|
123
|
-
pageFilesLoaded: pageFilesServerSide,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function resolveHeadersResponse(pageContext) {
|
|
127
|
-
const headersResponse = mergeHeaders(pageContext.config.headersResponse);
|
|
128
|
-
if (!headersResponse.get('Cache-Control')) {
|
|
129
|
-
const cacheControl = getCacheControl(pageContext.pageId, pageContext._globalContext._pageConfigs);
|
|
130
|
-
if (cacheControl)
|
|
131
|
-
headersResponse.set('Cache-Control', cacheControl);
|
|
132
|
-
}
|
|
133
|
-
return headersResponse;
|
|
134
|
-
}
|
|
135
|
-
function mergeHeaders(headersList = []) {
|
|
136
|
-
const headersMerged = new Headers();
|
|
137
|
-
headersList.forEach((headers) => {
|
|
138
|
-
new Headers(headers).forEach((value, key) => {
|
|
139
|
-
headersMerged.append(key, value);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
return headersMerged;
|
|
121
|
+
return pageContextAddendum;
|
|
143
122
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { preparePageContextForPublicUsageServer };
|
|
2
2
|
export type { PageContextForPublicUsageServer };
|
|
3
3
|
import type { PageContextUrlInternal } from '../../../shared/getPageContextUrlComputed.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PageContextConfig } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
5
5
|
import type { PageContextInternalServer } from '../../../types/PageContext.js';
|
|
6
6
|
import type { GlobalContextServerInternal } from '../globalContext.js';
|
|
7
|
-
type PageContextForPublicUsageServer = PageContextInternalServer &
|
|
7
|
+
type PageContextForPublicUsageServer = PageContextInternalServer & PageContextConfig & {
|
|
8
8
|
urlOriginal: string;
|
|
9
9
|
/** @deprecated */
|
|
10
10
|
url: string;
|