vike 0.4.238 → 0.4.239-commit-050a4a3
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/globalContext.js +1 -0
- 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/pluginBaseUrls.js +32 -28
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/cjs/node/vite/plugins/pluginCommon.js +7 -21
- package/dist/cjs/node/vite/plugins/pluginDev.js +51 -47
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +63 -57
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +101 -91
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +24 -16
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +67 -57
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +26 -19
- package/dist/cjs/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +41 -33
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +50 -37
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- 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 +154 -40
- package/dist/esm/node/runtime/globalContext.js +1 -0
- 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/pluginBaseUrls.js +32 -28
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/esm/node/vite/plugins/pluginCommon.js +8 -22
- package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +63 -57
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +101 -91
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +24 -16
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +67 -57
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +26 -19
- package/dist/esm/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +41 -33
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +51 -38
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- 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
|
@@ -19,32 +19,38 @@ function pluginPreview() {
|
|
|
19
19
|
return {
|
|
20
20
|
name: 'vike:pluginPreview',
|
|
21
21
|
apply: utils_js_1.applyPreview,
|
|
22
|
-
config
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
config: {
|
|
23
|
+
handler() {
|
|
24
|
+
return {
|
|
25
|
+
appType: 'custom',
|
|
26
|
+
};
|
|
27
|
+
},
|
|
26
28
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
configResolved: {
|
|
30
|
+
async handler(config_) {
|
|
31
|
+
config = config_;
|
|
32
|
+
vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
|
|
33
|
+
(0, pluginDev_js_1.logDockerHint)(config.preview.host);
|
|
34
|
+
// vikeConfig = await getVikeConfig(config)
|
|
35
|
+
},
|
|
32
36
|
},
|
|
33
|
-
configurePreviewServer
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
configurePreviewServer: {
|
|
38
|
+
handler(server) {
|
|
39
|
+
/* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
|
|
40
|
+
- This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
|
|
41
|
+
config.appType = 'mpa'
|
|
42
|
+
*/
|
|
43
|
+
return () => {
|
|
44
|
+
const { isPrerenderingEnabledForAllPages, isPrerenderingEnabled } = vikeConfig.prerenderContext;
|
|
45
|
+
assertDist(isPrerenderingEnabledForAllPages);
|
|
46
|
+
// We cannot re-use Vite's static middleware: https://github.com/vitejs/vite/pull/14836#issuecomment-1788540300
|
|
47
|
+
addStaticAssetsMiddleware(server.middlewares);
|
|
48
|
+
if (!isPrerenderingEnabledForAllPages) {
|
|
49
|
+
(0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares, config, true, isPrerenderingEnabled);
|
|
50
|
+
}
|
|
51
|
+
addStatic404Middleware(server.middlewares);
|
|
52
|
+
};
|
|
53
|
+
},
|
|
48
54
|
},
|
|
49
55
|
};
|
|
50
56
|
function assertDist(isPrerenderingEnabledForAllPages) {
|
|
@@ -11,41 +11,49 @@ function pluginReplaceConstants() {
|
|
|
11
11
|
name: 'vike:pluginReplaceConstants',
|
|
12
12
|
enforce: 'post',
|
|
13
13
|
apply: 'build',
|
|
14
|
-
configResolved
|
|
15
|
-
|
|
14
|
+
configResolved: {
|
|
15
|
+
handler(config_) {
|
|
16
|
+
config = config_;
|
|
17
|
+
},
|
|
16
18
|
},
|
|
17
|
-
transform
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(0, utils_js_1.assertPosixPath)(config.root);
|
|
23
|
-
if (!id.startsWith(config.root))
|
|
24
|
-
return;
|
|
25
|
-
if (!code.includes('({}).'))
|
|
26
|
-
return;
|
|
27
|
-
const isBuild = config.command === 'build';
|
|
28
|
-
(0, utils_js_1.assert)(isBuild);
|
|
29
|
-
// Used by vike.dev
|
|
30
|
-
// https://github.com/vikejs/vike/blob/08a1ff55c80ddca64ca6d4417fefd45fefeb4ffb/docs/vite.config.ts#L12
|
|
31
|
-
// @ts-expect-error
|
|
32
|
-
if (config._skipVikeReplaceConstants?.(id))
|
|
33
|
-
return;
|
|
34
|
-
const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
|
|
35
|
-
const constantsMap = [];
|
|
36
|
-
constantsMap.push({
|
|
37
|
-
constants: ['pageContext.isClientSide', 'globalContext.isClientSide', 'pageContext.globalContext.isClientSide'],
|
|
38
|
-
replacement: !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options),
|
|
39
|
-
});
|
|
40
|
-
constantsMap.forEach(({ constants, replacement }) => {
|
|
41
|
-
if (!constants.some((c) => code.includes(c)))
|
|
19
|
+
transform: {
|
|
20
|
+
handler(code, id, options) {
|
|
21
|
+
id = (0, normalizeId_js_1.normalizeId)(id);
|
|
22
|
+
(0, utils_js_1.assertPosixPath)(id);
|
|
23
|
+
if (id.includes('/node_modules/'))
|
|
42
24
|
return;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
(0, utils_js_1.assertPosixPath)(config.root);
|
|
26
|
+
if (!id.startsWith(config.root))
|
|
27
|
+
return;
|
|
28
|
+
if (!code.includes('({}).'))
|
|
29
|
+
return;
|
|
30
|
+
const isBuild = config.command === 'build';
|
|
31
|
+
(0, utils_js_1.assert)(isBuild);
|
|
32
|
+
// Used by vike.dev
|
|
33
|
+
// https://github.com/vikejs/vike/blob/08a1ff55c80ddca64ca6d4417fefd45fefeb4ffb/docs/vite.config.ts#L12
|
|
34
|
+
// @ts-expect-error
|
|
35
|
+
if (config._skipVikeReplaceConstants?.(id))
|
|
36
|
+
return;
|
|
37
|
+
const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
|
|
38
|
+
const constantsMap = [];
|
|
39
|
+
constantsMap.push({
|
|
40
|
+
constants: [
|
|
41
|
+
'pageContext.isClientSide',
|
|
42
|
+
'globalContext.isClientSide',
|
|
43
|
+
'pageContext.globalContext.isClientSide',
|
|
44
|
+
],
|
|
45
|
+
replacement: !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options),
|
|
46
|
+
});
|
|
47
|
+
constantsMap.forEach(({ constants, replacement }) => {
|
|
48
|
+
if (!constants.some((c) => code.includes(c)))
|
|
49
|
+
return;
|
|
50
|
+
const regExp = getConstantRegExp(constants);
|
|
51
|
+
magicString.replaceAll(regExp, JSON.stringify(replacement));
|
|
52
|
+
});
|
|
53
|
+
if (!magicString.hasChanged())
|
|
54
|
+
return null;
|
|
55
|
+
return getMagicStringResult();
|
|
56
|
+
},
|
|
49
57
|
},
|
|
50
58
|
};
|
|
51
59
|
}
|
|
@@ -22,8 +22,10 @@ function pluginSetGlobalContext() {
|
|
|
22
22
|
(0, utils_js_1.markSetup_viteDevServer)();
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
-
configurePreviewServer
|
|
26
|
-
(
|
|
25
|
+
configurePreviewServer: {
|
|
26
|
+
handler() {
|
|
27
|
+
(0, utils_js_1.markSetup_vitePreviewServer)();
|
|
28
|
+
},
|
|
27
29
|
},
|
|
28
30
|
config: {
|
|
29
31
|
order: 'pre',
|
package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -144,7 +144,7 @@ function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
|
|
|
144
144
|
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
145
145
|
const globOptions = { eager: isEager };
|
|
146
146
|
if (query) {
|
|
147
|
-
const isNewViteInterface = (0, utils_js_1.
|
|
147
|
+
const isNewViteInterface = (0, utils_js_1.isVersionMatch)(vite_1.version, ['5.1.0']);
|
|
148
148
|
if (isNewViteInterface &&
|
|
149
149
|
// When used for the old design, the new syntax breaks Vike's CI (surprinsigly so). I couldn't reproduce locally (I didn't dig much).
|
|
150
150
|
isV1Design) {
|
|
@@ -21,47 +21,57 @@ function pluginVirtualFiles() {
|
|
|
21
21
|
let config;
|
|
22
22
|
return {
|
|
23
23
|
name: 'vike:pluginVirtualFiles',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
configResolved: {
|
|
25
|
+
async handler(config_) {
|
|
26
|
+
config = config_;
|
|
27
|
+
// TO-DO/next-major-release: remove
|
|
28
|
+
if (!(0, resolveVikeConfigInternal_js_1.isV1Design)())
|
|
29
|
+
config.experimental.importGlobRestoreExtension = true;
|
|
30
|
+
},
|
|
29
31
|
},
|
|
30
|
-
resolveId
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
return await handleHotUpdate(ctx, config);
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
// Vite swallows errors thrown by handleHotUpdate()
|
|
41
|
-
console.error(err);
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
32
|
+
resolveId: {
|
|
33
|
+
handler(id) {
|
|
34
|
+
if ((0, utils_js_1.isVirtualFileId)(id)) {
|
|
35
|
+
return (0, utils_js_1.addVirtualFileIdPrefix)(id);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
44
38
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const isDev = config._isDev;
|
|
50
|
-
(0, utils_js_1.assert)(typeof isDev === 'boolean');
|
|
51
|
-
const idParsed = (0, virtualFileId_js_1.parseVirtualFileId)(id);
|
|
52
|
-
if (idParsed) {
|
|
53
|
-
if (idParsed.type === 'page-entry') {
|
|
54
|
-
const code = await (0, generateVirtualFilePageEntry_js_1.generateVirtualFilePageEntry)(id, isDev);
|
|
55
|
-
return code;
|
|
39
|
+
handleHotUpdate: {
|
|
40
|
+
async handler(ctx) {
|
|
41
|
+
try {
|
|
42
|
+
return await handleHotUpdate(ctx, config);
|
|
56
43
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
catch (err) {
|
|
45
|
+
// Vite swallows errors thrown by handleHotUpdate()
|
|
46
|
+
console.error(err);
|
|
47
|
+
throw err;
|
|
60
48
|
}
|
|
61
|
-
}
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
load: {
|
|
52
|
+
async handler(id, options) {
|
|
53
|
+
if (!(0, utils_js_1.isVirtualFileId)(id))
|
|
54
|
+
return undefined;
|
|
55
|
+
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
56
|
+
const isDev = config._isDev;
|
|
57
|
+
(0, utils_js_1.assert)(typeof isDev === 'boolean');
|
|
58
|
+
const idParsed = (0, virtualFileId_js_1.parseVirtualFileId)(id);
|
|
59
|
+
if (idParsed) {
|
|
60
|
+
if (idParsed.type === 'page-entry') {
|
|
61
|
+
const code = await (0, generateVirtualFilePageEntry_js_1.generateVirtualFilePageEntry)(id, isDev);
|
|
62
|
+
return code;
|
|
63
|
+
}
|
|
64
|
+
if (idParsed.type === 'global-entry') {
|
|
65
|
+
const code = await (0, generateVirtualFileGlobalEntryWithOldDesign_js_1.generateVirtualFileGlobalEntryWithOldDesign)(id, options, config, this.environment, isDev);
|
|
66
|
+
return code;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
62
70
|
},
|
|
63
|
-
configureServer
|
|
64
|
-
|
|
71
|
+
configureServer: {
|
|
72
|
+
handler(server) {
|
|
73
|
+
handleFileAddRemove(server, config);
|
|
74
|
+
},
|
|
65
75
|
},
|
|
66
76
|
};
|
|
67
77
|
}
|
|
@@ -130,7 +140,10 @@ async function handleHotUpdate(ctx, config) {
|
|
|
130
140
|
// Ensure we invalidate `file` *before* server.ssrLoadModule() in updateUserFiles()
|
|
131
141
|
// Vite already invalidates it, but *after* handleHotUpdate() and thus after server.ssrLoadModule()
|
|
132
142
|
ctx.modules.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
133
|
-
(0, globalContext_js_1.
|
|
143
|
+
if ((0, globalContext_js_1.isRunnable)(server)) {
|
|
144
|
+
// TODO/now: await
|
|
145
|
+
(0, globalContext_js_1.updateUserFiles)();
|
|
146
|
+
}
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
}
|
|
@@ -4,12 +4,14 @@ exports.pluginWorkaroundCssModuleHmr = pluginWorkaroundCssModuleHmr;
|
|
|
4
4
|
function pluginWorkaroundCssModuleHmr() {
|
|
5
5
|
return {
|
|
6
6
|
name: 'vike:pluginWorkaroundCssModuleHmr',
|
|
7
|
-
handleHotUpdate
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
handleHotUpdate: {
|
|
8
|
+
handler(ctx) {
|
|
9
|
+
// prevent full reload due to non self-accepting css module.
|
|
10
|
+
// here only "?direct" module should be filtered out as it doesn't have a parent module.
|
|
11
|
+
if (ctx.file.includes('module.css')) {
|
|
12
|
+
return ctx.modules.filter((m) => !m.id?.includes('?direct'));
|
|
13
|
+
}
|
|
14
|
+
},
|
|
13
15
|
},
|
|
14
16
|
};
|
|
15
17
|
}
|
|
@@ -152,7 +152,7 @@ async function isGitNotUsable(userRootDir) {
|
|
|
152
152
|
// - We didn't bother test which is the earliest version that works.
|
|
153
153
|
// - Git 2.32.0 doesn't seem to work: https://github.com/vikejs/vike/discussions/1549
|
|
154
154
|
// - Maybe it's because of StackBlitz: looking at the release notes, Git 2.32.0 should be working.
|
|
155
|
-
if (!(0, utils_js_1.
|
|
155
|
+
if (!(0, utils_js_1.isVersionMatch)(gitVersion, ['2.43.1']))
|
|
156
156
|
return true;
|
|
157
157
|
}
|
|
158
158
|
// Is userRootDir inside a Git repository?
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getVikeConfig = getVikeConfig;
|
|
6
7
|
exports.getVikeConfigInternal = getVikeConfigInternal;
|
|
7
8
|
exports.getVikeConfigInternalOptional = getVikeConfigInternalOptional;
|
|
8
9
|
exports.getVikeConfigInternalSync = getVikeConfigInternalSync;
|
|
@@ -12,7 +13,6 @@ exports.isV1Design = isV1Design;
|
|
|
12
13
|
exports.getConfVal = getConfVal;
|
|
13
14
|
exports.getConfigDefinitionOptional = getConfigDefinitionOptional;
|
|
14
15
|
exports.getVikeConfigFromCliOrEnv = getVikeConfigFromCliOrEnv;
|
|
15
|
-
exports.getVikeConfig = getVikeConfig;
|
|
16
16
|
const utils_js_1 = require("../utils.js");
|
|
17
17
|
const configDefinitionsBuiltIn_js_1 = require("./resolveVikeConfigInternal/configDefinitionsBuiltIn.js");
|
|
18
18
|
const filesystemRouting_js_1 = require("./resolveVikeConfigInternal/filesystemRouting.js");
|
|
@@ -173,31 +173,26 @@ async function resolveVikeConfigInternal(userRootDir, vikeVitePluginOptions, esb
|
|
|
173
173
|
// Backwards compatibility for vike(options) in vite.config.js
|
|
174
174
|
temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
|
|
175
175
|
setCliAndApiOptions(pageConfigGlobal, configDefinitionsResolved);
|
|
176
|
-
|
|
177
|
-
const pageConfigGlobalValues = getConfigValues(pageConfigGlobal);
|
|
178
|
-
const vikeConfigPublicGlobal = (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicGlobal)({ pageConfigGlobalValues });
|
|
179
|
-
// pages
|
|
180
|
-
const vikeConfigPublicPagesEager = (0, utils_js_1.objectFromEntries)(pageConfigs.map((pageConfig) => {
|
|
181
|
-
const pageConfigValues = getConfigValues(pageConfig, true);
|
|
182
|
-
return (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicPageEagerLoaded)(pageConfigGlobalValues, pageConfig, pageConfigValues);
|
|
183
|
-
}));
|
|
176
|
+
const globalConfigPublic = resolveGlobalConfig(pageConfigGlobal, pageConfigs);
|
|
184
177
|
const prerenderContext = resolvePrerenderContext({
|
|
185
|
-
config:
|
|
186
|
-
_from:
|
|
178
|
+
config: globalConfigPublic.config,
|
|
179
|
+
_from: globalConfigPublic._from,
|
|
187
180
|
_pageConfigs: pageConfigs,
|
|
188
181
|
});
|
|
189
182
|
const vikeConfig = {
|
|
183
|
+
...globalConfigPublic,
|
|
184
|
+
prerenderContext,
|
|
190
185
|
_pageConfigs: pageConfigs,
|
|
191
186
|
_pageConfigGlobal: pageConfigGlobal,
|
|
192
|
-
config: vikeConfigPublicGlobal.config,
|
|
193
|
-
_from: vikeConfigPublicGlobal._from,
|
|
194
|
-
pages: vikeConfigPublicPagesEager,
|
|
195
|
-
prerenderContext,
|
|
196
187
|
_vikeConfigDependencies: esbuildCache.vikeConfigDependencies,
|
|
197
188
|
};
|
|
198
189
|
globalObject.vikeConfigSync = vikeConfig;
|
|
199
190
|
return vikeConfig;
|
|
200
191
|
}
|
|
192
|
+
function resolveGlobalConfig(pageConfigGlobal, pageConfigs) {
|
|
193
|
+
const globalConfigPublic = (0, resolveVikeConfigPublic_js_1.resolveGlobalConfigPublic)(pageConfigs, pageConfigGlobal, getConfigValues);
|
|
194
|
+
return globalConfigPublic;
|
|
195
|
+
}
|
|
201
196
|
async function resolveConfigDefinitions(plusFilesAll, userRootDir, esbuildCache) {
|
|
202
197
|
const plusFilesAllOrdered = Object.values(plusFilesAll)
|
|
203
198
|
.flat()
|
|
@@ -361,7 +356,8 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
361
356
|
// When using Server Routing, loading a onBeforeRender() hook on the client-side hasn't any effect (the Server Routing's client runtime never calls it); it unnecessarily bloats client bundle sizes
|
|
362
357
|
(0, utils_js_1.assertUsage)(!(onBeforeRenderEnv.client && !isClientRouting), `Page ${pageConfig.pageId} has an onBeforeRender() hook with env ${picocolors_1.default.cyan(JSON.stringify(onBeforeRenderEnv))} which doesn't make sense because the page is using Server Routing: onBeforeRender() can be run in the client only when using Client Routing.`);
|
|
363
358
|
}
|
|
364
|
-
function getConfigValues(pageConfig,
|
|
359
|
+
function getConfigValues(pageConfig, isGlobalConfig) {
|
|
360
|
+
const tolerateMissingValue = !isGlobalConfig;
|
|
365
361
|
const configValues = {};
|
|
366
362
|
(0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig, { isForConfig: true }, null).forEach((entry) => {
|
|
367
363
|
if (entry.configValueBase.type === 'computed') {
|
|
@@ -1128,11 +1124,15 @@ function restartViteDevServer() {
|
|
|
1128
1124
|
(0, removeSuperfluousViteLog_js_1.removeSuperfluousViteLog_disable)();
|
|
1129
1125
|
}
|
|
1130
1126
|
function getVikeConfigDummy(esbuildCache) {
|
|
1131
|
-
const globalDummy = (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicGlobal)({ pageConfigGlobalValues: {} });
|
|
1132
1127
|
const pageConfigsDummy = [];
|
|
1128
|
+
const pageConfigGlobalDummy = {
|
|
1129
|
+
configValueSources: {},
|
|
1130
|
+
configDefinitions: {},
|
|
1131
|
+
};
|
|
1132
|
+
const globalConfigPublicDummy = resolveGlobalConfig(pageConfigGlobalDummy, pageConfigsDummy);
|
|
1133
1133
|
const prerenderContextDummy = resolvePrerenderContext({
|
|
1134
|
-
config:
|
|
1135
|
-
_from:
|
|
1134
|
+
config: globalConfigPublicDummy.config,
|
|
1135
|
+
_from: globalConfigPublicDummy._from,
|
|
1136
1136
|
_pageConfigs: pageConfigsDummy,
|
|
1137
1137
|
});
|
|
1138
1138
|
const vikeConfigDummy = {
|
|
@@ -1141,9 +1141,7 @@ function getVikeConfigDummy(esbuildCache) {
|
|
|
1141
1141
|
configDefinitions: {},
|
|
1142
1142
|
configValueSources: {},
|
|
1143
1143
|
},
|
|
1144
|
-
|
|
1145
|
-
_from: globalDummy._from,
|
|
1146
|
-
pages: {},
|
|
1144
|
+
...globalConfigPublicDummy,
|
|
1147
1145
|
prerenderContext: prerenderContextDummy,
|
|
1148
1146
|
_vikeConfigDependencies: esbuildCache.vikeConfigDependencies,
|
|
1149
1147
|
};
|
|
@@ -73,7 +73,9 @@ addGlobalContextTmp, addGlobalContextAsync) {
|
|
|
73
73
|
return globalObject.globalContext;
|
|
74
74
|
}
|
|
75
75
|
function createGlobalContextBase(virtualFileExportsGlobalEntry) {
|
|
76
|
-
const { pageFilesAll,
|
|
76
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseVirtualFileExportsGlobalEntry_js_1.parseVirtualFileExportsGlobalEntry)(virtualFileExportsGlobalEntry);
|
|
77
|
+
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
78
|
+
const globalContextAddendum = (0, resolveVikeConfigPublic_js_1.resolveGlobalContextConfig)(pageConfigs, pageConfigGlobal);
|
|
77
79
|
const globalContext = {
|
|
78
80
|
/**
|
|
79
81
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
@@ -87,31 +89,11 @@ function createGlobalContextBase(virtualFileExportsGlobalEntry) {
|
|
|
87
89
|
_pageConfigs: pageConfigs,
|
|
88
90
|
_pageConfigGlobal: pageConfigGlobal,
|
|
89
91
|
_allPageIds: allPageIds,
|
|
90
|
-
|
|
91
|
-
config: vikeConfigPublicGlobal.config,
|
|
92
|
-
pages: vikeConfigPublicPagesEager,
|
|
92
|
+
...globalContextAddendum,
|
|
93
93
|
};
|
|
94
94
|
(0, utils_js_1.changeEnumerable)(globalContext, '_isOriginalObject', false);
|
|
95
95
|
return globalContext;
|
|
96
96
|
}
|
|
97
|
-
function getConfigsAll(virtualFileExportsGlobalEntry) {
|
|
98
|
-
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseVirtualFileExportsGlobalEntry_js_1.parseVirtualFileExportsGlobalEntry)(virtualFileExportsGlobalEntry);
|
|
99
|
-
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
100
|
-
const vikeConfigPublicGlobal = (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicGlobal)({
|
|
101
|
-
pageConfigGlobalValues: pageConfigGlobal.configValues,
|
|
102
|
-
});
|
|
103
|
-
const vikeConfigPublicPagesEager = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
104
|
-
return (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicPageEagerLoaded)(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
|
|
105
|
-
}));
|
|
106
|
-
return {
|
|
107
|
-
pageFilesAll,
|
|
108
|
-
allPageIds,
|
|
109
|
-
pageConfigs,
|
|
110
|
-
pageConfigGlobal,
|
|
111
|
-
vikeConfigPublicGlobal,
|
|
112
|
-
vikeConfigPublicPagesEager,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
97
|
function getAllPageIds(pageFilesAll, pageConfigs) {
|
|
116
98
|
const fileIds = pageFilesAll.filter(({ isDefaultPageFile }) => !isDefaultPageFile).map(({ pageId }) => pageId);
|
|
117
99
|
const allPageIds = (0, utils_js_1.unique)(fileIds);
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPageContextShared = createPageContextShared;
|
|
4
4
|
exports.createPageContextObject = createPageContextObject;
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
|
-
function createPageContextShared(pageContextCreated,
|
|
7
|
-
(0, utils_js_1.objectAssign)(pageContextCreated,
|
|
6
|
+
function createPageContextShared(pageContextCreated, globalConfigPublic) {
|
|
7
|
+
(0, utils_js_1.objectAssign)(pageContextCreated, globalConfigPublic);
|
|
8
8
|
return pageContextCreated;
|
|
9
9
|
}
|
|
10
10
|
function createPageContextObject() {
|
|
@@ -1,57 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// TO-DO/soon: rename PageConfig names
|
|
3
|
-
// - Use `Internal` suffix, i.e. {Page,Global}ConfigInternal
|
|
4
|
-
// - While keeping {Page,Global}ConfigPublic or remove Public suffix and rename it to {Page,Global}Config ?
|
|
5
|
-
// - rename EagerLoaded EagerlyLoaded
|
|
6
|
-
// - remove `LazyLoaded` suffix
|
|
7
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
4
|
};
|
|
10
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
6
|
+
exports.resolveGlobalConfigPublic = resolveGlobalConfigPublic;
|
|
7
|
+
exports.resolvePageContextConfig = resolvePageContextConfig;
|
|
8
|
+
exports.resolveGlobalContextConfig = resolveGlobalContextConfig;
|
|
14
9
|
const assert_exports_old_design_js_1 = require("../getPageFiles/assert_exports_old_design.js");
|
|
15
10
|
const getConfigDefinedAt_js_1 = require("./getConfigDefinedAt.js");
|
|
16
11
|
const helpers_js_1 = require("./helpers.js");
|
|
17
12
|
const utils_js_1 = require("../utils.js");
|
|
18
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
function resolveGlobalConfigPublicPage(pageConfigGlobalValues, pageConfig, pageConfigValues) {
|
|
15
|
+
const pageConfigPublic_ = resolvePageConfigPublic({ pageConfigGlobalValues, pageConfigValues });
|
|
16
|
+
const pageConfigPublic = getPublicCopy(pageConfigPublic_);
|
|
17
|
+
const page = (() => {
|
|
18
|
+
if (!pageConfig.isErrorPage) {
|
|
19
|
+
const route = pageConfigPublic.config.route ?? pageConfig.routeFilesystem.routeString;
|
|
20
|
+
return {
|
|
21
|
+
...pageConfigPublic,
|
|
22
|
+
route,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return {
|
|
27
|
+
...pageConfigPublic,
|
|
28
|
+
isErrorPage: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
36
32
|
return [pageConfig.pageId, page];
|
|
37
33
|
}
|
|
38
|
-
function getPublicCopy(
|
|
39
|
-
|
|
40
|
-
config:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
function getPublicCopy(configInternal) {
|
|
35
|
+
const configPublic = {
|
|
36
|
+
config: configInternal.config,
|
|
37
|
+
// TO-DO/soon/flat-pageContext: expose publicly?
|
|
38
|
+
_source: configInternal.source,
|
|
39
|
+
_sources: configInternal.sources,
|
|
40
|
+
_from: configInternal.from,
|
|
44
41
|
};
|
|
42
|
+
return configPublic;
|
|
45
43
|
}
|
|
46
|
-
function
|
|
44
|
+
function resolvePageConfigPublic({ pageConfigGlobalValues, pageConfigValues, }) {
|
|
47
45
|
const configValues = { ...pageConfigGlobalValues, ...pageConfigValues };
|
|
48
|
-
return
|
|
46
|
+
return resolveConfigPublic_V1Design({ configValues });
|
|
49
47
|
}
|
|
50
|
-
function
|
|
51
|
-
const vikeConfigPublicGlobal = resolveVikeConfigPublic_V1Design({ configValues: pageConfigGlobalValues });
|
|
52
|
-
return getPublicCopy(vikeConfigPublicGlobal);
|
|
53
|
-
}
|
|
54
|
-
function resolveVikeConfigPublicPageLazyLoaded(pageFiles, // V0.4 design
|
|
48
|
+
function resolvePageContextConfig(pageFiles, // V0.4 design
|
|
55
49
|
pageConfig, // V1 design
|
|
56
50
|
pageConfigGlobal) {
|
|
57
51
|
const config = {};
|
|
@@ -78,7 +72,7 @@ pageConfigGlobal) {
|
|
|
78
72
|
let sources;
|
|
79
73
|
let from;
|
|
80
74
|
if (pageConfig) {
|
|
81
|
-
const res =
|
|
75
|
+
const res = resolvePageConfigPublic({
|
|
82
76
|
pageConfigGlobalValues: pageConfigGlobal.configValues,
|
|
83
77
|
pageConfigValues: pageConfig.configValues,
|
|
84
78
|
});
|
|
@@ -113,7 +107,7 @@ pageConfigGlobal) {
|
|
|
113
107
|
});
|
|
114
108
|
(0, utils_js_1.assert)(!('default' in exports));
|
|
115
109
|
(0, utils_js_1.assert)(!('default' in exportsAll));
|
|
116
|
-
const
|
|
110
|
+
const pageContextAddendum = {
|
|
117
111
|
config: config,
|
|
118
112
|
from,
|
|
119
113
|
source,
|
|
@@ -124,7 +118,7 @@ pageConfigGlobal) {
|
|
|
124
118
|
exportsAll,
|
|
125
119
|
};
|
|
126
120
|
// TO-DO/next-major-release: remove
|
|
127
|
-
(0, utils_js_1.objectDefineProperty)(
|
|
121
|
+
(0, utils_js_1.objectDefineProperty)(pageContextAddendum, 'pageExports', {
|
|
128
122
|
get: () => {
|
|
129
123
|
// We only show the warning in Node.js because when using Client Routing Vue integration uses `Object.assign(pageContextReactive, pageContext)` which will wrongully trigger the warning. There is no cross-browser way to catch whether the property accessor was initiated by an `Object.assign()` call.
|
|
130
124
|
if (!(0, utils_js_1.isBrowser)()) {
|
|
@@ -138,10 +132,33 @@ pageConfigGlobal) {
|
|
|
138
132
|
enumerable: false,
|
|
139
133
|
configurable: true,
|
|
140
134
|
});
|
|
141
|
-
return
|
|
135
|
+
return pageContextAddendum;
|
|
136
|
+
}
|
|
137
|
+
function resolveGlobalContextConfig(pageConfigs, pageConfigGlobal) {
|
|
138
|
+
const globalContextAddendum = resolveGlobalConfigPublic(pageConfigs, pageConfigGlobal, (c) => c.configValues);
|
|
139
|
+
return globalContextAddendum;
|
|
140
|
+
}
|
|
141
|
+
function resolveGlobalConfigPublic(pageConfigs, pageConfigGlobal, getConfigValues) {
|
|
142
|
+
// global
|
|
143
|
+
const pageConfigGlobalValues = getConfigValues(pageConfigGlobal, true);
|
|
144
|
+
const globalConfigPublicBase_ = resolveConfigPublic_V1Design({ configValues: pageConfigGlobalValues });
|
|
145
|
+
const globalConfigPublicBase = getPublicCopy(globalConfigPublicBase_);
|
|
146
|
+
// pages
|
|
147
|
+
const pages = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
148
|
+
const pageConfigValues = getConfigValues(pageConfig);
|
|
149
|
+
return resolveGlobalConfigPublicPage(pageConfigGlobalValues, pageConfig, pageConfigValues);
|
|
150
|
+
}));
|
|
151
|
+
const globalConfigPublic = {
|
|
152
|
+
...globalConfigPublicBase,
|
|
153
|
+
pages,
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
...globalConfigPublic,
|
|
157
|
+
_globalConfigPublic: globalConfigPublic,
|
|
158
|
+
};
|
|
142
159
|
}
|
|
143
160
|
// V1 design
|
|
144
|
-
function
|
|
161
|
+
function resolveConfigPublic_V1Design(pageConfig) {
|
|
145
162
|
const config = {};
|
|
146
163
|
const configEntries = {};
|
|
147
164
|
const exportsAll = {};
|
|
@@ -229,6 +246,8 @@ function resolveVikeConfigPublic_V1Design(pageConfig) {
|
|
|
229
246
|
from,
|
|
230
247
|
};
|
|
231
248
|
}
|
|
249
|
+
// V0.4 design
|
|
250
|
+
// TO-DO/next-major-release: remove
|
|
232
251
|
function getExportValues(pageFile) {
|
|
233
252
|
const { filePath, fileExports } = pageFile;
|
|
234
253
|
(0, utils_js_1.assert)(fileExports); // assume pageFile.loadFile() was called
|