vike 0.4.236 → 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 +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 +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/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 +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/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
|
@@ -12,7 +12,6 @@ exports.isV1Design = isV1Design;
|
|
|
12
12
|
exports.getConfVal = getConfVal;
|
|
13
13
|
exports.getConfigDefinitionOptional = getConfigDefinitionOptional;
|
|
14
14
|
exports.getVikeConfigFromCliOrEnv = getVikeConfigFromCliOrEnv;
|
|
15
|
-
exports.isOverridden = isOverridden;
|
|
16
15
|
exports.getVikeConfig = getVikeConfig;
|
|
17
16
|
const utils_js_1 = require("../utils.js");
|
|
18
17
|
const configDefinitionsBuiltIn_js_1 = require("./resolveVikeConfigInternal/configDefinitionsBuiltIn.js");
|
|
@@ -182,7 +181,7 @@ async function resolveVikeConfigInternal(userRootDir, vikeVitePluginOptions, esb
|
|
|
182
181
|
// pages
|
|
183
182
|
const vikeConfigPublicPagesEager = (0, utils_js_1.objectFromEntries)(pageConfigs.map((pageConfig) => {
|
|
184
183
|
const pageConfigValues = getConfigValues(pageConfig, true);
|
|
185
|
-
return (0, resolveVikeConfigPublic_js_1.
|
|
184
|
+
return (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicPageEagerLoaded)(pageConfigGlobalValues, pageConfig, pageConfigValues);
|
|
186
185
|
}));
|
|
187
186
|
const prerenderContext = resolvePrerenderContext({
|
|
188
187
|
config: vikeConfigPublicGlobal.config,
|
|
@@ -290,15 +289,16 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
|
|
|
290
289
|
applyEffectsMetaEnv(configValueSources, configDefinitionsLocal);
|
|
291
290
|
applyEffectsConfVal(configValueSources, configDefinitionsLocal, plusFilesAll);
|
|
292
291
|
sortConfigValueSources(configValueSources, locationId);
|
|
293
|
-
const configValuesComputed = getComputed(configValueSources, configDefinitionsLocal);
|
|
294
292
|
const pageConfig = {
|
|
295
293
|
pageId: locationId,
|
|
296
294
|
...pageConfigRoute,
|
|
297
295
|
configDefinitions: configDefinitionsLocal,
|
|
298
296
|
plusFiles: plusFilesRelevant,
|
|
299
297
|
configValueSources,
|
|
300
|
-
configValuesComputed,
|
|
301
298
|
};
|
|
299
|
+
const configValuesComputed = getComputed(pageConfig);
|
|
300
|
+
(0, utils_js_1.objectAssign)(pageConfig, { configValuesComputed });
|
|
301
|
+
(0, utils_js_1.checkType)(pageConfig);
|
|
302
302
|
return pageConfig;
|
|
303
303
|
});
|
|
304
304
|
assertPageConfigs(pageConfigs);
|
|
@@ -365,7 +365,7 @@ function assertOnBeforeRenderEnv(pageConfig) {
|
|
|
365
365
|
}
|
|
366
366
|
function getConfigValues(pageConfig, tolerateMissingValue) {
|
|
367
367
|
const configValues = {};
|
|
368
|
-
(0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig,
|
|
368
|
+
(0, serializeConfigValues_js_1.getConfigValuesBase)(pageConfig, { isForConfig: true }, null).forEach((entry) => {
|
|
369
369
|
if (entry.configValueBase.type === 'computed') {
|
|
370
370
|
(0, utils_js_1.assert)('value' in entry); // Help TS
|
|
371
371
|
const { configValueBase, value, configName } = entry;
|
|
@@ -899,12 +899,12 @@ function applyEffectMetaEnv(configModFromEffect, configValueSources, configDefEf
|
|
|
899
899
|
});
|
|
900
900
|
});
|
|
901
901
|
}
|
|
902
|
-
function getComputed(
|
|
902
|
+
function getComputed(pageConfig) {
|
|
903
903
|
const configValuesComputed = {};
|
|
904
|
-
(0, utils_js_1.objectEntries)(configDefinitions).forEach(([configName, configDef]) => {
|
|
904
|
+
(0, utils_js_1.objectEntries)(pageConfig.configDefinitions).forEach(([configName, configDef]) => {
|
|
905
905
|
if (!configDef._computed)
|
|
906
906
|
return;
|
|
907
|
-
const value = configDef._computed(
|
|
907
|
+
const value = configDef._computed(pageConfig);
|
|
908
908
|
if (value === undefined)
|
|
909
909
|
return;
|
|
910
910
|
configValuesComputed[configName] = {
|
|
@@ -1100,17 +1100,6 @@ function isGlobalLocation(locationId, plusFilesAll) {
|
|
|
1100
1100
|
.map(([locationId]) => locationId);
|
|
1101
1101
|
return locationIdsPage.every((locId) => (0, filesystemRouting_js_1.isInherited)(locationId, locId));
|
|
1102
1102
|
}
|
|
1103
|
-
function isOverridden(source, configName, pageConfig) {
|
|
1104
|
-
const configDef = pageConfig.configDefinitions[configName];
|
|
1105
|
-
(0, utils_js_1.assert)(configDef);
|
|
1106
|
-
if (configDef.cumulative)
|
|
1107
|
-
return false;
|
|
1108
|
-
const sources = pageConfig.configValueSources[configName];
|
|
1109
|
-
(0, utils_js_1.assert)(sources);
|
|
1110
|
-
const idx = sources.indexOf(source);
|
|
1111
|
-
(0, utils_js_1.assert)(idx >= 0);
|
|
1112
|
-
return idx > 0;
|
|
1113
|
-
}
|
|
1114
1103
|
function resolvePrerenderContext(vikeConfig) {
|
|
1115
1104
|
const { isPrerenderingEnabled, isPrerenderingEnabledForAllPages } = (0, resolvePrerenderConfig_js_1.resolvePrerenderConfigGlobal)(vikeConfig);
|
|
1116
1105
|
prerenderContext ?? (prerenderContext = {
|
|
@@ -42,3 +42,4 @@ __exportStar(require("../../utils/isDocker.js"), exports);
|
|
|
42
42
|
__exportStar(require("../../utils/isVitest.js"), exports);
|
|
43
43
|
__exportStar(require("../../utils/rollupSourceMap.js"), exports);
|
|
44
44
|
__exportStar(require("../../utils/isImportPath.js"), exports);
|
|
45
|
+
__exportStar(require("../../utils/virtualFileId.js"), exports);
|
|
@@ -3,32 +3,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGlobalContextSyncErrMsg = void 0;
|
|
4
4
|
exports.createGlobalContextShared = createGlobalContextShared;
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
|
-
const
|
|
6
|
+
const parseVirtualFileExportsGlobalEntry_js_1 = require("./getPageFiles/parseVirtualFileExportsGlobalEntry.js");
|
|
7
7
|
const resolveVikeConfigPublic_js_1 = require("./page-configs/resolveVikeConfigPublic.js");
|
|
8
8
|
const execHook_js_1 = require("./hooks/execHook.js");
|
|
9
9
|
const prepareGlobalContextForPublicUsage_js_1 = require("./prepareGlobalContextForPublicUsage.js");
|
|
10
10
|
const getHook_js_1 = require("./hooks/getHook.js");
|
|
11
11
|
const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
12
12
|
exports.getGlobalContextSyncErrMsg = getGlobalContextSyncErrMsg;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const globalObject_ = (0, utils_js_1.getGlobalObject)('shared/createGlobalContextShared.ts', {});
|
|
14
|
+
// TO-DO/eventually use flat globalContext — like flat pageContext
|
|
15
|
+
async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
|
|
16
|
+
// TO-DO/next-major-release: we'll be able to remove addGlobalContextTmp after loadPageRoutes() is sync (it will be sync after we remove the old design)
|
|
17
|
+
addGlobalContextTmp, addGlobalContextAsync) {
|
|
18
|
+
const { previousCallPromise } = globalObject_;
|
|
19
|
+
const { promise, resolve } = (0, utils_js_1.genPromise)({
|
|
20
|
+
// Avoid this Cloudflare Worker error:
|
|
21
|
+
// ```console
|
|
22
|
+
// Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler.
|
|
23
|
+
// ```
|
|
24
|
+
timeout: null,
|
|
25
|
+
});
|
|
26
|
+
globalObject_.previousCallPromise = promise;
|
|
27
|
+
await previousCallPromise;
|
|
28
|
+
const globalContext = createGlobalContextBase(virtualFileExportsGlobalEntry);
|
|
15
29
|
let isNewGlobalContext;
|
|
16
30
|
if (!globalObject.globalContext) {
|
|
31
|
+
// We set globalObject.globalContext early and before any async operations, so that getGlobalContextSync() can be used early.
|
|
32
|
+
// - Required by vike-vercel
|
|
17
33
|
globalObject.globalContext = globalContext;
|
|
18
34
|
isNewGlobalContext = false;
|
|
19
35
|
}
|
|
20
36
|
else {
|
|
21
37
|
isNewGlobalContext = true;
|
|
22
38
|
}
|
|
23
|
-
if (
|
|
24
|
-
//
|
|
39
|
+
if (addGlobalContext &&
|
|
40
|
+
// TO-DO/next-major-release: remove
|
|
25
41
|
globalContext._pageConfigs.length > 0) {
|
|
26
|
-
const
|
|
27
|
-
(0, utils_js_1.objectAssign)(globalContext,
|
|
42
|
+
const globalContextAdded = addGlobalContext?.(globalContext);
|
|
43
|
+
(0, utils_js_1.objectAssign)(globalContext, globalContextAdded);
|
|
28
44
|
}
|
|
29
45
|
else {
|
|
30
|
-
const
|
|
31
|
-
(0, utils_js_1.objectAssign)(globalContext,
|
|
46
|
+
const globalContextAdded = await addGlobalContextTmp?.(globalContext);
|
|
47
|
+
(0, utils_js_1.objectAssign)(globalContext, globalContextAdded);
|
|
48
|
+
}
|
|
49
|
+
{
|
|
50
|
+
const globalContextAddedAsync = await addGlobalContextAsync?.(globalContext);
|
|
51
|
+
(0, utils_js_1.objectAssign)(globalContext, globalContextAddedAsync);
|
|
32
52
|
}
|
|
33
53
|
const onCreateGlobalContextHooks = (0, getHook_js_1.getHookFromPageConfigGlobalCumulative)(globalContext._pageConfigGlobal, 'onCreateGlobalContext');
|
|
34
54
|
let hooksCalled = false;
|
|
@@ -47,10 +67,11 @@ async function createGlobalContextShared(virtualFileExports, globalObject, addGl
|
|
|
47
67
|
(0, utils_js_1.objectAssign)(globalObject.globalContext, globalContext, true);
|
|
48
68
|
}
|
|
49
69
|
}
|
|
70
|
+
resolve();
|
|
50
71
|
return globalObject.globalContext;
|
|
51
72
|
}
|
|
52
|
-
function createGlobalContextBase(
|
|
53
|
-
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(
|
|
73
|
+
function createGlobalContextBase(virtualFileExportsGlobalEntry) {
|
|
74
|
+
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, vikeConfigPublicGlobal, vikeConfigPublicPagesEager, } = getConfigsAll(virtualFileExportsGlobalEntry);
|
|
54
75
|
const globalContext = {
|
|
55
76
|
/**
|
|
56
77
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
@@ -59,7 +80,7 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
59
80
|
*/
|
|
60
81
|
isGlobalContext: true,
|
|
61
82
|
_isOriginalObject: true,
|
|
62
|
-
|
|
83
|
+
_virtualFileExportsGlobalEntry: virtualFileExportsGlobalEntry,
|
|
63
84
|
_pageFilesAll: pageFilesAll,
|
|
64
85
|
_pageConfigs: pageConfigs,
|
|
65
86
|
_pageConfigGlobal: pageConfigGlobal,
|
|
@@ -71,14 +92,14 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
71
92
|
(0, utils_js_1.changeEnumerable)(globalContext, '_isOriginalObject', false);
|
|
72
93
|
return globalContext;
|
|
73
94
|
}
|
|
74
|
-
function getConfigsAll(
|
|
75
|
-
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0,
|
|
95
|
+
function getConfigsAll(virtualFileExportsGlobalEntry) {
|
|
96
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseVirtualFileExportsGlobalEntry_js_1.parseVirtualFileExportsGlobalEntry)(virtualFileExportsGlobalEntry);
|
|
76
97
|
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
77
98
|
const vikeConfigPublicGlobal = (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicGlobal)({
|
|
78
99
|
pageConfigGlobalValues: pageConfigGlobal.configValues,
|
|
79
100
|
});
|
|
80
101
|
const vikeConfigPublicPagesEager = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
81
|
-
return (0, resolveVikeConfigPublic_js_1.
|
|
102
|
+
return (0, resolveVikeConfigPublic_js_1.resolveVikeConfigPublicPageEagerLoaded)(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
|
|
82
103
|
}));
|
|
83
104
|
return {
|
|
84
105
|
pageFilesAll,
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseVirtualFileExportsGlobalEntry = parseVirtualFileExportsGlobalEntry;
|
|
4
4
|
// TO-DO/next-major-release: remove old design code, and remove all assertions.
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const assert_exports_old_design_js_1 = require("./assert_exports_old_design.js");
|
|
7
7
|
const getPageFileObject_js_1 = require("./getPageFileObject.js");
|
|
8
8
|
const fileTypes_js_1 = require("./fileTypes.js");
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
12
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
13
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
14
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
15
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
16
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
17
|
-
(0, utils_js_1.hasProp)(
|
|
18
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
19
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
20
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(
|
|
21
|
-
const { pageConfigsSerialized, pageConfigGlobalSerialized } =
|
|
9
|
+
const parsePageConfigsSerialized_js_1 = require("../page-configs/serialize/parsePageConfigsSerialized.js");
|
|
10
|
+
function parseVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry) {
|
|
11
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesLazy', 'object'));
|
|
12
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesEager', 'object'));
|
|
13
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesExportNamesLazy', 'object'));
|
|
14
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesExportNamesEager', 'object'));
|
|
15
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry.pageFilesLazy, '.page'));
|
|
16
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry.pageFilesLazy, '.page.client') ||
|
|
17
|
+
(0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry.pageFilesLazy, '.page.server'));
|
|
18
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageFilesList', 'string[]'));
|
|
19
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageConfigsSerialized'));
|
|
20
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(virtualFileExportsGlobalEntry, 'pageConfigGlobalSerialized'));
|
|
21
|
+
const { pageConfigsSerialized, pageConfigGlobalSerialized } = virtualFileExportsGlobalEntry;
|
|
22
22
|
assertPageConfigsSerialized(pageConfigsSerialized);
|
|
23
23
|
assertPageConfigGlobalSerialized(pageConfigGlobalSerialized);
|
|
24
|
-
const { pageConfigs, pageConfigGlobal } = (0,
|
|
24
|
+
const { pageConfigs, pageConfigGlobal } = (0, parsePageConfigsSerialized_js_1.parsePageConfigsSerialized)(pageConfigsSerialized, pageConfigGlobalSerialized);
|
|
25
25
|
const pageFilesMap = {};
|
|
26
|
-
parseGlobResult(
|
|
26
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
27
27
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
28
28
|
const loadModule = globValue;
|
|
29
29
|
assertLoadModule(loadModule);
|
|
@@ -34,7 +34,7 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
|
-
parseGlobResult(
|
|
37
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
38
38
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
39
39
|
const loadModule = globValue;
|
|
40
40
|
assertLoadModule(loadModule);
|
|
@@ -47,20 +47,20 @@ function parseVirtualFileExports(virtualFileExports) {
|
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
49
|
// `pageFilesEager` contains `.page.route.js` files
|
|
50
|
-
parseGlobResult(
|
|
50
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
51
51
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
52
52
|
const moduleExports = globValue;
|
|
53
53
|
(0, utils_js_1.assert)((0, utils_js_1.isObject)(moduleExports));
|
|
54
54
|
pageFile.fileExports = moduleExports;
|
|
55
55
|
});
|
|
56
|
-
parseGlobResult(
|
|
56
|
+
parseGlobResult(virtualFileExportsGlobalEntry.pageFilesExportNamesEager).forEach(({ filePath, pageFile, globValue }) => {
|
|
57
57
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
58
58
|
const moduleExports = globValue;
|
|
59
59
|
(0, utils_js_1.assert)((0, utils_js_1.isObject)(moduleExports));
|
|
60
60
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(moduleExports, 'exportNames', 'string[]'), pageFile.filePath);
|
|
61
61
|
pageFile.exportNames = moduleExports.exportNames;
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
virtualFileExportsGlobalEntry.pageFilesList.forEach((filePath) => {
|
|
64
64
|
pageFilesMap[filePath] = pageFilesMap[filePath] ?? (0, getPageFileObject_js_1.getPageFileObject)(filePath);
|
|
65
65
|
});
|
|
66
66
|
const pageFilesAll = Object.values(pageFilesMap);
|
|
@@ -43,8 +43,8 @@ function onInternalProp(propStr, objName) {
|
|
|
43
43
|
// - We must skip it in the client-side because of the reactivity mechanism of UI frameworks like Solid.
|
|
44
44
|
// - TO-DO/eventually: use import.meta.CLIENT instead of isBrowser()
|
|
45
45
|
// - Where import.meta.CLIENT is defined by Vike
|
|
46
|
-
// - Using
|
|
47
|
-
// - If Rolldown Vite + Rolldowns always transpiles node_modules/ then we can simply use
|
|
46
|
+
// - Using ({}).CLIENT (note `.env.`) doesn't seem possible: https://github.com/brillout/playground_node_({})
|
|
47
|
+
// - If Rolldown Vite + Rolldowns always transpiles node_modules/ then we can simply use ({}).SSR
|
|
48
48
|
if ((0, utils_js_1.isBrowser)())
|
|
49
49
|
return;
|
|
50
50
|
// TO-DO/soon/proxy: remove this and only warn on built-in access instead
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.modifyUrlSameOrigin = modifyUrlSameOrigin;
|
|
4
|
+
// We don't move modifyUrlSameOrigin() to the modifyUrl.ts file because we plan to use modifyUrlSameOrigin() on the client-side:
|
|
5
|
+
// https://github.com/vikejs/vike/blob/c5a2de5e85262771f97851767c00ac35da69c64b/packages/vike/client/runtime-client-routing/navigate.ts#L4
|
|
4
6
|
const utils_js_1 = require("./utils.js");
|
|
5
7
|
function modifyUrlSameOrigin(url, modify) {
|
|
6
8
|
const urlParsed = (0, utils_js_1.parseUrl)(url, '/');
|
|
@@ -27,16 +29,19 @@ function modifyUrlSameOrigin(url, modify) {
|
|
|
27
29
|
const urlModified = (0, utils_js_1.createUrlFromComponents)(urlParsed.origin, pathname, search, hash);
|
|
28
30
|
return urlModified;
|
|
29
31
|
}
|
|
30
|
-
function resolveSearch(urlParsed,
|
|
32
|
+
function resolveSearch(urlParsed, modifySearch) {
|
|
31
33
|
let searchParams;
|
|
32
|
-
if (
|
|
34
|
+
if (modifySearch instanceof URLSearchParams) {
|
|
33
35
|
// Overwrite
|
|
34
|
-
searchParams =
|
|
36
|
+
searchParams = modifySearch;
|
|
35
37
|
}
|
|
36
38
|
else {
|
|
37
39
|
// Merge
|
|
38
|
-
const searchMap = (0, utils_js_1.objectFilter)({ ...urlParsed.search, ...
|
|
40
|
+
const searchMap = (0, utils_js_1.objectFilter)({ ...urlParsed.search, ...(0, utils_js_1.objectFilter)(modifySearch, isNotUndefined) }, (utils_js_1.isNotNullish_keyVal));
|
|
39
41
|
searchParams = new URLSearchParams(searchMap);
|
|
40
42
|
}
|
|
41
43
|
return '?' + searchParams.toString();
|
|
42
44
|
}
|
|
45
|
+
function isNotUndefined(arg) {
|
|
46
|
+
return arg[1] !== undefined;
|
|
47
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadPageEntry = loadPageEntry;
|
|
4
|
+
const utils_js_1 = require("../utils.js");
|
|
5
|
+
const parsePageConfigsSerialized_js_1 = require("./serialize/parsePageConfigsSerialized.js");
|
|
6
|
+
async function loadPageEntry(pageConfig, isDev) {
|
|
7
|
+
if ('isPageEntryLoaded' in pageConfig &&
|
|
8
|
+
// We don't need to cache in dev, since Vite already caches the virtual module
|
|
9
|
+
!isDev) {
|
|
10
|
+
return pageConfig;
|
|
11
|
+
}
|
|
12
|
+
const { moduleId, moduleExportsPromise } = pageConfig.loadVirtualFilePageEntry();
|
|
13
|
+
const virtualFileExportsPageEntry = await moduleExportsPromise;
|
|
14
|
+
// `configValuesLoaded` is sometimes `undefined` https://github.com/vikejs/vike/discussions/2092
|
|
15
|
+
if (!virtualFileExportsPageEntry)
|
|
16
|
+
(0, utils_js_1.assert)(false, { moduleExportsPromise, virtualFileExportsPageEntry, moduleId });
|
|
17
|
+
const configValues = parseVirtualFileExportsPageEntry(virtualFileExportsPageEntry);
|
|
18
|
+
Object.assign(pageConfig.configValues, configValues);
|
|
19
|
+
(0, utils_js_1.objectAssign)(pageConfig, { isPageEntryLoaded: true });
|
|
20
|
+
return pageConfig;
|
|
21
|
+
}
|
|
22
|
+
function parseVirtualFileExportsPageEntry(virtualFileExportsPageEntry) {
|
|
23
|
+
const configValues = (0, parsePageConfigsSerialized_js_1.parseConfigValuesSerialized)(virtualFileExportsPageEntry.configValuesSerialized);
|
|
24
|
+
return configValues;
|
|
25
|
+
}
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveVikeConfigPublicGlobal = resolveVikeConfigPublicGlobal;
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
7
|
+
exports.resolveVikeConfigPublicPageEagerLoaded = resolveVikeConfigPublicPageEagerLoaded;
|
|
8
|
+
exports.resolveVikeConfigPublicPageLazyLoaded = resolveVikeConfigPublicPageLazyLoaded;
|
|
9
9
|
const assert_exports_old_design_js_1 = require("../getPageFiles/assert_exports_old_design.js");
|
|
10
10
|
const getConfigDefinedAt_js_1 = require("./getConfigDefinedAt.js");
|
|
11
11
|
const helpers_js_1 = require("./helpers.js");
|
|
12
12
|
const utils_js_1 = require("../utils.js");
|
|
13
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
-
function
|
|
14
|
+
function resolveVikeConfigPublicPageEagerLoaded(pageConfigGlobalValues, pageConfig, pageConfigValues) {
|
|
15
15
|
const vikeConfigPublicPage_ = resolveVikeConfigPublic_base({ pageConfigGlobalValues, pageConfigValues });
|
|
16
16
|
const vikeConfigPublicPage = getPublicCopy(vikeConfigPublicPage_);
|
|
17
17
|
let page;
|
|
@@ -46,7 +46,7 @@ function resolveVikeConfigPublicGlobal({ pageConfigGlobalValues, }) {
|
|
|
46
46
|
const vikeConfigPublicGlobal = resolveVikeConfigPublic_V1Design({ configValues: pageConfigGlobalValues });
|
|
47
47
|
return getPublicCopy(vikeConfigPublicGlobal);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function resolveVikeConfigPublicPageLazyLoaded(pageFiles, // V0.4 design
|
|
50
50
|
pageConfig, // V1 design
|
|
51
51
|
pageConfigGlobal) {
|
|
52
52
|
const config = {};
|
package/dist/cjs/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parsePageConfigsSerialized = parsePageConfigsSerialized;
|
|
4
4
|
exports.parseConfigValuesSerialized = parseConfigValuesSerialized;
|
|
5
5
|
const utils_js_1 = require("../../utils.js");
|
|
6
6
|
const getConfigDefinedAt_js_1 = require("../getConfigDefinedAt.js");
|
|
7
7
|
const parse_1 = require("@brillout/json-serializer/parse");
|
|
8
8
|
const assertPlusFileExport_js_1 = require("../assertPlusFileExport.js");
|
|
9
|
-
function
|
|
9
|
+
function parsePageConfigsSerialized(pageConfigsSerialized, pageConfigGlobalSerialized) {
|
|
10
10
|
// pageConfigs
|
|
11
11
|
const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
|
|
12
12
|
const configValues = parseConfigValuesSerialized(pageConfigSerialized.configValuesSerialized);
|
|
@@ -12,18 +12,19 @@ const pointerImports_js_1 = require("../../../node/vite/shared/resolveVikeConfig
|
|
|
12
12
|
const helpers_js_1 = require("../helpers.js");
|
|
13
13
|
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
14
14
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
|
-
const
|
|
15
|
+
const getConfigValueSourcesRelevant_js_1 = require("../../../node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js");
|
|
16
16
|
const stringifyOptions = { forbidReactElements: true };
|
|
17
17
|
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
18
18
|
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
19
|
-
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with
|
|
20
|
-
// - vike/shared/page-configs/serialize/
|
|
21
|
-
// -
|
|
19
|
+
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with parsePageConfigsSerialized()
|
|
20
|
+
// - vike/shared/page-configs/serialize/parsePageConfigsSerialized.ts
|
|
21
|
+
// - parsePageConfigsSerialized() is loaded on both the client- and server-side.
|
|
22
|
+
(0, utils_js_1.assertIsNotBrowser)();
|
|
22
23
|
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
23
|
-
function serializeConfigValues(pageConfig, importStatements, filesEnv,
|
|
24
|
+
function serializeConfigValues(pageConfig, importStatements, filesEnv, runtimeEnv, tabspace, isEager) {
|
|
24
25
|
const lines = [];
|
|
25
26
|
tabspace += ' ';
|
|
26
|
-
getConfigValuesBase(pageConfig,
|
|
27
|
+
getConfigValuesBase(pageConfig, runtimeEnv, isEager).forEach((entry) => {
|
|
27
28
|
if (entry.configValueBase.type === 'computed') {
|
|
28
29
|
(0, utils_js_1.assert)('value' in entry); // Help TS
|
|
29
30
|
const { configValueBase, value, configName, configEnv } = entry;
|
|
@@ -180,12 +181,12 @@ function logJsonSerializeError(err, configName, definedAtData) {
|
|
|
180
181
|
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
181
182
|
(0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined using a separate file ${picocolors_1.default.bold(`+${configName}.js`)}, see https://vike.dev/error/runtime-in-config`);
|
|
182
183
|
}
|
|
183
|
-
function getConfigValuesBase(pageConfig,
|
|
184
|
+
function getConfigValuesBase(pageConfig, runtimeEnv, isEager) {
|
|
184
185
|
const fromComputed = Object.entries(pageConfig.configValuesComputed ?? {}).map(([configName, valueInfo]) => {
|
|
185
186
|
const { configEnv, value } = valueInfo;
|
|
186
|
-
if (!
|
|
187
|
+
if (!(0, getConfigValueSourcesRelevant_js_1.isRuntimeEnvMatch)(configEnv, runtimeEnv))
|
|
187
188
|
return 'SKIP';
|
|
188
|
-
//
|
|
189
|
+
// AFAICT this should never happen: I ain't aware of a use case for overriding computed values. If there is a use case, then configValueSources has higher precedence.
|
|
189
190
|
if (pageConfig.configValueSources[configName])
|
|
190
191
|
return 'SKIP';
|
|
191
192
|
const configValueBase = {
|
|
@@ -194,16 +195,17 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
|
194
195
|
};
|
|
195
196
|
return { configValueBase, value, configName, configEnv };
|
|
196
197
|
});
|
|
197
|
-
const fromSources = Object.entries(pageConfig.configValueSources).map(([configName
|
|
198
|
+
const fromSources = Object.entries(pageConfig.configValueSources).map(([configName]) => {
|
|
198
199
|
const configDef = pageConfig.configDefinitions[configName];
|
|
199
200
|
(0, utils_js_1.assert)(configDef);
|
|
200
201
|
if (isEager !== null && isEager !== !!configDef.eager)
|
|
201
202
|
return 'SKIP';
|
|
202
203
|
if (!configDef.cumulative) {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
if (!
|
|
204
|
+
const sourcesRelevant = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourcesRelevant)(configName, runtimeEnv, pageConfig);
|
|
205
|
+
const source = sourcesRelevant[0];
|
|
206
|
+
if (!source)
|
|
206
207
|
return 'SKIP';
|
|
208
|
+
(0, utils_js_1.assert)(sourcesRelevant.length === 1);
|
|
207
209
|
const definedAtFile = getDefinedAtFileSource(source);
|
|
208
210
|
const configValueBase = {
|
|
209
211
|
type: 'standard',
|
|
@@ -212,9 +214,7 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
|
212
214
|
return { configValueBase, sourceRelevant: source, configName };
|
|
213
215
|
}
|
|
214
216
|
else {
|
|
215
|
-
const sourcesRelevant =
|
|
216
|
-
.filter((source) => !(0, resolveVikeConfigInternal_js_1.isOverridden)(source, configName, pageConfig))
|
|
217
|
-
.filter((source) => isEnvMatch(source.configEnv));
|
|
217
|
+
const sourcesRelevant = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourcesRelevant)(configName, runtimeEnv, pageConfig);
|
|
218
218
|
if (sourcesRelevant.length === 0)
|
|
219
219
|
return 'SKIP';
|
|
220
220
|
const definedAtData = [];
|
package/dist/cjs/shared/utils.js
CHANGED
|
@@ -45,3 +45,5 @@ __exportStar(require("../utils/objectDefineProperty.js"), exports);
|
|
|
45
45
|
__exportStar(require("../utils/isScriptFile.js"), exports);
|
|
46
46
|
__exportStar(require("../utils/objectFilter.js"), exports);
|
|
47
47
|
__exportStar(require("../utils/getPropAccessNotation.js"), exports);
|
|
48
|
+
__exportStar(require("../utils/getGlobalObject.js"), exports);
|
|
49
|
+
__exportStar(require("../utils/genPromise.js"), exports);
|
|
@@ -29,6 +29,8 @@ function assertIsNotProductionRuntime() {
|
|
|
29
29
|
setup.shouldNotBeProduction = true;
|
|
30
30
|
}
|
|
31
31
|
function onSetupRuntime() {
|
|
32
|
+
if (true)
|
|
33
|
+
return; // TODO/now refactor this
|
|
32
34
|
if (debug.isActivated)
|
|
33
35
|
debug('assertSetup()', new Error().stack);
|
|
34
36
|
if (isTest())
|
|
@@ -36,15 +38,15 @@ function onSetupRuntime() {
|
|
|
36
38
|
assertNodeEnvIsNotUndefinedString();
|
|
37
39
|
if (!setup.viteDevServer && setup.isViteDev === undefined) {
|
|
38
40
|
// TO-DO/eventually: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
39
|
-
(0, assert_js_1.assertWarning)(!isNodeEnvDev(), `The ${getEnvDescription()}, which is contradictory because the environment seems to be a production environment (Vite isn't loaded), see https://vike.dev/NODE_ENV`, { onlyOnce: true });
|
|
40
|
-
(0, assert_js_1.assertUsage)(!setup.vikeVitePlugin, `
|
|
41
|
+
(0, assert_js_1.assertWarning)(!isNodeEnvDev(), `The ${getEnvDescription()}, which is contradictory because the environment seems to be a production environment (Vite isn't loaded), see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')} and ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`, { onlyOnce: true });
|
|
42
|
+
(0, assert_js_1.assertUsage)(!setup.vikeVitePlugin, `Vike's Vite plugin (the ${picocolors_1.default.cyan('vike/plugin')} module) shouldn't be loaded in production, see ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`);
|
|
41
43
|
// This assert() one of the main goal of this file: it ensures assertIsNotProductionRuntime()
|
|
42
44
|
(0, assert_js_1.assert)(!setup.shouldNotBeProduction);
|
|
43
45
|
}
|
|
44
46
|
else {
|
|
45
47
|
if (!setup.isPreview && !setup.vitePreviewServer && !setup.isPrerendering) {
|
|
46
48
|
// TO-DO/eventually: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
47
|
-
(0, assert_js_1.assertWarning)(isNodeEnvDev(), `The ${getEnvDescription()}
|
|
49
|
+
(0, assert_js_1.assertWarning)(isNodeEnvDev(), `The ${getEnvDescription()} while Vite is loaded, but Vite shouldn't be loaded in production, see ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`, { onlyOnce: true });
|
|
48
50
|
}
|
|
49
51
|
(0, assert_js_1.assert)(setup.vikeVitePlugin);
|
|
50
52
|
(0, assert_js_1.assert)(setup.shouldNotBeProduction);
|
|
@@ -114,7 +116,7 @@ function assertUsageNodeEnvIsNotDev(operation) {
|
|
|
114
116
|
if (!isNodeEnvDev())
|
|
115
117
|
return;
|
|
116
118
|
// TO-DO/eventually: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
117
|
-
(0, assert_js_1.assertWarning)(false, `The ${getEnvDescription()}
|
|
119
|
+
(0, assert_js_1.assertWarning)(false, `The ${getEnvDescription()} upon ${operation} which shouldn't be the case, see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')}`, { onlyOnce: true });
|
|
118
120
|
}
|
|
119
121
|
function getEnvDescription() {
|
|
120
122
|
const envType = `${(isNodeEnvDev() ? 'development' : 'production')} environment`;
|
|
@@ -125,7 +127,7 @@ function getEnvDescription() {
|
|
|
125
127
|
// https://github.com/cloudflare/workers-sdk/issues/7886
|
|
126
128
|
function assertNodeEnvIsNotUndefinedString() {
|
|
127
129
|
const nodeEnv = getNodeEnv();
|
|
128
|
-
(0, assert_js_1.assertWarning)(nodeEnv !== 'undefined', `${picocolors_1.default.cyan('process.env.NODE_ENV==="undefined"')} which is unexpected: ${picocolors_1.default.cyan('process.env.NODE_ENV')} is allowed to be the *value* ${picocolors_1.default.cyan('undefined')} (i.e. ${picocolors_1.default.cyan('process.env.NODE_ENV===undefined')}) but it shouldn't be the *string* ${picocolors_1.default.cyan('"undefined"')} ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')}`, { onlyOnce: true });
|
|
130
|
+
(0, assert_js_1.assertWarning)(nodeEnv !== 'undefined', `${picocolors_1.default.cyan('process.env.NODE_ENV==="undefined"')} which is unexpected: ${picocolors_1.default.cyan('process.env.NODE_ENV')} is allowed to be the *value* ${picocolors_1.default.cyan('undefined')} (i.e. ${picocolors_1.default.cyan('process.env.NODE_ENV===undefined')}) but it shouldn't be the *string* ${picocolors_1.default.cyan('"undefined"')} — see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')}`, { onlyOnce: true });
|
|
129
131
|
}
|
|
130
132
|
function isNodeEnvDev() {
|
|
131
133
|
const nodeEnv = getNodeEnv();
|
package/dist/cjs/utils/cast.js
CHANGED
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getViteRPC = getViteRPC;
|
|
4
|
+
exports.createViteRPC = createViteRPC;
|
|
5
|
+
const assert_js_1 = require("./assert.js");
|
|
6
|
+
const genPromise_js_1 = require("./genPromise.js");
|
|
7
|
+
const getRandomId_js_1 = require("./getRandomId.js");
|
|
8
|
+
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
9
|
+
const debug_js_1 = require("./debug.js");
|
|
10
|
+
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
11
|
+
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
12
|
+
const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/getViteRPC.ts', {
|
|
13
|
+
rpc: null,
|
|
14
|
+
});
|
|
15
|
+
const debug = (0, debug_js_1.createDebugger)('vike:vite-rpc');
|
|
16
|
+
function getViteRPC() {
|
|
17
|
+
globalObject.rpc ?? (globalObject.rpc = createRpcClient());
|
|
18
|
+
return globalObject.rpc;
|
|
19
|
+
}
|
|
20
|
+
function createRpcClient() {
|
|
21
|
+
// @ts-ignore CJS build doesn't support import.meta — TO-DO/eventually: let's remove this ts-ignore after we removed the CJS build
|
|
22
|
+
const hot = (undefined);
|
|
23
|
+
(0, assert_js_1.assert)(hot);
|
|
24
|
+
const listeners = [];
|
|
25
|
+
hot.on(`vike:rpc:response`, (dataResponse) => {
|
|
26
|
+
if (debug.isActivated)
|
|
27
|
+
debug('Response received', dataResponse);
|
|
28
|
+
const { callId, functionReturn } = dataResponse;
|
|
29
|
+
listeners.forEach((l) => {
|
|
30
|
+
if (callId !== l.callId)
|
|
31
|
+
return;
|
|
32
|
+
l.cb(functionReturn);
|
|
33
|
+
listeners.splice(listeners.indexOf(l), 1);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
const rpc = new Proxy({}, {
|
|
37
|
+
get(_, functionName) {
|
|
38
|
+
return async (...functionArgs) => {
|
|
39
|
+
// @ts-ignore CJS build doesn't support import.meta — TO-DO/eventually: let's remove this ts-ignore after we removed the CJS build
|
|
40
|
+
const hot = (undefined);
|
|
41
|
+
(0, assert_js_1.assert)(hot);
|
|
42
|
+
const callId = (0, getRandomId_js_1.getRandomId)();
|
|
43
|
+
const { promise, resolve } = (0, genPromise_js_1.genPromise)({ timeout: 3 * 1000 });
|
|
44
|
+
listeners.push({
|
|
45
|
+
callId,
|
|
46
|
+
cb: (functionReturn) => {
|
|
47
|
+
resolve(functionReturn);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const dataRequest = { callId, functionName, functionArgs };
|
|
51
|
+
if (debug.isActivated)
|
|
52
|
+
debug('Request sent', dataRequest);
|
|
53
|
+
// Vite's type is wrong: (undefined).send() does seem to return a promise
|
|
54
|
+
await hot.send('vike:rpc:request', dataRequest);
|
|
55
|
+
const functionReturn = await promise;
|
|
56
|
+
return functionReturn;
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
return rpc;
|
|
61
|
+
}
|
|
62
|
+
function createViteRPC(viteDevServer, getRpcFunctions) {
|
|
63
|
+
const rpcFunctions = getRpcFunctions(viteDevServer);
|
|
64
|
+
const { environments } = viteDevServer;
|
|
65
|
+
for (const envName in environments) {
|
|
66
|
+
debug('Listening to environment', envName);
|
|
67
|
+
const env = environments[envName];
|
|
68
|
+
env.hot.on('vike:rpc:request', async (dataRequest) => {
|
|
69
|
+
if (debug.isActivated)
|
|
70
|
+
debug('Request received', dataRequest);
|
|
71
|
+
const { callId, functionName, functionArgs } = dataRequest;
|
|
72
|
+
const functionReturn = await rpcFunctions[functionName](...functionArgs);
|
|
73
|
+
const dataResponse = { callId, functionReturn };
|
|
74
|
+
if (debug.isActivated)
|
|
75
|
+
debug('Response sent', dataResponse);
|
|
76
|
+
env.hot.send('vike:rpc:response', dataResponse);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.assertFilePathAbsoluteFilesystem = assertFilePathAbsoluteFilesystem;
|
|
7
|
+
exports.isFilePathAbsoluteFilesystem = isFilePathAbsoluteFilesystem;
|
|
7
8
|
exports.isFilePathAbsolute = isFilePathAbsolute;
|
|
8
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
10
|
const assert_js_1 = require("./assert.js");
|