vike 0.4.229-commit-7056ef0 → 0.4.229-commit-5da80bf
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} +15 -19
- package/dist/cjs/node/api/build.js +1 -5
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -2
- package/dist/cjs/node/prerender/runPrerender.js +40 -36
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +13 -27
- package/dist/cjs/node/runtime/html/serializeContext.js +1 -1
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +4 -8
- package/dist/cjs/node/runtime/renderPage/execHookServer.js +11 -0
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +9 -9
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -12
- package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +10 -0
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/cjs/node/runtime/renderPage.js +7 -5
- 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 +6 -3
- package/dist/cjs/shared/createPageContextShared.js +14 -3
- package/dist/cjs/shared/getPageContext.js +3 -3
- package/dist/cjs/shared/getPageContextUrlComputed.js +2 -36
- package/dist/cjs/shared/getProxyForPublicUsage.js +106 -0
- package/dist/cjs/shared/hooks/execHook.js +164 -0
- package/dist/cjs/shared/page-configs/getUserFriendlyConfigs.js +17 -15
- package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +10 -0
- package/dist/cjs/shared/preparePageContextForPublicUsage.js +75 -0
- package/dist/cjs/shared/route/abort.js +2 -2
- 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 +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/objectAssign.js +3 -3
- package/dist/cjs/utils/objectDefineProperty.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContextClientSide.d.ts +10 -7
- package/dist/esm/client/client-routing-runtime/createPageContextClientSide.js +8 -10
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +397 -20
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +15 -15
- package/dist/esm/client/client-routing-runtime/globalContext.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +3 -8
- 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 +66 -72
- 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 +8 -6
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +8 -10
- package/dist/esm/client/server-routing-runtime/entry.js +4 -6
- package/dist/esm/client/server-routing-runtime/globalContext.d.ts +1 -0
- 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 +1 -0
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +3 -3
- package/dist/esm/client/shared/executeOnRenderClientHook.js +4 -13
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +11 -0
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.js +40 -0
- package/dist/esm/node/api/build.js +1 -2
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +15 -115
- package/dist/esm/node/prerender/runPrerender.js +40 -36
- 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 +5 -373
- package/dist/esm/node/runtime/globalContext.js +14 -28
- package/dist/esm/node/runtime/html/serializeContext.d.ts +1 -1
- package/dist/esm/node/runtime/html/serializeContext.js +1 -1
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +15 -62
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +5 -9
- 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 +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +9 -9
- 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/preparePageContextForPublicUsageServer.d.ts +20 -0
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +8 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +15 -115
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/esm/node/runtime/renderPage.d.ts +10 -60
- package/dist/esm/node/runtime/renderPage.js +7 -5
- 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 +2 -0
- package/dist/esm/shared/createGlobalContextShared.js +7 -4
- package/dist/esm/shared/createPageContextShared.d.ts +6 -2
- package/dist/esm/shared/createPageContextShared.js +15 -4
- 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/getProxyForPublicUsage.d.ts +12 -0
- package/dist/esm/shared/getProxyForPublicUsage.js +104 -0
- package/dist/esm/shared/hooks/execHook.d.ts +63 -0
- package/dist/esm/shared/hooks/execHook.js +162 -0
- package/dist/esm/shared/hooks/getHook.d.ts +3 -1
- package/dist/esm/shared/page-configs/Config.d.ts +3 -3
- package/dist/esm/shared/page-configs/getUserFriendlyConfigs.js +18 -16
- package/dist/esm/shared/prepareGlobalContextForPublicUsage.d.ts +7 -0
- package/dist/esm/shared/prepareGlobalContextForPublicUsage.js +8 -0
- package/dist/esm/shared/preparePageContextForPublicUsage.d.ts +12 -0
- package/dist/esm/shared/preparePageContextForPublicUsage.js +73 -0
- package/dist/esm/shared/route/abort.js +1 -1
- 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 +13 -3
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- 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/package.json +2 -2
- package/dist/cjs/client/shared/getPageContextProxyForUser.js +0 -16
- package/dist/cjs/node/runtime/renderPage/executeHookServer.js +0 -11
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +0 -16
- package/dist/cjs/shared/hooks/executeHook.js +0 -108
- 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/executeHookServer.d.ts +0 -13
- package/dist/esm/node/runtime/renderPage/executeHookServer.js +0 -9
- 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/hooks/executeHook.d.ts +0 -34
- package/dist/esm/shared/hooks/executeHook.js +0 -106
- 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
|
@@ -2,11 +2,11 @@ export { renderPage };
|
|
|
2
2
|
export { renderPage_addAsyncHookwrapper };
|
|
3
3
|
export type { PageContextInit };
|
|
4
4
|
export type { PageContextBegin };
|
|
5
|
-
import { type
|
|
5
|
+
import { type GlobalContextServerInternal } from './globalContext.js';
|
|
6
6
|
import { type HttpResponse } from './renderPage/createHttpResponse.js';
|
|
7
7
|
import type { PageContextServer } from '../../types/index.js';
|
|
8
|
-
import type {
|
|
9
|
-
type PageContextInit = Pick<
|
|
8
|
+
import type { PageContextInternalServer } from '../../shared/types.js';
|
|
9
|
+
type PageContextInit = Pick<PageContextInternalServer, 'urlOriginal' | 'headersOriginal'> & {
|
|
10
10
|
/** @deprecated Set `pageContextInit.urlOriginal` instead */ url?: string;
|
|
11
11
|
/** @deprecated Set pageContextInit.headersOriginal instead */ headers?: Record<string, string>;
|
|
12
12
|
};
|
|
@@ -18,16 +18,19 @@ declare let asyncHookWrapper: <PageContext>(_httpRequestId: number, ret: () => P
|
|
|
18
18
|
pageContextReturn: Awaited<PageContext>;
|
|
19
19
|
}>;
|
|
20
20
|
declare function renderPage_addAsyncHookwrapper(wrapper: typeof asyncHookWrapper): void;
|
|
21
|
-
declare function getPageContextBegin(pageContextInit: PageContextInit, globalContext: GlobalContextServerInternal,
|
|
22
|
-
|
|
21
|
+
declare function getPageContextBegin(pageContextInit: PageContextInit, globalContext: GlobalContextServerInternal, httpRequestId: number): Promise<{
|
|
22
|
+
_isOriginalObject: true;
|
|
23
|
+
isPageContext: true;
|
|
24
|
+
} & {
|
|
25
|
+
isClientSide: false;
|
|
23
26
|
isPrerendering: boolean;
|
|
24
|
-
} & Pick<
|
|
27
|
+
} & Pick<PageContextInternalServer, "urlOriginal" | "headersOriginal"> & {
|
|
25
28
|
/** @deprecated Set `pageContextInit.urlOriginal` instead */ url?: string;
|
|
26
29
|
/** @deprecated Set pageContextInit.headersOriginal instead */ headers?: Record<string, string>;
|
|
27
30
|
} & {
|
|
28
|
-
globalContext: GlobalContextServer;
|
|
29
31
|
_globalContext: {
|
|
30
32
|
isGlobalContext: true;
|
|
33
|
+
_isOriginalObject: true;
|
|
31
34
|
_virtualFileExports: unknown;
|
|
32
35
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
33
36
|
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
@@ -65,23 +68,6 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
65
68
|
isClientSide: false;
|
|
66
69
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
67
70
|
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
68
|
-
isGlobalContext: true;
|
|
69
|
-
_virtualFileExports: unknown;
|
|
70
|
-
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
71
|
-
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
72
|
-
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
73
|
-
_allPageIds: string[];
|
|
74
|
-
_userFriendlyConfigsGlobal: import("../../shared/page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly;
|
|
75
|
-
config: import("../../types/index.js").ConfigResolved;
|
|
76
|
-
pages: {
|
|
77
|
-
[k: string]: import("../../shared/page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly & ({
|
|
78
|
-
route: import("../../shared/page-configs/Config.js").Route;
|
|
79
|
-
isErrorPage?: undefined;
|
|
80
|
-
} | {
|
|
81
|
-
route?: undefined;
|
|
82
|
-
isErrorPage: true;
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
71
|
} | {
|
|
86
72
|
_isPrerendering: true;
|
|
87
73
|
viteConfig: import("vite").ResolvedConfig;
|
|
@@ -104,23 +90,6 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
104
90
|
isClientSide: false;
|
|
105
91
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
106
92
|
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
107
|
-
isGlobalContext: true;
|
|
108
|
-
_virtualFileExports: unknown;
|
|
109
|
-
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
110
|
-
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
111
|
-
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
112
|
-
_allPageIds: string[];
|
|
113
|
-
_userFriendlyConfigsGlobal: import("../../shared/page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly;
|
|
114
|
-
config: import("../../types/index.js").ConfigResolved;
|
|
115
|
-
pages: {
|
|
116
|
-
[k: string]: import("../../shared/page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly & ({
|
|
117
|
-
route: import("../../shared/page-configs/Config.js").Route;
|
|
118
|
-
isErrorPage?: undefined;
|
|
119
|
-
} | {
|
|
120
|
-
route?: undefined;
|
|
121
|
-
isErrorPage: true;
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
93
|
} | {
|
|
125
94
|
_isPrerendering: false;
|
|
126
95
|
viteConfig: null;
|
|
@@ -143,23 +112,6 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
143
112
|
isClientSide: false;
|
|
144
113
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
145
114
|
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
146
|
-
isGlobalContext: true;
|
|
147
|
-
_virtualFileExports: unknown;
|
|
148
|
-
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
149
|
-
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
150
|
-
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
151
|
-
_allPageIds: string[];
|
|
152
|
-
_userFriendlyConfigsGlobal: import("../../shared/page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly;
|
|
153
|
-
config: import("../../types/index.js").ConfigResolved;
|
|
154
|
-
pages: {
|
|
155
|
-
[k: string]: import("../../shared/page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly & ({
|
|
156
|
-
route: import("../../shared/page-configs/Config.js").Route;
|
|
157
|
-
isErrorPage?: undefined;
|
|
158
|
-
} | {
|
|
159
|
-
route?: undefined;
|
|
160
|
-
isErrorPage: true;
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
115
|
});
|
|
164
116
|
_baseServer: string;
|
|
165
117
|
_baseAssets: string;
|
|
@@ -180,8 +132,6 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
180
132
|
url: string;
|
|
181
133
|
} & {
|
|
182
134
|
headers: Record<string, string> | null;
|
|
183
|
-
} & {
|
|
184
|
-
isPageContext: true;
|
|
185
135
|
} & {
|
|
186
136
|
_httpRequestId: number;
|
|
187
137
|
}>;
|
|
@@ -19,6 +19,7 @@ import { getErrorPageId } from '../../shared/error-page.js';
|
|
|
19
19
|
import { handleErrorWithoutErrorPage } from './renderPage/handleErrorWithoutErrorPage.js';
|
|
20
20
|
import { loadPageConfigsLazyServerSide } from './renderPage/loadPageConfigsLazyServerSide.js';
|
|
21
21
|
import { resolveRedirects } from './renderPage/resolveRedirects.js';
|
|
22
|
+
import { getProxyForMutationTracking } from '../../shared/getProxyForPublicUsage.js';
|
|
22
23
|
const globalObject = getGlobalObject('runtime/renderPage.ts', {
|
|
23
24
|
httpRequestsCount: 0
|
|
24
25
|
});
|
|
@@ -76,8 +77,8 @@ async function renderPagePrepare(pageContextInit, httpRequestId) {
|
|
|
76
77
|
else {
|
|
77
78
|
// `globalContext` now contains the entire Vike config and getVikeConfig() isn't called anymore for this request.
|
|
78
79
|
}
|
|
79
|
-
const { globalContext
|
|
80
|
-
const pageContextBegin = await getPageContextBegin(pageContextInit, globalContext,
|
|
80
|
+
const { globalContext } = await getGlobalContextServerInternal();
|
|
81
|
+
const pageContextBegin = await getPageContextBegin(pageContextInit, globalContext, httpRequestId);
|
|
81
82
|
// Check Base URL
|
|
82
83
|
{
|
|
83
84
|
const pageContextHttpResponse = await checkBaseUrl(pageContextBegin, globalContext);
|
|
@@ -299,9 +300,9 @@ async function getPageContextErrorPageInit(pageContextBegin, errNominalPage, pag
|
|
|
299
300
|
assert(pageContext.errorWhileRendering);
|
|
300
301
|
return pageContext;
|
|
301
302
|
}
|
|
302
|
-
async function getPageContextBegin(pageContextInit, globalContext,
|
|
303
|
+
async function getPageContextBegin(pageContextInit, globalContext, httpRequestId) {
|
|
303
304
|
const { isClientSideNavigation, _urlHandler } = handlePageContextUrl(pageContextInit.urlOriginal);
|
|
304
|
-
const pageContextBegin = await createPageContextServerSide(pageContextInit, globalContext,
|
|
305
|
+
const pageContextBegin = await createPageContextServerSide(pageContextInit, globalContext, {
|
|
305
306
|
isPrerendering: false,
|
|
306
307
|
ssr: {
|
|
307
308
|
urlHandler: _urlHandler,
|
|
@@ -483,5 +484,6 @@ function getPageContextInvalidVikeConfig(err, pageContextInit, httpRequestId) {
|
|
|
483
484
|
function forkPageContext(pageContextBegin) {
|
|
484
485
|
const pageContext = {};
|
|
485
486
|
objectAssign(pageContext, pageContextBegin, true);
|
|
486
|
-
|
|
487
|
+
const pageContextWithProxy = getProxyForMutationTracking(pageContext);
|
|
488
|
+
return pageContextWithProxy;
|
|
487
489
|
}
|
|
@@ -54,5 +54,5 @@ export * from '../../utils/isVikeReactApp.js';
|
|
|
54
54
|
export * from '../../utils/getPropAccessNotation.js';
|
|
55
55
|
export * from '../../utils/PROJECT_VERSION.js';
|
|
56
56
|
export * from '../../utils/genPromise.js';
|
|
57
|
-
export * from '../../utils/getPublicProxy.js';
|
|
58
57
|
export * from '../../utils/augmentType.js';
|
|
58
|
+
export * from '../../utils/changeEnumerable.js';
|
|
@@ -58,5 +58,5 @@ export * from '../../utils/isVikeReactApp.js';
|
|
|
58
58
|
export * from '../../utils/getPropAccessNotation.js';
|
|
59
59
|
export * from '../../utils/PROJECT_VERSION.js';
|
|
60
60
|
export * from '../../utils/genPromise.js';
|
|
61
|
-
export * from '../../utils/getPublicProxy.js';
|
|
62
61
|
export * from '../../utils/augmentType.js';
|
|
62
|
+
export * from '../../utils/changeEnumerable.js';
|
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
export { addIs404ToPageProps };
|
|
2
|
-
|
|
3
|
-
declare function addIs404ToPageProps(pageContext: Record<string, unknown> & PageContextAssertIs404): void;
|
|
4
|
-
type PageContextAssertIs404 = {
|
|
5
|
-
pageId: string;
|
|
6
|
-
_pageConfigs: PageConfigRuntime[];
|
|
7
|
-
};
|
|
2
|
+
declare function addIs404ToPageProps(pageContext: Record<string, unknown>): void;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
export { addIs404ToPageProps };
|
|
2
|
-
import {
|
|
3
|
-
import { isErrorPage } from './error-page.js';
|
|
2
|
+
import { assertWarning, isObject } from './utils.js';
|
|
4
3
|
function addIs404ToPageProps(pageContext) {
|
|
5
|
-
assertIs404(pageContext);
|
|
6
4
|
addIs404(pageContext);
|
|
7
5
|
}
|
|
8
|
-
function assertIs404(pageContext) {
|
|
9
|
-
if (isErrorPage(pageContext.pageId, pageContext._pageConfigs)) {
|
|
10
|
-
assert(hasProp(pageContext, 'is404', 'boolean'));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
6
|
function addIs404(pageContext) {
|
|
14
7
|
if (pageContext.is404 === undefined || pageContext.is404 === null)
|
|
15
8
|
return;
|
|
@@ -14,6 +14,7 @@ declare function createGlobalContextShared<GlobalContextAddendum extends object>
|
|
|
14
14
|
* https://vike.dev/globalContext#typescript
|
|
15
15
|
*/
|
|
16
16
|
isGlobalContext: true;
|
|
17
|
+
_isOriginalObject: true;
|
|
17
18
|
_virtualFileExports: unknown;
|
|
18
19
|
_pageFilesAll: PageFile[];
|
|
19
20
|
_pageConfigs: PageConfigRuntime[];
|
|
@@ -40,6 +41,7 @@ declare function createGlobalContextBase(virtualFileExports: unknown): {
|
|
|
40
41
|
* https://vike.dev/globalContext#typescript
|
|
41
42
|
*/
|
|
42
43
|
isGlobalContext: true;
|
|
44
|
+
_isOriginalObject: true;
|
|
43
45
|
_virtualFileExports: unknown;
|
|
44
46
|
_pageFilesAll: PageFile[];
|
|
45
47
|
_pageConfigs: PageConfigRuntime[];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { createGlobalContextShared };
|
|
2
2
|
export { getGlobalContextSyncErrMsg };
|
|
3
|
-
import { objectAssign, unique } from './utils.js';
|
|
3
|
+
import { changeEnumerable, objectAssign, unique } from './utils.js';
|
|
4
4
|
import { parseGlobResults } from './getPageFiles/parseGlobResults.js';
|
|
5
5
|
import { getUserFriendlyConfigsGlobal, getUserFriendlyConfigsPageEager } from './page-configs/getUserFriendlyConfigs.js';
|
|
6
|
-
import {
|
|
6
|
+
import { execHookGlobal } from './hooks/execHook.js';
|
|
7
|
+
import { prepareGlobalContextForPublicUsage } from './prepareGlobalContextForPublicUsage.js';
|
|
7
8
|
const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
8
9
|
async function createGlobalContextShared(virtualFileExports, globalObject, addGlobalContext) {
|
|
9
10
|
const globalContext = createGlobalContextBase(virtualFileExports);
|
|
@@ -22,12 +23,12 @@ async function createGlobalContextShared(virtualFileExports, globalObject, addGl
|
|
|
22
23
|
// - globalContext._viteDevServer.hot.send()
|
|
23
24
|
// - Send 'full-server-reload' signal whenever a onCreateGlobalContext() function is modified => we need a globalObject to track all hooks and see if one of them is new/modified.
|
|
24
25
|
// - Seems less idiomatic
|
|
25
|
-
await
|
|
26
|
+
await execHookGlobal('onCreateGlobalContext', globalContext._pageConfigGlobal, null, globalContext, prepareGlobalContextForPublicUsage);
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
29
|
// Singleton: ensure all `globalContext` user-land references are preserved & updated.
|
|
29
30
|
// We don't use objectReplace() in order to keep user-land properties.
|
|
30
|
-
objectAssign(globalObject.globalContext, globalContext);
|
|
31
|
+
objectAssign(globalObject.globalContext, globalContext, true);
|
|
31
32
|
}
|
|
32
33
|
return globalObject.globalContext;
|
|
33
34
|
}
|
|
@@ -40,6 +41,7 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
40
41
|
* https://vike.dev/globalContext#typescript
|
|
41
42
|
*/
|
|
42
43
|
isGlobalContext: true,
|
|
44
|
+
_isOriginalObject: true,
|
|
43
45
|
_virtualFileExports: virtualFileExports,
|
|
44
46
|
_pageFilesAll: pageFilesAll,
|
|
45
47
|
_pageConfigs: pageConfigs,
|
|
@@ -49,6 +51,7 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
49
51
|
config: userFriendlyConfigsGlobal.config,
|
|
50
52
|
pages: userFriendlyConfigsPageEager
|
|
51
53
|
};
|
|
54
|
+
changeEnumerable(globalContext, '_isOriginalObject', false);
|
|
52
55
|
return globalContext;
|
|
53
56
|
}
|
|
54
57
|
function getConfigsAll(virtualFileExports) {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { createPageContextShared };
|
|
2
|
+
export { createPageContextObject };
|
|
2
3
|
import type { PageConfigUserFriendly } from './page-configs/getUserFriendlyConfigs.js';
|
|
3
4
|
import type { PageConfigGlobalRuntime } from './page-configs/PageConfig.js';
|
|
4
|
-
|
|
5
|
+
import { type PageContextPrepareMinimum } from './preparePageContextForPublicUsage.js';
|
|
6
|
+
declare function createPageContextShared<T extends PageContextPrepareMinimum>(pageContextCreated: T, pageConfigGlobal: PageConfigGlobalRuntime, userFriendlyConfigsGlobal: PageConfigUserFriendly): Promise<T & PageConfigUserFriendly>;
|
|
7
|
+
declare function createPageContextObject(): {
|
|
8
|
+
_isOriginalObject: true;
|
|
5
9
|
isPageContext: true;
|
|
6
|
-
}
|
|
10
|
+
};
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
export { createPageContextShared };
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
export { createPageContextObject };
|
|
3
|
+
import { getProxyForMutationTracking } from './getProxyForPublicUsage.js';
|
|
4
|
+
import { execHookGlobal } from './hooks/execHook.js';
|
|
5
|
+
import { preparePageContextForPublicUsage } from './preparePageContextForPublicUsage.js';
|
|
6
|
+
import { changeEnumerable, objectAssign } from './utils.js';
|
|
4
7
|
async function createPageContextShared(pageContextCreated, pageConfigGlobal, userFriendlyConfigsGlobal) {
|
|
5
|
-
objectAssign(pageContextCreated, { isPageContext: true }, true);
|
|
6
8
|
objectAssign(pageContextCreated, userFriendlyConfigsGlobal);
|
|
7
|
-
await
|
|
9
|
+
await execHookGlobal('onCreatePageContext', pageConfigGlobal, pageContextCreated, pageContextCreated, preparePageContextForPublicUsage);
|
|
8
10
|
return pageContextCreated;
|
|
9
11
|
}
|
|
12
|
+
function createPageContextObject() {
|
|
13
|
+
const pageContext = {
|
|
14
|
+
_isOriginalObject: true,
|
|
15
|
+
isPageContext: true
|
|
16
|
+
};
|
|
17
|
+
changeEnumerable(pageContext, '_isOriginalObject', false);
|
|
18
|
+
const pageContextWithProxy = getProxyForMutationTracking(pageContext);
|
|
19
|
+
return pageContextWithProxy;
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getPageContext, providePageContext } from './hooks/
|
|
1
|
+
export { getPageContext, providePageContext } from './hooks/execHook.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getPageContext, providePageContext } from './hooks/
|
|
1
|
+
export { getPageContext, providePageContext } from './hooks/execHook.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { getPageContextUrlComputed };
|
|
2
|
-
export { assertPageContextUrl };
|
|
3
2
|
export type { PageContextUrlInternal };
|
|
4
3
|
export type { PageContextUrlClient };
|
|
5
4
|
export type { PageContextUrlServer };
|
|
6
5
|
export type { PageContextUrlSource };
|
|
6
|
+
import { type PageContextPrepareMinimum } from './preparePageContextForPublicUsage.js';
|
|
7
7
|
import { type UrlPublic } from './utils.js';
|
|
8
8
|
type PageContextUrlComputed = {
|
|
9
9
|
/** Parsed information about the current URL */
|
|
@@ -17,7 +17,7 @@ type PageContextUrl = {
|
|
|
17
17
|
/** The URL of the HTTP request */
|
|
18
18
|
urlOriginal: string;
|
|
19
19
|
} & PageContextUrlComputed;
|
|
20
|
-
type PageContextUrlInternal = PageContextUrl & {
|
|
20
|
+
type PageContextUrlInternal = PageContextPrepareMinimum & PageContextUrl & {
|
|
21
21
|
_urlRewrite: string | null;
|
|
22
22
|
};
|
|
23
23
|
type PageContextUrlClient = PageContextUrl;
|
|
@@ -40,6 +40,3 @@ type PageContextUrlSource = {
|
|
|
40
40
|
_baseServer: string;
|
|
41
41
|
_urlHandler: null | ((url: string) => string);
|
|
42
42
|
};
|
|
43
|
-
declare function assertPageContextUrl(pageContext: {
|
|
44
|
-
urlOriginal: string;
|
|
45
|
-
} & PageContextUrlClient): void;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { getPageContextUrlComputed };
|
|
2
|
-
export { assertPageContextUrl };
|
|
3
2
|
// =====================
|
|
4
3
|
// File determining the URL logic.
|
|
5
4
|
// URLs need to be computed, because the user can modify the URL e.g. with onBeforeRoute() for i18n.
|
|
6
5
|
// =====================
|
|
7
6
|
import { objectDefineProperty } from '../utils/objectDefineProperty.js';
|
|
8
|
-
import {
|
|
7
|
+
import { assertPropertyGetters } from './preparePageContextForPublicUsage.js';
|
|
8
|
+
import { assert, parseUrl, assertWarning, isBrowser, changeEnumerable } from './utils.js';
|
|
9
9
|
function getPageContextUrlComputed(pageContext) {
|
|
10
10
|
assert(typeof pageContext.urlOriginal === 'string');
|
|
11
|
-
|
|
11
|
+
assertPropertyGetters(pageContext);
|
|
12
12
|
const pageContextUrlComputed = {};
|
|
13
13
|
objectDefineProperty(pageContextUrlComputed, 'urlPathname', {
|
|
14
14
|
get: urlPathnameGetter,
|
|
@@ -128,37 +128,3 @@ function urlParsedGetter() {
|
|
|
128
128
|
}
|
|
129
129
|
return urlParsedEnhanced;
|
|
130
130
|
}
|
|
131
|
-
function assertPageContextUrl(pageContext) {
|
|
132
|
-
assert(typeof pageContext.urlOriginal === 'string');
|
|
133
|
-
assert(typeof pageContext.urlPathname === 'string');
|
|
134
|
-
assert(isPlainObject(pageContext.urlParsed));
|
|
135
|
-
assert(pageContext.urlPathname === pageContext.urlParsed.pathname);
|
|
136
|
-
assertPageContextUrlComputed(pageContext);
|
|
137
|
-
}
|
|
138
|
-
function assertPageContextUrlComputed(pageContext) {
|
|
139
|
-
/*
|
|
140
|
-
If the isPropertyGetter() assertions fail then it's most likely because Object.assign() was used instead of `objectAssign()`:
|
|
141
|
-
```js
|
|
142
|
-
const PageContextUrlComputed = getPageContextUrlComputed(pageContext)
|
|
143
|
-
|
|
144
|
-
// ❌ Breaks the property descriptors/getters of pageContext defined by getPageContextUrlComputed() such as pageContext.urlPathname
|
|
145
|
-
Object.assign(pageContext, pageContextUrlComputed)
|
|
146
|
-
|
|
147
|
-
// ❌ Also breaks property descriptors/getters
|
|
148
|
-
const pageContext = { ...pageContextUrlComputed }
|
|
149
|
-
|
|
150
|
-
// ✅ Preserves property descriptors/getters (see objectAssign() implementation)
|
|
151
|
-
objectAssign(pageContext, pageContextUrlComputed)
|
|
152
|
-
```
|
|
153
|
-
*/
|
|
154
|
-
if ('urlPathname' in pageContext) {
|
|
155
|
-
assert(typeof pageContext.urlPathname === 'string');
|
|
156
|
-
assert(isPropertyGetter(pageContext, 'urlPathname'));
|
|
157
|
-
assert(isPropertyGetter(pageContext, 'urlParsed'));
|
|
158
|
-
assert(isPropertyGetter(pageContext, 'url'));
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
assert(!('urlParsed' in pageContext));
|
|
162
|
-
assert(!('url' in pageContext));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { getProxyForPublicUsage };
|
|
2
|
+
export { getProxyForPublicUsageFlat };
|
|
3
|
+
export { getProxyForMutationTracking };
|
|
4
|
+
type Target = Record<string, unknown> & {
|
|
5
|
+
_onChange?: () => void;
|
|
6
|
+
_proxyTarget?: any;
|
|
7
|
+
_userMods?: any;
|
|
8
|
+
_proxyTargetPublic?: any;
|
|
9
|
+
};
|
|
10
|
+
declare function getProxyForPublicUsage<Obj extends Target>(obj: Obj, objName: string, skipOnInternalProp?: true): Obj;
|
|
11
|
+
declare function getProxyForPublicUsageFlat<Obj extends Target>(obj: Obj, objName: string, skipOnInternalProp?: true): Obj;
|
|
12
|
+
declare function getProxyForMutationTracking<Obj extends Target>(obj: Obj): Obj;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export { getProxyForPublicUsage };
|
|
2
|
+
export { getProxyForPublicUsageFlat };
|
|
3
|
+
export { getProxyForMutationTracking };
|
|
4
|
+
// We use a proxy instead of property getters.
|
|
5
|
+
// - 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.
|
|
6
|
+
// ```console
|
|
7
|
+
// TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>
|
|
8
|
+
// ```
|
|
9
|
+
// - Previous implementation using property getters: https://github.com/vikejs/vike/blob/main/vike/utils/makePublicCopy.ts
|
|
10
|
+
// Show warning when user is accessing internal `_` properties.
|
|
11
|
+
import { NOT_SERIALIZABLE } from './NOT_SERIALIZABLE.js';
|
|
12
|
+
import { assert, assertUsage, assertWarning, getPropAccessNotation, isBrowser, objectAssign, objectReplace } from './utils.js';
|
|
13
|
+
function getProxyForPublicUsage(obj, objName, skipOnInternalProp) {
|
|
14
|
+
return new Proxy(obj, {
|
|
15
|
+
get: getTrapGet(obj, objName, skipOnInternalProp)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function getProxyForPublicUsageFlat(obj, objName, skipOnInternalProp) {
|
|
19
|
+
assert(obj._isOriginalObject);
|
|
20
|
+
assert(obj._proxyTarget);
|
|
21
|
+
obj._proxyTargetPublic ?? (obj._proxyTargetPublic = {});
|
|
22
|
+
const target = obj._proxyTargetPublic;
|
|
23
|
+
obj._userMods ?? (obj._userMods = {});
|
|
24
|
+
const objUserMods = obj._userMods;
|
|
25
|
+
const update = () => {
|
|
26
|
+
assert(obj._proxyTarget);
|
|
27
|
+
objectReplace(target, obj._proxyTarget);
|
|
28
|
+
objectAssign(target, objUserMods);
|
|
29
|
+
};
|
|
30
|
+
obj._onChange = () => {
|
|
31
|
+
update();
|
|
32
|
+
};
|
|
33
|
+
update();
|
|
34
|
+
return new Proxy(target, {
|
|
35
|
+
// get: getTrapGet(target, objName, skipOnInternalProp),
|
|
36
|
+
set(_, prop, val) {
|
|
37
|
+
const ret = Reflect.set(objUserMods, prop, val);
|
|
38
|
+
update();
|
|
39
|
+
return ret;
|
|
40
|
+
},
|
|
41
|
+
defineProperty(_, ...args) {
|
|
42
|
+
const ret = Reflect.defineProperty(objUserMods, ...args);
|
|
43
|
+
update();
|
|
44
|
+
return ret;
|
|
45
|
+
},
|
|
46
|
+
deleteProperty(_, ...args) {
|
|
47
|
+
const ret = Reflect.deleteProperty(objUserMods, ...args);
|
|
48
|
+
update();
|
|
49
|
+
return ret;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function getTrapGet(obj, objName, skipOnInternalProp) {
|
|
54
|
+
return function (_, prop) {
|
|
55
|
+
const propStr = String(prop);
|
|
56
|
+
if (!skipOnInternalProp)
|
|
57
|
+
onInternalProp(propStr, objName);
|
|
58
|
+
const val = obj[prop];
|
|
59
|
+
onNotSerializable(propStr, val, objName);
|
|
60
|
+
return val;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function getProxyForMutationTracking(obj) {
|
|
64
|
+
objectAssign(obj, { _proxyTarget: obj });
|
|
65
|
+
return new Proxy(obj, {
|
|
66
|
+
set(...args) {
|
|
67
|
+
const ret = Reflect.set(...args);
|
|
68
|
+
obj._onChange?.();
|
|
69
|
+
return ret;
|
|
70
|
+
},
|
|
71
|
+
defineProperty(...args) {
|
|
72
|
+
const ret = Reflect.defineProperty(...args);
|
|
73
|
+
obj._onChange?.();
|
|
74
|
+
return ret;
|
|
75
|
+
},
|
|
76
|
+
deleteProperty(...args) {
|
|
77
|
+
const ret = Reflect.deleteProperty(...args);
|
|
78
|
+
obj._onChange?.();
|
|
79
|
+
return ret;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function onNotSerializable(propStr, val, objName) {
|
|
84
|
+
if (val !== NOT_SERIALIZABLE)
|
|
85
|
+
return;
|
|
86
|
+
const propName = getPropAccessNotation(propStr);
|
|
87
|
+
assert(isBrowser());
|
|
88
|
+
assertUsage(false, `Can't access ${objName}${propName} on the client side. Because it can't be serialized, see server logs.`);
|
|
89
|
+
}
|
|
90
|
+
function onInternalProp(propStr, objName) {
|
|
91
|
+
// - We must skip it in the client-side because of the reactivity mechanism of UI frameworks like Solid.
|
|
92
|
+
// - TO-DO/eventually: use import.meta.CLIENT instead of isBrowser()
|
|
93
|
+
// - Where import.meta.CLIENT is defined by Vike
|
|
94
|
+
// - Using import.meta.env.CLIENT (note `.env.`) doesn't seem possible: https://github.com/brillout/playground_node_import.meta.env
|
|
95
|
+
// - If Rolldown Vite + Rolldowns always transpiles node_modules/ then we can simply use import.meta.env.SSR
|
|
96
|
+
if (isBrowser())
|
|
97
|
+
return;
|
|
98
|
+
// TODO/now remove this and only warn on built-in access instead
|
|
99
|
+
if (propStr === '_configFromHook')
|
|
100
|
+
return;
|
|
101
|
+
if (propStr.startsWith('_')) {
|
|
102
|
+
assertWarning(false, `Using internal ${objName}.${propStr} which may break in any minor version update. Reach out on GitHub to request official support for your use case.`, { onlyOnce: true, showStackTrace: true });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export { execHook };
|
|
2
|
+
export { execHookSingle };
|
|
3
|
+
export { execHookSingleWithReturn };
|
|
4
|
+
export { execHookErrorHandling };
|
|
5
|
+
export { execHooksErrorHandling };
|
|
6
|
+
export { execHookWithoutPageContext };
|
|
7
|
+
export { execHookGlobal };
|
|
8
|
+
export { execHookSync };
|
|
9
|
+
export { getPageContext };
|
|
10
|
+
export { providePageContext };
|
|
11
|
+
export { isUserHookError };
|
|
12
|
+
export type { PageContextExecuteHook };
|
|
13
|
+
import type { PageContextClient, PageContextServer } from '../types.js';
|
|
14
|
+
import type { Hook, HookLoc } from './getHook.js';
|
|
15
|
+
import type { PageConfigUserFriendlyOld } from '../getPageFiles.js';
|
|
16
|
+
import type { HookName, HookNameGlobal } from '../page-configs/Config.js';
|
|
17
|
+
import type { PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
|
|
18
|
+
import type { PageContextForPublicUsageServer } from '../../node/runtime/renderPage/preparePageContextForPublicUsageServer.js';
|
|
19
|
+
import type { PageContextForPublicUsageClientShared } from '../../client/shared/preparePageContextForPublicUsageClientShared.js';
|
|
20
|
+
import { type PageContextPrepareMinimum } from '../preparePageContextForPublicUsage.js';
|
|
21
|
+
import type { GlobalContextPrepareMinimum } from '../prepareGlobalContextForPublicUsage.js';
|
|
22
|
+
type PageContextExecuteHook = PageConfigUserFriendlyOld & PageContextForPublicUsage;
|
|
23
|
+
type PageContextForPublicUsage = PageContextForPublicUsageServer | PageContextForPublicUsageClientShared;
|
|
24
|
+
type HookWithResult = Hook & {
|
|
25
|
+
hookReturn: unknown;
|
|
26
|
+
};
|
|
27
|
+
declare function execHookSingle<PageContext extends PageContextExecuteHook>(hook: Hook, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<void>;
|
|
28
|
+
declare function execHookSingleWithReturn<PageContext extends PageContextExecuteHook>(hook: Hook, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<{
|
|
29
|
+
hookReturn: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
declare function execHook<PageContext extends PageContextExecuteHook>(hookName: HookName, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<HookWithResult[]>;
|
|
32
|
+
declare function execHookErrorHandling<PageContext extends PageContextExecuteHook>(hookName: HookName, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<{
|
|
33
|
+
hooks: HookWithResult[];
|
|
34
|
+
err?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
hooks: Hook[];
|
|
37
|
+
err: unknown;
|
|
38
|
+
}>;
|
|
39
|
+
declare function execHooksErrorHandling<PageContext extends PageContextPrepareMinimum>(hooks: Hook[], pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<{
|
|
40
|
+
hooks: HookWithResult[];
|
|
41
|
+
err?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
hooks: Hook[];
|
|
44
|
+
err: unknown;
|
|
45
|
+
}>;
|
|
46
|
+
declare function execHookGlobal<HookArg extends PageContextPrepareMinimum | GlobalContextPrepareMinimum>(hookName: HookNameGlobal, pageConfigGlobal: PageConfigGlobalRuntime, pageContext: PageContextPrepareMinimum | null, hookArg: HookArg, prepareForPublicUsage: (hookArg: HookArg) => HookArg): Promise<void>;
|
|
47
|
+
declare function isUserHookError(err: unknown): false | HookLoc;
|
|
48
|
+
declare function execHookWithoutPageContext<HookReturn>(hookFnCaller: () => HookReturn, hook: Omit<Hook, 'hookFn'>): Promise<HookReturn>;
|
|
49
|
+
declare function execHookSync<PageContext extends PageContextPrepareMinimum>(hook: Omit<Hook, 'hookTimeout'>, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): {
|
|
50
|
+
hookReturn: unknown;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Access `pageContext` object inside Vike hooks, in order to create universal hooks.
|
|
54
|
+
*
|
|
55
|
+
* https://vike.dev/getPageContext
|
|
56
|
+
*/
|
|
57
|
+
declare function getPageContext<PageContext = PageContextClient | PageContextServer>(): null | PageContext;
|
|
58
|
+
/**
|
|
59
|
+
* Provide `pageContext` for universal hooks.
|
|
60
|
+
*
|
|
61
|
+
* https://vike.dev/getPageContext
|
|
62
|
+
*/
|
|
63
|
+
declare function providePageContext(pageContext: null | PageContextPrepareMinimum): void;
|