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
|
@@ -8,10 +8,9 @@ export { isV1Design };
|
|
|
8
8
|
export { getConfVal };
|
|
9
9
|
export { getConfigDefinitionOptional };
|
|
10
10
|
export { getVikeConfigFromCliOrEnv };
|
|
11
|
-
export { isOverridden };
|
|
12
11
|
// Public usage
|
|
13
12
|
export { getVikeConfig };
|
|
14
|
-
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, assertKeys, objectKeys, objectFromEntries, unique, isCallable, makeFirst, lowerFirst, makeLast, assertIsSingleModuleInstance, genPromise, } from '../utils.js';
|
|
13
|
+
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, assertKeys, objectKeys, objectFromEntries, unique, isCallable, makeFirst, lowerFirst, makeLast, assertIsSingleModuleInstance, genPromise, checkType, objectAssign, } from '../utils.js';
|
|
15
14
|
import { configDefinitionsBuiltIn, } from './resolveVikeConfigInternal/configDefinitionsBuiltIn.js';
|
|
16
15
|
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, applyFilesystemRoutingRootEffect, } from './resolveVikeConfigInternal/filesystemRouting.js';
|
|
17
16
|
import { getViteDevServer } from '../../runtime/globalContext.js';
|
|
@@ -23,7 +22,7 @@ import { loadPointerImport, loadValueFile } from './resolveVikeConfigInternal/lo
|
|
|
23
22
|
import { resolvePointerImport } from './resolveVikeConfigInternal/resolvePointerImport.js';
|
|
24
23
|
import { getFilePathResolved } from './getFilePath.js';
|
|
25
24
|
import { getConfigValueBuildTime } from '../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
26
|
-
import { resolveVikeConfigPublicGlobal,
|
|
25
|
+
import { resolveVikeConfigPublicGlobal, resolveVikeConfigPublicPageEagerLoaded, } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
27
26
|
import { getConfigValuesBase, isJsonValue } from '../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
28
27
|
import { getPlusFilesAll, } from './resolveVikeConfigInternal/getPlusFilesAll.js';
|
|
29
28
|
import { getEnvVarObject } from './getEnvVarObject.js';
|
|
@@ -179,7 +178,7 @@ async function resolveVikeConfigInternal(userRootDir, vikeVitePluginOptions, esb
|
|
|
179
178
|
// pages
|
|
180
179
|
const vikeConfigPublicPagesEager = objectFromEntries(pageConfigs.map((pageConfig) => {
|
|
181
180
|
const pageConfigValues = getConfigValues(pageConfig, true);
|
|
182
|
-
return
|
|
181
|
+
return resolveVikeConfigPublicPageEagerLoaded(pageConfigGlobalValues, pageConfig, pageConfigValues);
|
|
183
182
|
}));
|
|
184
183
|
const prerenderContext = resolvePrerenderContext({
|
|
185
184
|
config: vikeConfigPublicGlobal.config,
|
|
@@ -287,15 +286,16 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
|
|
|
287
286
|
applyEffectsMetaEnv(configValueSources, configDefinitionsLocal);
|
|
288
287
|
applyEffectsConfVal(configValueSources, configDefinitionsLocal, plusFilesAll);
|
|
289
288
|
sortConfigValueSources(configValueSources, locationId);
|
|
290
|
-
const configValuesComputed = getComputed(configValueSources, configDefinitionsLocal);
|
|
291
289
|
const pageConfig = {
|
|
292
290
|
pageId: locationId,
|
|
293
291
|
...pageConfigRoute,
|
|
294
292
|
configDefinitions: configDefinitionsLocal,
|
|
295
293
|
plusFiles: plusFilesRelevant,
|
|
296
294
|
configValueSources,
|
|
297
|
-
configValuesComputed,
|
|
298
295
|
};
|
|
296
|
+
const configValuesComputed = getComputed(pageConfig);
|
|
297
|
+
objectAssign(pageConfig, { configValuesComputed });
|
|
298
|
+
checkType(pageConfig);
|
|
299
299
|
return pageConfig;
|
|
300
300
|
});
|
|
301
301
|
assertPageConfigs(pageConfigs);
|
|
@@ -362,7 +362,7 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
362
362
|
}
|
|
363
363
|
function getConfigValues(pageConfig, tolerateMissingValue) {
|
|
364
364
|
const configValues = {};
|
|
365
|
-
getConfigValuesBase(pageConfig,
|
|
365
|
+
getConfigValuesBase(pageConfig, { isForConfig: true }, null).forEach((entry) => {
|
|
366
366
|
if (entry.configValueBase.type === 'computed') {
|
|
367
367
|
assert('value' in entry); // Help TS
|
|
368
368
|
const { configValueBase, value, configName } = entry;
|
|
@@ -896,12 +896,12 @@ function applyEffectMetaEnv(configModFromEffect, configValueSources, configDefEf
|
|
|
896
896
|
});
|
|
897
897
|
});
|
|
898
898
|
}
|
|
899
|
-
function getComputed(
|
|
899
|
+
function getComputed(pageConfig) {
|
|
900
900
|
const configValuesComputed = {};
|
|
901
|
-
objectEntries(configDefinitions).forEach(([configName, configDef]) => {
|
|
901
|
+
objectEntries(pageConfig.configDefinitions).forEach(([configName, configDef]) => {
|
|
902
902
|
if (!configDef._computed)
|
|
903
903
|
return;
|
|
904
|
-
const value = configDef._computed(
|
|
904
|
+
const value = configDef._computed(pageConfig);
|
|
905
905
|
if (value === undefined)
|
|
906
906
|
return;
|
|
907
907
|
configValuesComputed[configName] = {
|
|
@@ -1097,17 +1097,6 @@ function isGlobalLocation(locationId, plusFilesAll) {
|
|
|
1097
1097
|
.map(([locationId]) => locationId);
|
|
1098
1098
|
return locationIdsPage.every((locId) => isInherited(locationId, locId));
|
|
1099
1099
|
}
|
|
1100
|
-
function isOverridden(source, configName, pageConfig) {
|
|
1101
|
-
const configDef = pageConfig.configDefinitions[configName];
|
|
1102
|
-
assert(configDef);
|
|
1103
|
-
if (configDef.cumulative)
|
|
1104
|
-
return false;
|
|
1105
|
-
const sources = pageConfig.configValueSources[configName];
|
|
1106
|
-
assert(sources);
|
|
1107
|
-
const idx = sources.indexOf(source);
|
|
1108
|
-
assert(idx >= 0);
|
|
1109
|
-
return idx > 0;
|
|
1110
|
-
}
|
|
1111
1100
|
function resolvePrerenderContext(vikeConfig) {
|
|
1112
1101
|
const { isPrerenderingEnabled, isPrerenderingEnabledForAllPages } = resolvePrerenderConfigGlobal(vikeConfig);
|
|
1113
1102
|
prerenderContext ?? (prerenderContext = {
|
|
@@ -9,7 +9,7 @@ import type { GlobalContextServerInternal } from '../node/runtime/globalContext.
|
|
|
9
9
|
import type { GlobalContextClientInternal } from '../client/runtime-client-routing/globalContext.js';
|
|
10
10
|
import { type Hook } from './hooks/getHook.js';
|
|
11
11
|
declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
12
|
-
declare function createGlobalContextShared<GlobalContextAdded extends Record<string, any>, GlobalContextAddedAsync extends Record<string, any>>(
|
|
12
|
+
declare function createGlobalContextShared<GlobalContextAdded extends Record<string, any>, GlobalContextAddedAsync extends Record<string, any>>(virtualFileExportsGlobalEntry: unknown, globalObject: {
|
|
13
13
|
globalContext?: Record<string, unknown>;
|
|
14
14
|
onCreateGlobalContextHooks?: Hook[];
|
|
15
15
|
}, addGlobalContext?: (globalContext: GlobalContextBase) => GlobalContextAdded, addGlobalContextTmp?: (globalContext: GlobalContextBase) => Promise<GlobalContextAdded>, addGlobalContextAsync?: (globalContext: GlobalContextBase) => Promise<GlobalContextAddedAsync>): Promise<{
|
|
@@ -20,7 +20,7 @@ declare function createGlobalContextShared<GlobalContextAdded extends Record<str
|
|
|
20
20
|
*/
|
|
21
21
|
isGlobalContext: true;
|
|
22
22
|
_isOriginalObject: true;
|
|
23
|
-
|
|
23
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
24
24
|
_pageFilesAll: PageFile[];
|
|
25
25
|
_pageConfigs: PageConfigRuntime[];
|
|
26
26
|
_pageConfigGlobal: import("../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -33,12 +33,12 @@ declare function createGlobalContextShared<GlobalContextAdded extends Record<str
|
|
|
33
33
|
};
|
|
34
34
|
config: import("../types/index.js").ConfigResolved;
|
|
35
35
|
pages: {
|
|
36
|
-
[k: string]: import("./page-configs/resolveVikeConfigPublic.js").
|
|
36
|
+
[k: string]: import("./page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
37
37
|
};
|
|
38
38
|
} & GlobalContextAdded & GlobalContextAddedAsync>;
|
|
39
39
|
type GlobalContextBasePublic = Pick<GlobalContextBase, 'config' | 'pages' | 'isGlobalContext'>;
|
|
40
40
|
type GlobalContextBase = ReturnType<typeof createGlobalContextBase>;
|
|
41
|
-
declare function createGlobalContextBase(
|
|
41
|
+
declare function createGlobalContextBase(virtualFileExportsGlobalEntry: unknown): {
|
|
42
42
|
/**
|
|
43
43
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
44
44
|
*
|
|
@@ -46,7 +46,7 @@ declare function createGlobalContextBase(virtualFileExports: unknown): {
|
|
|
46
46
|
*/
|
|
47
47
|
isGlobalContext: true;
|
|
48
48
|
_isOriginalObject: true;
|
|
49
|
-
|
|
49
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
50
50
|
_pageFilesAll: PageFile[];
|
|
51
51
|
_pageConfigs: PageConfigRuntime[];
|
|
52
52
|
_pageConfigGlobal: import("../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -59,6 +59,6 @@ declare function createGlobalContextBase(virtualFileExports: unknown): {
|
|
|
59
59
|
};
|
|
60
60
|
config: import("../types/index.js").ConfigResolved;
|
|
61
61
|
pages: {
|
|
62
|
-
[k: string]: import("./page-configs/resolveVikeConfigPublic.js").
|
|
62
|
+
[k: string]: import("./page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
63
63
|
};
|
|
64
64
|
};
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
export { createGlobalContextShared };
|
|
2
2
|
export { getGlobalContextSyncErrMsg };
|
|
3
|
-
import { changeEnumerable, objectAssign, objectReplace, unique } from './utils.js';
|
|
4
|
-
import {
|
|
5
|
-
import { resolveVikeConfigPublicGlobal,
|
|
3
|
+
import { changeEnumerable, genPromise, getGlobalObject, objectAssign, objectReplace, unique } from './utils.js';
|
|
4
|
+
import { parseVirtualFileExportsGlobalEntry } from './getPageFiles/parseVirtualFileExportsGlobalEntry.js';
|
|
5
|
+
import { resolveVikeConfigPublicGlobal, resolveVikeConfigPublicPageEagerLoaded, } from './page-configs/resolveVikeConfigPublic.js';
|
|
6
6
|
import { execHookGlobal } from './hooks/execHook.js';
|
|
7
7
|
import { prepareGlobalContextForPublicUsage } from './prepareGlobalContextForPublicUsage.js';
|
|
8
8
|
import { getHookFromPageConfigGlobalCumulative } from './hooks/getHook.js';
|
|
9
9
|
const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
10
|
-
|
|
10
|
+
const globalObject_ = getGlobalObject('shared/createGlobalContextShared.ts', {});
|
|
11
|
+
// TO-DO/eventually use flat globalContext — like flat pageContext
|
|
12
|
+
async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
|
|
11
13
|
// 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)
|
|
12
14
|
addGlobalContextTmp, addGlobalContextAsync) {
|
|
13
|
-
const
|
|
15
|
+
const { previousCallPromise } = globalObject_;
|
|
16
|
+
const { promise, resolve } = genPromise({
|
|
17
|
+
// Avoid this Cloudflare Worker error:
|
|
18
|
+
// ```console
|
|
19
|
+
// 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.
|
|
20
|
+
// ```
|
|
21
|
+
timeout: null,
|
|
22
|
+
});
|
|
23
|
+
globalObject_.previousCallPromise = promise;
|
|
24
|
+
await previousCallPromise;
|
|
25
|
+
const globalContext = createGlobalContextBase(virtualFileExportsGlobalEntry);
|
|
14
26
|
let isNewGlobalContext;
|
|
15
27
|
if (!globalObject.globalContext) {
|
|
16
28
|
// We set globalObject.globalContext early and before any async operations, so that getGlobalContextSync() can be used early.
|
|
@@ -22,7 +34,7 @@ addGlobalContextTmp, addGlobalContextAsync) {
|
|
|
22
34
|
isNewGlobalContext = true;
|
|
23
35
|
}
|
|
24
36
|
if (addGlobalContext &&
|
|
25
|
-
//
|
|
37
|
+
// TO-DO/next-major-release: remove
|
|
26
38
|
globalContext._pageConfigs.length > 0) {
|
|
27
39
|
const globalContextAdded = addGlobalContext?.(globalContext);
|
|
28
40
|
objectAssign(globalContext, globalContextAdded);
|
|
@@ -52,10 +64,11 @@ addGlobalContextTmp, addGlobalContextAsync) {
|
|
|
52
64
|
objectAssign(globalObject.globalContext, globalContext, true);
|
|
53
65
|
}
|
|
54
66
|
}
|
|
67
|
+
resolve();
|
|
55
68
|
return globalObject.globalContext;
|
|
56
69
|
}
|
|
57
|
-
function createGlobalContextBase(
|
|
58
|
-
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(
|
|
70
|
+
function createGlobalContextBase(virtualFileExportsGlobalEntry) {
|
|
71
|
+
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(virtualFileExportsGlobalEntry);
|
|
59
72
|
const globalContext = {
|
|
60
73
|
/**
|
|
61
74
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
@@ -64,7 +77,7 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
64
77
|
*/
|
|
65
78
|
isGlobalContext: true,
|
|
66
79
|
_isOriginalObject: true,
|
|
67
|
-
|
|
80
|
+
_virtualFileExportsGlobalEntry: virtualFileExportsGlobalEntry,
|
|
68
81
|
_pageFilesAll: pageFilesAll,
|
|
69
82
|
_pageConfigs: pageConfigs,
|
|
70
83
|
_pageConfigGlobal: pageConfigGlobal,
|
|
@@ -76,14 +89,14 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
76
89
|
changeEnumerable(globalContext, '_isOriginalObject', false);
|
|
77
90
|
return globalContext;
|
|
78
91
|
}
|
|
79
|
-
function getConfigsAll(
|
|
80
|
-
const { pageFilesAll, pageConfigs, pageConfigGlobal } =
|
|
92
|
+
function getConfigsAll(virtualFileExportsGlobalEntry) {
|
|
93
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = parseVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry);
|
|
81
94
|
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
82
95
|
const vikeConfigPublicGlobal = resolveVikeConfigPublicGlobal({
|
|
83
96
|
pageConfigGlobalValues: pageConfigGlobal.configValues,
|
|
84
97
|
});
|
|
85
98
|
const vikeConfigPublicPagesEager = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
86
|
-
return
|
|
99
|
+
return resolveVikeConfigPublicPageEagerLoaded(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
|
|
87
100
|
}));
|
|
88
101
|
return {
|
|
89
102
|
pageFilesAll,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { parseVirtualFileExportsGlobalEntry };
|
|
2
2
|
import { type PageFile } from './getPageFileObject.js';
|
|
3
3
|
import type { PageConfigRuntime, PageConfigGlobalRuntime } from '../../types/PageConfig.js';
|
|
4
|
-
declare function
|
|
4
|
+
declare function parseVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry: unknown): {
|
|
5
5
|
pageFilesAll: PageFile[];
|
|
6
6
|
pageConfigs: PageConfigRuntime[];
|
|
7
7
|
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
export {
|
|
2
|
-
// TODO/now: rename parseVirtualFileExportsEntryGlobal
|
|
3
|
-
// TODO/now: merge or collocate following both files?
|
|
4
|
-
// ```filesystem
|
|
5
|
-
// vike/packages/vike/shared/getPageFiles/parseVirtualFileExports.ts
|
|
6
|
-
// vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
7
|
-
// ```
|
|
1
|
+
export { parseVirtualFileExportsGlobalEntry };
|
|
8
2
|
// TO-DO/next-major-release: remove old design code, and remove all assertions.
|
|
9
3
|
import { assert, hasProp, isCallable, isObject, cast, isArray } from '../utils.js';
|
|
10
4
|
import { assertExportValues } from './assert_exports_old_design.js';
|
|
11
5
|
import { getPageFileObject } from './getPageFileObject.js';
|
|
12
6
|
import { fileTypes } from './fileTypes.js';
|
|
13
|
-
import {
|
|
14
|
-
function
|
|
15
|
-
assert(hasProp(
|
|
16
|
-
assert(hasProp(
|
|
17
|
-
assert(hasProp(
|
|
18
|
-
assert(hasProp(
|
|
19
|
-
assert(hasProp(
|
|
20
|
-
assert(hasProp(
|
|
21
|
-
hasProp(
|
|
22
|
-
assert(hasProp(
|
|
23
|
-
assert(hasProp(
|
|
24
|
-
assert(hasProp(
|
|
25
|
-
const { pageConfigsSerialized, pageConfigGlobalSerialized } =
|
|
7
|
+
import { parsePageConfigsSerialized } from '../page-configs/serialize/parsePageConfigsSerialized.js';
|
|
8
|
+
function parseVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry) {
|
|
9
|
+
assert(hasProp(virtualFileExportsGlobalEntry, 'pageFilesLazy', 'object'));
|
|
10
|
+
assert(hasProp(virtualFileExportsGlobalEntry, 'pageFilesEager', 'object'));
|
|
11
|
+
assert(hasProp(virtualFileExportsGlobalEntry, 'pageFilesExportNamesLazy', 'object'));
|
|
12
|
+
assert(hasProp(virtualFileExportsGlobalEntry, 'pageFilesExportNamesEager', 'object'));
|
|
13
|
+
assert(hasProp(virtualFileExportsGlobalEntry.pageFilesLazy, '.page'));
|
|
14
|
+
assert(hasProp(virtualFileExportsGlobalEntry.pageFilesLazy, '.page.client') ||
|
|
15
|
+
hasProp(virtualFileExportsGlobalEntry.pageFilesLazy, '.page.server'));
|
|
16
|
+
assert(hasProp(virtualFileExportsGlobalEntry, 'pageFilesList', 'string[]'));
|
|
17
|
+
assert(hasProp(virtualFileExportsGlobalEntry, 'pageConfigsSerialized'));
|
|
18
|
+
assert(hasProp(virtualFileExportsGlobalEntry, 'pageConfigGlobalSerialized'));
|
|
19
|
+
const { pageConfigsSerialized, pageConfigGlobalSerialized } = virtualFileExportsGlobalEntry;
|
|
26
20
|
assertPageConfigsSerialized(pageConfigsSerialized);
|
|
27
21
|
assertPageConfigGlobalSerialized(pageConfigGlobalSerialized);
|
|
28
|
-
const { pageConfigs, pageConfigGlobal } =
|
|
22
|
+
const { pageConfigs, pageConfigGlobal } = parsePageConfigsSerialized(pageConfigsSerialized, pageConfigGlobalSerialized);
|
|
29
23
|
const pageFilesMap = {};
|
|
30
|
-
parseGlobResult(
|
|
24
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
31
25
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
32
26
|
const loadModule = globValue;
|
|
33
27
|
assertLoadModule(loadModule);
|
|
@@ -38,7 +32,7 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
38
32
|
}
|
|
39
33
|
};
|
|
40
34
|
});
|
|
41
|
-
parseGlobResult(
|
|
35
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
42
36
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
43
37
|
const loadModule = globValue;
|
|
44
38
|
assertLoadModule(loadModule);
|
|
@@ -51,20 +45,20 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
51
45
|
};
|
|
52
46
|
});
|
|
53
47
|
// `pageFilesEager` contains `.page.route.js` files
|
|
54
|
-
parseGlobResult(
|
|
48
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
55
49
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
56
50
|
const moduleExports = globValue;
|
|
57
51
|
assert(isObject(moduleExports));
|
|
58
52
|
pageFile.fileExports = moduleExports;
|
|
59
53
|
});
|
|
60
|
-
parseGlobResult(
|
|
54
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
61
55
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
62
56
|
const moduleExports = globValue;
|
|
63
57
|
assert(isObject(moduleExports));
|
|
64
58
|
assert(hasProp(moduleExports, 'exportNames', 'string[]'), pageFile.filePath);
|
|
65
59
|
pageFile.exportNames = moduleExports.exportNames;
|
|
66
60
|
});
|
|
67
|
-
|
|
61
|
+
virtualFileExportsGlobalEntry.pageFilesList.forEach((filePath) => {
|
|
68
62
|
pageFilesMap[filePath] = pageFilesMap[filePath] ?? getPageFileObject(filePath);
|
|
69
63
|
});
|
|
70
64
|
const pageFilesAll = Object.values(pageFilesMap);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { PageFile } from './getPageFiles/getPageFileObject.js';
|
|
2
|
-
export type { ExportsAll,
|
|
2
|
+
export type { ExportsAll, VikeConfigPublicPageLazyLoaded } from './page-configs/resolveVikeConfigPublic.js';
|
|
3
3
|
export { getPageFilesClientSide } from './getPageFiles/getAllPageIdFiles.js';
|
|
4
4
|
export { getPageFilesServerSide } from './getPageFiles/getAllPageIdFiles.js';
|
|
@@ -11,14 +11,14 @@ export { isUserHookError };
|
|
|
11
11
|
export type { PageContextExecHook };
|
|
12
12
|
import type { PageContextClient, PageContextServer } from '../../types/PageContext.js';
|
|
13
13
|
import type { Hook, HookLoc } from './getHook.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { VikeConfigPublicPageLazyLoaded } from '../getPageFiles.js';
|
|
15
15
|
import type { HookName, HookNameGlobal } from '../../types/Config.js';
|
|
16
16
|
import type { PageConfigGlobalRuntime } from '../../types/PageConfig.js';
|
|
17
17
|
import type { PageContextForPublicUsageServer } from '../../node/runtime/renderPage/preparePageContextForPublicUsageServer.js';
|
|
18
18
|
import type { PageContextForPublicUsageClientShared } from '../../client/shared/preparePageContextForPublicUsageClientShared.js';
|
|
19
19
|
import { type PageContextPrepareMinimum } from '../preparePageContextForPublicUsage.js';
|
|
20
20
|
import type { GlobalContextPrepareMinimum } from '../prepareGlobalContextForPublicUsage.js';
|
|
21
|
-
type PageContextExecHook =
|
|
21
|
+
type PageContextExecHook = VikeConfigPublicPageLazyLoaded & PageContextForPublicUsage;
|
|
22
22
|
type PageContextForPublicUsage = PageContextForPublicUsageServer | PageContextForPublicUsageClientShared;
|
|
23
23
|
type HookWithResult = Hook & {
|
|
24
24
|
hookReturn: unknown;
|
|
@@ -9,7 +9,7 @@ export type { HookLoc };
|
|
|
9
9
|
export type { HookTimeout };
|
|
10
10
|
export type { HooksTimeoutProvidedByUser };
|
|
11
11
|
export { getHookTimeoutDefault };
|
|
12
|
-
import type {
|
|
12
|
+
import type { VikeConfigPublicPageLazyLoaded } from '../getPageFiles.js';
|
|
13
13
|
import type { HookNameOld, HookNamePage, HookNameGlobal, HookName } from '../../types/Config.js';
|
|
14
14
|
import type { PageConfigGlobalRuntime, PageConfigRuntime } from '../../types/PageConfig.js';
|
|
15
15
|
import type { GlobalContextPrepareMinimum } from '../prepareGlobalContextForPublicUsage.js';
|
|
@@ -28,8 +28,8 @@ type HookTimeout = {
|
|
|
28
28
|
warning: number | false;
|
|
29
29
|
};
|
|
30
30
|
type HooksTimeoutProvidedByUser = false | Partial<Record<HookNameOld, false | Partial<HookTimeout>>>;
|
|
31
|
-
declare function getHookFromPageContext(pageContext:
|
|
32
|
-
declare function getHookFromPageContextNew(hookName: HookName, pageContext:
|
|
31
|
+
declare function getHookFromPageContext(pageContext: VikeConfigPublicPageLazyLoaded, hookName: HookNameOld): null | Hook;
|
|
32
|
+
declare function getHookFromPageContextNew(hookName: HookName, pageContext: VikeConfigPublicPageLazyLoaded): Hook[];
|
|
33
33
|
declare function getHookFromPageConfig(pageConfig: PageConfigRuntime, hookName: HookNamePage): null | Hook;
|
|
34
34
|
declare function getHookFromPageConfigGlobal(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): null | Hook;
|
|
35
35
|
declare function getHookFromPageConfigGlobalCumulative(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): Hook[];
|
|
@@ -5,5 +5,5 @@ type ModifyUrlSameOriginOptions = {
|
|
|
5
5
|
search?: Search | null;
|
|
6
6
|
pathname?: string;
|
|
7
7
|
};
|
|
8
|
-
type Search = Record<string, string | null> | URLSearchParams;
|
|
8
|
+
type Search = Record<string, string | null | undefined> | URLSearchParams;
|
|
9
9
|
declare function modifyUrlSameOrigin(url: string, modify: ModifyUrlSameOriginOptions): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { modifyUrlSameOrigin };
|
|
2
|
+
// We don't move modifyUrlSameOrigin() to the modifyUrl.ts file because we plan to use modifyUrlSameOrigin() on the client-side:
|
|
3
|
+
// https://github.com/vikejs/vike/blob/c5a2de5e85262771f97851767c00ac35da69c64b/packages/vike/client/runtime-client-routing/navigate.ts#L4
|
|
2
4
|
import { createUrlFromComponents, isNotNullish_keyVal, parseUrl, objectFilter, assertUsageUrlPathnameAbsolute, } from './utils.js';
|
|
3
5
|
function modifyUrlSameOrigin(url, modify) {
|
|
4
6
|
const urlParsed = parseUrl(url, '/');
|
|
@@ -25,16 +27,19 @@ function modifyUrlSameOrigin(url, modify) {
|
|
|
25
27
|
const urlModified = createUrlFromComponents(urlParsed.origin, pathname, search, hash);
|
|
26
28
|
return urlModified;
|
|
27
29
|
}
|
|
28
|
-
function resolveSearch(urlParsed,
|
|
30
|
+
function resolveSearch(urlParsed, modifySearch) {
|
|
29
31
|
let searchParams;
|
|
30
|
-
if (
|
|
32
|
+
if (modifySearch instanceof URLSearchParams) {
|
|
31
33
|
// Overwrite
|
|
32
|
-
searchParams =
|
|
34
|
+
searchParams = modifySearch;
|
|
33
35
|
}
|
|
34
36
|
else {
|
|
35
37
|
// Merge
|
|
36
|
-
const searchMap = objectFilter({ ...urlParsed.search, ...
|
|
38
|
+
const searchMap = objectFilter({ ...urlParsed.search, ...objectFilter(modifySearch, isNotUndefined) }, (isNotNullish_keyVal));
|
|
37
39
|
searchParams = new URLSearchParams(searchMap);
|
|
38
40
|
}
|
|
39
41
|
return '?' + searchParams.toString();
|
|
40
42
|
}
|
|
43
|
+
function isNotUndefined(arg) {
|
|
44
|
+
return arg[1] !== undefined;
|
|
45
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { loadPageEntry };
|
|
2
|
+
import { assert, objectAssign } from '../utils.js';
|
|
3
|
+
import { parseConfigValuesSerialized } from './serialize/parsePageConfigsSerialized.js';
|
|
4
|
+
async function loadPageEntry(pageConfig, isDev) {
|
|
5
|
+
if ('isPageEntryLoaded' in pageConfig &&
|
|
6
|
+
// We don't need to cache in dev, since Vite already caches the virtual module
|
|
7
|
+
!isDev) {
|
|
8
|
+
return pageConfig;
|
|
9
|
+
}
|
|
10
|
+
const { moduleId, moduleExportsPromise } = pageConfig.loadVirtualFilePageEntry();
|
|
11
|
+
const virtualFileExportsPageEntry = await moduleExportsPromise;
|
|
12
|
+
// `configValuesLoaded` is sometimes `undefined` https://github.com/vikejs/vike/discussions/2092
|
|
13
|
+
if (!virtualFileExportsPageEntry)
|
|
14
|
+
assert(false, { moduleExportsPromise, virtualFileExportsPageEntry, moduleId });
|
|
15
|
+
const configValues = parseVirtualFileExportsPageEntry(virtualFileExportsPageEntry);
|
|
16
|
+
Object.assign(pageConfig.configValues, configValues);
|
|
17
|
+
objectAssign(pageConfig, { isPageEntryLoaded: true });
|
|
18
|
+
return pageConfig;
|
|
19
|
+
}
|
|
20
|
+
function parseVirtualFileExportsPageEntry(virtualFileExportsPageEntry) {
|
|
21
|
+
const configValues = parseConfigValuesSerialized(virtualFileExportsPageEntry.configValuesSerialized);
|
|
22
|
+
return configValues;
|
|
23
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { resolveVikeConfigPublicGlobal };
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { resolveVikeConfigPublicPageEagerLoaded };
|
|
3
|
+
export { resolveVikeConfigPublicPageLazyLoaded };
|
|
4
4
|
export type { VikeConfigPublicGlobal };
|
|
5
|
-
export type {
|
|
6
|
-
export type {
|
|
5
|
+
export type { VikeConfigPublicPageEagerLoaded };
|
|
6
|
+
export type { VikeConfigPublicPageLazyLoaded };
|
|
7
7
|
export type { Source };
|
|
8
8
|
export type { Sources };
|
|
9
9
|
export type { From };
|
|
@@ -35,7 +35,7 @@ type ConfigEntries = Record<string, {
|
|
|
35
35
|
configDefinedAt: ConfigDefinedAtOptional;
|
|
36
36
|
configDefinedByFile: string | null;
|
|
37
37
|
}[]>;
|
|
38
|
-
type
|
|
38
|
+
type VikeConfigPublicPageLazyLoaded = {
|
|
39
39
|
config: ConfigResolved;
|
|
40
40
|
source: Source;
|
|
41
41
|
sources: Sources;
|
|
@@ -90,12 +90,12 @@ type WithRoute = {
|
|
|
90
90
|
route?: undefined;
|
|
91
91
|
isErrorPage: true;
|
|
92
92
|
};
|
|
93
|
-
type
|
|
93
|
+
type VikeConfigPublicPageEagerLoaded = VikeConfigPublic & WithRoute;
|
|
94
94
|
type VikeConfigPublicGlobal = VikeConfigPublic;
|
|
95
|
-
declare function
|
|
95
|
+
declare function resolveVikeConfigPublicPageEagerLoaded(pageConfigGlobalValues: ConfigValues, pageConfig: PageConfigRuntime | PageConfigBuildTime, pageConfigValues: ConfigValues): [string, VikeConfigPublicPageEagerLoaded];
|
|
96
96
|
declare function resolveVikeConfigPublicGlobal({ pageConfigGlobalValues, }: {
|
|
97
97
|
pageConfigGlobalValues: ConfigValues;
|
|
98
98
|
}): VikeConfigPublicGlobal;
|
|
99
|
-
declare function
|
|
99
|
+
declare function resolveVikeConfigPublicPageLazyLoaded(pageFiles: PageFile[], // V0.4 design
|
|
100
100
|
pageConfig: PageConfigRuntimeLoaded | null, // V1 design
|
|
101
|
-
pageConfigGlobal: PageConfigGlobalRuntime):
|
|
101
|
+
pageConfigGlobal: PageConfigGlobalRuntime): VikeConfigPublicPageLazyLoaded;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// TO-DO/soon/same-api: use public API internally?
|
|
2
2
|
// TO-DO/soon/flat-pageContext: rename definedAt => definedBy
|
|
3
3
|
export { resolveVikeConfigPublicGlobal };
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { resolveVikeConfigPublicPageEagerLoaded };
|
|
5
|
+
export { resolveVikeConfigPublicPageLazyLoaded };
|
|
6
6
|
import { assertDefaultExports, forbiddenDefaultExports } from '../getPageFiles/assert_exports_old_design.js';
|
|
7
7
|
import { getConfigDefinedAtOptional, getDefinedAtString } from './getConfigDefinedAt.js';
|
|
8
8
|
import { getConfigValueFilePathToShowToUser } from './helpers.js';
|
|
9
9
|
import { assert, isObject, assertWarning, assertUsage, makeLast, isBrowser, isScriptFile, isTemplateFile, objectDefineProperty, } from '../utils.js';
|
|
10
10
|
import pc from '@brillout/picocolors';
|
|
11
|
-
function
|
|
11
|
+
function resolveVikeConfigPublicPageEagerLoaded(pageConfigGlobalValues, pageConfig, pageConfigValues) {
|
|
12
12
|
const vikeConfigPublicPage_ = resolveVikeConfigPublic_base({ pageConfigGlobalValues, pageConfigValues });
|
|
13
13
|
const vikeConfigPublicPage = getPublicCopy(vikeConfigPublicPage_);
|
|
14
14
|
let page;
|
|
@@ -43,7 +43,7 @@ function resolveVikeConfigPublicGlobal({ pageConfigGlobalValues, }) {
|
|
|
43
43
|
const vikeConfigPublicGlobal = resolveVikeConfigPublic_V1Design({ configValues: pageConfigGlobalValues });
|
|
44
44
|
return getPublicCopy(vikeConfigPublicGlobal);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function resolveVikeConfigPublicPageLazyLoaded(pageFiles, // V0.4 design
|
|
47
47
|
pageConfig, // V1 design
|
|
48
48
|
pageConfigGlobal) {
|
|
49
49
|
const config = {};
|
|
@@ -7,7 +7,7 @@ import type { ConfigValueStandard, ConfigValueComputed, ConfigValueCumulative, P
|
|
|
7
7
|
type PageConfigRuntimeSerialized = PageConfigCommon & {
|
|
8
8
|
/** Config values that are serializable and loaded eagerly such as config.passToClient */
|
|
9
9
|
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
10
|
-
|
|
10
|
+
loadVirtualFilePageEntry: PageConfigRuntime['loadVirtualFilePageEntry'];
|
|
11
11
|
};
|
|
12
12
|
type PageConfigGlobalRuntimeSerialized = {
|
|
13
13
|
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { parsePageConfigsSerialized };
|
|
2
2
|
export { parseConfigValuesSerialized };
|
|
3
3
|
import type { ConfigValues, PageConfigRuntime, PageConfigGlobalRuntime } from '../../../types/PageConfig.js';
|
|
4
4
|
import type { PageConfigGlobalRuntimeSerialized, PageConfigRuntimeSerialized } from './PageConfigSerialized.js';
|
|
5
5
|
import type { ConfigValueSerialized } from './PageConfigSerialized.js';
|
|
6
|
-
declare function
|
|
6
|
+
declare function parsePageConfigsSerialized(pageConfigsSerialized: PageConfigRuntimeSerialized[], pageConfigGlobalSerialized: PageConfigGlobalRuntimeSerialized): {
|
|
7
7
|
pageConfigs: PageConfigRuntime[];
|
|
8
8
|
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
9
9
|
};
|
package/dist/esm/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { parsePageConfigsSerialized };
|
|
2
2
|
export { parseConfigValuesSerialized };
|
|
3
3
|
import { assert, assertUsage, isCallable } from '../../utils.js';
|
|
4
4
|
import { getConfigDefinedAt } from '../getConfigDefinedAt.js';
|
|
5
5
|
import { parseTransform } from '@brillout/json-serializer/parse';
|
|
6
6
|
import { assertPlusFileExport } from '../assertPlusFileExport.js';
|
|
7
|
-
function
|
|
7
|
+
function parsePageConfigsSerialized(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
8
8
|
// pageConfigs
|
|
9
9
|
const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
|
|
10
10
|
const configValues = parseConfigValuesSerialized(pageConfigSerialized.configValuesSerialized);
|
|
@@ -3,9 +3,10 @@ export { getConfigValuesBase };
|
|
|
3
3
|
export { isJsonValue };
|
|
4
4
|
export type { FilesEnv };
|
|
5
5
|
import type { ConfigEnvInternal, ConfigValueSource, DefinedAt, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../../../types/PageConfig.js';
|
|
6
|
-
|
|
6
|
+
import { type RuntimeEnv } from '../../../node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
7
|
+
declare function serializeConfigValues(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, importStatements: string[], filesEnv: FilesEnv, runtimeEnv: RuntimeEnv, tabspace: string, isEager: boolean | null): string[];
|
|
7
8
|
declare function isJsonValue(value: unknown): boolean;
|
|
8
|
-
declare function getConfigValuesBase(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime,
|
|
9
|
+
declare function getConfigValuesBase(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, runtimeEnv: RuntimeEnv, isEager: boolean | null): ConfigValuesBase;
|
|
9
10
|
type ConfigValuesBase = ({
|
|
10
11
|
configValueBase: {
|
|
11
12
|
type: 'computed';
|