vike 0.4.229 → 0.4.230-commit-dd11364
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/client/server-routing-runtime/utils.js +1 -0
- package/dist/cjs/client/shared/{preparePageContextForUserConsumptionClientSide.js → preparePageContextForPublicUsageClientShared.js} +14 -19
- package/dist/cjs/node/api/build.js +2 -5
- package/dist/cjs/node/plugin/index.js +3 -1
- package/dist/cjs/node/plugin/onLoad.js +2 -0
- package/dist/cjs/node/plugin/plugins/build/pluginDistFileNames.js +1 -0
- package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +4 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -0
- 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/assertExtensions.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -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/getPlusFilesAll.js +6 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +12 -8
- 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/loggerNotProd.js +2 -2
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +42 -38
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +13 -27
- package/dist/cjs/node/runtime/html/renderHtml.js +12 -2
- package/dist/cjs/node/runtime/html/serializeContext.js +4 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +7 -5
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +3 -4
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +6 -9
- package/dist/cjs/node/runtime/renderPage/execHookServer.js +11 -0
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +14 -15
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -12
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +1 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/cjs/node/runtime/renderPage/{loadUserFilesServerSide.js → loadPageConfigsLazyServerSide.js} +4 -4
- package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +10 -0
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -5
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -2
- package/dist/cjs/node/runtime/renderPage.js +21 -12
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -1
- package/dist/cjs/shared/addIs404ToPageProps.js +0 -7
- package/dist/cjs/shared/createGlobalContextShared.js +37 -8
- package/dist/cjs/shared/createPageContextShared.js +14 -11
- package/dist/cjs/shared/getPageContext.js +3 -3
- package/dist/cjs/shared/getPageContextUrlComputed.js +2 -36
- package/dist/cjs/shared/getProxyForPublicUsage.js +56 -0
- package/dist/cjs/shared/hooks/execHook.js +170 -0
- package/dist/cjs/shared/hooks/getHook.js +23 -4
- package/dist/cjs/shared/page-configs/{getPageConfigUserFriendly.js → getUserFriendlyConfigs.js} +54 -47
- package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +10 -0
- package/dist/cjs/shared/preparePageContextForPublicUsage.js +80 -0
- package/dist/cjs/shared/route/abort.js +2 -2
- package/dist/cjs/shared/route/debug.js +17 -7
- package/dist/cjs/shared/route/executeGuardHook.js +4 -9
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +4 -3
- package/dist/cjs/shared/route/index.js +2 -4
- package/dist/cjs/shared/route/loadPageRoutes.js +6 -0
- package/dist/cjs/shared/route/resolveRouteFunction.js +14 -10
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/debug.js +15 -6
- package/dist/cjs/utils/isDev.js +3 -1
- package/dist/cjs/utils/isScriptFile.js +24 -21
- package/dist/cjs/utils/objectAssign.js +3 -3
- package/dist/cjs/utils/objectDefineProperty.js +1 -1
- package/dist/cjs/utils/parseNpmPackage.js +1 -0
- package/dist/cjs/utils/parseUrl-extras.js +0 -1
- package/dist/cjs/utils/requireResolve.js +39 -19
- package/dist/esm/client/client-routing-runtime/{createPageContext.d.ts → createPageContextClientSide.d.ts} +21 -13
- package/dist/esm/client/client-routing-runtime/{createPageContext.js → createPageContextClientSide.js} +9 -11
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +400 -15
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +56 -54
- package/dist/esm/client/client-routing-runtime/globalContext.d.ts +11 -1
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +3 -8
- package/dist/esm/client/client-routing-runtime/prefetch.js +3 -3
- package/dist/esm/client/client-routing-runtime/preparePageContextForPublicUsageClient.d.ts +11 -0
- package/dist/esm/client/client-routing-runtime/preparePageContextForPublicUsageClient.js +5 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +135 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +72 -81
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/utils.js +1 -0
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.d.ts +19 -13
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +15 -26
- package/dist/esm/client/server-routing-runtime/entry.js +4 -4
- package/dist/esm/client/server-routing-runtime/globalContext.d.ts +11 -1
- package/dist/esm/client/server-routing-runtime/preparePageContextForPublicUsageClient.d.ts +9 -0
- package/dist/esm/client/server-routing-runtime/preparePageContextForPublicUsageClient.js +5 -0
- package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/utils.js +1 -0
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +11 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +3 -3
- package/dist/esm/client/shared/executeOnRenderClientHook.js +4 -13
- package/dist/esm/client/shared/{loadUserFilesClientSide.d.ts → loadPageConfigsLazyClientSide.d.ts} +2 -2
- package/dist/esm/client/shared/{loadUserFilesClientSide.js → loadPageConfigsLazyClientSide.js} +4 -4
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +11 -0
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.js +39 -0
- package/dist/esm/node/api/build.js +2 -2
- package/dist/esm/node/plugin/index.js +3 -1
- package/dist/esm/node/plugin/onLoad.js +2 -0
- package/dist/esm/node/plugin/plugins/build/pluginDistFileNames.js +1 -0
- package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +4 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +6 -1
- 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/assertExtensions.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +5 -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/getPlusFilesAll.js +7 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +12 -8
- 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/loggerNotProd.js +1 -1
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.d.ts +1 -1
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +37 -73
- package/dist/esm/node/prerender/runPrerender.js +42 -38
- 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 +46 -251
- package/dist/esm/node/runtime/globalContext.js +14 -28
- package/dist/esm/node/runtime/html/renderHtml.js +12 -2
- package/dist/esm/node/runtime/html/serializeContext.d.ts +1 -1
- package/dist/esm/node/runtime/html/serializeContext.js +4 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +7 -5
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +3 -4
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +26 -41
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +7 -10
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +12 -0
- package/dist/esm/node/runtime/renderPage/execHookServer.js +9 -0
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -3
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +14 -15
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -12
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/esm/node/runtime/renderPage/{loadUserFilesServerSide.d.ts → loadPageConfigsLazyServerSide.d.ts} +6 -6
- package/dist/esm/node/runtime/renderPage/{loadUserFilesServerSide.js → loadPageConfigsLazyServerSide.js} +4 -4
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +20 -0
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +8 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +38 -74
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -5
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +0 -2
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +0 -1
- package/dist/esm/node/runtime/renderPage.d.ts +21 -39
- package/dist/esm/node/runtime/renderPage.js +22 -13
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/shared/NOT_SERIALIZABLE.js +0 -1
- package/dist/esm/shared/addIs404ToPageProps.d.ts +1 -6
- package/dist/esm/shared/addIs404ToPageProps.js +1 -8
- package/dist/esm/shared/createGlobalContextShared.d.ts +28 -6
- package/dist/esm/shared/createGlobalContextShared.js +37 -8
- package/dist/esm/shared/createPageContextShared.d.ts +7 -6
- package/dist/esm/shared/createPageContextShared.js +15 -12
- package/dist/esm/shared/getPageContext.d.ts +1 -1
- package/dist/esm/shared/getPageContext.js +1 -1
- package/dist/esm/shared/getPageContextUrlComputed.d.ts +2 -5
- package/dist/esm/shared/getPageContextUrlComputed.js +3 -37
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/getProxyForPublicUsage.d.ts +4 -0
- package/dist/esm/shared/getProxyForPublicUsage.js +54 -0
- package/dist/esm/shared/hooks/execHook.d.ts +63 -0
- package/dist/esm/shared/hooks/execHook.js +168 -0
- package/dist/esm/shared/hooks/getHook.d.ts +10 -11
- package/dist/esm/shared/hooks/getHook.js +23 -4
- package/dist/esm/shared/page-configs/Config.d.ts +11 -4
- package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.d.ts → getUserFriendlyConfigs.d.ts} +8 -6
- package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.js → getUserFriendlyConfigs.js} +55 -48
- package/dist/esm/shared/prepareGlobalContextForPublicUsage.d.ts +7 -0
- package/dist/esm/shared/prepareGlobalContextForPublicUsage.js +8 -0
- package/dist/esm/shared/preparePageContextForPublicUsage.d.ts +11 -0
- package/dist/esm/shared/preparePageContextForPublicUsage.js +78 -0
- package/dist/esm/shared/route/abort.js +1 -1
- package/dist/esm/shared/route/debug.d.ts +4 -1
- package/dist/esm/shared/route/debug.js +17 -7
- package/dist/esm/shared/route/executeGuardHook.d.ts +4 -3
- package/dist/esm/shared/route/executeGuardHook.js +4 -9
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +4 -3
- package/dist/esm/shared/route/index.js +2 -4
- package/dist/esm/shared/route/loadPageRoutes.d.ts +2 -1
- package/dist/esm/shared/route/loadPageRoutes.js +7 -1
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +14 -10
- package/dist/esm/shared/types.d.ts +14 -4
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +15 -6
- package/dist/esm/utils/isDev.js +3 -1
- 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 +3 -3
- package/dist/esm/utils/objectDefineProperty.d.ts +0 -1
- package/dist/esm/utils/objectDefineProperty.js +1 -1
- package/dist/esm/utils/parseNpmPackage.d.ts +2 -0
- package/dist/esm/utils/parseNpmPackage.js +1 -1
- package/dist/esm/utils/parseUrl-extras.js +0 -1
- package/dist/esm/utils/requireResolve.js +39 -19
- package/package.json +2 -2
- package/dist/cjs/client/shared/getPageContextProxyForUser.js +0 -16
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +0 -16
- package/dist/cjs/shared/getPageConfigsRuntime.js +0 -23
- package/dist/cjs/shared/hooks/executeHook.js +0 -87
- package/dist/cjs/shared/hooks/executeHookGeneric.js +0 -18
- package/dist/cjs/shared/preparePageContextForUserConsumption.js +0 -34
- package/dist/cjs/utils/getPublicProxy.js +0 -27
- package/dist/esm/client/shared/getPageContextProxyForUser.d.ts +0 -2
- package/dist/esm/client/shared/getPageContextProxyForUser.js +0 -14
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +0 -12
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.js +0 -44
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +0 -24
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +0 -14
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +0 -14
- package/dist/esm/shared/getPageConfigsRuntime.js +0 -21
- package/dist/esm/shared/hooks/executeHook.d.ts +0 -21
- package/dist/esm/shared/hooks/executeHook.js +0 -85
- package/dist/esm/shared/hooks/executeHookGeneric.d.ts +0 -8
- package/dist/esm/shared/hooks/executeHookGeneric.js +0 -16
- package/dist/esm/shared/preparePageContextForUserConsumption.d.ts +0 -5
- package/dist/esm/shared/preparePageContextForUserConsumption.js +0 -32
- package/dist/esm/utils/getPublicProxy.d.ts +0 -2
- package/dist/esm/utils/getPublicProxy.js +0 -25
|
@@ -7,12 +7,15 @@ export type { GlobalContextClient };
|
|
|
7
7
|
export type { PageContextWithServerRouting };
|
|
8
8
|
export type { PageContextClientWithServerRouting };
|
|
9
9
|
export type { GlobalContextClientWithServerRouting };
|
|
10
|
-
export type {
|
|
10
|
+
export type { PageContextInternalServer };
|
|
11
|
+
export type { PageContextInternalClient };
|
|
12
|
+
export type { PageContextInternalClient_ServerRouting };
|
|
13
|
+
export type { PageContextInternalClient_ClientRouting };
|
|
11
14
|
export type { PageContextBuiltInServer_deprecated as PageContextBuiltInServer };
|
|
12
15
|
export type { PageContextBuiltInClientWithClientRouting_deprecated as PageContextBuiltInClientWithClientRouting };
|
|
13
16
|
export type { PageContextBuiltInClientWithServerRouting_deprecated as PageContextBuiltInClientWithServerRouting };
|
|
14
17
|
import type { PageContextUrlInternal, PageContextUrlClient, PageContextUrlServer } from './getPageContextUrlComputed.js';
|
|
15
|
-
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-configs/
|
|
18
|
+
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-configs/getUserFriendlyConfigs.js';
|
|
16
19
|
import type { Config } from './page-configs/Config.js';
|
|
17
20
|
import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
|
|
18
21
|
import type { AbortStatusCode } from './route/abort.js';
|
|
@@ -235,8 +238,15 @@ type PageContextClientCommon = {
|
|
|
235
238
|
*/
|
|
236
239
|
isPrerendering: false;
|
|
237
240
|
};
|
|
238
|
-
|
|
239
|
-
type
|
|
241
|
+
type PageContextInternalServer = Omit<PageContextBuiltInCommon<unknown> & PageContextUrlInternal, 'data' | 'globalContext'>;
|
|
242
|
+
type OnlyUsers = 'data' | 'Page' | 'globalContext';
|
|
243
|
+
type PageContextInternalClient = Omit<PageContextInternalClient_ClientRouting | PageContextInternalClient_ServerRouting, OnlyUsers>;
|
|
244
|
+
type PageContextInternalClient_ClientRouting = Omit<PageContextBuiltInClientWithClientRouting<unknown>, OnlyUsers | 'previousPageContext'> & {
|
|
245
|
+
previousPageContext: {
|
|
246
|
+
pageId: string;
|
|
247
|
+
} | null;
|
|
248
|
+
};
|
|
249
|
+
type PageContextInternalClient_ServerRouting = Omit<PageContextBuiltInClientWithServerRouting<unknown>, OnlyUsers>;
|
|
240
250
|
/** @deprecated
|
|
241
251
|
* Replace:
|
|
242
252
|
* ```
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ export type { Config, ConfigMeta as Meta, ImportString, DataAsync, DataSync, Gua
|
|
|
6
6
|
export type { ConfigResolved } from '../shared/page-configs/Config/PageContextConfig.js';
|
|
7
7
|
export type { ConfigEnv } from '../shared/page-configs/PageConfig.js';
|
|
8
8
|
export type { ConfigDefinition, ConfigEffect } from '../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
9
|
-
export type { ConfigEntries } from '../shared/page-configs/
|
|
9
|
+
export type { ConfigEntries } from '../shared/page-configs/getUserFriendlyConfigs.js';
|
|
10
10
|
export type { VikeConfigPublic as VikeConfig } from '../node/plugin/plugins/commonConfig.js';
|
|
11
11
|
export type { UrlPublic as Url } from '../utils/parseUrl.js';
|
|
12
12
|
export type { InjectFilterEntry } from '../node/runtime/html/injectAssets/getHtmlTags.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.230-commit-dd11364";
|
|
@@ -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.230-commit-dd11364';
|
|
@@ -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
|
@@ -8,11 +8,10 @@ import { checkType } from './checkType.js';
|
|
|
8
8
|
import { getTerminalWidth } from './getTerminWidth.js';
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
10
|
import { isArray } from './isArray.js';
|
|
11
|
-
|
|
11
|
+
import { isObject } from './isObject.js';
|
|
12
|
+
import { setCreateDebugger } from '../shared/route/debug.js';
|
|
12
13
|
assert(!isBrowser());
|
|
13
|
-
|
|
14
|
-
// We purposely read process.env.DEBUG early, in order to avoid users from the temptation to set process.env.DEBUG with JavaScript, since reading & writing process.env.DEBUG dynamically leads to inconsistencies: for example https://github.com/vikejs/vike/issues/2239
|
|
15
|
-
const DEBUG = getDEBUG() ?? '';
|
|
14
|
+
setCreateDebugger(createDebugger); // for isomorphic code
|
|
16
15
|
const flags = [
|
|
17
16
|
'vike:crawl',
|
|
18
17
|
'vike:error',
|
|
@@ -26,6 +25,7 @@ const flags = [
|
|
|
26
25
|
'vike:outDir',
|
|
27
26
|
'vike:pageFiles',
|
|
28
27
|
'vike:pointer-imports',
|
|
28
|
+
'vike:resolve',
|
|
29
29
|
'vike:routing',
|
|
30
30
|
'vike:setup',
|
|
31
31
|
'vike:stream',
|
|
@@ -33,6 +33,10 @@ const flags = [
|
|
|
33
33
|
];
|
|
34
34
|
const flagsSkipWildcard = ['vike:log'];
|
|
35
35
|
const flagRegex = /\bvike:[a-zA-Z-]+/g;
|
|
36
|
+
// We purposely read process.env.DEBUG early, in order to avoid users from the temptation to set process.env.DEBUG with JavaScript, since reading & writing process.env.DEBUG dynamically leads to inconsistencies such as https://github.com/vikejs/vike/issues/2239
|
|
37
|
+
const DEBUG = getDEBUG() ?? '';
|
|
38
|
+
if (isDebug())
|
|
39
|
+
Error.stackTraceLimit = Infinity;
|
|
36
40
|
assertFlagsActivated();
|
|
37
41
|
function createDebugger(flag, optionsGlobal) {
|
|
38
42
|
checkType(flag);
|
|
@@ -59,9 +63,10 @@ function debug_(flag, options, ...msgs) {
|
|
|
59
63
|
});
|
|
60
64
|
let logFirst;
|
|
61
65
|
let logsRest;
|
|
62
|
-
const noNewLine = msgsRest.length <= 1 &&
|
|
66
|
+
const noNewLine = msgsRest.length <= 1 &&
|
|
67
|
+
[msgFirst, ...msgsRest].every((m) => (typeof m === 'string' ? !m.includes('\n') : !isObject(m)));
|
|
63
68
|
if (noNewLine) {
|
|
64
|
-
logFirst = [msgFirst, ...msgsRest].map((m) =>
|
|
69
|
+
logFirst = [msgFirst, ...msgsRest].map((m) => (typeof m !== 'string' ? m : m.trim()));
|
|
65
70
|
logsRest = [];
|
|
66
71
|
}
|
|
67
72
|
else {
|
|
@@ -151,6 +156,10 @@ function getFlagsActivated() {
|
|
|
151
156
|
const all = DEBUG.includes('vike:*');
|
|
152
157
|
return { flagsActivated, all };
|
|
153
158
|
}
|
|
159
|
+
function isDebug() {
|
|
160
|
+
const { flagsActivated, all } = getFlagsActivated();
|
|
161
|
+
return all || flagsActivated.length > 0;
|
|
162
|
+
}
|
|
154
163
|
function getDEBUG() {
|
|
155
164
|
let DEBUG;
|
|
156
165
|
// - `process` can be undefined in edge workers
|
package/dist/esm/utils/isDev.js
CHANGED
|
@@ -4,7 +4,9 @@ export { applyPreview };
|
|
|
4
4
|
import { assertUsage } from './assert.js';
|
|
5
5
|
function isDevCheck(configEnv) {
|
|
6
6
|
const { isPreview, command } = configEnv;
|
|
7
|
-
//
|
|
7
|
+
// Note that:
|
|
8
|
+
// - `assertVersion('Vite', version, '5.1.0')` at node/plugin/onLoad.ts isn't enough: https://github.com/vitejs/vite/pull/19355
|
|
9
|
+
// - We'll eventually be able to make this an assert() instead of assertUsage() once Vike requires a Vite version that supports this.meta.viteVersion
|
|
8
10
|
assertUsage(typeof isPreview === 'boolean', 'You are using an old Vite version; make sure to use Vite 5.1.0 or above.');
|
|
9
11
|
return command === 'serve' && !isPreview;
|
|
10
12
|
}
|
|
@@ -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
|
|
2
|
+
declare function objectAssign<Obj extends object, ObjAddendum extends Record<string, any> | null | undefined>(obj: Obj, objAddendum: ObjAddendum, objAddendumCanBeOriginalObject?: true): asserts obj is Obj & ObjAddendum;
|
|
@@ -3,10 +3,10 @@ import { assert } from './assert.js';
|
|
|
3
3
|
// Same as Object.assign() but:
|
|
4
4
|
// - With type inference
|
|
5
5
|
// - Preserves property descriptors, which we need for preserving the getters of getPageContextUrlComputed()
|
|
6
|
-
function objectAssign(obj, objAddendum,
|
|
6
|
+
function objectAssign(obj, objAddendum, objAddendumCanBeOriginalObject) {
|
|
7
7
|
if (!objAddendum)
|
|
8
8
|
return;
|
|
9
|
-
if (!
|
|
10
|
-
assert(!
|
|
9
|
+
if (!objAddendumCanBeOriginalObject)
|
|
10
|
+
assert(!objAddendum._isOriginalObject);
|
|
11
11
|
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
12
12
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Like Object.defineProperty() but with type inference */
|
|
2
1
|
export declare function objectDefineProperty<Obj extends object, Prop extends PropertyKey, PropertyType>(obj: Obj, prop: Prop, { get, ...args }: {
|
|
3
2
|
get: () => PropertyType;
|
|
4
3
|
} & Omit<PropertyDescriptor, 'set' | 'get'>): asserts obj is Obj & Record<Prop, PropertyType>;
|
|
@@ -2,6 +2,7 @@ export { isImportPathNpmPackage };
|
|
|
2
2
|
export { isImportPathNpmPackageOrPathAlias };
|
|
3
3
|
export { assertIsImportPathNpmPackage };
|
|
4
4
|
export { isPathAliasRecommended };
|
|
5
|
+
export { getNpmPackageName };
|
|
5
6
|
export { parseNpmPackage };
|
|
6
7
|
export { isDistinguishable };
|
|
7
8
|
declare function isImportPathNpmPackage(str: string, { cannotBePathAlias }: {
|
|
@@ -9,6 +10,7 @@ declare function isImportPathNpmPackage(str: string, { cannotBePathAlias }: {
|
|
|
9
10
|
}): boolean;
|
|
10
11
|
declare function isImportPathNpmPackageOrPathAlias(str: string): boolean;
|
|
11
12
|
declare function assertIsImportPathNpmPackage(str: string): void;
|
|
13
|
+
declare function getNpmPackageName(str: string): null | string;
|
|
12
14
|
declare function isPathAliasRecommended(alias: string): boolean;
|
|
13
15
|
declare function isDistinguishable(alias: string): boolean;
|
|
14
16
|
declare function parseNpmPackage(str: string | undefined): null | {
|
|
@@ -2,9 +2,9 @@ export { isImportPathNpmPackage };
|
|
|
2
2
|
export { isImportPathNpmPackageOrPathAlias };
|
|
3
3
|
export { assertIsImportPathNpmPackage };
|
|
4
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
|
|
@@ -92,7 +92,6 @@ function modifyUrlPathname(url, modifier) {
|
|
|
92
92
|
function removeUrlOrigin(url) {
|
|
93
93
|
const { origin, pathnameOriginal, searchOriginal, hashOriginal } = parseUrl(url, '/');
|
|
94
94
|
const urlModified = createUrlFromComponents(null, pathnameOriginal, searchOriginal, hashOriginal);
|
|
95
|
-
assert(urlModified.startsWith('/'));
|
|
96
95
|
return { urlModified, origin };
|
|
97
96
|
}
|
|
98
97
|
function setUrlOrigin(url, origin) {
|
|
@@ -12,11 +12,13 @@ import { createRequire } from 'node:module';
|
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { assertIsImportPathNpmPackage, isImportPathNpmPackageOrPathAlias } from './parseNpmPackage.js';
|
|
14
14
|
import { isNotNullish } from './isNullish.js';
|
|
15
|
+
import { createDebugger } from './debug.js';
|
|
15
16
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
16
17
|
const importMetaUrl = import.meta.url;
|
|
17
18
|
assertPosixPath(importMetaUrl);
|
|
18
19
|
assertIsNotBrowser();
|
|
19
20
|
assertIsNotProductionRuntime();
|
|
21
|
+
const debug = createDebugger('vike:resolve');
|
|
20
22
|
// - We still can't use import.meta.resolve() as of 23.1.0 (November 2024) because `parent` argument requires an experimental flag.
|
|
21
23
|
// - https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment139581675_62272600
|
|
22
24
|
// - Passing context to createRequire(context) isn't equivalent to passing it to the `paths` argument of require.resolve()
|
|
@@ -25,33 +27,31 @@ assertIsNotProductionRuntime();
|
|
|
25
27
|
// - The argument createRequire(argument) seems to be overriden by the `paths` argument require.resolve()
|
|
26
28
|
// - For example, passing an empty array to `paths` kills the argument passed to `createRequire()`
|
|
27
29
|
// - Thus, when `paths` is defined, then the context needs to be passed to both createRequire() as well as the `paths` argument of require.resolve()
|
|
28
|
-
function requireResolve_(importPath, importerFilePath,
|
|
30
|
+
function requireResolve_(importPath, importerFilePath, userRootDir, doNotHandleFileExtension = false) {
|
|
29
31
|
assertPosixPath(importPath);
|
|
30
32
|
const contexts = importerFilePath
|
|
31
33
|
? [importerFilePath]
|
|
32
34
|
: [userRootDir ? getFakeImporterFile(userRootDir) : importMetaUrl];
|
|
33
|
-
addExtraContextForNpmPackageImport(contexts,
|
|
35
|
+
addExtraContextForNpmPackageImport(contexts, importPath, userRootDir);
|
|
34
36
|
let importPathResolvedFilePath;
|
|
35
37
|
let failure;
|
|
36
38
|
for (const context of contexts) {
|
|
37
39
|
assertPosixPath(context);
|
|
38
|
-
const
|
|
40
|
+
const contextNode = makeNodeFriendly(ensureFilePrefix(context));
|
|
41
|
+
let importPathNode = makeNodeFriendly(importPath);
|
|
42
|
+
const require_ = createRequire(contextNode);
|
|
39
43
|
if (!doNotHandleFileExtension) {
|
|
40
44
|
addFileExtensionsToRequireResolve(require_);
|
|
41
|
-
|
|
45
|
+
importPathNode = removeFileExtention(importPathNode);
|
|
42
46
|
}
|
|
43
47
|
try {
|
|
44
|
-
importPathResolvedFilePath = require_.resolve(
|
|
48
|
+
importPathResolvedFilePath = require_.resolve(importPathNode);
|
|
45
49
|
}
|
|
46
50
|
catch (err) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log('context', context)
|
|
52
|
-
console.log('importMetaUrl', importMetaUrl)
|
|
53
|
-
console.log('paths', paths)
|
|
54
|
-
//*/
|
|
51
|
+
if (debug.isActivated) {
|
|
52
|
+
const stack = new Error().stack;
|
|
53
|
+
debug('ERROR', { err, importPath, context }, stack);
|
|
54
|
+
}
|
|
55
55
|
failure ?? (failure = { err });
|
|
56
56
|
}
|
|
57
57
|
if (importPathResolvedFilePath)
|
|
@@ -59,23 +59,39 @@ function requireResolve_(importPath, importerFilePath, { userRootDir, doNotHandl
|
|
|
59
59
|
}
|
|
60
60
|
if (!importPathResolvedFilePath) {
|
|
61
61
|
assert(failure);
|
|
62
|
+
if (debug.isActivated) {
|
|
63
|
+
debug('FAILURE', {
|
|
64
|
+
importPath,
|
|
65
|
+
importerFilePath,
|
|
66
|
+
userRootDir,
|
|
67
|
+
doNotHandleFileExtension,
|
|
68
|
+
importMetaUrl,
|
|
69
|
+
contexts
|
|
70
|
+
});
|
|
71
|
+
}
|
|
62
72
|
return { importPathResolvedFilePath: undefined, err: failure.err, hasFailed: true };
|
|
63
73
|
}
|
|
64
74
|
else {
|
|
75
|
+
if (failure && debug.isActivated) {
|
|
76
|
+
debug('SUCCESS', {
|
|
77
|
+
importPath,
|
|
78
|
+
contexts
|
|
79
|
+
});
|
|
80
|
+
}
|
|
65
81
|
assert(importPathResolvedFilePath);
|
|
66
82
|
importPathResolvedFilePath = toPosixPath(importPathResolvedFilePath);
|
|
67
83
|
return { importPathResolvedFilePath, err: undefined, hasFailed: false };
|
|
68
84
|
}
|
|
69
85
|
}
|
|
70
86
|
function requireResolveOptional({ importPath, importerFilePath, userRootDir }) {
|
|
71
|
-
const res = requireResolve_(importPath, importerFilePath,
|
|
87
|
+
const res = requireResolve_(importPath, importerFilePath, userRootDir);
|
|
72
88
|
if (res.hasFailed)
|
|
73
89
|
return null;
|
|
74
90
|
return res.importPathResolvedFilePath;
|
|
75
91
|
}
|
|
76
92
|
function requireResolveOptionalDir({ importPath, importerDir, userRootDir }) {
|
|
77
93
|
const importerFilePath = getFakeImporterFile(importerDir);
|
|
78
|
-
const res = requireResolve_(importPath, importerFilePath,
|
|
94
|
+
const res = requireResolve_(importPath, importerFilePath, userRootDir);
|
|
79
95
|
if (res.hasFailed)
|
|
80
96
|
return null;
|
|
81
97
|
return res.importPathResolvedFilePath;
|
|
@@ -83,7 +99,7 @@ function requireResolveOptionalDir({ importPath, importerDir, userRootDir }) {
|
|
|
83
99
|
function requireResolveNpmPackage({ importPathNpmPackage, userRootDir }) {
|
|
84
100
|
assertIsImportPathNpmPackage(importPathNpmPackage);
|
|
85
101
|
const importerFilePath = getFakeImporterFile(userRootDir);
|
|
86
|
-
const res = requireResolve_(importPathNpmPackage, importerFilePath,
|
|
102
|
+
const res = requireResolve_(importPathNpmPackage, importerFilePath, userRootDir);
|
|
87
103
|
if (res.hasFailed)
|
|
88
104
|
throw res.err;
|
|
89
105
|
return res.importPathResolvedFilePath;
|
|
@@ -92,19 +108,19 @@ function requireResolveVikeDistFile(vikeDistFile) {
|
|
|
92
108
|
const vikeNodeModulesRoot = getVikeNodeModulesRoot();
|
|
93
109
|
assertPosixPath(vikeNodeModulesRoot);
|
|
94
110
|
assertPosixPath(vikeDistFile);
|
|
95
|
-
const importPathResolvedFilePath = path.posix.join(vikeNodeModulesRoot, vikeDistFile);
|
|
111
|
+
const importPathResolvedFilePath = makeNodeFriendly(path.posix.join(vikeNodeModulesRoot, vikeDistFile));
|
|
96
112
|
// Double check
|
|
97
113
|
{
|
|
98
114
|
const res = requireResolve_(importPathResolvedFilePath,
|
|
99
115
|
// No context needed: importPathResolvedFilePath is already resolved and absolute
|
|
100
|
-
null,
|
|
116
|
+
null, null, true);
|
|
101
117
|
if (res.hasFailed)
|
|
102
118
|
throw res.err;
|
|
103
119
|
assert(res.importPathResolvedFilePath === importPathResolvedFilePath);
|
|
104
120
|
}
|
|
105
121
|
return importPathResolvedFilePath;
|
|
106
122
|
}
|
|
107
|
-
function addExtraContextForNpmPackageImport(contexts,
|
|
123
|
+
function addExtraContextForNpmPackageImport(contexts, importPath, userRootDir) {
|
|
108
124
|
// We should add extra context only for npm packages, but unfortunately we cannot always disambiguate between npm package imports and path aliases.
|
|
109
125
|
if (!isImportPathNpmPackageOrPathAlias(importPath))
|
|
110
126
|
return;
|
|
@@ -186,3 +202,7 @@ function getFilePrefix() {
|
|
|
186
202
|
prefix += '/';
|
|
187
203
|
return prefix;
|
|
188
204
|
}
|
|
205
|
+
function makeNodeFriendly(filePath) {
|
|
206
|
+
// https://github.com/vikejs/vike/issues/2436#issuecomment-2849145340
|
|
207
|
+
return decodeURIComponent(filePath);
|
|
208
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.230-commit-dd11364",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"@types/resolve": "^1.20.6",
|
|
255
255
|
"@types/semver": "^7.5.8",
|
|
256
256
|
"@types/source-map-support": "^0.5.10",
|
|
257
|
-
"react-streaming": "^0.
|
|
257
|
+
"react-streaming": "^0.4.2",
|
|
258
258
|
"rimraf": "^5.0.5",
|
|
259
259
|
"typescript": "^5.8.3",
|
|
260
260
|
"vite": "^6.3.2"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPageContextProxyForUser = getPageContextProxyForUser;
|
|
4
|
-
const utils_js_1 = require("../server-routing-runtime/utils.js");
|
|
5
|
-
const NOT_SERIALIZABLE_js_1 = require("../../shared/NOT_SERIALIZABLE.js");
|
|
6
|
-
// Throw error when pageContext value isn't serializable
|
|
7
|
-
function getPageContextProxyForUser(pageContext) {
|
|
8
|
-
return new Proxy(pageContext, {
|
|
9
|
-
get(_, prop) {
|
|
10
|
-
const val = pageContext[prop];
|
|
11
|
-
const propName = (0, utils_js_1.getPropAccessNotation)(prop);
|
|
12
|
-
(0, utils_js_1.assertUsage)(val !== NOT_SERIALIZABLE_js_1.NOT_SERIALIZABLE, `Can't access pageContext${propName} on the client side. Because it can't be serialized, see server logs.`);
|
|
13
|
-
return val;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.preparePageContextForUserConsumptionServerSide = preparePageContextForUserConsumptionServerSide;
|
|
4
|
-
const utils_js_1 = require("../utils.js");
|
|
5
|
-
const getPageContextUrlComputed_js_1 = require("../../../shared/getPageContextUrlComputed.js");
|
|
6
|
-
const preparePageContextForUserConsumption_js_1 = require("../../../shared/preparePageContextForUserConsumption.js");
|
|
7
|
-
function preparePageContextForUserConsumptionServerSide(pageContext) {
|
|
8
|
-
(0, getPageContextUrlComputed_js_1.assertPageContextUrl)(pageContext);
|
|
9
|
-
(0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(pageContext.routeParams));
|
|
10
|
-
(0, utils_js_1.assert)('Page' in pageContext);
|
|
11
|
-
(0, utils_js_1.assert)(typeof pageContext.isClientSideNavigation === 'boolean');
|
|
12
|
-
(0, utils_js_1.assert)(pageContext.isPageContext);
|
|
13
|
-
(0, utils_js_1.assert)(pageContext.isClientSide === false);
|
|
14
|
-
(0, utils_js_1.assert)(typeof pageContext.isPrerendering === 'boolean');
|
|
15
|
-
(0, preparePageContextForUserConsumption_js_1.preparePageContextForUserConsumption)(pageContext);
|
|
16
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPageConfigsRuntime = getPageConfigsRuntime;
|
|
4
|
-
exports.getAllPageIds = getAllPageIds;
|
|
5
|
-
const parseGlobResults_js_1 = require("./getPageFiles/parseGlobResults.js");
|
|
6
|
-
const getPageConfigUserFriendly_js_1 = require("./page-configs/getPageConfigUserFriendly.js");
|
|
7
|
-
const utils_js_1 = require("./utils.js");
|
|
8
|
-
function getPageConfigsRuntime(virtualFileExports) {
|
|
9
|
-
const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseGlobResults_js_1.parseGlobResults)(virtualFileExports);
|
|
10
|
-
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
11
|
-
// TODO/now: re-use this call, instead of calling it twice
|
|
12
|
-
const globalConfig = (0, getPageConfigUserFriendly_js_1.getPageConfigGlobalUserFriendly)({ pageConfigGlobalValues: pageConfigGlobal.configValues });
|
|
13
|
-
const pageConfigsUserFriendly = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
14
|
-
return (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendly)(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
|
|
15
|
-
}));
|
|
16
|
-
return { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig, pageConfigsUserFriendly };
|
|
17
|
-
}
|
|
18
|
-
function getAllPageIds(pageFilesAll, pageConfigs) {
|
|
19
|
-
const fileIds = pageFilesAll.filter(({ isDefaultPageFile }) => !isDefaultPageFile).map(({ pageId }) => pageId);
|
|
20
|
-
const allPageIds = (0, utils_js_1.unique)(fileIds);
|
|
21
|
-
const allPageIds2 = pageConfigs.map((p) => p.pageId);
|
|
22
|
-
return [...allPageIds, ...allPageIds2];
|
|
23
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeHook = executeHook;
|
|
4
|
-
exports.getPageContext = getPageContext;
|
|
5
|
-
exports.providePageContext = providePageContext;
|
|
6
|
-
exports.isUserHookError = isUserHookError;
|
|
7
|
-
const assert_js_1 = require("../../utils/assert.js");
|
|
8
|
-
const getGlobalObject_js_1 = require("../../utils/getGlobalObject.js");
|
|
9
|
-
const humanizeTime_js_1 = require("../../utils/humanizeTime.js");
|
|
10
|
-
const isObject_js_1 = require("../../utils/isObject.js");
|
|
11
|
-
const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/executeHook.ts', {
|
|
12
|
-
userHookErrors: new WeakMap(),
|
|
13
|
-
pageContext: null
|
|
14
|
-
});
|
|
15
|
-
function isUserHookError(err) {
|
|
16
|
-
if (!(0, isObject_js_1.isObject)(err))
|
|
17
|
-
return false;
|
|
18
|
-
return globalObject.userHookErrors.get(err) ?? false;
|
|
19
|
-
}
|
|
20
|
-
function executeHook(hookFnCaller, hook, pageContext) {
|
|
21
|
-
const { hookName, hookFilePath, hookTimeout: { error: timeoutErr, warning: timeoutWarn } } = hook;
|
|
22
|
-
let resolve;
|
|
23
|
-
let reject;
|
|
24
|
-
const promise = new Promise((resolve_, reject_) => {
|
|
25
|
-
resolve = (ret) => {
|
|
26
|
-
clearTimeouts();
|
|
27
|
-
resolve_(ret);
|
|
28
|
-
};
|
|
29
|
-
reject = (err) => {
|
|
30
|
-
clearTimeouts();
|
|
31
|
-
reject_(err);
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
const clearTimeouts = () => {
|
|
35
|
-
if (currentTimeoutWarn)
|
|
36
|
-
clearTimeout(currentTimeoutWarn);
|
|
37
|
-
if (currentTimeoutErr)
|
|
38
|
-
clearTimeout(currentTimeoutErr);
|
|
39
|
-
};
|
|
40
|
-
const currentTimeoutWarn = isNotDisabled(timeoutWarn) &&
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
(0, assert_js_1.assertWarning)(false, `The ${hookName}() hook defined by ${hookFilePath} is slow: it's taking more than ${(0, humanizeTime_js_1.humanizeTime)(timeoutWarn)} (https://vike.dev/hooksTimeout)`, { onlyOnce: false });
|
|
43
|
-
}, timeoutWarn);
|
|
44
|
-
const currentTimeoutErr = isNotDisabled(timeoutErr) &&
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
const err = (0, assert_js_1.getProjectError)(`The ${hookName}() hook defined by ${hookFilePath} timed out: it didn't finish after ${(0, humanizeTime_js_1.humanizeTime)(timeoutErr)} (https://vike.dev/hooksTimeout)`);
|
|
47
|
-
reject(err);
|
|
48
|
-
}, timeoutErr);
|
|
49
|
-
(async () => {
|
|
50
|
-
try {
|
|
51
|
-
providePageContext(pageContext);
|
|
52
|
-
const ret = await hookFnCaller();
|
|
53
|
-
resolve(ret);
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
if ((0, isObject_js_1.isObject)(err)) {
|
|
57
|
-
globalObject.userHookErrors.set(err, { hookName, hookFilePath });
|
|
58
|
-
}
|
|
59
|
-
reject(err);
|
|
60
|
-
}
|
|
61
|
-
})();
|
|
62
|
-
return promise;
|
|
63
|
-
}
|
|
64
|
-
function isNotDisabled(timeout) {
|
|
65
|
-
return !!timeout && timeout !== Infinity;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Access `pageContext` object inside Vike hooks, in order to create universal hooks.
|
|
69
|
-
*
|
|
70
|
-
* https://vike.dev/getPageContext
|
|
71
|
-
*/
|
|
72
|
-
function getPageContext() {
|
|
73
|
-
return globalObject.pageContext;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Provide `pageContext` for universal hooks.
|
|
77
|
-
*
|
|
78
|
-
* https://vike.dev/getPageContext
|
|
79
|
-
*/
|
|
80
|
-
function providePageContext(pageContext) {
|
|
81
|
-
globalObject.pageContext = pageContext;
|
|
82
|
-
// Promise.resolve() is quicker than process.nextTick() and setImmediate()
|
|
83
|
-
// https://stackoverflow.com/questions/67949576/process-nexttick-before-promise-resolve-then
|
|
84
|
-
Promise.resolve().then(() => {
|
|
85
|
-
globalObject.pageContext = null;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeHookGeneric = executeHookGeneric;
|
|
4
|
-
exports.executeHookGenericGlobalCumulative = executeHookGenericGlobalCumulative;
|
|
5
|
-
const executeHook_js_1 = require("./executeHook.js");
|
|
6
|
-
const getHook_js_1 = require("./getHook.js");
|
|
7
|
-
async function executeHookGeneric(hookName, pageContext) {
|
|
8
|
-
const hook = (0, getHook_js_1.getHookFromPageContext)(pageContext, hookName);
|
|
9
|
-
if (!hook)
|
|
10
|
-
return;
|
|
11
|
-
await (0, executeHook_js_1.executeHook)(() => hook.hookFn(pageContext), hook, pageContext);
|
|
12
|
-
}
|
|
13
|
-
async function executeHookGenericGlobalCumulative(hookName, pageConfigGlobal, pageContext, arg) {
|
|
14
|
-
const hooks = (0, getHook_js_1.getHookFromPageConfigGlobalCumulative)(pageConfigGlobal, hookName);
|
|
15
|
-
await Promise.all(hooks.map(async (hook) => {
|
|
16
|
-
await (0, executeHook_js_1.executeHook)(() => hook.hookFn(arg), hook, pageContext);
|
|
17
|
-
}));
|
|
18
|
-
}
|