vike 0.4.220 → 0.4.221-commit-8577456
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/__internal/index.js +5 -23
- package/dist/cjs/node/api/build.js +33 -24
- package/dist/cjs/node/api/context.js +6 -8
- package/dist/cjs/node/api/prepareViteApiCall.js +23 -21
- package/dist/cjs/node/api/prerender.js +1 -0
- package/dist/cjs/node/api/utils.js +2 -1
- package/dist/cjs/node/cli/context.js +16 -0
- package/dist/cjs/node/cli/entry.js +2 -0
- package/dist/cjs/node/cli/utils.js +1 -0
- package/dist/cjs/node/plugin/index.js +4 -8
- package/dist/cjs/node/plugin/onLoad.js +6 -1
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +34 -33
- package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildApp.js +72 -0
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +12 -12
- package/dist/cjs/node/plugin/plugins/buildConfig.js +17 -12
- package/dist/cjs/node/plugin/plugins/buildEntry/index.js +28 -24
- package/dist/cjs/node/plugin/plugins/commonConfig.js +9 -7
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +7 -4
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +15 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +11 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +41 -36
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +59 -22
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +159 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +40 -23
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +9 -64
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +403 -590
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +12 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +13 -11
- package/dist/cjs/node/plugin/plugins/packageJsonFile.js +2 -2
- package/dist/cjs/node/plugin/plugins/previewConfig.js +7 -7
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +3 -5
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +20 -0
- package/dist/cjs/{utils → node/plugin/shared}/getOutDirs.js +70 -61
- package/dist/cjs/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/cjs/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/cjs/node/plugin/utils.js +1 -2
- package/dist/cjs/node/prerender/context.js +31 -0
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +46 -0
- package/dist/cjs/node/prerender/runPrerender.js +89 -68
- package/dist/cjs/node/prerender/utils.js +2 -2
- package/dist/cjs/node/runtime/globalContext.js +222 -150
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +11 -7
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/cjs/node/runtime/html/injectAssets.js +4 -4
- package/dist/cjs/node/runtime/html/renderHtml.js +4 -5
- package/dist/cjs/node/runtime/page-files/setup.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +2 -27
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/cjs/node/runtime/renderPage/isFontFallback.js +29 -0
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +5 -4
- package/dist/cjs/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +14 -10
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
- package/dist/cjs/node/runtime/renderPage.js +31 -29
- package/dist/cjs/node/runtime/utils.js +3 -3
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/cjs/node/shared/resolveBase.js +7 -0
- package/dist/cjs/shared/getPageConfigsRuntime.js +20 -0
- package/dist/cjs/shared/getPageContextUrlComputed.js +6 -1
- package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -1
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/cjs/shared/getPageFiles.js +1 -3
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +15 -6
- package/dist/cjs/shared/page-configs/loadConfigValues.js +5 -1
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +69 -18
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -0
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +1 -1
- package/dist/cjs/utils/catchInfiniteLoop.js +34 -0
- package/dist/cjs/utils/debug.js +8 -6
- package/dist/cjs/utils/findFile.js +4 -3
- package/dist/cjs/utils/isDev.js +2 -2
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
- package/dist/cjs/utils/makePublicCopy.js +32 -0
- package/dist/cjs/utils/objectAssignSafe.js +7 -0
- package/dist/cjs/utils/path.js +48 -0
- package/dist/cjs/utils/requireResolve.js +3 -3
- package/dist/esm/__internal/index.d.ts +2 -2
- package/dist/esm/__internal/index.js +7 -26
- package/dist/esm/client/client-routing-runtime/createPageContext.js +5 -9
- package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/history.js +23 -18
- package/dist/esm/client/client-routing-runtime/index.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/index.js +0 -1
- package/dist/esm/client/client-routing-runtime/initClientRouter.js +2 -2
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.d.ts +0 -4
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +0 -11
- package/dist/esm/client/client-routing-runtime/initOnPopState.d.ts +0 -10
- package/dist/esm/client/client-routing-runtime/initOnPopState.js +50 -70
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +15 -15
- package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +4 -6
- package/dist/esm/client/client-routing-runtime/scrollRestoration.js +17 -12
- package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/setScrollPosition.js +29 -5
- package/dist/esm/client/client-routing-runtime/skipLink.d.ts +0 -2
- package/dist/esm/client/client-routing-runtime/skipLink.js +0 -1
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/utils.js +1 -0
- package/dist/esm/client/server-routing-runtime/getPageContext.js +3 -4
- package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -2
- package/dist/esm/node/api/build.d.ts +1 -6
- package/dist/esm/node/api/build.js +31 -25
- package/dist/esm/node/api/context.d.ts +4 -4
- package/dist/esm/node/api/context.js +6 -9
- package/dist/esm/node/api/prepareViteApiCall.d.ts +4 -3
- package/dist/esm/node/api/prepareViteApiCall.js +24 -22
- package/dist/esm/node/api/prerender.js +1 -0
- package/dist/esm/node/api/utils.d.ts +2 -1
- package/dist/esm/node/api/utils.js +2 -1
- package/dist/esm/node/cli/context.d.ts +5 -0
- package/dist/esm/node/cli/context.js +14 -0
- package/dist/esm/node/cli/entry.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +3 -1
- package/dist/esm/node/cli/utils.d.ts +1 -0
- package/dist/esm/node/cli/utils.js +1 -0
- package/dist/esm/node/plugin/index.d.ts +29 -1
- package/dist/esm/node/plugin/index.js +5 -9
- package/dist/esm/node/plugin/onLoad.js +7 -2
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +35 -34
- package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/esm/node/plugin/plugins/buildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/buildApp.js +70 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +11 -11
- package/dist/esm/node/plugin/plugins/buildConfig.js +16 -11
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/buildEntry/index.js +28 -24
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +8 -2
- package/dist/esm/node/plugin/plugins/commonConfig.js +7 -5
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +6 -3
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +14 -9
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +11 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.d.ts +6 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{assertExtensions.js → getVikeConfig/assertExtensions.js} +41 -36
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +58 -21
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.js → getVikeConfig/getConfigFileExport.js} +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.d.ts +39 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +154 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +15 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +41 -24
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +8 -18
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +10 -65
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +6 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +12 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +10 -122
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +407 -594
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.js → virtual-files/debug.js} +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.js → virtual-files/getVirtualFilePageConfigValuesAll.js} +12 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.js → virtual-files/getVirtualFilePageConfigs.js} +13 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.d.ts → virtual-files/isRuntimeEnvMatch.d.ts} +1 -1
- package/dist/esm/node/plugin/plugins/packageJsonFile.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +5 -5
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +4 -6
- package/dist/esm/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.d.ts +2 -0
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +17 -0
- package/dist/esm/{utils → node/plugin/shared}/getOutDirs.d.ts +1 -1
- package/dist/esm/{utils → node/plugin/shared}/getOutDirs.js +52 -43
- package/dist/esm/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
- package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.d.ts +2 -5
- package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +1 -2
- package/dist/esm/node/prerender/context.d.ts +11 -0
- package/dist/esm/node/prerender/context.js +29 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +12 -0
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +44 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +42 -1
- package/dist/esm/node/prerender/runPrerender.js +90 -69
- package/dist/esm/node/prerender/utils.d.ts +2 -2
- package/dist/esm/node/prerender/utils.js +2 -2
- package/dist/esm/node/runtime/globalContext.d.ts +44 -36
- package/dist/esm/node/runtime/globalContext.js +223 -151
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +11 -7
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +4 -1
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +2 -3
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -0
- package/dist/esm/node/runtime/html/injectAssets.js +4 -4
- package/dist/esm/node/runtime/html/renderHtml.js +4 -5
- package/dist/esm/node/runtime/page-files/setup.js +1 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -3
- package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -26
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +2 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +3 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -4
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +3 -5
- package/dist/esm/node/runtime/renderPage/isFontFallback.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/isFontFallback.js +27 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +6 -5
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/log404/index.js +1 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +26 -10
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +14 -10
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
- package/dist/esm/node/runtime/renderPage.js +32 -30
- package/dist/esm/node/runtime/utils.d.ts +3 -3
- package/dist/esm/node/runtime/utils.js +3 -3
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +5 -3
- package/dist/esm/node/shared/resolveBase.d.ts +5 -1
- package/dist/esm/node/shared/resolveBase.js +7 -0
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +13 -0
- package/dist/esm/shared/getPageConfigsRuntime.js +18 -0
- package/dist/esm/shared/getPageContextUrlComputed.js +6 -1
- package/dist/esm/shared/getPageFiles/fileTypes.js +1 -2
- package/dist/esm/shared/getPageFiles/getAllPageIdFiles.js +0 -3
- package/dist/esm/shared/getPageFiles/getPageFileObject.js +0 -5
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +4 -3
- package/dist/esm/shared/getPageFiles.d.ts +0 -1
- package/dist/esm/shared/getPageFiles.js +0 -1
- package/dist/esm/shared/page-configs/Config.d.ts +83 -3
- package/dist/esm/shared/page-configs/PageConfig.d.ts +30 -18
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +6 -8
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +15 -6
- package/dist/esm/shared/page-configs/loadConfigValues.js +6 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +7 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +70 -19
- package/dist/esm/shared/route/loadPageRoutes.js +1 -0
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -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 +1 -1
- package/dist/esm/utils/catchInfiniteLoop.d.ts +2 -0
- package/dist/esm/utils/catchInfiniteLoop.js +32 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +8 -6
- package/dist/esm/utils/findFile.js +2 -1
- package/dist/esm/utils/isDev.js +3 -3
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
- package/dist/esm/utils/makePublicCopy.d.ts +3 -0
- package/dist/esm/utils/makePublicCopy.js +30 -0
- package/dist/esm/utils/objectAssignSafe.d.ts +1 -0
- package/dist/esm/utils/objectAssignSafe.js +4 -0
- package/dist/esm/utils/path.d.ts +14 -0
- package/dist/esm/utils/path.js +46 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -17
- package/dist/cjs/node/plugin/plugins/importUserCode/addImportStatement.js +0 -29
- package/dist/cjs/node/prerender/isPrerenderAutoRunEnabled.js +0 -16
- package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
- package/dist/cjs/shared/assertPageFilePath.js +0 -11
- package/dist/cjs/shared/getPageFiles/getPageFiles.js +0 -48
- package/dist/cjs/utils/filesystemPathHandling.js +0 -18
- package/dist/cjs/utils/path-shim.js +0 -19
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +0 -14
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.js +0 -27
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +0 -5
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.d.ts +0 -5
- package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.js +0 -14
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
- package/dist/esm/node/shared/assertPluginManifest.js +0 -18
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
- package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
- package/dist/esm/shared/assertPageFilePath.d.ts +0 -2
- package/dist/esm/shared/assertPageFilePath.js +0 -9
- package/dist/esm/shared/getPageFiles/getPageFiles.d.ts +0 -15
- package/dist/esm/shared/getPageFiles/getPageFiles.js +0 -46
- package/dist/esm/utils/filesystemPathHandling.d.ts +0 -4
- package/dist/esm/utils/filesystemPathHandling.js +0 -16
- package/dist/esm/utils/path-shim.d.ts +0 -2
- package/dist/esm/utils/path-shim.js +0 -17
- /package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getConfigFileExport.d.ts → getVikeConfig/getConfigFileExport.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{debug.d.ts → virtual-files/debug.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigValuesAll.d.ts → virtual-files/getVirtualFilePageConfigValuesAll.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{getVirtualFilePageConfigs.d.ts → virtual-files/getVirtualFilePageConfigs.d.ts} +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/{isRuntimeEnvMatch.js → virtual-files/isRuntimeEnvMatch.js} +0 -0
- /package/dist/esm/node/plugin/{resolveClientEntriesDev.d.ts → shared/resolveClientEntriesDev.d.ts} +0 -0
|
@@ -20,7 +20,8 @@ import type { ConfigValueSerialized } from './serialize/PageConfigSerialized.js'
|
|
|
20
20
|
import type { LocationId } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js';
|
|
21
21
|
import type { FilePath } from './FilePath.js';
|
|
22
22
|
import type { ConfigDefinitions } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
23
|
-
type
|
|
23
|
+
import type { PlusFile, PlusFilesByLocationId } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js';
|
|
24
|
+
type PageConfigCommon = {
|
|
24
25
|
pageId: string;
|
|
25
26
|
isErrorPage?: true;
|
|
26
27
|
routeFilesystem?: {
|
|
@@ -28,34 +29,40 @@ type PageConfigBase = {
|
|
|
28
29
|
definedBy: string;
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
|
-
/** Page config data structure
|
|
32
|
-
type PageConfigRuntime =
|
|
32
|
+
/** Page config, runtime data structure */
|
|
33
|
+
type PageConfigRuntime = PageConfigCommon & {
|
|
33
34
|
configValues: ConfigValues;
|
|
34
35
|
/** Load config values that are lazily loaded such as config.Page */
|
|
35
|
-
loadConfigValuesAll:
|
|
36
|
-
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
37
|
-
}>;
|
|
36
|
+
loadConfigValuesAll: LoadConfigValuesAll;
|
|
38
37
|
};
|
|
39
|
-
/**
|
|
40
|
-
type
|
|
41
|
-
|
|
42
|
-
isAllLoaded: true;
|
|
38
|
+
/** Global config that applies to all pages, runtime data structure */
|
|
39
|
+
type PageConfigGlobalRuntime = {
|
|
40
|
+
configValues: ConfigValues;
|
|
43
41
|
};
|
|
44
|
-
/** Page config data structure
|
|
45
|
-
type PageConfigBuildTime =
|
|
42
|
+
/** Page config, build-time data structure */
|
|
43
|
+
type PageConfigBuildTime = PageConfigCommon & {
|
|
46
44
|
configDefinitions: ConfigDefinitions;
|
|
45
|
+
plusFiles: PlusFilesByLocationId;
|
|
47
46
|
configValueSources: ConfigValueSources;
|
|
48
47
|
configValuesComputed: ConfigValuesComputed;
|
|
49
48
|
};
|
|
50
|
-
/**
|
|
51
|
-
type PageConfigGlobalRuntime = {
|
|
52
|
-
configValues: ConfigValues;
|
|
53
|
-
};
|
|
49
|
+
/** Global config that applies to all pages, build-time data structure */
|
|
54
50
|
type PageConfigGlobalBuildTime = {
|
|
55
51
|
configValueSources: ConfigValueSources;
|
|
56
52
|
configDefinitions: ConfigDefinitions;
|
|
57
53
|
configValuesComputed?: undefined;
|
|
58
54
|
};
|
|
55
|
+
/** Same as PageConfigRuntime but also contains all lazily loaded config values such as config.Page */
|
|
56
|
+
type PageConfigRuntimeLoaded = PageConfigRuntime & {
|
|
57
|
+
/** Whether loadConfigValuesAll() was called */
|
|
58
|
+
isAllLoaded: true;
|
|
59
|
+
};
|
|
60
|
+
type LoadConfigValuesAll = () => {
|
|
61
|
+
moduleId: string;
|
|
62
|
+
moduleExports: Promise<{
|
|
63
|
+
configValuesSerialized: Record<string, ConfigValueSerialized>;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
59
66
|
/** In what environment(s) the config value is loaded.
|
|
60
67
|
*
|
|
61
68
|
* https://vike.dev/meta
|
|
@@ -74,9 +81,9 @@ type ConfigEnvInternal = Omit<ConfigEnv, 'client'> & {
|
|
|
74
81
|
type ConfigValueSources = Record<string, // configName
|
|
75
82
|
ConfigValueSource[]>;
|
|
76
83
|
type ConfigValueSource = {
|
|
77
|
-
value?: unknown;
|
|
78
84
|
configEnv: ConfigEnvInternal;
|
|
79
85
|
definedAtFilePath: DefinedAtFilePath;
|
|
86
|
+
plusFile: PlusFile | null;
|
|
80
87
|
locationId: LocationId;
|
|
81
88
|
isOverriden: boolean;
|
|
82
89
|
/** Wether the config value is loaded at runtime, for example config.Page or config.onBeforeRender */
|
|
@@ -84,7 +91,12 @@ type ConfigValueSource = {
|
|
|
84
91
|
/** Whether the config value is a file path, for example config.client */
|
|
85
92
|
valueIsFilePath?: true;
|
|
86
93
|
valueIsDefinedByPlusFile: boolean;
|
|
87
|
-
}
|
|
94
|
+
} & ({
|
|
95
|
+
valueIsLoaded: false;
|
|
96
|
+
} | {
|
|
97
|
+
valueIsLoaded: true;
|
|
98
|
+
value: unknown;
|
|
99
|
+
});
|
|
88
100
|
type DefinedAtFilePath = DefinedAtFile & FilePath & {
|
|
89
101
|
fileExportName?: string;
|
|
90
102
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getPageConfigUserFriendlyOld };
|
|
2
2
|
export { getPageConfigUserFriendlyNew };
|
|
3
3
|
export type { ConfigUserFriendly };
|
|
4
4
|
export type { PageConfigUserFriendly };
|
|
@@ -33,7 +33,7 @@ type ConfigEntries = Record<string, {
|
|
|
33
33
|
configDefinedByFile: string | null;
|
|
34
34
|
}[]>;
|
|
35
35
|
type PageConfigUserFriendly = {
|
|
36
|
-
config:
|
|
36
|
+
config: ConfigResolved;
|
|
37
37
|
source: Source;
|
|
38
38
|
sources: Sources;
|
|
39
39
|
from: From;
|
|
@@ -73,15 +73,13 @@ type SourceConfigsComputed = {
|
|
|
73
73
|
type: 'configsComputed';
|
|
74
74
|
value: unknown;
|
|
75
75
|
};
|
|
76
|
-
declare function getPageConfigUserFriendly(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null): PageConfigUserFriendly;
|
|
77
76
|
type ConfigUserFriendly = {
|
|
78
77
|
config: ConfigResolved;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
sources: Sources;
|
|
83
|
-
from: From;
|
|
78
|
+
_source: Source;
|
|
79
|
+
_sources: Sources;
|
|
80
|
+
_from: From;
|
|
84
81
|
};
|
|
85
82
|
declare function getPageConfigUserFriendlyNew(pageConfig: {
|
|
86
83
|
configValues: ConfigValues;
|
|
87
84
|
}): ConfigUserFriendly;
|
|
85
|
+
declare function getPageConfigUserFriendlyOld(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null): PageConfigUserFriendly;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getPageConfigUserFriendlyOld };
|
|
2
2
|
export { getPageConfigUserFriendlyNew };
|
|
3
3
|
import { assertDefaultExports, forbiddenDefaultExports } from '../getPageFiles/assert_exports_old_design.js';
|
|
4
4
|
import { getConfigDefinedAtOptional, getDefinedAtString } from './getConfigDefinedAt.js';
|
|
5
5
|
import { getConfigValueFilePathToShowToUser } from './helpers.js';
|
|
6
6
|
import { assert, isObject, assertWarning, assertUsage, makeLast, isBrowser, isScriptFile, isTemplateFile } from '../utils.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
|
-
function
|
|
8
|
+
function getPageConfigUserFriendlyNew(pageConfig) {
|
|
9
|
+
const res = getPageConfigUserFriendlyV1Desin(pageConfig);
|
|
10
|
+
return {
|
|
11
|
+
config: res.config,
|
|
12
|
+
_source: res.source,
|
|
13
|
+
_sources: res.sources,
|
|
14
|
+
_from: res.from
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
9
18
|
const config = {};
|
|
10
19
|
const configEntries = {}; // TODO/v1-release: remove
|
|
11
20
|
const exportsAll = {}; // TODO/v1-release: remove
|
|
@@ -30,7 +39,7 @@ function getPageConfigUserFriendly(pageFiles, pageConfig) {
|
|
|
30
39
|
let sources;
|
|
31
40
|
let from;
|
|
32
41
|
if (pageConfig) {
|
|
33
|
-
const res =
|
|
42
|
+
const res = getPageConfigUserFriendlyV1Desin(pageConfig);
|
|
34
43
|
source = res.source;
|
|
35
44
|
sources = res.sources;
|
|
36
45
|
from = res.from;
|
|
@@ -63,11 +72,11 @@ function getPageConfigUserFriendly(pageFiles, pageConfig) {
|
|
|
63
72
|
assert(!('default' in exports));
|
|
64
73
|
assert(!('default' in exportsAll));
|
|
65
74
|
const pageContextExports = {
|
|
75
|
+
config: config,
|
|
66
76
|
from,
|
|
67
77
|
source,
|
|
68
78
|
sources,
|
|
69
79
|
// TODO/eventually: deprecate/remove every prop below
|
|
70
|
-
config,
|
|
71
80
|
configEntries,
|
|
72
81
|
exports,
|
|
73
82
|
exportsAll,
|
|
@@ -76,7 +85,7 @@ function getPageConfigUserFriendly(pageFiles, pageConfig) {
|
|
|
76
85
|
return pageContextExports;
|
|
77
86
|
}
|
|
78
87
|
// V1 design
|
|
79
|
-
function
|
|
88
|
+
function getPageConfigUserFriendlyV1Desin(pageConfig) {
|
|
80
89
|
const config = {};
|
|
81
90
|
const configEntries = {};
|
|
82
91
|
const exportsAll = {};
|
|
@@ -151,7 +160,7 @@ function getPageConfigUserFriendlyNew(pageConfig) {
|
|
|
151
160
|
});
|
|
152
161
|
});
|
|
153
162
|
return {
|
|
154
|
-
config,
|
|
163
|
+
config: config,
|
|
155
164
|
configEntries,
|
|
156
165
|
exportsAll,
|
|
157
166
|
source,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { loadConfigValues };
|
|
2
|
-
import { objectAssign } from '../utils.js';
|
|
2
|
+
import { assert, objectAssign } from '../utils.js';
|
|
3
3
|
import { parseConfigValuesSerialized } from './serialize/parsePageConfigs.js';
|
|
4
4
|
async function loadConfigValues(pageConfig, isDev) {
|
|
5
5
|
if ('isAllLoaded' in pageConfig &&
|
|
@@ -7,7 +7,11 @@ async function loadConfigValues(pageConfig, isDev) {
|
|
|
7
7
|
!isDev) {
|
|
8
8
|
return pageConfig;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const { moduleId, moduleExports } = pageConfig.loadConfigValuesAll();
|
|
11
|
+
const configValuesLoaded = await moduleExports;
|
|
12
|
+
// `configValuesLoaded` is sometimes `undefined` https://github.com/vikejs/vike/discussions/2092
|
|
13
|
+
if (!configValuesLoaded)
|
|
14
|
+
assert(false, { moduleExports, configValuesLoaded, moduleId });
|
|
11
15
|
const configValues = parseConfigValuesSerialized(configValuesLoaded.configValuesSerialized);
|
|
12
16
|
Object.assign(pageConfig.configValues, configValues);
|
|
13
17
|
objectAssign(pageConfig, { isAllLoaded: true });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { serializeConfigValues };
|
|
2
2
|
export { getConfigValuesBase };
|
|
3
|
+
export type { FilesEnv };
|
|
3
4
|
import type { ConfigEnvInternal, ConfigValueSource, DefinedAtFile, PageConfigBuildTime, PageConfigGlobalBuildTime } from '../PageConfig.js';
|
|
4
|
-
declare function serializeConfigValues(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, importStatements: string[], isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, tabspace: string, isEager: boolean | null): string[];
|
|
5
|
+
declare function serializeConfigValues(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, importStatements: string[], filesEnv: FilesEnv, isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, tabspace: string, isEager: boolean | null): string[];
|
|
5
6
|
declare function getConfigValuesBase(pageConfig: PageConfigBuildTime | PageConfigGlobalBuildTime, isEnvMatch: (configEnv: ConfigEnvInternal) => boolean, isEager: boolean | null): ConfigValuesBase;
|
|
6
7
|
type ConfigValuesBase = ({
|
|
7
8
|
configValueBase: {
|
|
@@ -9,6 +10,7 @@ type ConfigValuesBase = ({
|
|
|
9
10
|
definedAtData: null;
|
|
10
11
|
};
|
|
11
12
|
value: unknown;
|
|
13
|
+
configEnv: ConfigEnvInternal;
|
|
12
14
|
configName: string;
|
|
13
15
|
} | {
|
|
14
16
|
configValueBase: {
|
|
@@ -25,3 +27,7 @@ type ConfigValuesBase = ({
|
|
|
25
27
|
sourcesRelevant: ConfigValueSource[];
|
|
26
28
|
configName: string;
|
|
27
29
|
})[];
|
|
30
|
+
type FilesEnv = Map<string, {
|
|
31
|
+
configEnv: ConfigEnvInternal;
|
|
32
|
+
configName: string;
|
|
33
|
+
}[]>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { serializeConfigValues };
|
|
2
2
|
export { getConfigValuesBase };
|
|
3
3
|
import { assertIsNotProductionRuntime } from '../../../utils/assertSetup.js';
|
|
4
|
-
import { assert, assertUsage, getPropAccessNotation } from '../../../node/plugin/utils.js';
|
|
5
|
-
import { addImportStatement } from '../../../node/plugin/plugins/importUserCode/addImportStatement.js';
|
|
4
|
+
import { assert, assertPosixPath, assertUsage, deepEqual, getPropAccessNotation } from '../../../node/plugin/utils.js';
|
|
6
5
|
import { parsePointerImportData } from '../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformPointerImports.js';
|
|
7
6
|
import { getConfigValueFilePathToShowToUser } from '../helpers.js';
|
|
8
7
|
import { stringify } from '@brillout/json-serializer/stringify';
|
|
@@ -13,20 +12,20 @@ const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
|
13
12
|
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
14
13
|
// - parsePageConfigs() is loaded on both the client- and server-side.
|
|
15
14
|
assertIsNotProductionRuntime();
|
|
16
|
-
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace, isEager) {
|
|
15
|
+
function serializeConfigValues(pageConfig, importStatements, filesEnv, isEnvMatch, tabspace, isEager) {
|
|
17
16
|
const lines = [];
|
|
18
17
|
tabspace += ' ';
|
|
19
18
|
getConfigValuesBase(pageConfig, isEnvMatch, isEager).forEach((entry) => {
|
|
20
19
|
if (entry.configValueBase.type === 'computed') {
|
|
21
20
|
assert('value' in entry); // Help TS
|
|
22
|
-
const { configValueBase, value, configName } = entry;
|
|
23
|
-
const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements);
|
|
21
|
+
const { configValueBase, value, configName, configEnv } = entry;
|
|
22
|
+
const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements, filesEnv, configEnv);
|
|
24
23
|
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
25
24
|
}
|
|
26
25
|
if (entry.configValueBase.type === 'standard') {
|
|
27
26
|
assert('sourceRelevant' in entry); // Help TS
|
|
28
27
|
const { configValueBase, sourceRelevant, configName } = entry;
|
|
29
|
-
const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements);
|
|
28
|
+
const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements, filesEnv);
|
|
30
29
|
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
31
30
|
}
|
|
32
31
|
if (entry.configValueBase.type === 'cumulative') {
|
|
@@ -34,7 +33,7 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
34
33
|
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
35
34
|
const valueDataList = [];
|
|
36
35
|
sourcesRelevant.forEach((source) => {
|
|
37
|
-
const valueData = getValueSerializedFromSource(source, configName, importStatements);
|
|
36
|
+
const valueData = getValueSerializedFromSource(source, configName, importStatements, filesEnv);
|
|
38
37
|
valueDataList.push(valueData);
|
|
39
38
|
});
|
|
40
39
|
serializeConfigValue(configValueBase, valueDataList, configName, lines, tabspace);
|
|
@@ -42,14 +41,14 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
42
41
|
});
|
|
43
42
|
return lines;
|
|
44
43
|
}
|
|
45
|
-
function getValueSerializedFromSource(configValueSource, configName, importStatements) {
|
|
44
|
+
function getValueSerializedFromSource(configValueSource, configName, importStatements, filesEnv) {
|
|
46
45
|
assert(configValueSource.isOverriden === false);
|
|
47
46
|
let valueData;
|
|
48
47
|
if ('value' in configValueSource) {
|
|
49
|
-
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements);
|
|
48
|
+
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements, filesEnv, configValueSource.configEnv);
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
52
|
-
valueData = getValueSerializedWithImport(configValueSource, importStatements);
|
|
51
|
+
valueData = getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName);
|
|
53
52
|
}
|
|
54
53
|
return valueData;
|
|
55
54
|
}
|
|
@@ -95,27 +94,27 @@ function serializeConfigValue(configValueBase, valueData, configName, lines, tab
|
|
|
95
94
|
tabspace = tabspace.slice(2);
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
|
-
function getValueSerializedWithImport(configValueSource, importStatements) {
|
|
97
|
+
function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
|
|
99
98
|
assert(!configValueSource.valueIsFilePath);
|
|
100
|
-
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath } = configValueSource;
|
|
99
|
+
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath, configEnv } = configValueSource;
|
|
101
100
|
assert(valueIsImportedAtRuntime);
|
|
102
101
|
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
103
102
|
if (valueIsDefinedByPlusFile)
|
|
104
103
|
assert(fileExportName === undefined);
|
|
105
|
-
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*');
|
|
104
|
+
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*', filesEnv, configEnv, configName);
|
|
106
105
|
return {
|
|
107
106
|
type: valueIsDefinedByPlusFile ? 'plus-file' : 'pointer-import',
|
|
108
107
|
valueAsJsCode: importName
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
|
-
function getValueSerializedWithJson(value, configName, definedAtData, importStatements) {
|
|
112
|
-
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements);
|
|
110
|
+
function getValueSerializedWithJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
111
|
+
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv);
|
|
113
112
|
return {
|
|
114
113
|
type: 'js-serialized',
|
|
115
114
|
valueAsJsCode
|
|
116
115
|
};
|
|
117
116
|
}
|
|
118
|
-
function valueToJson(value, configName, definedAtData, importStatements) {
|
|
117
|
+
function valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
119
118
|
const valueName = `config${getPropAccessNotation(configName)}`;
|
|
120
119
|
let configValueSerialized;
|
|
121
120
|
try {
|
|
@@ -130,7 +129,7 @@ function valueToJson(value, configName, definedAtData, importStatements) {
|
|
|
130
129
|
if (typeof value === 'string') {
|
|
131
130
|
const importData = parsePointerImportData(value);
|
|
132
131
|
if (importData) {
|
|
133
|
-
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName);
|
|
132
|
+
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName, filesEnv, configEnv, configName);
|
|
134
133
|
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
135
134
|
return { replacement };
|
|
136
135
|
}
|
|
@@ -167,7 +166,8 @@ function logJsonSerializeError(err, configName, definedAtData) {
|
|
|
167
166
|
}
|
|
168
167
|
function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
169
168
|
const fromComputed = Object.entries(pageConfig.configValuesComputed ?? {}).map(([configName, valueInfo]) => {
|
|
170
|
-
|
|
169
|
+
const { configEnv, value } = valueInfo;
|
|
170
|
+
if (!isEnvMatch(configEnv))
|
|
171
171
|
return 'SKIP';
|
|
172
172
|
// Is there a use case for overriding computed values? If yes, then configValeSources has higher precedence
|
|
173
173
|
if (pageConfig.configValueSources[configName])
|
|
@@ -176,7 +176,7 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
|
176
176
|
type: 'computed',
|
|
177
177
|
definedAtData: null
|
|
178
178
|
};
|
|
179
|
-
return { configValueBase, value
|
|
179
|
+
return { configValueBase, value, configName, configEnv };
|
|
180
180
|
});
|
|
181
181
|
const fromSources = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
|
|
182
182
|
const configDef = pageConfig.configDefinitions[configName];
|
|
@@ -221,3 +221,54 @@ function getDefinedAtFileSource(source) {
|
|
|
221
221
|
};
|
|
222
222
|
return definedAtFile;
|
|
223
223
|
}
|
|
224
|
+
/*
|
|
225
|
+
* Naming:
|
|
226
|
+
* `import { someExport as someImport } from './some-file'`
|
|
227
|
+
* <=>
|
|
228
|
+
* `{`
|
|
229
|
+
* `importPath: './some-file',`
|
|
230
|
+
* `exportName: 'someExport',`
|
|
231
|
+
* `importName: 'someImport',`
|
|
232
|
+
* `}`
|
|
233
|
+
*/
|
|
234
|
+
function addImportStatement(importStatements, importPath, exportName, filesEnv, configEnv, configName) {
|
|
235
|
+
const importCounter = importStatements.length + 1;
|
|
236
|
+
const importName = `import${importCounter}`;
|
|
237
|
+
const importLiteral = (() => {
|
|
238
|
+
if (exportName === '*') {
|
|
239
|
+
return `* as ${importName}`;
|
|
240
|
+
}
|
|
241
|
+
if (exportName === 'default') {
|
|
242
|
+
return importName;
|
|
243
|
+
}
|
|
244
|
+
return `{ ${exportName} as ${importName} }`;
|
|
245
|
+
})();
|
|
246
|
+
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
247
|
+
importStatements.push(importStatement);
|
|
248
|
+
assertFileEnv(importPath, configEnv, configName, filesEnv);
|
|
249
|
+
return { importName };
|
|
250
|
+
}
|
|
251
|
+
function assertFileEnv(importPath, configEnv, configName, filesEnv) {
|
|
252
|
+
const key = importPath;
|
|
253
|
+
assert(key);
|
|
254
|
+
assertPosixPath(key);
|
|
255
|
+
assert(!isRelativeImportPath(key));
|
|
256
|
+
if (!filesEnv.has(key)) {
|
|
257
|
+
filesEnv.set(key, []);
|
|
258
|
+
}
|
|
259
|
+
const fileEnvs = filesEnv.get(key);
|
|
260
|
+
const fileEnvNew = { configEnv, configName };
|
|
261
|
+
fileEnvs.push(fileEnvNew);
|
|
262
|
+
const fileEnvDiff = fileEnvs.filter((c) => !deepEqual(c.configEnv, configEnv))[0];
|
|
263
|
+
if (fileEnvDiff) {
|
|
264
|
+
assertUsage(false, [
|
|
265
|
+
`${importPath} defines the value of configs living in different environments:`,
|
|
266
|
+
...[fileEnvDiff, fileEnvNew].map((c) => ` - config ${pc.code(c.configName)} which value lives in environment ${pc.code(JSON.stringify(c.configEnv))}`),
|
|
267
|
+
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
|
|
268
|
+
].join('\n'));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// TODO/now dedupe
|
|
272
|
+
function isRelativeImportPath(importPath) {
|
|
273
|
+
return importPath.startsWith('./') || importPath.startsWith('../');
|
|
274
|
+
}
|
|
@@ -10,6 +10,7 @@ import { getHookFromPageConfigGlobal, getHookTimeoutDefault } from '../hooks/get
|
|
|
10
10
|
async function loadPageRoutes(
|
|
11
11
|
// Remove all arguments and use GlobalContext instead?
|
|
12
12
|
pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
|
|
13
|
+
// TODO/next-major: remove & make this function sync
|
|
13
14
|
await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
|
|
14
15
|
const { onBeforeRouteHook, filesystemRoots } = getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal);
|
|
15
16
|
const pageRoutes = getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds);
|
|
@@ -12,7 +12,6 @@ export * from '../utils/isPlainObject.js';
|
|
|
12
12
|
export * from '../utils/compareString.js';
|
|
13
13
|
export * from '../utils/isNotNullish.js';
|
|
14
14
|
export * from '../utils/stringifyStringArray.js';
|
|
15
|
-
export * from '../utils/filesystemPathHandling.js';
|
|
16
15
|
export * from '../utils/cast.js';
|
|
17
16
|
export * from '../utils/isPropertyGetter.js';
|
|
18
17
|
export * from '../utils/isPromise.js';
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -16,7 +16,6 @@ export * from '../utils/isPlainObject.js';
|
|
|
16
16
|
export * from '../utils/compareString.js';
|
|
17
17
|
export * from '../utils/isNotNullish.js';
|
|
18
18
|
export * from '../utils/stringifyStringArray.js';
|
|
19
|
-
export * from '../utils/filesystemPathHandling.js';
|
|
20
19
|
export * from '../utils/cast.js';
|
|
21
20
|
export * from '../utils/isPropertyGetter.js';
|
|
22
21
|
export * from '../utils/isPromise.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.221-commit-8577456";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.221-commit-8577456';
|
|
@@ -32,7 +32,7 @@ function onSetupRuntime() {
|
|
|
32
32
|
if (!isViteLoaded()) {
|
|
33
33
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
34
34
|
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 });
|
|
35
|
-
assertUsage(!setup.vikeVitePlugin,
|
|
35
|
+
assertUsage(!setup.vikeVitePlugin, `Loading Vike's Vite plugin (the ${pc.cyan('vike/plugin')} module) is prohibited in production.`);
|
|
36
36
|
// This assert() one of the main goal of this file: it ensures assertIsNotProductionRuntime()
|
|
37
37
|
assert(!setup.shouldNotBeProduction);
|
|
38
38
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { catchInfiniteLoop };
|
|
2
|
+
import { assert, assertWarning } from './assert.js';
|
|
3
|
+
const trackers = {};
|
|
4
|
+
function catchInfiniteLoop(functionName, maxNumberOfCalls = 100, withinSeconds = 5) {
|
|
5
|
+
// Init
|
|
6
|
+
const now = new Date();
|
|
7
|
+
let tracker = (trackers[functionName] ?? (trackers[functionName] = createTracker(now)));
|
|
8
|
+
// Reset
|
|
9
|
+
const elapsedTime = now.getTime() - tracker.start.getTime();
|
|
10
|
+
if (elapsedTime > withinSeconds * 1000)
|
|
11
|
+
tracker = trackers[functionName] = createTracker(now);
|
|
12
|
+
// Count
|
|
13
|
+
tracker.count++;
|
|
14
|
+
// Error
|
|
15
|
+
const msg = `[Infinite Loop] ${functionName} called ${tracker.count} times within ${withinSeconds} seconds`;
|
|
16
|
+
if (tracker.count > maxNumberOfCalls) {
|
|
17
|
+
assert(false, msg);
|
|
18
|
+
}
|
|
19
|
+
// Warning, at 50% threshold
|
|
20
|
+
if (!tracker.warned && tracker.count > maxNumberOfCalls * 0.5) {
|
|
21
|
+
// Warning is shown upon 10 calls a second, on average during 5 seconds, given the default parameters
|
|
22
|
+
assertWarning(false, msg, { onlyOnce: false });
|
|
23
|
+
tracker.warned = true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function createTracker(now) {
|
|
27
|
+
const tracker = {
|
|
28
|
+
count: 0,
|
|
29
|
+
start: now
|
|
30
|
+
};
|
|
31
|
+
return tracker;
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugActivated };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
declare const flags: readonly ["vike:error", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"
|
|
4
|
+
declare const flags: readonly ["vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
5
5
|
type Flag = (typeof flags)[number];
|
|
6
6
|
type Debug = ReturnType<typeof createDebugger>;
|
|
7
7
|
type Options = {
|
package/dist/esm/utils/debug.js
CHANGED
|
@@ -13,6 +13,7 @@ assert(!isBrowser());
|
|
|
13
13
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
14
14
|
const flags = [
|
|
15
15
|
'vike:error',
|
|
16
|
+
'vike:esbuild-resolve',
|
|
16
17
|
'vike:extractAssets',
|
|
17
18
|
'vike:extractExportNames',
|
|
18
19
|
'vike:glob',
|
|
@@ -25,9 +26,9 @@ const flags = [
|
|
|
25
26
|
'vike:routing',
|
|
26
27
|
'vike:setup',
|
|
27
28
|
'vike:stream',
|
|
28
|
-
'vike:virtual-files'
|
|
29
|
-
'vike:esbuild-resolve'
|
|
29
|
+
'vike:virtual-files'
|
|
30
30
|
];
|
|
31
|
+
const flagsSkipWildcard = ['vike:log'];
|
|
31
32
|
const flagRegex = /\bvike:[a-zA-Z-]+/g;
|
|
32
33
|
assertFlagsActivated();
|
|
33
34
|
function createDebugger(flag, optionsGlobal) {
|
|
@@ -72,8 +73,8 @@ function debug_(flag, options, ...msgs) {
|
|
|
72
73
|
function isDebugActivated(flag) {
|
|
73
74
|
checkType(flag);
|
|
74
75
|
assert(flags.includes(flag));
|
|
75
|
-
const flagsActivated = getFlagsActivated();
|
|
76
|
-
const isActivated = flagsActivated.includes(flag);
|
|
76
|
+
const { flagsActivated, all } = getFlagsActivated();
|
|
77
|
+
const isActivated = flagsActivated.includes(flag) || (all && !flagsSkipWildcard.includes(flag));
|
|
77
78
|
return isActivated;
|
|
78
79
|
}
|
|
79
80
|
function formatMsg(info, options, padding, position) {
|
|
@@ -137,7 +138,7 @@ function replaceFunctionSerializer(_key, value) {
|
|
|
137
138
|
return value;
|
|
138
139
|
}
|
|
139
140
|
function assertFlagsActivated() {
|
|
140
|
-
const flagsActivated = getFlagsActivated();
|
|
141
|
+
const { flagsActivated } = getFlagsActivated();
|
|
141
142
|
flagsActivated.forEach((flag) => {
|
|
142
143
|
assertUsage(flags.includes(flag), `Unknown DEBUG flag ${pc.cyan(flag)}. Valid flags:\n${flags.map((f) => ` ${pc.cyan(f)}`).join('\n')}`);
|
|
143
144
|
});
|
|
@@ -145,7 +146,8 @@ function assertFlagsActivated() {
|
|
|
145
146
|
function getFlagsActivated() {
|
|
146
147
|
const DEBUG = getDEBUG() ?? '';
|
|
147
148
|
const flagsActivated = DEBUG.match(flagRegex) ?? [];
|
|
148
|
-
|
|
149
|
+
const all = DEBUG.includes('vike:*');
|
|
150
|
+
return { flagsActivated, all };
|
|
149
151
|
}
|
|
150
152
|
function getDEBUG() {
|
|
151
153
|
let DEBUG;
|
|
@@ -2,7 +2,8 @@ export { findFile };
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { isArray } from './isArray.js';
|
|
5
|
-
import { assertPosixPath } from './
|
|
5
|
+
import { assertPosixPath } from './path.js';
|
|
6
|
+
// We need to be able to crawl the filesystem, regardless of Vike's `$ git ls-files` command call, because we need to fallback if the user didn't setup Git (e.g. we cannot remove the fast-glob fallback).
|
|
6
7
|
function findFile(arg, cwd) {
|
|
7
8
|
assertPosixPath(cwd);
|
|
8
9
|
const filenames = isArray(arg) ? arg : [arg];
|
package/dist/esm/utils/isDev.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { isDevCheck };
|
|
2
2
|
export { applyDev };
|
|
3
3
|
export { applyPreview };
|
|
4
|
-
import {
|
|
4
|
+
import { assertUsage } from './assert.js';
|
|
5
5
|
function isDevCheck(configEnv) {
|
|
6
6
|
const { isPreview, command } = configEnv;
|
|
7
|
-
//
|
|
8
|
-
|
|
7
|
+
// `assertVersion('Vite', version, '5.1.0')` isn't enough: https://github.com/vitejs/vite/pull/19355
|
|
8
|
+
assertUsage(typeof isPreview === 'boolean', 'You are using an old Vite version; make sure to use Vite 5.1.0 or above.');
|
|
9
9
|
return command === 'serve' && !isPreview;
|
|
10
10
|
}
|
|
11
11
|
function applyDev(_, env) {
|
|
@@ -2,7 +2,7 @@ export { assertFilePathAbsoluteFilesystem };
|
|
|
2
2
|
export { isFilePathAbsolute };
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { assert } from './assert.js';
|
|
5
|
-
import { assertPosixPath } from './
|
|
5
|
+
import { assertPosixPath } from './path.js';
|
|
6
6
|
/**
|
|
7
7
|
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
8
8
|
*
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { makePublicCopy };
|
|
2
|
+
/** Prefix internal properties with `_` + show warning */
|
|
3
|
+
declare function makePublicCopy<Obj extends Record<string, unknown>, PropsPublic extends readonly (keyof Obj)[]>(obj: Obj, objName: string, propsPublic: PropsPublic, propsInternalNoWarning?: (keyof Obj)[]): Pick<Obj, PropsPublic[number]>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { makePublicCopy };
|
|
2
|
+
import { assertWarning } from './assert.js';
|
|
3
|
+
import { objectKeys } from './objectKeys.js';
|
|
4
|
+
/** Prefix internal properties with `_` + show warning */
|
|
5
|
+
function makePublicCopy(obj, objName, propsPublic, propsInternalNoWarning) {
|
|
6
|
+
const objPublic = {};
|
|
7
|
+
objectKeys(obj).forEach((key) => {
|
|
8
|
+
const val = obj[key];
|
|
9
|
+
if (propsPublic.includes(key)) {
|
|
10
|
+
objPublic[key] = val;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const keyPublic = key.startsWith('_') ? key : `_${key}`;
|
|
14
|
+
if (propsInternalNoWarning?.includes(key)) {
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
objPublic[keyPublic] = val;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
Object.defineProperty(objPublic, keyPublic, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get() {
|
|
22
|
+
assertWarning(false, `Using internal ${objName}.${keyPublic} which may break in any minor version update. Reach out on GitHub and elaborate your use case so that the Vike team can add official support for your use case.`, { onlyOnce: true });
|
|
23
|
+
return val;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return objPublic;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function objectAssignSafe<Obj extends Record<string, unknown>, ObjNewVals extends Partial<Obj>>(obj: Obj, objNewVals: ObjNewVals): void;
|