vike 0.4.236 → 0.4.237-commit-8749e81
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 +21 -13
- package/dist/cjs/client/shared/getJsonSerializedInHtml.js +10 -1
- package/dist/cjs/client/shared/utils.js +1 -0
- 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 +127 -41
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +3 -1
- package/dist/cjs/node/runtime/html/serializeContext.js +25 -64
- 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 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +8 -34
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +50 -14
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +23 -9
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -5
- package/dist/cjs/node/runtime/renderPage.js +9 -8
- package/dist/cjs/node/runtime/utils.js +4 -0
- package/dist/cjs/node/shared/utils.js +1 -0
- package/dist/cjs/node/shared/virtualFileId.js +110 -0
- package/dist/cjs/node/vite/index.js +5 -3
- package/dist/cjs/node/vite/onLoad.js +5 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +31 -23
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +29 -13
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +20 -14
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +17 -5
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +6 -12
- package/dist/cjs/node/vite/plugins/pluginCommon.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +119 -73
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +8 -15
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +8 -9
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +7 -3
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +47 -0
- package/dist/cjs/node/vite/plugins/pluginPreview.js +11 -4
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +6 -13
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +11 -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 -11
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +67 -0
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +18 -17
- 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 +18 -0
- package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +10 -0
- 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 +56 -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/crawlPlusFiles.js +1 -3
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +8 -19
- package/dist/cjs/node/vite/utils.js +1 -0
- package/dist/cjs/shared/createGlobalContextShared.js +36 -15
- package/dist/cjs/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -20
- package/dist/cjs/shared/getProxyForPublicUsage.js +2 -2
- 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 +16 -16
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +7 -5
- package/dist/cjs/utils/cast.js +1 -1
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/cjs/utils/getViteRPC.js +79 -0
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +1 -0
- package/dist/cjs/utils/isRunnableDevEnvironment.js +9 -0
- package/dist/cjs/utils/virtualFileId.js +39 -0
- package/dist/esm/client/node.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +3 -3
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +14 -14
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +35 -48
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +3 -3
- 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 +5 -5
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +43 -30
- 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 +4 -4
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +3 -3
- 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 +4 -4
- package/dist/esm/client/shared/createGetGlobalContextClient.js +21 -13
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
- package/dist/esm/client/shared/getJsonSerializedInHtml.js +10 -1
- 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/client/shared/utils.d.ts +1 -0
- package/dist/esm/client/shared/utils.js +1 -0
- package/dist/esm/node/api/preview.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +49 -141
- package/dist/esm/node/prerender/runPrerender.js +4 -4
- package/dist/esm/node/runtime/globalContext.d.ts +43 -63
- package/dist/esm/node/runtime/globalContext.js +128 -42
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +4 -2
- package/dist/esm/node/runtime/html/serializeContext.d.ts +11 -6
- package/dist/esm/node/runtime/html/serializeContext.js +25 -64
- 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 +13 -36
- 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 -3
- 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 +8 -34
- 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 +26 -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 +30 -77
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -5
- package/dist/esm/node/runtime/renderPage.d.ts +13 -35
- package/dist/esm/node/runtime/renderPage.js +9 -8
- package/dist/esm/node/runtime/utils.d.ts +4 -0
- package/dist/esm/node/runtime/utils.js +4 -0
- package/dist/esm/node/shared/utils.d.ts +1 -0
- package/dist/esm/node/shared/utils.js +1 -0
- 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 +5 -3
- package/dist/esm/node/vite/onLoad.js +5 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +32 -24
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +3 -3
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +29 -13
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +21 -14
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +17 -5
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +7 -10
- package/dist/esm/node/vite/plugins/pluginCommon.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginCommon.js +1 -0
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +121 -75
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +6 -10
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +7 -8
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +6 -2
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +26 -0
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +45 -0
- 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} +11 -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 -11
- 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 +17 -16
- 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.d.ts +9 -0
- package/dist/esm/node/vite/shared/getMagicString.js +13 -0
- package/dist/esm/node/vite/shared/getManifestFilePathRelative.d.ts +2 -0
- package/dist/esm/node/vite/shared/getManifestFilePathRelative.js +8 -0
- 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 +58 -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/crawlPlusFiles.js +1 -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/node/vite/utils.d.ts +1 -0
- package/dist/esm/node/vite/utils.js +1 -0
- package/dist/esm/shared/createGlobalContextShared.d.ts +8 -8
- package/dist/esm/shared/createGlobalContextShared.js +38 -17
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.d.ts → parseVirtualFileExportsGlobalEntry.d.ts} +2 -2
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -20
- 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 +17 -17
- 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/assertSetup.js +7 -5
- package/dist/esm/utils/cast.d.ts +2 -2
- package/dist/esm/utils/cast.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +1 -0
- package/dist/esm/utils/getViteRPC.d.ts +6 -0
- package/dist/esm/utils/getViteRPC.js +77 -0
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.d.ts +7 -0
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -0
- package/dist/esm/utils/isRunnableDevEnvironment.d.ts +3 -0
- package/dist/esm/utils/isRunnableDevEnvironment.js +7 -0
- package/dist/esm/utils/objectFilter.d.ts +1 -1
- package/dist/esm/utils/virtualFileId.d.ts +6 -0
- package/dist/esm/{node/shared/virtualFiles.js → utils/virtualFileId.js} +15 -17
- package/package.json +16 -7
- package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +0 -29
- package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -39
- package/dist/cjs/node/shared/virtualFiles.js +0 -41
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -23
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +0 -10
- 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 -26
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.d.ts +0 -9
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -37
- package/dist/esm/node/shared/virtualFiles.d.ts +0 -8
- 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 -8
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { configDefinitionsBuiltIn };
|
|
2
2
|
import { assert, assertUsage } from '../../utils.js';
|
|
3
3
|
import { getConfigDefinedAt } from '../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
4
|
+
import { getConfigValueSourcesRelevant } from '../../plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js';
|
|
4
5
|
const configDefinitionsBuiltIn = {
|
|
5
6
|
onRenderHtml: {
|
|
6
7
|
env: { server: true },
|
|
@@ -95,6 +96,22 @@ const configDefinitionsBuiltIn = {
|
|
|
95
96
|
meta: {
|
|
96
97
|
env: { config: true },
|
|
97
98
|
},
|
|
99
|
+
serverOnlyHooks: {
|
|
100
|
+
env: { client: true },
|
|
101
|
+
eager: true,
|
|
102
|
+
_computed: (pageConfig) => {
|
|
103
|
+
const sources = ['data', 'onBeforeRender', 'onCreatePageContext']
|
|
104
|
+
.map((hookName) => getConfigValueSourcesRelevant(hookName, {
|
|
105
|
+
isForClientSide: false,
|
|
106
|
+
// TO-DO/eventually/remove-server-router: let's eventually remove support for Server Routing
|
|
107
|
+
isClientRouting: true,
|
|
108
|
+
}, pageConfig))
|
|
109
|
+
.flat(1)
|
|
110
|
+
// Server-only
|
|
111
|
+
.filter((source) => !source.configEnv.client);
|
|
112
|
+
return sources.length > 0;
|
|
113
|
+
},
|
|
114
|
+
},
|
|
98
115
|
// Whether the page loads:
|
|
99
116
|
// - Vike's client runtime
|
|
100
117
|
// - User's client hooks
|
|
@@ -102,7 +119,8 @@ const configDefinitionsBuiltIn = {
|
|
|
102
119
|
isClientRuntimeLoaded: {
|
|
103
120
|
env: { server: true, client: true },
|
|
104
121
|
eager: true,
|
|
105
|
-
_computed: (
|
|
122
|
+
_computed: (pageConfig) => {
|
|
123
|
+
const { configValueSources } = pageConfig;
|
|
106
124
|
{
|
|
107
125
|
const source = getConfigValueSource(configValueSources, 'clientHooks');
|
|
108
126
|
if (source) {
|
|
@@ -120,15 +138,25 @@ const configDefinitionsBuiltIn = {
|
|
|
120
138
|
!!getConfigEnv(configValueSources, 'Page')?.client);
|
|
121
139
|
},
|
|
122
140
|
},
|
|
141
|
+
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
123
142
|
onBeforeRenderEnv: {
|
|
124
143
|
env: { client: true },
|
|
125
144
|
eager: true,
|
|
126
|
-
_computed: (
|
|
145
|
+
_computed: (pageConfig) => {
|
|
146
|
+
const { configValueSources } = pageConfig;
|
|
147
|
+
return !isConfigSet(configValueSources, 'onBeforeRender')
|
|
148
|
+
? null
|
|
149
|
+
: getConfigEnv(configValueSources, 'onBeforeRender');
|
|
150
|
+
},
|
|
127
151
|
},
|
|
152
|
+
// TO-DO/soon/cumulative-hooks: remove and replace with new computed prop `clientOnlyHooks: string[]` (see other TO-DO/soon/cumulative-hooks entries)
|
|
128
153
|
dataEnv: {
|
|
129
154
|
env: { client: true },
|
|
130
155
|
eager: true,
|
|
131
|
-
_computed: (
|
|
156
|
+
_computed: (pageConfig) => {
|
|
157
|
+
const { configValueSources } = pageConfig;
|
|
158
|
+
return !isConfigSet(configValueSources, 'data') ? null : getConfigEnv(configValueSources, 'data');
|
|
159
|
+
},
|
|
132
160
|
},
|
|
133
161
|
hooksTimeout: {
|
|
134
162
|
env: { server: true, client: true },
|
|
@@ -30,9 +30,7 @@ async function crawlPlusFiles(userRootDir) {
|
|
|
30
30
|
: // Fallback to tinyglobby for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
31
31
|
filesGlob;
|
|
32
32
|
assert(files);
|
|
33
|
-
if (debug.isActivated) {
|
|
34
|
-
assert(filesGit);
|
|
35
|
-
assert(filesGlob);
|
|
33
|
+
if (debug.isActivated && filesGit && filesGlob) {
|
|
36
34
|
assertWarning(deepEqual(filesGlob.slice().sort(), filesGit.slice().sort()), "Git and glob results aren't matching.", { onlyOnce: false });
|
|
37
35
|
}
|
|
38
36
|
// Filter build files
|
|
@@ -7,13 +7,12 @@ export { isV1Design };
|
|
|
7
7
|
export { getConfVal };
|
|
8
8
|
export { getConfigDefinitionOptional };
|
|
9
9
|
export { getVikeConfigFromCliOrEnv };
|
|
10
|
-
export { isOverridden };
|
|
11
10
|
export type { VikeConfigInternal };
|
|
12
11
|
export { getVikeConfig };
|
|
13
12
|
export type { VikeConfig };
|
|
14
|
-
import type { PageConfigGlobalBuildTime,
|
|
13
|
+
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../types/PageConfig.js';
|
|
15
14
|
import { type ConfigDefinitionsInternal, type ConfigDefinitionInternal } from './resolveVikeConfigInternal/configDefinitionsBuiltIn.js';
|
|
16
|
-
import { type VikeConfigPublicGlobal, type
|
|
15
|
+
import { type VikeConfigPublicGlobal, type VikeConfigPublicPageEagerLoaded } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
17
16
|
import { type PlusFile } from './resolveVikeConfigInternal/getPlusFilesAll.js';
|
|
18
17
|
import type { PrerenderContextPublic } from '../../prerender/runPrerender.js';
|
|
19
18
|
import type { ResolvedConfig, UserConfig } from 'vite';
|
|
@@ -34,7 +33,7 @@ type VikeConfigInternal = {
|
|
|
34
33
|
config: VikeConfigPublicGlobal['config'];
|
|
35
34
|
_from: VikeConfigPublicGlobal['_from'];
|
|
36
35
|
pages: Record<string, // pageId
|
|
37
|
-
|
|
36
|
+
VikeConfigPublicPageEagerLoaded>;
|
|
38
37
|
_vikeConfigDependencies: Set<string>;
|
|
39
38
|
prerenderContext: PrerenderContext;
|
|
40
39
|
};
|
|
@@ -65,4 +64,3 @@ declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|
|
|
65
64
|
} | {
|
|
66
65
|
valueIsLoaded: false;
|
|
67
66
|
};
|
|
68
|
-
declare function isOverridden(source: ConfigValueSource, configName: string, pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime): boolean;
|
|
@@ -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,10 +9,10 @@ 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<
|
|
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<{
|
|
16
16
|
/**
|
|
17
17
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
18
18
|
*
|
|
@@ -20,7 +20,7 @@ declare function createGlobalContextShared<GlobalContextAddendum extends Record<
|
|
|
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<GlobalContextAddendum extends Record<
|
|
|
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,31 +1,51 @@
|
|
|
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
|
-
|
|
11
|
-
|
|
10
|
+
const globalObject_ = getGlobalObject('shared/createGlobalContextShared.ts', {});
|
|
11
|
+
// TO-DO/eventually use flat globalContext — like flat pageContext
|
|
12
|
+
async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
|
|
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)
|
|
14
|
+
addGlobalContextTmp, addGlobalContextAsync) {
|
|
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);
|
|
12
26
|
let isNewGlobalContext;
|
|
13
27
|
if (!globalObject.globalContext) {
|
|
28
|
+
// We set globalObject.globalContext early and before any async operations, so that getGlobalContextSync() can be used early.
|
|
29
|
+
// - Required by vike-vercel
|
|
14
30
|
globalObject.globalContext = globalContext;
|
|
15
31
|
isNewGlobalContext = false;
|
|
16
32
|
}
|
|
17
33
|
else {
|
|
18
34
|
isNewGlobalContext = true;
|
|
19
35
|
}
|
|
20
|
-
if (
|
|
21
|
-
//
|
|
36
|
+
if (addGlobalContext &&
|
|
37
|
+
// TO-DO/next-major-release: remove
|
|
22
38
|
globalContext._pageConfigs.length > 0) {
|
|
23
|
-
const
|
|
24
|
-
objectAssign(globalContext,
|
|
39
|
+
const globalContextAdded = addGlobalContext?.(globalContext);
|
|
40
|
+
objectAssign(globalContext, globalContextAdded);
|
|
25
41
|
}
|
|
26
42
|
else {
|
|
27
|
-
const
|
|
28
|
-
objectAssign(globalContext,
|
|
43
|
+
const globalContextAdded = await addGlobalContextTmp?.(globalContext);
|
|
44
|
+
objectAssign(globalContext, globalContextAdded);
|
|
45
|
+
}
|
|
46
|
+
{
|
|
47
|
+
const globalContextAddedAsync = await addGlobalContextAsync?.(globalContext);
|
|
48
|
+
objectAssign(globalContext, globalContextAddedAsync);
|
|
29
49
|
}
|
|
30
50
|
const onCreateGlobalContextHooks = getHookFromPageConfigGlobalCumulative(globalContext._pageConfigGlobal, 'onCreateGlobalContext');
|
|
31
51
|
let hooksCalled = false;
|
|
@@ -44,10 +64,11 @@ async function createGlobalContextShared(virtualFileExports, globalObject, addGl
|
|
|
44
64
|
objectAssign(globalObject.globalContext, globalContext, true);
|
|
45
65
|
}
|
|
46
66
|
}
|
|
67
|
+
resolve();
|
|
47
68
|
return globalObject.globalContext;
|
|
48
69
|
}
|
|
49
|
-
function createGlobalContextBase(
|
|
50
|
-
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(
|
|
70
|
+
function createGlobalContextBase(virtualFileExportsGlobalEntry) {
|
|
71
|
+
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(virtualFileExportsGlobalEntry);
|
|
51
72
|
const globalContext = {
|
|
52
73
|
/**
|
|
53
74
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
@@ -56,7 +77,7 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
56
77
|
*/
|
|
57
78
|
isGlobalContext: true,
|
|
58
79
|
_isOriginalObject: true,
|
|
59
|
-
|
|
80
|
+
_virtualFileExportsGlobalEntry: virtualFileExportsGlobalEntry,
|
|
60
81
|
_pageFilesAll: pageFilesAll,
|
|
61
82
|
_pageConfigs: pageConfigs,
|
|
62
83
|
_pageConfigGlobal: pageConfigGlobal,
|
|
@@ -68,14 +89,14 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
68
89
|
changeEnumerable(globalContext, '_isOriginalObject', false);
|
|
69
90
|
return globalContext;
|
|
70
91
|
}
|
|
71
|
-
function getConfigsAll(
|
|
72
|
-
const { pageFilesAll, pageConfigs, pageConfigGlobal } =
|
|
92
|
+
function getConfigsAll(virtualFileExportsGlobalEntry) {
|
|
93
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = parseVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry);
|
|
73
94
|
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
74
95
|
const vikeConfigPublicGlobal = resolveVikeConfigPublicGlobal({
|
|
75
96
|
pageConfigGlobalValues: pageConfigGlobal.configValues,
|
|
76
97
|
});
|
|
77
98
|
const vikeConfigPublicPagesEager = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
78
|
-
return
|
|
99
|
+
return resolveVikeConfigPublicPageEagerLoaded(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
|
|
79
100
|
}));
|
|
80
101
|
return {
|
|
81
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,27 +1,27 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { parseVirtualFileExportsGlobalEntry };
|
|
2
2
|
// TO-DO/next-major-release: remove old design code, and remove all assertions.
|
|
3
3
|
import { assert, hasProp, isCallable, isObject, cast, isArray } from '../utils.js';
|
|
4
4
|
import { assertExportValues } from './assert_exports_old_design.js';
|
|
5
5
|
import { getPageFileObject } from './getPageFileObject.js';
|
|
6
6
|
import { fileTypes } from './fileTypes.js';
|
|
7
|
-
import {
|
|
8
|
-
function
|
|
9
|
-
assert(hasProp(
|
|
10
|
-
assert(hasProp(
|
|
11
|
-
assert(hasProp(
|
|
12
|
-
assert(hasProp(
|
|
13
|
-
assert(hasProp(
|
|
14
|
-
assert(hasProp(
|
|
15
|
-
hasProp(
|
|
16
|
-
assert(hasProp(
|
|
17
|
-
assert(hasProp(
|
|
18
|
-
assert(hasProp(
|
|
19
|
-
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;
|
|
20
20
|
assertPageConfigsSerialized(pageConfigsSerialized);
|
|
21
21
|
assertPageConfigGlobalSerialized(pageConfigGlobalSerialized);
|
|
22
|
-
const { pageConfigs, pageConfigGlobal } =
|
|
22
|
+
const { pageConfigs, pageConfigGlobal } = parsePageConfigsSerialized(pageConfigsSerialized, pageConfigGlobalSerialized);
|
|
23
23
|
const pageFilesMap = {};
|
|
24
|
-
parseGlobResult(
|
|
24
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
25
25
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
26
26
|
const loadModule = globValue;
|
|
27
27
|
assertLoadModule(loadModule);
|
|
@@ -32,7 +32,7 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
|
-
parseGlobResult(
|
|
35
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
36
36
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
37
37
|
const loadModule = globValue;
|
|
38
38
|
assertLoadModule(loadModule);
|
|
@@ -45,20 +45,20 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
45
45
|
};
|
|
46
46
|
});
|
|
47
47
|
// `pageFilesEager` contains `.page.route.js` files
|
|
48
|
-
parseGlobResult(
|
|
48
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
49
49
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
50
50
|
const moduleExports = globValue;
|
|
51
51
|
assert(isObject(moduleExports));
|
|
52
52
|
pageFile.fileExports = moduleExports;
|
|
53
53
|
});
|
|
54
|
-
parseGlobResult(
|
|
54
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
55
55
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
56
56
|
const moduleExports = globValue;
|
|
57
57
|
assert(isObject(moduleExports));
|
|
58
58
|
assert(hasProp(moduleExports, 'exportNames', 'string[]'), pageFile.filePath);
|
|
59
59
|
pageFile.exportNames = moduleExports.exportNames;
|
|
60
60
|
});
|
|
61
|
-
|
|
61
|
+
virtualFileExportsGlobalEntry.pageFilesList.forEach((filePath) => {
|
|
62
62
|
pageFilesMap[filePath] = pageFilesMap[filePath] ?? getPageFileObject(filePath);
|
|
63
63
|
});
|
|
64
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;
|