vike 0.4.236-commit-eab75f6 → 0.4.237-commit-85e89b1
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/client/runtime-client-routing/globalContext.js +2 -2
- package/dist/cjs/client/runtime-server-routing/globalContext.js +2 -2
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +5 -7
- package/dist/cjs/node/api/preview.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +4 -4
- package/dist/cjs/node/runtime/globalContext.js +21 -22
- package/dist/cjs/node/runtime/html/serializeContext.js +8 -47
- package/dist/cjs/node/runtime/html/stream.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +3 -3
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +4 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsDev.js → retrievePageAssetsDev.js} +21 -6
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +5 -34
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +50 -14
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +22 -9
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -3
- package/dist/cjs/node/runtime/renderPage.js +7 -6
- package/dist/cjs/node/shared/virtualFileId.js +110 -0
- package/dist/cjs/node/vite/index.js +3 -3
- package/dist/cjs/node/vite/onLoad.js +5 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +10 -10
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +20 -11
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -10
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +46 -44
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +5 -12
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +5 -5
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +5 -1
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +2 -6
- package/dist/cjs/node/vite/plugins/pluginPreview.js +11 -4
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +5 -12
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +7 -9
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFileEntry.js → generateVirtualFileGlobalEntryWithOldDesign.js} +11 -11
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -12
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +67 -0
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +14 -12
- package/dist/cjs/node/vite/shared/findPageFiles.js +1 -1
- package/dist/cjs/node/vite/shared/{resolveClientEntriesDev.js → getClientEntrySrcDev.js} +2 -2
- package/dist/cjs/node/vite/shared/getMagicString.js +1 -1
- package/dist/cjs/node/vite/shared/getOutDirs.js +18 -12
- package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/cjs/node/vite/shared/isViteServerBuild.js +54 -31
- package/dist/cjs/node/vite/shared/loggerVite.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +8 -19
- package/dist/cjs/shared/createGlobalContextShared.js +23 -10
- package/dist/cjs/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -26
- package/dist/cjs/shared/modifyUrlSameOrigin.js +9 -4
- package/dist/cjs/shared/page-configs/loadPageEntry.js +25 -0
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +4 -4
- package/dist/cjs/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js} +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +15 -16
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/cast.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +12 -12
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +35 -48
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/globalContext.js +2 -2
- package/dist/esm/client/runtime-client-routing/history.d.ts +3 -5
- package/dist/esm/client/runtime-client-routing/history.js +39 -22
- package/dist/esm/client/runtime-client-routing/initClientRouter.js +2 -3
- 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 +4 -4
- package/dist/esm/client/runtime-client-routing/utils.d.ts +2 -0
- package/dist/esm/client/runtime-client-routing/utils.js +2 -0
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +3 -3
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +2 -2
- package/dist/esm/client/runtime-server-routing/globalContext.js +2 -2
- package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +3 -3
- package/dist/esm/client/shared/createGetGlobalContextClient.js +5 -7
- 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 +4 -4
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
- package/dist/esm/node/api/preview.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +9 -9
- package/dist/esm/node/prerender/runPrerender.js +4 -4
- package/dist/esm/node/runtime/globalContext.d.ts +10 -10
- package/dist/esm/node/runtime/globalContext.js +21 -22
- package/dist/esm/node/runtime/html/serializeContext.d.ts +8 -3
- package/dist/esm/node/runtime/html/serializeContext.js +8 -47
- package/dist/esm/node/runtime/html/stream.js +1 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +3 -3
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +4 -7
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/{retrieveAssetsDev.js → retrievePageAssetsDev.js} +22 -7
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +0 -6
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -33
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.js +51 -15
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +25 -12
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -3
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +10 -11
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -3
- package/dist/esm/node/runtime/renderPage.d.ts +3 -2
- package/dist/esm/node/runtime/renderPage.js +7 -6
- package/dist/esm/node/shared/virtualFileId.d.ts +28 -0
- package/dist/esm/node/shared/virtualFileId.js +107 -0
- package/dist/esm/node/vite/index.js +3 -3
- package/dist/esm/node/vite/onLoad.js +5 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +11 -11
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +1 -0
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +21 -12
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +5 -8
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +47 -45
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +6 -10
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +4 -4
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +6 -2
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +2 -6
- package/dist/esm/node/vite/plugins/pluginPreview.js +13 -6
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +6 -10
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.d.ts +2 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +7 -9
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.d.ts +6 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFileEntry.js → generateVirtualFileGlobalEntryWithOldDesign.js} +11 -11
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -12
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +14 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +65 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +14 -12
- package/dist/esm/node/vite/shared/findPageFiles.js +1 -1
- package/dist/esm/node/vite/shared/getClientEntrySrcDev.d.ts +4 -0
- package/dist/esm/node/vite/shared/{resolveClientEntriesDev.js → getClientEntrySrcDev.js} +2 -2
- package/dist/esm/node/vite/shared/getMagicString.js +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +6 -3
- package/dist/esm/node/vite/shared/getOutDirs.js +19 -13
- package/dist/esm/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/esm/node/vite/shared/isViteServerBuild.d.ts +14 -11
- package/dist/esm/node/vite/shared/isViteServerBuild.js +55 -31
- package/dist/esm/node/vite/shared/loggerVite.js +1 -1
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +3 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +10 -21
- package/dist/esm/shared/createGlobalContextShared.d.ts +6 -6
- package/dist/esm/shared/createGlobalContextShared.js +25 -12
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.d.ts → parseVirtualFileExportsGlobalEntry.d.ts} +2 -2
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -26
- 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/modifyUrlSameOrigin.d.ts +1 -1
- package/dist/esm/shared/modifyUrlSameOrigin.js +9 -4
- package/dist/esm/shared/page-configs/loadPageEntry.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadPageEntry.js +23 -0
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +9 -9
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +4 -4
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +1 -1
- package/dist/esm/shared/page-configs/serialize/{parsePageConfigs.d.ts → parsePageConfigsSerialized.d.ts} +2 -2
- package/dist/esm/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js} +2 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +15 -16
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/Config.d.ts +33 -98
- package/dist/esm/types/PageConfig.d.ts +9 -7
- package/dist/esm/types/VikeNamespace.d.ts +13 -0
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/cast.d.ts +2 -2
- package/dist/esm/utils/cast.js +1 -1
- package/dist/esm/utils/objectFilter.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +0 -31
- package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -45
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -23
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +0 -11
- package/dist/cjs/shared/page-configs/loadConfigValues.js +0 -21
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.d.ts +0 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +0 -4
- package/dist/esm/node/shared/virtualFiles/virtualFileEntry.d.ts +0 -11
- package/dist/esm/node/shared/virtualFiles/virtualFileEntry.js +0 -28
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.d.ts +0 -9
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -43
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFileEntry.d.ts +0 -5
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigsEager.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.d.ts +0 -7
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -21
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.d.ts +0 -3
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +0 -9
- package/dist/esm/node/vite/shared/resolveClientEntriesDev.d.ts +0 -4
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadConfigValues.js +0 -19
|
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pluginVirtualFiles = pluginVirtualFiles;
|
|
7
7
|
const vite_1 = require("vite");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const generateVirtualFilePageEntry_js_1 = require("./pluginVirtualFiles/generateVirtualFilePageEntry.js");
|
|
9
|
+
const generateVirtualFileGlobalEntryWithOldDesign_js_1 = require("./pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js");
|
|
10
10
|
const utils_js_1 = require("../utils.js");
|
|
11
|
-
const
|
|
12
|
-
const virtualFileEntry_js_1 = require("../../shared/virtualFiles/virtualFileEntry.js");
|
|
11
|
+
const virtualFileId_js_1 = require("../../shared/virtualFileId.js");
|
|
13
12
|
const resolveVikeConfigInternal_js_1 = require("../shared/resolveVikeConfigInternal.js");
|
|
14
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
14
|
const loggerNotProd_js_1 = require("../shared/loggerNotProd.js");
|
|
@@ -49,13 +48,16 @@ function pluginVirtualFiles() {
|
|
|
49
48
|
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
50
49
|
const isDev = config._isDev;
|
|
51
50
|
(0, utils_js_1.assert)(typeof isDev === 'boolean');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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, config);
|
|
55
|
+
return code;
|
|
56
|
+
}
|
|
57
|
+
if (idParsed.type === 'global-entry') {
|
|
58
|
+
const code = await (0, generateVirtualFileGlobalEntryWithOldDesign_js_1.generateVirtualFileGlobalEntryWithOldDesign)(id, options, config, this.environment, isDev);
|
|
59
|
+
return code;
|
|
60
|
+
}
|
|
59
61
|
}
|
|
60
62
|
},
|
|
61
63
|
configureServer(server) {
|
|
@@ -168,7 +170,7 @@ function reloadConfig(filePath, config, op, server) {
|
|
|
168
170
|
}
|
|
169
171
|
function getVikeVirtualFiles(server) {
|
|
170
172
|
const vikeVirtualFiles = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
171
|
-
.filter((url) => (0,
|
|
173
|
+
.filter((url) => (0, virtualFileId_js_1.parseVirtualFileId)(url))
|
|
172
174
|
.map((url) => {
|
|
173
175
|
const mod = server.moduleGraph.urlToModuleMap.get(url);
|
|
174
176
|
(0, utils_js_1.assert)(mod);
|
|
@@ -10,7 +10,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
|
10
10
|
const getOutDirs_js_1 = require("./getOutDirs.js");
|
|
11
11
|
async function findPageFiles(config, fileTypes, isDev) {
|
|
12
12
|
const cwd = config.root;
|
|
13
|
-
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
13
|
+
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config, undefined);
|
|
14
14
|
const timeBase = new Date().getTime();
|
|
15
15
|
let pageFiles = await (0, tinyglobby_1.glob)(fileTypes.map((fileType) => `**/*${fileType}.${utils_js_1.scriptFileExtensionPattern}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false, expandDirectories: false });
|
|
16
16
|
pageFiles = pageFiles.map((p) => '/' + (0, utils_js_1.toPosixPath)(p));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getClientEntrySrcDev = getClientEntrySrcDev;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
6
|
-
function
|
|
6
|
+
function getClientEntrySrcDev(clientEntry, viteDevServer) {
|
|
7
7
|
let userRootDir = viteDevServer.config.root;
|
|
8
8
|
(0, utils_js_1.assert)(userRootDir);
|
|
9
9
|
userRootDir = (0, utils_js_1.toPosixPath)(userRootDir);
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getMagicString = getMagicString;
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
|
-
//
|
|
8
|
+
// Used everywhere instead of `new MagicString()` for consistent source map generation
|
|
9
9
|
function getMagicString(code, id) {
|
|
10
10
|
const magicString = new magic_string_1.default(code);
|
|
11
11
|
const getMagicStringResult = () => {
|
|
@@ -5,23 +5,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getOutDirs = getOutDirs;
|
|
7
7
|
exports.resolveOutDir = resolveOutDir;
|
|
8
|
+
exports.resolveOutDir_configEnvironment = resolveOutDir_configEnvironment;
|
|
8
9
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
10
|
const utils_js_1 = require("../utils.js");
|
|
10
11
|
const isViteServerBuild_js_1 = require("./isViteServerBuild.js");
|
|
11
12
|
const debug = (0, utils_js_1.createDebugger)('vike:outDir');
|
|
12
13
|
function getOutDirs(configGlobal, viteEnv) {
|
|
13
|
-
const configEnv = viteEnv?.config ?? configGlobal;
|
|
14
14
|
debug('getOutDirs()', new Error().stack);
|
|
15
|
-
const outDir =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const outDirs = getOutDirsAll(outDir, configEnv.root);
|
|
15
|
+
const outDir = getOutDirFromResolvedConfig(configGlobal);
|
|
16
|
+
assertOutDirResolved(outDir, configGlobal, viteEnv);
|
|
17
|
+
const outDirs = getOutDirsAll(outDir, configGlobal.root);
|
|
19
18
|
return outDirs;
|
|
20
19
|
}
|
|
20
|
+
function resolveOutDir_configEnvironment(configGlobal, envName, configEnv) {
|
|
21
|
+
(0, utils_js_1.assert)(configGlobal && envName && configEnv);
|
|
22
|
+
const viteEnv = { name: envName, config: configEnv };
|
|
23
|
+
const isServerSide = (0, isViteServerBuild_js_1.isViteServerBuild)(configGlobal, viteEnv);
|
|
24
|
+
return resolveOutDir(configEnv, isServerSide);
|
|
25
|
+
}
|
|
21
26
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
22
|
-
function resolveOutDir(config,
|
|
27
|
+
function resolveOutDir(config, isServerSide) {
|
|
23
28
|
debug('resolveOutDir()', new Error().stack);
|
|
24
|
-
const isServerSide = (0, isViteServerBuild_js_1.isViteServerBuild)(config) || isSSR;
|
|
25
29
|
debug('isServerSide', isServerSide);
|
|
26
30
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
27
31
|
debug('outDir', outDir);
|
|
@@ -103,14 +107,16 @@ function isOutDirRoot(outDirRot) {
|
|
|
103
107
|
function assertIsNotOutDirRoot(outDir) {
|
|
104
108
|
(0, utils_js_1.assert)(outDir.endsWith('/client') || outDir.endsWith('/server'));
|
|
105
109
|
}
|
|
106
|
-
/** Assert that `outDir` ends with `/server` or `/client` */
|
|
107
|
-
function assertOutDirResolved(outDir,
|
|
110
|
+
/** Assert that `outDir` ends with the correct directory `/server` or `/client` */
|
|
111
|
+
function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
108
112
|
(0, utils_js_1.assertPosixPath)(outDir);
|
|
109
|
-
|
|
113
|
+
if (isOutDirRoot(outDir))
|
|
114
|
+
return;
|
|
115
|
+
(0, utils_js_1.assert)(outDir.endsWith('/client') || outDir.endsWith('/server')); // we normalized outDir
|
|
110
116
|
(0, utils_js_1.assert)('/client'.length === '/server'.length);
|
|
111
117
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
112
118
|
const wrongUsage = `You've set Vite's config.build.outDir to ${picocolors_1.default.cyan(outDir)} but you should set it to ${picocolors_1.default.cyan(outDirCorrected)} instead.`;
|
|
113
|
-
if ((0, isViteServerBuild_js_1.
|
|
119
|
+
if ((0, isViteServerBuild_js_1.isViteServerBuild_withoutEnv)(configGlobal, viteEnv)) {
|
|
114
120
|
(0, utils_js_1.assertUsage)(outDir.endsWith('/server'), wrongUsage);
|
|
115
121
|
}
|
|
116
122
|
else {
|
|
@@ -124,7 +130,7 @@ function getOutDirFromViteUserConfig(config) {
|
|
|
124
130
|
outDir = normalizeOutDir(outDir);
|
|
125
131
|
return outDir;
|
|
126
132
|
}
|
|
127
|
-
function
|
|
133
|
+
function getOutDirFromResolvedConfig(config) {
|
|
128
134
|
let outDir = config.build.outDir;
|
|
129
135
|
(0, utils_js_1.assert)(outDir);
|
|
130
136
|
outDir = normalizeOutDir(outDir);
|
|
@@ -5,7 +5,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
5
5
|
const getOutDirs_js_1 = require("./getOutDirs.js");
|
|
6
6
|
function getViteConfigRuntime(config) {
|
|
7
7
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(config, '_baseViteOriginal', 'string'));
|
|
8
|
-
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
8
|
+
const { outDirRoot } = (0, getOutDirs_js_1.getOutDirs)(config, undefined);
|
|
9
9
|
(0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot);
|
|
10
10
|
const viteConfigRuntime = {
|
|
11
11
|
root: config.root,
|
|
@@ -2,46 +2,69 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isViteServerBuild = isViteServerBuild;
|
|
4
4
|
exports.isViteClientBuild = isViteClientBuild;
|
|
5
|
-
exports.
|
|
6
|
-
exports.isViteServerBuild_safe = isViteServerBuild_safe;
|
|
5
|
+
exports.isViteServerBuild_withoutEnv = isViteServerBuild_withoutEnv;
|
|
7
6
|
exports.isViteServerBuild_onlySsrEnv = isViteServerBuild_onlySsrEnv;
|
|
7
|
+
exports.isViteServerBuild_extraSafe = isViteServerBuild_extraSafe;
|
|
8
8
|
const assert_js_1 = require("../../../utils/assert.js");
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function isViteServerBuild_withoutEnv(configGlobal, viteEnv) {
|
|
10
|
+
(0, assert_js_1.assert)(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
11
|
+
const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
12
|
+
const isServerSide2 = !viteEnv?.name ? null : viteEnv.name !== 'client'; // I can't think of a use case for creating another client-side environment
|
|
13
|
+
const isServerSide3 = !viteEnv ? null : !!viteEnv.config.build?.ssr;
|
|
14
|
+
const isServerSide4 = !!configGlobal.build?.ssr;
|
|
15
|
+
const debug = {
|
|
16
|
+
envIsUndefined: !viteEnv,
|
|
17
|
+
envName: viteEnv?.name ?? null,
|
|
18
|
+
envConsumer: viteEnv?.config.consumer ?? null,
|
|
19
|
+
configEnvBuildSsr: viteEnv?.config.build?.ssr ?? null,
|
|
20
|
+
configGlobalBuildSsr: configGlobal.build?.ssr ?? null,
|
|
21
|
+
isServerSide1,
|
|
22
|
+
isServerSide2,
|
|
23
|
+
isServerSide3,
|
|
24
|
+
isServerSide4,
|
|
25
|
+
};
|
|
26
|
+
if (isServerSide1 !== null) {
|
|
27
|
+
(0, assert_js_1.assert)(isServerSide1 === isServerSide2 || isServerSide2 === null, debug);
|
|
28
|
+
(0, assert_js_1.assert)(isServerSide1 === isServerSide3, debug);
|
|
29
|
+
return isServerSide1;
|
|
30
|
+
}
|
|
31
|
+
if (isServerSide2 !== null) {
|
|
32
|
+
/* This assertion can fail, seems to be a Vite bug?
|
|
33
|
+
assert(isServerSide2 === isServerSide3, debug)
|
|
34
|
+
*/
|
|
35
|
+
return isServerSide2;
|
|
36
|
+
}
|
|
37
|
+
if (isServerSide3 !== null) {
|
|
38
|
+
return isServerSide3;
|
|
39
|
+
}
|
|
40
|
+
return isServerSide4;
|
|
12
41
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return viteEnv ? viteEnv.name === 'ssr' : isViteServerBuild(configGlobal);
|
|
42
|
+
function isViteServerBuild(configGlobal, viteEnv) {
|
|
43
|
+
return isViteServerBuild_withoutEnv(configGlobal, viteEnv);
|
|
16
44
|
}
|
|
17
45
|
function isViteClientBuild(configGlobal, viteEnv) {
|
|
18
|
-
|
|
19
|
-
const isVite5 = viteEnv === undefined;
|
|
20
|
-
if (!isVite5) {
|
|
21
|
-
const yes2 = viteEnv.name === 'client';
|
|
22
|
-
(0, assert_js_1.assert)(yes === yes2);
|
|
23
|
-
}
|
|
24
|
-
return yes;
|
|
46
|
+
return !isViteServerBuild(configGlobal, viteEnv);
|
|
25
47
|
}
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
49
|
+
function isViteServerBuild_onlySsrEnv(configGlobal, viteEnv) {
|
|
50
|
+
return viteEnv ? viteEnv.name === 'ssr' : isViteServerBuild(configGlobal, viteEnv);
|
|
28
51
|
}
|
|
29
|
-
// Vite is quite messy about setting
|
|
30
|
-
|
|
31
|
-
function isViteServerBuild_safe(config, options) {
|
|
52
|
+
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
53
|
+
function isViteServerBuild_extraSafe(config, options, viteEnv) {
|
|
32
54
|
if (config.command === 'build') {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return
|
|
55
|
+
const res = config.build.ssr;
|
|
56
|
+
(0, assert_js_1.assert)(typeof res === 'boolean');
|
|
57
|
+
(0, assert_js_1.assert)(res === options?.ssr || options?.ssr === undefined);
|
|
58
|
+
(0, assert_js_1.assert)(res === isViteServerBuild(config, viteEnv));
|
|
59
|
+
return res;
|
|
38
60
|
}
|
|
39
61
|
else {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/* This
|
|
43
|
-
if (typeof config.build.ssr === 'boolean') assert(
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
const res = options?.ssr;
|
|
63
|
+
(0, assert_js_1.assert)(typeof res === 'boolean');
|
|
64
|
+
/* This assertion can fail, seems to be a Vite bug? It's very unexpected.
|
|
65
|
+
if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
|
|
66
|
+
*/
|
|
67
|
+
(0, assert_js_1.assert)(res === isViteServerBuild(config, viteEnv));
|
|
68
|
+
return res;
|
|
46
69
|
}
|
|
47
70
|
}
|
|
@@ -33,7 +33,7 @@ function intercept(logType, config) {
|
|
|
33
33
|
// We swallow Vite's message: we didn't see it add any value so far.
|
|
34
34
|
// - It can even be confusing, such as the following:
|
|
35
35
|
// ```
|
|
36
|
-
// Error when evaluating SSR module virtual:vike:
|
|
36
|
+
// Error when evaluating SSR module virtual:vike:page-entry:server:/pages/abort: failed to import "/pages/abort/+Page.mdx"
|
|
37
37
|
// ```
|
|
38
38
|
(0, utils_js_1.assert)(!(0, isErrorDebug_js_1.isErrorDebug)());
|
|
39
39
|
return;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.configDefinitionsBuiltIn = void 0;
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
const getConfigDefinedAt_js_1 = require("../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
6
|
+
const getConfigValueSourcesRelevant_js_1 = require("../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js");
|
|
6
7
|
const configDefinitionsBuiltIn = {
|
|
7
8
|
onRenderHtml: {
|
|
8
9
|
env: { server: true },
|
|
@@ -97,6 +98,22 @@ const configDefinitionsBuiltIn = {
|
|
|
97
98
|
meta: {
|
|
98
99
|
env: { config: true },
|
|
99
100
|
},
|
|
101
|
+
serverOnlyHooks: {
|
|
102
|
+
env: { client: true },
|
|
103
|
+
eager: true,
|
|
104
|
+
_computed: (pageConfig) => {
|
|
105
|
+
const sources = ['data', 'onBeforeRender', 'onCreatePageContext']
|
|
106
|
+
.map((hookName) => (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourcesRelevant)(hookName, {
|
|
107
|
+
isForClientSide: false,
|
|
108
|
+
// TO-DO/eventually/remove-server-router: let's eventually remove support for Server Routing
|
|
109
|
+
isClientRouting: true,
|
|
110
|
+
}, pageConfig))
|
|
111
|
+
.flat(1)
|
|
112
|
+
// Server-only
|
|
113
|
+
.filter((source) => !source.configEnv.client);
|
|
114
|
+
return sources.length > 0;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
100
117
|
// Whether the page loads:
|
|
101
118
|
// - Vike's client runtime
|
|
102
119
|
// - User's client hooks
|
|
@@ -104,7 +121,8 @@ const configDefinitionsBuiltIn = {
|
|
|
104
121
|
isClientRuntimeLoaded: {
|
|
105
122
|
env: { server: true, client: true },
|
|
106
123
|
eager: true,
|
|
107
|
-
_computed: (
|
|
124
|
+
_computed: (pageConfig) => {
|
|
125
|
+
const { configValueSources } = pageConfig;
|
|
108
126
|
{
|
|
109
127
|
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
110
128
|
if (source) {
|
|
@@ -122,15 +140,25 @@ const configDefinitionsBuiltIn = {
|
|
|
122
140
|
!!getConfigEnv(configValueSources, 'Page')?.client);
|
|
123
141
|
},
|
|
124
142
|
},
|
|
143
|
+
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
125
144
|
onBeforeRenderEnv: {
|
|
126
145
|
env: { client: true },
|
|
127
146
|
eager: true,
|
|
128
|
-
_computed: (
|
|
147
|
+
_computed: (pageConfig) => {
|
|
148
|
+
const { configValueSources } = pageConfig;
|
|
149
|
+
return !isConfigSet(configValueSources, 'onBeforeRender')
|
|
150
|
+
? null
|
|
151
|
+
: getConfigEnv(configValueSources, 'onBeforeRender');
|
|
152
|
+
},
|
|
129
153
|
},
|
|
154
|
+
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
130
155
|
dataEnv: {
|
|
131
156
|
env: { client: true },
|
|
132
157
|
eager: true,
|
|
133
|
-
_computed: (
|
|
158
|
+
_computed: (pageConfig) => {
|
|
159
|
+
const { configValueSources } = pageConfig;
|
|
160
|
+
return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
|
|
161
|
+
},
|
|
134
162
|
},
|
|
135
163
|
hooksTimeout: {
|
|
136
164
|
env: { server: true, client: true },
|
|
@@ -12,7 +12,6 @@ exports.isV1Design = isV1Design;
|
|
|
12
12
|
exports.getConfVal = getConfVal;
|
|
13
13
|
exports.getConfigDefinitionOptional = getConfigDefinitionOptional;
|
|
14
14
|
exports.getVikeConfigFromCliOrEnv = getVikeConfigFromCliOrEnv;
|
|
15
|
-
exports.isOverridden = isOverridden;
|
|
16
15
|
exports.getVikeConfig = getVikeConfig;
|
|
17
16
|
const utils_js_1 = require("../utils.js");
|
|
18
17
|
const configDefinitionsBuiltIn_js_1 = require("./resolveVikeConfigInternal/configDefinitionsBuiltIn.js");
|
|
@@ -182,7 +181,7 @@ async function resolveVikeConfigInternal(userRootDir, vikeVitePluginOptions, esb
|
|
|
182
181
|
// pages
|
|
183
182
|
const vikeConfigPublicPagesEager = (0, utils_js_1.objectFromEntries)(pageConfigs.map((pageConfig) => {
|
|
184
183
|
const pageConfigValues = getConfigValues(pageConfig, true);
|
|
185
|
-
return (0, resolveVikeConfigPublic_js_1.
|
|
184
|
+
return (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicPageEagerLoaded)(pageConfigGlobalValues, pageConfig, pageConfigValues);
|
|
186
185
|
}));
|
|
187
186
|
const prerenderContext = resolvePrerenderContext({
|
|
188
187
|
config: vikeConfigPublicGlobal.config,
|
|
@@ -290,15 +289,16 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
|
|
|
290
289
|
applyEffectsMetaEnv(configValueSources, configDefinitionsLocal);
|
|
291
290
|
applyEffectsConfVal(configValueSources, configDefinitionsLocal, plusFilesAll);
|
|
292
291
|
sortConfigValueSources(configValueSources, locationId);
|
|
293
|
-
const configValuesComputed = getComputed(configValueSources, configDefinitionsLocal);
|
|
294
292
|
const pageConfig = {
|
|
295
293
|
pageId: locationId,
|
|
296
294
|
...pageConfigRoute,
|
|
297
295
|
configDefinitions: configDefinitionsLocal,
|
|
298
296
|
plusFiles: plusFilesRelevant,
|
|
299
297
|
configValueSources,
|
|
300
|
-
configValuesComputed,
|
|
301
298
|
};
|
|
299
|
+
const configValuesComputed = getComputed(pageConfig);
|
|
300
|
+
(0, utils_js_1.objectAssign)(pageConfig, { configValuesComputed });
|
|
301
|
+
(0, utils_js_1.checkType)(pageConfig);
|
|
302
302
|
return pageConfig;
|
|
303
303
|
});
|
|
304
304
|
assertPageConfigs(pageConfigs);
|
|
@@ -365,7 +365,7 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
365
365
|
}
|
|
366
366
|
function getConfigValues(pageConfig, tolerateMissingValue) {
|
|
367
367
|
const configValues = {};
|
|
368
|
-
(0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig,
|
|
368
|
+
(0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig, { isForConfig: true }, null).forEach((entry) => {
|
|
369
369
|
if (entry.configValueBase.type === 'computed') {
|
|
370
370
|
(0, utils_js_1.assert)('value' in entry); // Help TS
|
|
371
371
|
const { configValueBase, value, configName } = entry;
|
|
@@ -899,12 +899,12 @@ function applyEffectMetaEnv(configModFromEffect, configValueSources, configDefEf
|
|
|
899
899
|
});
|
|
900
900
|
});
|
|
901
901
|
}
|
|
902
|
-
function getComputed(
|
|
902
|
+
function getComputed(pageConfig) {
|
|
903
903
|
const configValuesComputed = {};
|
|
904
|
-
(0, utils_js_1.objectEntries)(configDefinitions).forEach(([configName, configDef]) => {
|
|
904
|
+
(0, utils_js_1.objectEntries)(pageConfig.configDefinitions).forEach(([configName, configDef]) => {
|
|
905
905
|
if (!configDef._computed)
|
|
906
906
|
return;
|
|
907
|
-
const value = configDef._computed(
|
|
907
|
+
const value = configDef._computed(pageConfig);
|
|
908
908
|
if (value === undefined)
|
|
909
909
|
return;
|
|
910
910
|
configValuesComputed[configName] = {
|
|
@@ -1100,17 +1100,6 @@ function isGlobalLocation(locationId, plusFilesAll) {
|
|
|
1100
1100
|
.map(([locationId]) => locationId);
|
|
1101
1101
|
return locationIdsPage.every((locId) => (0, filesystemRouting_js_1.isInherited)(locationId, locId));
|
|
1102
1102
|
}
|
|
1103
|
-
function isOverridden(source, configName, pageConfig) {
|
|
1104
|
-
const configDef = pageConfig.configDefinitions[configName];
|
|
1105
|
-
(0, utils_js_1.assert)(configDef);
|
|
1106
|
-
if (configDef.cumulative)
|
|
1107
|
-
return false;
|
|
1108
|
-
const sources = pageConfig.configValueSources[configName];
|
|
1109
|
-
(0, utils_js_1.assert)(sources);
|
|
1110
|
-
const idx = sources.indexOf(source);
|
|
1111
|
-
(0, utils_js_1.assert)(idx >= 0);
|
|
1112
|
-
return idx > 0;
|
|
1113
|
-
}
|
|
1114
1103
|
function resolvePrerenderContext(vikeConfig) {
|
|
1115
1104
|
const { isPrerenderingEnabled, isPrerenderingEnabledForAllPages } = (0, resolvePrerenderConfig_js_1.resolvePrerenderConfigGlobal)(vikeConfig);
|
|
1116
1105
|
prerenderContext ?? (prerenderContext = {
|
|
@@ -3,17 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGlobalContextSyncErrMsg = void 0;
|
|
4
4
|
exports.createGlobalContextShared = createGlobalContextShared;
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
|
-
const
|
|
6
|
+
const parseVirtualFileExportsGlobalEntry_js_1 = require("./getPageFiles/parseVirtualFileExportsGlobalEntry.js");
|
|
7
7
|
const resolveVikeConfigPublic_js_1 = require("./page-configs/resolveVikeConfigPublic.js");
|
|
8
8
|
const execHook_js_1 = require("./hooks/execHook.js");
|
|
9
9
|
const prepareGlobalContextForPublicUsage_js_1 = require("./prepareGlobalContextForPublicUsage.js");
|
|
10
10
|
const getHook_js_1 = require("./hooks/getHook.js");
|
|
11
11
|
const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
12
12
|
exports.getGlobalContextSyncErrMsg = getGlobalContextSyncErrMsg;
|
|
13
|
-
|
|
13
|
+
const globalObject_ = (0, utils_js_1.getGlobalObject)('shared/createGlobalContextShared.ts', {});
|
|
14
|
+
// TO-DO/eventually use flat globalContext — like flat pageContext
|
|
15
|
+
async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
|
|
14
16
|
// TO-DO/next-major-release: we'll be able to remove addGlobalContextTmp after loadPageRoutes() is sync (it will be sync after we remove the old design)
|
|
15
17
|
addGlobalContextTmp, addGlobalContextAsync) {
|
|
16
|
-
const
|
|
18
|
+
const { previousCallPromise } = globalObject_;
|
|
19
|
+
const { promise, resolve } = (0, utils_js_1.genPromise)({
|
|
20
|
+
// Avoid this Cloudflare Worker error:
|
|
21
|
+
// ```console
|
|
22
|
+
// Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler.
|
|
23
|
+
// ```
|
|
24
|
+
timeout: null,
|
|
25
|
+
});
|
|
26
|
+
globalObject_.previousCallPromise = promise;
|
|
27
|
+
await previousCallPromise;
|
|
28
|
+
const globalContext = createGlobalContextBase(virtualFileExportsGlobalEntry);
|
|
17
29
|
let isNewGlobalContext;
|
|
18
30
|
if (!globalObject.globalContext) {
|
|
19
31
|
// We set globalObject.globalContext early and before any async operations, so that getGlobalContextSync() can be used early.
|
|
@@ -25,7 +37,7 @@ addGlobalContextTmp, addGlobalContextAsync) {
|
|
|
25
37
|
isNewGlobalContext = true;
|
|
26
38
|
}
|
|
27
39
|
if (addGlobalContext &&
|
|
28
|
-
//
|
|
40
|
+
// TO-DO/next-major-release: remove
|
|
29
41
|
globalContext._pageConfigs.length > 0) {
|
|
30
42
|
const globalContextAdded = addGlobalContext?.(globalContext);
|
|
31
43
|
(0, utils_js_1.objectAssign)(globalContext, globalContextAdded);
|
|
@@ -55,10 +67,11 @@ addGlobalContextTmp, addGlobalContextAsync) {
|
|
|
55
67
|
(0, utils_js_1.objectAssign)(globalObject.globalContext, globalContext, true);
|
|
56
68
|
}
|
|
57
69
|
}
|
|
70
|
+
resolve();
|
|
58
71
|
return globalObject.globalContext;
|
|
59
72
|
}
|
|
60
|
-
function createGlobalContextBase(
|
|
61
|
-
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(
|
|
73
|
+
function createGlobalContextBase(virtualFileExportsGlobalEntry) {
|
|
74
|
+
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(virtualFileExportsGlobalEntry);
|
|
62
75
|
const globalContext = {
|
|
63
76
|
/**
|
|
64
77
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
@@ -67,7 +80,7 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
67
80
|
*/
|
|
68
81
|
isGlobalContext: true,
|
|
69
82
|
_isOriginalObject: true,
|
|
70
|
-
|
|
83
|
+
_virtualFileExportsGlobalEntry: virtualFileExportsGlobalEntry,
|
|
71
84
|
_pageFilesAll: pageFilesAll,
|
|
72
85
|
_pageConfigs: pageConfigs,
|
|
73
86
|
_pageConfigGlobal: pageConfigGlobal,
|
|
@@ -79,14 +92,14 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
79
92
|
(0, utils_js_1.changeEnumerable)(globalContext, '_isOriginalObject', false);
|
|
80
93
|
return globalContext;
|
|
81
94
|
}
|
|
82
|
-
function getConfigsAll(
|
|
83
|
-
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0,
|
|
95
|
+
function getConfigsAll(virtualFileExportsGlobalEntry) {
|
|
96
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseVirtualFileExportsGlobalEntry_js_1.parseVirtualFileExportsGlobalEntry)(virtualFileExportsGlobalEntry);
|
|
84
97
|
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
85
98
|
const vikeConfigPublicGlobal = (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicGlobal)({
|
|
86
99
|
pageConfigGlobalValues: pageConfigGlobal.configValues,
|
|
87
100
|
});
|
|
88
101
|
const vikeConfigPublicPagesEager = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
89
|
-
return (0, resolveVikeConfigPublic_js_1.
|
|
102
|
+
return (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicPageEagerLoaded)(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
|
|
90
103
|
}));
|
|
91
104
|
return {
|
|
92
105
|
pageFilesAll,
|
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
// TODO/now: rename parseVirtualFileExportsEntryGlobal
|
|
5
|
-
// TODO/now: merge or collocate following both files?
|
|
6
|
-
// ```filesystem
|
|
7
|
-
// vike/packages/vike/shared/getPageFiles/parseVirtualFileExports.ts
|
|
8
|
-
// vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
9
|
-
// ```
|
|
3
|
+
exports.parseVirtualFileExportsGlobalEntry = parseVirtualFileExportsGlobalEntry;
|
|
10
4
|
// TO-DO/next-major-release: remove old design code, and remove all assertions.
|
|
11
5
|
const utils_js_1 = require("../utils.js");
|
|
12
6
|
const assert_exports_old_design_js_1 = require("./assert_exports_old_design.js");
|
|
13
7
|
const getPageFileObject_js_1 = require("./getPageFileObject.js");
|
|
14
8
|
const fileTypes_js_1 = require("./fileTypes.js");
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
18
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
19
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
20
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
21
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
22
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
23
|
-
(0, utils_js_1.hasProp)(
|
|
24
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
25
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
26
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
27
|
-
const { pageConfigsSerialized, pageConfigGlobalSerialized } =
|
|
9
|
+
const parsePageConfigsSerialized_js_1 = require("../page-configs/serialize/parsePageConfigsSerialized.js");
|
|
10
|
+
function parseVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry) {
|
|
11
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesLazy', 'object'));
|
|
12
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesEager', 'object'));
|
|
13
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesExportNamesLazy', 'object'));
|
|
14
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesExportNamesEager', 'object'));
|
|
15
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry.pageFilesLazy, '.page'));
|
|
16
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry.pageFilesLazy, '.page.client') ||
|
|
17
|
+
(0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry.pageFilesLazy, '.page.server'));
|
|
18
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesList', 'string[]'));
|
|
19
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageConfigsSerialized'));
|
|
20
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageConfigGlobalSerialized'));
|
|
21
|
+
const { pageConfigsSerialized, pageConfigGlobalSerialized } = virtualFileExportsGlobalEntry;
|
|
28
22
|
assertPageConfigsSerialized(pageConfigsSerialized);
|
|
29
23
|
assertPageConfigGlobalSerialized(pageConfigGlobalSerialized);
|
|
30
|
-
const { pageConfigs, pageConfigGlobal } = (0,
|
|
24
|
+
const { pageConfigs, pageConfigGlobal } = (0, parsePageConfigsSerialized_js_1.parsePageConfigsSerialized)(pageConfigsSerialized, pageConfigGlobalSerialized);
|
|
31
25
|
const pageFilesMap = {};
|
|
32
|
-
parseGlobResult(
|
|
26
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
33
27
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
34
28
|
const loadModule = globValue;
|
|
35
29
|
assertLoadModule(loadModule);
|
|
@@ -40,7 +34,7 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
40
34
|
}
|
|
41
35
|
};
|
|
42
36
|
});
|
|
43
|
-
parseGlobResult(
|
|
37
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
44
38
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
45
39
|
const loadModule = globValue;
|
|
46
40
|
assertLoadModule(loadModule);
|
|
@@ -53,20 +47,20 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
53
47
|
};
|
|
54
48
|
});
|
|
55
49
|
// `pageFilesEager` contains `.page.route.js` files
|
|
56
|
-
parseGlobResult(
|
|
50
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
57
51
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
58
52
|
const moduleExports = globValue;
|
|
59
53
|
(0, utils_js_1.assert)((0, utils_js_1.isObject)(moduleExports));
|
|
60
54
|
pageFile.fileExports = moduleExports;
|
|
61
55
|
});
|
|
62
|
-
parseGlobResult(
|
|
56
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
63
57
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
64
58
|
const moduleExports = globValue;
|
|
65
59
|
(0, utils_js_1.assert)((0, utils_js_1.isObject)(moduleExports));
|
|
66
60
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(moduleExports, 'exportNames', 'string[]'), pageFile.filePath);
|
|
67
61
|
pageFile.exportNames = moduleExports.exportNames;
|
|
68
62
|
});
|
|
69
|
-
|
|
63
|
+
virtualFileExportsGlobalEntry.pageFilesList.forEach((filePath) => {
|
|
70
64
|
pageFilesMap[filePath] = pageFilesMap[filePath] ?? (0, getPageFileObject_js_1.getPageFileObject)(filePath);
|
|
71
65
|
});
|
|
72
66
|
const pageFilesAll = Object.values(pageFilesMap);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.modifyUrlSameOrigin = modifyUrlSameOrigin;
|
|
4
|
+
// We don't move modifyUrlSameOrigin() to the modifyUrl.ts file because we plan to use modifyUrlSameOrigin() on the client-side:
|
|
5
|
+
// https://github.com/vikejs/vike/blob/c5a2de5e85262771f97851767c00ac35da69c64b/packages/vike/client/runtime-client-routing/navigate.ts#L4
|
|
4
6
|
const utils_js_1 = require("./utils.js");
|
|
5
7
|
function modifyUrlSameOrigin(url, modify) {
|
|
6
8
|
const urlParsed = (0, utils_js_1.parseUrl)(url, '/');
|
|
@@ -27,16 +29,19 @@ function modifyUrlSameOrigin(url, modify) {
|
|
|
27
29
|
const urlModified = (0, utils_js_1.createUrlFromComponents)(urlParsed.origin, pathname, search, hash);
|
|
28
30
|
return urlModified;
|
|
29
31
|
}
|
|
30
|
-
function resolveSearch(urlParsed,
|
|
32
|
+
function resolveSearch(urlParsed, modifySearch) {
|
|
31
33
|
let searchParams;
|
|
32
|
-
if (
|
|
34
|
+
if (modifySearch instanceof URLSearchParams) {
|
|
33
35
|
// Overwrite
|
|
34
|
-
searchParams =
|
|
36
|
+
searchParams = modifySearch;
|
|
35
37
|
}
|
|
36
38
|
else {
|
|
37
39
|
// Merge
|
|
38
|
-
const searchMap = (0, utils_js_1.objectFilter)({ ...urlParsed.search, ...
|
|
40
|
+
const searchMap = (0, utils_js_1.objectFilter)({ ...urlParsed.search, ...(0, utils_js_1.objectFilter)(modifySearch, isNotUndefined) }, (utils_js_1.isNotNullish_keyVal));
|
|
39
41
|
searchParams = new URLSearchParams(searchMap);
|
|
40
42
|
}
|
|
41
43
|
return '?' + searchParams.toString();
|
|
42
44
|
}
|
|
45
|
+
function isNotUndefined(arg) {
|
|
46
|
+
return arg[1] !== undefined;
|
|
47
|
+
}
|