vike 0.4.232-commit-ec54a7e → 0.4.232-commit-1690f53
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/node/prerender/runPrerender.js +3 -3
- package/dist/cjs/node/runtime/renderPage/{executeOnBeforeRenderAndDataHooks.js → execHookDataAndOnBeforeRender.js} +2 -2
- package/dist/cjs/node/runtime/renderPage/{executeOnRenderHtmlHook.js → execHookOnRenderHtml.js} +3 -3
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +4 -4
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -11
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -2
- package/dist/cjs/shared/hooks/execHook.js +31 -54
- package/dist/cjs/shared/route/{executeGuardHook.js → execHookGuard.js} +3 -3
- package/dist/cjs/shared/route/{executeOnBeforeRouteHook.js → execHookOnBeforeRoute.js} +4 -4
- package/dist/cjs/shared/route/index.js +2 -2
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +9 -9
- package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +88 -65
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +4 -4
- package/dist/esm/client/runtime-server-routing/entry.js +2 -2
- package/dist/esm/client/shared/{executeOnRenderClientHook.d.ts → execHookOnRenderClient.d.ts} +2 -2
- package/dist/esm/client/shared/{executeOnRenderClientHook.js → execHookOnRenderClient.js} +4 -4
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +5 -7
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +6 -6
- package/dist/esm/node/prerender/runPrerender.js +5 -5
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/execHookDataAndOnBeforeRender.d.ts +6 -0
- package/dist/esm/node/runtime/renderPage/{executeOnBeforeRenderAndDataHooks.js → execHookDataAndOnBeforeRender.js} +2 -2
- package/dist/esm/node/runtime/renderPage/{executeOnRenderHtmlHook.d.ts → execHookOnRenderHtml.d.ts} +2 -2
- package/dist/esm/node/runtime/renderPage/{executeOnRenderHtmlHook.js → execHookOnRenderHtml.js} +4 -4
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +6 -6
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +4 -4
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +12 -12
- package/dist/esm/node/runtime/renderPage.js +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -2
- package/dist/esm/shared/hooks/execHook.d.ts +14 -29
- package/dist/esm/shared/hooks/execHook.js +31 -54
- package/dist/esm/shared/route/execHookGuard.d.ts +8 -0
- package/dist/esm/shared/route/{executeGuardHook.js → execHookGuard.js} +4 -4
- package/dist/esm/shared/route/{executeOnBeforeRouteHook.d.ts → execHookOnBeforeRoute.d.ts} +2 -2
- package/dist/esm/shared/route/{executeOnBeforeRouteHook.js → execHookOnBeforeRoute.js} +5 -5
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +0 -6
- package/dist/esm/shared/route/executeGuardHook.d.ts +0 -8
|
@@ -16,7 +16,7 @@ import pc from '@brillout/picocolors';
|
|
|
16
16
|
import { getPageContextClientSerializedAbort, getPageContextClientSerialized } from './html/serializeContext.js';
|
|
17
17
|
import { getErrorPageId } from '../../shared/error-page.js';
|
|
18
18
|
import { handleErrorWithoutErrorPage } from './renderPage/handleErrorWithoutErrorPage.js';
|
|
19
|
-
import {
|
|
19
|
+
import { loadPageConfigsLazyServerSideAndExecHook } from './renderPage/loadPageConfigsLazyServerSide.js';
|
|
20
20
|
import { resolveRedirects } from './renderPage/resolveRedirects.js';
|
|
21
21
|
import { getVikeConfigError } from '../shared/getVikeConfigError.js';
|
|
22
22
|
const globalObject = getGlobalObject('runtime/renderPage.ts', { httpRequestsCount: 0 });
|
|
@@ -419,7 +419,7 @@ pageContextNominalPageBegin, httpRequestId, pageContextErrorPageInit, globalCont
|
|
|
419
419
|
objectAssign(pageContext, { pageId: errorPageId });
|
|
420
420
|
objectAssign(pageContext, pageContextAbort);
|
|
421
421
|
objectAssign(pageContext, pageContextErrorPageInit, true);
|
|
422
|
-
augmentType(pageContext, await
|
|
422
|
+
augmentType(pageContext, await loadPageConfigsLazyServerSideAndExecHook(pageContext));
|
|
423
423
|
// We include pageContextInit: we don't only serialize pageContextAbort because the error page may need to access pageContextInit
|
|
424
424
|
pageContextSerialized = getPageContextClientSerialized(pageContext);
|
|
425
425
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export { execHook };
|
|
2
|
-
export { execHookSingle };
|
|
3
|
-
export { execHookSingleWithReturn };
|
|
4
|
-
export { execHookErrorHandling };
|
|
5
|
-
export { execHooksErrorHandling };
|
|
6
|
-
export { execHookWithoutPageContext };
|
|
7
2
|
export { execHookGlobal };
|
|
8
|
-
export {
|
|
3
|
+
export { execHookDirect };
|
|
4
|
+
export { execHookDirectSingle };
|
|
5
|
+
export { execHookDirectSingleWithReturn };
|
|
6
|
+
export { execHookDirectWithoutPageContext };
|
|
7
|
+
export { execHookDirectSync };
|
|
9
8
|
export { getPageContext };
|
|
10
9
|
export { providePageContext };
|
|
11
10
|
export { isUserHookError };
|
|
12
|
-
export type {
|
|
11
|
+
export type { PageContextExecHook };
|
|
13
12
|
import type { PageContextClient, PageContextServer } from '../../types/PageContext.js';
|
|
14
13
|
import type { Hook, HookLoc } from './getHook.js';
|
|
15
14
|
import type { VikeConfigPublicPageLazy } from '../getPageFiles.js';
|
|
@@ -19,35 +18,21 @@ import type { PageContextForPublicUsageServer } from '../../node/runtime/renderP
|
|
|
19
18
|
import type { PageContextForPublicUsageClientShared } from '../../client/shared/preparePageContextForPublicUsageClientShared.js';
|
|
20
19
|
import { type PageContextPrepareMinimum } from '../preparePageContextForPublicUsage.js';
|
|
21
20
|
import type { GlobalContextPrepareMinimum } from '../prepareGlobalContextForPublicUsage.js';
|
|
22
|
-
type
|
|
23
|
-
type PageContextExecuteHook = VikeConfigPublicPageLazy & PageContextForPublicUsage;
|
|
21
|
+
type PageContextExecHook = VikeConfigPublicPageLazy & PageContextForPublicUsage;
|
|
24
22
|
type PageContextForPublicUsage = PageContextForPublicUsageServer | PageContextForPublicUsageClientShared;
|
|
25
23
|
type HookWithResult = Hook & {
|
|
26
24
|
hookReturn: unknown;
|
|
27
25
|
};
|
|
28
|
-
declare function
|
|
29
|
-
declare function
|
|
26
|
+
declare function execHook<PageContext extends PageContextExecHook>(hookName: HookName, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<HookWithResult[]>;
|
|
27
|
+
declare function execHookGlobal<HookArg extends PageContextPrepareMinimum | GlobalContextPrepareMinimum>(hookName: HookNameGlobal, pageConfigGlobal: PageConfigGlobalRuntime, pageContext: PageContextPrepareMinimum | null, hookArg: HookArg, prepareForPublicUsage: (hookArg: HookArg) => HookArg): Promise<void>;
|
|
28
|
+
declare function execHookDirect<PageContext extends PageContextPrepareMinimum>(hooks: Hook[], pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<HookWithResult[]>;
|
|
29
|
+
declare function execHookDirectSingle<PageContext extends PageContextExecHook>(hook: Hook, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<void>;
|
|
30
|
+
declare function execHookDirectSingleWithReturn<PageContext extends PageContextExecHook>(hook: Hook, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<{
|
|
30
31
|
hookReturn: unknown;
|
|
31
32
|
}>;
|
|
32
|
-
declare function execHook<PageContext extends PageContextPrepareMinimum2>(hookName: HookName, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<HookWithResult[]>;
|
|
33
|
-
declare function execHookErrorHandling<PageContext extends PageContextPrepareMinimum2>(hookName: HookName, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<{
|
|
34
|
-
hooks: HookWithResult[];
|
|
35
|
-
err?: undefined;
|
|
36
|
-
} | {
|
|
37
|
-
hooks: Hook[];
|
|
38
|
-
err: unknown;
|
|
39
|
-
}>;
|
|
40
|
-
declare function execHooksErrorHandling<PageContext extends PageContextPrepareMinimum>(hooks: Hook[], pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): Promise<{
|
|
41
|
-
hooks: HookWithResult[];
|
|
42
|
-
err?: undefined;
|
|
43
|
-
} | {
|
|
44
|
-
hooks: Hook[];
|
|
45
|
-
err: unknown;
|
|
46
|
-
}>;
|
|
47
|
-
declare function execHookGlobal<HookArg extends PageContextPrepareMinimum | GlobalContextPrepareMinimum>(hookName: HookNameGlobal, pageConfigGlobal: PageConfigGlobalRuntime, pageContext: PageContextPrepareMinimum | null, hookArg: HookArg, prepareForPublicUsage: (hookArg: HookArg) => HookArg): Promise<void>;
|
|
48
33
|
declare function isUserHookError(err: unknown): false | HookLoc;
|
|
49
|
-
declare function
|
|
50
|
-
declare function
|
|
34
|
+
declare function execHookDirectWithoutPageContext<HookReturn>(hookFnCaller: () => HookReturn, hook: Omit<Hook, 'hookFn'>): Promise<HookReturn>;
|
|
35
|
+
declare function execHookDirectSync<PageContext extends PageContextPrepareMinimum>(hook: Omit<Hook, 'hookTimeout'>, pageContext: PageContext, preparePageContextForPublicUsage: (pageContext: PageContext) => PageContext): {
|
|
51
36
|
hookReturn: unknown;
|
|
52
37
|
};
|
|
53
38
|
/**
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export { execHook };
|
|
2
|
-
export { execHookSingle };
|
|
3
|
-
export { execHookSingleWithReturn };
|
|
4
|
-
export { execHookErrorHandling };
|
|
5
|
-
export { execHooksErrorHandling };
|
|
6
|
-
export { execHookWithoutPageContext };
|
|
7
2
|
export { execHookGlobal };
|
|
8
|
-
export {
|
|
3
|
+
export { execHookDirect };
|
|
4
|
+
export { execHookDirectSingle };
|
|
5
|
+
export { execHookDirectSingleWithReturn };
|
|
6
|
+
export { execHookDirectWithoutPageContext };
|
|
7
|
+
export { execHookDirectSync };
|
|
9
8
|
export { getPageContext };
|
|
10
9
|
export { providePageContext };
|
|
11
10
|
export { isUserHookError };
|
|
@@ -19,70 +18,48 @@ const globalObject = getGlobalObject('utils/execHook.ts', {
|
|
|
19
18
|
userHookErrors: new WeakMap(),
|
|
20
19
|
pageContext: null,
|
|
21
20
|
});
|
|
22
|
-
async function execHookSingle(hook, pageContext, preparePageContextForPublicUsage) {
|
|
23
|
-
const res = await execHooksErrorHandling([hook], pageContext, preparePageContextForPublicUsage);
|
|
24
|
-
if ('err' in res)
|
|
25
|
-
throw res.err;
|
|
26
|
-
const { hookReturn } = res.hooks[0];
|
|
27
|
-
assertUsage(hookReturn === undefined, `The ${hook.hookName}() hook defined by ${hook.hookFilePath} isn't allowed to return a value`);
|
|
28
|
-
}
|
|
29
|
-
async function execHookSingleWithReturn(hook, pageContext, preparePageContextForPublicUsage) {
|
|
30
|
-
const res = await execHooksErrorHandling([hook], pageContext, preparePageContextForPublicUsage);
|
|
31
|
-
if ('err' in res)
|
|
32
|
-
throw res.err;
|
|
33
|
-
const { hookReturn } = res.hooks[0];
|
|
34
|
-
return { hookReturn };
|
|
35
|
-
}
|
|
36
21
|
async function execHook(hookName, pageContext, preparePageContextForPublicUsage) {
|
|
37
|
-
const res = await execHookErrorHandling(hookName, pageContext, preparePageContextForPublicUsage);
|
|
38
|
-
if ('err' in res)
|
|
39
|
-
throw res.err;
|
|
40
|
-
return res.hooks;
|
|
41
|
-
}
|
|
42
|
-
async function execHookErrorHandling(hookName, pageContext, preparePageContextForPublicUsage) {
|
|
43
22
|
const hooks = getHookFromPageContextNew(hookName, pageContext);
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
async function execHooksErrorHandling(hooks, pageContext, preparePageContextForPublicUsage) {
|
|
47
|
-
if (!hooks.length)
|
|
48
|
-
return { hooks: [] };
|
|
49
|
-
const pageContextForPublicUsage = preparePageContextForPublicUsage(pageContext);
|
|
50
|
-
let hooksWithResult;
|
|
51
|
-
let err;
|
|
52
|
-
try {
|
|
53
|
-
hooksWithResult = await Promise.all(hooks.map(async (hook) => {
|
|
54
|
-
const hookReturn = await execHookAsync(() => hook.hookFn(pageContextForPublicUsage), hook, pageContextForPublicUsage);
|
|
55
|
-
return { ...hook, hookReturn };
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
58
|
-
catch (err_) {
|
|
59
|
-
err = err_;
|
|
60
|
-
}
|
|
61
|
-
if (hooksWithResult) {
|
|
62
|
-
return { hooks: hooksWithResult };
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
return { hooks, err };
|
|
66
|
-
}
|
|
23
|
+
return await execHookDirect(hooks, pageContext, preparePageContextForPublicUsage);
|
|
67
24
|
}
|
|
68
25
|
async function execHookGlobal(hookName, pageConfigGlobal, pageContext, hookArg, prepareForPublicUsage) {
|
|
69
26
|
const hooks = getHookFromPageConfigGlobalCumulative(pageConfigGlobal, hookName);
|
|
70
27
|
const hookArgForPublicUsage = prepareForPublicUsage(hookArg);
|
|
71
28
|
await Promise.all(hooks.map(async (hook) => {
|
|
72
|
-
await
|
|
29
|
+
await execHookDirectAsync(() => hook.hookFn(hookArgForPublicUsage), hook, pageContext);
|
|
73
30
|
}));
|
|
74
31
|
}
|
|
32
|
+
async function execHookDirect(hooks, pageContext, preparePageContextForPublicUsage) {
|
|
33
|
+
if (!hooks.length)
|
|
34
|
+
return [];
|
|
35
|
+
const pageContextForPublicUsage = preparePageContextForPublicUsage(pageContext);
|
|
36
|
+
const hooksWithResult = await Promise.all(hooks.map(async (hook) => {
|
|
37
|
+
const hookReturn = await execHookDirectAsync(() => hook.hookFn(pageContextForPublicUsage), hook, pageContextForPublicUsage);
|
|
38
|
+
return { ...hook, hookReturn };
|
|
39
|
+
}));
|
|
40
|
+
return hooksWithResult;
|
|
41
|
+
}
|
|
42
|
+
async function execHookDirectSingle(hook, pageContext, preparePageContextForPublicUsage) {
|
|
43
|
+
const hooksWithResult = await execHookDirect([hook], pageContext, preparePageContextForPublicUsage);
|
|
44
|
+
const { hookReturn } = hooksWithResult[0];
|
|
45
|
+
assertUsage(hookReturn === undefined, `The ${hook.hookName}() hook defined by ${hook.hookFilePath} isn't allowed to return a value`);
|
|
46
|
+
}
|
|
47
|
+
async function execHookDirectSingleWithReturn(hook, pageContext, preparePageContextForPublicUsage) {
|
|
48
|
+
const hooksWithResult = await execHookDirect([hook], pageContext, preparePageContextForPublicUsage);
|
|
49
|
+
const { hookReturn } = hooksWithResult[0];
|
|
50
|
+
return { hookReturn };
|
|
51
|
+
}
|
|
75
52
|
function isUserHookError(err) {
|
|
76
53
|
if (!isObject(err))
|
|
77
54
|
return false;
|
|
78
55
|
return globalObject.userHookErrors.get(err) ?? false;
|
|
79
56
|
}
|
|
80
|
-
async function
|
|
57
|
+
async function execHookDirectWithoutPageContext(hookFnCaller, hook) {
|
|
81
58
|
const { hookName, hookFilePath, hookTimeout } = hook;
|
|
82
|
-
const hookReturn = await
|
|
59
|
+
const hookReturn = await execHookDirectAsync(hookFnCaller, { hookName, hookFilePath, hookTimeout }, null);
|
|
83
60
|
return hookReturn;
|
|
84
61
|
}
|
|
85
|
-
function
|
|
62
|
+
function execHookDirectAsync(hookFnCaller, hook, pageContextForPublicUsage) {
|
|
86
63
|
const { hookName, hookFilePath, hookTimeout: { error: timeoutErr, warning: timeoutWarn }, } = hook;
|
|
87
64
|
let resolve;
|
|
88
65
|
let reject;
|
|
@@ -126,7 +103,7 @@ function execHookAsync(hookFnCaller, hook, pageContextForPublicUsage) {
|
|
|
126
103
|
})();
|
|
127
104
|
return promise;
|
|
128
105
|
}
|
|
129
|
-
function
|
|
106
|
+
function execHookDirectSync(hook, pageContext, preparePageContextForPublicUsage) {
|
|
130
107
|
const pageContextForPublicUsage = preparePageContextForPublicUsage(pageContext);
|
|
131
108
|
providePageContextInternal(pageContextForPublicUsage);
|
|
132
109
|
const hookReturn = hook.hookFn(pageContextForPublicUsage);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { execHookGuard };
|
|
2
|
+
import { type PageContextExecHook } from '../hooks/execHook.js';
|
|
3
|
+
import type { GlobalContextInternal } from '../createGlobalContextShared.js';
|
|
4
|
+
declare function execHookGuard<PageContext extends {
|
|
5
|
+
pageId: string;
|
|
6
|
+
} & {
|
|
7
|
+
_globalContext: GlobalContextInternal;
|
|
8
|
+
} & PageContextExecHook>(pageContext: PageContext, prepareForPublicUsage: (pageConfig: PageContext) => PageContext): Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { execHookGuard };
|
|
2
2
|
import { getHookFromPageContext, getHookTimeoutDefault } from '../hooks/getHook.js';
|
|
3
3
|
import { assert, assertUsage, isCallable } from './utils.js';
|
|
4
|
-
import {
|
|
4
|
+
import { execHookDirectSingle } from '../hooks/execHook.js';
|
|
5
5
|
const errIntro = 'The guard() hook defined by';
|
|
6
|
-
async function
|
|
6
|
+
async function execHookGuard(pageContext, prepareForPublicUsage) {
|
|
7
7
|
let hook;
|
|
8
8
|
if (pageContext._globalContext._pageFilesAll.length > 0) {
|
|
9
9
|
// TODO/v1-release: remove
|
|
@@ -17,7 +17,7 @@ async function executeGuardHook(pageContext, prepareForPublicUsage) {
|
|
|
17
17
|
}
|
|
18
18
|
if (!hook)
|
|
19
19
|
return;
|
|
20
|
-
await
|
|
20
|
+
await execHookDirectSingle(hook, pageContext, prepareForPublicUsage);
|
|
21
21
|
}
|
|
22
22
|
function findPageGuard(pageId, pageFilesAll) {
|
|
23
23
|
const pageRouteFile = pageFilesAll.find((p) => p.pageId === pageId && p.fileType === '.page.route');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { execHookOnBeforeRoute };
|
|
2
2
|
import type { PageContextForRoute, PageContextFromRoute } from './index.js';
|
|
3
|
-
declare function
|
|
3
|
+
declare function execHookOnBeforeRoute(pageContext: PageContextForRoute): Promise<null | ({
|
|
4
4
|
_routingProvidedByOnBeforeRouteHook: true;
|
|
5
5
|
} & PageContextFromRoute) | {
|
|
6
6
|
_routingProvidedByOnBeforeRouteHook: false;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { execHookOnBeforeRoute };
|
|
2
2
|
import { assertPageContextProvidedByUser } from '../assertPageContextProvidedByUser.js';
|
|
3
3
|
import { assertUsage, hasProp, isObjectWithKeys, objectAssign, assertWarning, assertUsageUrlPathnameAbsolute, joinEnglish, assert, } from './utils.js';
|
|
4
4
|
import { assertRouteParams, assertSyncRouting } from './resolveRouteFunction.js';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
6
|
-
import {
|
|
6
|
+
import { execHookDirectSync } from '../hooks/execHook.js';
|
|
7
7
|
import { preparePageContextForPublicUsage, } from '../preparePageContextForPublicUsage.js';
|
|
8
|
-
async function
|
|
8
|
+
async function execHookOnBeforeRoute(pageContext) {
|
|
9
9
|
const pageContextFromOnBeforeRouteHook = {};
|
|
10
10
|
if (!pageContext._globalContext._onBeforeRouteHook)
|
|
11
11
|
return null;
|
|
@@ -34,9 +34,9 @@ async function executeOnBeforeRouteHook(pageContext) {
|
|
|
34
34
|
return pageContextFromOnBeforeRouteHook;
|
|
35
35
|
}
|
|
36
36
|
async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
37
|
-
let { hookReturn } =
|
|
37
|
+
let { hookReturn } = execHookDirectSync(onBeforeRouteHook, pageContext, preparePageContextForPublicUsage);
|
|
38
38
|
assertSyncRouting(hookReturn, `The onBeforeRoute() hook ${onBeforeRouteHook.hookFilePath}`);
|
|
39
|
-
// TODO/v1-release: make
|
|
39
|
+
// TODO/v1-release: make execHookOnBeforeRoute() and route() sync
|
|
40
40
|
hookReturn = await hookReturn;
|
|
41
41
|
const errPrefix = `The onBeforeRoute() hook defined by ${onBeforeRouteHook.hookFilePath}`;
|
|
42
42
|
assertUsage(hookReturn === null ||
|
|
@@ -9,7 +9,7 @@ import { assert, assertUsage, isPlainObject, objectAssign } from './utils.js';
|
|
|
9
9
|
import { resolvePrecedence } from './resolvePrecedence.js';
|
|
10
10
|
import { resolveRouteString } from './resolveRouteString.js';
|
|
11
11
|
import { resolveRouteFunction } from './resolveRouteFunction.js';
|
|
12
|
-
import {
|
|
12
|
+
import { execHookOnBeforeRoute } from './execHookOnBeforeRoute.js';
|
|
13
13
|
import { debug } from './debug.js';
|
|
14
14
|
import pc from '@brillout/picocolors';
|
|
15
15
|
// TODO/next-major-release: make it sync
|
|
@@ -18,7 +18,7 @@ async function route(pageContext, skipOnBeforeRouteHook) {
|
|
|
18
18
|
const pageContextFromRoute = {};
|
|
19
19
|
// onBeforeRoute()
|
|
20
20
|
if (!skipOnBeforeRouteHook) {
|
|
21
|
-
const pageContextFromOnBeforeRouteHook = await
|
|
21
|
+
const pageContextFromOnBeforeRouteHook = await execHookOnBeforeRoute(pageContext);
|
|
22
22
|
if (pageContextFromOnBeforeRouteHook) {
|
|
23
23
|
if (pageContextFromOnBeforeRouteHook._routingProvidedByOnBeforeRouteHook) {
|
|
24
24
|
assert(pageContextFromOnBeforeRouteHook.pageId);
|
|
@@ -2,12 +2,12 @@ export { resolveRouteFunction };
|
|
|
2
2
|
export { assertRouteParams };
|
|
3
3
|
export { assertSyncRouting };
|
|
4
4
|
export { warnDeprecatedAllowKey };
|
|
5
|
-
import {
|
|
5
|
+
import { execHookDirectSync } from '../hooks/execHook.js';
|
|
6
6
|
import { preparePageContextForPublicUsage } from '../preparePageContextForPublicUsage.js';
|
|
7
7
|
import { assert, assertUsage, assertWarning, hasProp, isPlainObject, isPromise } from './utils.js';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
async function resolveRouteFunction(routeFunction, pageContext, routeFunctionFilePath) {
|
|
10
|
-
let { hookReturn: result } =
|
|
10
|
+
let { hookReturn: result } = execHookDirectSync({
|
|
11
11
|
hookFn: routeFunction,
|
|
12
12
|
hookFilePath: routeFunctionFilePath,
|
|
13
13
|
hookName: 'route',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.232-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.232-commit-1690f53";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.232-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.232-commit-1690f53';
|
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { executeOnBeforeRenderAndDataHooks };
|
|
2
|
-
import { type PageContextExecuteHookServer } from './execHookServer.js';
|
|
3
|
-
declare function executeOnBeforeRenderAndDataHooks(pageContext: {
|
|
4
|
-
pageId: string;
|
|
5
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
6
|
-
} & PageContextExecuteHookServer): Promise<void>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { executeGuardHook };
|
|
2
|
-
import { type PageContextExecuteHook } from '../hooks/execHook.js';
|
|
3
|
-
import type { GlobalContextInternal } from '../createGlobalContextShared.js';
|
|
4
|
-
declare function executeGuardHook<PageContext extends {
|
|
5
|
-
pageId: string;
|
|
6
|
-
} & {
|
|
7
|
-
_globalContext: GlobalContextInternal;
|
|
8
|
-
} & PageContextExecuteHook>(pageContext: PageContext, prepareForPublicUsage: (pageConfig: PageContext) => PageContext): Promise<void>;
|