vike 0.4.239 → 0.4.240-commit-bac5dee
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/esm/client/index.d.ts +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-client-routing/entry.js +5 -3
- package/dist/esm/client/runtime-client-routing/getBaseServer.js +0 -1
- package/dist/esm/client/runtime-client-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +2 -2
- package/dist/esm/client/runtime-client-routing/{globalContext.js → getGlobalContextClientInternal.js} +8 -4
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +6 -6
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/runtime-client-routing/isClientSideRoutable.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +4 -4
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +15 -4
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-server-routing/entry.js +5 -3
- package/dist/esm/client/runtime-server-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +2 -2
- package/dist/esm/client/runtime-server-routing/getGlobalContextClientInternal.js +6 -0
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +1 -1
- package/dist/esm/client/shared/{createGetGlobalContextClient.d.ts → getGlobalContextClientInternalShared.d.ts} +11 -8
- package/dist/esm/client/shared/getGlobalContextClientInternalShared.js +66 -0
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +1 -3
- package/dist/esm/node/prerender/runPrerender.d.ts +4 -2
- package/dist/esm/node/prerender/runPrerender.js +5 -2
- package/dist/esm/node/runtime/globalContext.d.ts +15 -2
- package/dist/esm/node/runtime/globalContext.js +46 -32
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +8 -4
- package/dist/esm/node/runtime/renderPage.d.ts +4 -2
- package/dist/esm/node/vite/index.js +42 -18
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/handleAssetsManifest.d.ts +4 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/handleAssetsManifest.js +21 -6
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildApp.js +24 -20
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildConfig.js +20 -6
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginDistFileNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/build/pluginDistFileNames.js +253 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginDistPackageJsonFile.d.ts +1 -1
- package/dist/esm/node/vite/plugins/build/pluginDistPackageJsonFile.js +40 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginModuleBanner.d.ts +1 -1
- package/dist/esm/node/vite/plugins/build/pluginModuleBanner.js +49 -0
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginProdBuildEntry.js +4 -2
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginSuppressRollupWarning.d.ts +1 -1
- package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginSuppressRollupWarning.js +27 -23
- package/dist/esm/node/vite/plugins/non-runnable-dev/pluginReplaceConstantsNonRunnableDev.d.ts +7 -0
- package/dist/esm/node/vite/plugins/non-runnable-dev/pluginReplaceConstantsNonRunnableDev.js +47 -0
- package/dist/esm/node/vite/plugins/{pluginNonRunnableDev.d.ts → non-runnable-dev/pluginViteRPC.d.ts} +3 -7
- package/dist/esm/node/vite/plugins/non-runnable-dev/pluginViteRPC.js +30 -0
- package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBaseUrls.js +39 -33
- package/dist/esm/node/vite/plugins/pluginCommon.js +8 -28
- package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +1 -1
- package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +108 -92
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +39 -23
- package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +117 -92
- package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginPreview.js +38 -30
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsEnvVars.js +127 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.d.ts +17 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.js +52 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsPageContext.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsPageContext.js +89 -0
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +67 -47
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +13 -9
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
- package/dist/esm/node/vite/shared/getMagicString.d.ts +1 -1
- package/dist/esm/node/vite/shared/getMagicString.js +2 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +2 -2
- package/dist/esm/shared/createGlobalContextShared.d.ts +4 -4
- package/dist/esm/shared/route/abort.d.ts +22 -11
- package/dist/esm/shared/route/abort.js +45 -5
- package/dist/esm/shared/route/index.js +13 -4
- package/dist/esm/shared/route/utils.d.ts +1 -0
- package/dist/esm/shared/route/utils.js +1 -0
- package/dist/esm/types/Config.d.ts +1 -1
- package/dist/esm/types/PageContext.d.ts +8 -8
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +1 -0
- package/dist/esm/utils/debug.d.ts +5 -3
- package/dist/esm/utils/debug.js +28 -11
- package/dist/esm/utils/findPackageJson.js +0 -1
- package/dist/esm/utils/getGlobalObject.d.ts +5 -1
- package/dist/esm/utils/getGlobalObject.js +5 -1
- package/dist/esm/utils/getViteRPC.js +0 -2
- package/dist/esm/utils/isDev.js +3 -1
- package/dist/esm/utils/isNonRunnableDev.js +2 -2
- package/dist/esm/utils/requireResolve.js +1 -2
- package/dist/esm/utils/virtualFileId.d.ts +4 -0
- package/dist/esm/utils/virtualFileId.js +14 -11
- package/package.json +7 -26
- package/dist/cjs/__internal/index.js +0 -35
- package/dist/cjs/client/runtime-client-routing/globalContext.js +0 -49
- package/dist/cjs/client/runtime-client-routing/prefetch/PrefetchSetting.js +0 -2
- package/dist/cjs/client/runtime-server-routing/globalContext.js +0 -41
- package/dist/cjs/client/runtime-server-routing/onLoad.js +0 -7
- package/dist/cjs/client/runtime-server-routing/utils.js +0 -34
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +0 -65
- package/dist/cjs/client/shared/getJsonSerializedInHtml.js +0 -40
- package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +0 -41
- package/dist/cjs/client/shared/utils.js +0 -23
- package/dist/cjs/node/api/build.js +0 -24
- package/dist/cjs/node/api/context.js +0 -23
- package/dist/cjs/node/api/dev.js +0 -18
- package/dist/cjs/node/api/index.js +0 -44
- package/dist/cjs/node/api/onLoad.js +0 -9
- package/dist/cjs/node/api/prepareViteApiCall.js +0 -206
- package/dist/cjs/node/api/prerender.js +0 -18
- package/dist/cjs/node/api/preview.js +0 -38
- package/dist/cjs/node/api/types.js +0 -2
- package/dist/cjs/node/api/utils.js +0 -27
- package/dist/cjs/node/cli/context.js +0 -17
- package/dist/cjs/node/cli/entry.js +0 -121
- package/dist/cjs/node/cli/index.js +0 -12
- package/dist/cjs/node/cli/onLoad.js +0 -9
- package/dist/cjs/node/cli/parseCli.js +0 -95
- package/dist/cjs/node/cli/utils.js +0 -24
- package/dist/cjs/node/client/router.js +0 -19
- package/dist/cjs/node/createPageRenderer.js +0 -132
- package/dist/cjs/node/importBuild.js +0 -3
- package/dist/cjs/node/prerender/context.js +0 -26
- package/dist/cjs/node/prerender/index.js +0 -12
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +0 -66
- package/dist/cjs/node/prerender/runPrerender.js +0 -777
- package/dist/cjs/node/prerender/runPrerenderEntry.js +0 -55
- package/dist/cjs/node/prerender/utils.js +0 -37
- package/dist/cjs/node/runtime/globalContext.js +0 -572
- package/dist/cjs/node/runtime/index-deprecated.js +0 -33
- package/dist/cjs/node/runtime/index.js +0 -74
- package/dist/cjs/node/runtime/loggerRuntime.js +0 -17
- package/dist/cjs/node/runtime/onLoad.js +0 -29
- package/dist/cjs/node/runtime/page-files/setup.js +0 -5
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +0 -71
- package/dist/cjs/node/runtime/renderPage/assertArguments.js +0 -42
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +0 -51
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -114
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +0 -59
- package/dist/cjs/node/runtime/renderPage/csp.js +0 -47
- package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +0 -31
- package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +0 -120
- package/dist/cjs/node/runtime/renderPage/execHookServer.js +0 -8
- package/dist/cjs/node/runtime/renderPage/getCacheControl.js +0 -24
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +0 -20
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +0 -137
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +0 -125
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.js +0 -86
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.js +0 -77
- package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +0 -36
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +0 -50
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +0 -41
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +0 -68
- package/dist/cjs/node/runtime/renderPage/headersResponse.js +0 -48
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/getHtmlTags.js +0 -269
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/getViteDevScript.js +0 -32
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/inferHtmlTags.js +0 -55
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectAssets__public.js +0 -31
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectHtmlTags.js +0 -161
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/mergeScriptTags.js +0 -73
- package/dist/cjs/node/runtime/renderPage/html/injectAssets/sanitizeJson.js +0 -8
- package/dist/cjs/node/runtime/renderPage/html/injectAssets.js +0 -93
- package/dist/cjs/node/runtime/renderPage/html/propKeys.js +0 -47
- package/dist/cjs/node/runtime/renderPage/html/renderHtml.js +0 -245
- package/dist/cjs/node/runtime/renderPage/html/serializeContext.js +0 -189
- package/dist/cjs/node/runtime/renderPage/html/stream/react-streaming.js +0 -36
- package/dist/cjs/node/runtime/renderPage/html/stream.js +0 -829
- package/dist/cjs/node/runtime/renderPage/inferMediaType.js +0 -81
- package/dist/cjs/node/runtime/renderPage/isFontFallback.js +0 -29
- package/dist/cjs/node/runtime/renderPage/isNewError.js +0 -25
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +0 -124
- package/dist/cjs/node/runtime/renderPage/log404/index.js +0 -154
- package/dist/cjs/node/runtime/renderPage/logErrorHint/errors.js +0 -20
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +0 -200
- package/dist/cjs/node/runtime/renderPage/loggerProd.js +0 -34
- package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +0 -10
- package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +0 -83
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -71
- package/dist/cjs/node/runtime/renderPage.js +0 -502
- package/dist/cjs/node/runtime/universal-middleware.js +0 -20
- package/dist/cjs/node/runtime/utils.js +0 -83
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -27
- package/dist/cjs/node/runtime-dev/index.js +0 -42
- package/dist/cjs/node/shared/assertV1Design.js +0 -30
- package/dist/cjs/node/shared/extractAssetsQuery.js +0 -29
- package/dist/cjs/node/shared/getVikeConfigError.js +0 -22
- package/dist/cjs/node/shared/isErrorDebug.js +0 -7
- package/dist/cjs/node/shared/prependEntriesDir.js +0 -13
- package/dist/cjs/node/shared/resolveBase.js +0 -35
- package/dist/cjs/node/shared/utils.js +0 -35
- package/dist/cjs/node/shared/virtualFileId.js +0 -110
- package/dist/cjs/node/vite/index.js +0 -69
- package/dist/cjs/node/vite/onLoad.js +0 -21
- package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +0 -48
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -342
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -179
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -220
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -254
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -36
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -41
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -109
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -63
- package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -21
- package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
- package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -197
- package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -28
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +0 -163
- package/dist/cjs/node/vite/plugins/pluginDev.js +0 -107
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -87
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -227
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -99
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -149
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -52
- package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -76
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -69
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -49
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/debug.js +0 -5
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +0 -56
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +0 -190
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +0 -54
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +0 -97
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +0 -215
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -15
- package/dist/cjs/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +0 -35
- package/dist/cjs/node/vite/shared/addSsrMiddleware.js +0 -60
- package/dist/cjs/node/vite/shared/findPageFiles.js +0 -25
- package/dist/cjs/node/vite/shared/getAssetsDir.js +0 -10
- package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +0 -42
- package/dist/cjs/node/vite/shared/getEnvVarObject.js +0 -37
- package/dist/cjs/node/vite/shared/getFilePath.js +0 -172
- package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +0 -125
- package/dist/cjs/node/vite/shared/getMagicString.js +0 -18
- package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +0 -10
- package/dist/cjs/node/vite/shared/getOutDirs.js +0 -146
- package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +0 -21
- package/dist/cjs/node/vite/shared/isAsset.js +0 -40
- package/dist/cjs/node/vite/shared/isViteCliCall.js +0 -83
- package/dist/cjs/node/vite/shared/isViteServerSide.js +0 -68
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +0 -15
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.js +0 -15
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +0 -38
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.js +0 -26
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.js +0 -85
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.js +0 -30
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.js +0 -19
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.js +0 -19
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +0 -29
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.js +0 -13
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.js +0 -15
- package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +0 -162
- package/dist/cjs/node/vite/shared/loggerNotProd/log.js +0 -102
- package/dist/cjs/node/vite/shared/loggerNotProd.js +0 -208
- package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -26
- package/dist/cjs/node/vite/shared/loggerVite.js +0 -54
- package/dist/cjs/node/vite/shared/normalizeId.js +0 -9
- package/dist/cjs/node/vite/shared/parseEsModule.js +0 -33
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +0 -136
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -262
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles/ignorePatternsBuiltIn.js +0 -18
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +0 -252
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +0 -190
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getConfigFileExport.js +0 -17
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getPlusFilesAll.js +0 -127
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.js +0 -129
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +0 -195
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +0 -102
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +0 -425
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +0 -1151
- package/dist/cjs/node/vite/shared/rollupIsEsm.js +0 -15
- package/dist/cjs/node/vite/utils.js +0 -45
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -4
- package/dist/cjs/shared/RenderErrorPage.js +0 -6
- package/dist/cjs/shared/abort.js +0 -16
- package/dist/cjs/shared/addIs404ToPageProps.js +0 -18
- package/dist/cjs/shared/assertHookReturnedObject.js +0 -21
- package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +0 -21
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +0 -20
- package/dist/cjs/shared/createGlobalContextShared.js +0 -109
- package/dist/cjs/shared/createPageContextShared.js +0 -17
- package/dist/cjs/shared/determinePageIdOld.js +0 -11
- package/dist/cjs/shared/error-page.js +0 -40
- package/dist/cjs/shared/getPageContext.js +0 -6
- package/dist/cjs/shared/getPageContextRequestUrl.js +0 -16
- package/dist/cjs/shared/getPageContextUrlComputed.js +0 -132
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +0 -19
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/ClientDependency.js +0 -2
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +0 -50
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +0 -30
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +0 -15
- package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +0 -59
- package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +0 -22
- package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +0 -24
- package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -52
- package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -102
- package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -56
- package/dist/cjs/shared/getPageFiles/parseVirtualFileExportsGlobalEntry.js +0 -100
- package/dist/cjs/shared/getPageFiles.js +0 -7
- package/dist/cjs/shared/getProxyForPublicUsage.js +0 -56
- package/dist/cjs/shared/hooks/execHook.js +0 -147
- package/dist/cjs/shared/hooks/getHook.js +0 -173
- package/dist/cjs/shared/htmlElementIds.js +0 -5
- package/dist/cjs/shared/misc/isServerSideError.js +0 -4
- package/dist/cjs/shared/misc/pageContextInitIsPassedToClient.js +0 -4
- package/dist/cjs/shared/modifyUrl.js +0 -28
- package/dist/cjs/shared/modifyUrlSameOrigin.js +0 -47
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +0 -42
- package/dist/cjs/shared/page-configs/findPageConfig.js +0 -10
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +0 -65
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -68
- package/dist/cjs/shared/page-configs/getConfigValueRuntime.js +0 -10
- package/dist/cjs/shared/page-configs/getConfigValueTyped.js +0 -32
- package/dist/cjs/shared/page-configs/getExportPath.js +0 -29
- package/dist/cjs/shared/page-configs/helpers.js +0 -27
- package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +0 -25
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +0 -287
- package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +0 -2
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -1
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigsSerialized.js +0 -145
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +0 -290
- package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +0 -10
- package/dist/cjs/shared/preparePageContextForPublicUsage.js +0 -80
- package/dist/cjs/shared/route/abort.js +0 -178
- package/dist/cjs/shared/route/debug.js +0 -23
- package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +0 -52
- package/dist/cjs/shared/route/execHookGuard.js +0 -37
- package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -84
- package/dist/cjs/shared/route/index.js +0 -107
- package/dist/cjs/shared/route/loadPageRoutes.js +0 -197
- package/dist/cjs/shared/route/noRouteMatch.js +0 -4
- package/dist/cjs/shared/route/resolvePrecedence.js +0 -93
- package/dist/cjs/shared/route/resolveRoute.js +0 -20
- package/dist/cjs/shared/route/resolveRouteFunction.js +0 -73
- package/dist/cjs/shared/route/resolveRouteString.js +0 -153
- package/dist/cjs/shared/route/resolveUrlPathname.js +0 -47
- package/dist/cjs/shared/route/routing.js +0 -9
- package/dist/cjs/shared/route/utils.js +0 -40
- package/dist/cjs/shared/utils.js +0 -49
- package/dist/cjs/types/Config/ConfigResolved.js +0 -2
- package/dist/cjs/types/Config.js +0 -2
- package/dist/cjs/types/FilePath.js +0 -2
- package/dist/cjs/types/PageConfig.js +0 -2
- package/dist/cjs/types/PageContext.js +0 -2
- package/dist/cjs/types/VikeGlobalInternal.js +0 -2
- package/dist/cjs/types/VikeNamespace.js +0 -2
- package/dist/cjs/types/ViteManifest.js +0 -2
- package/dist/cjs/types/defineConfig.js +0 -6
- package/dist/cjs/types/index-dreprecated.js +0 -3
- package/dist/cjs/types/index.js +0 -5
- package/dist/cjs/utils/PROJECT_VERSION.js +0 -5
- package/dist/cjs/utils/PromiseType.js +0 -2
- package/dist/cjs/utils/assert.js +0 -211
- package/dist/cjs/utils/assertIsBrowser.js +0 -8
- package/dist/cjs/utils/assertIsNotBrowser.js +0 -9
- package/dist/cjs/utils/assertKeys.js +0 -27
- package/dist/cjs/utils/assertNodeVersion.js +0 -14
- package/dist/cjs/utils/assertRoutingType.js +0 -29
- package/dist/cjs/utils/assertSetup.js +0 -171
- package/dist/cjs/utils/assertSingleInstance.js +0 -110
- package/dist/cjs/utils/assertVersion.js +0 -60
- package/dist/cjs/utils/capitalizeFirstLetter.js +0 -9
- package/dist/cjs/utils/cast.js +0 -6
- package/dist/cjs/utils/catchInfiniteLoop.js +0 -34
- package/dist/cjs/utils/changeEnumerable.js +0 -8
- package/dist/cjs/utils/checkType.js +0 -6
- package/dist/cjs/utils/compareString.js +0 -10
- package/dist/cjs/utils/createErrorWithCleanStackTrace.js +0 -39
- package/dist/cjs/utils/debug.js +0 -178
- package/dist/cjs/utils/debugGlob.js +0 -6
- package/dist/cjs/utils/deepEqual.js +0 -10
- package/dist/cjs/utils/escapeHtml.js +0 -13
- package/dist/cjs/utils/escapeRegex.js +0 -7
- package/dist/cjs/utils/findFile.js +0 -30
- package/dist/cjs/utils/findPackageJson.js +0 -18
- package/dist/cjs/utils/formatHintLog.js +0 -17
- package/dist/cjs/utils/freezePartial.js +0 -35
- package/dist/cjs/utils/genPromise.js +0 -51
- package/dist/cjs/utils/getFileExtension.js +0 -16
- package/dist/cjs/utils/getGlobalObject.js +0 -15
- package/dist/cjs/utils/getMostSimilar.js +0 -68
- package/dist/cjs/utils/getPropAccessNotation.js +0 -9
- package/dist/cjs/utils/getRandomId.js +0 -14
- package/dist/cjs/utils/getTerminalWidth.js +0 -7
- package/dist/cjs/utils/getValuePrintable.js +0 -10
- package/dist/cjs/utils/getViteRPC.js +0 -79
- package/dist/cjs/utils/hasProp.js +0 -50
- package/dist/cjs/utils/humanizeTime.js +0 -24
- package/dist/cjs/utils/includes.js +0 -13
- package/dist/cjs/utils/injectRollupInputs.js +0 -29
- package/dist/cjs/utils/isArray.js +0 -7
- package/dist/cjs/utils/isArrayOfStrings.js +0 -7
- package/dist/cjs/utils/isBrowser.js +0 -8
- package/dist/cjs/utils/isCallable.js +0 -6
- package/dist/cjs/utils/isDev.js +0 -20
- package/dist/cjs/utils/isDocker.js +0 -45
- package/dist/cjs/utils/isEqualStringList.js +0 -13
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +0 -66
- package/dist/cjs/utils/isHtml.js +0 -9
- package/dist/cjs/utils/isImportPath.js +0 -21
- package/dist/cjs/utils/isNodeJS.js +0 -16
- package/dist/cjs/utils/isNonRunnableDev.js +0 -12
- package/dist/cjs/utils/isNullish.js +0 -16
- package/dist/cjs/utils/isObject.js +0 -6
- package/dist/cjs/utils/isObjectOfStrings.js +0 -7
- package/dist/cjs/utils/isObjectWithKeys.js +0 -15
- package/dist/cjs/utils/isPlainObject.js +0 -19
- package/dist/cjs/utils/isPromise.js +0 -7
- package/dist/cjs/utils/isPropertyGetter.js +0 -7
- package/dist/cjs/utils/isReact.js +0 -23
- package/dist/cjs/utils/isRunnableDevEnvironment.js +0 -9
- package/dist/cjs/utils/isSameErrorMessage.js +0 -9
- package/dist/cjs/utils/isScriptFile.js +0 -67
- package/dist/cjs/utils/isVikeReactApp.js +0 -8
- package/dist/cjs/utils/isVitest.js +0 -6
- package/dist/cjs/utils/joinEnglish.js +0 -14
- package/dist/cjs/utils/normalizeHeaders.js +0 -17
- package/dist/cjs/utils/objectAssign.js +0 -14
- package/dist/cjs/utils/objectAssignSafe.js +0 -7
- package/dist/cjs/utils/objectDefineProperty.js +0 -7
- package/dist/cjs/utils/objectEntries.js +0 -8
- package/dist/cjs/utils/objectEntriesForEach.js +0 -7
- package/dist/cjs/utils/objectFilter.js +0 -10
- package/dist/cjs/utils/objectFromEntries.js +0 -7
- package/dist/cjs/utils/objectKeys.js +0 -9
- package/dist/cjs/utils/objectReplace.js +0 -9
- package/dist/cjs/utils/onPageVisibilityChange.js +0 -18
- package/dist/cjs/utils/pLimit.js +0 -134
- package/dist/cjs/utils/parseNpmPackage.js +0 -106
- package/dist/cjs/utils/parseUrl-extras.js +0 -110
- package/dist/cjs/utils/parseUrl.js +0 -338
- package/dist/cjs/utils/path.js +0 -59
- package/dist/cjs/utils/pick.js +0 -12
- package/dist/cjs/utils/preservePropertyGetters.js +0 -30
- package/dist/cjs/utils/redirectHard.js +0 -6
- package/dist/cjs/utils/removeEmptyLines.js +0 -9
- package/dist/cjs/utils/removeFileExtension.js +0 -6
- package/dist/cjs/utils/requireResolve.js +0 -214
- package/dist/cjs/utils/rollupSourceMap.js +0 -19
- package/dist/cjs/utils/sleep.js +0 -6
- package/dist/cjs/utils/slice.js +0 -35
- package/dist/cjs/utils/sorter.js +0 -117
- package/dist/cjs/utils/stringifyStringArray.js +0 -6
- package/dist/cjs/utils/stripAnsi.js +0 -21
- package/dist/cjs/utils/styleFileRE.js +0 -6
- package/dist/cjs/utils/throttle.js +0 -15
- package/dist/cjs/utils/trackLogs.js +0 -31
- package/dist/cjs/utils/trimWithAnsi.js +0 -40
- package/dist/cjs/utils/truncateString.js +0 -23
- package/dist/cjs/utils/unique.js +0 -6
- package/dist/cjs/utils/updateType.js +0 -9
- package/dist/cjs/utils/urlToFile.js +0 -36
- package/dist/cjs/utils/virtualFileId.js +0 -39
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
- package/dist/esm/client/runtime-server-routing/globalContext.js +0 -5
- package/dist/esm/client/shared/createGetGlobalContextClient.js +0 -65
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -249
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -34
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -39
- package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginBuild.js +0 -19
- package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +0 -85
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +0 -50
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -67
- package/dist/esm/shared/route/debug.d.ts +0 -6
- package/dist/esm/shared/route/debug.js +0 -21
- /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildApp.d.ts +0 -0
- /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildConfig.d.ts +0 -0
- /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginProdBuildEntry.d.ts +0 -0
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.serializeConfigValues = serializeConfigValues;
|
|
7
|
-
exports.getConfigValuesBase = getConfigValuesBase;
|
|
8
|
-
exports.isJsonValue = isJsonValue;
|
|
9
|
-
const assertSetup_js_1 = require("../../../utils/assertSetup.js");
|
|
10
|
-
const utils_js_1 = require("../../../node/vite/utils.js");
|
|
11
|
-
const pointerImports_js_1 = require("../../../node/vite/shared/resolveVikeConfigInternal/pointerImports.js");
|
|
12
|
-
const helpers_js_1 = require("../helpers.js");
|
|
13
|
-
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
14
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
|
-
const getConfigValueSourcesRelevant_js_1 = require("../../../node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js");
|
|
16
|
-
const stringifyOptions = { forbidReactElements: true };
|
|
17
|
-
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
18
|
-
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
19
|
-
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with parsePageConfigsSerialized()
|
|
20
|
-
// - vike/shared/page-configs/serialize/parsePageConfigsSerialized.ts
|
|
21
|
-
// - parsePageConfigsSerialized() is loaded on both the client- and server-side.
|
|
22
|
-
(0, utils_js_1.assertIsNotBrowser)();
|
|
23
|
-
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
24
|
-
function serializeConfigValues(pageConfig, importStatements, filesEnv, runtimeEnv, tabspace, isEager) {
|
|
25
|
-
const lines = [];
|
|
26
|
-
tabspace += ' ';
|
|
27
|
-
getConfigValuesBase(pageConfig, runtimeEnv, isEager).forEach((entry) => {
|
|
28
|
-
if (entry.configValueBase.type === 'computed') {
|
|
29
|
-
(0, utils_js_1.assert)('value' in entry); // Help TS
|
|
30
|
-
const { configValueBase, value, configName, configEnv } = entry;
|
|
31
|
-
const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements, filesEnv, configEnv);
|
|
32
|
-
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
33
|
-
}
|
|
34
|
-
if (entry.configValueBase.type === 'standard') {
|
|
35
|
-
(0, utils_js_1.assert)('sourceRelevant' in entry); // Help TS
|
|
36
|
-
const { configValueBase, sourceRelevant, configName } = entry;
|
|
37
|
-
const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements, filesEnv);
|
|
38
|
-
serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
|
|
39
|
-
}
|
|
40
|
-
if (entry.configValueBase.type === 'cumulative') {
|
|
41
|
-
(0, utils_js_1.assert)('sourcesRelevant' in entry); // Help TS
|
|
42
|
-
const { configValueBase, sourcesRelevant, configName } = entry;
|
|
43
|
-
const valueDataList = [];
|
|
44
|
-
sourcesRelevant.forEach((source) => {
|
|
45
|
-
const valueData = getValueSerializedFromSource(source, configName, importStatements, filesEnv);
|
|
46
|
-
valueDataList.push(valueData);
|
|
47
|
-
});
|
|
48
|
-
serializeConfigValue(configValueBase, valueDataList, configName, lines, tabspace);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return lines;
|
|
52
|
-
}
|
|
53
|
-
function getValueSerializedFromSource(configValueSource, configName, importStatements, filesEnv) {
|
|
54
|
-
let valueData;
|
|
55
|
-
if (configValueSource.valueIsLoaded && !configValueSource.valueIsLoadedWithImport) {
|
|
56
|
-
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAt, importStatements, filesEnv, configValueSource.configEnv);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
valueData = getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName);
|
|
60
|
-
}
|
|
61
|
-
return valueData;
|
|
62
|
-
}
|
|
63
|
-
function serializeConfigValue(configValueBase, valueData, configName, lines, tabspace) {
|
|
64
|
-
lineAdd(`[${JSON.stringify(configName)}]: {`);
|
|
65
|
-
{
|
|
66
|
-
tab();
|
|
67
|
-
lineAdd(`type: "${configValueBase.type}",`);
|
|
68
|
-
lineAdd(`definedAtData: ${JSON.stringify(configValueBase.definedAtData)},`);
|
|
69
|
-
lineAdd(`valueSerialized:`);
|
|
70
|
-
if (!Array.isArray(valueData)) {
|
|
71
|
-
serializeValueData(valueData);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
lineAppend(' [');
|
|
75
|
-
valueData.forEach(serializeValueData);
|
|
76
|
-
lineAppend(` ],`);
|
|
77
|
-
}
|
|
78
|
-
untab();
|
|
79
|
-
}
|
|
80
|
-
lineAdd('},');
|
|
81
|
-
return;
|
|
82
|
-
function serializeValueData(valueData) {
|
|
83
|
-
lineAppend(` {`);
|
|
84
|
-
tab();
|
|
85
|
-
lineAdd(`type: "${valueData.type}",`);
|
|
86
|
-
const valueProp = valueData.type !== 'plus-file' ? 'value' : 'exportValues';
|
|
87
|
-
lineAdd(`${valueProp}: ${valueData.valueAsJsCode},`);
|
|
88
|
-
untab();
|
|
89
|
-
lineAdd(`},`);
|
|
90
|
-
}
|
|
91
|
-
function lineAppend(str) {
|
|
92
|
-
const i = lines.length - 1;
|
|
93
|
-
lines[i] = lines[i] += str;
|
|
94
|
-
}
|
|
95
|
-
function lineAdd(str) {
|
|
96
|
-
lines.push(`${tabspace}${str}`);
|
|
97
|
-
}
|
|
98
|
-
function tab() {
|
|
99
|
-
tabspace += ' ';
|
|
100
|
-
}
|
|
101
|
-
function untab() {
|
|
102
|
-
tabspace = tabspace.slice(2);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
|
|
106
|
-
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
107
|
-
const { valueIsDefinedByPlusValueFile, definedAt, configEnv } = configValueSource;
|
|
108
|
-
(0, utils_js_1.assert)(!definedAt.definedBy);
|
|
109
|
-
const { filePathAbsoluteVite, fileExportName } = definedAt;
|
|
110
|
-
if (valueIsDefinedByPlusValueFile)
|
|
111
|
-
(0, utils_js_1.assert)(fileExportName === undefined);
|
|
112
|
-
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*', filesEnv, configEnv, configName);
|
|
113
|
-
return {
|
|
114
|
-
type: valueIsDefinedByPlusValueFile ? 'plus-file' : 'pointer-import',
|
|
115
|
-
valueAsJsCode: importName,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function getValueSerializedWithJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
119
|
-
const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv);
|
|
120
|
-
return {
|
|
121
|
-
type: 'js-serialized',
|
|
122
|
-
valueAsJsCode,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
|
|
126
|
-
const valueName = `config${(0, utils_js_1.getPropAccessNotation)(configName)}`;
|
|
127
|
-
let configValueSerialized;
|
|
128
|
-
try {
|
|
129
|
-
configValueSerialized = (0, stringify_1.stringify)(value, {
|
|
130
|
-
valueName,
|
|
131
|
-
...stringifyOptions,
|
|
132
|
-
// Replace import strings with import variables.
|
|
133
|
-
// - We don't need this anymore and could remove it.
|
|
134
|
-
// - We temporarily needed it for nested document configs (`config.document.{title,description,favicon}`), but we finally decided to go for flat document configs instead (`config.{title,description,favicon}`).
|
|
135
|
-
// - https://github.com/vikejs/vike-react/pull/113
|
|
136
|
-
replacer(_, value) {
|
|
137
|
-
if (typeof value === 'string') {
|
|
138
|
-
const importData = (0, pointerImports_js_1.parsePointerImportData)(value);
|
|
139
|
-
if (importData) {
|
|
140
|
-
const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName, filesEnv, configEnv, configName);
|
|
141
|
-
const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
|
|
142
|
-
return { replacement };
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
catch (err) {
|
|
149
|
-
logJsonSerializeError(err, configName, definedAtData);
|
|
150
|
-
(0, utils_js_1.assert)(false);
|
|
151
|
-
}
|
|
152
|
-
configValueSerialized = configValueSerialized.replaceAll(`"${REPLACE_ME_BEFORE}`, '');
|
|
153
|
-
configValueSerialized = configValueSerialized.replaceAll(`${REPLACE_ME_AFTER}"`, '');
|
|
154
|
-
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_BEFORE));
|
|
155
|
-
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_AFTER));
|
|
156
|
-
return configValueSerialized;
|
|
157
|
-
}
|
|
158
|
-
function isJsonValue(value) {
|
|
159
|
-
try {
|
|
160
|
-
(0, stringify_1.stringify)(value, stringifyOptions);
|
|
161
|
-
}
|
|
162
|
-
catch (err) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
function logJsonSerializeError(err, configName, definedAtData) {
|
|
168
|
-
/*
|
|
169
|
-
// import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
|
|
170
|
-
let serializationErrMsg = ''
|
|
171
|
-
if (isJsonSerializerError(err)) {
|
|
172
|
-
serializationErrMsg = err.messageCore
|
|
173
|
-
} else {
|
|
174
|
-
// When a property getter throws an error
|
|
175
|
-
console.error('Serialization error:')
|
|
176
|
-
console.error(err)
|
|
177
|
-
serializationErrMsg = 'see serialization error printed above'
|
|
178
|
-
}
|
|
179
|
-
//*/
|
|
180
|
-
const configValueFilePathToShowToUser = (0, helpers_js_1.getConfigValueFilePathToShowToUser)(definedAtData);
|
|
181
|
-
(0, utils_js_1.assert)(configValueFilePathToShowToUser);
|
|
182
|
-
(0, utils_js_1.assertUsage)(false, `${picocolors_1.default.cyan(configName)} defined by ${configValueFilePathToShowToUser} must be defined using a separate file ${picocolors_1.default.bold(`+${configName}.js`)}, see https://vike.dev/error/runtime-in-config`);
|
|
183
|
-
}
|
|
184
|
-
function getConfigValuesBase(pageConfig, runtimeEnv, isEager) {
|
|
185
|
-
const fromComputed = Object.entries(pageConfig.configValuesComputed ?? {}).map(([configName, valueInfo]) => {
|
|
186
|
-
const { configEnv, value } = valueInfo;
|
|
187
|
-
if (!(0, getConfigValueSourcesRelevant_js_1.isRuntimeEnvMatch)(configEnv, runtimeEnv))
|
|
188
|
-
return 'SKIP';
|
|
189
|
-
// AFAICT this should never happen: I ain't aware of a use case for overriding computed values. If there is a use case, then configValueSources has higher precedence.
|
|
190
|
-
if (pageConfig.configValueSources[configName])
|
|
191
|
-
return 'SKIP';
|
|
192
|
-
const configValueBase = {
|
|
193
|
-
type: 'computed',
|
|
194
|
-
definedAtData: null,
|
|
195
|
-
};
|
|
196
|
-
return { configValueBase, value, configName, configEnv };
|
|
197
|
-
});
|
|
198
|
-
const fromSources = Object.entries(pageConfig.configValueSources).map(([configName]) => {
|
|
199
|
-
const configDef = pageConfig.configDefinitions[configName];
|
|
200
|
-
(0, utils_js_1.assert)(configDef);
|
|
201
|
-
if (isEager !== null && isEager !== !!configDef.eager)
|
|
202
|
-
return 'SKIP';
|
|
203
|
-
if (!configDef.cumulative) {
|
|
204
|
-
const sourcesRelevant = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourcesRelevant)(configName, runtimeEnv, pageConfig);
|
|
205
|
-
const source = sourcesRelevant[0];
|
|
206
|
-
if (!source)
|
|
207
|
-
return 'SKIP';
|
|
208
|
-
(0, utils_js_1.assert)(sourcesRelevant.length === 1);
|
|
209
|
-
const definedAtFile = getDefinedAtFileSource(source);
|
|
210
|
-
const configValueBase = {
|
|
211
|
-
type: 'standard',
|
|
212
|
-
definedAtData: definedAtFile,
|
|
213
|
-
};
|
|
214
|
-
return { configValueBase, sourceRelevant: source, configName };
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
const sourcesRelevant = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourcesRelevant)(configName, runtimeEnv, pageConfig);
|
|
218
|
-
if (sourcesRelevant.length === 0)
|
|
219
|
-
return 'SKIP';
|
|
220
|
-
const definedAtData = [];
|
|
221
|
-
sourcesRelevant.forEach((source) => {
|
|
222
|
-
const definedAtFile = getDefinedAtFileSource(source);
|
|
223
|
-
definedAtData.push(definedAtFile);
|
|
224
|
-
});
|
|
225
|
-
const configValueBase = {
|
|
226
|
-
type: 'cumulative',
|
|
227
|
-
definedAtData,
|
|
228
|
-
};
|
|
229
|
-
return { configValueBase, sourcesRelevant, configName };
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
return [...fromComputed, ...fromSources].filter((r) => r !== 'SKIP');
|
|
233
|
-
}
|
|
234
|
-
function getDefinedAtFileSource(source) {
|
|
235
|
-
const { definedAt } = source;
|
|
236
|
-
if (definedAt.definedBy)
|
|
237
|
-
return definedAt;
|
|
238
|
-
const definedAtFile = {
|
|
239
|
-
filePathToShowToUser: definedAt.filePathToShowToUser,
|
|
240
|
-
fileExportPathToShowToUser: definedAt.fileExportPathToShowToUser,
|
|
241
|
-
};
|
|
242
|
-
return definedAtFile;
|
|
243
|
-
}
|
|
244
|
-
/*
|
|
245
|
-
* Naming:
|
|
246
|
-
* `import { someExport as someImport } from './some-file'`
|
|
247
|
-
* <=>
|
|
248
|
-
* `{`
|
|
249
|
-
* `importPath: './some-file',`
|
|
250
|
-
* `exportName: 'someExport',`
|
|
251
|
-
* `importName: 'someImport',`
|
|
252
|
-
* `}`
|
|
253
|
-
*/
|
|
254
|
-
function addImportStatement(importStatements, importPath, exportName, filesEnv, configEnv, configName) {
|
|
255
|
-
const importCounter = importStatements.length + 1;
|
|
256
|
-
const importName = `import${importCounter}`;
|
|
257
|
-
const importLiteral = (() => {
|
|
258
|
-
if (exportName === '*') {
|
|
259
|
-
return `* as ${importName}`;
|
|
260
|
-
}
|
|
261
|
-
if (exportName === 'default') {
|
|
262
|
-
return importName;
|
|
263
|
-
}
|
|
264
|
-
return `{ ${exportName} as ${importName} }`;
|
|
265
|
-
})();
|
|
266
|
-
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
267
|
-
importStatements.push(importStatement);
|
|
268
|
-
assertFileEnv(importPath, configEnv, configName, filesEnv);
|
|
269
|
-
return { importName };
|
|
270
|
-
}
|
|
271
|
-
function assertFileEnv(importPath, configEnv, configName, filesEnv) {
|
|
272
|
-
(0, utils_js_1.assert)(!(0, utils_js_1.isImportPathRelative)(importPath));
|
|
273
|
-
const key = importPath;
|
|
274
|
-
(0, utils_js_1.assert)(key);
|
|
275
|
-
(0, utils_js_1.assertPosixPath)(key);
|
|
276
|
-
if (!filesEnv.has(key)) {
|
|
277
|
-
filesEnv.set(key, []);
|
|
278
|
-
}
|
|
279
|
-
const fileEnvs = filesEnv.get(key);
|
|
280
|
-
const fileEnvNew = { configEnv, configName };
|
|
281
|
-
fileEnvs.push(fileEnvNew);
|
|
282
|
-
const fileEnvDiff = fileEnvs.filter((c) => !(0, utils_js_1.deepEqual)(c.configEnv, configEnv))[0];
|
|
283
|
-
if (fileEnvDiff) {
|
|
284
|
-
(0, utils_js_1.assertUsage)(false, [
|
|
285
|
-
`${importPath} defines the value of configs living in different environments:`,
|
|
286
|
-
...[fileEnvDiff, fileEnvNew].map((c) => ` - config ${picocolors_1.default.code(c.configName)} which value lives in environment ${picocolors_1.default.code(JSON.stringify(c.configEnv))}`),
|
|
287
|
-
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports',
|
|
288
|
-
].join('\n'));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareGlobalContextForPublicUsage = prepareGlobalContextForPublicUsage;
|
|
4
|
-
const getProxyForPublicUsage_js_1 = require("./getProxyForPublicUsage.js");
|
|
5
|
-
const utils_js_1 = require("./utils.js");
|
|
6
|
-
function prepareGlobalContextForPublicUsage(globalContext) {
|
|
7
|
-
(0, utils_js_1.assert)(globalContext._isOriginalObject); // ensure we preserve the original object reference
|
|
8
|
-
const globalContextPublic = (0, getProxyForPublicUsage_js_1.getProxyForPublicUsage)(globalContext, 'globalContext');
|
|
9
|
-
return globalContextPublic;
|
|
10
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.preparePageContextForPublicUsage = preparePageContextForPublicUsage;
|
|
4
|
-
exports.assertPropertyGetters = assertPropertyGetters;
|
|
5
|
-
const utils_js_1 = require("./utils.js");
|
|
6
|
-
const addIs404ToPageProps_js_1 = require("./addIs404ToPageProps.js");
|
|
7
|
-
const prepareGlobalContextForPublicUsage_js_1 = require("./prepareGlobalContextForPublicUsage.js");
|
|
8
|
-
const getProxyForPublicUsage_js_1 = require("./getProxyForPublicUsage.js");
|
|
9
|
-
function preparePageContextForPublicUsage(pageContext) {
|
|
10
|
-
(0, utils_js_1.assert)(!pageContext._isProxyObject);
|
|
11
|
-
(0, utils_js_1.assert)(!pageContext.globalContext); // pageContext.globalContext should only be available to users — Vike itself should use pageContext._globalContext instead
|
|
12
|
-
(0, utils_js_1.assert)(pageContext._isOriginalObject); // ensure we preserve the original object reference
|
|
13
|
-
(0, addIs404ToPageProps_js_1.addIs404ToPageProps)(pageContext);
|
|
14
|
-
// TO-DO/next-major-release: remove
|
|
15
|
-
if (!('_pageId' in pageContext)) {
|
|
16
|
-
Object.defineProperty(pageContext, '_pageId', {
|
|
17
|
-
get() {
|
|
18
|
-
(0, utils_js_1.assertWarning)(false, 'pageContext._pageId has been renamed to pageContext.pageId', {
|
|
19
|
-
showStackTrace: true,
|
|
20
|
-
onlyOnce: true,
|
|
21
|
-
});
|
|
22
|
-
return pageContext.pageId;
|
|
23
|
-
},
|
|
24
|
-
enumerable: false,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
// For a more readable `console.log(pageContext)` output
|
|
28
|
-
sortPageContext(pageContext);
|
|
29
|
-
const globalContextPublic = (0, prepareGlobalContextForPublicUsage_js_1.prepareGlobalContextForPublicUsage)(pageContext._globalContext);
|
|
30
|
-
const pageContextPublic = (0, getProxyForPublicUsage_js_1.getProxyForPublicUsage)(pageContext, 'pageContext',
|
|
31
|
-
// We must skip it in the client-side because of the reactivity mechanism of UI frameworks like Solid.
|
|
32
|
-
// - TO-DO/soon/proxy: double check whether that's true
|
|
33
|
-
true, (prop) => {
|
|
34
|
-
if (prop === 'globalContext') {
|
|
35
|
-
return globalContextPublic;
|
|
36
|
-
}
|
|
37
|
-
if (prop in globalContextPublic) {
|
|
38
|
-
return globalContextPublic[prop];
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return pageContextPublic;
|
|
42
|
-
}
|
|
43
|
-
// Sort `pageContext` keys alphabetically, in order to make reading the `console.log(pageContext)` output easier
|
|
44
|
-
function sortPageContext(pageContext) {
|
|
45
|
-
let descriptors = Object.getOwnPropertyDescriptors(pageContext);
|
|
46
|
-
for (const key of Object.keys(pageContext))
|
|
47
|
-
delete pageContext[key];
|
|
48
|
-
descriptors = Object.fromEntries(Object.entries(descriptors).sort(([key1], [key2]) => (0, utils_js_1.compareString)(key1, key2)));
|
|
49
|
-
Object.defineProperties(pageContext, descriptors);
|
|
50
|
-
}
|
|
51
|
-
function assertPropertyGetters(pageContext) {
|
|
52
|
-
/*
|
|
53
|
-
If the isPropertyGetter() assertions fail then it's most likely because Object.assign() was used instead of `objectAssign()`:
|
|
54
|
-
```js
|
|
55
|
-
const PageContextUrlComputed = getPageContextUrlComputed(pageContext)
|
|
56
|
-
|
|
57
|
-
// ❌ Breaks the property descriptors/getters of pageContext defined by getPageContextUrlComputed() such as pageContext.urlPathname
|
|
58
|
-
Object.assign(pageContext, pageContextUrlComputed)
|
|
59
|
-
|
|
60
|
-
// ❌ Also breaks property descriptors/getters
|
|
61
|
-
const pageContext = { ...pageContextUrlComputed }
|
|
62
|
-
|
|
63
|
-
// ✅ Preserves property descriptors/getters (see objectAssign() implementation)
|
|
64
|
-
objectAssign(pageContext, pageContextUrlComputed)
|
|
65
|
-
```
|
|
66
|
-
*/
|
|
67
|
-
;
|
|
68
|
-
[
|
|
69
|
-
'urlPathname',
|
|
70
|
-
// TO-DO/next-major-release: remove
|
|
71
|
-
'urlParsed',
|
|
72
|
-
// TO-DO/next-major-release: remove
|
|
73
|
-
'url',
|
|
74
|
-
// TO-DO/next-major-release: remove
|
|
75
|
-
'pageExports',
|
|
76
|
-
].forEach((prop) => {
|
|
77
|
-
if (pageContext.prop)
|
|
78
|
-
(0, utils_js_1.assert)((0, utils_js_1.isPropertyGetter)(pageContext, prop));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.redirect = redirect;
|
|
7
|
-
exports.render = render;
|
|
8
|
-
exports.RenderErrorPage = RenderErrorPage;
|
|
9
|
-
exports.isAbortError = isAbortError;
|
|
10
|
-
exports.isAbortPageContext = isAbortPageContext;
|
|
11
|
-
exports.logAbortErrorHandled = logAbortErrorHandled;
|
|
12
|
-
exports.getPageContextFromAllRewrites = getPageContextFromAllRewrites;
|
|
13
|
-
exports.AbortRender = AbortRender;
|
|
14
|
-
exports.assertNoInfiniteAbortLoop = assertNoInfiniteAbortLoop;
|
|
15
|
-
const execHook_js_1 = require("../hooks/execHook.js");
|
|
16
|
-
const utils_js_1 = require("./utils.js");
|
|
17
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
18
|
-
/**
|
|
19
|
-
* Abort the rendering of the current page, and redirect the user to another URL instead.
|
|
20
|
-
*
|
|
21
|
-
* https://vike.dev/redirect
|
|
22
|
-
*
|
|
23
|
-
* @param url The URL to redirect to.
|
|
24
|
-
* @param statusCode By default a temporary redirection (`302`) is performed. For permanent redirections (`301`), use `config.redirects` https://vike.dev/redirects instead or, alternatively, set the `statusCode` argument to `301`.
|
|
25
|
-
*/
|
|
26
|
-
function redirect(url, statusCode) {
|
|
27
|
-
const abortCaller = 'throw redirect()';
|
|
28
|
-
(0, utils_js_1.assertUsageUrlRedirectTarget)(url, getErrPrefix(abortCaller));
|
|
29
|
-
const args = [JSON.stringify(url)];
|
|
30
|
-
if (!statusCode) {
|
|
31
|
-
statusCode = 302;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
assertStatusCode(statusCode, [301, 302], 'redirect');
|
|
35
|
-
args.push(String(statusCode));
|
|
36
|
-
}
|
|
37
|
-
const pageContextAbort = {};
|
|
38
|
-
(0, utils_js_1.objectAssign)(pageContextAbort, {
|
|
39
|
-
_abortCaller: abortCaller,
|
|
40
|
-
_abortCall: `redirect(${args.join(', ')})`,
|
|
41
|
-
_urlRedirect: {
|
|
42
|
-
url,
|
|
43
|
-
statusCode,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
return AbortRender(pageContextAbort);
|
|
47
|
-
}
|
|
48
|
-
function render(urlOrStatusCode, abortReason) {
|
|
49
|
-
const args = [typeof urlOrStatusCode === 'number' ? String(urlOrStatusCode) : JSON.stringify(urlOrStatusCode)];
|
|
50
|
-
if (abortReason !== undefined)
|
|
51
|
-
args.push((0, utils_js_1.truncateString)(JSON.stringify(abortReason), 30));
|
|
52
|
-
const abortCaller = 'throw render()';
|
|
53
|
-
const abortCall = `render(${args.join(', ')})`;
|
|
54
|
-
return render_(urlOrStatusCode, abortReason, abortCall, abortCaller);
|
|
55
|
-
}
|
|
56
|
-
function render_(urlOrStatusCode, abortReason, abortCall, abortCaller, pageContextAddendum) {
|
|
57
|
-
const pageContextAbort = {
|
|
58
|
-
abortReason,
|
|
59
|
-
_abortCaller: abortCaller,
|
|
60
|
-
_abortCall: abortCall,
|
|
61
|
-
};
|
|
62
|
-
if (pageContextAddendum) {
|
|
63
|
-
(0, utils_js_1.assert)(pageContextAddendum._isLegacyRenderErrorPage === true);
|
|
64
|
-
(0, utils_js_1.objectAssign)(pageContextAbort, pageContextAddendum);
|
|
65
|
-
}
|
|
66
|
-
if (typeof urlOrStatusCode === 'string') {
|
|
67
|
-
const url = urlOrStatusCode;
|
|
68
|
-
(0, utils_js_1.assertUsageUrlPathnameAbsolute)(url, getErrPrefix(abortCaller));
|
|
69
|
-
(0, utils_js_1.objectAssign)(pageContextAbort, {
|
|
70
|
-
_urlRewrite: url,
|
|
71
|
-
});
|
|
72
|
-
return AbortRender(pageContextAbort);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
const abortStatusCode = urlOrStatusCode;
|
|
76
|
-
assertStatusCode(urlOrStatusCode, [401, 403, 404, 410, 429, 500, 503], 'render');
|
|
77
|
-
(0, utils_js_1.objectAssign)(pageContextAbort, {
|
|
78
|
-
abortStatusCode,
|
|
79
|
-
is404: abortStatusCode === 404,
|
|
80
|
-
});
|
|
81
|
-
return AbortRender(pageContextAbort);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function AbortRender(pageContextAbort) {
|
|
85
|
-
const err = new Error('AbortRender');
|
|
86
|
-
(0, utils_js_1.objectAssign)(err, { _pageContextAbort: pageContextAbort, [stamp]: true });
|
|
87
|
-
(0, utils_js_1.checkType)(err);
|
|
88
|
-
return err;
|
|
89
|
-
}
|
|
90
|
-
// TO-DO/next-major-release: remove
|
|
91
|
-
/**
|
|
92
|
-
* @deprecated Use `throw render()` or `throw redirect()` instead, see https://vike.dev/render'
|
|
93
|
-
*/
|
|
94
|
-
function RenderErrorPage({ pageContext = {} } = {}) {
|
|
95
|
-
(0, utils_js_1.assertWarning)(false, `${picocolors_1.default.cyan('throw RenderErrorPage()')} is deprecated and will be removed in the next major release. Use ${picocolors_1.default.cyan('throw render()')} or ${picocolors_1.default.cyan('throw redirect()')} instead, see https://vike.dev/render`, { onlyOnce: false });
|
|
96
|
-
let abortStatusCode = 404;
|
|
97
|
-
let abortReason = 'Page Not Found';
|
|
98
|
-
if (pageContext.is404 === false || pageContext.pageProps?.is404 === false) {
|
|
99
|
-
abortStatusCode = 500;
|
|
100
|
-
abortReason = 'Something went wrong';
|
|
101
|
-
}
|
|
102
|
-
(0, utils_js_1.objectAssign)(pageContext, { _isLegacyRenderErrorPage: true });
|
|
103
|
-
return render_(abortStatusCode, abortReason, 'RenderErrorPage()', 'throw RenderErrorPage()', pageContext);
|
|
104
|
-
}
|
|
105
|
-
const stamp = '_isAbortError';
|
|
106
|
-
function isAbortError(thing) {
|
|
107
|
-
return typeof thing === 'object' && thing !== null && stamp in thing;
|
|
108
|
-
}
|
|
109
|
-
function isAbortPageContext(pageContext) {
|
|
110
|
-
if (!(pageContext._urlRewrite || pageContext._urlRedirect || pageContext.abortStatusCode)) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContext, '_abortCall', 'string'));
|
|
114
|
-
/* Isn't needed and is missing on the client-side
|
|
115
|
-
assert(hasProp(pageContext, '_abortCaller', 'string'))
|
|
116
|
-
*/
|
|
117
|
-
(0, utils_js_1.checkType)(pageContext);
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
function logAbortErrorHandled(err, isProduction, pageContext) {
|
|
121
|
-
if (isProduction)
|
|
122
|
-
return;
|
|
123
|
-
const urlCurrent = pageContext._urlRewrite ?? pageContext.urlOriginal;
|
|
124
|
-
(0, utils_js_1.assert)(urlCurrent);
|
|
125
|
-
const abortCall = err._pageContextAbort._abortCall;
|
|
126
|
-
(0, utils_js_1.assert)(abortCall);
|
|
127
|
-
const hookLoc = (0, execHook_js_1.isUserHookError)(err);
|
|
128
|
-
let thrownBy = '';
|
|
129
|
-
if (hookLoc) {
|
|
130
|
-
thrownBy = ` by ${picocolors_1.default.cyan(`${hookLoc.hookName}()`)} hook defined at ${hookLoc.hookFilePath}`;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
// hookLoc is missing when serializing abort errors from server to client
|
|
134
|
-
}
|
|
135
|
-
(0, utils_js_1.assertInfo)(false, `${picocolors_1.default.cyan(abortCall)} thrown${thrownBy} while rendering ${picocolors_1.default.cyan(urlCurrent)}`, {
|
|
136
|
-
onlyOnce: false,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
function assertStatusCode(statusCode, expected, caller) {
|
|
140
|
-
const expectedEnglish = (0, utils_js_1.joinEnglish)(expected.map((s) => s.toString()), 'or');
|
|
141
|
-
(0, utils_js_1.assertWarning)(expected.includes(statusCode), `Unepexected status code ${statusCode} passed to ${caller}(), we recommend ${expectedEnglish} instead. (Or reach out at https://github.com/vikejs/vike/issues/1008 if you believe ${statusCode} should be added.)`, { onlyOnce: true });
|
|
142
|
-
}
|
|
143
|
-
function getPageContextFromAllRewrites(pageContextsFromRewrite) {
|
|
144
|
-
assertNoInfiniteLoop(pageContextsFromRewrite);
|
|
145
|
-
const pageContextFromAllRewrites = { _urlRewrite: null };
|
|
146
|
-
pageContextsFromRewrite.forEach((pageContextFromRewrite) => {
|
|
147
|
-
Object.assign(pageContextFromAllRewrites, pageContextFromRewrite);
|
|
148
|
-
});
|
|
149
|
-
return pageContextFromAllRewrites;
|
|
150
|
-
}
|
|
151
|
-
function assertNoInfiniteLoop(pageContextsFromRewrite) {
|
|
152
|
-
const urlRewrites = [];
|
|
153
|
-
pageContextsFromRewrite.forEach((pageContext) => {
|
|
154
|
-
const urlRewrite = pageContext._urlRewrite;
|
|
155
|
-
{
|
|
156
|
-
const idx = urlRewrites.indexOf(urlRewrite);
|
|
157
|
-
if (idx !== -1) {
|
|
158
|
-
const loop = [...urlRewrites.slice(idx), urlRewrite].map((url) => `render('${url}')`).join(' => ');
|
|
159
|
-
(0, utils_js_1.assertUsage)(false, `Infinite loop of render() calls: ${loop}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
urlRewrites.push(urlRewrite);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function assertNoInfiniteAbortLoop(rewriteCount, redirectCount) {
|
|
166
|
-
const abortCalls = [
|
|
167
|
-
// prettier-ignore
|
|
168
|
-
// biome-ignore format:
|
|
169
|
-
rewriteCount > 0 && picocolors_1.default.cyan("throw render('/some-url')"),
|
|
170
|
-
redirectCount > 0 && picocolors_1.default.cyan("throw redirect('/some-url')"),
|
|
171
|
-
]
|
|
172
|
-
.filter(Boolean)
|
|
173
|
-
.join(' and ');
|
|
174
|
-
(0, utils_js_1.assertUsage)(rewriteCount + redirectCount <= 7, `Maximum chain length of 7 ${abortCalls} exceeded. Did you define an infinite loop of ${abortCalls}?`);
|
|
175
|
-
}
|
|
176
|
-
function getErrPrefix(abortCaller) {
|
|
177
|
-
return `URL passed to ${picocolors_1.default.code(abortCaller)}`;
|
|
178
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debug = debug;
|
|
4
|
-
exports.setCreateDebugger = setCreateDebugger;
|
|
5
|
-
// Using createDebugger() for isomorphic code without bloating the client-side.
|
|
6
|
-
// On the server-side, this is just a transparent proxy.
|
|
7
|
-
// On the client-side, this is an empty shell.
|
|
8
|
-
const getGlobalObject_js_1 = require("../../utils/getGlobalObject.js");
|
|
9
|
-
const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('route/debug.ts', {});
|
|
10
|
-
function debug(...args) {
|
|
11
|
-
// Client-side => does nothing
|
|
12
|
-
if (!globalObject.createDebugger)
|
|
13
|
-
return;
|
|
14
|
-
// Server-side => just a proxy
|
|
15
|
-
if (!globalObject.debug) {
|
|
16
|
-
globalObject.debug = globalObject.createDebugger('vike:routing');
|
|
17
|
-
}
|
|
18
|
-
globalObject.debug(...args);
|
|
19
|
-
}
|
|
20
|
-
// Called only on the server-side
|
|
21
|
-
function setCreateDebugger(createDebugger) {
|
|
22
|
-
globalObject.createDebugger = createDebugger;
|
|
23
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Unit tests at ./deduceRouteStringFromFilesystemPath.spec.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.deduceRouteStringFromFilesystemPath = deduceRouteStringFromFilesystemPath;
|
|
5
|
-
const utils_js_1 = require("./utils.js");
|
|
6
|
-
// TO-DO/next-major-release: remove this and whole filesystemRoot mechanism
|
|
7
|
-
function deduceRouteStringFromFilesystemPath(pageId, filesystemRoots) {
|
|
8
|
-
// Handle Filesystem Routing Root
|
|
9
|
-
const filesystemRootsMatch = filesystemRoots
|
|
10
|
-
.filter(({ filesystemRoot }) => pageId.startsWith(filesystemRoot))
|
|
11
|
-
.sort((0, utils_js_1.higherFirst)(({ filesystemRoot }) => filesystemRoot.length));
|
|
12
|
-
const fsBase = filesystemRootsMatch[0];
|
|
13
|
-
let filesystemRoute;
|
|
14
|
-
if (fsBase) {
|
|
15
|
-
// Example values:
|
|
16
|
-
// - `{"pageId":"/pages/index","filesystemRoot":"/","urlRoot":"/client_portal"}`
|
|
17
|
-
const { filesystemRoot, urlRoot } = fsBase;
|
|
18
|
-
const debugInfo = { pageId, filesystemRoot, urlRoot };
|
|
19
|
-
(0, utils_js_1.assert)(urlRoot.startsWith('/') && pageId.startsWith('/') && filesystemRoot.startsWith('/'), debugInfo);
|
|
20
|
-
(0, utils_js_1.assert)(pageId.startsWith(filesystemRoot), debugInfo);
|
|
21
|
-
if (filesystemRoot !== '/') {
|
|
22
|
-
(0, utils_js_1.assert)(!filesystemRoot.endsWith('/'), debugInfo);
|
|
23
|
-
filesystemRoute = (0, utils_js_1.slice)(pageId, filesystemRoot.length, 0);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
filesystemRoute = pageId;
|
|
27
|
-
}
|
|
28
|
-
(0, utils_js_1.assert)(filesystemRoute.startsWith('/'), debugInfo);
|
|
29
|
-
filesystemRoute = urlRoot + (urlRoot.endsWith('/') ? '' : '/') + (0, utils_js_1.slice)(filesystemRoute, 1, 0);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
filesystemRoute = pageId;
|
|
33
|
-
}
|
|
34
|
-
(0, utils_js_1.assert)(filesystemRoute.startsWith('/'));
|
|
35
|
-
// Remove `pages/`, `index/, and `src/`, directories
|
|
36
|
-
filesystemRoute = filesystemRoute
|
|
37
|
-
.split('/')
|
|
38
|
-
.filter((dir) => dir !== 'pages' && dir !== 'src' && dir !== 'index')
|
|
39
|
-
.join('/');
|
|
40
|
-
// Handle `/index.page.*` suffix
|
|
41
|
-
(0, utils_js_1.assert)(!filesystemRoute.includes('.page.'));
|
|
42
|
-
(0, utils_js_1.assert)(!filesystemRoute.endsWith('.'));
|
|
43
|
-
if (filesystemRoute.endsWith('/index')) {
|
|
44
|
-
filesystemRoute = (0, utils_js_1.slice)(filesystemRoute, 0, -'/index'.length);
|
|
45
|
-
}
|
|
46
|
-
if (filesystemRoute === '') {
|
|
47
|
-
filesystemRoute = '/';
|
|
48
|
-
}
|
|
49
|
-
(0, utils_js_1.assert)(filesystemRoute.startsWith('/'));
|
|
50
|
-
(0, utils_js_1.assert)(!filesystemRoute.endsWith('/') || filesystemRoute === '/');
|
|
51
|
-
return filesystemRoute;
|
|
52
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execHookGuard = execHookGuard;
|
|
4
|
-
const getHook_js_1 = require("../hooks/getHook.js");
|
|
5
|
-
const utils_js_1 = require("./utils.js");
|
|
6
|
-
const execHook_js_1 = require("../hooks/execHook.js");
|
|
7
|
-
const errIntro = 'The guard() hook defined by';
|
|
8
|
-
async function execHookGuard(pageContext, prepareForPublicUsage) {
|
|
9
|
-
let hook;
|
|
10
|
-
if (pageContext._globalContext._pageFilesAll.length > 0) {
|
|
11
|
-
// TO-DO/next-major-release: remove
|
|
12
|
-
// V0.4 design
|
|
13
|
-
(0, utils_js_1.assert)(pageContext._globalContext._pageConfigs.length === 0);
|
|
14
|
-
hook = findPageGuard(pageContext.pageId, pageContext._globalContext._pageFilesAll);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
// V1 design
|
|
18
|
-
hook = (0, getHook_js_1.getHookFromPageContext)(pageContext, 'guard');
|
|
19
|
-
}
|
|
20
|
-
if (!hook)
|
|
21
|
-
return;
|
|
22
|
-
await (0, execHook_js_1.execHookDirectSingle)(hook, pageContext, prepareForPublicUsage);
|
|
23
|
-
}
|
|
24
|
-
function findPageGuard(pageId, pageFilesAll) {
|
|
25
|
-
const pageRouteFile = pageFilesAll.find((p) => p.pageId === pageId && p.fileType === '.page.route');
|
|
26
|
-
if (!pageRouteFile)
|
|
27
|
-
return null;
|
|
28
|
-
const { filePath, fileExports } = pageRouteFile;
|
|
29
|
-
(0, utils_js_1.assert)(fileExports); // loadPageRoutes() should already have been called
|
|
30
|
-
const hookFn = fileExports.guard;
|
|
31
|
-
if (!hookFn)
|
|
32
|
-
return null;
|
|
33
|
-
const hookFilePath = filePath;
|
|
34
|
-
const hookTimeout = (0, getHook_js_1.getHookTimeoutDefault)('guard');
|
|
35
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isCallable)(hookFn), `${errIntro} ${hookFilePath} should be a function`);
|
|
36
|
-
return { hookFn, hookName: 'guard', hookFilePath, hookTimeout };
|
|
37
|
-
}
|