vike 0.4.143 → 0.4.144-commit-68c730d
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/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +31 -30
- package/dist/cjs/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +19 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +7 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +251 -209
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +11 -35
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +60 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +18 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +25 -24
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +1 -12
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/utils.js +2 -3
- package/dist/cjs/node/prerender/runPrerender.js +18 -20
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -2
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/node/shared/getClientEntryFilePath.js +1 -7
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/cjs/shared/error-page.js +1 -1
- package/dist/cjs/shared/getPageFiles/getExports.js +8 -11
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +10 -44
- package/dist/cjs/shared/hooks/getHook.js +3 -1
- package/dist/cjs/shared/page-configs/assertExports.js +60 -0
- package/dist/cjs/shared/page-configs/getExportPath.js +9 -10
- package/dist/cjs/shared/page-configs/loadConfigValues.js +18 -0
- package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +2 -0
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigs.js +19 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +56 -0
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +65 -0
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +58 -0
- package/dist/cjs/shared/page-configs/utils.js +65 -42
- package/dist/cjs/shared/route/loadPageRoutes.js +12 -15
- package/dist/cjs/shared/route/resolveRedirects.js +1 -1
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -0
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/getFilePathAbsolute.js +11 -11
- package/dist/cjs/utils/getOutDirs.js +25 -18
- package/dist/cjs/utils/getValuePrintable.js +1 -1
- package/dist/cjs/utils/objectAssign.js +3 -1
- package/dist/cjs/utils/parseUrl.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/{resolve.js → requireResolve.js} +3 -3
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +1 -1
- package/dist/esm/__internal/index.d.ts +3 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageId.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/useClientRouter.js +3 -3
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/plugin/index.js +3 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/config/index.js +2 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +31 -30
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +13 -2
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +20 -11
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +20 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +7 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +5 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +252 -210
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +11 -32
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +60 -95
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +7 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +15 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.d.ts +18 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +25 -24
- package/dist/esm/node/plugin/shared/findPageFiles.js +3 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.d.ts → getConfigValueSourcesRelevant.d.ts} +0 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +0 -11
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +1 -2
- package/dist/esm/node/plugin/utils.js +2 -3
- package/dist/esm/node/prerender/runPrerender.js +20 -22
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +13 -13
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -2
- package/dist/esm/node/runtime/renderPage.js +1 -1
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +2 -2
- package/dist/esm/node/shared/getClientEntryFilePath.js +2 -8
- package/dist/esm/shared/addIs404ToPageProps.d.ts +2 -2
- package/dist/esm/shared/addUrlComputedProps.d.ts +4 -2
- package/dist/esm/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/esm/shared/error-page.d.ts +3 -3
- package/dist/esm/shared/error-page.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +2 -2
- package/dist/esm/shared/getPageFiles/getExports.d.ts +3 -4
- package/dist/esm/shared/getPageFiles/getExports.js +7 -10
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +3 -3
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +9 -43
- package/dist/esm/shared/getPageFiles/setPageFiles.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +3 -1
- package/dist/esm/shared/page-configs/Config.d.ts +201 -14
- package/dist/esm/shared/page-configs/PageConfig.d.ts +80 -73
- package/dist/esm/shared/page-configs/assertExports.d.ts +6 -0
- package/dist/esm/shared/page-configs/assertExports.js +54 -0
- package/dist/esm/shared/page-configs/findPageConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
- package/dist/esm/shared/page-configs/getExportPath.js +9 -10
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +15 -0
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +32 -0
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.js +1 -0
- package/dist/esm/shared/page-configs/serialize/assertPageConfigs.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/assertPageConfigs.js +16 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +4 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +50 -0
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +7 -0
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +62 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +8 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +52 -0
- package/dist/esm/shared/page-configs/utils.d.ts +21 -14
- package/dist/esm/shared/page-configs/utils.js +64 -41
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/loadPageRoutes.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +13 -16
- package/dist/esm/shared/route/resolveRedirects.js +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -0
- package/dist/esm/shared/types.d.ts +8 -6
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/utils/getFilePathAbsolute.d.ts +1 -1
- package/dist/esm/utils/getFilePathAbsolute.js +11 -11
- package/dist/esm/utils/getOutDirs.d.ts +0 -2
- package/dist/esm/utils/getOutDirs.js +24 -17
- package/dist/esm/utils/getValuePrintable.js +1 -1
- package/dist/esm/utils/objectAssign.js +3 -1
- package/dist/esm/utils/parseUrl.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/requireResolve.d.ts +2 -0
- package/dist/esm/utils/{resolve.js → requireResolve.js} +2 -2
- package/dist/esm/utils/warnIfErrorIsNotObject.js +1 -1
- package/package.json +2 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -13
- package/dist/cjs/shared/getPageFiles/assertPageConfigs.js +0 -19
- package/dist/cjs/shared/page-configs/loadPageCode.js +0 -63
- package/dist/cjs/utils/assertDefaultExport.js +0 -53
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -10
- package/dist/esm/shared/getPageFiles/assertPageConfigs.d.ts +0 -5
- package/dist/esm/shared/getPageFiles/assertPageConfigs.js +0 -16
- package/dist/esm/shared/page-configs/loadPageCode.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadPageCode.js +0 -57
- package/dist/esm/utils/assertDefaultExport.d.ts +0 -8
- package/dist/esm/utils/assertDefaultExport.js +0 -47
- package/dist/esm/utils/resolve.d.ts +0 -2
- /package/dist/cjs/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.d.ts → assert_exports_old_design.d.ts} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
|
@@ -20,6 +20,7 @@ import { preparePageContextForUserConsumptionServerSide } from './preparePageCon
|
|
|
20
20
|
import { executeGuardHook } from '../../../shared/route/executeGuardHook.js';
|
|
21
21
|
import { loadPageRoutes } from '../../../shared/route/loadPageRoutes.js';
|
|
22
22
|
import pc from '@brillout/picocolors';
|
|
23
|
+
import { getConfigValueFilePathToShowToUser } from '../../../shared/page-configs/utils.js';
|
|
23
24
|
async function renderPageAlreadyRouted(pageContext) {
|
|
24
25
|
// pageContext._pageId can either be the:
|
|
25
26
|
// - ID of the page matching the routing, or the
|
|
@@ -166,9 +167,9 @@ function assertNonMixedDesign(pageFilesAll, pageConfigs) {
|
|
|
166
167
|
const indent = '- ';
|
|
167
168
|
const v1Files = unique(pageConfigs
|
|
168
169
|
.map((p) => Object.values(p.configValues)
|
|
169
|
-
.map(
|
|
170
|
+
.map(getConfigValueFilePathToShowToUser)
|
|
170
171
|
.filter(isNotNullish)
|
|
171
|
-
.map((
|
|
172
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
172
173
|
.flat(2));
|
|
173
174
|
assertUsage(false, [
|
|
174
175
|
'Mixing the new V1 design with the old V0.4 design is forbidden.',
|
|
@@ -305,7 +305,7 @@ function getRequestId() {
|
|
|
305
305
|
}
|
|
306
306
|
function skipRequest(urlOriginal) {
|
|
307
307
|
const isViteClientRequest = urlOriginal.endsWith('/@vite/client') || urlOriginal.startsWith('/@fs/');
|
|
308
|
-
assertWarning(!isViteClientRequest, `The vike middleware renderPage() was called with the URL ${urlOriginal} which is unexpected because the HTTP request should have already been handled by Vite's development middleware. Make sure to 1. install Vite's development middleware and 2. add Vite's middleware *before*
|
|
308
|
+
assertWarning(!isViteClientRequest, `The vike middleware renderPage() was called with the URL ${urlOriginal} which is unexpected because the HTTP request should have already been handled by Vite's development middleware. Make sure to 1. install Vite's development middleware and 2. add Vite's middleware *before* Vike's middleware, see https://vike.dev/renderPage`, { onlyOnce: true });
|
|
309
309
|
return (urlOriginal.endsWith('/__vite_ping') ||
|
|
310
310
|
urlOriginal.endsWith('/favicon.ico') ||
|
|
311
311
|
!isParsable(urlOriginal) ||
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { getClientEntryFilePath };
|
|
2
|
-
import type {
|
|
3
|
-
declare function getClientEntryFilePath(pageConfig:
|
|
2
|
+
import type { PageConfigRuntime, PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
|
|
3
|
+
declare function getClientEntryFilePath(pageConfig: PageConfigRuntime | PageConfigBuildTime): null | string;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
export { getClientEntryFilePath };
|
|
2
|
-
import {
|
|
3
|
-
import { assert } from './utils.js';
|
|
2
|
+
import { getConfigValue } from '../../shared/page-configs/utils.js';
|
|
4
3
|
function getClientEntryFilePath(pageConfig) {
|
|
5
4
|
const configName = 'client';
|
|
6
5
|
const configValue = getConfigValue(pageConfig, configName, 'string');
|
|
7
6
|
if (!configValue)
|
|
8
7
|
return null;
|
|
9
|
-
|
|
10
|
-
const { value } = configValue;
|
|
11
|
-
// Users should be able to suppress client entry by setting its value to null
|
|
12
|
-
assert(value !== null);
|
|
13
|
-
const clientEntryFilePath = definedAtInfo.filePath;
|
|
14
|
-
return clientEntryFilePath;
|
|
8
|
+
return configValue.value;
|
|
15
9
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { addIs404ToPageProps };
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageConfigRuntime } from './page-configs/PageConfig.js';
|
|
3
3
|
declare function addIs404ToPageProps(pageContext: Record<string, unknown> & PageContextAssertIs404): void;
|
|
4
4
|
type PageContextAssertIs404 = {
|
|
5
5
|
_pageId: string;
|
|
6
|
-
_pageConfigs:
|
|
6
|
+
_pageConfigs: PageConfigRuntime[];
|
|
7
7
|
};
|
|
@@ -4,7 +4,8 @@ export type { PageContextUrlComputedPropsInternal };
|
|
|
4
4
|
export type { PageContextUrlComputedPropsClient };
|
|
5
5
|
export type { PageContextUrlComputedPropsServer };
|
|
6
6
|
export type { PageContextUrlSources };
|
|
7
|
-
type
|
|
7
|
+
export type { Url };
|
|
8
|
+
type Url = {
|
|
8
9
|
/** The URL origin, e.g. `https://example.com` of `https://example.com/product/42?details=yes#reviews` */
|
|
9
10
|
origin: null | string;
|
|
10
11
|
/** The URL pathname, e.g. `/product/42` of `https://example.com/product/42?details=yes#reviews` */
|
|
@@ -34,8 +35,9 @@ type PageContextUrlComputedPropsClient = {
|
|
|
34
35
|
/** The URL pathname, e.g. `/product/42` of `https://example.com/product/42?details=yes#reviews` */
|
|
35
36
|
urlPathname: string;
|
|
36
37
|
/** Parsed information about the current URL */
|
|
37
|
-
urlParsed:
|
|
38
|
+
urlParsed: Url;
|
|
38
39
|
};
|
|
40
|
+
/** For Vike internal use */
|
|
39
41
|
type PageContextUrlComputedPropsInternal = PageContextUrlComputedPropsClient & {
|
|
40
42
|
_urlRewrite: string | null;
|
|
41
43
|
};
|
|
@@ -10,6 +10,6 @@ function assertPageContextProvidedByUser(pageContextProvidedByUser, { hookName,
|
|
|
10
10
|
assertUsage(!('_objectCreatedByVike' in pageContextProvidedByUser), `${errPrefix} shouldn't be the whole ${pc.cyan('pageContext')} object, see https://vike.dev/pageContext-manipulation#do-not-return-entire-pagecontext`);
|
|
11
11
|
// In principle, it's possible to use onBeforeRoute()` to override and define the whole routing.
|
|
12
12
|
// Is that a good idea to allow users to do this? Beyond deep integration with Vue Router or React Router, is there a use case for this?
|
|
13
|
-
assertWarning(!('_pageId' in pageContextProvidedByUser), `${errPrefix} sets ${pc.cyan('pageContext._pageId')} which means that
|
|
13
|
+
assertWarning(!('_pageId' in pageContextProvidedByUser), `${errPrefix} sets ${pc.cyan('pageContext._pageId')} which means that Vike's routing is overriden. This is an experimental feature: make sure to contact a vike maintainer before using this.`, { onlyOnce: true });
|
|
14
14
|
assertUsage(!('is404' in pageContextProvidedByUser), `${errPrefix} sets ${pc.cyan('pageContext.is404')} which is forbidden, use ${pc.cyan('throw render()')} instead, see https://vike.dev/render`);
|
|
15
15
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { getErrorPageId };
|
|
2
2
|
export { isErrorPageId };
|
|
3
3
|
export { isErrorPage };
|
|
4
|
-
import type {
|
|
4
|
+
import type { PageConfigRuntime } from './page-configs/PageConfig.js';
|
|
5
5
|
import type { PageFile } from './getPageFiles.js';
|
|
6
|
-
declare function getErrorPageId(pageFilesAll: PageFile[], pageConfigs:
|
|
6
|
+
declare function getErrorPageId(pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[]): string | null;
|
|
7
7
|
declare function isErrorPageId(pageId: string, _isV1Design: false): boolean;
|
|
8
|
-
declare function isErrorPage(pageId: string, pageConfigs:
|
|
8
|
+
declare function isErrorPage(pageId: string, pageConfigs: PageConfigRuntime[]): boolean;
|
|
@@ -30,7 +30,7 @@ function isErrorPage(pageId, pageConfigs) {
|
|
|
30
30
|
if (pageConfigs.length > 0) {
|
|
31
31
|
const pageConfig = pageConfigs.find((p) => p.pageId === pageId);
|
|
32
32
|
assert(pageConfig);
|
|
33
|
-
return pageConfig.isErrorPage;
|
|
33
|
+
return !!pageConfig.isErrorPage;
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
return isErrorPageId(pageId, false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { analyzeClientSide };
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageConfigRuntime } from '../page-configs/PageConfig.js';
|
|
3
3
|
import type { PageFile } from './getPageFileObject.js';
|
|
4
|
-
declare function analyzeClientSide(pageConfig:
|
|
4
|
+
declare function analyzeClientSide(pageConfig: PageConfigRuntime | null, pageFilesAll: PageFile[], pageId: string): {
|
|
5
5
|
isClientSideRenderable: boolean;
|
|
6
6
|
isClientRouting: boolean;
|
|
7
7
|
};
|
|
@@ -4,18 +4,17 @@ export type { ExportsAll };
|
|
|
4
4
|
export type { PageContextExports };
|
|
5
5
|
export type { ConfigEntries };
|
|
6
6
|
import type { FileType } from './fileTypes.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { PageConfigRuntimeLoaded } from './../page-configs/PageConfig.js';
|
|
8
8
|
import type { PageFile } from './getPageFileObject.js';
|
|
9
9
|
type ExportsAll = Record<string, {
|
|
10
10
|
exportValue: unknown;
|
|
11
11
|
exportSource: string;
|
|
12
|
+
filePath: string | null;
|
|
12
13
|
/** @deprecated */
|
|
13
14
|
_fileType: FileType | null;
|
|
14
15
|
/** @deprecated */
|
|
15
16
|
_isFromDefaultExport: boolean | null;
|
|
16
17
|
/** @deprecated */
|
|
17
|
-
filePath: string | null;
|
|
18
|
-
/** @deprecated */
|
|
19
18
|
_filePath: string | null;
|
|
20
19
|
}[]>;
|
|
21
20
|
/** All the config's values (including overriden ones) and where they come from.
|
|
@@ -35,5 +34,5 @@ type PageContextExports = {
|
|
|
35
34
|
/** @deprecated */
|
|
36
35
|
pageExports: Record<string, unknown>;
|
|
37
36
|
};
|
|
38
|
-
declare function getExports(pageFiles: PageFile[], pageConfig:
|
|
37
|
+
declare function getExports(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null): PageContextExports;
|
|
39
38
|
declare function getExportUnion(exportsAll: ExportsAll, propName: string): string[];
|
|
@@ -2,8 +2,8 @@ export { getExportUnion };
|
|
|
2
2
|
export { getExports };
|
|
3
3
|
import { isScriptFile, isTemplateFile } from '../../utils/isScriptFile.js';
|
|
4
4
|
import { assert, hasProp, isObject, assertWarning, assertUsage, makeLast, isBrowser } from '../utils.js';
|
|
5
|
-
import { assertDefaultExports, forbiddenDefaultExports } from './
|
|
6
|
-
import { getConfigDefinedAtString } from '../page-configs/utils.js';
|
|
5
|
+
import { assertDefaultExports, forbiddenDefaultExports } from './assert_exports_old_design.js';
|
|
6
|
+
import { getConfigDefinedAtString, getConfigValueFilePathToShowToUser } from '../page-configs/utils.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
function getExports(pageFiles, pageConfig) {
|
|
9
9
|
const configEntries = {};
|
|
@@ -29,11 +29,8 @@ function getExports(pageFiles, pageConfig) {
|
|
|
29
29
|
// V1 design
|
|
30
30
|
if (pageConfig) {
|
|
31
31
|
Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
|
|
32
|
-
const { value
|
|
33
|
-
|
|
34
|
-
if (definedAtInfo) {
|
|
35
|
-
filePath = definedAtInfo.filePath;
|
|
36
|
-
}
|
|
32
|
+
const { value } = configValue;
|
|
33
|
+
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(configValue);
|
|
37
34
|
const configDefinedAt = getConfigDefinedAtString(configName, configValue, true);
|
|
38
35
|
config[configName] = config[configName] ?? value;
|
|
39
36
|
configEntries[configName] = configEntries[configName] ?? [];
|
|
@@ -42,7 +39,7 @@ function getExports(pageFiles, pageConfig) {
|
|
|
42
39
|
configEntries[configName].push({
|
|
43
40
|
configValue: value,
|
|
44
41
|
configDefinedAt,
|
|
45
|
-
configDefinedByFile:
|
|
42
|
+
configDefinedByFile: configValueFilePathToShowToUser
|
|
46
43
|
});
|
|
47
44
|
// TODO/v1-release: remove
|
|
48
45
|
const exportName = configName;
|
|
@@ -50,8 +47,8 @@ function getExports(pageFiles, pageConfig) {
|
|
|
50
47
|
exportsAll[exportName].push({
|
|
51
48
|
exportValue: value,
|
|
52
49
|
exportSource: configDefinedAt,
|
|
53
|
-
filePath,
|
|
54
|
-
_filePath:
|
|
50
|
+
filePath: configValueFilePathToShowToUser,
|
|
51
|
+
_filePath: configValueFilePathToShowToUser,
|
|
55
52
|
_fileType: null,
|
|
56
53
|
_isFromDefaultExport: null
|
|
57
54
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { parseGlobResults };
|
|
2
2
|
import { type PageFile } from './getPageFileObject.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PageConfigRuntime, PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
|
|
4
4
|
declare function parseGlobResults(pageFilesExports: unknown): {
|
|
5
5
|
pageFiles: PageFile[];
|
|
6
|
-
pageConfigs:
|
|
7
|
-
pageConfigGlobal:
|
|
6
|
+
pageConfigs: PageConfigRuntime[];
|
|
7
|
+
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
8
8
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { parseGlobResults };
|
|
2
2
|
import { assert, hasProp, isCallable, isObject, cast, assertUsage } from '../utils.js';
|
|
3
|
-
import { assertExportValues } from './
|
|
3
|
+
import { assertExportValues } from './assert_exports_old_design.js';
|
|
4
4
|
import { getPageFileObject } from './getPageFileObject.js';
|
|
5
5
|
import { fileTypes } from './fileTypes.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { assertPageConfigGlobalSerialized, assertPageConfigsSerialized } from '../page-configs/serialize/assertPageConfigs.js';
|
|
7
|
+
import { parsePageConfigs } from '../page-configs/serialize/parsePageConfigs.js';
|
|
8
8
|
function parseGlobResults(pageFilesExports) {
|
|
9
9
|
assert(hasProp(pageFilesExports, 'isGeneratedFile'));
|
|
10
10
|
assert(pageFilesExports.isGeneratedFile !== false, `vike was re-installed(/re-built). Restart your app.`);
|
|
@@ -16,12 +16,12 @@ function parseGlobResults(pageFilesExports) {
|
|
|
16
16
|
assert(hasProp(pageFilesExports.pageFilesLazy, '.page'));
|
|
17
17
|
assert(hasProp(pageFilesExports.pageFilesLazy, '.page.client') || hasProp(pageFilesExports.pageFilesLazy, '.page.server'));
|
|
18
18
|
assert(hasProp(pageFilesExports, 'pageFilesList', 'string[]'));
|
|
19
|
-
assert(hasProp(pageFilesExports, '
|
|
20
|
-
assert(hasProp(pageFilesExports, '
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
assert(hasProp(pageFilesExports, 'pageConfigsSerialized'));
|
|
20
|
+
assert(hasProp(pageFilesExports, 'pageConfigGlobalSerialized'));
|
|
21
|
+
const { pageConfigsSerialized, pageConfigGlobalSerialized } = pageFilesExports;
|
|
22
|
+
assertPageConfigsSerialized(pageConfigsSerialized);
|
|
23
|
+
assertPageConfigGlobalSerialized(pageConfigGlobalSerialized);
|
|
24
|
+
const { pageConfigs, pageConfigGlobal } = parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized);
|
|
25
25
|
const pageFilesMap = {};
|
|
26
26
|
parseGlobResult(pageFilesExports.pageFilesLazy).forEach(({ filePath, pageFile, globValue }) => {
|
|
27
27
|
pageFile = pageFilesMap[filePath] = pageFilesMap[filePath] ?? pageFile;
|
|
@@ -88,37 +88,3 @@ function parseGlobResult(globObject) {
|
|
|
88
88
|
function assertLoadModule(globValue) {
|
|
89
89
|
assert(isCallable(globValue));
|
|
90
90
|
}
|
|
91
|
-
function parsePageConfigs(pageConfigs) {
|
|
92
|
-
pageConfigs.forEach((pageConfig) => {
|
|
93
|
-
Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
|
|
94
|
-
{
|
|
95
|
-
const { valueSerialized } = configValue;
|
|
96
|
-
if (valueSerialized !== undefined) {
|
|
97
|
-
configValue.value = parse(valueSerialized);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/*
|
|
101
|
-
if (configName === 'route') {
|
|
102
|
-
assertRouteConfigValue(configElement)
|
|
103
|
-
}
|
|
104
|
-
*/
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
// TODO: use again
|
|
109
|
-
// function assertRouteConfigValue(configElement: ConfigElement) {
|
|
110
|
-
// assert(hasProp(configElement, 'configValue')) // route files are eagerly loaded
|
|
111
|
-
// const { configValue } = configElement
|
|
112
|
-
// const configValueType = typeof configValue
|
|
113
|
-
// assertUsage(
|
|
114
|
-
// configValueType === 'string' || isCallable(configValue),
|
|
115
|
-
// `${configElement.configDefinedAt} has an invalid type '${configValueType}': it should be a string or a function instead, see https://vike.dev/route`
|
|
116
|
-
// )
|
|
117
|
-
// /* We don't do that to avoid unnecessarily bloating the client-side bundle when using Server Routing
|
|
118
|
-
// * - When using Server Routing, this file is loaded as well
|
|
119
|
-
// * - When using Server Routing, client-side validation is superfluous as Route Strings only need to be validated on the server-side
|
|
120
|
-
// if (typeof configValue === 'string') {
|
|
121
|
-
// assertRouteString(configValue, `${configElement.configDefinedAt} defines an`)
|
|
122
|
-
// }
|
|
123
|
-
// */
|
|
124
|
-
// }
|
|
@@ -2,12 +2,12 @@ export { setPageFiles };
|
|
|
2
2
|
export { setPageFilesAsync };
|
|
3
3
|
export { getPageFilesAll };
|
|
4
4
|
import type { PageFile } from './getPageFileObject.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { PageConfigRuntime, PageConfigGlobalRuntime } from '../page-configs/PageConfig.js';
|
|
6
6
|
declare function setPageFiles(pageFilesExports: unknown): void;
|
|
7
7
|
declare function setPageFilesAsync(getPageFilesExports: () => Promise<unknown>): void;
|
|
8
8
|
declare function getPageFilesAll(isClientSide: boolean, isProduction?: boolean): Promise<{
|
|
9
9
|
pageFilesAll: PageFile[];
|
|
10
10
|
allPageIds: string[];
|
|
11
|
-
pageConfigs:
|
|
12
|
-
pageConfigGlobal:
|
|
11
|
+
pageConfigs: PageConfigRuntime[];
|
|
12
|
+
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
13
13
|
}>;
|
|
@@ -11,7 +11,9 @@ function getHook(pageContext, hookName) {
|
|
|
11
11
|
assert(file.exportValue === hookFn);
|
|
12
12
|
if (hookFn === null)
|
|
13
13
|
return null;
|
|
14
|
-
const hookFilePath = file.
|
|
14
|
+
const hookFilePath = file.filePath;
|
|
15
|
+
assert(hookFilePath);
|
|
16
|
+
assert(!hookFilePath.endsWith(' '));
|
|
15
17
|
assertHookFn(hookFn, { hookName, hookFilePath });
|
|
16
18
|
return { hookFn, hookName, hookFilePath };
|
|
17
19
|
}
|
|
@@ -3,15 +3,202 @@ export type { ConfigBuiltIn };
|
|
|
3
3
|
export type { ConfigNameBuiltIn };
|
|
4
4
|
export type { ConfigMeta };
|
|
5
5
|
export type { HookName };
|
|
6
|
+
export type { GuardAsync };
|
|
7
|
+
export type { GuardSync };
|
|
8
|
+
export type { OnBeforePrerenderStartAsync };
|
|
9
|
+
export type { OnBeforePrerenderStartSync };
|
|
10
|
+
export type { OnBeforeRenderAsync };
|
|
11
|
+
export type { OnBeforeRenderSync };
|
|
12
|
+
export type { OnBeforeRouteAsync };
|
|
13
|
+
export type { OnBeforeRouteSync };
|
|
14
|
+
export type { OnHydrationEndAsync };
|
|
15
|
+
export type { OnHydrationEndSync };
|
|
16
|
+
export type { OnPageTransitionEndAsync };
|
|
17
|
+
export type { OnPageTransitionEndSync };
|
|
18
|
+
export type { OnPageTransitionStartAsync };
|
|
19
|
+
export type { OnPageTransitionStartSync };
|
|
20
|
+
export type { OnPrerenderStartAsync };
|
|
21
|
+
export type { OnPrerenderStartSync };
|
|
22
|
+
export type { OnRenderClientAsync };
|
|
23
|
+
export type { OnRenderClientSync };
|
|
24
|
+
export type { OnRenderHtmlAsync };
|
|
25
|
+
export type { OnRenderHtmlSync };
|
|
26
|
+
export type { RouteAsync };
|
|
27
|
+
export type { RouteSync };
|
|
6
28
|
import type { PrefetchStaticAssets } from '../../client/client-routing-runtime/prefetch/getPrefetchSettings.js';
|
|
7
29
|
import type { ConfigDefinition } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
30
|
+
import type { DocumentHtml } from '../../node/runtime/html/renderHtml.js';
|
|
8
31
|
import type { ConfigVikeUserProvided } from '../ConfigVike.js';
|
|
9
32
|
import type { Vike, VikePackages } from '../VikeNamespace.js';
|
|
33
|
+
import type { PageContextClient, PageContextServer } from '../types.js';
|
|
10
34
|
type HookName = 'onHydrationEnd' | 'onBeforePrerender' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onBeforeRoute' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onPrerenderStart' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'render';
|
|
11
|
-
type
|
|
12
|
-
type ConfigNameBuiltInInternal = 'isClientSideRenderable' | 'onBeforeRenderEnv';
|
|
13
|
-
type ConfigNameBuiltIn = ConfigNameBuiltInPublic | ConfigNameBuiltInInternal;
|
|
35
|
+
type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientSideRenderable' | 'onBeforeRenderEnv';
|
|
14
36
|
type Config = ConfigBuiltIn & Vike.Config & (VikePackages.ConfigVikeReact | VikePackages.ConfigVikeVue | VikePackages.ConfigVikeSolid | VikePackages.ConfigVikeSvelte);
|
|
37
|
+
/** Protect page(s), e.g. forbid unauthorized access.
|
|
38
|
+
*
|
|
39
|
+
* https://vike.dev/guard
|
|
40
|
+
*/
|
|
41
|
+
type GuardAsync = (pageContext: PageContextServer) => Promise<void>;
|
|
42
|
+
/** Protect page(s), e.g. forbid unauthorized access.
|
|
43
|
+
*
|
|
44
|
+
* https://vike.dev/guard
|
|
45
|
+
*/
|
|
46
|
+
type GuardSync = (pageContext: PageContextServer) => void;
|
|
47
|
+
/** Global Hook called before the whole pre-rendering process starts.
|
|
48
|
+
*
|
|
49
|
+
* https://vike.dev/onBeforePrerenderStart
|
|
50
|
+
*/
|
|
51
|
+
type OnBeforePrerenderStartAsync = () => Promise<(string | {
|
|
52
|
+
url: string;
|
|
53
|
+
pageContext: Partial<Vike.PageContext>;
|
|
54
|
+
})[]>;
|
|
55
|
+
/** Global Hook called before the whole pre-rendering process starts.
|
|
56
|
+
*
|
|
57
|
+
* https://vike.dev/onBeforePrerenderStart
|
|
58
|
+
*/
|
|
59
|
+
type OnBeforePrerenderStartSync = () => (string | {
|
|
60
|
+
url: string;
|
|
61
|
+
pageContext: Partial<Vike.PageContext>;
|
|
62
|
+
})[];
|
|
63
|
+
/** Hook called before the page is rendered, usually for fetching data.
|
|
64
|
+
*
|
|
65
|
+
* https://vike.dev/onBeforeRender
|
|
66
|
+
*/
|
|
67
|
+
type OnBeforeRenderAsync = (pageContext: PageContextServer) => Promise<{
|
|
68
|
+
pageContext: Partial<Vike.PageContext>;
|
|
69
|
+
} | void>;
|
|
70
|
+
/** Hook called before the page is rendered, usually for fetching data.
|
|
71
|
+
*
|
|
72
|
+
* https://vike.dev/onBeforeRender
|
|
73
|
+
*/
|
|
74
|
+
type OnBeforeRenderSync = (pageContext: PageContextServer) => {
|
|
75
|
+
pageContext: Partial<Vike.PageContext>;
|
|
76
|
+
} | void;
|
|
77
|
+
/** Hook called before the URL is routed to a page.
|
|
78
|
+
*
|
|
79
|
+
* https://vike.dev/onBeforeRoute
|
|
80
|
+
*/
|
|
81
|
+
type OnBeforeRouteAsync = (pageContext: PageContextServer) => Promise<{
|
|
82
|
+
pageContext: Partial<{
|
|
83
|
+
/** The URL you provided to Vike when calling `renderPage({ urlOriginal })` in your server middleware.
|
|
84
|
+
*
|
|
85
|
+
* https://vike.dev/renderPage
|
|
86
|
+
*/
|
|
87
|
+
urlOriginal: string;
|
|
88
|
+
} | Vike.PageContext>;
|
|
89
|
+
}>;
|
|
90
|
+
/** Hook called before the URL is routed to a page.
|
|
91
|
+
*
|
|
92
|
+
* https://vike.dev/onBeforeRoute
|
|
93
|
+
*/
|
|
94
|
+
type OnBeforeRouteSync = (pageContext: PageContextServer) => {
|
|
95
|
+
pageContext: Partial<{
|
|
96
|
+
/** The URL you provided to Vike when calling `renderPage({ urlOriginal })` in your server middleware.
|
|
97
|
+
*
|
|
98
|
+
* https://vike.dev/renderPage
|
|
99
|
+
*/
|
|
100
|
+
urlOriginal: string;
|
|
101
|
+
} | Vike.PageContext>;
|
|
102
|
+
};
|
|
103
|
+
/** Hook called after the page is hydrated.
|
|
104
|
+
*
|
|
105
|
+
* https://vike.dev/clientRouting
|
|
106
|
+
*/
|
|
107
|
+
type OnHydrationEndAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
108
|
+
/** Hook called after the page is hydrated.
|
|
109
|
+
*
|
|
110
|
+
* https://vike.dev/clientRouting
|
|
111
|
+
*/
|
|
112
|
+
type OnHydrationEndSync = (pageContext: PageContextClient) => void;
|
|
113
|
+
/** Hook called after the user navigates to a new page.
|
|
114
|
+
*
|
|
115
|
+
* https://vike.dev/clientRouting
|
|
116
|
+
*/
|
|
117
|
+
type OnPageTransitionEndAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
118
|
+
/** Hook called after the user navigates to a new page.
|
|
119
|
+
*
|
|
120
|
+
* https://vike.dev/clientRouting
|
|
121
|
+
*/
|
|
122
|
+
type OnPageTransitionEndSync = (pageContext: PageContextClient) => void;
|
|
123
|
+
/** Hook called before the user navigates to a new page.
|
|
124
|
+
*
|
|
125
|
+
* https://vike.dev/clientRouting
|
|
126
|
+
*/
|
|
127
|
+
type OnPageTransitionStartAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
128
|
+
/** Hook called before the user navigates to a new page.
|
|
129
|
+
*
|
|
130
|
+
* https://vike.dev/clientRouting
|
|
131
|
+
*/
|
|
132
|
+
type OnPageTransitionStartSync = (pageContext: PageContextClient) => void;
|
|
133
|
+
/** Page Hook called when pre-rendering starts.
|
|
134
|
+
*
|
|
135
|
+
* https://vike.dev/onPrerenderStart
|
|
136
|
+
*/
|
|
137
|
+
type OnPrerenderStartAsync = (prerenderContext: {
|
|
138
|
+
pageContexts: PageContextServer[];
|
|
139
|
+
}) => Promise<{
|
|
140
|
+
prerenderContext: {
|
|
141
|
+
pageContexts: PageContextServer[];
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
144
|
+
/** Page Hook called when pre-rendering starts.
|
|
145
|
+
*
|
|
146
|
+
* https://vike.dev/onPrerenderStart
|
|
147
|
+
*/
|
|
148
|
+
type OnPrerenderStartSync = (prerenderContext: {
|
|
149
|
+
pageContexts: PageContextServer[];
|
|
150
|
+
}) => {
|
|
151
|
+
prerenderContext: {
|
|
152
|
+
pageContexts: PageContextServer[];
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
/** Hook called when page is rendered on the client-side.
|
|
156
|
+
*
|
|
157
|
+
* https://vike.dev/onRenderClient
|
|
158
|
+
*/
|
|
159
|
+
type OnRenderClientAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
160
|
+
/** Hook called when page is rendered on the client-side.
|
|
161
|
+
*
|
|
162
|
+
* https://vike.dev/onRenderClient
|
|
163
|
+
*/
|
|
164
|
+
type OnRenderClientSync = (pageContext: PageContextClient) => void;
|
|
165
|
+
/** Hook called when page is rendered to HTML on the server-side.
|
|
166
|
+
*
|
|
167
|
+
* https://vike.dev/onRenderHtml
|
|
168
|
+
*/
|
|
169
|
+
type OnRenderHtmlAsync = (pageContext: PageContextServer) => Promise<DocumentHtml | {
|
|
170
|
+
documentHtml: DocumentHtml;
|
|
171
|
+
pageContext: OnRenderHtmlPageContextReturn | (() => Promise<OnRenderHtmlPageContextReturn> | OnRenderHtmlPageContextReturn);
|
|
172
|
+
}>;
|
|
173
|
+
/** Hook called when page is rendered to HTML on the server-side.
|
|
174
|
+
*
|
|
175
|
+
* https://vike.dev/onRenderHtml
|
|
176
|
+
*/
|
|
177
|
+
type OnRenderHtmlSync = (pageContext: PageContextServer) => DocumentHtml | {
|
|
178
|
+
documentHtml: DocumentHtml;
|
|
179
|
+
pageContext: OnRenderHtmlPageContextReturn | (() => Promise<OnRenderHtmlPageContextReturn> | OnRenderHtmlPageContextReturn);
|
|
180
|
+
};
|
|
181
|
+
type OnRenderHtmlPageContextReturn = Partial<Vike.PageContext & {
|
|
182
|
+
/** See https://vike.dev/stream */
|
|
183
|
+
enableEagerStreaming: boolean;
|
|
184
|
+
}>;
|
|
185
|
+
/** @deprecated Use a sync route() with an async guard() instead */
|
|
186
|
+
type RouteAsync = (pageContext: PageContextServer | PageContextClient) => Promise<{
|
|
187
|
+
routeParams?: Record<string, string>;
|
|
188
|
+
precedence?: number;
|
|
189
|
+
} | boolean>;
|
|
190
|
+
/** The page's URL(s).
|
|
191
|
+
*
|
|
192
|
+
* https://vike.dev/route
|
|
193
|
+
*/
|
|
194
|
+
type RouteSync = (pageContext: PageContextServer | PageContextClient) => {
|
|
195
|
+
routeParams?: Record<string, string>;
|
|
196
|
+
precedence?: number;
|
|
197
|
+
} | boolean;
|
|
198
|
+
/** The page's URL(s).
|
|
199
|
+
*
|
|
200
|
+
* https://vike.dev/route
|
|
201
|
+
*/
|
|
15
202
|
/** Page configuration.
|
|
16
203
|
*
|
|
17
204
|
* https://vike.dev/config
|
|
@@ -23,12 +210,12 @@ type ConfigBuiltIn = {
|
|
|
23
210
|
*
|
|
24
211
|
* https://vike.dev/route
|
|
25
212
|
*/
|
|
26
|
-
route?: string |
|
|
213
|
+
route?: string | RouteAsync | RouteSync | ImportString;
|
|
27
214
|
/** Protect page(s), e.g. forbid unauthorized access.
|
|
28
215
|
*
|
|
29
216
|
* https://vike.dev/guard
|
|
30
217
|
*/
|
|
31
|
-
guard?:
|
|
218
|
+
guard?: GuardAsync | GuardSync | ImportString;
|
|
32
219
|
/**
|
|
33
220
|
* Whether to pre-render the page(s).
|
|
34
221
|
*
|
|
@@ -45,7 +232,7 @@ type ConfigBuiltIn = {
|
|
|
45
232
|
*
|
|
46
233
|
* https://vike.dev/onBeforeRender
|
|
47
234
|
*/
|
|
48
|
-
onBeforeRender?:
|
|
235
|
+
onBeforeRender?: OnBeforeRenderAsync | OnBeforeRenderSync | ImportString | null;
|
|
49
236
|
/** Determines what pageContext properties are sent to the client-side.
|
|
50
237
|
*
|
|
51
238
|
* https://vike.dev/passToClient
|
|
@@ -55,12 +242,12 @@ type ConfigBuiltIn = {
|
|
|
55
242
|
*
|
|
56
243
|
* https://vike.dev/onRenderClient
|
|
57
244
|
*/
|
|
58
|
-
onRenderClient?:
|
|
245
|
+
onRenderClient?: OnRenderClientAsync | OnRenderClientSync | ImportString;
|
|
59
246
|
/** Hook called when page is rendered to HTML on the server-side.
|
|
60
247
|
*
|
|
61
248
|
* https://vike.dev/onRenderHtml
|
|
62
249
|
*/
|
|
63
|
-
onRenderHtml?:
|
|
250
|
+
onRenderHtml?: OnRenderHtmlAsync | OnRenderHtmlSync | ImportString;
|
|
64
251
|
/** Enable async Route Functions.
|
|
65
252
|
*
|
|
66
253
|
* https://vike.dev/route-function#async
|
|
@@ -75,32 +262,32 @@ type ConfigBuiltIn = {
|
|
|
75
262
|
*
|
|
76
263
|
* https://vike.dev/onPrerenderStart
|
|
77
264
|
*/
|
|
78
|
-
onPrerenderStart?:
|
|
265
|
+
onPrerenderStart?: OnPrerenderStartAsync | OnPrerenderStartSync | ImportString;
|
|
79
266
|
/** Global Hook called before the whole pre-rendering process starts.
|
|
80
267
|
*
|
|
81
268
|
* https://vike.dev/onBeforePrerenderStart
|
|
82
269
|
*/
|
|
83
|
-
onBeforePrerenderStart?:
|
|
270
|
+
onBeforePrerenderStart?: OnBeforePrerenderStartAsync | OnBeforePrerenderStartSync | ImportString;
|
|
84
271
|
/** Hook called before the URL is routed to a page.
|
|
85
272
|
*
|
|
86
273
|
* https://vike.dev/onBeforeRoute
|
|
87
274
|
*/
|
|
88
|
-
onBeforeRoute?:
|
|
275
|
+
onBeforeRoute?: OnBeforeRouteAsync | OnBeforeRouteSync | ImportString;
|
|
89
276
|
/** Hook called after the page is hydrated.
|
|
90
277
|
*
|
|
91
278
|
* https://vike.dev/clientRouting
|
|
92
279
|
*/
|
|
93
|
-
onHydrationEnd?:
|
|
280
|
+
onHydrationEnd?: OnHydrationEndAsync | OnHydrationEndSync | ImportString;
|
|
94
281
|
/** Hook called before the user navigates to a new page.
|
|
95
282
|
*
|
|
96
283
|
* https://vike.dev/clientRouting
|
|
97
284
|
*/
|
|
98
|
-
onPageTransitionStart?:
|
|
285
|
+
onPageTransitionStart?: OnPageTransitionStartAsync | OnPageTransitionStartSync | ImportString;
|
|
99
286
|
/** Hook called after the user navigates to a new page.
|
|
100
287
|
*
|
|
101
288
|
* https://vike.dev/clientRouting
|
|
102
289
|
*/
|
|
103
|
-
onPageTransitionEnd?:
|
|
290
|
+
onPageTransitionEnd?: OnPageTransitionEndAsync | OnPageTransitionEndSync | ImportString;
|
|
104
291
|
/** Whether the UI framework (React/Vue/Solid/...) allows the page's hydration to be aborted.
|
|
105
292
|
*
|
|
106
293
|
* https://vike.dev/clientRouting
|