vike 0.4.239-commit-59f1017 → 0.4.239-commit-9dcde6d
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.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} +1 -1
- package/dist/esm/client/runtime-client-routing/{globalContext.js → getGlobalContextClientInternal.js} +8 -4
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/runtime-client-routing/isClientSideRoutable.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +2 -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.js +3 -1
- package/dist/esm/node/vite/index.js +34 -15
- package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBaseUrls.js +37 -35
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +82 -80
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +23 -21
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +38 -36
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +26 -24
- package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
- package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +87 -65
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +29 -27
- package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +75 -73
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +30 -28
- package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginPreview.js +35 -33
- package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +9 -0
- package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +45 -0
- package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.js +89 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +50 -48
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +12 -10
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
- package/dist/esm/shared/createGlobalContextShared.d.ts +1 -1
- package/dist/esm/shared/route/abort.d.ts +22 -11
- package/dist/esm/shared/route/abort.js +37 -5
- 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/findPackageJson.js +0 -1
- package/dist/esm/utils/getViteRPC.js +0 -2
- package/dist/esm/utils/requireResolve.js +0 -1
- package/package.json +2 -21
- 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 -778
- 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 -582
- 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 -52
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -357
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -183
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -234
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -256
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -40
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -49
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -111
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -65
- package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -22
- package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
- package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -183
- 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 -111
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -92
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -241
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -113
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -172
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -70
- package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -82
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -95
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -51
- 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 -233
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -17
- 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 -43
- 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.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginBuild.js +0 -20
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -14
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -92
|
@@ -1,29 +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.assertClientRouting = assertClientRouting;
|
|
7
|
-
exports.assertServerRouting = assertServerRouting;
|
|
8
|
-
exports.checkIfClientRouting = checkIfClientRouting;
|
|
9
|
-
const assert_js_1 = require("./assert.js");
|
|
10
|
-
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
11
|
-
const isBrowser_js_1 = require("./isBrowser.js");
|
|
12
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
const state = (0, getGlobalObject_js_1.getGlobalObject)('utils/assertRouterType.ts', {});
|
|
14
|
-
function assertClientRouting() {
|
|
15
|
-
assertNoContradiction(checkIfClientRouting());
|
|
16
|
-
state.isClientRouting = true;
|
|
17
|
-
}
|
|
18
|
-
function checkIfClientRouting() {
|
|
19
|
-
return state.isClientRouting !== false;
|
|
20
|
-
}
|
|
21
|
-
function assertServerRouting() {
|
|
22
|
-
assertNoContradiction(state.isClientRouting !== true);
|
|
23
|
-
state.isClientRouting = false;
|
|
24
|
-
}
|
|
25
|
-
function assertNoContradiction(noContradiction) {
|
|
26
|
-
// If an assertion fails because of a wrong usage, then we assume that the user is trying to import from 'vike/client/router' while not setting `clientRouting` to `true`. Note that 'vike/client' only exports the type `PageContextBuiltInClient` and that the package.json#exports entry 'vike/client' will eventually be removed.
|
|
27
|
-
(0, assert_js_1.assertUsage)((0, isBrowser_js_1.isBrowser)(), `${picocolors_1.default.cyan("import { something } from 'vike/client/router'")} is forbidden on the server-side`, { showStackTrace: true });
|
|
28
|
-
(0, assert_js_1.assertWarning)(noContradiction, "You shouldn't `import { something } from 'vike/client/router'` when using Server Routing. The 'vike/client/router' utilities work only with Client Routing. In particular, don't `import { navigate }` nor `import { prefetch }` as they unnecessarily bloat your client-side bundle sizes.", { showStackTrace: true, onlyOnce: true });
|
|
29
|
-
}
|
|
@@ -1,171 +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.assertIsNotProductionRuntime = assertIsNotProductionRuntime;
|
|
7
|
-
exports.onSetupRuntime = onSetupRuntime;
|
|
8
|
-
exports.onSetupBuild = onSetupBuild;
|
|
9
|
-
exports.onSetupPrerender = onSetupPrerender;
|
|
10
|
-
exports.onSetupPreview = onSetupPreview;
|
|
11
|
-
exports.setNodeEnvProduction = setNodeEnvProduction;
|
|
12
|
-
exports.markSetup_viteDevServer = markSetup_viteDevServer;
|
|
13
|
-
exports.markSetup_vitePreviewServer = markSetup_vitePreviewServer;
|
|
14
|
-
exports.markSetup_vikeVitePlugin = markSetup_vikeVitePlugin;
|
|
15
|
-
exports.markSetup_isViteDev = markSetup_isViteDev;
|
|
16
|
-
const assert_js_1 = require("./assert.js");
|
|
17
|
-
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
18
|
-
const debug_js_1 = require("./debug.js");
|
|
19
|
-
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
20
|
-
const isNonRunnableDev_js_1 = require("./isNonRunnableDev.js");
|
|
21
|
-
const isVitest_js_1 = require("./isVitest.js");
|
|
22
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
23
|
-
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
24
|
-
const debug = (0, debug_js_1.createDebugger)('vike:setup');
|
|
25
|
-
const setup = (0, getGlobalObject_js_1.getGlobalObject)('utils/assertSetup.ts', {});
|
|
26
|
-
// Called by Vike modules that want to ensure that they aren't loaded by the server runtime in production
|
|
27
|
-
function assertIsNotProductionRuntime() {
|
|
28
|
-
if (debug.isActivated)
|
|
29
|
-
debug('assertIsNotProductionRuntime()', new Error().stack);
|
|
30
|
-
setup.shouldNotBeProduction = true;
|
|
31
|
-
}
|
|
32
|
-
function onSetupRuntime() {
|
|
33
|
-
if (debug.isActivated)
|
|
34
|
-
debug('assertSetup()', new Error().stack);
|
|
35
|
-
if (isTest())
|
|
36
|
-
return;
|
|
37
|
-
assertNodeEnvIsNotUndefinedString();
|
|
38
|
-
if (!setup.viteDevServer && setup.isViteDev === undefined) {
|
|
39
|
-
// TO-DO/eventually: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
40
|
-
(0, assert_js_1.assertWarning)(!isNodeEnvDev() || (0, isNonRunnableDev_js_1.isNonRunnableDev)(), `The ${getEnvDescription()}, which is contradictory because the environment seems to be a production environment (Vite isn't loaded), see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')} and ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`, { onlyOnce: true });
|
|
41
|
-
(0, assert_js_1.assertUsage)(!setup.vikeVitePlugin, `Vike's Vite plugin (the ${picocolors_1.default.cyan('vike/plugin')} module) shouldn't be loaded in production, see ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`);
|
|
42
|
-
// This assert() one of the main goal of this file: it ensures assertIsNotProductionRuntime()
|
|
43
|
-
(0, assert_js_1.assert)(!setup.shouldNotBeProduction);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
if (!setup.isPreview && !setup.vitePreviewServer && !setup.isPrerendering) {
|
|
47
|
-
// TO-DO/eventually: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
48
|
-
(0, assert_js_1.assertWarning)(isNodeEnvDev(), `The ${getEnvDescription()} while Vite is loaded, but Vite shouldn't be loaded in production, see ${picocolors_1.default.underline('https://vike.dev/warning/setup')}`, { onlyOnce: true });
|
|
49
|
-
}
|
|
50
|
-
(0, assert_js_1.assert)(setup.vikeVitePlugin);
|
|
51
|
-
(0, assert_js_1.assert)(setup.shouldNotBeProduction);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// Ensure NODE_ENV is 'production' when building.
|
|
55
|
-
// - Used by both Vue and React for bundling minified version:
|
|
56
|
-
// - Vue: https://github.com/vuejs/core/blob/f66a75ea75c8aece065b61e2126b4c5b2338aa6e/packages/vue/index.js
|
|
57
|
-
// - React: https://github.com/facebook/react/blob/01ab35a9a731dec69995fbd28f3ac7eaad11e183/packages/react/npm/index.js
|
|
58
|
-
// - Required for React: setting NODE_ENV to a value other than 'production' triggers an error: https://github.com/vikejs/vike/issues/1469#issuecomment-1969301797
|
|
59
|
-
// - Not required for Vue: when building the app, NODE_ENV can be set to a value other than 'production', e.g. 'development'.
|
|
60
|
-
function onSetupBuild() {
|
|
61
|
-
assertUsageNodeEnvIsNotDev('building');
|
|
62
|
-
/* Not needed: Vite already sets `process.env.NODE_ENV = 'production'`
|
|
63
|
-
setNodeEnvProduction()
|
|
64
|
-
*/
|
|
65
|
-
}
|
|
66
|
-
// Called by ../node/prerender/runPrerender.ts
|
|
67
|
-
function onSetupPrerender() {
|
|
68
|
-
markSetup_isPrerendering();
|
|
69
|
-
if (getNodeEnv())
|
|
70
|
-
assertUsageNodeEnvIsNotDev('pre-rendering');
|
|
71
|
-
setNodeEnvProduction();
|
|
72
|
-
}
|
|
73
|
-
// Called by ../node/api/preview.ts
|
|
74
|
-
function onSetupPreview() {
|
|
75
|
-
markSetup_isPreview();
|
|
76
|
-
}
|
|
77
|
-
function isTest() {
|
|
78
|
-
return (0, isVitest_js_1.isVitest)() || isNodeEnv('test');
|
|
79
|
-
}
|
|
80
|
-
// Called by Vite hook configureServer()
|
|
81
|
-
function markSetup_viteDevServer() {
|
|
82
|
-
if (debug.isActivated)
|
|
83
|
-
debug('markSetup_viteDevServer()', new Error().stack);
|
|
84
|
-
setup.viteDevServer = true;
|
|
85
|
-
}
|
|
86
|
-
// Called by Vite hook configurePreviewServer()
|
|
87
|
-
function markSetup_vitePreviewServer() {
|
|
88
|
-
if (debug.isActivated)
|
|
89
|
-
debug('markSetup_vitePreviewServer()', new Error().stack);
|
|
90
|
-
setup.vitePreviewServer = true;
|
|
91
|
-
}
|
|
92
|
-
// Called by ../node/vite/index.ts
|
|
93
|
-
function markSetup_vikeVitePlugin() {
|
|
94
|
-
if (debug.isActivated)
|
|
95
|
-
debug('markSetup_vikeVitePlugin()', new Error().stack);
|
|
96
|
-
setup.vikeVitePlugin = true;
|
|
97
|
-
}
|
|
98
|
-
// Whether Vite is loaded and whether it's in dev mode (the value returned by `isDevCheck()`)
|
|
99
|
-
function markSetup_isViteDev(isViteDev) {
|
|
100
|
-
if (debug.isActivated)
|
|
101
|
-
debug('markSetup_isViteDev()', new Error().stack);
|
|
102
|
-
setup.isViteDev = isViteDev;
|
|
103
|
-
}
|
|
104
|
-
function markSetup_isPrerendering() {
|
|
105
|
-
if (debug.isActivated)
|
|
106
|
-
debug('markSetup_isPrerendering()', new Error().stack);
|
|
107
|
-
setup.isPrerendering = true;
|
|
108
|
-
}
|
|
109
|
-
function markSetup_isPreview() {
|
|
110
|
-
if (debug.isActivated)
|
|
111
|
-
debug('markSetup_isPreview()', new Error().stack);
|
|
112
|
-
setup.isPreview = true;
|
|
113
|
-
}
|
|
114
|
-
function assertUsageNodeEnvIsNotDev(operation) {
|
|
115
|
-
if (!isNodeEnvDev())
|
|
116
|
-
return;
|
|
117
|
-
// TO-DO/eventually: make it assertUsage() again once https://github.com/vikejs/vike/issues/1528 is implemented.
|
|
118
|
-
(0, assert_js_1.assertWarning)(false, `The ${getEnvDescription()} upon ${operation} which shouldn't be the case, see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')}`, { onlyOnce: true });
|
|
119
|
-
}
|
|
120
|
-
function getEnvDescription() {
|
|
121
|
-
const envType = `${(isNodeEnvDev() ? 'development' : 'production')} environment`;
|
|
122
|
-
const nodeEnvDesc = `environment is set to be a ${picocolors_1.default.bold(envType)} by ${picocolors_1.default.cyan(`process.env.NODE_ENV===${JSON.stringify(getNodeEnv())}`)}`;
|
|
123
|
-
return nodeEnvDesc;
|
|
124
|
-
}
|
|
125
|
-
// For example, Wrangler bug replaces `process.env.NODE_ENV` with `"undefined"`
|
|
126
|
-
// https://github.com/cloudflare/workers-sdk/issues/7886
|
|
127
|
-
function assertNodeEnvIsNotUndefinedString() {
|
|
128
|
-
const nodeEnv = getNodeEnv();
|
|
129
|
-
(0, assert_js_1.assertWarning)(nodeEnv !== 'undefined', `${picocolors_1.default.cyan('process.env.NODE_ENV==="undefined"')} which is unexpected: ${picocolors_1.default.cyan('process.env.NODE_ENV')} is allowed to be the *value* ${picocolors_1.default.cyan('undefined')} (i.e. ${picocolors_1.default.cyan('process.env.NODE_ENV===undefined')}) but it shouldn't be the *string* ${picocolors_1.default.cyan('"undefined"')} — see ${picocolors_1.default.underline('https://vike.dev/NODE_ENV')}`, { onlyOnce: true });
|
|
130
|
-
}
|
|
131
|
-
function isNodeEnvDev() {
|
|
132
|
-
const nodeEnv = getNodeEnv();
|
|
133
|
-
// That's quite strict, let's see if some user complains
|
|
134
|
-
return nodeEnv === undefined || isNodeEnv(['development', 'dev', '']);
|
|
135
|
-
}
|
|
136
|
-
function isNodeEnv(value) {
|
|
137
|
-
const values = Array.isArray(value) ? value : [value];
|
|
138
|
-
const nodeEnv = getNodeEnv();
|
|
139
|
-
return nodeEnv !== undefined && values.includes(nodeEnv.toLowerCase());
|
|
140
|
-
}
|
|
141
|
-
function getNodeEnv() {
|
|
142
|
-
let val;
|
|
143
|
-
try {
|
|
144
|
-
val = process.env.NODE_ENV;
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
/*
|
|
150
|
-
// Should we show the following warning? So far I don't think so because of the following. Maybe we can show it once we enable users to disable warnings.
|
|
151
|
-
// - The warning isn't always actionable, e.g. if it's a tool that dynamically sets `process.env.NODE_ENV`.
|
|
152
|
-
// - We assume that tools use `process.env.NODE_ENV` and not something like `const { env } = process; env.NODE_ENV`. Thus, in practice, `val` overrides `val2` so having `val!==val2` isn't an issue.
|
|
153
|
-
{
|
|
154
|
-
const val2 = process.env['NODE' + '_ENV']
|
|
155
|
-
if (val2)
|
|
156
|
-
assertWarning(
|
|
157
|
-
val === val2,
|
|
158
|
-
`Dynamically setting process.env.NODE_ENV to ${val2} hasn't any effect because process.env.NODE_ENV is being statically replaced to ${val}.`,
|
|
159
|
-
{ onlyOnce: true }
|
|
160
|
-
)
|
|
161
|
-
}
|
|
162
|
-
//*/
|
|
163
|
-
return val;
|
|
164
|
-
}
|
|
165
|
-
function setNodeEnvProduction() {
|
|
166
|
-
// The statement `process.env['NODE_ENV'] = 'production'` chokes webpack v4
|
|
167
|
-
const proc = process;
|
|
168
|
-
const { env } = proc;
|
|
169
|
-
env.NODE_ENV = 'production';
|
|
170
|
-
(0, assert_js_1.assert)(isNodeEnv('production'));
|
|
171
|
-
}
|
|
@@ -1,110 +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.assertSingleInstance_onClientEntryServerRouting = assertSingleInstance_onClientEntryServerRouting;
|
|
7
|
-
exports.assertSingleInstance_onClientEntryClientRouting = assertSingleInstance_onClientEntryClientRouting;
|
|
8
|
-
exports.assertSingleInstance_onAssertModuleLoad = assertSingleInstance_onAssertModuleLoad;
|
|
9
|
-
// - Show warning if there are two different Vike versions loaded
|
|
10
|
-
// - Show warning if entry of Client Routing and entry of Server Routing are both loaded
|
|
11
|
-
// - Show warning if Vike is loaded twice
|
|
12
|
-
const unique_js_1 = require("./unique.js");
|
|
13
|
-
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
14
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
|
-
const PROJECT_VERSION_js_1 = require("./PROJECT_VERSION.js");
|
|
16
|
-
/* Use original assertWarning() after all CJS is removed from node_modules/vike/dist/
|
|
17
|
-
import { assertWarning } from './assert.js'
|
|
18
|
-
*/
|
|
19
|
-
let globalObject;
|
|
20
|
-
// getGlobalObjectSafe() can be called before this line
|
|
21
|
-
globalObject ?? (globalObject = genGlobalConfig());
|
|
22
|
-
function genGlobalConfig() {
|
|
23
|
-
return (0, getGlobalObject_js_1.getGlobalObject)('utils/assertSingleInstance.ts', {
|
|
24
|
-
instances: [],
|
|
25
|
-
alreadyLogged: new Set(),
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
// We need getGlobalObjectSafe() because globalObject is `undefined` when exported functions are called before globalObject is initialized
|
|
29
|
-
function getGlobalObjectSafe() {
|
|
30
|
-
globalObject ?? (globalObject = genGlobalConfig());
|
|
31
|
-
return globalObject;
|
|
32
|
-
}
|
|
33
|
-
const clientRuntimesClonflict = 'Client runtime of both Server Routing and Client Routing loaded https://vike.dev/client-runtimes-conflict';
|
|
34
|
-
const clientNotSingleInstance = 'Client runtime loaded twice https://vike.dev/client-runtime-duplicated';
|
|
35
|
-
function assertSingleInstance() {
|
|
36
|
-
const globalObject = getGlobalObjectSafe();
|
|
37
|
-
{
|
|
38
|
-
const versions = (0, unique_js_1.unique)(globalObject.instances);
|
|
39
|
-
assertWarning(versions.length <= 1,
|
|
40
|
-
// Do *NOT* patch Vike to remove this warning: you *will* eventually encounter the issues listed at https://vike.dev/warning/version-mismatch
|
|
41
|
-
// - This happened before: https://github.com/vikejs/vike/issues/1108#issuecomment-1719061509
|
|
42
|
-
`vike@${picocolors_1.default.bold(versions[0])} and vike@${picocolors_1.default.bold(versions[1])} loaded which is highly discouraged, see ${picocolors_1.default.underline('https://vike.dev/warning/version-mismatch')}`, { onlyOnce: true, showStackTrace: false });
|
|
43
|
-
}
|
|
44
|
-
if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
|
|
45
|
-
/*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
|
|
46
|
-
console.warn(clientNotSingleInstance)
|
|
47
|
-
/*/
|
|
48
|
-
assertWarning(false, clientNotSingleInstance, { onlyOnce: true, showStackTrace: true });
|
|
49
|
-
//*/
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function assertSingleInstance_onClientEntryServerRouting(isProduction) {
|
|
53
|
-
const globalObject = getGlobalObjectSafe();
|
|
54
|
-
assertWarning(globalObject.isClientRouting !== true, clientRuntimesClonflict, {
|
|
55
|
-
onlyOnce: true,
|
|
56
|
-
showStackTrace: true,
|
|
57
|
-
});
|
|
58
|
-
assertWarning(globalObject.isClientRouting === undefined, clientNotSingleInstance, {
|
|
59
|
-
onlyOnce: true,
|
|
60
|
-
showStackTrace: true,
|
|
61
|
-
});
|
|
62
|
-
globalObject.isClientRouting = false;
|
|
63
|
-
if (isProduction)
|
|
64
|
-
globalObject.checkSingleInstance = true;
|
|
65
|
-
assertSingleInstance();
|
|
66
|
-
}
|
|
67
|
-
function assertSingleInstance_onClientEntryClientRouting(isProduction) {
|
|
68
|
-
const globalObject = getGlobalObjectSafe();
|
|
69
|
-
assertWarning(globalObject.isClientRouting !== false, clientRuntimesClonflict, {
|
|
70
|
-
onlyOnce: true,
|
|
71
|
-
showStackTrace: true,
|
|
72
|
-
});
|
|
73
|
-
assertWarning(globalObject.isClientRouting === undefined, clientNotSingleInstance, {
|
|
74
|
-
onlyOnce: true,
|
|
75
|
-
showStackTrace: true,
|
|
76
|
-
});
|
|
77
|
-
globalObject.isClientRouting = true;
|
|
78
|
-
if (isProduction)
|
|
79
|
-
globalObject.checkSingleInstance = true;
|
|
80
|
-
assertSingleInstance();
|
|
81
|
-
}
|
|
82
|
-
// Called by utils/assert.ts which is (most certainly) loaded by all entries. That way we don't have to call a callback for every entry. (There are a lot of entries: `client/router/`, `client/`, `node/runtime/`, `node/vite/`, `node/cli`.)
|
|
83
|
-
function assertSingleInstance_onAssertModuleLoad() {
|
|
84
|
-
const globalObject = getGlobalObjectSafe();
|
|
85
|
-
globalObject.instances.push(PROJECT_VERSION_js_1.PROJECT_VERSION);
|
|
86
|
-
assertSingleInstance();
|
|
87
|
-
}
|
|
88
|
-
function assertWarning(condition, errorMessage, { onlyOnce, showStackTrace }) {
|
|
89
|
-
const globalObject = getGlobalObjectSafe();
|
|
90
|
-
if (condition) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const msg = `[Vike][Warning] ${errorMessage}`;
|
|
94
|
-
if (onlyOnce) {
|
|
95
|
-
const { alreadyLogged } = globalObject;
|
|
96
|
-
const key = onlyOnce === true ? msg : onlyOnce;
|
|
97
|
-
if (alreadyLogged.has(key)) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
alreadyLogged.add(key);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (showStackTrace) {
|
|
105
|
-
console.warn(new Error(msg));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
console.warn(msg);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,60 +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.assertVersion = assertVersion;
|
|
7
|
-
exports.isVersionMatch = isVersionMatch;
|
|
8
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
-
const assert_js_1 = require("./assert.js");
|
|
10
|
-
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
11
|
-
const joinEnglish_js_1 = require("./joinEnglish.js");
|
|
12
|
-
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
13
|
-
function assertVersion(dependencyName, versionActual, versionExpectedList) {
|
|
14
|
-
(0, assert_js_1.assertUsage)(isVersionMatch(versionActual, versionExpectedList), `${picocolors_1.default.bold(dependencyName)} ${picocolors_1.default.red(picocolors_1.default.bold(versionActual))} isn't supported, use ${picocolors_1.default.bold(dependencyName)} ${(0, joinEnglish_js_1.joinEnglish)([...versionExpectedList, 'above'].map((v) => picocolors_1.default.green(picocolors_1.default.bold(v))), 'or')}.`);
|
|
15
|
-
}
|
|
16
|
-
function isVersionMatch(versionActual, versionExpectedList) {
|
|
17
|
-
(0, assert_js_1.assert)(versionActual);
|
|
18
|
-
(0, assert_js_1.assert)(versionExpectedList);
|
|
19
|
-
(0, assert_js_1.assert)(versionExpectedList.length > 0);
|
|
20
|
-
const versionActualMajor = parseVersion(versionActual)[0];
|
|
21
|
-
const versionExpectedListSameMajor = versionExpectedList.filter((versionExpected) => {
|
|
22
|
-
const versionExpectedMajor = parseVersion(versionExpected)[0];
|
|
23
|
-
return versionExpectedMajor === versionActualMajor;
|
|
24
|
-
});
|
|
25
|
-
(0, assert_js_1.assert)(versionExpectedListSameMajor.length <= 1);
|
|
26
|
-
const versionExpectedSameMajor = versionExpectedListSameMajor[0];
|
|
27
|
-
if (versionExpectedSameMajor) {
|
|
28
|
-
return isSameOrAbove(versionActual, versionExpectedSameMajor);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return versionExpectedList.every((versionExpected) => isSameOrAbove(versionActual, versionExpected));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function isSameOrAbove(versionActual, versionExpected) {
|
|
35
|
-
const p1 = parseVersion(versionActual);
|
|
36
|
-
const p2 = parseVersion(versionExpected);
|
|
37
|
-
// major
|
|
38
|
-
if (p1[0] !== p2[0])
|
|
39
|
-
return p1[0] > p2[0];
|
|
40
|
-
// minor
|
|
41
|
-
if (p1[1] !== p2[1])
|
|
42
|
-
return p1[1] > p2[1];
|
|
43
|
-
// patch
|
|
44
|
-
if (p1[2] !== p2[2])
|
|
45
|
-
return p1[2] > p2[2];
|
|
46
|
-
// Same version
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
function parseVersion(version) {
|
|
50
|
-
// Remove pre-release tag
|
|
51
|
-
version = version.split('-')[0];
|
|
52
|
-
let partsStr = version.split('.');
|
|
53
|
-
// Git seems to be using a fourth number: https://github.com/git/git/tree/master/Documentation/RelNotes
|
|
54
|
-
partsStr = partsStr.slice(0, 3);
|
|
55
|
-
// major.minor.patch
|
|
56
|
-
(0, assert_js_1.assert)(partsStr.length === 3);
|
|
57
|
-
(0, assert_js_1.assert)(partsStr.every((s) => s.length > 0));
|
|
58
|
-
const parts = partsStr.map((s) => parseInt(s, 10));
|
|
59
|
-
return parts;
|
|
60
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
4
|
-
function capitalizeFirstLetter(word) {
|
|
5
|
-
if (!word[0]) {
|
|
6
|
-
return word;
|
|
7
|
-
}
|
|
8
|
-
return word[0].toUpperCase() + word.slice(1);
|
|
9
|
-
}
|
package/dist/cjs/utils/cast.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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] Rendering ${tracker.count} times within ${withinSeconds} seconds [${functionName}]`;
|
|
18
|
-
if (tracker.count > maxNumberOfCalls) {
|
|
19
|
-
(0, assert_js_1.assertUsage)(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, showStackTrace: true });
|
|
25
|
-
tracker.warned = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function createTracker(now) {
|
|
29
|
-
const tracker = {
|
|
30
|
-
count: 0,
|
|
31
|
-
start: now,
|
|
32
|
-
};
|
|
33
|
-
return tracker;
|
|
34
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeEnumerable = changeEnumerable;
|
|
4
|
-
/** Change enumerability of an object property. */
|
|
5
|
-
function changeEnumerable(obj, prop, enumerable) {
|
|
6
|
-
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
7
|
-
Object.defineProperty(obj, prop, { ...descriptor, enumerable });
|
|
8
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compareString = compareString;
|
|
4
|
-
function compareString(str1, str2) {
|
|
5
|
-
if (str1.toLowerCase() < str2.toLowerCase())
|
|
6
|
-
return -1;
|
|
7
|
-
if (str1.toLowerCase() > str2.toLowerCase())
|
|
8
|
-
return 1;
|
|
9
|
-
return 0;
|
|
10
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createErrorWithCleanStackTrace = createErrorWithCleanStackTrace;
|
|
4
|
-
const isNodeJS_js_1 = require("./isNodeJS.js");
|
|
5
|
-
function createErrorWithCleanStackTrace(errorMessage, numberOfStackTraceLinesToRemove) {
|
|
6
|
-
const err = new Error(errorMessage);
|
|
7
|
-
if ((0, isNodeJS_js_1.isNodeJS)()) {
|
|
8
|
-
err.stack = clean(err.stack, numberOfStackTraceLinesToRemove);
|
|
9
|
-
}
|
|
10
|
-
return err;
|
|
11
|
-
}
|
|
12
|
-
function clean(errStack, numberOfStackTraceLinesToRemove) {
|
|
13
|
-
if (!errStack) {
|
|
14
|
-
return errStack;
|
|
15
|
-
}
|
|
16
|
-
const stackLines = splitByLine(errStack);
|
|
17
|
-
let linesRemoved = 0;
|
|
18
|
-
const stackLine__cleaned = stackLines
|
|
19
|
-
.filter((line) => {
|
|
20
|
-
// Remove internal stack traces
|
|
21
|
-
if (line.includes(' (internal/') || line.includes(' (node:internal')) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (linesRemoved < numberOfStackTraceLinesToRemove && isStackTraceLine(line)) {
|
|
25
|
-
linesRemoved++;
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
})
|
|
30
|
-
.join('\n');
|
|
31
|
-
return stackLine__cleaned;
|
|
32
|
-
}
|
|
33
|
-
function isStackTraceLine(line) {
|
|
34
|
-
return line.startsWith(' at ');
|
|
35
|
-
}
|
|
36
|
-
function splitByLine(str) {
|
|
37
|
-
// https://stackoverflow.com/questions/21895233/how-in-node-to-split-string-by-newline-n
|
|
38
|
-
return str.split(/\r?\n/);
|
|
39
|
-
}
|
package/dist/cjs/utils/debug.js
DELETED
|
@@ -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.createDebugger = createDebugger;
|
|
7
|
-
exports.isDebugActivated = isDebugActivated;
|
|
8
|
-
const isCallable_js_1 = require("./isCallable.js");
|
|
9
|
-
const objectAssign_js_1 = require("./objectAssign.js");
|
|
10
|
-
const assert_js_1 = require("./assert.js");
|
|
11
|
-
const checkType_js_1 = require("./checkType.js");
|
|
12
|
-
const getTerminalWidth_js_1 = require("./getTerminalWidth.js");
|
|
13
|
-
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
14
|
-
const isArray_js_1 = require("./isArray.js");
|
|
15
|
-
const isObject_js_1 = require("./isObject.js");
|
|
16
|
-
const debug_js_1 = require("../shared/route/debug.js");
|
|
17
|
-
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
18
|
-
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
19
|
-
(0, debug_js_1.setCreateDebugger)(createDebugger); // for isomorphic code
|
|
20
|
-
const flags = [
|
|
21
|
-
'vike:crawl',
|
|
22
|
-
'vike:error',
|
|
23
|
-
'vike:esbuild-resolve',
|
|
24
|
-
'vike:pluginExtractAssets',
|
|
25
|
-
'vike:pluginExtractExportNames',
|
|
26
|
-
'vike:glob',
|
|
27
|
-
'vike:globalContext',
|
|
28
|
-
'vike:log',
|
|
29
|
-
'vike:optimizeDeps',
|
|
30
|
-
'vike:outDir',
|
|
31
|
-
'vike:pageFiles',
|
|
32
|
-
'vike:pointer-imports',
|
|
33
|
-
'vike:resolve',
|
|
34
|
-
'vike:routing',
|
|
35
|
-
'vike:setup',
|
|
36
|
-
'vike:stream',
|
|
37
|
-
'vike:virtualFiles',
|
|
38
|
-
'vike:vite-rpc',
|
|
39
|
-
];
|
|
40
|
-
const flagsSkipWildcard = ['vike:log'];
|
|
41
|
-
const flagRegex = /\bvike:[a-zA-Z-]+/g;
|
|
42
|
-
// We purposely read process.env.DEBUG early, in order to avoid users from the temptation to set process.env.DEBUG with JavaScript, since reading & writing process.env.DEBUG dynamically leads to inconsistencies such as https://github.com/vikejs/vike/issues/2239
|
|
43
|
-
const DEBUG = getDEBUG() ?? '';
|
|
44
|
-
if (isDebug())
|
|
45
|
-
Error.stackTraceLimit = Infinity;
|
|
46
|
-
assertFlagsActivated();
|
|
47
|
-
function createDebugger(flag, optionsGlobal) {
|
|
48
|
-
(0, checkType_js_1.checkType)(flag);
|
|
49
|
-
(0, assert_js_1.assert)(flags.includes(flag));
|
|
50
|
-
const debugWithOptions = (optionsLocal) => {
|
|
51
|
-
return (...msgs) => {
|
|
52
|
-
const options = { ...optionsGlobal, ...optionsLocal };
|
|
53
|
-
debug_(flag, options, ...msgs);
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const debug = (...msgs) => debugWithOptions({})(...msgs);
|
|
57
|
-
(0, objectAssign_js_1.objectAssign)(debug, { options: debugWithOptions, isActivated: isDebugActivated(flag) });
|
|
58
|
-
return debug;
|
|
59
|
-
}
|
|
60
|
-
function debug_(flag, options, ...msgs) {
|
|
61
|
-
if (!isDebugActivated(flag))
|
|
62
|
-
return;
|
|
63
|
-
let [msgFirst, ...msgsRest] = msgs;
|
|
64
|
-
const padding = ' '.repeat(flag.length + 1);
|
|
65
|
-
msgFirst = formatMsg(msgFirst, options, padding, 'FIRST');
|
|
66
|
-
msgsRest = msgsRest.map((msg, i) => {
|
|
67
|
-
const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE';
|
|
68
|
-
return formatMsg(msg, options, padding, position);
|
|
69
|
-
});
|
|
70
|
-
let logFirst;
|
|
71
|
-
let logsRest;
|
|
72
|
-
const noNewLine = msgsRest.length <= 1 &&
|
|
73
|
-
[msgFirst, ...msgsRest].every((m) => (typeof m === 'string' ? !m.includes('\n') : !(0, isObject_js_1.isObject)(m)));
|
|
74
|
-
if (noNewLine) {
|
|
75
|
-
logFirst = [msgFirst, ...msgsRest].map((m) => (typeof m !== 'string' ? m : m.trim()));
|
|
76
|
-
logsRest = [];
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
logFirst = [msgFirst];
|
|
80
|
-
logsRest = msgsRest;
|
|
81
|
-
}
|
|
82
|
-
console.log('\x1b[1m%s\x1b[0m', flag, ...logFirst);
|
|
83
|
-
logsRest.forEach((msg) => {
|
|
84
|
-
console.log(msg);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
function isDebugActivated(flag) {
|
|
88
|
-
(0, checkType_js_1.checkType)(flag);
|
|
89
|
-
(0, assert_js_1.assert)(flags.includes(flag));
|
|
90
|
-
const { flagsActivated, all } = getFlagsActivated();
|
|
91
|
-
const isActivated = flagsActivated.includes(flag) || (all && !flagsSkipWildcard.includes(flag));
|
|
92
|
-
return isActivated;
|
|
93
|
-
}
|
|
94
|
-
function formatMsg(info, options, padding, position) {
|
|
95
|
-
if (info === undefined) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
let str = position === 'FIRST' ? '' : padding;
|
|
99
|
-
if (typeof info === 'string') {
|
|
100
|
-
str += info;
|
|
101
|
-
}
|
|
102
|
-
else if ((0, isArray_js_1.isArray)(info)) {
|
|
103
|
-
if (info.length === 0) {
|
|
104
|
-
str += options.serialization?.emptyArray ?? '[]';
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
str += info.map(strUnknown).join('\n');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
str += strUnknown(info);
|
|
112
|
-
}
|
|
113
|
-
str = pad(str, padding);
|
|
114
|
-
if (position !== 'LAST' && position !== 'FIRST') {
|
|
115
|
-
str += '\n';
|
|
116
|
-
}
|
|
117
|
-
return str;
|
|
118
|
-
}
|
|
119
|
-
function pad(str, padding) {
|
|
120
|
-
const terminalWidth = (0, getTerminalWidth_js_1.getTerminalWidth)();
|
|
121
|
-
const lines = [];
|
|
122
|
-
str.split('\n').forEach((line) => {
|
|
123
|
-
if (!terminalWidth) {
|
|
124
|
-
lines.push(line);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
chunk(line, terminalWidth - padding.length).forEach((chunk) => {
|
|
128
|
-
lines.push(chunk);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
return lines.join('\n' + padding);
|
|
133
|
-
}
|
|
134
|
-
function chunk(str, size) {
|
|
135
|
-
if (str.length <= size) {
|
|
136
|
-
return [str];
|
|
137
|
-
}
|
|
138
|
-
const chunks = str.match(new RegExp('.{1,' + size + '}', 'g'));
|
|
139
|
-
(0, assert_js_1.assert)(chunks);
|
|
140
|
-
return chunks;
|
|
141
|
-
}
|
|
142
|
-
function strUnknown(thing) {
|
|
143
|
-
return typeof thing === 'string' ? thing : strObj(thing);
|
|
144
|
-
}
|
|
145
|
-
function strObj(obj, newLines = true) {
|
|
146
|
-
return JSON.stringify(obj, replaceFunctionSerializer, newLines ? 2 : undefined);
|
|
147
|
-
}
|
|
148
|
-
function replaceFunctionSerializer(_key, value) {
|
|
149
|
-
if ((0, isCallable_js_1.isCallable)(value)) {
|
|
150
|
-
return value.toString().split(/\s+/).join(' ');
|
|
151
|
-
}
|
|
152
|
-
return value;
|
|
153
|
-
}
|
|
154
|
-
function assertFlagsActivated() {
|
|
155
|
-
const { flagsActivated } = getFlagsActivated();
|
|
156
|
-
flagsActivated.forEach((flag) => {
|
|
157
|
-
(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')}`);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function getFlagsActivated() {
|
|
161
|
-
const flagsActivated = DEBUG.match(flagRegex) ?? [];
|
|
162
|
-
const all = DEBUG.includes('vike:*');
|
|
163
|
-
return { flagsActivated, all };
|
|
164
|
-
}
|
|
165
|
-
function isDebug() {
|
|
166
|
-
const { flagsActivated, all } = getFlagsActivated();
|
|
167
|
-
return all || flagsActivated.length > 0;
|
|
168
|
-
}
|
|
169
|
-
function getDEBUG() {
|
|
170
|
-
let DEBUG;
|
|
171
|
-
// - `process` can be undefined in edge workers
|
|
172
|
-
// - We want bundlers to be able to statically replace `process.env.*`
|
|
173
|
-
try {
|
|
174
|
-
DEBUG = process.env.DEBUG;
|
|
175
|
-
}
|
|
176
|
-
catch { }
|
|
177
|
-
return DEBUG;
|
|
178
|
-
}
|