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,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEqualStringList = isEqualStringList;
|
|
4
|
-
function isEqualStringList(a, b) {
|
|
5
|
-
if (a === b)
|
|
6
|
-
return true;
|
|
7
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
8
|
-
const sortedA = [...a].sort();
|
|
9
|
-
const sortedB = [...b].sort();
|
|
10
|
-
return sortedA.length === sortedB.length && sortedA.every((val, i) => val === sortedB[i]);
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
@@ -1,66 +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.assertFilePathAbsoluteFilesystem = assertFilePathAbsoluteFilesystem;
|
|
7
|
-
exports.isFilePathAbsoluteFilesystem = isFilePathAbsoluteFilesystem;
|
|
8
|
-
exports.isFilePathAbsolute = isFilePathAbsolute;
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const assert_js_1 = require("./assert.js");
|
|
11
|
-
const path_js_1 = require("./path.js");
|
|
12
|
-
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
13
|
-
const assertSetup_js_1 = require("./assertSetup.js");
|
|
14
|
-
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
15
|
-
// Server runtime shouldn't depend on node:path
|
|
16
|
-
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
17
|
-
/**
|
|
18
|
-
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
19
|
-
*
|
|
20
|
-
* It isn't reliable for Linux users, but that's okay because the assertion will eventually fail on windows.
|
|
21
|
-
*/
|
|
22
|
-
function assertFilePathAbsoluteFilesystem(filePath) {
|
|
23
|
-
// The assert is "eventually reliable":
|
|
24
|
-
// - For Windows users, the assert is correct.
|
|
25
|
-
// - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
26
|
-
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
27
|
-
// - On Linux there doesn't seem to be a way to distinguish between an absolute path starting from the filesystem root or starting from the user root directory, see comment at isFilePathAbsoluteFilesystem()
|
|
28
|
-
(0, path_js_1.assertPosixPath)(filePath);
|
|
29
|
-
(0, assert_js_1.assert)(isFilePathAbsoluteFilesystem(filePath));
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Whether `filePath` is an absolute file path starting from the filesystem root.
|
|
33
|
-
*
|
|
34
|
-
* Isn't reliable for Linux users: it returns `true` for an absolute path starting from the user root dir.
|
|
35
|
-
*/
|
|
36
|
-
function isFilePathAbsoluteFilesystem(filePath) {
|
|
37
|
-
(0, assert_js_1.assert)(!filePath.startsWith('/@fs/'));
|
|
38
|
-
if (process.platform !== 'win32') {
|
|
39
|
-
// - For linux users, there doesn't seem to be a reliable way to distinguish between:
|
|
40
|
-
// - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
|
|
41
|
-
// - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
|
|
42
|
-
// - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
|
|
43
|
-
// - Using require.resolve() or node:fs to check whether the file/dir exists would be a solution, but maybe too slow?
|
|
44
|
-
return filePath.startsWith('/');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const yes = node_path_1.default.win32.isAbsolute(filePath);
|
|
48
|
-
// Ensure isFilePathAbsoluteFilesystem() returns `false` if path is absolute starting from the user root dir (see comments above).
|
|
49
|
-
if (yes)
|
|
50
|
-
(0, assert_js_1.assert)(!filePath.startsWith('/'));
|
|
51
|
-
return yes;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Whether `filePath` is an absolute file path.
|
|
56
|
-
*
|
|
57
|
-
* Returns `true` regardless whether it starts from the user root dir or filesystem root.
|
|
58
|
-
*/
|
|
59
|
-
function isFilePathAbsolute(filePath) {
|
|
60
|
-
(0, assert_js_1.assert)(!filePath.startsWith('/@fs/'));
|
|
61
|
-
// Absolute path starting from the user root dir.
|
|
62
|
-
if (filePath.startsWith('/'))
|
|
63
|
-
return true;
|
|
64
|
-
// Seems to be reliable: https://nodejs.org/api/path.html#pathisabsolutepath
|
|
65
|
-
return node_path_1.default.isAbsolute(filePath);
|
|
66
|
-
}
|
package/dist/cjs/utils/isHtml.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Unit tests at ./isHtml.spec.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.isHtml = isHtml;
|
|
5
|
-
function isHtml(str) {
|
|
6
|
-
// Copied and adapted from https://stackoverflow.com/questions/15458876/check-if-a-string-is-html-or-not/51325984#51325984
|
|
7
|
-
const re = /(<\/[^<]+>)|(<[^<]+\/>)/;
|
|
8
|
-
return re.test(str);
|
|
9
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isImportPath = isImportPath;
|
|
4
|
-
exports.isImportPathRelative = isImportPathRelative;
|
|
5
|
-
const path_js_1 = require("./path.js");
|
|
6
|
-
const assert_js_1 = require("./assert.js");
|
|
7
|
-
const parseNpmPackage_js_1 = require("./parseNpmPackage.js");
|
|
8
|
-
function isImportPath(importPath) {
|
|
9
|
-
return isImportPathRelative(importPath) || (0, parseNpmPackage_js_1.isImportPathNpmPackageOrPathAlias)(importPath);
|
|
10
|
-
}
|
|
11
|
-
// See also `import { pathIsRelative } from './path'`
|
|
12
|
-
function isImportPathRelative(importPath) {
|
|
13
|
-
(0, path_js_1.assertPosixPath)(importPath);
|
|
14
|
-
if (importPath.startsWith('./') || importPath.startsWith('../')) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
(0, assert_js_1.assert)(!importPath.startsWith('.'));
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNodeJS = isNodeJS;
|
|
4
|
-
function isNodeJS() {
|
|
5
|
-
if (typeof process === 'undefined')
|
|
6
|
-
return false;
|
|
7
|
-
if (!process.cwd)
|
|
8
|
-
return false;
|
|
9
|
-
// https://stackoverflow.com/questions/4224606/how-to-check-whether-a-script-is-running-under-node-js/35813135#35813135
|
|
10
|
-
if (!process.versions || typeof process.versions.node === 'undefined')
|
|
11
|
-
return false;
|
|
12
|
-
// https://stackoverflow.com/questions/4224606/how-to-check-whether-a-script-is-running-under-node-js/35813135#comment92529277_35813135
|
|
13
|
-
if (!process.release || process.release.name !== 'node')
|
|
14
|
-
return false;
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNonRunnableDev = isNonRunnableDev;
|
|
4
|
-
const assert_js_1 = require("./assert.js");
|
|
5
|
-
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
6
|
-
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
7
|
-
function isNonRunnableDev() {
|
|
8
|
-
if (typeof __VIKE__IS_NON_RUNNABLE_DEV === 'undefined')
|
|
9
|
-
return false;
|
|
10
|
-
(0, assert_js_1.assert)(__VIKE__IS_NON_RUNNABLE_DEV === true);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNullish = isNullish;
|
|
4
|
-
exports.isNotNullish = isNotNullish;
|
|
5
|
-
exports.isNotNullish_keyVal = isNotNullish_keyVal;
|
|
6
|
-
function isNullish(val) {
|
|
7
|
-
return val === null || val === undefined;
|
|
8
|
-
}
|
|
9
|
-
// someArray.filter(isNotNullish)
|
|
10
|
-
function isNotNullish(p) {
|
|
11
|
-
return !isNullish(p);
|
|
12
|
-
}
|
|
13
|
-
// objectFilter(obj).filter(isNotNullish_keyVal)
|
|
14
|
-
function isNotNullish_keyVal(arg) {
|
|
15
|
-
return !isNullish(arg[1]);
|
|
16
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isObjectOfStrings = isObjectOfStrings;
|
|
4
|
-
const isObject_js_1 = require("./isObject.js");
|
|
5
|
-
function isObjectOfStrings(val) {
|
|
6
|
-
return (0, isObject_js_1.isObject)(val) && Object.values(val).every((v) => typeof v === 'string');
|
|
7
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isObjectWithKeys = isObjectWithKeys;
|
|
4
|
-
const isPlainObject_js_1 = require("./isPlainObject.js");
|
|
5
|
-
function isObjectWithKeys(obj, keys) {
|
|
6
|
-
if (!(0, isPlainObject_js_1.isPlainObject)(obj)) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
for (const key of Object.keys(obj)) {
|
|
10
|
-
if (!keys.includes(key)) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPlainObject = isPlainObject;
|
|
4
|
-
function isPlainObject(value) {
|
|
5
|
-
// Is object?
|
|
6
|
-
if (typeof value !== 'object' || value === null) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
// Support `Object.create(null)`
|
|
10
|
-
if (Object.getPrototypeOf(value) === null) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
// Is plain object?
|
|
14
|
-
return (
|
|
15
|
-
/* Doesn't work in Cloudflare Pages workers
|
|
16
|
-
value.constructor === Object
|
|
17
|
-
*/
|
|
18
|
-
value.constructor.name === 'Object');
|
|
19
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPromise = isPromise;
|
|
4
|
-
const isCallable_js_1 = require("./isCallable.js");
|
|
5
|
-
function isPromise(val) {
|
|
6
|
-
return typeof val === 'object' && val !== null && 'then' in val && (0, isCallable_js_1.isCallable)(val.then);
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPropertyGetter = isPropertyGetter;
|
|
4
|
-
function isPropertyGetter(obj, prop) {
|
|
5
|
-
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
6
|
-
return !!descriptor && !('value' in descriptor) && !!descriptor.get;
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isReact = isReact;
|
|
4
|
-
// There doesn't seem to be a reliable way to detect React:
|
|
5
|
-
// - https://stackoverflow.com/questions/73156433/detect-with-javascript-whether-the-website-is-using-react
|
|
6
|
-
function isReact() {
|
|
7
|
-
// Heuristic using values set by React (Dev Tools)
|
|
8
|
-
// - `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` is an internal API for React Dev Tools
|
|
9
|
-
// - https://stackoverflow.com/questions/46807826/how-does-react-developer-tools-determine-that-the-webpage-is-using-react/46808361#46808361
|
|
10
|
-
// - In principle, `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` should exist only if React Dev Tools is installed. (Although it seems that it's sometimes defined even when React Dev Tools isn't installed; I don't know why.)
|
|
11
|
-
// - We use `isReact1`/`isReact2` merely to validate `isReact3` and `isReact4`. Because `isReact1`/`isReact2` can be false negatives:
|
|
12
|
-
// - React populates `__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers` fairly late => false negative early in the rendering phase
|
|
13
|
-
// - `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` is `undefined` if React Dev Tools isn't installed => false negative
|
|
14
|
-
const isReact1 = !!window.__REACT_DEVTOOLS_GLOBAL_HOOK__?.renderers?.size;
|
|
15
|
-
const isReact2 = !!window.__REACT_DEVTOOLS_GLOBAL_HOOK__?.rendererInterfaces?.size;
|
|
16
|
-
// Heuristic using values set by `@vitejs/plugin-react`
|
|
17
|
-
const isReact3 = !!window.__vite_plugin_react_preamble_installed__;
|
|
18
|
-
/* Also set by Preact Vite plugin `@preact/preset-vite`
|
|
19
|
-
const isReact4 = !!(window as any).$RefreshReg$
|
|
20
|
-
*/
|
|
21
|
-
// console.log({ isReact1, isReact2, isReact3 })
|
|
22
|
-
return isReact1 || isReact2 || isReact3;
|
|
23
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRunnableDevEnvironment = isRunnableDevEnvironment;
|
|
4
|
-
// We use this instead of `import { isRunnableDevEnvironment } from 'vite'` because:
|
|
5
|
-
// - Vite's isRunnableDevEnvironment() isn't reliable in monorepos where multiple Vite instances can be used simultaneously (it uses `instanceof RunnableDevEnvironment` which fails)
|
|
6
|
-
// - We can use this in Vike's server production runtime without having to load the 'vite' package
|
|
7
|
-
function isRunnableDevEnvironment(environment) {
|
|
8
|
-
return !!environment && 'runner' in environment && !!environment.runner;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSameErrorMessage = isSameErrorMessage;
|
|
4
|
-
const isObject_js_1 = require("./isObject.js");
|
|
5
|
-
function isSameErrorMessage(err1, err2) {
|
|
6
|
-
if (!(0, isObject_js_1.isObject)(err1) || !(0, isObject_js_1.isObject)(err2))
|
|
7
|
-
return false;
|
|
8
|
-
return err1.message === err2.message;
|
|
9
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scriptFileExtensionPattern = exports.scriptFileExtensionList = void 0;
|
|
4
|
-
exports.isScriptFile = isScriptFile;
|
|
5
|
-
exports.isPlainScriptFile = isPlainScriptFile;
|
|
6
|
-
exports.isTemplateFile = isTemplateFile;
|
|
7
|
-
// We can't use a RegExp:
|
|
8
|
-
// - Needs to work with Micromatch: https://github.com/micromatch/micromatch because:
|
|
9
|
-
// - Vite's `import.meta.glob()` uses Micromatch
|
|
10
|
-
// - We need this to be a allowlist because:
|
|
11
|
-
// - A pattern `*([a-zA-Z0-9]` doesn't work.
|
|
12
|
-
// - Because of ReScript: `.res` are ReScript source files which need to be ignored. (The ReScript compiler generates `.js` files alongside `.res` files.)
|
|
13
|
-
// - Block listing doesn't work.
|
|
14
|
-
// - We cannot implement a blocklist with a glob pattern.
|
|
15
|
-
// - A post `import.meta.glob()` blocklist filtering doesn't work because Vite would still process the files (e.g. including them in the bundle).
|
|
16
|
-
// prettier-ignore
|
|
17
|
-
// biome-ignore format:
|
|
18
|
-
const extJs = [
|
|
19
|
-
'js',
|
|
20
|
-
'cjs',
|
|
21
|
-
'mjs',
|
|
22
|
-
];
|
|
23
|
-
// prettier-ignore
|
|
24
|
-
// biome-ignore format:
|
|
25
|
-
const extTs = [
|
|
26
|
-
'ts',
|
|
27
|
-
'cts',
|
|
28
|
-
'mts',
|
|
29
|
-
];
|
|
30
|
-
const extJsOrTs = [...extJs, ...extTs];
|
|
31
|
-
// prettier-ignore
|
|
32
|
-
// biome-ignore format:
|
|
33
|
-
const extJsx = [
|
|
34
|
-
'jsx',
|
|
35
|
-
'cjsx',
|
|
36
|
-
'mjsx',
|
|
37
|
-
];
|
|
38
|
-
// prettier-ignore
|
|
39
|
-
// biome-ignore format:
|
|
40
|
-
const extTsx = [
|
|
41
|
-
'tsx',
|
|
42
|
-
'ctsx',
|
|
43
|
-
'mtsx'
|
|
44
|
-
];
|
|
45
|
-
const extJsxOrTsx = [...extJsx, ...extTsx];
|
|
46
|
-
// prettier-ignore
|
|
47
|
-
// biome-ignore format:
|
|
48
|
-
const extTemplates = [
|
|
49
|
-
'vue',
|
|
50
|
-
'svelte',
|
|
51
|
-
'marko',
|
|
52
|
-
'md',
|
|
53
|
-
'mdx'
|
|
54
|
-
];
|
|
55
|
-
const scriptFileExtensionList = [...extJsOrTs, ...extJsxOrTsx, ...extTemplates];
|
|
56
|
-
exports.scriptFileExtensionList = scriptFileExtensionList;
|
|
57
|
-
const scriptFileExtensionPattern = '(' + scriptFileExtensionList.join('|') + ')';
|
|
58
|
-
exports.scriptFileExtensionPattern = scriptFileExtensionPattern;
|
|
59
|
-
function isScriptFile(filePath) {
|
|
60
|
-
return scriptFileExtensionList.some((ext) => filePath.endsWith('.' + ext));
|
|
61
|
-
}
|
|
62
|
-
function isPlainScriptFile(filePath) {
|
|
63
|
-
return extJsOrTs.some((ext) => filePath.endsWith('.' + ext));
|
|
64
|
-
}
|
|
65
|
-
function isTemplateFile(filePath) {
|
|
66
|
-
return extTemplates.some((ext) => filePath.endsWith('.' + ext));
|
|
67
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isVikeReactApp = isVikeReactApp;
|
|
4
|
-
function isVikeReactApp() {
|
|
5
|
-
const g = globalThis;
|
|
6
|
-
// Set by vike-react https://github.com/vikejs/vike-react/blob/23e92434424f10e7e742b6bf587edee5aa8832df/packages/vike-react/src/renderer/onRenderHtml.tsx#L75
|
|
7
|
-
return !!g._isVikeReactApp;
|
|
8
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.joinEnglish = joinEnglish;
|
|
4
|
-
const assert_js_1 = require("./assert.js");
|
|
5
|
-
// https://stackoverflow.com/questions/53879088/join-an-array-by-commas-and-and/53879103#53879103
|
|
6
|
-
function joinEnglish(arr, conjunction, colorizer = (s) => s) {
|
|
7
|
-
(0, assert_js_1.assert)(arr.length > 0);
|
|
8
|
-
if (arr.length === 1)
|
|
9
|
-
return colorizer(arr[0]);
|
|
10
|
-
const firsts = arr.slice(0, arr.length - 1);
|
|
11
|
-
const last = arr[arr.length - 1];
|
|
12
|
-
const lastComma = arr.length > 2 ? ',' : '';
|
|
13
|
-
return firsts.map(colorizer).join(', ') + `${lastComma} ${conjunction} ` + colorizer(last);
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeHeaders = normalizeHeaders;
|
|
4
|
-
const isObject_js_1 = require("./isObject.js");
|
|
5
|
-
function normalizeHeaders(
|
|
6
|
-
/* This type is too strict which is annoying: cannot pass `string[][]` because it doesn't match the more precise type `[string,string][]`.
|
|
7
|
-
headersOriginal ConstructorParameters<typeof Headers>[0]
|
|
8
|
-
*/
|
|
9
|
-
headersOriginal) {
|
|
10
|
-
let headersCleaned = headersOriginal;
|
|
11
|
-
// Copied from https://github.com/hattipjs/hattip/blob/69237d181300b200a14114df2c3c115c44e0f3eb/packages/adapter/adapter-node/src/request.ts#L78-L83
|
|
12
|
-
if ((0, isObject_js_1.isObject)(headersCleaned) && headersCleaned[':method'])
|
|
13
|
-
headersCleaned = Object.fromEntries(Object.entries(headersCleaned).filter(([key]) => !key.startsWith(':')));
|
|
14
|
-
const headersStandard = new Headers(headersCleaned);
|
|
15
|
-
const headers = Object.fromEntries(headersStandard.entries());
|
|
16
|
-
return headers;
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectAssign = objectAssign;
|
|
4
|
-
const assert_js_1 = require("./assert.js");
|
|
5
|
-
// Same as Object.assign() but:
|
|
6
|
-
// - With type inference
|
|
7
|
-
// - Preserves property descriptors, which we need for preserving the getters of getPageContextUrlComputed()
|
|
8
|
-
function objectAssign(obj, objAddendum, objAddendumCanBeOriginalObject) {
|
|
9
|
-
if (!objAddendum)
|
|
10
|
-
return;
|
|
11
|
-
if (!objAddendumCanBeOriginalObject)
|
|
12
|
-
(0, assert_js_1.assert)(!objAddendum._isOriginalObject);
|
|
13
|
-
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
14
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectAssignSafe = objectAssignSafe;
|
|
4
|
-
// Same as `Object.assign(obj, objNewVals)` but ensure that `objNewVals` properties already exist on `obj`
|
|
5
|
-
function objectAssignSafe(obj, objNewVals) {
|
|
6
|
-
Object.assign(obj, objNewVals);
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectDefineProperty = objectDefineProperty;
|
|
4
|
-
// Same as Object.defineProperty() but with type inference
|
|
5
|
-
function objectDefineProperty(obj, prop, { get, ...args }) {
|
|
6
|
-
Object.defineProperty(obj, prop, { ...args, get });
|
|
7
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectEntries = objectEntries;
|
|
4
|
-
// https://stackoverflow.com/questions/60141960/typescript-key-value-relation-preserving-object-entries-type/75337277#75337277
|
|
5
|
-
/** Same as Object.entries() but with type inference */
|
|
6
|
-
function objectEntries(obj) {
|
|
7
|
-
return Object.entries(obj);
|
|
8
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectEntriesForEach = objectEntriesForEach;
|
|
4
|
-
/** Same as Object.entries().forEach() but with type inference */
|
|
5
|
-
function objectEntriesForEach(obj, iterator) {
|
|
6
|
-
Object.entries(obj).forEach(([key, val]) => iterator(key, val));
|
|
7
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectFilter = objectFilter;
|
|
4
|
-
// Type inference for:
|
|
5
|
-
// ```js
|
|
6
|
-
// Object.fromEntries(Object.entries(obj).filter(someFilter))
|
|
7
|
-
// ```
|
|
8
|
-
function objectFilter(obj, filter) {
|
|
9
|
-
return Object.fromEntries(Object.entries(obj).filter(filter));
|
|
10
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectKeys = objectKeys;
|
|
4
|
-
// https://stackoverflow.com/questions/52856496/typescript-object-keys-return-string
|
|
5
|
-
// https://github.com/sindresorhus/ts-extras/blob/main/source/object-keys.ts
|
|
6
|
-
/** Same as Object.keys() but with type inference */
|
|
7
|
-
function objectKeys(obj) {
|
|
8
|
-
return Object.keys(obj);
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectReplace = objectReplace;
|
|
4
|
-
function objectReplace(objOld, objNew, except) {
|
|
5
|
-
Object.keys(objOld)
|
|
6
|
-
.filter((key) => !except?.includes(key))
|
|
7
|
-
.forEach((key) => delete objOld[key]);
|
|
8
|
-
Object.defineProperties(objOld, Object.getOwnPropertyDescriptors(objNew));
|
|
9
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onPageHide = onPageHide;
|
|
4
|
-
exports.onPageShow = onPageShow;
|
|
5
|
-
function onPageHide(listener) {
|
|
6
|
-
window.addEventListener('visibilitychange', () => {
|
|
7
|
-
if (document.visibilityState === 'hidden') {
|
|
8
|
-
listener();
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
function onPageShow(listener) {
|
|
13
|
-
window.addEventListener('visibilitychange', () => {
|
|
14
|
-
if (document.visibilityState === 'visible') {
|
|
15
|
-
listener();
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
package/dist/cjs/utils/pLimit.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* Copied from https://github.com/sindresorhus/p-limit */
|
|
3
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
6
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
11
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
12
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
13
|
-
};
|
|
14
|
-
var _Queue_head, _Queue_tail, _Queue_size;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.pLimit = pLimit;
|
|
17
|
-
function pLimit(concurrency) {
|
|
18
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
19
|
-
throw new TypeError('Expected concurrency to be a number from 1 and up');
|
|
20
|
-
}
|
|
21
|
-
const queue = new Queue();
|
|
22
|
-
let activeCount = 0;
|
|
23
|
-
const next = () => {
|
|
24
|
-
activeCount--;
|
|
25
|
-
if (queue.size > 0) {
|
|
26
|
-
queue.dequeue()();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
const run = async (fn, resolve, args) => {
|
|
31
|
-
activeCount++;
|
|
32
|
-
const result = (async () => fn(...args))();
|
|
33
|
-
resolve(result);
|
|
34
|
-
try {
|
|
35
|
-
await result;
|
|
36
|
-
}
|
|
37
|
-
catch { }
|
|
38
|
-
next();
|
|
39
|
-
};
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
const enqueue = (fn, resolve, args) => {
|
|
42
|
-
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
|
43
|
-
(async () => {
|
|
44
|
-
// This function needs to wait until the next microtask before comparing
|
|
45
|
-
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
46
|
-
// when the run function is dequeued and called. The comparison in the if-statement
|
|
47
|
-
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
48
|
-
await Promise.resolve();
|
|
49
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
50
|
-
queue.dequeue()();
|
|
51
|
-
}
|
|
52
|
-
})();
|
|
53
|
-
};
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
56
|
-
enqueue(fn, resolve, args);
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperties(generator, {
|
|
59
|
-
activeCount: {
|
|
60
|
-
get: () => activeCount,
|
|
61
|
-
},
|
|
62
|
-
pendingCount: {
|
|
63
|
-
get: () => queue.size,
|
|
64
|
-
},
|
|
65
|
-
clearQueue: {
|
|
66
|
-
value: () => {
|
|
67
|
-
queue.clear();
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
return generator;
|
|
73
|
-
}
|
|
74
|
-
/*
|
|
75
|
-
How it works:
|
|
76
|
-
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
|
77
|
-
*/
|
|
78
|
-
class Node {
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
constructor(value) {
|
|
81
|
-
this.value = value;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
class Queue {
|
|
85
|
-
constructor() {
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
_Queue_head.set(this, void 0);
|
|
88
|
-
// @ts-ignore
|
|
89
|
-
_Queue_tail.set(this, void 0);
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
_Queue_size.set(this, void 0);
|
|
92
|
-
this.clear();
|
|
93
|
-
}
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
enqueue(value) {
|
|
96
|
-
var _a;
|
|
97
|
-
const node = new Node(value);
|
|
98
|
-
if (__classPrivateFieldGet(this, _Queue_head, "f")) {
|
|
99
|
-
__classPrivateFieldGet(this, _Queue_tail, "f").next = node;
|
|
100
|
-
__classPrivateFieldSet(this, _Queue_tail, node, "f");
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
__classPrivateFieldSet(this, _Queue_head, node, "f");
|
|
104
|
-
__classPrivateFieldSet(this, _Queue_tail, node, "f");
|
|
105
|
-
}
|
|
106
|
-
__classPrivateFieldSet(this, _Queue_size, (_a = __classPrivateFieldGet(this, _Queue_size, "f"), _a++, _a), "f");
|
|
107
|
-
}
|
|
108
|
-
dequeue() {
|
|
109
|
-
var _a;
|
|
110
|
-
const current = __classPrivateFieldGet(this, _Queue_head, "f");
|
|
111
|
-
if (!current) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
__classPrivateFieldSet(this, _Queue_head, __classPrivateFieldGet(this, _Queue_head, "f").next, "f");
|
|
115
|
-
__classPrivateFieldSet(this, _Queue_size, (_a = __classPrivateFieldGet(this, _Queue_size, "f"), _a--, _a), "f");
|
|
116
|
-
return current.value;
|
|
117
|
-
}
|
|
118
|
-
clear() {
|
|
119
|
-
__classPrivateFieldSet(this, _Queue_head, undefined, "f");
|
|
120
|
-
__classPrivateFieldSet(this, _Queue_tail, undefined, "f");
|
|
121
|
-
__classPrivateFieldSet(this, _Queue_size, 0, "f");
|
|
122
|
-
}
|
|
123
|
-
get size() {
|
|
124
|
-
return __classPrivateFieldGet(this, _Queue_size, "f");
|
|
125
|
-
}
|
|
126
|
-
*[(_Queue_head = new WeakMap(), _Queue_tail = new WeakMap(), _Queue_size = new WeakMap(), Symbol.iterator)]() {
|
|
127
|
-
let current = __classPrivateFieldGet(this, _Queue_head, "f");
|
|
128
|
-
while (current) {
|
|
129
|
-
yield current.value;
|
|
130
|
-
current = current.next;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.default = Queue;
|