vike 0.4.229-commit-845a4e0 → 0.4.229-commit-7056ef0
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/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +12 -6
- package/dist/cjs/node/prerender/runPrerender.js +2 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +7 -5
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -1
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +2 -1
- package/dist/cjs/node/runtime/renderPage/executeHookServer.js +11 -0
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +8 -16
- package/dist/cjs/node/runtime/renderPage/{loadUserFilesServerSide.js → loadPageConfigsLazyServerSide.js} +4 -4
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/cjs/node/runtime/renderPage.js +2 -2
- package/dist/cjs/shared/createGlobalContextShared.js +33 -7
- package/dist/cjs/shared/createPageContextShared.js +5 -11
- package/dist/cjs/shared/hooks/executeHook.js +21 -0
- package/dist/cjs/shared/hooks/getHook.js +23 -4
- package/dist/cjs/shared/page-configs/{getPageConfigUserFriendly.js → getUserFriendlyConfigs.js} +37 -32
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/client/client-routing-runtime/{createPageContext.d.ts → createPageContextClientSide.d.ts} +11 -6
- package/dist/esm/client/client-routing-runtime/{createPageContext.js → createPageContextClientSide.js} +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +15 -7
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +38 -46
- package/dist/esm/client/client-routing-runtime/globalContext.d.ts +10 -1
- package/dist/esm/client/client-routing-runtime/prefetch.js +3 -3
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +14 -22
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.d.ts +12 -8
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +7 -16
- package/dist/esm/client/server-routing-runtime/entry.js +5 -3
- package/dist/esm/client/server-routing-runtime/globalContext.d.ts +10 -1
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +10 -1
- 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/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -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 -6
- package/dist/esm/node/prerender/runPrerender.d.ts +82 -18
- package/dist/esm/node/prerender/runPrerender.js +2 -2
- package/dist/esm/node/runtime/globalContext.d.ts +181 -18
- 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.js +0 -1
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +41 -9
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -1
- package/dist/esm/node/runtime/renderPage/executeHookServer.d.ts +13 -0
- package/dist/esm/node/runtime/renderPage/executeHookServer.js +9 -0
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -3
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +8 -16
- 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/preparePageContextForUserConsumptionServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +84 -20
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -2
- package/dist/esm/node/runtime/renderPage.d.ts +41 -9
- package/dist/esm/node/runtime/renderPage.js +2 -2
- package/dist/esm/shared/createGlobalContextShared.d.ts +26 -6
- package/dist/esm/shared/createGlobalContextShared.js +33 -7
- package/dist/esm/shared/createPageContextShared.d.ts +3 -6
- package/dist/esm/shared/createPageContextShared.js +5 -11
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/executeHook.d.ts +14 -1
- package/dist/esm/shared/hooks/executeHook.js +21 -0
- package/dist/esm/shared/hooks/getHook.d.ts +7 -10
- package/dist/esm/shared/hooks/getHook.js +23 -4
- package/dist/esm/shared/page-configs/Config.d.ts +4 -2
- package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.d.ts → getUserFriendlyConfigs.d.ts} +8 -6
- package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.js → getUserFriendlyConfigs.js} +37 -32
- package/dist/esm/shared/types.d.ts +1 -1
- 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/package.json +1 -1
- package/dist/cjs/shared/getPageConfigsRuntime.js +0 -23
- package/dist/cjs/shared/hooks/executeHookGeneric.js +0 -18
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +0 -14
- package/dist/esm/shared/getPageConfigsRuntime.js +0 -21
- package/dist/esm/shared/hooks/executeHookGeneric.d.ts +0 -8
- package/dist/esm/shared/hooks/executeHookGeneric.js +0 -16
|
@@ -2,6 +2,8 @@ export { createGlobalContextShared };
|
|
|
2
2
|
export { getGlobalContextSyncErrMsg };
|
|
3
3
|
export type { GlobalContextShared };
|
|
4
4
|
export type { GlobalContextSharedPublic };
|
|
5
|
+
import type { PageFile } from './getPageFiles.js';
|
|
6
|
+
import type { PageConfigRuntime } from './page-configs/PageConfig.js';
|
|
5
7
|
declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
6
8
|
declare function createGlobalContextShared<GlobalContextAddendum extends object>(virtualFileExports: unknown, globalObject: {
|
|
7
9
|
globalContext?: Record<string, unknown>;
|
|
@@ -13,12 +15,21 @@ declare function createGlobalContextShared<GlobalContextAddendum extends object>
|
|
|
13
15
|
*/
|
|
14
16
|
isGlobalContext: true;
|
|
15
17
|
_virtualFileExports: unknown;
|
|
16
|
-
_pageFilesAll:
|
|
17
|
-
_pageConfigs:
|
|
18
|
+
_pageFilesAll: PageFile[];
|
|
19
|
+
_pageConfigs: PageConfigRuntime[];
|
|
18
20
|
_pageConfigGlobal: import("./page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
19
21
|
_allPageIds: string[];
|
|
22
|
+
_userFriendlyConfigsGlobal: import("./page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly;
|
|
20
23
|
config: import("./page-configs/Config/PageContextConfig.js").ConfigResolved;
|
|
21
|
-
pages:
|
|
24
|
+
pages: {
|
|
25
|
+
[k: string]: import("./page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly & ({
|
|
26
|
+
route: import("./page-configs/Config.js").Route;
|
|
27
|
+
isErrorPage?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
route?: undefined;
|
|
30
|
+
isErrorPage: true;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
22
33
|
} & Awaited<GlobalContextAddendum>>;
|
|
23
34
|
type GlobalContextSharedPublic = Pick<GlobalContextShared, 'config' | 'pages' | 'isGlobalContext'>;
|
|
24
35
|
type GlobalContextShared = ReturnType<typeof createGlobalContextBase>;
|
|
@@ -30,10 +41,19 @@ declare function createGlobalContextBase(virtualFileExports: unknown): {
|
|
|
30
41
|
*/
|
|
31
42
|
isGlobalContext: true;
|
|
32
43
|
_virtualFileExports: unknown;
|
|
33
|
-
_pageFilesAll:
|
|
34
|
-
_pageConfigs:
|
|
44
|
+
_pageFilesAll: PageFile[];
|
|
45
|
+
_pageConfigs: PageConfigRuntime[];
|
|
35
46
|
_pageConfigGlobal: import("./page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
36
47
|
_allPageIds: string[];
|
|
48
|
+
_userFriendlyConfigsGlobal: import("./page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly;
|
|
37
49
|
config: import("./page-configs/Config/PageContextConfig.js").ConfigResolved;
|
|
38
|
-
pages:
|
|
50
|
+
pages: {
|
|
51
|
+
[k: string]: import("./page-configs/getUserFriendlyConfigs.js").PageConfigUserFriendly & ({
|
|
52
|
+
route: import("./page-configs/Config.js").Route;
|
|
53
|
+
isErrorPage?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
route?: undefined;
|
|
56
|
+
isErrorPage: true;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
39
59
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { createGlobalContextShared };
|
|
2
2
|
export { getGlobalContextSyncErrMsg };
|
|
3
|
+
import { objectAssign, unique } from './utils.js';
|
|
4
|
+
import { parseGlobResults } from './getPageFiles/parseGlobResults.js';
|
|
5
|
+
import { getUserFriendlyConfigsGlobal, getUserFriendlyConfigsPageEager } from './page-configs/getUserFriendlyConfigs.js';
|
|
6
|
+
import { executeHookGlobalCumulative } from './hooks/executeHook.js';
|
|
3
7
|
const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
|
|
4
|
-
import { getPageConfigsRuntime } from './getPageConfigsRuntime.js';
|
|
5
|
-
import { executeHookGenericGlobalCumulative } from './hooks/executeHookGeneric.js';
|
|
6
|
-
import { objectAssign } from './utils.js';
|
|
7
8
|
async function createGlobalContextShared(virtualFileExports, globalObject, addGlobalContext) {
|
|
8
9
|
const globalContext = createGlobalContextBase(virtualFileExports);
|
|
9
10
|
const globalContextAddendum = await addGlobalContext?.(globalContext);
|
|
@@ -21,7 +22,7 @@ async function createGlobalContextShared(virtualFileExports, globalObject, addGl
|
|
|
21
22
|
// - globalContext._viteDevServer.hot.send()
|
|
22
23
|
// - 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.
|
|
23
24
|
// - Seems less idiomatic
|
|
24
|
-
await
|
|
25
|
+
await executeHookGlobalCumulative('onCreateGlobalContext', globalContext._pageConfigGlobal, null, globalContext);
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
28
|
// Singleton: ensure all `globalContext` user-land references are preserved & updated.
|
|
@@ -31,7 +32,7 @@ async function createGlobalContextShared(virtualFileExports, globalObject, addGl
|
|
|
31
32
|
return globalObject.globalContext;
|
|
32
33
|
}
|
|
33
34
|
function createGlobalContextBase(virtualFileExports) {
|
|
34
|
-
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal,
|
|
35
|
+
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, userFriendlyConfigsGlobal, userFriendlyConfigsPageEager } = getConfigsAll(virtualFileExports);
|
|
35
36
|
const globalContext = {
|
|
36
37
|
/**
|
|
37
38
|
* Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
|
|
@@ -44,8 +45,33 @@ function createGlobalContextBase(virtualFileExports) {
|
|
|
44
45
|
_pageConfigs: pageConfigs,
|
|
45
46
|
_pageConfigGlobal: pageConfigGlobal,
|
|
46
47
|
_allPageIds: allPageIds,
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
_userFriendlyConfigsGlobal: userFriendlyConfigsGlobal,
|
|
49
|
+
config: userFriendlyConfigsGlobal.config,
|
|
50
|
+
pages: userFriendlyConfigsPageEager
|
|
49
51
|
};
|
|
50
52
|
return globalContext;
|
|
51
53
|
}
|
|
54
|
+
function getConfigsAll(virtualFileExports) {
|
|
55
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = parseGlobResults(virtualFileExports);
|
|
56
|
+
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
57
|
+
const userFriendlyConfigsGlobal = getUserFriendlyConfigsGlobal({
|
|
58
|
+
pageConfigGlobalValues: pageConfigGlobal.configValues
|
|
59
|
+
});
|
|
60
|
+
const userFriendlyConfigsPageEager = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
61
|
+
return getUserFriendlyConfigsPageEager(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
|
|
62
|
+
}));
|
|
63
|
+
return {
|
|
64
|
+
pageFilesAll,
|
|
65
|
+
allPageIds,
|
|
66
|
+
pageConfigs,
|
|
67
|
+
pageConfigGlobal,
|
|
68
|
+
userFriendlyConfigsGlobal,
|
|
69
|
+
userFriendlyConfigsPageEager
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function getAllPageIds(pageFilesAll, pageConfigs) {
|
|
73
|
+
const fileIds = pageFilesAll.filter(({ isDefaultPageFile }) => !isDefaultPageFile).map(({ pageId }) => pageId);
|
|
74
|
+
const allPageIds = unique(fileIds);
|
|
75
|
+
const allPageIds2 = pageConfigs.map((p) => p.pageId);
|
|
76
|
+
return [...allPageIds, ...allPageIds2];
|
|
77
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export { createPageContextShared };
|
|
2
|
+
import type { PageConfigUserFriendly } from './page-configs/getUserFriendlyConfigs.js';
|
|
2
3
|
import type { PageConfigGlobalRuntime } from './page-configs/PageConfig.js';
|
|
3
|
-
declare function createPageContextShared<T extends object>(pageContextCreated: T, pageConfigGlobal: PageConfigGlobalRuntime): Promise<T & {
|
|
4
|
-
config: import("./page-configs/Config/PageContextConfig.js").ConfigResolved;
|
|
5
|
-
_source: import("./page-configs/getPageConfigUserFriendly.js").Source;
|
|
6
|
-
_sources: import("./page-configs/getPageConfigUserFriendly.js").Sources;
|
|
7
|
-
_from: import("./page-configs/getPageConfigUserFriendly.js").From;
|
|
4
|
+
declare function createPageContextShared<T extends object>(pageContextCreated: T, pageConfigGlobal: PageConfigGlobalRuntime, userFriendlyConfigsGlobal: PageConfigUserFriendly): Promise<T & {
|
|
8
5
|
isPageContext: true;
|
|
9
|
-
}>;
|
|
6
|
+
} & PageConfigUserFriendly>;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
export { createPageContextShared };
|
|
2
|
-
import {
|
|
3
|
-
import { getPageConfigGlobalUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
|
|
2
|
+
import { executeHookGlobalCumulative } from './hooks/executeHook.js';
|
|
4
3
|
import { objectAssign } from './utils.js';
|
|
5
|
-
async function createPageContextShared(pageContextCreated, pageConfigGlobal) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
objectAssign(pageContextCreated, {
|
|
10
|
-
isPageContext: true,
|
|
11
|
-
...pageConfigGlobalUserFriendly
|
|
12
|
-
}, true);
|
|
13
|
-
await executeHookGenericGlobalCumulative('onCreatePageContext', pageConfigGlobal, pageContextCreated, pageContextCreated);
|
|
4
|
+
async function createPageContextShared(pageContextCreated, pageConfigGlobal, userFriendlyConfigsGlobal) {
|
|
5
|
+
objectAssign(pageContextCreated, { isPageContext: true }, true);
|
|
6
|
+
objectAssign(pageContextCreated, userFriendlyConfigsGlobal);
|
|
7
|
+
await executeHookGlobalCumulative('onCreatePageContext', pageConfigGlobal, pageContextCreated, pageContextCreated);
|
|
14
8
|
return pageContextCreated;
|
|
15
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { PageFile } from './getPageFiles/getPageFileObject.js';
|
|
2
|
-
export type { ExportsAll, PageConfigUserFriendlyOld } from './page-configs/
|
|
2
|
+
export type { ExportsAll, PageConfigUserFriendlyOld } from './page-configs/getUserFriendlyConfigs.js';
|
|
3
3
|
export { getPageFilesClientSide } from './getPageFiles/getAllPageIdFiles.js';
|
|
4
4
|
export { getPageFilesServerSide } from './getPageFiles/getAllPageIdFiles.js';
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
export { executeHook };
|
|
2
|
+
export { executeHookNew };
|
|
3
|
+
export { executeHookGlobalCumulative };
|
|
2
4
|
export { getPageContext };
|
|
3
5
|
export { providePageContext };
|
|
4
6
|
export { isUserHookError };
|
|
5
7
|
import type { PageContextClient, PageContextServer } from '../types.js';
|
|
6
8
|
import type { Hook, HookLoc } from './getHook.js';
|
|
7
|
-
type
|
|
9
|
+
import type { PageConfigUserFriendlyOld } from '../getPageFiles.js';
|
|
10
|
+
import type { HookName, HookNameGlobal } from '../page-configs/Config.js';
|
|
11
|
+
import type { PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
|
|
12
|
+
declare function executeHookNew<PageContext extends PageConfigUserFriendlyOld>(hookName: HookName, pageContext: PageContext, prepare: (pageContext: PageContext) => PageContext): Promise<{
|
|
13
|
+
hookResult: unknown;
|
|
14
|
+
hookName: import("../page-configs/Config.js").HookNameOld;
|
|
15
|
+
hookFilePath: string;
|
|
16
|
+
hookFn: (arg: object) => unknown;
|
|
17
|
+
hookTimeout: import("./getHook.js").HookTimeout;
|
|
18
|
+
}[]>;
|
|
19
|
+
declare function executeHookGlobalCumulative(hookName: HookNameGlobal, pageConfigGlobal: PageConfigGlobalRuntime, pageContext: PageContextUnknown | null, arg: object): Promise<void>;
|
|
20
|
+
type PageContextUnknown = null | Record<string, unknown>;
|
|
8
21
|
declare function isUserHookError(err: unknown): false | HookLoc;
|
|
9
22
|
declare function executeHook<T = unknown>(hookFnCaller: () => T, hook: Omit<Hook, 'hookFn'>, pageContext: PageContextUnknown): Promise<T>;
|
|
10
23
|
/**
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { executeHook };
|
|
2
|
+
export { executeHookNew };
|
|
3
|
+
export { executeHookGlobalCumulative };
|
|
2
4
|
export { getPageContext };
|
|
3
5
|
export { providePageContext };
|
|
4
6
|
export { isUserHookError };
|
|
@@ -6,10 +8,29 @@ import { getProjectError, assertWarning } from '../../utils/assert.js';
|
|
|
6
8
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
7
9
|
import { humanizeTime } from '../../utils/humanizeTime.js';
|
|
8
10
|
import { isObject } from '../../utils/isObject.js';
|
|
11
|
+
import { getHookFromPageConfigGlobalCumulative, getHookFromPageContextNew } from './getHook.js';
|
|
9
12
|
const globalObject = getGlobalObject('utils/executeHook.ts', {
|
|
10
13
|
userHookErrors: new WeakMap(),
|
|
11
14
|
pageContext: null
|
|
12
15
|
});
|
|
16
|
+
// TO-DO/eventually: use this variant more prominently
|
|
17
|
+
async function executeHookNew(hookName, pageContext, prepare) {
|
|
18
|
+
const hooks = getHookFromPageContextNew(hookName, pageContext);
|
|
19
|
+
if (!hooks.length)
|
|
20
|
+
return [];
|
|
21
|
+
const pageContextPrepared = prepare(pageContext);
|
|
22
|
+
const hooksWithResult = await Promise.all(hooks.map(async (hook) => {
|
|
23
|
+
const hookResult = await executeHook(() => hook.hookFn(pageContextPrepared), hook, pageContext);
|
|
24
|
+
return { ...hook, hookResult };
|
|
25
|
+
}));
|
|
26
|
+
return hooksWithResult;
|
|
27
|
+
}
|
|
28
|
+
async function executeHookGlobalCumulative(hookName, pageConfigGlobal, pageContext, arg) {
|
|
29
|
+
const hooks = getHookFromPageConfigGlobalCumulative(pageConfigGlobal, hookName);
|
|
30
|
+
await Promise.all(hooks.map(async (hook) => {
|
|
31
|
+
await executeHook(() => hook.hookFn(arg), hook, pageContext);
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
13
34
|
function isUserHookError(err) {
|
|
14
35
|
if (!isObject(err))
|
|
15
36
|
return false;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
export { getHookFromPageContext };
|
|
2
|
+
export { getHookFromPageContextNew };
|
|
2
3
|
export { getHookFromPageConfig };
|
|
3
4
|
export { getHookFromPageConfigGlobal };
|
|
4
5
|
export { getHookFromPageConfigGlobalCumulative };
|
|
5
|
-
export { assertHook };
|
|
6
6
|
export { getHook_setIsPrerenderering };
|
|
7
7
|
export type { Hook };
|
|
8
|
-
export type { HookName };
|
|
9
8
|
export type { HookLoc };
|
|
10
9
|
export type { HookTimeout };
|
|
11
10
|
export type { HooksTimeoutProvidedByUser };
|
|
12
11
|
export { getHookTimeoutDefault };
|
|
13
12
|
import type { PageConfigUserFriendlyOld } from '../getPageFiles.js';
|
|
14
|
-
import type {
|
|
13
|
+
import type { HookNameOld, HookNamePage, HookNameGlobal, HookName } from '../page-configs/Config.js';
|
|
15
14
|
import type { PageConfigGlobalRuntime, PageConfigRuntime } from '../page-configs/PageConfig.js';
|
|
16
15
|
type Hook = HookLoc & {
|
|
17
16
|
hookFn: HookFn;
|
|
18
17
|
hookTimeout: HookTimeout;
|
|
19
18
|
};
|
|
20
19
|
type HookLoc = {
|
|
21
|
-
hookName:
|
|
20
|
+
hookName: HookNameOld;
|
|
22
21
|
hookFilePath: string;
|
|
23
22
|
};
|
|
24
23
|
type HookFn = (arg: object) => unknown;
|
|
@@ -26,13 +25,11 @@ type HookTimeout = {
|
|
|
26
25
|
error: number | false;
|
|
27
26
|
warning: number | false;
|
|
28
27
|
};
|
|
29
|
-
type HooksTimeoutProvidedByUser = false | Partial<Record<
|
|
30
|
-
declare function getHookFromPageContext(pageContext: PageConfigUserFriendlyOld, hookName:
|
|
28
|
+
type HooksTimeoutProvidedByUser = false | Partial<Record<HookNameOld, false | Partial<HookTimeout>>>;
|
|
29
|
+
declare function getHookFromPageContext(pageContext: PageConfigUserFriendlyOld, hookName: HookNameOld): null | Hook;
|
|
30
|
+
declare function getHookFromPageContextNew(hookName: HookName, pageContext: PageConfigUserFriendlyOld): Hook[];
|
|
31
31
|
declare function getHookFromPageConfig(pageConfig: PageConfigRuntime, hookName: HookNamePage): null | Hook;
|
|
32
32
|
declare function getHookFromPageConfigGlobal(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): null | Hook;
|
|
33
33
|
declare function getHookFromPageConfigGlobalCumulative(pageConfigGlobal: PageConfigGlobalRuntime, hookName: HookNameGlobal): Hook[];
|
|
34
|
-
declare function
|
|
35
|
-
exports: Record<THookName, Function | undefined>;
|
|
36
|
-
};
|
|
37
|
-
declare function getHookTimeoutDefault(hookName: HookName): HookTimeout;
|
|
34
|
+
declare function getHookTimeoutDefault(hookName: HookNameOld): HookTimeout;
|
|
38
35
|
declare function getHook_setIsPrerenderering(): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { getHookFromPageContext };
|
|
2
|
+
export { getHookFromPageContextNew };
|
|
2
3
|
export { getHookFromPageConfig };
|
|
3
4
|
export { getHookFromPageConfigGlobal };
|
|
4
5
|
export { getHookFromPageConfigGlobalCumulative };
|
|
5
|
-
export { assertHook };
|
|
6
6
|
export { getHook_setIsPrerenderering };
|
|
7
7
|
// TODO/v1-release: remove
|
|
8
8
|
// We export for old V0.4 design which doesn't support config.hooksTimeout
|
|
@@ -22,12 +22,34 @@ function getHookFromPageContext(pageContext, hookName) {
|
|
|
22
22
|
const hookFn = pageContext.exports[hookName];
|
|
23
23
|
if (hookFn === null)
|
|
24
24
|
return null;
|
|
25
|
+
// TO-DO/eventually: use pageContext.configEntries in favor of pageContext.exportsAll once V0.4 is removed
|
|
25
26
|
const file = pageContext.exportsAll[hookName][0];
|
|
26
27
|
assert(file.exportValue === hookFn);
|
|
27
28
|
const hookFilePath = file.filePath;
|
|
28
29
|
assert(hookFilePath);
|
|
29
30
|
return getHook(hookFn, hookName, hookFilePath, hookTimeout);
|
|
30
31
|
}
|
|
32
|
+
// TO-DO/eventually: remove getHookFromPageContext() in favor of getHookFromPageContextNew()
|
|
33
|
+
function getHookFromPageContextNew(hookName, pageContext) {
|
|
34
|
+
const { hooksTimeout } = pageContext.config;
|
|
35
|
+
const hookTimeout = getHookTimeout(hooksTimeout, hookName);
|
|
36
|
+
const hooks = [];
|
|
37
|
+
/* TO-DO/eventually: use pageContext.configEntries in favor of pageContext.exportsAll once V0.4 is removed
|
|
38
|
+
pageContext.configEntries[hookName]?.forEach((val) => {
|
|
39
|
+
const hookFn = val.configValue
|
|
40
|
+
if (hookFn === null) return
|
|
41
|
+
const hookFilePath = val.configDefinedByFile
|
|
42
|
+
*/
|
|
43
|
+
pageContext.exportsAll[hookName]?.forEach((val) => {
|
|
44
|
+
const hookFn = val.exportValue;
|
|
45
|
+
if (hookFn === null)
|
|
46
|
+
return;
|
|
47
|
+
const hookFilePath = val.filePath;
|
|
48
|
+
assert(hookFilePath);
|
|
49
|
+
hooks.push(getHook(hookFn, hookName, hookFilePath, hookTimeout));
|
|
50
|
+
});
|
|
51
|
+
return hooks;
|
|
52
|
+
}
|
|
31
53
|
function getHookFromPageConfig(pageConfig, hookName) {
|
|
32
54
|
const configValue = getConfigValueRuntime(pageConfig, hookName);
|
|
33
55
|
if (!configValue?.value)
|
|
@@ -76,9 +98,6 @@ function getHookFromConfigValue(configValue) {
|
|
|
76
98
|
const hookFilePath = getHookFilePathToShowToUser(configValue.definedAtData);
|
|
77
99
|
return { hookFn, hookFilePath };
|
|
78
100
|
}
|
|
79
|
-
function assertHook(pageContext, hookName) {
|
|
80
|
-
getHookFromPageContext(pageContext, hookName);
|
|
81
|
-
}
|
|
82
101
|
function assertHookFn(hookFn, { hookName, hookFilePath }) {
|
|
83
102
|
assert(hookName && hookFilePath);
|
|
84
103
|
assert(!hookName.endsWith(')'));
|
|
@@ -5,6 +5,7 @@ export type { ConfigNameBuiltIn };
|
|
|
5
5
|
export type { ConfigNameGlobal };
|
|
6
6
|
export type { ConfigMeta };
|
|
7
7
|
export type { HookName };
|
|
8
|
+
export type { HookNameOld };
|
|
8
9
|
export type { HookNamePage };
|
|
9
10
|
export type { HookNameGlobal };
|
|
10
11
|
export type { ImportString };
|
|
@@ -43,10 +44,11 @@ import type { Vike, VikePackages } from '../VikeNamespace.js';
|
|
|
43
44
|
import type { HooksTimeoutProvidedByUser } from '../hooks/getHook.js';
|
|
44
45
|
import type { GlobalContext, PageContextClient, PageContextServer } from '../types.js';
|
|
45
46
|
import type { InlineConfig } from 'vite';
|
|
46
|
-
type
|
|
47
|
+
type HookNameOld = HookName | HookNameOldDesign;
|
|
48
|
+
type HookName = HookNamePage | HookNameGlobal;
|
|
47
49
|
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data' | 'onData';
|
|
48
50
|
type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart' | 'onCreatePageContext' | 'onCreateGlobalContext';
|
|
49
|
-
type HookNameOldDesign = 'render' | 'prerender';
|
|
51
|
+
type HookNameOldDesign = 'render' | 'prerender' | 'onBeforePrerender';
|
|
50
52
|
type ConfigNameBuiltIn = Exclude<keyof Config, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware';
|
|
51
53
|
type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
|
|
52
54
|
type Config = ConfigBuiltIn & Vike.Config & (VikePackages.ConfigVikeReact | VikePackages.ConfigVikeVue | VikePackages.ConfigVikeSolid | VikePackages.ConfigVikeSvelte | VikePackages.ConfigVikeAngular);
|
package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.d.ts → getUserFriendlyConfigs.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { getUserFriendlyConfigsGlobal };
|
|
2
|
+
export { getUserFriendlyConfigsPageEager };
|
|
3
|
+
export { getUserFriendlyConfigsPageLazy };
|
|
4
4
|
export type { PageConfigsUserFriendly };
|
|
5
5
|
export type { PageConfigUserFriendly };
|
|
6
6
|
export type { PageConfigUserFriendlyOld };
|
|
@@ -92,8 +92,10 @@ type WithRoute = {
|
|
|
92
92
|
isErrorPage: true;
|
|
93
93
|
};
|
|
94
94
|
type PageConfigUserFriendlyWithRoute = PageConfigUserFriendly & WithRoute;
|
|
95
|
-
declare function
|
|
96
|
-
declare function
|
|
95
|
+
declare function getUserFriendlyConfigsPageEager(pageConfigGlobalValues: ConfigValues, pageConfig: PageConfigRuntime | PageConfigBuildTime, pageConfigValues: ConfigValues): [string, PageConfigUserFriendlyWithRoute];
|
|
96
|
+
declare function getUserFriendlyConfigsGlobal({ pageConfigGlobalValues }: {
|
|
97
97
|
pageConfigGlobalValues: ConfigValues;
|
|
98
98
|
}): PageConfigUserFriendly;
|
|
99
|
-
declare function
|
|
99
|
+
declare function getUserFriendlyConfigsPageLazy(pageFiles: PageFile[], // V0.4 design
|
|
100
|
+
pageConfig: PageConfigRuntimeLoaded | null, // V1 design
|
|
101
|
+
pageConfigGlobal: PageConfigGlobalRuntime): PageConfigUserFriendlyOld;
|
package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.js → getUserFriendlyConfigs.js}
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { getUserFriendlyConfigsGlobal };
|
|
2
|
+
export { getUserFriendlyConfigsPageEager };
|
|
3
|
+
export { getUserFriendlyConfigsPageLazy };
|
|
4
4
|
import { assertDefaultExports, forbiddenDefaultExports } from '../getPageFiles/assert_exports_old_design.js';
|
|
5
5
|
import { getConfigDefinedAtOptional, getDefinedAtString } from './getConfigDefinedAt.js';
|
|
6
6
|
import { getConfigValueFilePathToShowToUser } from './helpers.js';
|
|
7
7
|
import { assert, isObject, assertWarning, assertUsage, makeLast, isBrowser, isScriptFile, isTemplateFile } from '../utils.js';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
|
-
function
|
|
10
|
-
const pageConfigUserFriendly =
|
|
9
|
+
function getUserFriendlyConfigsPageEager(pageConfigGlobalValues, pageConfig, pageConfigValues) {
|
|
10
|
+
const pageConfigUserFriendly = getUserFriendlyConfigs_public({ pageConfigGlobalValues, pageConfigValues });
|
|
11
11
|
let page;
|
|
12
12
|
if (!pageConfig.isErrorPage) {
|
|
13
13
|
const route = pageConfigUserFriendly.config.route ?? pageConfig.routeFilesystem.routeString;
|
|
@@ -24,8 +24,8 @@ function getPageConfigUserFriendly(pageConfigGlobalValues, pageConfig, pageConfi
|
|
|
24
24
|
}
|
|
25
25
|
return [pageConfig.pageId, page];
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const pageConfigUserFriendly =
|
|
27
|
+
function getUserFriendlyConfigs_public({ pageConfigGlobalValues, pageConfigValues }) {
|
|
28
|
+
const pageConfigUserFriendly = getUserFriendlyConfigs_base({ pageConfigGlobalValues, pageConfigValues });
|
|
29
29
|
return getPublicCopy(pageConfigUserFriendly);
|
|
30
30
|
}
|
|
31
31
|
function getPublicCopy(pageConfigUserFriendly) {
|
|
@@ -37,15 +37,17 @@ function getPublicCopy(pageConfigUserFriendly) {
|
|
|
37
37
|
_from: p.from
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function getUserFriendlyConfigs_base({ pageConfigGlobalValues, pageConfigValues }) {
|
|
41
41
|
const configValues = { ...pageConfigGlobalValues, ...pageConfigValues };
|
|
42
|
-
return
|
|
42
|
+
return getUserFriendlyConfigs_V1Design({ configValues });
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const pageConfigGlobalUserFriendly =
|
|
44
|
+
function getUserFriendlyConfigsGlobal({ pageConfigGlobalValues }) {
|
|
45
|
+
const pageConfigGlobalUserFriendly = getUserFriendlyConfigs_V1Design({ configValues: pageConfigGlobalValues });
|
|
46
46
|
return getPublicCopy(pageConfigGlobalUserFriendly);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function getUserFriendlyConfigsPageLazy(pageFiles, // V0.4 design
|
|
49
|
+
pageConfig, // V1 design
|
|
50
|
+
pageConfigGlobal) {
|
|
49
51
|
const config = {};
|
|
50
52
|
const configEntries = {}; // TODO/v1-release: remove
|
|
51
53
|
const exportsAll = {}; // TODO/v1-release: remove
|
|
@@ -70,7 +72,7 @@ function getPageConfigUserFriendly_oldDesign(pageFiles, pageConfig, pageConfigGl
|
|
|
70
72
|
let sources;
|
|
71
73
|
let from;
|
|
72
74
|
if (pageConfig) {
|
|
73
|
-
const res =
|
|
75
|
+
const res = getUserFriendlyConfigs_base({
|
|
74
76
|
pageConfigGlobalValues: pageConfigGlobal.configValues,
|
|
75
77
|
pageConfigValues: pageConfig.configValues
|
|
76
78
|
});
|
|
@@ -119,7 +121,7 @@ function getPageConfigUserFriendly_oldDesign(pageFiles, pageConfig, pageConfigGl
|
|
|
119
121
|
return pageContextExports;
|
|
120
122
|
}
|
|
121
123
|
// V1 design
|
|
122
|
-
function
|
|
124
|
+
function getUserFriendlyConfigs_V1Design(pageConfig) {
|
|
123
125
|
const config = {};
|
|
124
126
|
const configEntries = {};
|
|
125
127
|
const exportsAll = {};
|
|
@@ -135,19 +137,30 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
135
137
|
sources[configName] ?? (sources[configName] = []);
|
|
136
138
|
sources[configName].push(src);
|
|
137
139
|
};
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const configDefinedAt = getConfigDefinedAtOptional('Config', configName, configValue.definedAtData);
|
|
142
|
-
config[configName] = config[configName] ?? value;
|
|
140
|
+
const addLegacy = (configName, value, definedAtData) => {
|
|
141
|
+
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(definedAtData);
|
|
142
|
+
const configDefinedAt = getConfigDefinedAtOptional('Config', configName, definedAtData);
|
|
143
143
|
configEntries[configName] = configEntries[configName] ?? [];
|
|
144
|
-
// Currently each configName has only one entry. Adding an entry for each overriden config value isn't implemented yet. (This is an isomorphic file and it isn't clear whether this can/should be implemented on the client-side. We should load a minimum amount of code on the client-side.)
|
|
145
|
-
assert(configEntries[configName].length === 0);
|
|
146
144
|
configEntries[configName].push({
|
|
147
145
|
configValue: value,
|
|
148
146
|
configDefinedAt,
|
|
149
147
|
configDefinedByFile: configValueFilePathToShowToUser
|
|
150
148
|
});
|
|
149
|
+
// TODO/v1-release: remove
|
|
150
|
+
const exportName = configName;
|
|
151
|
+
exportsAll[exportName] = exportsAll[exportName] ?? [];
|
|
152
|
+
exportsAll[exportName].push({
|
|
153
|
+
exportValue: value,
|
|
154
|
+
exportSource: configDefinedAt,
|
|
155
|
+
filePath: configValueFilePathToShowToUser,
|
|
156
|
+
_filePath: configValueFilePathToShowToUser,
|
|
157
|
+
_fileType: null,
|
|
158
|
+
_isFromDefaultExport: null
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
|
|
162
|
+
const { value } = configValue;
|
|
163
|
+
config[configName] = config[configName] ?? value;
|
|
151
164
|
if (configValue.type === 'standard') {
|
|
152
165
|
const src = {
|
|
153
166
|
type: 'configsStandard',
|
|
@@ -156,6 +169,7 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
156
169
|
};
|
|
157
170
|
addSrc(src, configName);
|
|
158
171
|
from.configsStandard[configName] = src;
|
|
172
|
+
addLegacy(configName, value, configValue.definedAtData);
|
|
159
173
|
}
|
|
160
174
|
if (configValue.type === 'cumulative') {
|
|
161
175
|
const src = {
|
|
@@ -164,6 +178,7 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
164
178
|
const definedAtFile = configValue.definedAtData[i];
|
|
165
179
|
assert(definedAtFile);
|
|
166
180
|
const definedAt = getDefinedAtString(definedAtFile, configName);
|
|
181
|
+
addLegacy(configName, value, definedAtFile);
|
|
167
182
|
return {
|
|
168
183
|
value,
|
|
169
184
|
definedAt
|
|
@@ -180,18 +195,8 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
180
195
|
};
|
|
181
196
|
addSrc(src, configName);
|
|
182
197
|
from.configsComputed[configName] = src;
|
|
198
|
+
addLegacy(configName, value, configValue.definedAtData);
|
|
183
199
|
}
|
|
184
|
-
// TODO/v1-release: remove
|
|
185
|
-
const exportName = configName;
|
|
186
|
-
exportsAll[exportName] = exportsAll[exportName] ?? [];
|
|
187
|
-
exportsAll[exportName].push({
|
|
188
|
-
exportValue: value,
|
|
189
|
-
exportSource: configDefinedAt,
|
|
190
|
-
filePath: configValueFilePathToShowToUser,
|
|
191
|
-
_filePath: configValueFilePathToShowToUser,
|
|
192
|
-
_fileType: null,
|
|
193
|
-
_isFromDefaultExport: null
|
|
194
|
-
});
|
|
195
200
|
});
|
|
196
201
|
return {
|
|
197
202
|
config: config,
|
|
@@ -12,7 +12,7 @@ export type { PageContextBuiltInServer_deprecated as PageContextBuiltInServer };
|
|
|
12
12
|
export type { PageContextBuiltInClientWithClientRouting_deprecated as PageContextBuiltInClientWithClientRouting };
|
|
13
13
|
export type { PageContextBuiltInClientWithServerRouting_deprecated as PageContextBuiltInClientWithServerRouting };
|
|
14
14
|
import type { PageContextUrlInternal, PageContextUrlClient, PageContextUrlServer } from './getPageContextUrlComputed.js';
|
|
15
|
-
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-configs/
|
|
15
|
+
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-configs/getUserFriendlyConfigs.js';
|
|
16
16
|
import type { Config } from './page-configs/Config.js';
|
|
17
17
|
import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
|
|
18
18
|
import type { AbortStatusCode } from './route/abort.js';
|
|
@@ -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.229-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.229-commit-7056ef0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.229-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.229-commit-7056ef0';
|
package/package.json
CHANGED
|
@@ -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,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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { getPageConfigsRuntime };
|
|
2
|
-
export { getAllPageIds };
|
|
3
|
-
import type { PageFile } from './getPageFiles.js';
|
|
4
|
-
import { type PageConfigUserFriendly, type PageConfigsUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
|
|
5
|
-
import type { PageConfigGlobalRuntime, PageConfigRuntime } from './page-configs/PageConfig.js';
|
|
6
|
-
declare function getPageConfigsRuntime(virtualFileExports: unknown): {
|
|
7
|
-
pageFilesAll: PageFile[];
|
|
8
|
-
allPageIds: string[];
|
|
9
|
-
pageConfigs: PageConfigRuntime[];
|
|
10
|
-
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
11
|
-
globalConfig: PageConfigUserFriendly;
|
|
12
|
-
pageConfigsUserFriendly: PageConfigsUserFriendly;
|
|
13
|
-
};
|
|
14
|
-
declare function getAllPageIds(pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[]): string[];
|