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
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveBase = resolveBase;
|
|
7
|
+
exports.resolveBaseRuntime = resolveBaseRuntime;
|
|
7
8
|
exports.resolveBaseFromResolvedConfig = resolveBaseFromResolvedConfig;
|
|
8
9
|
const utils_js_1 = require("./utils.js");
|
|
9
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -12,6 +13,12 @@ function resolveBaseFromResolvedConfig(baseServer, baseAssets, config) {
|
|
|
12
13
|
(0, utils_js_1.assert)(baseViteOriginal === null || typeof baseViteOriginal == 'string');
|
|
13
14
|
return resolveBase(baseViteOriginal, baseServer, baseAssets);
|
|
14
15
|
}
|
|
16
|
+
function resolveBaseRuntime(globalContext) {
|
|
17
|
+
const baseViteOriginal = globalContext.viteConfigRuntime._baseViteOriginal;
|
|
18
|
+
const baseServerUnresolved = globalContext.config.baseServer ?? null;
|
|
19
|
+
const baseAssetsUnresolved = globalContext.config.baseAssets ?? null;
|
|
20
|
+
return resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
|
|
21
|
+
}
|
|
15
22
|
function resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved) {
|
|
16
23
|
if (baseViteOriginal === '/__UNSET__')
|
|
17
24
|
baseViteOriginal = null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPageConfigsRuntime = getPageConfigsRuntime;
|
|
4
|
+
exports.getAllPageIds = getAllPageIds;
|
|
5
|
+
const parseGlobResults_js_1 = require("./getPageFiles/parseGlobResults.js");
|
|
6
|
+
const getPageConfigUserFriendly_js_1 = require("./page-configs/getPageConfigUserFriendly.js");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
8
|
+
function getPageConfigsRuntime(virtualFileExports) {
|
|
9
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseGlobResults_js_1.parseGlobResults)(virtualFileExports);
|
|
10
|
+
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
11
|
+
// TODO/now: re-use this call, instead of calling it twice
|
|
12
|
+
const globalConfig = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)(pageConfigGlobal);
|
|
13
|
+
return { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig };
|
|
14
|
+
}
|
|
15
|
+
function getAllPageIds(pageFilesAll, pageConfigs) {
|
|
16
|
+
const fileIds = pageFilesAll.filter(({ isDefaultPageFile }) => !isDefaultPageFile).map(({ pageId }) => pageId);
|
|
17
|
+
const allPageIds = (0, utils_js_1.unique)(fileIds);
|
|
18
|
+
const allPageIds2 = pageConfigs.map((p) => p.pageId);
|
|
19
|
+
return [...allPageIds, ...allPageIds2];
|
|
20
|
+
}
|
|
@@ -39,24 +39,29 @@ function getUrlParsed(pageContext) {
|
|
|
39
39
|
// 6. The value of pageContext.urlPathname is now '/login': the pathname of `pageContext.urlLogical`. (While pageContext.urlOriginal is still '/fr-FR/admin'.)
|
|
40
40
|
// Reproduction: https://github.com/vikejs/vike/discussions/1436#discussioncomment-8142023
|
|
41
41
|
// Determine logical URL
|
|
42
|
+
// TODO/soon: revert https://github.com/vikejs/vike/issues/2138#issuecomment-2631713411
|
|
43
|
+
const assertUrlResolved = (src) => (0, utils_js_1.assert)(urlResolved && typeof urlResolved === 'string', { src, urlResolved });
|
|
42
44
|
let urlResolved;
|
|
43
45
|
let baseToBeRemoved;
|
|
44
46
|
if (pageContext.urlLogical) {
|
|
45
47
|
// Set by onBeforeRoute()
|
|
46
48
|
urlResolved = pageContext.urlLogical;
|
|
47
49
|
baseToBeRemoved = false;
|
|
50
|
+
assertUrlResolved(1);
|
|
48
51
|
}
|
|
49
52
|
else if (pageContext._urlRewrite) {
|
|
50
53
|
// Set by `throw render()`
|
|
51
54
|
urlResolved = pageContext._urlRewrite;
|
|
52
55
|
baseToBeRemoved = false;
|
|
56
|
+
assertUrlResolved(2);
|
|
53
57
|
}
|
|
54
58
|
else {
|
|
55
59
|
// Set by renderPage()
|
|
56
60
|
urlResolved = pageContext.urlOriginal;
|
|
57
61
|
baseToBeRemoved = true;
|
|
62
|
+
assertUrlResolved(3);
|
|
58
63
|
}
|
|
59
|
-
(
|
|
64
|
+
assertUrlResolved(4);
|
|
60
65
|
// Remove .pageContext.json
|
|
61
66
|
let urlHandler = pageContext._urlHandler;
|
|
62
67
|
if (!urlHandler)
|
|
@@ -21,7 +21,6 @@ function isValidFileType(filePath) {
|
|
|
21
21
|
return ['.js', '.mjs', '.cjs', '.css'].some((ext) => filePath.endsWith(ext));
|
|
22
22
|
}
|
|
23
23
|
function determineFileType(filePath) {
|
|
24
|
-
(0, utils_js_1.assertPosixPath)(filePath);
|
|
25
24
|
{
|
|
26
25
|
const isCSS = filePath.endsWith('.css');
|
|
27
26
|
if (isCSS) {
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.getPageFilesClientSide = getPageFilesClientSide;
|
|
5
5
|
exports.getPageFilesServerSide = getPageFilesServerSide;
|
|
6
6
|
const utils_js_1 = require("../utils.js");
|
|
7
|
-
const assertPageFilePath_js_1 = require("../assertPageFilePath.js");
|
|
8
7
|
function getPageFilesClientSide(pageFilesAll, pageId) {
|
|
9
8
|
return determine(pageFilesAll, pageId, true);
|
|
10
9
|
}
|
|
@@ -88,8 +87,6 @@ function getPageFilesSorter(envIsClient, pageId) {
|
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
89
|
function getPathDistance(pathA, pathB) {
|
|
91
|
-
(0, assertPageFilePath_js_1.assertPageFilePath)(pathA);
|
|
92
|
-
(0, assertPageFilePath_js_1.assertPageFilePath)(pathB);
|
|
93
90
|
// Index of first different character
|
|
94
91
|
let idx = 0;
|
|
95
92
|
for (; idx < pathA.length && idx < pathB.length; idx++) {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.getPageFileObject = getPageFileObject;
|
|
5
5
|
const determinePageIdOld_js_1 = require("../determinePageIdOld.js");
|
|
6
|
-
const assertPageFilePath_js_1 = require("../assertPageFilePath.js");
|
|
7
6
|
const error_page_js_1 = require("../error-page.js");
|
|
8
7
|
const utils_js_1 = require("../utils.js");
|
|
9
8
|
const fileTypes_js_1 = require("./fileTypes.js");
|
|
@@ -38,19 +37,15 @@ function getPageFileObject(filePath) {
|
|
|
38
37
|
return pageFile;
|
|
39
38
|
}
|
|
40
39
|
function isDefaultFilePath(filePath) {
|
|
41
|
-
(0, assertPageFilePath_js_1.assertPageFilePath)(filePath);
|
|
42
40
|
if ((0, error_page_js_1.isErrorPageId)(filePath, false)) {
|
|
43
41
|
return false;
|
|
44
42
|
}
|
|
45
43
|
return filePath.includes('/_default');
|
|
46
44
|
}
|
|
47
45
|
function isRendererFilePath(filePath) {
|
|
48
|
-
(0, assertPageFilePath_js_1.assertPageFilePath)(filePath);
|
|
49
46
|
return filePath.includes('/renderer/');
|
|
50
47
|
}
|
|
51
48
|
function isAncestorDefaultPage(pageId, defaultPageFilePath) {
|
|
52
|
-
(0, assertPageFilePath_js_1.assertPageFilePath)(pageId);
|
|
53
|
-
(0, assertPageFilePath_js_1.assertPageFilePath)(defaultPageFilePath);
|
|
54
49
|
(0, utils_js_1.assert)(!pageId.endsWith('/'));
|
|
55
50
|
(0, utils_js_1.assert)(!defaultPageFilePath.endsWith('/'));
|
|
56
51
|
(0, utils_js_1.assert)(isDefaultFilePath(defaultPageFilePath));
|
|
@@ -7,6 +7,7 @@ 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
9
|
const parsePageConfigs_js_1 = require("../page-configs/serialize/parsePageConfigs.js");
|
|
10
|
+
// TODO/now: rename
|
|
10
11
|
function parseGlobResults(pageFilesExports) {
|
|
11
12
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'pageFilesLazy', 'object'));
|
|
12
13
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageFilesExports, 'pageFilesEager', 'object'));
|
|
@@ -62,11 +63,11 @@ function parseGlobResults(pageFilesExports) {
|
|
|
62
63
|
pageFilesExports.pageFilesList.forEach((filePath) => {
|
|
63
64
|
pageFilesMap[filePath] = pageFilesMap[filePath] ?? (0, getPageFileObject_js_1.getPageFileObject)(filePath);
|
|
64
65
|
});
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const pageFilesAll = Object.values(pageFilesMap);
|
|
67
|
+
pageFilesAll.forEach(({ filePath }) => {
|
|
67
68
|
(0, utils_js_1.assert)(!filePath.includes('\\'));
|
|
68
69
|
});
|
|
69
|
-
return {
|
|
70
|
+
return { pageFilesAll, pageConfigs, pageConfigGlobal };
|
|
70
71
|
}
|
|
71
72
|
function parseGlobResult(globObject) {
|
|
72
73
|
const ret = [];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getPageFilesServerSide = exports.getPageFilesClientSide = void 0;
|
|
4
4
|
var getAllPageIdFiles_js_1 = require("./getPageFiles/getAllPageIdFiles.js");
|
|
5
5
|
Object.defineProperty(exports, "getPageFilesClientSide", { enumerable: true, get: function () { return getAllPageIdFiles_js_1.getPageFilesClientSide; } });
|
|
6
6
|
var getAllPageIdFiles_js_2 = require("./getPageFiles/getAllPageIdFiles.js");
|
|
7
7
|
Object.defineProperty(exports, "getPageFilesServerSide", { enumerable: true, get: function () { return getAllPageIdFiles_js_2.getPageFilesServerSide; } });
|
|
8
|
-
var getPageConfigUserFriendly_js_1 = require("./page-configs/getPageConfigUserFriendly.js");
|
|
9
|
-
Object.defineProperty(exports, "getPageConfigUserFriendly", { enumerable: true, get: function () { return getPageConfigUserFriendly_js_1.getPageConfigUserFriendly; } });
|
|
@@ -3,14 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getPageConfigUserFriendlyOld = getPageConfigUserFriendlyOld;
|
|
7
7
|
exports.getPageConfigUserFriendlyNew = getPageConfigUserFriendlyNew;
|
|
8
8
|
const assert_exports_old_design_js_1 = require("../getPageFiles/assert_exports_old_design.js");
|
|
9
9
|
const getConfigDefinedAt_js_1 = require("./getConfigDefinedAt.js");
|
|
10
10
|
const helpers_js_1 = require("./helpers.js");
|
|
11
11
|
const utils_js_1 = require("../utils.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
function
|
|
13
|
+
function getPageConfigUserFriendlyNew(pageConfig) {
|
|
14
|
+
const res = getPageConfigUserFriendlyV1Desin(pageConfig);
|
|
15
|
+
return {
|
|
16
|
+
config: res.config,
|
|
17
|
+
_source: res.source,
|
|
18
|
+
_sources: res.sources,
|
|
19
|
+
_from: res.from
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
14
23
|
const config = {};
|
|
15
24
|
const configEntries = {}; // TODO/v1-release: remove
|
|
16
25
|
const exportsAll = {}; // TODO/v1-release: remove
|
|
@@ -35,7 +44,7 @@ function getPageConfigUserFriendly(pageFiles, pageConfig) {
|
|
|
35
44
|
let sources;
|
|
36
45
|
let from;
|
|
37
46
|
if (pageConfig) {
|
|
38
|
-
const res =
|
|
47
|
+
const res = getPageConfigUserFriendlyV1Desin(pageConfig);
|
|
39
48
|
source = res.source;
|
|
40
49
|
sources = res.sources;
|
|
41
50
|
from = res.from;
|
|
@@ -68,11 +77,11 @@ function getPageConfigUserFriendly(pageFiles, pageConfig) {
|
|
|
68
77
|
(0, utils_js_1.assert)(!('default' in exports));
|
|
69
78
|
(0, utils_js_1.assert)(!('default' in exportsAll));
|
|
70
79
|
const pageContextExports = {
|
|
80
|
+
config: config,
|
|
71
81
|
from,
|
|
72
82
|
source,
|
|
73
83
|
sources,
|
|
74
84
|
// TODO/eventually: deprecate/remove every prop below
|
|
75
|
-
config,
|
|
76
85
|
configEntries,
|
|
77
86
|
exports,
|
|
78
87
|
exportsAll,
|
|
@@ -81,7 +90,7 @@ function getPageConfigUserFriendly(pageFiles, pageConfig) {
|
|
|
81
90
|
return pageContextExports;
|
|
82
91
|
}
|
|
83
92
|
// V1 design
|
|
84
|
-
function
|
|
93
|
+
function getPageConfigUserFriendlyV1Desin(pageConfig) {
|
|
85
94
|
const config = {};
|
|
86
95
|
const configEntries = {};
|
|
87
96
|
const exportsAll = {};
|
|
@@ -156,7 +165,7 @@ function getPageConfigUserFriendlyNew(pageConfig) {
|
|
|
156
165
|
});
|
|
157
166
|
});
|
|
158
167
|
return {
|
|
159
|
-
config,
|
|
168
|
+
config: config,
|
|
160
169
|
configEntries,
|
|
161
170
|
exportsAll,
|
|
162
171
|
source,
|
|
@@ -9,7 +9,11 @@ async function loadConfigValues(pageConfig, isDev) {
|
|
|
9
9
|
!isDev) {
|
|
10
10
|
return pageConfig;
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const { moduleId, moduleExports } = pageConfig.loadConfigValuesAll();
|
|
13
|
+
const configValuesLoaded = await moduleExports;
|
|
14
|
+
// `configValuesLoaded` is sometimes `undefined` https://github.com/vikejs/vike/discussions/2092
|
|
15
|
+
if (!configValuesLoaded)
|
|
16
|
+
(0, utils_js_1.assert)(false, { moduleExports, configValuesLoaded, moduleId });
|
|
13
17
|
const configValues = (0, parsePageConfigs_js_1.parseConfigValuesSerialized)(configValuesLoaded.configValuesSerialized);
|
|
14
18
|
Object.assign(pageConfig.configValues, configValues);
|
|
15
19
|
(0, utils_js_1.objectAssign)(pageConfig, { isAllLoaded: true });
|
|
@@ -7,7 +7,6 @@ exports.serializeConfigValues = serializeConfigValues;
|
|
|
7
7
|
exports.getConfigValuesBase = getConfigValuesBase;
|
|
8
8
|
const assertSetup_js_1 = require("../../../utils/assertSetup.js");
|
|
9
9
|
const utils_js_1 = require("../../../node/plugin/utils.js");
|
|
10
|
-
const addImportStatement_js_1 = require("../../../node/plugin/plugins/importUserCode/addImportStatement.js");
|
|
11
10
|
const transformPointerImports_js_1 = require("../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformPointerImports.js");
|
|
12
11
|
const helpers_js_1 = require("../helpers.js");
|
|
13
12
|
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
@@ -18,20 +17,20 @@ const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
|
18
17
|
// - vike/shared/page-configs/serialize/parsePageConfigs.ts
|
|
19
18
|
// - parsePageConfigs() is loaded on both the client- and server-side.
|
|
20
19
|
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
21
|
-
function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace, isEager) {
|
|
20
|
+
function serializeConfigValues(pageConfig, importStatements, filesEnv, isEnvMatch, tabspace, isEager) {
|
|
22
21
|
const lines = [];
|
|
23
22
|
tabspace += ' ';
|
|
24
23
|
getConfigValuesBase(pageConfig, isEnvMatch, isEager).forEach((entry) => {
|
|
25
24
|
if (entry.configValueBase.type === 'computed') {
|
|
26
25
|
(0, utils_js_1.assert)('value' in entry); // Help TS
|
|
27
|
-
const { configValueBase, value, configName } = entry;
|
|
28
|
-
const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements);
|
|
26
|
+
const { configValueBase, value, configName, configEnv } = entry;
|
|
27
|
+
const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements, filesEnv, configEnv);
|
|
29
28
|
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
30
29
|
}
|
|
31
30
|
if (entry.configValueBase.type === 'standard') {
|
|
32
31
|
(0, utils_js_1.assert)('sourceRelevant' in entry); // Help TS
|
|
33
32
|
const { configValueBase, sourceRelevant, configName } = entry;
|
|
34
|
-
const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements);
|
|
33
|
+
const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements, filesEnv);
|
|
35
34
|
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
36
35
|
}
|
|
37
36
|
if (entry.configValueBase.type === 'cumulative') {
|
|
@@ -39,7 +38,7 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
39
38
|
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
40
39
|
const valueDataList = [];
|
|
41
40
|
sourcesRelevant.forEach((source) => {
|
|
42
|
-
const valueData = getValueSerializedFromSource(source, configName, importStatements);
|
|
41
|
+
const valueData = getValueSerializedFromSource(source, configName, importStatements, filesEnv);
|
|
43
42
|
valueDataList.push(valueData);
|
|
44
43
|
});
|
|
45
44
|
serializeConfigValue(configValueBase, valueDataList, configName, lines, tabspace);
|
|
@@ -47,14 +46,14 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
|
|
|
47
46
|
});
|
|
48
47
|
return lines;
|
|
49
48
|
}
|
|
50
|
-
function getValueSerializedFromSource(configValueSource, configName, importStatements) {
|
|
49
|
+
function getValueSerializedFromSource(configValueSource, configName, importStatements, filesEnv) {
|
|
51
50
|
(0, utils_js_1.assert)(configValueSource.isOverriden === false);
|
|
52
51
|
let valueData;
|
|
53
52
|
if ('value' in configValueSource) {
|
|
54
|
-
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements);
|
|
53
|
+
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements, filesEnv, configValueSource.configEnv);
|
|
55
54
|
}
|
|
56
55
|
else {
|
|
57
|
-
valueData = getValueSerializedWithImport(configValueSource, importStatements);
|
|
56
|
+
valueData = getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName);
|
|
58
57
|
}
|
|
59
58
|
return valueData;
|
|
60
59
|
}
|
|
@@ -100,27 +99,27 @@ function serializeConfigValue(configValueBase, valueData, configName, lines, tab
|
|
|
100
99
|
tabspace = tabspace.slice(2);
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
|
-
function getValueSerializedWithImport(configValueSource, importStatements) {
|
|
102
|
+
function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
|
|
104
103
|
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
105
|
-
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath } = configValueSource;
|
|
104
|
+
const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath, configEnv } = configValueSource;
|
|
106
105
|
(0, utils_js_1.assert)(valueIsImportedAtRuntime);
|
|
107
106
|
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
108
107
|
if (valueIsDefinedByPlusFile)
|
|
109
108
|
(0, utils_js_1.assert)(fileExportName === undefined);
|
|
110
|
-
const { importName } =
|
|
109
|
+
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*', filesEnv, configEnv, configName);
|
|
111
110
|
return {
|
|
112
111
|
type: valueIsDefinedByPlusFile ? 'plus-file' : 'pointer-import',
|
|
113
112
|
valueAsJsCode: importName
|
|
114
113
|
};
|
|
115
114
|
}
|
|
116
|
-
function getValueSerializedWithJson(value, configName, definedAtData, importStatements) {
|
|
117
|
-
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements);
|
|
115
|
+
function getValueSerializedWithJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
116
|
+
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv);
|
|
118
117
|
return {
|
|
119
118
|
type: 'js-serialized',
|
|
120
119
|
valueAsJsCode
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
|
-
function valueToJson(value, configName, definedAtData, importStatements) {
|
|
122
|
+
function valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
124
123
|
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
125
124
|
let configValueSerialized;
|
|
126
125
|
try {
|
|
@@ -135,7 +134,7 @@ function valueToJson(value, configName, definedAtData, importStatements) {
|
|
|
135
134
|
if (typeof value === 'string') {
|
|
136
135
|
const importData = (0, transformPointerImports_js_1.parsePointerImportData)(value);
|
|
137
136
|
if (importData) {
|
|
138
|
-
const { importName } =
|
|
137
|
+
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName, filesEnv, configEnv, configName);
|
|
139
138
|
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
140
139
|
return { replacement };
|
|
141
140
|
}
|
|
@@ -172,7 +171,8 @@ function logJsonSerializeError(err, configName, definedAtData) {
|
|
|
172
171
|
}
|
|
173
172
|
function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
174
173
|
const fromComputed = Object.entries(pageConfig.configValuesComputed ?? {}).map(([configName, valueInfo]) => {
|
|
175
|
-
|
|
174
|
+
const { configEnv, value } = valueInfo;
|
|
175
|
+
if (!isEnvMatch(configEnv))
|
|
176
176
|
return 'SKIP';
|
|
177
177
|
// Is there a use case for overriding computed values? If yes, then configValeSources has higher precedence
|
|
178
178
|
if (pageConfig.configValueSources[configName])
|
|
@@ -181,7 +181,7 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
|
181
181
|
type: 'computed',
|
|
182
182
|
definedAtData: null
|
|
183
183
|
};
|
|
184
|
-
return { configValueBase, value
|
|
184
|
+
return { configValueBase, value, configName, configEnv };
|
|
185
185
|
});
|
|
186
186
|
const fromSources = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
|
|
187
187
|
const configDef = pageConfig.configDefinitions[configName];
|
|
@@ -226,3 +226,54 @@ function getDefinedAtFileSource(source) {
|
|
|
226
226
|
};
|
|
227
227
|
return definedAtFile;
|
|
228
228
|
}
|
|
229
|
+
/*
|
|
230
|
+
* Naming:
|
|
231
|
+
* `import { someExport as someImport } from './some-file'`
|
|
232
|
+
* <=>
|
|
233
|
+
* `{`
|
|
234
|
+
* `importPath: './some-file',`
|
|
235
|
+
* `exportName: 'someExport',`
|
|
236
|
+
* `importName: 'someImport',`
|
|
237
|
+
* `}`
|
|
238
|
+
*/
|
|
239
|
+
function addImportStatement(importStatements, importPath, exportName, filesEnv, configEnv, configName) {
|
|
240
|
+
const importCounter = importStatements.length + 1;
|
|
241
|
+
const importName = `import${importCounter}`;
|
|
242
|
+
const importLiteral = (() => {
|
|
243
|
+
if (exportName === '*') {
|
|
244
|
+
return `* as ${importName}`;
|
|
245
|
+
}
|
|
246
|
+
if (exportName === 'default') {
|
|
247
|
+
return importName;
|
|
248
|
+
}
|
|
249
|
+
return `{ ${exportName} as ${importName} }`;
|
|
250
|
+
})();
|
|
251
|
+
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
252
|
+
importStatements.push(importStatement);
|
|
253
|
+
assertFileEnv(importPath, configEnv, configName, filesEnv);
|
|
254
|
+
return { importName };
|
|
255
|
+
}
|
|
256
|
+
function assertFileEnv(importPath, configEnv, configName, filesEnv) {
|
|
257
|
+
const key = importPath;
|
|
258
|
+
(0, utils_js_1.assert)(key);
|
|
259
|
+
(0, utils_js_1.assertPosixPath)(key);
|
|
260
|
+
(0, utils_js_1.assert)(!isRelativeImportPath(key));
|
|
261
|
+
if (!filesEnv.has(key)) {
|
|
262
|
+
filesEnv.set(key, []);
|
|
263
|
+
}
|
|
264
|
+
const fileEnvs = filesEnv.get(key);
|
|
265
|
+
const fileEnvNew = { configEnv, configName };
|
|
266
|
+
fileEnvs.push(fileEnvNew);
|
|
267
|
+
const fileEnvDiff = fileEnvs.filter((c) => !(0, utils_js_1.deepEqual)(c.configEnv, configEnv))[0];
|
|
268
|
+
if (fileEnvDiff) {
|
|
269
|
+
(0, utils_js_1.assertUsage)(false, [
|
|
270
|
+
`${importPath} defines the value of configs living in different environments:`,
|
|
271
|
+
...[fileEnvDiff, fileEnvNew].map((c) => ` - config ${picocolors_1.default.code(c.configName)} which value lives in environment ${picocolors_1.default.code(JSON.stringify(c.configEnv))}`),
|
|
272
|
+
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
|
|
273
|
+
].join('\n'));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// TODO/now dedupe
|
|
277
|
+
function isRelativeImportPath(importPath) {
|
|
278
|
+
return importPath.startsWith('./') || importPath.startsWith('../');
|
|
279
|
+
}
|
|
@@ -12,6 +12,7 @@ const getHook_js_1 = require("../hooks/getHook.js");
|
|
|
12
12
|
async function loadPageRoutes(
|
|
13
13
|
// Remove all arguments and use GlobalContext instead?
|
|
14
14
|
pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
|
|
15
|
+
// TODO/next-major: remove & make this function sync
|
|
15
16
|
await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
|
|
16
17
|
const { onBeforeRouteHook, filesystemRoots } = getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal);
|
|
17
18
|
const pageRoutes = getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds);
|
package/dist/cjs/shared/utils.js
CHANGED
|
@@ -32,7 +32,6 @@ __exportStar(require("../utils/isPlainObject.js"), exports);
|
|
|
32
32
|
__exportStar(require("../utils/compareString.js"), exports);
|
|
33
33
|
__exportStar(require("../utils/isNotNullish.js"), exports);
|
|
34
34
|
__exportStar(require("../utils/stringifyStringArray.js"), exports);
|
|
35
|
-
__exportStar(require("../utils/filesystemPathHandling.js"), exports);
|
|
36
35
|
__exportStar(require("../utils/cast.js"), exports);
|
|
37
36
|
__exportStar(require("../utils/isPropertyGetter.js"), exports);
|
|
38
37
|
__exportStar(require("../utils/isPromise.js"), exports);
|
|
@@ -37,7 +37,7 @@ function onSetupRuntime() {
|
|
|
37
37
|
if (!isViteLoaded()) {
|
|
38
38
|
// TODO: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
39
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,
|
|
40
|
+
(0, assert_js_1.assertUsage)(!setup.vikeVitePlugin, `Loading Vike's Vite plugin (the ${picocolors_1.default.cyan('vike/plugin')} module) is prohibited in production.`);
|
|
41
41
|
// This assert() one of the main goal of this file: it ensures assertIsNotProductionRuntime()
|
|
42
42
|
(0, assert_js_1.assert)(!setup.shouldNotBeProduction);
|
|
43
43
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.catchInfiniteLoop = catchInfiniteLoop;
|
|
4
|
+
const assert_js_1 = require("./assert.js");
|
|
5
|
+
const trackers = {};
|
|
6
|
+
function catchInfiniteLoop(functionName, maxNumberOfCalls = 100, withinSeconds = 5) {
|
|
7
|
+
// Init
|
|
8
|
+
const now = new Date();
|
|
9
|
+
let tracker = (trackers[functionName] ?? (trackers[functionName] = createTracker(now)));
|
|
10
|
+
// Reset
|
|
11
|
+
const elapsedTime = now.getTime() - tracker.start.getTime();
|
|
12
|
+
if (elapsedTime > withinSeconds * 1000)
|
|
13
|
+
tracker = trackers[functionName] = createTracker(now);
|
|
14
|
+
// Count
|
|
15
|
+
tracker.count++;
|
|
16
|
+
// Error
|
|
17
|
+
const msg = `[Infinite Loop] ${functionName} called ${tracker.count} times within ${withinSeconds} seconds`;
|
|
18
|
+
if (tracker.count > maxNumberOfCalls) {
|
|
19
|
+
(0, assert_js_1.assert)(false, msg);
|
|
20
|
+
}
|
|
21
|
+
// Warning, at 50% threshold
|
|
22
|
+
if (!tracker.warned && tracker.count > maxNumberOfCalls * 0.5) {
|
|
23
|
+
// Warning is shown upon 10 calls a second, on average during 5 seconds, given the default parameters
|
|
24
|
+
(0, assert_js_1.assertWarning)(false, msg, { onlyOnce: false });
|
|
25
|
+
tracker.warned = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function createTracker(now) {
|
|
29
|
+
const tracker = {
|
|
30
|
+
count: 0,
|
|
31
|
+
start: now
|
|
32
|
+
};
|
|
33
|
+
return tracker;
|
|
34
|
+
}
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -18,6 +18,7 @@ const isArray_js_1 = require("./isArray.js");
|
|
|
18
18
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
19
19
|
const flags = [
|
|
20
20
|
'vike:error',
|
|
21
|
+
'vike:esbuild-resolve',
|
|
21
22
|
'vike:extractAssets',
|
|
22
23
|
'vike:extractExportNames',
|
|
23
24
|
'vike:glob',
|
|
@@ -30,9 +31,9 @@ const flags = [
|
|
|
30
31
|
'vike:routing',
|
|
31
32
|
'vike:setup',
|
|
32
33
|
'vike:stream',
|
|
33
|
-
'vike:virtual-files'
|
|
34
|
-
'vike:esbuild-resolve'
|
|
34
|
+
'vike:virtual-files'
|
|
35
35
|
];
|
|
36
|
+
const flagsSkipWildcard = ['vike:log'];
|
|
36
37
|
const flagRegex = /\bvike:[a-zA-Z-]+/g;
|
|
37
38
|
assertFlagsActivated();
|
|
38
39
|
function createDebugger(flag, optionsGlobal) {
|
|
@@ -77,8 +78,8 @@ function debug_(flag, options, ...msgs) {
|
|
|
77
78
|
function isDebugActivated(flag) {
|
|
78
79
|
(0, checkType_js_1.checkType)(flag);
|
|
79
80
|
(0, assert_js_1.assert)(flags.includes(flag));
|
|
80
|
-
const flagsActivated = getFlagsActivated();
|
|
81
|
-
const isActivated = flagsActivated.includes(flag);
|
|
81
|
+
const { flagsActivated, all } = getFlagsActivated();
|
|
82
|
+
const isActivated = flagsActivated.includes(flag) || (all && !flagsSkipWildcard.includes(flag));
|
|
82
83
|
return isActivated;
|
|
83
84
|
}
|
|
84
85
|
function formatMsg(info, options, padding, position) {
|
|
@@ -142,7 +143,7 @@ function replaceFunctionSerializer(_key, value) {
|
|
|
142
143
|
return value;
|
|
143
144
|
}
|
|
144
145
|
function assertFlagsActivated() {
|
|
145
|
-
const flagsActivated = getFlagsActivated();
|
|
146
|
+
const { flagsActivated } = getFlagsActivated();
|
|
146
147
|
flagsActivated.forEach((flag) => {
|
|
147
148
|
(0, assert_js_1.assertUsage)(flags.includes(flag), `Unknown DEBUG flag ${picocolors_1.default.cyan(flag)}. Valid flags:\n${flags.map((f) => ` ${picocolors_1.default.cyan(f)}`).join('\n')}`);
|
|
148
149
|
});
|
|
@@ -150,7 +151,8 @@ function assertFlagsActivated() {
|
|
|
150
151
|
function getFlagsActivated() {
|
|
151
152
|
const DEBUG = getDEBUG() ?? '';
|
|
152
153
|
const flagsActivated = DEBUG.match(flagRegex) ?? [];
|
|
153
|
-
|
|
154
|
+
const all = DEBUG.includes('vike:*');
|
|
155
|
+
return { flagsActivated, all };
|
|
154
156
|
}
|
|
155
157
|
function getDEBUG() {
|
|
156
158
|
let DEBUG;
|
|
@@ -7,16 +7,17 @@ exports.findFile = findFile;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const isArray_js_1 = require("./isArray.js");
|
|
10
|
-
const
|
|
10
|
+
const path_js_1 = require("./path.js");
|
|
11
|
+
// 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).
|
|
11
12
|
function findFile(arg, cwd) {
|
|
12
|
-
(0,
|
|
13
|
+
(0, path_js_1.assertPosixPath)(cwd);
|
|
13
14
|
const filenames = (0, isArray_js_1.isArray)(arg) ? arg : [arg];
|
|
14
15
|
let dir = cwd;
|
|
15
16
|
while (true) {
|
|
16
17
|
for (const filename of filenames) {
|
|
17
18
|
const configFilePath = path_1.default.posix.join(dir, `./${filename}`);
|
|
18
19
|
if (fs_1.default.existsSync(configFilePath)) {
|
|
19
|
-
(0,
|
|
20
|
+
(0, path_js_1.assertPosixPath)(configFilePath);
|
|
20
21
|
return configFilePath;
|
|
21
22
|
}
|
|
22
23
|
}
|
package/dist/cjs/utils/isDev.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.applyPreview = applyPreview;
|
|
|
6
6
|
const assert_js_1 = require("./assert.js");
|
|
7
7
|
function isDevCheck(configEnv) {
|
|
8
8
|
const { isPreview, command } = configEnv;
|
|
9
|
-
//
|
|
10
|
-
(0, assert_js_1.
|
|
9
|
+
// `assertVersion('Vite', version, '5.1.0')` isn't enough: https://github.com/vitejs/vite/pull/19355
|
|
10
|
+
(0, assert_js_1.assertUsage)(typeof isPreview === 'boolean', 'You are using an old Vite version; make sure to use Vite 5.1.0 or above.');
|
|
11
11
|
return command === 'serve' && !isPreview;
|
|
12
12
|
}
|
|
13
13
|
function applyDev(_, env) {
|
|
@@ -7,7 +7,7 @@ exports.assertFilePathAbsoluteFilesystem = assertFilePathAbsoluteFilesystem;
|
|
|
7
7
|
exports.isFilePathAbsolute = isFilePathAbsolute;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const assert_js_1 = require("./assert.js");
|
|
10
|
-
const
|
|
10
|
+
const path_js_1 = require("./path.js");
|
|
11
11
|
/**
|
|
12
12
|
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
13
13
|
*
|
|
@@ -19,7 +19,7 @@ function assertFilePathAbsoluteFilesystem(filePath) {
|
|
|
19
19
|
// - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
20
20
|
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
21
21
|
(0, assert_js_1.assert)(isFilePathAbsoluteFilesystem(filePath));
|
|
22
|
-
(0,
|
|
22
|
+
(0, path_js_1.assertPosixPath)(filePath);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Whether `filePath` is an absolute file path starting from the filesystem root.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePublicCopy = makePublicCopy;
|
|
4
|
+
const assert_js_1 = require("./assert.js");
|
|
5
|
+
const objectKeys_js_1 = require("./objectKeys.js");
|
|
6
|
+
/** Prefix internal properties with `_` + show warning */
|
|
7
|
+
function makePublicCopy(obj, objName, propsPublic, propsInternalNoWarning) {
|
|
8
|
+
const objPublic = {};
|
|
9
|
+
(0, objectKeys_js_1.objectKeys)(obj).forEach((key) => {
|
|
10
|
+
const val = obj[key];
|
|
11
|
+
if (propsPublic.includes(key)) {
|
|
12
|
+
objPublic[key] = val;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const keyPublic = key.startsWith('_') ? key : `_${key}`;
|
|
16
|
+
if (propsInternalNoWarning?.includes(key)) {
|
|
17
|
+
// @ts-expect-error
|
|
18
|
+
objPublic[keyPublic] = val;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
Object.defineProperty(objPublic, keyPublic, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get() {
|
|
24
|
+
(0, assert_js_1.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 });
|
|
25
|
+
return val;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return objPublic;
|
|
32
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectAssignSafe = objectAssignSafe;
|
|
4
|
+
// Same as `Object.assign(obj, objNewVals)` but ensure that `objNewVals` properties alreay exist on `obj`
|
|
5
|
+
function objectAssignSafe(obj, objNewVals) {
|
|
6
|
+
Object.assign(obj, objNewVals);
|
|
7
|
+
}
|