vike 0.4.228 → 0.4.229-commit-a19745d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/__internal/index.js +2 -2
- package/dist/cjs/client/client-routing-runtime/globalContext.js +49 -0
- package/dist/cjs/client/server-routing-runtime/globalContext.js +41 -0
- package/dist/cjs/client/server-routing-runtime/utils.js +1 -1
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +58 -0
- package/dist/cjs/client/shared/getJsonSerializedInHtml.js +31 -0
- package/dist/cjs/client/shared/utils.js +22 -0
- package/dist/cjs/node/plugin/index.js +3 -1
- package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/handleAssetsManifest.js +10 -5
- package/dist/cjs/node/plugin/plugins/build/pluginBuildApp.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginBuildConfig.js +3 -10
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +9 -5
- package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +9 -5
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +1 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +14 -3
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +2 -7
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +6 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +17 -19
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +11 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +2 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformPointerImports.js → pointerImports.js} +13 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +20 -19
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +15 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +11 -11
- package/dist/cjs/node/plugin/plugins/replaceConstants.js +76 -0
- package/dist/cjs/node/plugin/shared/applyRegExWithMagicString.js +10 -0
- package/dist/cjs/node/plugin/shared/findPageFiles.js +1 -1
- package/dist/cjs/node/plugin/shared/getFilePath.js +2 -2
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +8 -20
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/prerender/runPrerender.js +44 -41
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +102 -125
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +18 -5
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +2 -2
- package/dist/cjs/node/runtime/html/propKeys.js +47 -0
- package/dist/cjs/node/runtime/html/renderHtml.js +13 -3
- package/dist/cjs/node/runtime/html/{serializePageContextClientSide.js → serializeContext.js} +37 -67
- package/dist/cjs/node/runtime/index-deprecated.js +9 -38
- package/dist/cjs/node/runtime/index.js +56 -2
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +8 -3
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +73 -0
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +1 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +1 -17
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +1 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +3 -3
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +1 -1
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/log404/index.js +1 -1
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -68
- package/dist/cjs/node/runtime/renderPage.js +102 -81
- package/dist/cjs/node/runtime/universal-middleware.js +7 -1
- package/dist/cjs/node/runtime/utils.js +3 -2
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/cjs/shared/createGlobalContextShared.js +54 -0
- package/dist/cjs/shared/createPageContextShared.js +17 -0
- package/dist/cjs/shared/getPageFiles/fileTypes.js +1 -1
- package/dist/cjs/shared/hooks/executeHookGeneric.js +18 -0
- package/dist/cjs/shared/hooks/getHook.js +45 -27
- package/dist/cjs/shared/htmlElementIds.js +5 -0
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +3 -7
- package/dist/cjs/shared/route/executeGuardHook.js +1 -1
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/catchInfiniteLoop.js +3 -3
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/cjs/utils/getPublicProxy.js +27 -0
- package/dist/cjs/utils/isImportPath.js +21 -0
- package/dist/cjs/utils/isScriptFile.js +24 -21
- package/dist/cjs/utils/objectAssign.js +6 -10
- package/dist/cjs/utils/objectReplace.js +4 -4
- package/dist/cjs/utils/{isNpmPackage.js → parseNpmPackage.js} +24 -23
- package/dist/cjs/utils/path.js +12 -2
- package/dist/cjs/utils/requireResolve.js +148 -53
- package/dist/esm/__internal/index.js +3 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +29 -10
- package/dist/esm/client/client-routing-runtime/createPageContext.js +23 -22
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +5 -4
- package/dist/esm/client/client-routing-runtime/globalContext.d.ts +20 -0
- package/dist/esm/client/client-routing-runtime/globalContext.js +13 -0
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +8 -7
- package/dist/esm/client/client-routing-runtime/utils.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/utils.js +0 -1
- package/dist/esm/client/index.d.ts +1 -0
- package/dist/esm/client/index.js +4 -0
- package/dist/esm/client/node.js +1 -3
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.d.ts +36 -0
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +47 -0
- package/dist/esm/client/server-routing-runtime/entry.js +2 -2
- package/dist/esm/client/server-routing-runtime/globalContext.d.ts +17 -0
- package/dist/esm/client/server-routing-runtime/globalContext.js +5 -0
- package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/utils.js +1 -1
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +23 -0
- package/dist/esm/client/shared/createGetGlobalContextClient.js +58 -0
- package/dist/esm/client/shared/executeOnRenderClientHook.js +5 -4
- package/dist/esm/client/shared/{getPageContextSerializedInHtml.d.ts → getJsonSerializedInHtml.d.ts} +2 -0
- package/dist/esm/client/shared/getJsonSerializedInHtml.js +29 -0
- package/dist/esm/client/shared/removeFoucBuster.js +1 -0
- package/dist/esm/client/shared/utils.d.ts +4 -0
- package/dist/esm/client/shared/utils.js +4 -0
- package/dist/esm/node/plugin/index.js +3 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
- package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.js +11 -6
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.js +2 -2
- package/dist/esm/node/plugin/plugins/build/pluginBuildConfig.js +4 -11
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +10 -6
- package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +9 -5
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -2
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +15 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +3 -8
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +7 -2
- package/dist/esm/node/plugin/plugins/envVars.js +18 -20
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +4 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +11 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformPointerImports.d.ts → pointerImports.d.ts} +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformPointerImports.js → pointerImports.js} +14 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +20 -19
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +15 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +11 -11
- package/dist/esm/node/plugin/plugins/replaceConstants.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/replaceConstants.js +71 -0
- package/dist/esm/node/plugin/shared/applyRegExWithMagicString.d.ts +3 -0
- package/dist/esm/node/plugin/shared/applyRegExWithMagicString.js +8 -0
- package/dist/esm/node/plugin/shared/findPageFiles.js +2 -2
- package/dist/esm/node/plugin/shared/getFilePath.js +3 -3
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.d.ts +1 -1
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +9 -21
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +314 -5
- package/dist/esm/node/prerender/runPrerender.js +48 -45
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +425 -47
- package/dist/esm/node/runtime/globalContext.js +103 -126
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +18 -5
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +2 -2
- package/dist/esm/node/runtime/html/injectAssets.d.ts +3 -3
- package/dist/esm/node/runtime/html/propKeys.d.ts +8 -0
- package/dist/esm/node/runtime/html/propKeys.js +45 -0
- package/dist/esm/node/runtime/html/renderHtml.js +13 -3
- package/dist/esm/node/runtime/html/{serializePageContextClientSide.d.ts → serializeContext.d.ts} +7 -6
- package/dist/esm/node/runtime/html/{serializePageContextClientSide.js → serializeContext.js} +36 -67
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -16
- package/dist/esm/node/runtime/index-deprecated.js +9 -36
- package/dist/esm/node/runtime/index.d.ts +23 -1
- package/dist/esm/node/runtime/index.js +38 -3
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +5 -4
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +8 -3
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +155 -0
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +71 -0
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -3
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +1 -17
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +3 -3
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.js +1 -1
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +225 -179
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -69
- package/dist/esm/node/runtime/renderPage.d.ts +146 -7
- package/dist/esm/node/runtime/renderPage.js +105 -84
- package/dist/esm/node/runtime/universal-middleware.js +7 -1
- package/dist/esm/node/runtime/utils.d.ts +3 -2
- package/dist/esm/node/runtime/utils.js +3 -2
- package/dist/esm/shared/VikeNamespace.d.ts +35 -13
- package/dist/esm/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/esm/shared/createGlobalContextShared.d.ts +39 -0
- package/dist/esm/shared/createGlobalContextShared.js +51 -0
- package/dist/esm/shared/createPageContextShared.d.ts +9 -0
- package/dist/esm/shared/createPageContextShared.js +15 -0
- package/dist/esm/shared/getPageFiles/fileTypes.js +1 -1
- package/dist/esm/shared/hooks/executeHookGeneric.d.ts +8 -0
- package/dist/esm/shared/hooks/executeHookGeneric.js +16 -0
- package/dist/esm/shared/hooks/getHook.d.ts +5 -3
- package/dist/esm/shared/hooks/getHook.js +47 -29
- package/dist/esm/shared/htmlElementIds.d.ts +2 -0
- package/dist/esm/shared/htmlElementIds.js +2 -0
- package/dist/esm/shared/page-configs/Config.d.ts +12 -2
- package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +1 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +3 -7
- package/dist/esm/shared/route/executeGuardHook.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +2 -1
- package/dist/esm/shared/types.d.ts +64 -32
- package/dist/esm/types/index.d.ts +1 -5
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/catchInfiniteLoop.js +4 -4
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +1 -0
- package/dist/esm/utils/getGlobalObject.d.ts +1 -1
- package/dist/esm/utils/getPublicProxy.d.ts +2 -0
- package/dist/esm/utils/getPublicProxy.js +25 -0
- package/dist/esm/utils/isImportPath.d.ts +4 -0
- package/dist/esm/utils/isImportPath.js +19 -0
- package/dist/esm/utils/isScriptFile.d.ts +5 -5
- package/dist/esm/utils/isScriptFile.js +23 -20
- package/dist/esm/utils/objectAssign.d.ts +1 -1
- package/dist/esm/utils/objectAssign.js +6 -10
- package/dist/esm/utils/objectReplace.d.ts +1 -1
- package/dist/esm/utils/objectReplace.js +4 -4
- package/dist/esm/utils/parseNpmPackage.d.ts +19 -0
- package/dist/esm/utils/{isNpmPackage.js → parseNpmPackage.js} +24 -24
- package/dist/esm/utils/path.d.ts +1 -1
- package/dist/esm/utils/path.js +12 -2
- package/dist/esm/utils/requireResolve.d.ts +20 -7
- package/dist/esm/utils/requireResolve.js +148 -53
- package/package.json +14 -13
- package/dist/cjs/node/runtime/index-common.js +0 -27
- package/dist/cjs/utils/makePublicCopy.js +0 -32
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +0 -19
- package/dist/esm/client/server-routing-runtime/getPageContext.js +0 -44
- package/dist/esm/client/shared/getPageContextSerializedInHtml.js +0 -20
- package/dist/esm/node/runtime/index-common.d.ts +0 -8
- package/dist/esm/node/runtime/index-common.js +0 -10
- package/dist/esm/utils/isNpmPackage.d.ts +0 -17
- package/dist/esm/utils/makePublicCopy.d.ts +0 -3
- package/dist/esm/utils/makePublicCopy.js +0 -30
|
@@ -1,42 +1,59 @@
|
|
|
1
|
-
export { PageContext };
|
|
2
|
-
export { PageContextServer };
|
|
3
|
-
export { PageContextClient };
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
1
|
+
export type { PageContext };
|
|
2
|
+
export type { PageContextServer };
|
|
3
|
+
export type { PageContextClient };
|
|
4
|
+
export type { GlobalContext };
|
|
5
|
+
export type { GlobalContextServer };
|
|
6
|
+
export type { GlobalContextClient };
|
|
7
|
+
export type { PageContextWithServerRouting };
|
|
8
|
+
export type { PageContextClientWithServerRouting };
|
|
9
|
+
export type { GlobalContextClientWithServerRouting };
|
|
10
|
+
export type { PageContextBuiltInServerInternal };
|
|
11
|
+
export type { PageContextBuiltInServer_deprecated as PageContextBuiltInServer };
|
|
12
|
+
export type { PageContextBuiltInClientWithClientRouting_deprecated as PageContextBuiltInClientWithClientRouting };
|
|
13
|
+
export type { PageContextBuiltInClientWithServerRouting_deprecated as PageContextBuiltInClientWithServerRouting };
|
|
10
14
|
import type { PageContextUrlInternal, PageContextUrlClient, PageContextUrlServer } from './getPageContextUrlComputed.js';
|
|
11
15
|
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-configs/getPageConfigUserFriendly.js';
|
|
12
16
|
import type { Config } from './page-configs/Config.js';
|
|
13
17
|
import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
|
|
14
18
|
import type { AbortStatusCode } from './route/abort.js';
|
|
15
|
-
import type {
|
|
16
|
-
type
|
|
19
|
+
import type { GlobalContextServer } from '../node/runtime/globalContext.js';
|
|
20
|
+
import type { GlobalContextClient } from '../client/client-routing-runtime/globalContext.js';
|
|
21
|
+
import type { GlobalContextClientWithServerRouting } from '../client/server-routing-runtime/globalContext.js';
|
|
22
|
+
type PageContextServer<Data = unknown> = PageContextBuiltInServer<Data> & Vike.PageContext & Vike.PageContextServer;
|
|
17
23
|
type PageContext<Data = unknown> = PageContextClient<Data> | PageContextServer<Data>;
|
|
18
|
-
type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> & Vike.PageContext;
|
|
24
|
+
type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> & Vike.PageContext & Vike.PageContextClient;
|
|
25
|
+
type GlobalContext = GlobalContextServer | GlobalContextClient;
|
|
19
26
|
type PageContextWithServerRouting<Data = unknown> = PageContextClientWithServerRouting<Data> | PageContextServer<Data>;
|
|
20
|
-
type PageContextClientWithServerRouting<Data = unknown> = PageContextBuiltInClientWithServerRouting<Data> & Vike.PageContext;
|
|
27
|
+
type PageContextClientWithServerRouting<Data = unknown> = PageContextBuiltInClientWithServerRouting<Data> & Vike.PageContext & Vike.PageContextClient;
|
|
21
28
|
type PageContextBuiltInCommon<Data> = {
|
|
29
|
+
/**
|
|
30
|
+
* Useful for distinguishing `pageContext` from other objects and narrowing down TypeScript unions.
|
|
31
|
+
*
|
|
32
|
+
* https://vike.dev/pageContext#typescript
|
|
33
|
+
*/
|
|
34
|
+
isPageContext: true;
|
|
22
35
|
/** The `export { Page }` of your `.page.js` file.
|
|
23
36
|
*
|
|
24
37
|
* https://vike.dev/Page
|
|
38
|
+
* https://vike.dev/pageContext#Page
|
|
25
39
|
*/
|
|
26
40
|
Page: Config['Page'];
|
|
27
41
|
/** Route Parameters, e.g. `pageContext.routeParams.productId` for a Route String `/product/@productId`.
|
|
28
42
|
*
|
|
29
43
|
* https://vike.dev/route-string
|
|
44
|
+
* https://vike.dev/pageContext#routeParams
|
|
30
45
|
*/
|
|
31
46
|
routeParams: Record<string, string>;
|
|
32
47
|
/** The page's data which was fetched using the data() hook.
|
|
33
48
|
*
|
|
34
49
|
* https://vike.dev/data
|
|
50
|
+
* https://vike.dev/pageContext#data
|
|
35
51
|
*/
|
|
36
52
|
data: Data;
|
|
37
53
|
/** The page's configuration values.
|
|
38
54
|
*
|
|
39
55
|
* https://vike.dev/config
|
|
56
|
+
* https://vike.dev/pageContext#config
|
|
40
57
|
*/
|
|
41
58
|
config: PageContextConfig;
|
|
42
59
|
/** The page's configuration, including the configs origin and overriden configs.
|
|
@@ -65,9 +82,8 @@ type PageContextBuiltInCommon<Data> = {
|
|
|
65
82
|
*
|
|
66
83
|
* As a string object normalized by Vike.
|
|
67
84
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* - `pageContext.headersOriginal`
|
|
85
|
+
* https://vike.dev/headers
|
|
86
|
+
* https://vike.dev/pageContext#headers
|
|
71
87
|
*/
|
|
72
88
|
headers: Record<string, string> | null;
|
|
73
89
|
/**
|
|
@@ -75,9 +91,8 @@ type PageContextBuiltInCommon<Data> = {
|
|
|
75
91
|
*
|
|
76
92
|
* The original object provided by the server.
|
|
77
93
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* - `pageContext.headers`
|
|
94
|
+
* https://vike.dev/headers
|
|
95
|
+
* https://vike.dev/pageContext#headersOriginal
|
|
81
96
|
*/
|
|
82
97
|
headersOriginal?: unknown;
|
|
83
98
|
/** If an error occurs, whether the error is a `404 Page Not Found`.
|
|
@@ -88,25 +103,28 @@ type PageContextBuiltInCommon<Data> = {
|
|
|
88
103
|
/**
|
|
89
104
|
* Whether the page was navigated by the client-side router.
|
|
90
105
|
*
|
|
91
|
-
* https://vike.dev/pageContext
|
|
106
|
+
* https://vike.dev/pageContext#isClientSideNavigation
|
|
92
107
|
*/
|
|
93
108
|
isClientSideNavigation: boolean;
|
|
94
109
|
/**
|
|
95
110
|
* The reason why the original page was aborted. Usually used for showing a custom message on the error page.
|
|
96
111
|
*
|
|
97
112
|
* https://vike.dev/render
|
|
113
|
+
* https://vike.dev/pageContext#abortReason
|
|
98
114
|
*/
|
|
99
115
|
abortReason?: unknown;
|
|
100
116
|
/**
|
|
101
117
|
* The status code set by `throw render(abortStatusCode)`.
|
|
102
118
|
*
|
|
103
119
|
* https://vike.dev/render
|
|
120
|
+
* https://vike.dev/pageContext#abortStatusCode
|
|
104
121
|
*/
|
|
105
122
|
abortStatusCode?: AbortStatusCode;
|
|
106
123
|
/**
|
|
107
124
|
* Error that occured while rendering.
|
|
108
125
|
*
|
|
109
126
|
* https://vike.dev/error-tracking
|
|
127
|
+
* https://vike.dev/pageContext#errorWhileRendering
|
|
110
128
|
*/
|
|
111
129
|
errorWhileRendering?: unknown;
|
|
112
130
|
/**
|
|
@@ -119,12 +137,6 @@ type PageContextBuiltInCommon<Data> = {
|
|
|
119
137
|
source: Source;
|
|
120
138
|
/** @experimental https://github.com/vikejs/vike/issues/1268 */
|
|
121
139
|
sources: Sources;
|
|
122
|
-
/**
|
|
123
|
-
* Runtime information about your app.
|
|
124
|
-
*
|
|
125
|
-
* https://vike.dev/getGlobalContext
|
|
126
|
-
*/
|
|
127
|
-
globalContext: GlobalContextPublic;
|
|
128
140
|
/** @deprecated */
|
|
129
141
|
url: string;
|
|
130
142
|
/** @deprecated */
|
|
@@ -133,14 +145,17 @@ type PageContextBuiltInCommon<Data> = {
|
|
|
133
145
|
* Whether the Base URL is missing in the URL of the HTTP request made to the SSR server.
|
|
134
146
|
*
|
|
135
147
|
* https://vike.dev/base-url#setup
|
|
148
|
+
* https://vike.dev/pageContext#isBaseMissing
|
|
136
149
|
*/
|
|
137
150
|
isBaseMissing?: true;
|
|
138
151
|
};
|
|
139
152
|
type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageContextUrlServer & {
|
|
140
153
|
/**
|
|
141
|
-
* Whether the page is being rendered on the client-side
|
|
154
|
+
* Whether the page is being rendered on the client-side or server-side / pre-rendered.
|
|
155
|
+
*
|
|
156
|
+
* We recommend using `import.meta.env.SSR` instead, see https://vike.dev/pageContext#isClientSide
|
|
142
157
|
*
|
|
143
|
-
*
|
|
158
|
+
* https://vike.dev/pageContext#isClientSide
|
|
144
159
|
*/
|
|
145
160
|
isClientSide: false;
|
|
146
161
|
/**
|
|
@@ -149,9 +164,16 @@ type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageConte
|
|
|
149
164
|
* The value is always `false` in development.
|
|
150
165
|
*
|
|
151
166
|
* https://vike.dev/pre-rendering
|
|
152
|
-
* https://vike.dev/pageContext
|
|
167
|
+
* https://vike.dev/pageContext#isPrerendering
|
|
153
168
|
*/
|
|
154
169
|
isPrerendering: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Runtime information about your app.
|
|
172
|
+
*
|
|
173
|
+
* https://vike.dev/getGlobalContext
|
|
174
|
+
* https://vike.dev/pageContext#globalContext
|
|
175
|
+
*/
|
|
176
|
+
globalContext: GlobalContextServer;
|
|
155
177
|
isHydration?: undefined;
|
|
156
178
|
isBackwardNavigation?: undefined;
|
|
157
179
|
previousPageContext?: undefined;
|
|
@@ -163,34 +185,44 @@ type PageContextBuiltInClientWithClientRouting<Data> = Partial<PageContextBuiltI
|
|
|
163
185
|
* Whether the user is navigating back in history.
|
|
164
186
|
*
|
|
165
187
|
* The value is `true` when the user clicks on his browser's backward navigation button, or when invoking `history.back()`.
|
|
188
|
+
*
|
|
189
|
+
* https://vike.dev/pageContext#isBackwardNavigation
|
|
166
190
|
*/
|
|
167
191
|
isBackwardNavigation: boolean | null;
|
|
168
192
|
/**
|
|
169
193
|
* Upon client-side page navigation, you can use `pageContext.previousPageContext` to access the `pageContext` of the previous page.
|
|
170
194
|
*
|
|
171
|
-
* https://vike.dev/pageContext
|
|
195
|
+
* https://vike.dev/pageContext#previousPageContext
|
|
172
196
|
*/
|
|
173
197
|
previousPageContext: PageContextClient<Data> | null;
|
|
198
|
+
globalContext: GlobalContextClient;
|
|
174
199
|
} & PageContextUrlClient;
|
|
175
200
|
type PageContextBuiltInClientWithServerRouting<Data> = Partial<PageContextBuiltInCommon<Data>> & Pick<PageContextBuiltInCommon<Data>, 'Page' | 'pageExports' | 'exports' | 'abortReason' | 'pageId' | 'data'> & PageContextClientCommon & {
|
|
176
201
|
/**
|
|
177
202
|
* Whether the current page is already rendered to HTML.
|
|
178
203
|
*
|
|
179
204
|
* The `isHydration` value is always `true` when using Server Routing.
|
|
205
|
+
*
|
|
206
|
+
* https://vike.dev/pageContext#isHydration
|
|
180
207
|
*/
|
|
181
208
|
isHydration: true;
|
|
182
209
|
/**
|
|
183
210
|
* Whether the user is navigating back in history.
|
|
184
211
|
*
|
|
185
212
|
* The `isBackwardNavigation` property only works with Client Routing. (The value is always `null` when using Server Routing.)
|
|
213
|
+
*
|
|
214
|
+
* https://vike.dev/pageContext#isBackwardNavigation
|
|
186
215
|
*/
|
|
187
216
|
isBackwardNavigation: null;
|
|
217
|
+
globalContext: GlobalContextClientWithServerRouting;
|
|
188
218
|
};
|
|
189
219
|
type PageContextClientCommon = {
|
|
190
220
|
/**
|
|
191
221
|
* Whether the page is being rendered on the client-side, or rendered on the server-side / pre-rendered.
|
|
192
222
|
*
|
|
193
|
-
* In order to save client-side KBs, we recommend using `import.meta.env.SSR` whenever possible instead, see https://vike.dev/pageContext
|
|
223
|
+
* In order to save client-side KBs, we recommend using `import.meta.env.SSR` whenever possible instead, see https://vike.dev/pageContext#isClientSide
|
|
224
|
+
*
|
|
225
|
+
* https://vike.dev/pageContext#isClientSide
|
|
194
226
|
*/
|
|
195
227
|
isClientSide: true;
|
|
196
228
|
/**
|
|
@@ -199,7 +231,7 @@ type PageContextClientCommon = {
|
|
|
199
231
|
* The value is always `false` in development.
|
|
200
232
|
*
|
|
201
233
|
* https://vike.dev/pre-rendering
|
|
202
|
-
* https://vike.dev/pageContext
|
|
234
|
+
* https://vike.dev/pageContext#isPrerendering
|
|
203
235
|
*/
|
|
204
236
|
isPrerendering: false;
|
|
205
237
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export type { PageContext } from '../shared/types.js';
|
|
2
|
-
export type { PageContextServer } from '../shared/types.js';
|
|
3
|
-
export type { PageContextClient } from '../shared/types.js';
|
|
4
|
-
export type { PageContextWithServerRouting } from '../shared/types.js';
|
|
5
|
-
export type { PageContextClientWithServerRouting } from '../shared/types.js';
|
|
1
|
+
export type { PageContext, PageContextServer, PageContextClient, GlobalContext, GlobalContextServer, GlobalContextClient, PageContextWithServerRouting, PageContextClientWithServerRouting, GlobalContextClientWithServerRouting } from '../shared/types.js';
|
|
6
2
|
export type { PageContextBuiltInServer } from '../shared/types.js';
|
|
7
3
|
export type { PageContextBuiltInClientWithClientRouting } from '../shared/types.js';
|
|
8
4
|
export type { PageContextBuiltInClientWithServerRouting } from '../shared/types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.229-commit-a19745d";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.229-commit-a19745d';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { catchInfiniteLoop };
|
|
2
|
-
import {
|
|
2
|
+
import { assertUsage, assertWarning } from './assert.js';
|
|
3
3
|
const trackers = {};
|
|
4
4
|
function catchInfiniteLoop(functionName, maxNumberOfCalls = 100, withinSeconds = 5) {
|
|
5
5
|
// Init
|
|
@@ -12,14 +12,14 @@ function catchInfiniteLoop(functionName, maxNumberOfCalls = 100, withinSeconds =
|
|
|
12
12
|
// Count
|
|
13
13
|
tracker.count++;
|
|
14
14
|
// Error
|
|
15
|
-
const msg = `[Infinite Loop]
|
|
15
|
+
const msg = `[Infinite Loop] Rendering ${tracker.count} times within ${withinSeconds} seconds [${functionName}]`;
|
|
16
16
|
if (tracker.count > maxNumberOfCalls) {
|
|
17
|
-
|
|
17
|
+
assertUsage(false, msg);
|
|
18
18
|
}
|
|
19
19
|
// Warning, at 50% threshold
|
|
20
20
|
if (!tracker.warned && tracker.count > maxNumberOfCalls * 0.5) {
|
|
21
21
|
// Warning is shown upon 10 calls a second, on average during 5 seconds, given the default parameters
|
|
22
|
-
assertWarning(false, msg, { onlyOnce: false });
|
|
22
|
+
assertWarning(false, msg, { onlyOnce: false, showStackTrace: true });
|
|
23
23
|
tracker.warned = true;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugActivated };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
declare const flags: readonly ["vike:crawl", "vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
4
|
+
declare const flags: readonly ["vike:crawl", "vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:resolve", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
5
5
|
type Flag = (typeof flags)[number];
|
|
6
6
|
type Debug = ReturnType<typeof createDebugger>;
|
|
7
7
|
type Options = {
|
package/dist/esm/utils/debug.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getGlobalObject };
|
|
2
2
|
export { assertIsSingleModuleInstance };
|
|
3
|
-
type Key = `${string}
|
|
3
|
+
type Key = `${string}.ts`;
|
|
4
4
|
/** Share information across module instances. */
|
|
5
5
|
declare function getGlobalObject<T extends Record<string, unknown> = never>(key: Key, defaultValue: T): T;
|
|
6
6
|
/** Assert that the module is instantiated only once. */
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { getPublicProxy };
|
|
2
|
+
// We use a proxy instead of property getters.
|
|
3
|
+
// - The issue with property getters is that they can't be `writable: true` but we do want the user to be able to modify the value of internal properties.
|
|
4
|
+
// ```console
|
|
5
|
+
// TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>
|
|
6
|
+
// ```
|
|
7
|
+
// - Previous implementation using property getters: https://github.com/vikejs/vike/blob/main/vike/utils/makePublicCopy.ts
|
|
8
|
+
import { assert, assertWarning } from './assert.js';
|
|
9
|
+
// Show warning when user is accessing internal `_` properties.
|
|
10
|
+
function getPublicProxy(obj, objName, propsPublic, expectCustomUserLandProps) {
|
|
11
|
+
if (!expectCustomUserLandProps) {
|
|
12
|
+
Object.keys(obj).forEach((key) => assert(key.startsWith('_') || propsPublic.includes(key)));
|
|
13
|
+
propsPublic.forEach((prop) => prop in obj);
|
|
14
|
+
}
|
|
15
|
+
return new Proxy(obj, {
|
|
16
|
+
get(_, prop) {
|
|
17
|
+
const propStr = String(prop);
|
|
18
|
+
if (propStr.startsWith('_')) {
|
|
19
|
+
assertWarning(false, `Using internal ${objName}.${propStr} which may break in any minor version update. Reach out on GitHub and elaborate your use case so that the Vike team can add official support for your use case.`, { onlyOnce: true });
|
|
20
|
+
}
|
|
21
|
+
// @ts-ignore Seems to be TypeScript bug
|
|
22
|
+
return Reflect.get(...arguments);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { isImportPath };
|
|
2
|
+
export { isImportPathRelative };
|
|
3
|
+
import { assertPosixPath } from './path.js';
|
|
4
|
+
import { assert } from './assert.js';
|
|
5
|
+
import { isImportPathNpmPackageOrPathAlias } from './parseNpmPackage.js';
|
|
6
|
+
function isImportPath(importPath) {
|
|
7
|
+
return isImportPathRelative(importPath) || isImportPathNpmPackageOrPathAlias(importPath);
|
|
8
|
+
}
|
|
9
|
+
// See also `import { pathIsRelative } from './path'`
|
|
10
|
+
function isImportPathRelative(importPath) {
|
|
11
|
+
assertPosixPath(importPath);
|
|
12
|
+
if (importPath.startsWith('./') || importPath.startsWith('../')) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
assert(!importPath.startsWith('.'));
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { isScriptFile };
|
|
2
|
-
export {
|
|
2
|
+
export { isPlainScriptFile };
|
|
3
3
|
export { isTemplateFile };
|
|
4
|
-
export {
|
|
4
|
+
export { scriptFileExtensionPattern };
|
|
5
5
|
export { scriptFileExtensionList };
|
|
6
|
-
declare const scriptFileExtensionList: readonly [
|
|
7
|
-
declare const
|
|
6
|
+
declare const scriptFileExtensionList: readonly ["js", "cjs", "mjs", "ts", "cts", "mts", "jsx", "cjsx", "mjsx", "tsx", "ctsx", "mtsx", "vue", "svelte", "marko", "md", "mdx"];
|
|
7
|
+
declare const scriptFileExtensionPattern: string;
|
|
8
8
|
declare function isScriptFile(filePath: string): boolean;
|
|
9
|
-
declare function
|
|
9
|
+
declare function isPlainScriptFile(filePath: string): boolean;
|
|
10
10
|
declare function isTemplateFile(filePath: string): boolean;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { isScriptFile };
|
|
2
|
-
export {
|
|
2
|
+
export { isPlainScriptFile };
|
|
3
3
|
export { isTemplateFile };
|
|
4
|
-
export {
|
|
4
|
+
export { scriptFileExtensionPattern };
|
|
5
5
|
export { scriptFileExtensionList };
|
|
6
|
-
import { assert } from './assert.js';
|
|
7
6
|
// We can't use a RegExp:
|
|
8
7
|
// - Needs to work with Micromatch: https://github.com/micromatch/micromatch because:
|
|
9
8
|
// - Vite's `import.meta.glob()` uses Micromatch
|
|
@@ -15,26 +14,36 @@ import { assert } from './assert.js';
|
|
|
15
14
|
// - 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
15
|
// prettier-ignore
|
|
17
16
|
// biome-ignore format:
|
|
18
|
-
const
|
|
17
|
+
const extJs = [
|
|
19
18
|
'js',
|
|
20
|
-
'ts',
|
|
21
19
|
'cjs',
|
|
22
|
-
'cts',
|
|
23
20
|
'mjs',
|
|
21
|
+
];
|
|
22
|
+
// prettier-ignore
|
|
23
|
+
// biome-ignore format:
|
|
24
|
+
const extTs = [
|
|
25
|
+
'ts',
|
|
26
|
+
'cts',
|
|
24
27
|
'mts',
|
|
25
28
|
];
|
|
29
|
+
const extJsOrTs = [...extJs, ...extTs];
|
|
26
30
|
// prettier-ignore
|
|
27
31
|
// biome-ignore format:
|
|
28
32
|
const extJsx = [
|
|
29
33
|
'jsx',
|
|
30
|
-
'tsx',
|
|
31
34
|
'cjsx',
|
|
32
|
-
'ctsx',
|
|
33
35
|
'mjsx',
|
|
34
|
-
'mtsx',
|
|
35
36
|
];
|
|
36
37
|
// prettier-ignore
|
|
37
38
|
// biome-ignore format:
|
|
39
|
+
const extTsx = [
|
|
40
|
+
'tsx',
|
|
41
|
+
'ctsx',
|
|
42
|
+
'mtsx'
|
|
43
|
+
];
|
|
44
|
+
const extJsxOrTsx = [...extJsx, ...extTsx];
|
|
45
|
+
// prettier-ignore
|
|
46
|
+
// biome-ignore format:
|
|
38
47
|
const extTemplates = [
|
|
39
48
|
'vue',
|
|
40
49
|
'svelte',
|
|
@@ -42,19 +51,13 @@ const extTemplates = [
|
|
|
42
51
|
'md',
|
|
43
52
|
'mdx'
|
|
44
53
|
];
|
|
45
|
-
const scriptFileExtensionList = [...
|
|
46
|
-
const
|
|
54
|
+
const scriptFileExtensionList = [...extJsOrTs, ...extJsxOrTsx, ...extTemplates];
|
|
55
|
+
const scriptFileExtensionPattern = '(' + scriptFileExtensionList.join('|') + ')';
|
|
47
56
|
function isScriptFile(filePath) {
|
|
48
|
-
|
|
49
|
-
if (isPlainJavaScriptFile(filePath))
|
|
50
|
-
assert(yes);
|
|
51
|
-
return yes;
|
|
57
|
+
return scriptFileExtensionList.some((ext) => filePath.endsWith('.' + ext));
|
|
52
58
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
const yes2 = extJavaScript.some((ext) => filePath.endsWith('.' + ext));
|
|
56
|
-
assert(yes1 === yes2);
|
|
57
|
-
return yes1;
|
|
59
|
+
function isPlainScriptFile(filePath) {
|
|
60
|
+
return extJsOrTs.some((ext) => filePath.endsWith('.' + ext));
|
|
58
61
|
}
|
|
59
62
|
function isTemplateFile(filePath) {
|
|
60
63
|
return extTemplates.some((ext) => filePath.endsWith('.' + ext));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { objectAssign };
|
|
2
|
-
declare function objectAssign<Obj extends object, ObjAddendum extends object | null>(obj: Obj, objAddendum: ObjAddendum, objAddendumCanBePageContextObject?: true): asserts obj is Obj & ObjAddendum;
|
|
2
|
+
declare function objectAssign<Obj extends object, ObjAddendum extends object | null | undefined>(obj: Obj, objAddendum: ObjAddendum, objAddendumCanBePageContextObject?: true): asserts obj is Obj & ObjAddendum;
|
|
@@ -2,15 +2,11 @@ export { objectAssign };
|
|
|
2
2
|
import { assert } from './assert.js';
|
|
3
3
|
// Same as Object.assign() but:
|
|
4
4
|
// - With type inference
|
|
5
|
-
// - Preserves property descriptors, which we need for preserving the getters
|
|
5
|
+
// - Preserves property descriptors, which we need for preserving the getters of getPageContextUrlComputed()
|
|
6
6
|
function objectAssign(obj, objAddendum, objAddendumCanBePageContextObject) {
|
|
7
|
-
if (objAddendum)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
assert(!('_isPageContextObject' in objAddendum));
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
15
|
-
}
|
|
7
|
+
if (!objAddendum)
|
|
8
|
+
return;
|
|
9
|
+
if (!objAddendumCanBePageContextObject)
|
|
10
|
+
assert(!('isPageContext' in objAddendum));
|
|
11
|
+
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
16
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function objectReplace(
|
|
1
|
+
export declare function objectReplace<T extends object>(objOld: T, objNew: T, except?: string[]): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function objectReplace(
|
|
2
|
-
Object.keys(
|
|
1
|
+
export function objectReplace(objOld, objNew, except) {
|
|
2
|
+
Object.keys(objOld)
|
|
3
3
|
.filter((key) => !except?.includes(key))
|
|
4
|
-
.forEach((key) => delete
|
|
5
|
-
Object.
|
|
4
|
+
.forEach((key) => delete objOld[key]);
|
|
5
|
+
Object.defineProperties(objOld, Object.getOwnPropertyDescriptors(objNew));
|
|
6
6
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { isImportPathNpmPackage };
|
|
2
|
+
export { isImportPathNpmPackageOrPathAlias };
|
|
3
|
+
export { assertIsImportPathNpmPackage };
|
|
4
|
+
export { isPathAliasRecommended };
|
|
5
|
+
export { getNpmPackageName };
|
|
6
|
+
export { parseNpmPackage };
|
|
7
|
+
export { isDistinguishable };
|
|
8
|
+
declare function isImportPathNpmPackage(str: string, { cannotBePathAlias }: {
|
|
9
|
+
cannotBePathAlias: true;
|
|
10
|
+
}): boolean;
|
|
11
|
+
declare function isImportPathNpmPackageOrPathAlias(str: string): boolean;
|
|
12
|
+
declare function assertIsImportPathNpmPackage(str: string): void;
|
|
13
|
+
declare function getNpmPackageName(str: string): null | string;
|
|
14
|
+
declare function isPathAliasRecommended(alias: string): boolean;
|
|
15
|
+
declare function isDistinguishable(alias: string): boolean;
|
|
16
|
+
declare function parseNpmPackage(str: string | undefined): null | {
|
|
17
|
+
pkgName: string;
|
|
18
|
+
importPath: null | string;
|
|
19
|
+
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
export { isImportPathNpmPackage };
|
|
2
|
+
export { isImportPathNpmPackageOrPathAlias };
|
|
3
|
+
export { assertIsImportPathNpmPackage };
|
|
4
|
+
export { isPathAliasRecommended };
|
|
5
|
+
export { getNpmPackageName };
|
|
5
6
|
/* Currently not used
|
|
6
7
|
export { isNpmPackageName }
|
|
7
|
-
export { getNpmPackageName }
|
|
8
8
|
export { getNpmPackageImportPath }
|
|
9
9
|
*/
|
|
10
10
|
// For ./isNpmPackage.spec.ts
|
|
11
|
-
export {
|
|
11
|
+
export { parseNpmPackage };
|
|
12
12
|
export { isDistinguishable };
|
|
13
13
|
import { assert } from './assert.js';
|
|
14
14
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
15
15
|
assertIsNotBrowser();
|
|
16
|
-
function
|
|
16
|
+
function isImportPathNpmPackage(str, { cannotBePathAlias }) {
|
|
17
17
|
assert(cannotBePathAlias);
|
|
18
|
-
return
|
|
18
|
+
return isImportPathNpmPackageOrPathAlias(str);
|
|
19
19
|
}
|
|
20
20
|
// We cannot distinguish path aliases that look like npm package imports
|
|
21
|
-
function
|
|
22
|
-
const res =
|
|
21
|
+
function isImportPathNpmPackageOrPathAlias(str) {
|
|
22
|
+
const res = parseNpmPackage(str);
|
|
23
23
|
return res !== null;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
assert(
|
|
27
|
-
// If `str` is a path alias that looks like an npm package =>
|
|
25
|
+
function assertIsImportPathNpmPackage(str) {
|
|
26
|
+
assert(isImportPathNpmPackage(str, {
|
|
27
|
+
// If `str` is a path alias that looks like an npm package => assertIsImportPathNpmPackage() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
|
|
28
28
|
cannotBePathAlias: true
|
|
29
29
|
}), str);
|
|
30
30
|
}
|
|
31
31
|
function isNpmPackageName(str) {
|
|
32
|
-
const res =
|
|
32
|
+
const res = parseNpmPackage(str);
|
|
33
33
|
return res !== null && res.importPath === null;
|
|
34
34
|
}
|
|
35
35
|
function getNpmPackageName(str) {
|
|
36
|
-
const res =
|
|
36
|
+
const res = parseNpmPackage(str);
|
|
37
37
|
if (!res)
|
|
38
38
|
return null;
|
|
39
39
|
return res.pkgName;
|
|
40
40
|
}
|
|
41
41
|
function getNpmPackageImportPath(str) {
|
|
42
|
-
const res =
|
|
42
|
+
const res = parseNpmPackage(str);
|
|
43
43
|
if (!res)
|
|
44
44
|
return null;
|
|
45
45
|
return res.importPath;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function isPathAliasRecommended(alias) {
|
|
48
48
|
// Cannot be distinguished from npm package names
|
|
49
49
|
if (!isDistinguishable(alias))
|
|
50
50
|
return false;
|
|
@@ -60,14 +60,14 @@ function isValidPathAlias(alias) {
|
|
|
60
60
|
return true;
|
|
61
61
|
}
|
|
62
62
|
function isDistinguishable(alias) {
|
|
63
|
-
return (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
return (parseNpmPackage(alias) === null &&
|
|
64
|
+
parseNpmPackage(`${alias}fake-path`) === null &&
|
|
65
|
+
parseNpmPackage(`${alias}/fake-path`) === null &&
|
|
66
|
+
parseNpmPackage(`${alias}fake/deep/path`) === null &&
|
|
67
|
+
parseNpmPackage(`${alias}/fake/deep/path`) === null &&
|
|
68
68
|
// See note about '-' in ./isNpmPackageName.spec.ts
|
|
69
69
|
// ```ts
|
|
70
|
-
// expect(
|
|
70
|
+
// expect(parseNpmPackage('-')).toBe(null) // actually wrong: https://www.npmjs.com/package/-
|
|
71
71
|
// ```
|
|
72
72
|
!alias.startsWith('-'));
|
|
73
73
|
}
|
|
@@ -75,7 +75,7 @@ function isDistinguishable(alias) {
|
|
|
75
75
|
// - https://www.npmjs.com/package/-
|
|
76
76
|
// The correct logic is complex, see https://github.com/npm/validate-npm-package-name
|
|
77
77
|
// We don't need to be accurate: are there npm packages with weird names that are actually being used?
|
|
78
|
-
function
|
|
78
|
+
function parseNpmPackage(str) {
|
|
79
79
|
if (!str)
|
|
80
80
|
return null;
|
|
81
81
|
let scope = null;
|
package/dist/esm/utils/path.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ declare function pathJoin(path1: string, path2: string): string;
|
|
|
11
11
|
/**********************/
|
|
12
12
|
declare function toPosixPath(path: string): string;
|
|
13
13
|
declare function assertPosixPath(path: string): void;
|
|
14
|
-
declare function pathIsRelative(
|
|
14
|
+
declare function pathIsRelative(path: string): boolean;
|